<?php require_once('../auth/auth.php'); ?>
<?php 
$cfid_check_default = mysqli_query($conn,"SELECT cfid  FROM custom_field WHERE coid='$coid'");
 $count = mysqli_num_rows($cfid_check_default);
if($count < 1){
mysqli_query($conn,"INSERT INTO `custom_field`(`coid`,`userid`) VALUES ('$coid','$uid')")or die(mysqli_error($conn));
}
$custom_field= mysqli_query($conn,"SELECT item FROM custom_field WHERE coid='$coid' LIMIT 1 ") or die (mysqli_error($conn));
$rowcf= mysqli_fetch_assoc ($custom_field);
$p=$rowcf['item'];
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"> <?php echo language(235);?></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(235);?> </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(98);?>  </td>   
                                <td>
                                         <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                            <input type="checkbox" id="u_type" class="custom-control-input selectAll c_per"  name="cus_check[]" value="u_type" <?php echo checked('u_type');?>>
                                            <label class="custom-control-label" for="u_type"></label>
                                         </div>
                                </td>  
                            </tr>
                   
                           <tr>  
                                <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(99);?>   </td>   
                                <td>
                                         <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                            <input type="checkbox" id="p_tax" class="custom-control-input selectAll c_per"  name="cus_check[]" value="p_tax" <?php echo checked('p_tax');?>>
                                            <label class="custom-control-label" for="p_tax"></label>
                                         </div>
                                </td>  
                            </tr>
                            <tr>  
                                <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(100);?> </td>   
                                <td>
                                         <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                            <input type="checkbox" id="s_tax" class="custom-control-input selectAll c_per"  name="cus_check[]" value="s_tax" <?php echo checked('s_tax');?>>
                                            <label class="custom-control-label" for="s_tax"></label>
                                         </div>
                                </td>  
                            </tr>
                            <tr>  
                                <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(101);?>    </td>   
                                <td>
                                         <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                            <input type="checkbox" id="batch_id" class="custom-control-input selectAll c_per"  name="cus_check[]" value="batch_id" <?php echo checked('batch_id');?>>
                                            <label class="custom-control-label" for="batch_id"></label>
                                         </div>
                                </td>  
                            </tr>
                            
                            
                                <tr>  
                                <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(79);?>  </td>   
                                <td>
                                         <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                            <input type="checkbox" id="sku" class="custom-control-input selectAll c_per"  name="cus_check[]" value="sku" <?php echo checked('sku');?>>
                                            <label class="custom-control-label" for="sku"></label>
                                         </div>
                                </td>  
                            </tr>
                            
                            <tr>  
                                <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(102);?> </td>   
                                <td>
                                         <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                            <input type="checkbox" id="weight" class="custom-control-input selectAll c_per"  name="cus_check[]" value="weight" <?php echo checked('weight');?>>
                                            <label class="custom-control-label" for="weight"></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="item_disc" class="custom-control-input selectAll c_per"  name="cus_check[]" value="item_disc" <?php echo checked('item_disc');?>>
                                            <label class="custom-control-label" for="item_disc"></label>
                                         </div>
                                </td>  
                            </tr>
                 
               
                           <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(104);?> </td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="wharehouse" class="custom-control-input selectAll c_per"  name="cus_check[]" value="wharehouse" <?php echo checked('wharehouse');?>>
                                    <label class="custom-control-label" for="wharehouse"></label>
                                 </div>
                              </td>  
                           </tr> 
                           
                           
                            <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(105)?> </td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="op_stock_create" class="custom-control-input selectAll c_per" name="cus_check[]" value="op_stock_create" <?php echo checked('op_stock_create');?>>
                                    <label class="custom-control-label" for="op_stock_create"></label>
                                 </div>
                              </td>  
                           </tr> 
                           
                           
                          <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i>  <?php echo language(16);?></td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="t_group" class="custom-control-input selectAll c_per" name="cus_check[]" value="t_group" <?php echo checked('t_group');?>>
                                    <label class="custom-control-label" for="t_group"></label>
                                 </div>
                              </td>  
                           </tr> 
                           
                           <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(19);?></td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="t_category" class="custom-control-input selectAll c_per" name="cus_check[]" value="t_category" <?php echo checked('t_category');?>>
                                    <label class="custom-control-label" for="t_category"></label>
                                 </div>
                              </td>  
                           </tr> 
                           
                           
                           <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(85);?></td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="item_notif" class="custom-control-input selectAll c_per" name="cus_check[]" value="item_notif" <?php echo checked('item_notif');?>>
                                    <label class="custom-control-label" for="item_notif"></label>
                                 </div>
                              </td>  
                           </tr> 
                           
                             <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(87);?></td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="location" class="custom-control-input selectAll c_per" name="cus_check[]" value="location" <?php echo checked('location');?>>
                                    <label class="custom-control-label" for="location"></label>
                                 </div>
                              </td>  
                           </tr> 
                            <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(86);?></td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="war_type" class="custom-control-input selectAll c_per" name="cus_check[]" value="war_type" <?php echo checked('war_type');?>>
                                    <label class="custom-control-label" for="war_type"></label>
                                 </div>
                              </td>  
                           </tr> 
                             <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(77);?></td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="item_details" class="custom-control-input selectAll c_per" name="cus_check[]" value="item_details" <?php echo checked('item_details');?>>
                                    <label class="custom-control-label" for="item_details"></label>
                                 </div>
                              </td>  
                           </tr> 
                           
                            <tr>  
                              <td><i class="ion-ios-navigate-outline text-success"> </i> <?php echo language(386);?></td>   
                              <td>
                                 <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
                                    <input type="checkbox" id="emei_tracking" class="custom-control-input selectAll c_per" name="cus_check[]" value="emei_tracking" <?php echo checked('emei_tracking');?>>
                                    <label class="custom-control-label" for="emei_tracking"></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("../itemstock/setting_db.php",$('#cusper_form').serialize(),function(data){
       toastr.success(data, yourdata);
    });
   });
  });  
</script>



