<!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>Edit Machine</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);">Machine</a></li>
                    <li class="breadcrumb-item active"><a href="javascript:void(0);">Add Machine</a></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_machine", 'id'=>"add_machine")); ?>
                        <fieldset class="content-group">
                           
                            <?php if($this->session->flashdata('machine_success')){ ?>
                    <div class="alert alert-success solid" style='text-align:center;'><?php echo $this->session->flashdata('machine_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 Machine</h5>
                    </div>
                    <div class="card-body">
                        <div id='machine_success' class='alert alert-success solid' style='display:none;'></div>
                       
                <div class="row">
                    <input type="hidden" value="<?php echo $this->uri->segment(3); ?>" name="id" id="id" required="required">
                    <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">Machine Code</label>
                            <input type="text" name="code" id="code" value="<?php echo $get_machine[0]['code']; ?>" readonly="readonly" placeholder="Machine Code" class="form-control code">
                        </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="machine_name" value="<?php echo $get_machine[0]['machine_name']; ?>" id="machine_name" 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">Machine Type:</label>
                            <select data-live-search="true" name="machine_type"  id="machine_type" class="form-control" tabindex="-98">
                                <?php if ($get_machine[0]['machine_type']==2){?>

                                    <option value="2">Injection</option>
                               <?php  }else if ($get_machine[0]['machine_type']==1){ ?>
                                <option value="1">EBM</option>

                               <?php } else if ($get_machine[0]['machine_type']==3){ ?>
                                <option value="3">IBM</option>

                               <?php } ?>
                                
                               <option value="2">Injection</option>
                               <option value="1">EBM</option>
                               <option value="3">IBM</option>
                              
                               
                                </select>
                        </div>
                    </div>


                    <div class="col-lg-6 col-md-6 col-sm-12">
                        <div class="form-group">
                            <label class="form-label">Manufacturer</label>
                            <input type="text" name="manufacture" value="<?php echo $get_machine[0]['manufacture']; ?>"  id="manufacture" placeholder="Manufacturer" class="form-control">
                        </div>
                    </div>

                     <div class="col-lg-6 col-md-6 col-sm-12">
                        <div class="form-group">
                            <label class="form-label">Vendor:</label>
                            <select data-live-search="true" name="vendor"  id="vendor" class="form-control" tabindex="-98">
                                <option value="<?php echo $get_machine[0]['vendor']; ?>"><?php echo vendor($get_machine[0]['vendor']); ?></option>
                                <?php foreach ($get_vendors as $vendors) { ?>
                            <option value="<?php echo $vendors['id']; ?>"><?php echo $vendors['vendor_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">Machine Cost</label>
                            <input type="text" name="cost" value="<?php echo $get_machine[0]['cost']; ?>" required="required" required="required" id="cost" placeholder="Machine Cost" class="form-control cost">
                        </div>
                    </div>

                     <div class="col-lg-6 col-md-6 col-sm-12">
                        <div class="form-group">
                            <label class="form-label">Depreciation Amount</label>
                            <input style="background-color: #e5e5e5;"  type="text" value="<?php echo $get_machine[0]['dept_amount']; ?>" readonly="readonly" name="dept_amount"  id="dept_amount" placeholder="Depreciation Amount" class="form-control">
                        </div>
                    </div>
                    
                    <div class="col-lg-6 col-md-6 col-sm-12">
                        <div class="form-group">
                            <label class="form-label">Depreciation Hrs</label>
                            <input type="text" required="required" value="<?php echo $get_machine[0]['dept_hrs']; ?>" name="dept_hrs" id="dept_hrs" placeholder="Depreciation Hrs" class="form-control dept_hrs">
                        </div>
                    </div>
                    
                      <div class="col-lg-6 col-md-6 col-sm-12">
                        <div class="form-group">
                            <label class="form-label">Depreciation Cost as Per Working Hours</label>
                            <input type="text" style="background-color: #e5e5e5;" value="<?php echo $get_machine[0]['dept_cost_p_w_h']; ?>" name="dept_cost_p_w_h" readonly="readonly" id="dept_cost_p_w_h" class="form-control">
                        </div>
                    </div>
                    
                       <div class="col-lg-6 col-md-6 col-sm-12">
                    <div class="form-group">
                    <label class="form-label">Working Hours</label>
                    <input type="text" name="whrs" id="whrs" value="<?php echo $get_machine[0]['whrs']; ?>" placeholder="Working Hours" class="form-control whrs">
                    </div>
                </div>

                     <div class="col-lg-6 col-md-6 col-sm-12">
                        <div class="form-group">
                            <label class="form-label">Depreciation Cost/hrs</label>
                            <input type="text" style="background-color: #e5e5e5;" name="dept_cost_hrs" value="<?php echo $get_machine[0]['dept_cost_hrs']; ?>" readonly="readonly" id="dept_cost_hrs" placeholder="Depreciation 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">Rental Cost</label>
                            <input type="text" name="rental" id="rental" value="<?php echo $get_machine[0]['rental']; ?>" required="required" placeholder="Rental Cost" class="form-control rental">
                        </div>
                    </div>

                        <div class="col-lg-6 col-md-6 col-sm-12">
                            <div class="form-group">
                            <label class="form-label">Maintenance Cost</label>
                            <input type="text" name="maintainance" value="<?php echo $get_machine[0]['maintainance']; ?>" readonly="readonly" style="background-color: #e5e5e5;" id="maintainance" placeholder="Maintenance 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">Supervisor & QC Cost</label>
                            <input type="text" name="supervisor" value="<?php echo $get_machine[0]['supervisor']; ?>" id="supervisor" placeholder="Supervisor Cost" class="form-control supervisor">
                        </div>
                    </div>


                  <div class="col-lg-6 col-md-6 col-sm-12">
                            <div class="form-group">
                            <label class="form-label">Labour Cost</label>
                            <input type="text" name="labour" value="<?php echo $get_machine[0]['labour']; ?>" id="labour" placeholder="Labour Cost" class="form-control labour">
                        </div>
                    </div>
                 <div class="col-lg-6 col-md-6 col-sm-12">
                    <div class="form-group">
                    <label class="form-label">Electricity Cost(Unit)</label>
                    <input type="text" name="electricity_cost" value="<?php echo $get_machine[0]['electricity_cost']; ?>" id="electricity_cost" placeholder="Electricity Cost" class="form-control electricity_cost">
                        </div>
                    </div>

                 <div class="col-lg-6 col-md-6 col-sm-12">
                    <div class="form-group">
                    <label class="form-label">Electricity Consumed(Unit)</label>
                    <input type="text" name="electricity_consume" value="<?php echo $get_machine[0]['electricity_consume']; ?>" id="electricity_consume" placeholder="Electricity Consumed(Unit)" class="form-control electricity_consume">
                        </div>
                    </div>
                 <div class="col-lg-6 col-md-6 col-sm-12">
                    <div class="form-group">
                    <label class="form-label">Electricity Cost/hr</label>
                    <input type="text" name="electricity_cost_hr" style="background-color: #e5e5e5;" readonly="readonly" id="electricity_cost_hr" value="<?php echo $get_machine[0]['electricity_cost_hr']; ?>" placeholder="Electricity Cost/Hr" class="form-control">
                    </div>
                </div>

                <div class="col-lg-6 col-md-6 col-sm-12">
                    <div class="form-group">
                    <label class="form-label">Water Cost/hr</label>
                    <input type="text" name="water_cost" id="water_cost" value="<?php echo $get_machine[0]['water_cost']; ?>" placeholder="Water Cost/Hr" class="form-control water_cost">
                    </div>
                </div>

                <div class="col-lg-6 col-md-6 col-sm-12">
                    <div class="form-group">
                    <label class="form-label">Profit(%)</label>
                    <input type="text" name="profit" id="profit" value="<?php echo $get_machine[0]['profit']; ?>" placeholder="Profit(%)" class="form-control profit">
                    </div>
                </div>

                <div class="col-lg-6 col-md-6 col-sm-12">
                    <div class="form-group">
                    <label class="form-label">Total Machine Cost</label>
                    <input type="text" style="background-color: #e5e5e5;" value="<?php echo $get_machine[0]['total_machine_cost']; ?>" readonly="readonly" name="total_machine_cost" id="total_machine_cost" placeholder="Total Machine 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">Profit Rate</label>
                    <input type="text" name="profit_rate" value="<?php echo $get_machine[0]['profit_rate']; ?>" style="background-color: #e5e5e5;" readonly="readonly" id="profit_rate" placeholder="Profit Rate" 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 Cost / Day</label>
                    <input type="text" style="background-color: #e5e5e5;" value="<?php echo $get_machine[0]['machine_cost_hr']; ?>" readonly="readonly" name="machine_cost_hr" id="machine_cost_hr" placeholder="Machine Cost/Hr" class="form-control">
                    </div>
                </div>

              
                
                <div class="col-lg-6 col-md-6 col-sm-12">
                    <div class="form-group">
                    <label class="form-label">M.D Profit</label>
                    <input type="text" name="md_profit" id="md_profit" readonly="readonly" value="<?php echo $get_machine[0]['md_profit']; ?>" placeholder="MD Profit" class="form-control md_profit">
                    </div>
                </div>


                 <div class="col-lg-6 col-md-6 col-sm-12">
                    <div class="form-group">
                    <label class="form-label">Machine Cost/hr</label>
                    <input type="text" style="background-color: #e5e5e5;" value="<?php echo $get_machine[0]['machine_cost_day']; ?>" readonly="readonly" name="machine_cost_day" id="machine_cost_day" placeholder="Machine Cost/day" class="form-control">
                    </div>
                </div>

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

                </div>
            <button type="submit" class="btn btn-primary">Submit <i class="icon-arrow-right14 position-right"></i></button>
        </div>
    </div>
</div>

        <?php form_close();?>

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


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

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

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


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

<!--**********************************
Scripts
***********************************-->
<!-- Required vendors -->

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

<script type='text/javascript'>



$(document).ready(function() {
  $('.code').keypress(function(event) {
    return isNumber(event, this)
  });

  $('.cost').keypress(function(event) {
    return isNumber(event, this)
  });

  $('.dept_hrs').keypress(function(event) {
    return isNumber(event, this)
  });

  $('.rental').keypress(function(event) {
    return isNumber(event, this)
  });

  $('.supervisor').keypress(function(event) {
    return isNumber(event, this)
  });

  $('.labour').keypress(function(event) {
    return isNumber(event, this)
  });
  $('.electricity_cost').keypress(function(event) {
    return isNumber(event, this)
  });
  $('.electricity_consume').keypress(function(event) {
    return isNumber(event, this)
  });
  $('.water_cost').keypress(function(event) {
    return isNumber(event, this)
  });


  $('.profit').keypress(function(event) {
    return isNumber(event, this)
  });
$('.whrs').keypress(function(event) {
    return isNumber(event, this)
  });

});

function isNumber(evt, element) {

  var charCode = (evt.which) ? evt.which : event.keyCode

  if (
    (charCode != 45 || $(element).val().indexOf('-') != -1) && // “-” CHECK MINUS, AND ONLY ONE.
    (charCode != 46 || $(element).val().indexOf('.') != -1) && // “.” CHECK DOT, AND ONLY ONE.
    (charCode < 48 || charCode > 57))
    return false;

  return true;
}




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

  var aa = $('#cost').val();
  var value = 90;
   var total = aa/100*90;
 var output=parseInt(total).toLocaleString(); 
  $('#dept_amount').val(output);
});

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

 
  var dept_hrs2 =   $('#dept_hrs').val();

  var dept_amount = $("#dept_amount").val();
  var val1 = parseFloat(dept_amount.replace(/,/g, ""));
 
 /*console.log("value1 "+ val1);

console.log("value2 "+ dept_hrs2);*/

   var total = val1 / dept_hrs2; 
    
 //var output=parseInt(total).toLocaleString(); 
  $('#dept_cost_hrs').val(total.toFixed(2));
});



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

  var electricity_cost = $('#electricity_cost').val();
  var electricity_consume = $('#electricity_consume').val();
   var total = electricity_cost*electricity_consume*20;
 //var output=parseInt(total).toLocaleString(); 
  $('#electricity_cost_hr').val(total);
});

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

  var aa = $('#dept_amount').val();
  var val1 = parseFloat(aa.replace(/,/g, ""));
  var value = 0.02;
   var total = val1/100*value;
 //var output=parseInt(total.toFixed(3)).toLocaleString(); 
  $('#maintainance').val(total);
});


