<?php require_once('../auth/auth.php'); ?>
<?php 
$custom_field= mysqli_query($conn,"SELECT supplier FROM custom_field WHERE coid='$coid' LIMIT 1 ") or die (mysqli_error($conn));
$rowcf= mysqli_fetch_assoc ($custom_field);
$p=$rowcf['supplier'];
function checked($ap)
{
  if (strpos($GLOBALS['p'], $ap) !== false) {
    return $checked='checked';
 } else {
    return $checked='';
 }
}
?>

<section class="content">
   <div class="container-fluid">
      <div class="row">
         <div class="col-md-4">
            <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: 5px 8px;"><h3 class="card-title"></h3> <div class="card-tools"> <button type="button" class="btn btn-tool" data-card-widget="remove"> <i class="fas fa-times"></i>  </button> </div>
              </div>
            <form id="cusper_form" action="#" method="post" autocomplete="off">
              <input type="hidden" value="<?php echo $coid ?>" name="getcoid">
              <input type="hidden" value="" name="cus_check[]">
              <div class="card-body">
               <div class="col-md-12">
                  <div class="row" style="margin:3px;">
                     <div class="col-md-12">
                        <div class="card card card-outline direct-chat direct-chat shadow-none" style="border-left:1px solid #969c9d;border-right:1px solid #969c9d;border-bottom:1px solid #969c9d;">
                           <div class="card-header" style="background: #28a745;padding: 4px 8px;color: whitesmoke;">
                             <h3 style="float:left" class="card-title"> <?php echo language(40);?> </h3>
                             <div class="card-tools" >
                              <button type="button"  class="btn btn-tool" data-card-widget="remove"> <i class="fas fa-times" style="color: whitesmoke;"></i></button>
                             </div>
                           </div>
                           <table id="trbl_table" class="searchtable ttable" cellpadding="0" cellspacing="0">
                              <tr>  
                                 <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(222);?></td>  
                                 <td>
                                    <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                       <input type="checkbox" class="custom-control-input"  name="cus_check[]"  id="selectAllcus"/>
                                       <label class="custom-control-label" for="selectAllcus"></label>
                                    </div>
                                 </td>
                              </tr>  
                              <tr>  
                                 <td ><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(112);?> </td>  
                                 <td style="width: 5%">
                                    <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                       <input type="checkbox" id="email" class="custom-control-input selectAll c_per" c_per="email" name="cus_check[]" value="email" <?php echo checked('email');?>>
                                       <label class="custom-control-label" for="email"></label>
                                    </div>
                                 </td>  
                              </tr>  
                              <tr>  
                                 <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(117);?> </td>  
                                 <td>
                                    <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                      <input type="checkbox" id="nid" class="custom-control-input selectAll c_per" c_per="nid" name="cus_check[]" value="nid" <?php echo checked('nid');?>>
                                      <label class="custom-control-label" for="nid"></label>
                                   </div>
                                </td>  
                             </tr>  
                             <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(88);?></td>  
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="discount" class="custom-control-input selectAll c_per" c_per="discount" name="cus_check[]" value="discount" <?php echo checked('discount');?>>
                                    <label class="custom-control-label" for="discount"></label>
                                 </div>
                              </td>  
                           </tr>  
                           <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i>  <?php echo language(120);?> </td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="cr_limit" class="custom-control-input selectAll c_per" c_per="cr_limit" name="cus_check[]" value="cr_limit" <?php echo checked('cr_limit');?>>
                                    <label class="custom-control-label" for="cr_limit"></label>
                                 </div>
                              </td>  
                           </tr> 
                           <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(121);?></td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="bank_info" class="custom-control-input selectAll c_per" c_per="bank_info" name="cus_check[]" value="bank_info" <?php echo checked('bank_info');?>>
                                    <label class="custom-control-label" for="bank_info"></label>
                                 </div>
                              </td>  
                           </tr> 
                           <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(128);?> </td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="g_note" class="custom-control-input selectAll c_per" c_per="g_note" name="cus_check[]" value="g_note" <?php echo checked('g_note');?>>
                                    <label class="custom-control-label" for="g_note"></label>
                                 </div>
                              </td>  
                           </tr> 
                           <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(125);?></td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="vatno" class="custom-control-input selectAll c_per" c_per="vatno" name="cus_check[]" value="vatno" <?php echo checked('vatno');?>>
                                    <label class="custom-control-label" for="vatno"></label>
                                 </div>
                              </td>  
                           </tr> 
                           <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(126);?>  </td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="currency" class="custom-control-input selectAll c_per" c_per="vatno" name="cus_check[]" value="currency" <?php echo checked('currency');?>>
                                    <label class="custom-control-label" for="currency"></label>
                                 </div>
                              </td>  
                           </tr> 

                           <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(127);?></td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="p_terms" class="custom-control-input selectAll c_per" c_per="vatno" name="cus_check[]" value="p_terms" <?php echo checked('p_terms');?>>
                                    <label class="custom-control-label" for="p_terms"></label>
                                 </div>
                              </td>  
                           </tr> 
                           
                           <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(371);?></td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="s_address" class="custom-control-input selectAll c_per"  name="cus_check[]" value="s_address" <?php echo checked('s_address');?>>
                                    <label class="custom-control-label" for="s_address"></label>
                                 </div>
                              </td>  
                           </tr> 
                        </table> 
                     </div>  
                  </div>
               </div>
            </div>
         </div>
      </form> 
      </div>
   </div>
</div>
</div>
</section>
<script type="text/javascript">
   if ($('.selectAll:checked').length === $('.selectAll').length) {
      $('#selectAllcus').prop('checked', true);   
   }

   $('#selectAllcus').click(function(){
      $('.selectAll').prop('checked', true);
      if(!$(this).prop("checked")) {
         $('.selectAll').prop('checked', false);
      }
   });
   $('.selectAll').change(function() {
      if(!$(this).prop("checked")) {
         $('#selectAllcus').prop('checked', false);
      } else {
         if ($('.selectAll:checked').length === $('.selectAll').length) {
            $('#selectAllcus').prop('checked', true);
         }
      }
   });
</script>
<script>
   $(document).ready(function() {
     $('#cusper_form input[type=checkbox]').change(function(e) { 
      e.preventDefault(); 
      $.post("../supplier/setting_db.php",$('#cusper_form').serialize(),function(data){
       toastr.success(data, yourdata);
    });
   });
  });  
</script>



