<!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>Daily Machine Report</h4>
                            <?php  $day_night = day_night($this->uri->segment(3)); ?>
           
                               
                        </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 active"><a href="javascript:void(0);">Daily Machine Report</a></li>
                            <li class="breadcrumb-item active"><?php 
                                if($day_night==1){ ?>
                    
                                 <img src="<?php echo base_url(); ?>/assets/image/day.png" style="width: 45px;border-radius: 23px;">
                                 
                              <?php }else if($day_night==2){ ?>
                    
                                <img src="<?php echo base_url(); ?>/assets/image/night.png" style="width: 45px;border-radius: 23px;">
                    
                             <?php }

                            ?></li>
                        </ol>
                    </div>
                </div>
        
        <div class="row">


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

     <div id='add_qc_machine' 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">
                <input type="hidden" value="<?php echo date('Y-m-d'); ?>" name="insert_date" id="insert_date" class="form-control required">
               
                 <input type="hidden" value="<?php echo $this->uri->segment(3); ?>" name="qc_machine_id" id="qc_machine_id" required="required"> 
               
        </div>
 </div>
          <input type="hidden" name="user_id" id="user_id" value="<?php echo $this->session->userdata('id');?>">

           

          <!-- <div class="col-lg-3 col-md-6 col-sm-12">
                           <div class="form-group">
                                <label class="form-label">Select Shift:</label>
                                 <select class="form-control day_night" data-live-search="true"   name="day_night" required="required" id="day_night">
                                <option>Select Option</option>
                              <option value="1">Day</option>
                              <option value="0">Night</option>
                            </select>
                             </div> 
                             
                           </div> -->

                  
                    <div class="col-lg-3 col-md-6 col-sm-12">
                           <div class="form-group">
                                <label class="form-label">Operator Name:</label>
                                 <select class="form-control emp_id" data-live-search="true"   name="emp_id" required="required" id="emp_id">
                                <option>Select Operator</option>
                                <?php foreach ($get_oprators as $get_oprator) { ?>
                                  <option value="<?php echo $get_oprator['id']; ?>"><?php echo $get_oprator['fullname']; ?></option>
                               <?php } ?>
                            </select>
                             </div> 
                             
                           </div>
                      
                            <div class="col-lg-3 col-md-6 col-sm-12">
                           <div class="form-group">
                                <label class="form-label">Machine:</label>
                                <?php 
                                $machine =   $this->uri->segment(3); 
                                $qc_machine_id = qc_machine_get_machine_id($machine);
                                $machine_name = machine_name($qc_machine_id);
                                ?>
                                <input type="text" id="" name="" readonly="readonly" value="<?php echo  $machine_name; ?>" required="required"  class="form-control ">
                                <input type="hidden" name="machine_id" value="<?php echo  $qc_machine_id; ?>" id="machine_id">
                                 <!-- <select class="form-control machine_id" data-live-search="true"   name="machine_id" required="required" id="machine_id">
                                <option>Select Machine</option>
                                <?php foreach ($get_machine as $get_machines) { ?>
                                  <option value="<?php echo $get_machines['machine_id']; ?>"><?php echo machine_name($get_machines['machine_id']); ?></option>
                               <?php } ?>
                            </select> -->
                             </div> 
                             
                           </div>


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

                                <?php 
                                $product =   $this->uri->segment(3); 
                                $qc_product_id = qc_machine_get_product_id($product);
                                //$product_name = product_name($qc_product_id);
                                ?>
                                <input type="text" id="" readonly="readonly" name="" value="<?php echo  product_name($qc_product_id); ?>" required="required"  class="form-control product_id">
                                 <input type="hidden" name="product_id" value="<?php echo  $qc_product_id; ?>" id="product_id">
                                 <!-- <select class="form-control product_id" data-live-search="true"   name="product_id" required="required" id="product_id">
                                <option>Select Product</option>
                                <?php foreach ($get_products as $get_productss) { ?>
                                  <option value="<?php echo $get_productss['product_id']; ?>"><?php echo product_name($get_productss['product_id']); ?></option>
                               <?php } ?>
                            </select> -->
                             </div> 
                             
                           </div>



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

                                <?php 
                                $material =   $this->uri->segment(3); 
                                $qc_material_id = qc_machine_get_material_id($material);
                               // $material_name = material_name($qc_material_id);
                                ?>
                                <input type="text" readonly="readonly" id="" name="" value="<?php echo  material_name($qc_material_id); ?>" required="required"  class="form-control ">
                                 <input type="hidden"  id="material_id" name="material_id" value="<?php echo  $qc_material_id; ?>">
                                <!--  <select class="form-control material_id" data-live-search="true"   name="material_id" required="required" id="material_id">
                                <option>Select Material</option>
                                <?php foreach ($get_materials as $get_materialss) { ?>
                                  <option value="<?php echo $get_materialss['material_id']; ?>"><?php echo material_name($get_materialss['material_id']); ?></option>
                               <?php } ?>
                            </select> -->
                             </div> 
                             
                           </div>

                             
                                  <input type="hidden" id="report_date"  name="report_date" value="<?php echo date('Y-m-d'); ?>" required="required"  class="form-control job">
                             
                   

                           <div class="col-lg-3 col-md-6 col-sm-12">
                           <div class="form-group">
                                <label class="form-label">Job No#:</label>
                                  <input type="number" id="job" name="job" value="<?php  $job = get_job_from_qcmachine($material); echo $job; ?>" required 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">M-Weight:</label>
                                  <input type="text" id="m_weight" name="m_weight" readonly="readonly" value="<?php 
                                  $p_id = $qc_product_id;
                                   $job = get_job_from_qcmachine($material);
                                   $seg_date =   $this->uri->segment(4); 
                                  $get_so_from_machine =  get_so_from_machine($p_id,$qc_machine_id); 
                                  $material_weight = get_material_weight($day_night,$seg_date,$job);
                                   echo $material_weight;
                                  ?>" onkeypress="return isNumberKey(event)"  required="required"  class="form-control m_weight">
                             </div> 
                             
                           </div>

                           

                           <div class="col-lg-3 col-md-6 col-sm-12">
                           <div class="form-group">
                                <label class="form-label">Waste Weight:</label>
                                  <input type="text" id="w_weight" name="w_weight" readonly="readonly" value="<?php 
                                  $p_id = $qc_product_id;
                                   $seg_date =   $this->uri->segment(4); 
                                    $job = get_job_from_qcmachine($material);
                                  $get_so_from_machine =  get_so_from_machine($p_id,$qc_machine_id); 
                                  $waste_weight = get_waste_weight($seg_date,$day_night,$job);
                                   echo $waste_weight;
                                  ?>"onkeypress="return isNumberKey(event)" required="required"  class="form-control w_weight">
                             </div> 
                             
                           </div>


                           <div class="col-lg-3 col-md-6 col-sm-12">
                           <div class="form-group">
                                <label class="form-label">C-H:</label>
                                  <input type="text" id="c_h" name="c_h" value="<?php echo get_complain_hours($job,$qc_machine_id); ?>" onkeypress="return isNumberKey(event)" required="required"  class="form-control c_h">
                             </div> 
                             
                           </div>


                            <div class="col-lg-3 col-md-6 col-sm-12">
                           <div class="form-group">
                                <label class="form-label">Genrator Working (hrs):</label>
                                  <input type="text" id="genrator_hrs" onkeypress="return isNumberKey(event)" name="genrator_hrs" required="required"  class="form-control genrator_hrs">
                             </div> 
                             
                           </div>

                          

                         <div class="col-lg-3 col-md-6 col-sm-12">
                           <div class="form-group">
                                <label class="form-label">T.P.Weight:</label>
                                <input type="number" id="tp_weight" name="tp_weight" readonly="readonly" required="required"  class="form-control tp_weight">
                             </div> 
                             
                           </div>

                           <div class="col-lg-3 col-md-6 col-sm-12">
                           <div class="form-group">
                                <label class="form-label">1 Hr Production:</label>

                                 <input type="number" id="hr" name="hr" readonly="readonly" required="required"  class="form-control hr">
                             </div> 
                             
                           </div>


                           <div class="col-lg-3 col-md-6 col-sm-12">
                           <div class="form-group">
                                <label class="form-label">Hrs:</label>
                                 <input type="number" id="hrs" name="hrs" readonly="readonly" required="required"  class="form-control hrs">
                             </div> 
                             
                           </div>



                           <input type="hidden" name="total_cost" id="total_cost" value="<?php echo $total_expense[0]['get_total_expense']; ?>">
                           <?php $machine_cost_hr = machine_cost_hr($qc_machine_id) ?>
                           
                           <input type="hidden" name="machine_cost_hr" value="<?php echo $machine_cost_hr; ?>" id="machine_cost_hr">
                            
                            <?php $machine_unit = machine_unit($qc_machine_id); ?>
                            
                            <input type="hidden" name="machine_unit" value="<?php echo $machine_unit; ?>" id="machine_unit">
                            
                            
                             <?php $machine_dep_amount = machine_dep_amount($qc_machine_id); ?>
                            
                            <input type="hidden" name="machine_dep_amount" value="<?php echo $machine_dep_amount; ?>" id="machine_dep_amount">
                           
                           
                           <input type="hidden" name="count_active_machine" id="count_active_machine" value="<?php echo $count_active_machine[0]['count_active_machine']; ?>">
                            
                            
                             <?php $md_profit = md_profit($qc_machine_id); ?>
                             
                            <input type="hidden" name="md_profit" id="md_profit" value="<?php  echo $md_profit; ?>">

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

                             <?php 
                                $mold_pr=   $this->uri->segment(3); 
                                $qc_mold_pr = qc_machine_get_mold_pr($mold_pr);
                               // $material_name = material_name($qc_material_id);
                                ?>

                          <input type="hidden" name="mr_mold" id="mr_mold" value="<?php echo $qc_mold_pr; ?>">

                            <?php 
                                $pc_cavity=   $this->uri->segment(3); 
                                $qc_pc_cavity = qc_machine_get_pc_cavity($pc_cavity);
                               // $material_name = material_name($qc_material_id);
                                ?>

                          <input type="hidden"  name="pcs_cavity" id="pcs_cavity" value="<?php echo $qc_pc_cavity; ?>">


                          <?php 
                                $pc_weight=   $this->uri->segment(3); 
                                $qc_pc_weight = qc_machine_get_pc_weight($pc_weight);
                               // $material_name = material_name($qc_material_id);
                                ?>

                          <input type="hidden" name="weight" id="weight" value="<?php echo $qc_pc_weight; ?>">
                        
                 </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 class="row">


                    <div class="col-12">
                        
                            <div class="card-body">
                                
                                <h4>Daily Machine Report Today Entry</h4>
                                <div class="table-responsive">
                                   
                                    <table id="example5" class="display" style="min-width: 845px;font-size: 13px;">

                                        <thead>
                                            <tr>
                                               
                                                <th>Operator</th>
                                                <th>Job</th>
                                                <th>M-Weight</th>
                                                <th>W-Weight</th>
                                                <th>T.P Weight</th>
                                                <th>Hrs</th>
                                                <th>Cost</th>
                                               
                                                <th>Date/Time</th>
                                                <th>Action</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                           
                                           <?php
                                                if(!empty($get_machine_data_today)){
                                             foreach($get_machine_data_today as $get_machine_data_todays){ ?>
                                            <tr>
                                              <!--  <td><?php if($get_machine_data_todays['day_night']==1){ ?>

                                                <img src="<?php echo base_url(); ?>/assets/image/day.png" style="width: 45px;border-radius: 23px;">
                                               <?php }else if($get_machine_data_todays['day_night']==0){ ?>

                                               <img src="<?php echo base_url(); ?>/assets/image/night.png" style="width: 45px;border-radius: 23px;">

                                               <?php } ?></td> -->
                                                <td><?php echo fullname($get_machine_data_todays['emp_id']); ?></td>
                                              
                                                <td><?php echo $get_machine_data_todays['job']; ?></td>
                                               <td><?php echo $get_machine_data_todays['m_weight']; ?></td>
                                                <td><?php echo $get_machine_data_todays['w_weight']; ?></td>
                                                <td><?php echo $get_machine_data_todays['tp_weight']; ?></td>
                                                <td><?php echo $get_machine_data_todays['hrs']; ?></td>
                                                <td><?php echo $get_machine_data_todays['cost']; ?></td>
                                                
                                                <td><?php echo $get_machine_data_todays['created']; ?></td>
                                                <td>
                                                    <a href="<?php echo base_url('Admin/edit_machine_data_todays/'.$get_machine_data_todays['id'].'/'.$this->uri->segment(3)); ?>" class="btn btn-sm btn-primary">Edit</a>
                                                   
                                                </td>                                               
                                            </tr>
                                           <?php }
                                                }
                                            ?>
                                        </tbody>
                                    </table>
                                </div>



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

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

    </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 add_qc_machines = $('#add_qc_machine');   
    
    add_qc_machines.on('submit',function(e){
     
        e.preventDefault();
        
        var add_qc_machinesdata = add_qc_machines.serialize();
         if (confirm('Are you sure you want to Add.?')) {
              $("#dis_submit").attr('disabled', true);
              var w_weight = $('#w_weight').val();
              var m_weight = $('#m_weight').val();
              if(w_weight =="" || m_weight ==""){
                $('#error').show().html('Material and Waste Not Available..!');
              }else{
            $.ajax({
                type:'POST',
                url:'<?php echo base_url('Admin/add_machine_report'); ?>',
                data:add_qc_machinesdata,
                dataType:'json',
                success:function(data){
                    console.log('first'+data.status);
                    if(data.status === 'true'){
                        console.log('second'+data.status);
                        //$('#add_qc_machines').show().html('added Successfully');
                       location.href="<?php echo base_url('Admin/daily_machine_report_data'); ?>";
                       //location.reload();

                    }else{
                        console.log('third'+data);          
                    }
                },
                error:function(data){console.log(data.responseText);}
            });
          }
       }
    });

   



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

        $.ajax({
                    type:'POST',
                    url:'<?php echo base_url('Admin/get_qc_machine_data'); ?>',
                    data:{id:id},
                    dataType:'json',
                    success:function(data){
                        //console.log(data[0].material_code);
                         $('.material_id').val(data.material_id);
                         $('#product_id').val(data.product_id);
                         
                       
                    },
                    error:function(data){console.log(data.responseText);}
                });

    });



