<!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>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">
                       <button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bd-example-modal-lg">Add Machine</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(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="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="row">

                   

                    


                    <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 $codes; ?>" 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="name" id="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="type"  id="type" class="form-control" tabindex="-98">
                            <option value="">Select Option</option>    
                            <option value="2">Sealing</option>
                               <option value="1">Printing</option>
                              
                                </select>
                        </div>
                    </div>

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

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

                                     <?php form_close();?>

                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                                            <button type="submit" class="btn btn-primary">Submit <i class="icon-arrow-right14 position-right"></i></button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                    </div>
                    <div class="card-body">
                    <div id='party_danger' class='alert alert-danger solid' style='display:none;width: 25%;'></div>

                        <div class="table-responsive">
                            <table id="example5" class="display" style="min-width: 845px">
                                <thead>
                                    <tr>
                                        <th>Id</th>
                                        <th>Machine Code</th>
                                        <th>Machine Type</th>
                                        <th>Machine Name</th>
                                      
                                        <th>Date</th>
                                        <th>Action</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php if(!empty($other_machine)){
                                        foreach ($other_machine as $value) {
                                        
                                     ?>
                                    <tr>
                                       <td><?php echo $value['id']; ?></td>
                                       <td><?php echo $value['code']; ?></td>
                                       <td><?php 
                                            if($value['type']==1){ ?>
                                            Printing
                                       <?php }elseif($value['type']==2){ ?>
                                        Sealing
                                       <?php }  ?>
                                          
                                    </td>
                                        <td>
                                            <strong>
                                            <a href="<?php echo base_url('Admin/view_machines_details/'.$value['id']); ?>"><?php echo $value['name']; ?>
                                            </a></strong></td>

                                      
                                       <td><?php echo $value['created']; ?></td>
                                        <td>
                                            <a href="<?php echo base_url('Admin/edit_othermachine/'.$value['id']); ?>" class="btn btn-sm btn-primary"><i class="la la-pencil"></i></a> 
                                            <a href="javascript:void(0);" onclick="delete_data(<?php echo $value['id']; ?>)" class="btn btn-sm btn-danger"><i class="la la-trash-o"></i></a>
                                            </td>                                               
                                    </tr>
                                     <?php
                                         }
                                            }
                                         ?>
                                </tbody>
                            </table>
                        </div>


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

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

$(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;
 //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 total = +dept_cost_hrs+ +rental+ +maintainance+ +supervisor+ +labour+ +electricity_cost_hr+ +water_cost;
 
 //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 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);


});


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

 //var output=parseInt(total).toLocaleString(); 
  $('#machine_cost_day').val(total.toFixed(3));

});

var machine = $('#add_machine');   

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

e.preventDefault();

var machinedata = machine.serialize();


    $.ajax({
        type:'POST',
        url:'<?php echo base_url('Admin/other_machine'); ?>',
        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 added Successfully').hide(3000);
               setTimeout(function(){location.href="<?php echo base_url('Admin/other_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>