<?php require_once('../auth/auth.php'); ?>
<div class="row">
   <div class="col-md-2"></div>
   <div class="col-md-8">
      <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(22)?></h3>
            <div class="card-tools m-0">
               <button type="button" class="btn btn-tool" data-card-widget="remove">
               <i class="fas fa-times"></i>
               </button>
            </div>
         </div>
         <form id="its_form" action="#" method="post" autocomplete="off">
            <div class="card-body">
               <div class="col-md-12">
                  <div class="row">
                     <div class="col-md-4">
                        <div class="form-group">
                           <label><?php echo language(69)?><b class="text-danger"> * </b></label>
                           <select name="item_gid" class="form-control" required="true">
                              <?php 
                                 $pgroup_query= mysqli_query($conn,"SELECT pgid,pgroup_name FROM item_group  WHERE coid='$coid' AND bid='$bid' AND active=1 ORDER BY pgid ASC") or die (mysqli_error($conn));
                                 while($rowgroup= mysqli_fetch_assoc($pgroup_query)){
                                   echo '<option value='.$rowgroup["pgid"].'>'.$rowgroup["pgroup_name"].' </option>';
                                 }?> 
                           </select>
                        </div>
                     </div>
                     <div class="col-md-4">
                        <div class="form-group">
                           <label><?php echo language(70)?><b class="text-danger"> * </b></label>
                           <select name="item_cid" class="form-control" required="true">
                              <?php 
                                 $pcatt_query= mysqli_query($conn,"SELECT pcid,pcat_name FROM item_catagory  WHERE coid='$coid' AND bid='$bid' AND active=1 ORDER BY pcid ASC") or die (mysqli_error($conn));
                                 while($rowcat= mysqli_fetch_assoc($pcatt_query)){
                                   echo '<option value='.$rowcat["pcid"].'>'.$rowcat["pcat_name"].' </option>';
                                 }?> 
                           </select>
                        </div>
                     </div>
                     <div class="col-md-4">
                        <div class="form-group">
                           <label><?php echo language(71)?><b class="text-danger"> * </b></label>
                           <select name="item_brnd" class="form-control" required="true">
                              <option></option>
                              <?php 
                                 $pbrand_query= mysqli_query($conn,"SELECT pbid,pbrand_name FROM item_brand  WHERE coid='$coid' AND bid='$bid' AND active=1 ORDER BY pbid ASC") or die (mysqli_error($conn));
                                 while($rowbrand= mysqli_fetch_assoc($pbrand_query)){
                                   echo '<option value='.$rowbrand["pbid"].'>'.$rowbrand["pbrand_name"].'</option>';
                                 }?> 
                           </select>
                        </div>
                     </div>
                  </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(95)?> <i class="fa fa-arrow-right" aria-hidden="true"></i></button>
               </div>
            </center>
         </form>
      </div>
   </div>
   <div class="col-md-2"></div>
</div>
<script>
   $(document).ready(function(){
     $("select").select2();
     $('#its_form').on('submit', function(e){
      e.preventDefault();
     $('#save').prop('disabled', true);
     $('#save').html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> '+'Loading...');
     e.preventDefault();  
     $.get("../itemstock/item_addn.php",$(this).serialize(),function(data){
      $('#its_form')[0].reset();
      $('#save').prop('disabled', false);
      $('#save').html('Save');
      $('#item_profile').html(data);
       toastr.success(Showing, '<?php echo "Data Load Succefully" ?>'); 
    });
   });
  });  
</script>