<?php require_once('../auth/auth.php');?>
<?php 
  $acid = $_GET['acid'];
   $active= mysqli_fetch_assoc(mysqli_query($conn,"SELECT active FROM accounts WHERE acid='$acid'  LIMIT 1"))['active'];
if ($active==0) {
	$currentMode= "Deactive";
}else if ($active==1) {
	$currentMode= "Active";
}
 ?>
<section class="content">
 <div class="container-fluid">
  <div class="row">
  	<div class="col-md-3"></div>
    <div class="col-md-6">
      <div class="card card-primary card-outline direct-chat direct-chat-primary shadow-none" style="border-left:1px solid #969c9d;border-right:1px solid #969c9d;border-bottom:1px solid #969c9d;">
        <div class="card-header" style="padding: 3px 8px;">
          <h3 class="card-title">Update status </h3>
          <div class="card-tools">
            <!-- <span title="3 New Messages" class="badge bg-primary">3</span> -->
            <button type="button" class="btn btn-tool" data-card-widget="remove">
              <i class="fas fa-times"></i>
            </button>
          </div>
        </div>


        <form id="active_form" action="#" method="post" autocomplete="off">
        	<input type="hidden" name="status_acid" value="<?php echo $acid ?>">
        	<div class="card-body">
        		<div class="col-md-12">
        			<div class="row">
        				<div class="col-md-1">	</div>
        				<div class="col-md-10">
        					<div class="form-group">
                                <label>Select Status          </label>
                                 <dt id="show" style="float: right;">  <span class="right badge badge-danger"><?php echo $currentMode ?></span></dt>
                                 <select id="active_acid"  name="active_status" class="form-control select2" style="width: 100%;" required="true">
                                 	<option value="<?php echo $active ?>"><?php echo $currentMode ?> </option>
                                 	<option value="1">Active </option>
                                 	<option value="0"> Unactive</option>
                               
                                 </select>
                            </div>
        				</div>
        				<div class="col-md-1">	</div>
        			</div>
        		</div>
        	</div>

        	<center>
        		<div class="card-footer" style="padding: 8px 5px;">
        			<button type="submit" id="save" class="btn btn-success btn-xs">Update </button>
        		</div>
        	</center>
        </form>



       </div> 
     </div>
     <div class="col-md-3"></div>
   </div>
 </div>
</section>
<script>
$(document).ready(function() {
$("#active_acid").select2();

$('#active_form').on('submit', function(e){
$('#save').prop('disabled', true);
$('#save').html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> '+'Loading...');
e.preventDefault();  
     $.post("../accounts/add_accounts_db.php",$(this).serialize(),function(data){
     $('#active_form')[0].reset();
     $('#save').prop('disabled', false);
     $('#save').html('Update ');
             toastr.success(Showing, '<?php echo "$currentMode" ?>');

   });
  });
});  
</script>

