<?php require_once('../auth/auth.php');require_once('../auth/function.php');?>
<?php
$insid = $_GET['insid'];

    @$get_acid=mysqli_fetch_assoc(mysqli_query($conn,"SELECT acid FROM intallment WHERE  insid='$insid' LIMIT 1 "))['acid'];


$inschat_query= mysqli_query($conn,"SELECT *,accounts.ac_name,accounts.acid,accounts.ac_alise,accounts.ac_number,accounts.balance,accounts.outlet_id FROM (intallment
INNER JOIN accounts ON intallment.acid = accounts.acid)
WHERE intallment.acid='$get_acid' ;") or die (mysqli_error($conn));
$ins_row= mysqli_fetch_assoc($inschat_query);

?>
<section class="content">
  <div class="row">
    <div class="col-md-12">
      <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"> <?php echo language(364); ?>  <strong class="ml-3 text-danger"> <?php echo @$ins_row['ac_name']; ?>  >>  <?php echo @$ins_row['ins_date']; ?> </strong>
          </h3>
          <div class="card-tools m-0">
            <button type="button" class="btn btn-tool" data-card-widget="remove" data-dismiss="modal">
            <i class="fas fa-times"></i>
            </button>
          </div>
        </div>
        <div class="card-body">
          <form id="insremark_form" class="mt-2" action="#" method="post" autocomplete="off">
            <div class="col-md-12">
              <div class="row mt-2">
                <input type="hidden" name="insid" value="<?php echo $insid; ?>">
                
                <div class="col-md-12">
                  <div class="form-group">
                    <label><?php echo language(361);?></label>
                    <textarea name="ins_remark"  class="form-control form-control-sm" cols="2" rows="2"  required="true">N/A</textarea>
                  </div>
                </div>
                
                <div class="col-md-4"> </div>
                <div class="col-md-4">
                  <div class="form-group">
                    <center><label><?php echo language(365);?></label></center>
                    <input type="text" name="next_ins_date" class="form-control form-control-sm" onmouseover="stdate(this)" style="text-align:center;" readonly="true" required="true" value="<?php echo $date;?>">
                  </div>
                </div>
                <div class="col-md-4"> </div>
                
                
              </div>
            </div>
            <center>
            <div class="card-footer" style="padding: 8px 5px;">
              <button type="submit" id="save" class="btn btn-success btn-xs"><?php echo language(23);?></button>
              <button type="reset" class="btn btn-secondary btn-xs"><?php echo language(24);?></button>
            </div>
            </center>
          </form>


                <div class="card-body p-1">
                  <tr>
                     <th rowspan="3"  class="text-center" >
                        <input type="text" id="search" class="form-control form-control-sm search"  placeholder="searching" required="true" style="border-radius: ;border:1px solid primary;width:100%; text-align:center; padding:; ">
                     </th>
                  </tr>
            <table class="table table-sm table-head-fixed text-nowrap table-hover table-bordered " style="overflow-x:auto;">
                     <thead>
                        <tr class="sticky-top">
                           <th class="text-center" style="width:5%;"><?php echo language(15);?></th>
                           <th class="text-center"><?php echo 'Change Date'; ?></th>
                           <th class="text-center"><?php echo 'Narrarion '; ?></th>
                           <th class="text-center"><?php echo language(131);?></th>
                        </tr>
                     </thead>
                     <tbody id="colview">
                        <?php
                           $chat_query= mysqli_query($conn,"SELECT * FROM `ins_chat` WHERE insid='$insid'  ") or die (mysqli_error($conn));
                           $i=0;
                           while ($rowc= mysqli_fetch_array ($chat_query) ){ ?>
                        <tr class="btn-outline-dark tr-hover delete_op">
                           <td class="text-center"><?php echo ++$i ?></td>
                           <td class="text-center"> <?php echo $rowc['subdate'] ;?> </td>
                           <td class="text-center"> <?php echo $rowc['comments'] ;?> </td>
       
                           <td class="text-center"><?php echo $rowc['date'];?></td>
                        </tr>
                        <?php } ?>
                     </tbody>
                  </table>
               </div>
          
        </div>
      </div>
    </div>
  </div>
</section>

<script>
   $(document).ready(function() {
          $("select").select2();
     $('#insremark_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("../remark/ins_remark_index_db.php",$(this).serialize(),function(data){
          $('#insremark_form')[0].reset();
          $('#save').prop('disabled', false);
          $('#save').html('Save');
             $.post('../remark/ins_remark_index.php?bid='+<?php echo $bid ?>+'&insid=<?php echo $insid ?>',{},function(res){
                $('#mdview').html(res);
             }); 
             toastr.success(Showing, '<?php echo "New Customer Add Successful" ?>');
          
     });
    });
   
   });  
</script>