 <!DOCTYPE html>
<html lang="en">


<!-- Mirrored from edumin.dexignlab.com/xhtml/add-departments.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Nov 2020 13:56:15 GMT -->
<head>
  
   <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Rizwan </title>
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="<?php echo base_url();?>assets/images/favicon.png">
    <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/bootstrap-select/dist/css/bootstrap-select.min.css">
    <link rel="stylesheet" href="<?php echo base_url();?>assets/css/style.css">
    <!-- Pick date -->
   <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/pickadate/themes/default.css">
    <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/pickadate/themes/default.date.css">
     <link href="<?php echo base_url();?>assets/vendor/datatables/css/jquery.dataTables.min.css" rel="stylesheet">
    <!-- Custom Stylesheet -->
     

</head>

<body>

    <!--*******************
        Preloader start
    ********************-->
        <div id="preloader">
        <div class="sk-three-bounce">
            <div class="sk-child sk-bounce1"></div>
            <div class="sk-child sk-bounce2"></div>
            <div class="sk-child sk-bounce3"></div>
        </div>
    </div>


 <div id="main-wrapper">
 	<?php  $this->load->view('header'); ?>
 <div class="content-body">
            <!-- row -->
            <div class="container-fluid">

 <div class="row">


                    <div class="col-12">
                      
       
                             <div class="card">
                               
                              <?php echo form_open(base_url(''),array('class'=>"form-horizontal add_sales_order", 'id'=>"add_sales_order")); ?>

                                <div class="card-body">
                                    <div id='sales_order_success' class='alert alert-success solid' style='display:none;'></div>
                                       <div class="row">


                                           <input type="hidden" name="id" id="plan_id" value="<?php echo $this->uri->segment('3'); ?>">
                                            <input type="hidden" name="so_id" id="so_id" value="<?php echo $this->uri->segment('4'); ?>">

                                             <input type="hidden" name="product_id" id="product_id" value="<?php echo $this->uri->segment('5'); ?>">

                                           
                                            <div class="col-lg-2 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Job No:</label>
                                                    <input type="text" id="job" name="job" value="<?php echo $get_plan[0]['job']; ?>" readonly="readonly"  class="form-control job">
                                                 </div>
                                                </div>


                                            <div class="col-lg-3 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Item:</label>
                                                    <input type="text" id="product_name" name="product_name" value="<?php echo $get_plan[0]['product_name']; ?>" readonly="readonly" style="font-size:12px;" class="form-control product_name">
                                                 </div>
                                                </div>  


                                                   


                                                 <div class="col-lg-2 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Production Qty:</label>
                                                    <?php 

                                                   /* $total_in_stock =  get_in_balance($this->uri->segment('4'))-get_out_balance($this->uri->segment('4'));  

                                                        $condi = $total_in_stock - $get_plan[0]['p_qty'];

                                                        if($get_plan[0]['p_qty']  > $condi){

                                                                $total = abs($total_in_stock - $get_plan[0]['p_qty']);

                                                        }else{

                                                              $total = abs($total_in_stock - $get_plan[0]['p_qty']);
                                                        }*/
                                                    ?>
                                                    <input type="text" id="pro_qty" name="pro_qty" value="<?php echo $get_plan[0]['pro_qty'];  ?>" readonly="readonly"  class="form-control pro_qty">
                                                 </div>
                                                </div>   

                                            <div class="col-lg-3 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Material:</label>
                                                    
                                                       <select data-live-search="true" name="material_id" required="required" id="material_id" class="form-control material_ids">
                                                        <option value="<?php echo $get_plan[0]['material_id']; ?>"><?php echo material_name($get_plan[0]['material_id']); ?></option> 
                                                       
                                                     
                                                    
                                                  </select>
                                                 </div>
                                                </div>


                                                <div class="col-lg-2 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label"> BOM-QTY:</label>
                                                      <input type="text" name="bom_qty"  id="bom_qty" value="<?php echo $get_plan[0]['bom_qty']; ?>" readonly="readonly"  class="form-control bqty">
                                                 </div>
                                                </div>

                                                 <div class="col-lg-2 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label"> BOM-Unit:</label>
                                                      <input type="text" name="bom_unit"  id="bom_unit" value="<?php echo $get_plan[0]['bom_unit']; ?>" readonly="readonly"  class="form-control bom_unit">
                                                 </div>
                                                </div>

                                                <div class="col-lg-2 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label"> IN Stock-QTY/Bag:</label>
                                                      <input type="text" name="in_stock_qty"  id="in_stock_qty" value="<?php echo $get_plan[0]['in_stock_qty']; ?>" readonly="readonly"  class="form-control in_stock_qty">
                                                 </div>
                                                </div>


                                                <div class="col-lg-2 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Production QTY:</label>
                                                      <input type="text" name="p_qty"  id="p_qty" value="<?php echo $get_plan[0]['p_qty']; ?> "  required="required" class="form-control p_qty">
                                                 </div>
                                                </div>

                                               <!--   <div class="col-lg-3 col-md-6 col-sm-12">
                                                  <div class="form-group">
                                                      <label class="form-label">Color:</label>
                                                      <input type="text" id="color" name="color" readonly="readonly" class="form-control color">
                                                   </div>
                                                </div> -->
                                                    
                                                <div class="col-lg-3 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Color:</label>
                                                    
                                                       <select data-live-search="true" name="color_id" id="color_id" class="form-control color_id">
                                                        <option value="">Select Color</option> 
                                                       
                                                      <?php 

                                                          foreach ($get_material_data as $values) {  ?>

                                                        <?php  $type = material_type_po($values['material_id']);
                                                                if($type==3){
                                                         ?>    

                                                        <option value="<?php echo $values['material_id']; ?>"><?php echo material_name($values['material_id']); ?></option>
                                                        
                                                     <?php  } }?>
                                                    
                                                  </select>
                                                 </div>
                                                </div>

                                                <div class="col-lg-2 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label"> Color BOM-QTY:</label>
                                                      <input type="text" name="cqty"  id="cqty" value="<?php echo $get_plan[0]['cqty']; ?>" readonly="readonly"  class="form-control cqty">
                                                 </div>
                                                </div>

                                                 <div class="col-lg-2 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Unit:</label>
                                                      

                                                      <select data-live-search="true" name="bom_unit_color" id="bom_unit_color" class="form-control bom_unit_color">
                                                        <option value="<?php  echo $get_plan[0]['bom_unit_color']; ?>"><?php echo $get_plan[0]['bom_unit_color']; ?></option> 
                                                       
                                                   
                                                    
                                                  </select>
                                                 </div>
                                                </div>

                                                <div class="col-lg-2 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label"> Color Stock/KG:</label>
                                                      <input type="text" name="in_stock_qty_color" value="<?php echo $get_plan[0]['in_stock_qty']; ?> "  id="in_stock_qty_color" readonly="readonly"  class="form-control in_stock_qty_color">
                                                 </div>
                                                </div>

                                                <div class="col-lg-2 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Cutting Ratio/Bag:</label>
                                                      <input type="text" name="cutting_ratio" value="<?php echo $get_plan[0]['cutting_ratio']; ?> "   id="cutting_ratio"  class="form-control ">
                                                 </div>
                                                </div>  

                                                 <div class="col-lg-2 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label" style="font-size: 11px;">Semi Standard:</label>
                                                      <input type="text" name="semi_standard"  value="<?php echo $get_plan[0]['semi_standard']; ?>"id="semi_standard"  class="form-control" onkeypress="return isNumberKey(event)" >
                                                 </div>
                                                </div>  


                                                <div class="col-lg-2 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label" style="font-size: 11px;">Weight Standard(kg):</label>
                                                      <input type="text" name="weight_standard" value="<?php echo $get_plan[0]['weight_standard']; ?>"  id="weight_standard"  class="form-control"  onkeypress="return isNumberKey(event)" >
                                                 </div>
                                                </div>  

                                                <div class="col-lg-3 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Spacification No:</label>
                                                    
                                                      <input type="text" name="spec_no" readonly="readonly" value="<?php echo $get_plan[0]['spec_no']; ?> " required="required" id="spec_no"  class="form-control ">

                                                 </div>
                                                </div>

                                                <div class="col-lg-3 col-md-6 col-sm-12">
                                                  <div class="form-group">
                                                    <label class="form-label">Mould:</label>
                                                      <select data-live-search="true" name="mold" id="mold"  readonly="readonly" class="form-control" required="required">

                                                     <option value="<?php echo $get_plan[0]['mold']; ?>"><?php echo mold_code($get_plan[0]['mold']); ?>
                                                    </option>
                                                       
                                                      
                                                    
                                                  </select>
                                                       </div>

                                                </div>

                                               <!--   <div class="col-lg-3 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Machine:</label>
                                                      <select data-live-search="true" name="machine" id="machine" class="form-control" required="required">

                                                        <option>Select Machine</option>
                                                       
                                                      <?php 
                                                          foreach ($get_machine_data as $values) { ?>

                                                        <option value="<?php echo $values['id']; ?>"><?php echo $values['machine_name']; ?></option>
                                                        
                                                     <?php  } ?>
                                                    
                                                  </select>
                                                 </div>
                                                </div> -->


                                              <!--   <div class="col-lg-3 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Day Expected Production:</label>
                                                      <input type="date" name="day_expected" required="required" id="day_expected"  class="form-control ">
                                                 </div>
                                                </div> -->


                                                <div class="col-lg-3 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Status:</label>
                                                      <select data-live-search="true" name="complete_status" id="complete_status" class="form-control" required="required">

                                                    <?php if($get_plan[0]['complete_status']==0){ ?>
                                                    <option value="0">Active</option>
                                                    <?php }elseif($get_plan[0]['complete_status']==2){ ?>
                                                        <option value="2">Closed</option>
                                                    <?php } ?>                                                       
                                                     <option value="0">Active</option>
                                                    <option value="2">Closed</option>
                                                  </select>
                                                 </div>
                                                </div>


                                                 <div class="col-lg-3 col-md-6 col-sm-12" id="closed_qty" style="display: none;">
                                                <div class="form-group">
                                                    <label class="form-label">Closed Qty:</label>
                                                    
                                                      <input type="text" name="closed_qty" placeholder="Closed Quantity"   id="spec_no"   class="form-control" >

                                                 </div>
                                                </div>

                                                 <div class="col-lg-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Remarks:</label>
                                                      <textarea name="remarks" class="form-control" id="remarks"><?php echo $get_plan[0]['remarks']; ?></textarea> 
                                                 </div>
                                                </div>

                                               

                                                <input type="hidden" name="user_id" id="user_id" value="<?php echo $this->session->userdata('id');?>">

                                                <div class="col-lg-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                   
                                                    <input type="hidden" name="created" id="created" value="<?php echo date('Y-m-d H:i:s'); ?>" class="form-control required">
                                                </div>
                                            </div>

                                            <div class="col-lg-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                   
                                                    <input type="hidden" value="<?php echo date('Y-m-d H:i:s'); ?>" name="modified" id="modified" class="form-control required">
                                                </div>
                                            </div>
                                           
                                        
                                       </div>
                                         <button type="submit" id="dc_dis" class="btn btn-primary">Submit <i class="icon-arrow-right14 position-right"></i></button>
                                     </div>

                                      <?php form_close();?>
                                    </div>
                                    
                          
                           
                               
                                

                    </div>


                         
                  </div>
                    </div>
                      </div>

                </div>

       <?php  $this->load->view('footer'); ?>
       <script>

        $(function() {
            $('#closed_qty').hide(); 
            $('#complete_status').change(function(){
                if($('#complete_status').val() == 2) {
                    $('#closed_qty').show(); 
                } else {
                    $('#closed_qty').hide(); 
                } 
            });
        });
	
     var add_order = $('#add_sales_order');   
    
						    add_order.on('submit',function(e){

						        e.preventDefault();
						        $("#save_data").attr('disabled', true);
						        var add_add_order = add_order.serialize();
						         var id = $('#plan_id').val();
                     var so_id = $('#so_id').val();
                     var product_id = $('#product_id').val();
						      
						            $.ajax({
						                type:'POST',
						                url:'<?php echo base_url('Requisition/edit_plan_production/'); ?>'+id+'/'+so_id+'/'+product_id,
						                data:add_add_order,
						                dataType:'json',
						                success:function(data){
						                    console.log('first'+data.status);
						                    if(data.status === 'true'){
						                        console.log('second'+data.status);
						                        $('#sales_order_success').show().html('Update Successfully');
						                       setTimeout(function(){location.href="<?php echo base_url('Requisition/production_plan/'); ?>"} , 2000);
						                    }else{
						                        console.log('third'+data);          
						                    }
						                },
						                error:function(data){console.log(data.responseText);}
						            });
						       // }
						    });

                      </script>