<?php require_once('head.php'); ?>

  <body>
  <!-- container section start -->
  <section id="container" class="">
      
	<?php require_once('header.php'); ?>	

	<?php require_once('sidebar.php'); ?>
      
      <!--main content start-->
      <section id="main-content">
          <section class="wrapper">

			  <div class="row">
                  <div class="col-lg-12">
                      <!--breadcrumbs start -->
                      <ul class="breadcrumb">
                          <li><a href="dashboard.php"><i class="icon_house_alt"></i> Home</a></li>
                          <li class="active"> SMS</li>
						  <li class="pull-right"> <i class="icon_calendar"></i>
							 <?php echo date('l jS F Y'); ?></li>
                      </ul>
                      <!--breadcrumbs end -->
                  </div>
              </div>
			  
			  <div class="row">
					<div class="col-lg-12">
					<section class="panel panel-body">
					<h3><?php echo WEB_NAME ?></h3>
					<h4>ACCOUNT SMS ALERTS</h4>
					<p>Find below SMS alerts sent to clients phone from account officer</p>
					<h4>SMS CREDITS (REMAINING): <span class="badge bg-success"> <span></h4>
					</section>
					</div>
              </div>
			  
				<!-- Messages Starts -->
				<div class="row">
			    <div class="col-sm-12">
				  <section class="panel">
					  <header class="panel-heading">
						  Account SMS Alerts
					  </header>
					  <!--collapse start-->
                      <div class="panel-group m-bot20" id="accordion">
					  
					  <?php
										dbconnect();
										$sql = "SELECT * FROM `".SMS_TABLE_NAME."` ORDER BY sms_date DESC";
										$stmt = $pdo->query($sql);
										while($row = $stmt->fetch(PDO::FETCH_ASSOC)){ 
									?> 
					  
                          <div class="panel panel-default">
                              <div class="panel-heading">
                                  <h4 class="panel-title">
                                      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapse<?php echo $row['sms_id']; ?>">
									  
									  <i class="icon-warning-sign"></i>
									  
                                          <?php echo substr($row['sms_cnt'], 0, 20); ?>...
                                      </a>
									  
									  <div class="date pull-right">
										<?php echo $row['sms_rcvr']; ?> | <?php echo date('jS F Y', strtotime($row['sms_date'])); ?> | <a href="delete-sms.php?smsid=<?php echo $row['sms_id']; ?>&user=<?php echo $row['sms_rcvr']; ?>" onclick="javascript:return confirm('Are you sure you want to delete this SMS?');">Delete</a>
										</div>
									  
                                  </h4>
                              </div>
                              <div id="collapse<?php echo $row['sms_id']; ?>" class="panel-collapse collapse">
                                  <div class="panel-body">
                                      <?php echo $row['sms_cnt']; ?>
                                  </div>
                              </div>
                          </div>
						  
						  <?php } ?>
						  
                      </div>
                      <!--collapse end-->
				  </section>
			  </div>
			  </div>
			  <!-- Messages end -->
			  
			  
			  <!-- Add Messages Starts -->
			  <div class="row">
                  <div class="col-lg-12">
                      <section class="panel">
                          <header class="panel-heading">
                              Send New SMS Alert
                          </header>
						  
						  <div class="panel-body">
						  
						  <!-- Error Message -->
							<?php if (!empty($_GET['error'])): ?>
							<div class="alert fade in alert-danger">
								<button data-dismiss="alert" class="close close-sm" type="button">
								<i class="icon-remove"></i>
								</button>
								<?php echo $_GET['error']?>
							</div>
							<?php endif ?>
							
							<!-- Success Message -->
							<?php if (!empty($_GET['msg'])): ?>
							<div class="alert fade in alert-success">
								<button data-dismiss="alert" class="close close-sm" type="button">
								<i class="icon-remove"></i>
								</button>
								<?php echo $_GET['msg']?>
							</div>
							<?php endif ?>
							
						  
                           <form method="post" enctype="multipart/form-data" class="form-validate form-horizontal" id="alrt-form" action="sms-sent.php">
								
								<div class="form-group">
								
								<?php
										dbconnect();
										$sql = "SELECT user_name, user_acc FROM `".USERS_TABLE_NAME."` WHERE user_status='1' ORDER BY user_name ASC";
										$stmt = $pdo->query($sql);
										?>
									<label class="col-md-4 control-label">To </label>
									<div class="col-md-6">
										<select id="alrt_rcvr" name="alrt_rcvr" class="form-control" required>

<?php while($row = $stmt->fetch(PDO::FETCH_ASSOC)){ ?>
											<option value='<?php echo $row['user_name']; ?>'><?php echo $row['user_name']; ?>
											</option>
												<?php }  ?>
											</select>
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-4 control-label">Message </label>
									<div class="col-md-6">
									
									<textarea rows="3" cols="5" name="alrt_cnt" class="auto form-control required" placeholder="Enter the alert message" style="overflow: hidden; word-wrap: break-word; resize: horizontal; height: 80px;" required></textarea>
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-4 control-label"></label>
									<div class="col-md-6">
									
									<input type="submit" id="submit" name="submit" value="Send SMS Alert" class="btn btn-primary pull-left">
									</div>
								</div>
							</form>
							
							</div>
                      </section>
                  </div>
              </div>
			  <!-- Add Messages end -->

              

          </section>
      </section>
      <!--main content end-->
  </section>
  <!-- container section start -->

    <!-- javascripts -->
    <script src="../js/jquery.js"></script>
    <script src="../js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="../js/jquery-ui-1.9.2.custom.min.js"></script>
    <!-- bootstrap -->
    <script src="../js/bootstrap.min.js"></script>
    <!-- nice scroll -->
    <script src="../js/jquery.scrollTo.min.js"></script>
    <script src="../js/jquery.nicescroll.js" type="text/javascript"></script>
	
	<!-- jquery validate js -->
    <script type="text/javascript" src="../js/jquery.validate.min.js"></script>

    <!-- custom form validation script for this page-->
    <script src="../js/form-validation-script.js"></script>

    <!-- custom select -->
    <script src="../js/jquery.customSelect.min.js" ></script>
    <!--custome script for all page-->
    <script src="../js/scripts.js"></script>


  </body>
</html>