<!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>
    <!--*******************
        Preloader end
    ********************-->

    <!--**********************************
        Main wrapper start
    ***********************************-->
    <div id="main-wrapper">

      <?php  $this->load->view('header'); ?>
        
        <!--**********************************
            Content body start
        ***********************************-->
        <div class="content-body">
            <!-- row -->
            <div class="container-fluid">
                    
                <div class="row page-titles mx-0">
                    <div class="col-sm-6 p-md-0">
                        <div class="welcome-text">
                            <h4>Add Tranform Assembled Form</h4>
                        </div>
                    </div>
                    <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="index.html">Home</a></li>
                           
                        </ol>
                    </div>
                </div>
                
                <div class="row">


                    <div class="col-12">
            
                               
                            
                          <div class="col-xl-12 col-xxl-12 col-sm-12">
                             <div class="card">

                               <?php echo form_open(base_url(''),array('class'=>"form-horizontal add_batch", 'id'=>"add_batch")); ?>
                                    
                                        <?php if($this->session->flashdata('party_success')){ ?>
                                <div class="alert alert-success solid" style='text-align:center;'><?php echo $this->session->flashdata('party_success'); ?></div>
                            <?php } ?> 
                                <div class="card-body">
                                    <div id='party_success' class='alert alert-success solid' style='display:none;'></div>
                                      
                                    <div id='validate' class='alert alert-danger solid' style='display:none;'></div>

                                    <div class="row">
                                    <?php foreach($transform_data_printing as $dd){ ?>
                                    <div class="col-lg-2 col-md-6 col-sm-12">
                                                     <div class="form-group">
                                                    <label class="badge badge-danger" >Assemble Item:</label>
                                                 
                                                   <?php $con = batch_product_ass($dd['batch']); 
                                                     if($con ==0){ ?>
                                                     <input type="text" value="<?php echo batch_product($dd['batch']); ?>" readonly="readonly" required="required"  class="form-control ">
                                                     <br/><label class="badge badge-success" >Code Item:</label>
                                                     <input type="text" value="<?php    
                                                        $product = batch_product($dd['batch']); 
                                                        $pro_id = product_id($product);
                                                       echo product_code($pro_id);
                                                     ?>" readonly="readonly" required="required"  class="form-control ">
                                             
                                                     <?php 
                                                     }else{ ?>

                                                      <input type="text" value="<?php echo product_name($con); ?>" readonly="readonly" required="required"  class="form-control ">
                                                      <br/><label class="badge badge-success" >Code Item:</label>
                                                      <input type="text" value="<?php    
                                                        $product = printing_product($dd['batch']); 
                                                        $pro_id = product_code($product);
                                                       echo $pro_id; ?>"
                                                        required="required"  class="form-control ">
                                             
                                                 <?php
                                                     }
                                                   ?>
                                                   
                                                     </div>
                                                </div>
                                                <?php } ?>
                                    </div><br/>
                                   
                                    <div class="row">
                                            
                                                    <input type="hidden" name="created" id="created" value="<?php echo date('Y-m-d H:i:s'); ?>" class="form-control required">
                                              
                                                    <input type="hidden" value="<?php echo $this->session->userdata('id'); ?>" name="user_id" id="user_id" class="form-control required">

                                                    <input type="hidden" name="id" id="id" value="<?php echo $this->uri->segment('3'); ?>" class="form-control required">
                                                   

                                                  <div class="col-lg-2 col-md-6 col-sm-12">
                                                     <div class="form-group">
                                                    <label class="form-label">Batch:</label>
                                                   
                                                    <input type="text" name="batch_no" value="<?php echo batch_no($transform_data_printing[0]['batch']); ?>" readonly="readonly" required="required"  class="form-control job">
                                                    <input type="hidden" id="batch_id" value="<?php echo $transform_data_printing[0]['batch']; ?>" name="batch_id" readonly="readonly" required="required"  class="form-control job">
                         
                                                     </div>
                                                </div>

                                                <div class="col-lg-4 col-md-6 col-sm-12">
                                                     <div class="form-group">
                                                    <label class="form-label">Product:</label>
                                                   
                                                    <input type="text" id="item" value="<?php echo batch_product_FG($transform_data_printing[0]['batch']); ?>" name="item" readonly="readonly" required="required"  class="form-control job">
                         
                                                     </div>
                                                </div>

                                                <div class="col-lg-2 col-md-6 col-sm-12">
                                                     <div class="form-group">
                                                    <label class="form-label">Transform:</label>
                                                    <select  data-live-search="true" class="form-control transform"  name="transform" required="required" id="product_id">
                                                        <option value="">Select Product</option>
                                                        <?php foreach ($get_semi as $product) { ?>
                                                        <option value="<?php echo $product['id']; ?>"><?php echo $product['name']; ?></option>
                                                    <?php } ?>
                                                    </select>

                                                     </div>
                                                </div>

                                              

                                                <div class="col-lg-2 col-md-6 col-sm-12">
                                                     <div class="form-group">
                                                    <label class="form-label">Batch Size :</label>
                                                    <?php
                                                          $product_name=batch_product($transform_data_printing[0]['batch']);
                                                          $Total_batch_qty =  batch_qty($transform_data_printing[0]['batch']);
                                                          $pro_batch_printing = pro_batch_printing($transform_data_printing[0]['batch']);
                                                          $result  = get_transform_qty_printing($transform_data_printing[0]['batch'],$pro_batch_printing);
                                                         
                                                    
                                                    ?>
                                                    <input type="text" readonly name="total_qty" value="<?php echo $Total_batch_qty; ?>" required="required"  class="form-control job">
                                                
                                                     </div>
                                                </div>

                                                <div class="col-lg-2 col-md-6 col-sm-12">
                                                     <div class="form-group">
                                                    <label class="form-label">Total Rejection Qty:</label>
                                                    
                                                    <input type="text" id="rej_qty"  name="rej_qty" required="required"  class="form-control job">
                         
                                                
                                                     </div>
                                                </div>

                                                <div class="col-lg-2 col-md-6 col-sm-12">
                                                     <div class="form-group">
                                                    <label class="form-label">Remaining Qty:</label>
                                                    
                                                    <?php
                                                        $btach_no = batch_no($transform_data_printing[0]['batch']);
                                                      $pro_batch_printing = pro_batch_sealing($btach_no);
                                                     
                                                      $Total_batch_qty1 =  get_transform_qty_sealed($btach_no,$pro_batch_printing); ?>

                                                    <input type="text" readonly id="remaining" value="<?php echo $Total_batch_qty-$Total_batch_qty1; ?>"  name="remaining" required="required"  class="form-control remaining">
                         
                                                
                                                     </div>
                                                </div>

                                                <div class="col-lg-2 col-md-6 col-sm-12"> 
                                                     <div class="form-group">
                                                    <label class="form-label">Qty:</label>
                                                   
                                                    <input type="text" id="transform_qty"   name="transform_qty" required="required"  class="form-control job">
                         
                                                
                                                     </div>
                                                </div>
                                               
                                                <div class="col-lg-2 col-md-6 col-sm-12">
                                                     <div class="form-group">
                                                    <label class="form-label">Transfer To:</label>
                                                    <select  data-live-search="true" class="form-control depart"  name="depart" required="required" id="product_id">
                                                        <option>Select Depart</option>
                                                        <?php foreach($dep as $deps){ ?>
                                                            <option value="<?php echo $deps['id']; ?>"><?php echo $deps['name']; ?></option>
                                                        <?php } ?>
                                                    </select>

                                                     </div>
                                                </div>
                                             </div>
                                          <button type="submit" id="dis_submit" class="btn btn-primary">Save <i class="icon-arrow-right14 position-right"></i></button>
                               
                                     <?php form_close();?>
                                </div>
                                     
                                
                            </div>

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

                   
                </div>
            </div>
       
        <!--**********************************
            Content body end
        ***********************************-->


        <!--**********************************
            Footer start
        ***********************************-->
        
        <!--**********************************
            Footer end
        ***********************************-->

        <!--**********************************
           Support ticket button start
        ***********************************-->

        <!--**********************************
           Support ticket button end
        ***********************************-->


    </div>
    <!--**********************************
        Main wrapper end
    ***********************************-->

    <!--**********************************
        Scripts
    ***********************************-->
    <!-- Required vendors -->
         <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
        <style>
        .redborder{
            border:1px solid red;
        }
        </style>

         <SCRIPT language=Javascript>
       
       function isNumberKey(evt)
       {
          var charCode = (evt.which) ? evt.which : evt.keyCode;
          if (charCode != 46 && charCode > 31 
            && (charCode < 48 || charCode > 57))
             return false;

          return true;
       }
       //-->
    </SCRIPT>
    <script type='text/javascript'>