$("#water_cost").keyup(function() {
  //var dept_cost_hrs = 3.00;
  var dept_cost_hrs = $('#dept_cost_hrs').val();
  var rental = $('#rental').val();
  var maintainance = $('#maintainance').val();
  var supervisor = $('#supervisor').val();
  var labour = $('#labour').val();
  var electricity_cost_hr = $('#electricity_cost_hr').val();
  var water_cost = $('#water_cost').val();
   var dept_cost_p_w_h = $('#dept_cost_p_w_h').val();
 
   var total = +rental+ +maintainance+ +supervisor+ +labour+ +electricity_cost_hr+ +water_cost+ +dept_cost_p_w_h;

   //alert(electricity_cost_hr);
 
 //var output=parseInt(total).toLocaleString(); 
  $('#total_machine_cost').val(total);
  
   
  
});


$("#profit").keyup(function() {
  //var dept_cost_hrs = 3.00;
  var profit = $('#profit').val();
  var total_machine_cost = $('#total_machine_cost').val();
  
   var total = total_machine_cost/100*profit;
    var profit_rate = $('#profit_rate').val();
 //var output=parseInt(total).toLocaleString(); 
  $('#profit_rate').val(total.toFixed(3));

 	var machine_cost_hr = +total_machine_cost+ +total;
 	 $('#machine_cost_hr').val(machine_cost_hr);
 
  
   

});


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

  var whrs = $('#whrs').val();
    var profit_rate = $('#profit_rate').val();
 	 var res = profit_rate/whrs;
     $('#md_profit').val(res.toFixed(3));
  
   

});