/*  $("#w_weight").keyup(function() {

         

    });*/

    $(document).ready(function() {
  
            var m_weight = $('#m_weight').val();
            var w_weight = $('#w_weight').val();
            if(m_weight=="" && w_weight==""){
                
                $("#dis_submit").attr('disabled', true);
            }else{
                $("#dis_submit").attr('disabled', false);
                
            }
      
          var aa = $('#mr_mold').val();
           var bb =  $('#pcs_cavity').val();
           var ww =  $('#weight').val();
           var output = Number(aa) * Number(bb);
            var total = output*6*ww/1000;
          //$('#hr').val(total);
          $('#hr').val(total.toFixed(2));
          

           var aa = $('#m_weight').val();
           var bb =  $('#w_weight').val();
           var output = Number(aa) + Number(bb);
          
          //$('#tp_weight').val(output);
           $('#tp_weight').val(output.toFixed(2));
  });

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



    });


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


          var mm = $('#m_weight').val();
          var aa = $('#mr_mold').val();
          var bb =  $('#pcs_cavity').val();
          var cc =  $('#hr').val();
          var ww =  $('#weight').val();
          var output = Number(aa) * Number(bb);
          var total_hr = output*6*ww/1000;
          var total_cost = $('#total_cost').val();
          var count_active_machine = $('#count_active_machine').val();
          var machine_cost_hr = $('#machine_cost_hr').val();
          var tp_weight =  $('#tp_weight').val();
          var genrator_hrs =  $('#genrator_hrs').val();
          var machine_unit = $('#machine_unit').val();
          var machine_dep_amount  = $('#machine_dep_amount').val();
          var md_profit  = $('#md_profit').val();
         
           //var output1 = Number(aa) * Number(bb);
            var total = mm/total_hr;
            //var hrs = mm/total;
            //var n = num.toFixed(3)
           $('#hrs').val(total.toFixed(1));
           var hrss = $('#hrs').val();
            var gen_hrs = genrator_hrs*9000/count_active_machine;
            //alert(count_active_machine);
           var expense_actual_cost = total_cost;
           //alert(actual_cost);
           var multi = count_active_machine;
           
           //alert(hrss);
           var tt = expense_actual_cost/multi;
            
           var res = machine_unit*hrss*20;
           var res1 = machine_dep_amount*hrss;
          //alert(gen_hrs);
           var md_profit_val = md_profit*hrss;
           
           var results = tt+res+res1+md_profit_val+gen_hrs;
          
           //alert(multi);
           var total_res = results/tp_weight;
           //$('#cost').val(tt);
           //Math.round
           
           $('#cost').val(Math.round(total_res).toFixed(2));


    });



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