        <!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>Moulds</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>
                                    <li class="breadcrumb-item active"><a href="javascript:void(0);">Moulds</a></li>
                                    <li class="breadcrumb-item active"><a href="javascript:void(0);">Add Moulds</a></li>
                                </ol>
                            </div>
                        </div>
        				
        				<div class="row">


                            <div class="col-12">
                                <div class="card">
                                    <div class="card-header">
                                       <button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bd-example-modal-lg">Add Moulds</button>
                                            <div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true">
                                                <div class="modal-dialog modal-lg">
                                                    <div class="modal-content">
                                                        <div class="modal-header">
                                                          
                                                            <button type="button" class="close" data-dismiss="modal"><span>&times;</span>
                                                            </button>
                                                        </div>
           <div class="modal-body">

         <?php echo form_open_multipart(base_url(''),array('class'=>"form-horizontal add_mold", 'id'=>"add_mold")); ?>
                    
                        <?php if($this->session->flashdata('mold_success')){ ?>
                <div class="alert alert-success solid" style='text-align:center;'><?php echo $this->session->flashdata('mold_success'); ?></div>
            <?php } ?>              

                    <div class="col-xl-12 col-xxl-12 col-sm-12">
                        <div class="card">
                            <div class="card-header">
                                <h5 class="card-title">Add Mold</h5>
                            </div>
                            <div class="card-body">
                               <div id='mold_success' class='alert alert-success solid' style='display:none;'></div>
                                    <div class="row">

                                        <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 class="col-lg-6 col-md-6 col-sm-12">
                                            <div class="form-group">
                                                <label class="form-label">Mold Code:</label>
                                                <input type="text" required="required" name="code" id="code" value="RA/"  class="form-control">
                                            </div>
                                        </div>
                                      
                                       
                                       <!--  <div class="col-lg-6 col-md-6 col-sm-12">
                                            <div class="form-group">
                                                <label class="form-label">Description:</label>
                                                    <input type="text" name="name" id="name" required="required" placeholder="Description" class="form-control">
                                            </div>
                                        </div> -->


                                         <div class="col-lg-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Component:</label>
                                                    
                                                       <select data-live-search="true" name="product_id" id="product_id" class="form-control product_id">
                                                        <option value="">Select Product</option>
                                                       
                                                      <?php 
                                                          foreach ($get_products as $values) { ?>

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



                                        <div class="col-lg-6 col-md-6 col-sm-12">
                                            <div class="form-group">
                                                <label class="form-label">Manufacture:</label>
                                                 <input type="text" name="manufacture" required="required" id="manufacture" placeholder="manufacture" class="form-control">
                                                <!--<select class="form-control" name="manufacture" required="required" id="manufacture" tabindex="-98">
                                                    <option value="">Select Manufacture</option>
                                                   <option value="Local">Local</option>
                                                    <option value="China">China</option>
                                                    </select>-->
                                            </div>
                                        </div>


                                        <div class="col-lg-6 col-md-6 col-sm-12">
                                            <div class="form-group">
                                                <label class="form-label">Mfg. Date:</label>
                                                    <input type="date" name="mfg_date" required="required" id="mfg_date" placeholder="Date" class="form-control">
                                            </div>
                                        </div>

                                        

                                        <div class="col-lg-6 col-md-6 col-sm-12">
                                            <div class="form-group">
                                                <label class="form-label">Cavity:</label>
                                                    <input type="text" name="cavity" id="cavity" placeholder="Cavity" class="form-control">
                                            </div>
                                        </div>
                                        
                                        <div class="col-lg-6 col-md-6 col-sm-12">
                                            <div class="form-group">
                                                <label class="form-label">Cycle Time (M.D.R.):</label>
                                                    <input type="text" name="cycle_time" required="required" id="cycle_time" placeholder="Cycle Time" class="form-control">
                                            </div>
                                        </div>


                                          <div class="col-lg-6 col-md-6 col-sm-12">
                                            <div class="form-group">
                                                <label class="form-label">Total Cost:</label>
                                                    <input type="number" name="cost" id="cost" required="required" placeholder="Cost" class="form-control">
                                            </div>
                                        </div>

                                          <div class="col-lg-6 col-md-6 col-sm-12">
                                            <div class="form-group">
                                                <label class="form-label">Shelf Life Actual(Pcs):</label>
                                                    <input type="number" id="self_life" name="self_life" placeholder="Self Life Actual" class="form-control">
                                            </div>
                                        </div> 

                                        <div class="col-lg-6 col-md-6 col-sm-12">
                                            <div class="form-group">
                                               <label class="form-label">Shelf Life Start(Pcs):</label>
                                                    <input type="number" name="self_life_start" id="self_life_start" placeholder="Selft Life Start" class="form-control">
                                            </div>
                                        </div>

                                    <div class="col-lg-6 col-md-6 col-sm-12">
                                            <div class="form-group">
                                               <label class="form-label">Shelf Life Remain(Pcs):</label>
                                                    <input type="number" name="self_life_remain" id="self_life_remain" placeholder="Selft Life Remain" class="form-control">
                                            </div>
                                        </div>



                                          <div class="col-lg-6 col-md-6 col-sm-12">
                                            <div class="form-group">
                                                <label class="form-label">Machine Type:</label>
                                                <select data-live-search="true" name="machine_type"  id="machine_type" class="form-control" tabindex="-98">
                                                    <option value="">Select Option</option>
                                                    <option value="2">Injection</option>
                                                   <option value="1">Blow</option>
                                                  
                                                   
                                                    </select>
                                            </div>
                                        </div>

                                    
                                        
                                    <!--<div class="col-lg-6 col-md-6 col-sm-12">
                                            <div class="form-group">
                                               <label class="form-label">QC Spec:</label>
                                                    <input type="text" name="qc_specs" id="qc_specs" placeholder="QC Specifications" class="form-control">
                                            </div>
                                        </div>-->

                                         <!-- <div class="col-lg-6 col-md-6 col-sm-12">
                                            <div class="form-group">
                                                <label class="form-label">Cost Required:</label>
                                                    <input type="text" name="cost_required" id="cost_required" placeholder="Cost Required" class="form-control">
                                            </div>
                                        </div>   -->


                                         <div class="col-lg-6 col-md-6 col-sm-12">
                                            <div class="form-group">
                                                <label class="form-label">Images:</label>
                                                    <input type="file" id="file" name='file'>

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



                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                    <button type="submit" id="dis_submit" class="btn btn-primary">Submit <i class="icon-arrow-right14 position-right"></i></button>
                </div>
                    <?php form_close();?>
            </div>


        </div>
    </div>
                                    </div>
                                    <div class="card-body">
                                          <?php if($this->session->flashdata('mold_danger')){ ?>
                                            <div class="alert alert-danger solid " style='text-align:center;'><?php echo $this->session->flashdata('mold_danger'); ?></div>
                                        <?php } ?>
                                         <div id='mold_danger' class='alert alert-danger solid' style='display:none;width: 25%;'></div>
                                        <div class="table-responsive">
                                            <table id="example5" class="display" style="min-width: 1200px">
                                                <thead>
                                                    <tr>
                                                        <th>ID</th>
                                                        <th>Description</th>
                                                        <th>Mould No</th>
                                                        <th>Manufacture</th>
                                                        <th>Mfg. Date</th>
                                                         <th>Cavity</th>
                                                        <th>Shelf Life Remain</th>
                                                       
                                                        <th>Type</th>
                                                        <th>Action</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <?php 
                                                    if(!empty($molds)){
                                                    foreach ($molds as $molds) {?>

                                                        <tr>
                                                       <td><?php echo $molds['id'];  ?></td>
                                                       <td><?php 
                                                        if($molds['product_id']==0){
                                                            echo "";
                                                        }else{
                                                       echo product_name($molds['product_id']); 
                                                        }
                                                       ?></td>
                                                       
                                                       <td><?php echo $molds['code']; ?></td>
                                                       <td><?php echo $molds['manufacture']; ?></td>

                                                       <td><?php 
                                                       if($molds['mfg_date']==""){
                                                           echo "";
                                                       }else{
                                                       $newDate = date("d-m-Y", strtotime($molds['mfg_date']));  
                                                       echo $newDate; }?></td>
                                                        <td><?php echo $molds['cavity']; ?></td>
                                                       
                                                       <td><?php echo $molds['self_life_remain']; ?></td>
                                                        <td><?php
                                                            if($molds['machine_type']==0){

                                                                echo 0;
                                                            }else  if($molds['machine_type']==1){
                                                               echo "Blow";
                                                                 
                                                            } if($molds['machine_type']==2){

                                                                echo "Injection";

                                                            }
                                                         ?></td>
                                                       <!--<td><a href ="<?php //echo base_url('assets/images/molds/'.$molds['image']); ?>" target="_blank"><img src="<?php //echo base_url('assets/images/molds/'.$molds['image']); ?>"  class="rounded-circle" width="54" height="54" alt=""></a></td>-->
                                                        <td>
                                                             <a href="<?php echo base_url('Admin/edit_get_mold/'.$molds['id']); ?>" class="btn btn-sm btn-primary"><i class="la la-pencil"></i></a> 
                                                            <a href="javascript:void(0);" onclick="delete_data(<?php echo $molds['id']; ?>)" class="btn btn-sm btn-danger"><i class="la la-trash-o"></i></a>

                                                           <button type="button" class="badge badge-warning" data-toggle="modal" data-target=".bd-example-modal-lg1" onclick="get_data('<?php  echo $molds['id']; ?>')">View</button>

                                                           <a href="<?php echo base_url('Admin/qc_parameter/').$molds['id']; ?>"  class="btn btn-sm btn-primary">QC Parameter</a>
                                                        </td>
                                                                                                      
                                                    </tr>
                                                       
                                                   <?php } } ?>
                                                    
                                                   
                                                </tbody>
                                            </table>
                                        </div>


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

                <div class="modal fade bd-example-modal-lg1" tabindex="-1" role="dialog" aria-hidden="true">
                                        <div class="modal-dialog modal-lg">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                  
                                                    <button type="button" class="close" data-dismiss="modal"><span>&times;</span>
                                                    </button>
                                                </div>
                                                <div class="modal-body">
                                              
                                            <div class="col-xl-12 col-xxl-12 col-sm-12">
                                                <div class="card">
                                                    <div class="card-header">
                                                 <h5 class="card-title">Mould Details</h5>
                                                    </div>
                                                   
                                                   <div class="card-body" id="molds_details">
                                              
                                                    </div>
                                                </div>
                                            </div>



                                                </div>
                                                <div class="modal-footer">
                              
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                                                  
                                                </div>
                                            </div>
                                        </div>
                                    </div>
            
                                  </div>
                <!--**********************************
                    Content body end
                ***********************************-->


                <!--**********************************
                    Footer start
                ***********************************-->
                <div class="footer">
                    <div class="copyright">
                        <p>Copyright © Designed &amp; Developed by  2020</p>
                    </div>
                </div>
                <!--**********************************
                    Footer end
                ***********************************-->

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

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


            </div>
            <script src="<?php echo base_url();?>assets/js/jjquery.min.js"></script>
                <style>
                .redborder{
                    border:1px solid red;
                }
                </style>





           <script type='text/javascript'>



        $("#self_life_start").keyup(function() {

          var self_life = $('#self_life').val();
         var self_life_start = $('#self_life_start').val();
           var total = self_life-self_life_start;
         var output=parseInt(total).toLocaleString(); 
          $('#self_life_remain').val(output);
        });

                
            var mold = $('#add_mold');   
            
            mold.on('submit',function(e){

                e.preventDefault();
                $("#dis_submit").attr('disabled', true);
                 var molddata = mold.serialize();
                 
                  var code = $("input#code").val();
                  var name = $("input#name").val();
                  var manufacture = $("#manufacture").val();
                  var mfg_date = $("input#mfg_date").val();
                  var cavity = $("input#cavity").val();
                  var cycle_time = $("input#cycle_time").val();
                  var cost = $("input#cost").val();
                  var self_life = $("input#self_life").val();
                  var self_life_start = $("input#self_life_start").val();
                    
                  var self_life_remain = $("input#self_life_remain").val();
                    //var cost_required = $("input#cost_required").val();
                    //var  images = $("input#images").val(); 
                  var created = $("input#created").val();
                  var modified = $("input#modified").val();
                  //var qc_specs = $("input#qc_specs").val();
                    
                    //var images = new FormData($("#images")[0]);
                       //var formData = new FormData(this);
                    $.ajax({
                     url:'<?php echo base_url('Admin/mold'); ?>',
                     type:"post",
                     data:new FormData(this),
                     processData:false,
                     contentType:false,
                     cache:false,
                     async:false,
                     dataType:'json',
                     success: function(data){
                    
                            if(data.status === 'true'){
                                console.log('second'+data.status);
                                $('#mold_success').show().html('Mold added Successfully').hide(2000);
                               setTimeout(function(){location.href="<?php echo base_url('Admin/mold'); ?>"} , 2000);
                            }else{
                                console.log('third'+data);          
                            }
                     }
                     });
               // }
            });

            function delete_data(id) { 
                var id = id;
                
                 $.ajax({
                        type:'POST',
                        url:'<?php echo base_url('Admin/delete_mold/'); ?>'+id,
                        data:id,
                        dataType:'json',
                        success:function(data){
                            console.log('first'+data.status);
                            
                                console.log('second'+data.status);
                                //debugger;
                                $('#mold_danger').show().html('Mold Deleted Successfully');
                               setTimeout(function(){location.href="<?php echo base_url('Admin/mold'); ?>"} , 2000);
                            
                        },
                        error:function(data){console.log(data.responseText);}
                    });
                } 



                 function get_data(id) { 
              var id =  id;
              //alert(id);

              $.ajax({
                        type:'POST',
                        url:'<?php echo base_url('Admin/view_molds_details'); ?>',
                        data:{id:id},
                        dataType:'json',
                        success:function(data){
                            //console.log('first'+data.status);
                            //if(data.status === 'true'){
                             $('#molds_details').show().html(data.html);
                               //$('#bom_details').show(data);
                           /* }else{
                                //console.log('third'+data);          
                            }*/
                        },
                        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>