//Arif ////
$("#md_profit").keyup(function() {

    var whrs = $('#whrs').val();
    var machine_cost_hr = $('#machine_cost_hr').val();
 	 
 	 var res = machine_cost_hr/whrs;
     $('#machine_cost_day').val(res.toFixed(3));
  
   

});


$("#whrs").keyup(function() {
  //var dept_cost_hrs = 3.00;
  var whrs = $('#whrs').val();
  var machine_cost_hr = $('#machine_cost_hr').val();
  var dept_cost_hrs = $('#dept_cost_hrs').val();
   //var total = machine_cost_hr/whrs;

 //var output=parseInt(total).toLocaleString(); 
  //$('#machine_cost_day').val(total.toFixed(3));
  
  var res = dept_cost_hrs*whrs;
  $('#dept_cost_p_w_h').val(res.toFixed(3)); 
  

});

var machine = $('#add_machine');   

machine.on('submit',function(e){

e.preventDefault();

var machinedata = machine.serialize();
 var id = $('#id').val();

    $.ajax({
        type:'POST',
        url:'<?php echo base_url('Admin/edit_get_machine/'); ?>'+id,
        data:machinedata,
        dataType:'json',
        success:function(data){
            console.log('first'+data.status);
            if(data.status === 'true'){
                console.log('second'+data.status);
                $('#machine_success').show().html('Machine Update Successfully').hide(3000);
               setTimeout(function(){location.href="<?php echo base_url('Admin/machine'); ?>"} , 3000);
            }else{
                console.log('third'+data);          
            }
        },
        error:function(data){console.log(data.responseText);}
    });
// }
});
</script>

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