var party = $('#add_batch');   
    
    party.on('submit',function(e){
        //$("#dis_submit").attr('disabled', true);
        e.preventDefault();
        
        var partydata = party.serialize();
        
      
            $.ajax({
                type:'POST',
                url:'<?php echo base_url('Stock/transform_page_assembled'); ?>',
                data:partydata,
                dataType:'json',
                success:function(data){
                    console.log('first'+data.status);
                    if(data.status === 'true'){
                        console.log('second'+data.status);
                        $('#party_success').show().html('Added Successfully').hide(3000);
                       setTimeout(function(){location.href="<?php echo base_url('Stock/batch_assembled_line'); ?>"} , 3000);
                    }else if(data.status == 'validate'){

                        $('#validate').show().html('Qty Greather Then Batch Qty...!');
                    }
                },
                error:function(data){console.log(data.responseText);}
            });
       // }
    });

       $("#product_id").change(function() {
    
        var id =  this.value;
        //alert(id);
        $.ajax({
                    type:'POST',
                    url:'<?php echo base_url('Sales_order/fg_product_code'); ?>',
                    data:{id:id},
                    dataType:'json',
                    success:function(data){
                        //console.log(data[0].material_code);
                        $('.pro_code').val(data[0].pro_code);
                        //$('.unit').val(data[0].unit);
                       
                       //$('.weight').val(data[0].weight);
                       
                    },
                    error:function(data){console.log(data.responseText);}
                });

    });

         $("#ref_code").change(function() {

          var id =  this.value;
       
        $.ajax({
                    type:'POST',
                    url:'<?php echo base_url('Sales_order/fg_product_rates'); ?>',
                    data:{id:id},
                    dataType:'json',
                    success:function(data){
                        //console.log(data[0].material_code);
                        $('#unit_rate').val(data[0].rates);
                        //$('.unit').val(data[0].unit);
                       
                       //$('.weight').val(data[0].weight);
                       
                    },
                    error:function(data){console.log(data.responseText);}
                });

    });
    
    $("#unit_rate,#quantity").keyup(function() {

        var gst = $('#gst').val();
       
            if(gst !=0){
          var aa = $('#unit_rate').val() * $('#quantity').val();
           var total = aa*1.17;
            }else{

                 var total = $('#unit_rate').val() * $('#quantity').val();
            }
           //var result = number_format(total);
         var output=parseInt(total).toLocaleString(); 
          $('#amount').val(output);

    });

 function addZeroes(ev) {
           
            // Convert input string to a number and store as a variable.
            var value = Number(ev.value);
            // Split the input string into two arrays containing integers/decimals
            var res = ev.value.split(".");
            // If there is no decimal point or only one decimal place found.
            if (res.length == 1 || res[1].length < 3) {
                // Set the number to two decimal places
                value = value.toFixed(4);
            }
            // Return updated or original number.
            if (ev.value != "") {
                ev.value = String(value);
            }
        }


          function delete_data_so(id) { 
        var id = id;
        if (confirm('Are you sure you want to Delete.?')) {
  
         $.ajax({
                type:'POST',
                url:'<?php echo base_url('Sales_order/sales_order_delete_data/'); ?>'+id,
                data:id,
                dataType:'json',
                success:function(data){
                    console.log('first'+data.status);
                    
                        console.log('second'+data.status);
                        //debugger;
                        $('#material_danger').show().html('Deleted Successfully');
                       setTimeout(function(){location.href="<?php echo base_url('Sales_order/all_sales_order'); ?>"} , 3000);
                    
                },
                error:function(data){console.log(data.responseText);}
            });
        } else {
  
            }
        } 


  
    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 = $('#main_product').val();
      
            $.ajax({
                type:'POST',
                url:'<?php echo base_url('Sales_order/all_sales_order'); ?>',
                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('Sales Order added Successfully');
                       setTimeout(function(){location.href="<?php echo base_url('Sales_order/all_sales_order/'); ?>"} , 2000);
                    }else if(data.check_status === 'true'){
                        $("#save_data").attr('disabled', false);
                               alert('Sales Order Number Already Created ....!');
                               $('#sales_order_success').show().html('Sales Order added Successfully');
                       setTimeout(function(){location.href="<?php echo base_url('Sales_order/all_sales_order/'); ?>"} , 2000);
                    }else{
                        console.log('third'+data);  
                    }
                },
                error:function(data){console.log(data.responseText);}
            });
       // }
    });

   



        $("#party_id").change(function() {
    
        var id =  this.value;

        $.ajax({
                    type:'POST',
                    url:'<?php echo base_url('Sales_order/parties_code'); ?>',
                    data:{id:id},
                    dataType:'json',
                    success:function(data){
                        //console.log(data[0].material_code);
                        $('.party_code').val(data[0].party_code);
                        //$('.code').val(data[0].pro_code);
                       
                       //$('.weight').val(data[0].weight);
                       
                    },
                    error:function(data){console.log(data.responseText);}
                });

    });


   



 function btnExport_monthly()
{
    
    var tab_text="<table border='2px'><tr bgcolor='#ebebeb'>";
    var textRange; var j=0;
    tab = document.getElementById('example5'); // id of table

    for(j = 0 ; j < tab.rows.length ; j++) 
    {     
        tab_text=tab_text+tab.rows[j].innerHTML+"</tr>";
        //tab_text=tab_text+"</tr>";
    }

    tab_text=tab_text+"</table>";
    tab_text= tab_text.replace(/<A[^>]*>|<\/A>/g, "");//remove if u want links in your table
    tab_text= tab_text.replace(/<img[^>]*>/gi,""); // remove if u want images in your table
    tab_text= tab_text.replace(/<input[^>]*>|<\/input>/gi, ""); // reomves input params


    var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE "); 

    if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))      // If Internet Explorer
    {
        txtArea2.document.open("txt/html","replace");
        txtArea2.document.write(tab_text);
        txtArea2.document.close();
        txtArea2.focus(); 
        sa=txtArea2.document.execCommand("SaveAs",true,"Generation_School_Report");
    }  
    else                 //other browser not tested on IE 11
        sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));  

    return (sa);
}
    
    </script>   

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

<!-- 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 -->
</html> 