siddharth_application/application/views/BatchcardHistEdit.php
2018-05-04 13:15:53 +05:30

570 lines
19 KiB
PHP
Executable File

<?php
//print_r($TableDatas);
$Machine_Code = '';
$Machine_Name ='';
$Machines_Make ='';
$Machines_Capacity ='';
$Machines_Category ='';
$Machines_Dept ='';
$Factory_Loc ='';
$Machines_PONO ='';
$Machines_POdate ='';
$Machines_Supplier ='';
$Instalization_Date ='';
$Machines_Lifetime ='';
$Commencement_Date ='';
$Range ='';
$Operating_Range='';
$Least_Count='';
$Calibration_Agency='';
$Calibration_On='';
$Calibration_Due='';
$Acceptence_Criteria='';
// $Machine_filename = '';
// $Machine_filepath = '';
// $filecount = '';
if(!empty($HistMstrEdit)){
foreach($HistMstrEdit as $Mstr)
{
$Machine_Code = $Mstr->Machine_Code;
$Machine_Name = $Mstr->Machine_Name ;
$Machines_Make = $Mstr->Machines_Make ;
$Machines_Capacity = $Mstr->Machines_Capacity;
$Machines_Category = $Mstr->Machines_Category;
$Machines_Dept = $Mstr->Machines_Dept;
$Factory_Loc = $Mstr->Factory_Loc ;
$Machines_PONO = $Mstr->Machines_PONO;
$Machines_POdate = $Mstr->Machines_POdate;
$Machines_Supplier = $Mstr->Machines_Supplier;
$Instalization_Date = $Mstr->Instalization_Date;
$Machines_Lifetime = $Mstr->Machines_Lifetime;
$Commencement_Date = $Mstr->Commencement_Date;
}
}
if(!empty($HistDtlsEdit)){
foreach($HistDtlsEdit as $Dtls)
{
$Range = $Dtls->Range;
$Operating_Range = $Dtls->Operating_Range;
$Least_Count = $Dtls->Least_Count;
$Calibration_Agency = $Dtls->Calibration_Agency;
$Calibration_On = $Dtls->Calibration_On;
$Calibration_Due = $Dtls->Calibration_Due;
$Acceptence_Criteria = $Dtls->Acceptence_Criteria;
}
}
// print_r($HistFileEdit);
// count($HistFileEdit);
// echo "<br>";
// echo sizeof($HistFileEdit);
// die();
// if(!empty($HistFileEdit)){
// $filecount = count($HistFileEdit);
// // foreach($HistFileEdit as $File)
// // {
// // $Machine_filename = $File->Machine_filename;
// // $Machine_filepath = $File->Machine_filepath ;
// // }
// }
?>
<style>
.left-margin { margin-left: 10px }
.autocomplete-suggestion{
cursor:pointer;
background-color:skyblue;
/* background-color: darkgrey; */
outline: 1px solid slategrey;
}
#machs_category {
/* text-transform: capitalize; */
text-transform: uppercase;
}
#divid1{
margin-top:14px;
}
</style>
<script type="text/javascript" src="<?php echo base_url();?>assets/Autocomplete/jquery.autocomplete.js"></script>
<div class="content-wrapper" style="min-height: 537px;">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center>Siddharth Industries - Edit Machine Master/History</center>
</h1>
</section>
<section class="content">
<div style="text-align:right;">
<a href="<?php echo base_url() ?>batchcard/getHistListing" class="btn btn-primary" value="Back"/>Back</a>
</div>
<br>
<div class="row">
<!-- left column -->
<div class="col-md-12">
<div class="box box-primary">
<!-- form start -->
<form role="form" id="MachHist" action="<?php echo base_url() ?>batchcard/editHist_mstr" enctype="multipart/form-data" method="post">
<div class="box-body">
<div class="row">
<div class="col-md-12">
<legend>Machinery Primary Details</legend>
<div class="col-md-12">
<div class="col-md-3">
<label>Machine code and Name</label>
<input type="text" id="mach_name" name="mach_name" class="form-control" readonly value="<?php echo $Machine_Code.'-'.$Machine_Name;?>"/>
</div>
<div class="col-md-3">
<label>Machine Make</label>
<input type="text" id="tomake" name="tomake" class="form-control" value="<?php echo $Machines_Make;?>" />
</div>
<div class="col-md-3">
<label>Mechine's Capacity</label>
<input type="text" id="machs_capacity" name="machs_capacity" class="form-control" value="<?php echo $Machines_Capacity;?>" />
</div>
<div class="col-md-3">
<label>Machine Category</label>
<input type="text" id="machs_category" name="machs_category" class="form-control" value="<?php echo $Machines_Category;?>" />
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<label>Department</label>
<select class="form-control select2" id="machs_dept" name="machs_dept">
<option value=" ">Select Department</option>
</select>
</div>
<div class="col-md-3">
<label>PONO&nbsp;&nbsp;</label>
<select class="form-control select2" id="machs_pono" name="machs_pono">
<option value=" ">Select PONO</option>
</select>
</div>
<div class="col-md-3">
<label>PO Date</label>
<input type="text" id="machs_podate" name="machs_podate" class="form-control" onkeypress="return false;" style="text-align:right;" readonly value="<?php echo $Machines_POdate; ?>"/>
</div>
<div class="col-md-3">
<label>Supplier</label>
<input type="text" id="machs_supplier" name="machs_supplier" class="form-control" readonly value="<?php echo $Machines_Supplier;?>" onkeypress="return false;"/>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<label>Factory Location</label>
<input type="text" id="machs_locn" name="machs_locn" class="form-control" value="<?php echo $Factory_Loc;?>"/>
</div>
<div class="col-md-3">
<label>Date Of Instalization</label>
<input type="text" id="install_date" name="install_date" class="form-control datepicker" style="text-align:right;" value="<?php echo $Instalization_Date;?>" onkeypress="return false;" />
</div>
<div class="col-md-3">
<label>Lifetime Of Machine</label>
<input type="text" id="machs_lifetime" name="machs_lifetime" class="form-control" value="<?php echo $Machines_Lifetime;?>"/>
</div>
<div class="col-md-3">
<label>Commencement Date</label>
<input type="text" id="machs_comm_date" name="machs_comm_date" class="form-control datepicker" onkeypress="return false;" style="text-align:right;" value="<?php echo $Commencement_Date;?>"/>
</div>
</div>
</div>
<br/><br/>
<div class="col-md-12">
<legend>Machinery Specification Details</legend>
<div class="col-md-12">
<div class="col-md-4">
<label>Range</label>
<input type="text" id="machs_range" name="machs_range" class="form-control" value="<?php echo $Range;?>"/>
</div>
<div class="col-md-4">
<label>Operating Range</label>
<input type="text" id="machs_operating_range" name="machs_operating_range" class="form-control" value="<?php echo $Operating_Range;?>"/>
</div>
<div class="col-md-4">
<label>Least Count</label>
<input type="text" id="machs_least_count" name="machs_least_count" class="form-control" value="<?php echo $Least_Count;?>"/>
</div>
</div>
<div class="col-md-12">
<div class="col-md-4">
<label>Calibration Agency</label>
<input type="text" id="machs_calibration_agency" name="machs_calibration_agency" class="form-control" value="<?php echo $Calibration_Agency;?>"/>
</div>
<div class="col-md-4">
<label>Calibration On</label>
<input type="text" id="machs_calibration_on" name="machs_calibration_on" class="form-control datepicker" onkeypress="return false;" style="text-align:right;" value="<?php echo $Calibration_On;?>"/>
</div>
<div class="col-md-4">
<label>Calibration Due</label>
<input type="text" id="machs_calibration_due" name="machs_calibration_due" class="form-control datepicker" onkeypress="return false;" style="text-align:right;" value="<?php echo $Calibration_Due;?>"/>
</div>
</div>
<div class="col-md-12">
<div class="col-md-4">
<div id="lab" style="display: none;">
<label>Acceptence Criteria</label>
<input type="text" id="machs_lab_acceptence_criteria" name="machs_acceptence_criteria" class="form-control" value="<?php echo $Acceptence_Criteria;?>"/>
</div>
</div>
</div>
<div class="col-md-12">
<legend>History Detail</legend>
<table id="History_Of_Table" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;" >
<thead>
<tr>
<th>S.No</th>
<th>Machine Department</th>
<th>Machine Catagories</th>
<th>Maintenances Types</th>
<th>Maintenances Date and Time </th>
<th>Maintenances Location</th>
<th>Maintenances Description</th>
<th>Maintenances Reason</th>
<th>Total hrs for Maintenances</th>
<th>Work Done By</th>
<th>Approved By</th>
</tr>
</thead>
<tbody id="Hist_Append">
</tbody>
</table>
</div>
<div class="col-md-12">
<legend>Multiple File</legend>
<div class="col-md-offset-10 col-md-1" >
<input type="button" class="btn btn-primary" id ="addmorebutton" value=" + ADD FILES..">
</div>
</div>
<!-- weight S.No Instrument Make Range Operating Range Machine number Least Count ******************** Calibration Agency calibration on calibration due -->
<!-- lab S.No Instrument Make Range Operating Range ************** Least Count Acceptence Criteria Calibration Agency calibration on calibration due -->
<div id="newdiv"></div><!-- this div for add more section-->
<input type="hidden" name="hidecounter" id="hidecounter" value="0" />
<input type="hidden" name="hideconstant" id="hideconstant" value="0" />
</div>
</div><!-- row -->
</div><!--box body -->
<br/>
<div class="box-footer" style="text-align:right">
<input type="submit" class="btn btn-primary" value="Submit" />
<!-- <input type="reset" id="resetbtn" class="btn btn-primary" value="Reset" /> -->
</div>
</form>
</div><!--box body primary-->
</div>
</div>
</section>
</div>
<script>
// function readURL(input) {
// if (input.files && input.files[0]) {
// var reader = new FileReader();
// reader.onload = function (e) {
// $('#profilepicture')
// .attr('src', e.target.result)
// .width(180)
// .height(180);
// };
// reader.readAsDataURL(input.files[0]);
// }
// }
/** ready function */
var index = 0 ;
var counter = 0;
var counterConstant = 0;
var sno = 1;
$(function() {
var pono_arr = [];
var dept_arr = [];
var file_arr = [];
var tble_arr = [];
$("#machs_dept").select2();
$("#machs_pono").select2();
$('.datepicker').datepicker({
maxDate : 'now',
dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,yearRange: '0:+10'
});
dept_arr = <?php echo json_encode($HistDeptList)?>;
pono_arr = <?php echo json_encode($HistPONOList)?>;
file_arr = <?php echo json_encode($HistFileEdit)?>;
$.each(dept_arr,function(d,da){
$("#machs_dept").append( $('<option></option>').val(da.DEPCode).html(da.DEPCode+'-'+da.shortName));
});
$('#machs_dept option[value="<?php echo $Machines_Dept?>"]').prop('selected', true);
$.each(pono_arr,function(p,pa){
$("#machs_pono").append( $('<option></option>').val(pa.PONO).html(pa.PONO));
});
$('#machs_pono option[value="<?php echo $Machines_PONO?>"]').prop('selected', true);
var mybaseurl='<?php echo base_url('uploads/images');?>';
$.each(file_arr,function(f,fa){
var div = document.createElement('div');
div.id = "dbdivid"+index;
div.className="row form-group";
div.style="margin-top:14px";
div.innerHTML='<div class="col-md-12">'+
'<div class="col-md-3">'+
'<label>File Name</label>'+
'<input type="text" id="db_machs_filename'+index+'" name="dbfilename'+index+'" class="form-control" value="'+fa.File_name+'" onkeypress="return false;" readonly/>'+
'</div>'+
'<div class="col-md-4">'+
'<label><br></label>'+
// '<input type="file" id="filepath'+index+'" name="browseFiles'+index+'" onchange="readURL(this);" placeholder= "'+fa.Machine_filepath+'" ><br>'+
'</div>'+
'<div class="col-md-3">'+
'<label><br><br></label>'+
'<input type="hidden" name="hidefileid'+index+'" id="hidefileid'+index+'" value="'+fa.File_No+'"/>'+
'<a href="'+mybaseurl+'/'+fa.File_name+'" class="btn btn-primary active" target="_blank" role="button"><i class="fa fa-download" ></i>Download</a>'+
'<button class="btn btn-danger left-margin" id="delbtn'+index+'" onclick="deleted(this.id)"><i class="fa fa-trash"></i> Remove</button>'+
'</div>'+
'</div>';
$('#newdiv').append(div);
index++;
});
tble_arr = <?php echo json_encode($TableDatas)?>;
//,Type,Maint_Subtype,,Maint_Time_from,Maint_Time_to,Maint_Total_hrs,Cost_Material,Cost_Labour
$.each(tble_arr,function(t,ta){
if(ta.Type == '0'){
Type = 'Maintenance';
}
else{
Type = 'Breakdown';
}
var html = '';
html += '<tr><td style="text-align:rignt;">'+sno+'</td>';
html += '<td style="text-align:right;">'+ta.Machines_Dept+' - '+ta.DepartmentName+'</td>';
html += '<td style="text-align:right;">'+ta.Machines_Category+'</td>';
html += '<td style="text-align:rignt;">'+Type+'</td>';
html += '<td style="text-align:right;">'+ta.date+' / '+ta.time+'</td>';
html += '<td style="text-align:right;">'+ta.Maint_Location+'</td>';
html += '<td style="text-align:right;">'+ta.Maint_Description+'</td>';
html += '<td style="text-align:right;">'+ta.Maint_Reason+'</td>';
html += '<td style="text-align:right;">'+ta.Maint_Total_hrs+'</td>';
html += '<td style="text-align:right;">'+ta.Worker_Name+'</td>';
html += '<td style="text-align:right;">'+ta.Approver_Name+'</td></tr>';
$('#Hist_Append').append(html);
sno++;
});
//foreach( as $File)
$('#machs_category').autocomplete({
onSearchStart: function (query) {
//alert(query);
$('#machs_category').autocomplete("option", "minLength", 0);
},
serviceUrl: "<?php echo base_url();?>batchcard/autocomplete",
onSelect: function (suggestion) {
var data = suggestion.ConfigValue;
var selectedvalue = $('input[name=machs_category]').val();
if(selectedvalue=='LAB') { $("#lab").show(); }
else{ $("#lab").hide(); }
}
});
var lab = "<?php echo $Machines_Category ?>";
if(lab == 'LAB') { $("#lab").show(); }
} );
// $("#resetbtn").click(function(){
// alert('0');
// $("#machs_dept").select2("val", "");
// $("#machs_pono").select2("val", "Select PONO");
// });
/** on change machines category */
$("#machs_category").change(function(){
var machine_category = $(this).val().toUpperCase();
// var machine_category = $(this).val().toLowerCase().replace(/\b[a-z]/g, function(letter) {
// return letter.toUpperCase();
// });
if(machine_category == 'LAB'){ $("#lab").show(); }
else { $("#lab").hide(); }
});
/**on change pono to set supplier and podate */
$("#machs_pono").change(function(){
var machine_pono = $(this).val();
//alert(machine_pono);
$.ajax({
data:{id:machine_pono},
type:"POST",
url:"<?php echo base_url();?>batchcard/getPODtls",
success:function(data) {
//alert(data);
var hist_podate = '';
var hist_supplier = '';
if(data)
{
data = JSON.parse(data);
$.each(data,function(i,arr){
hist_podate = arr.PO_Date;
hist_supplier = arr.SupplierID+'-'+arr.SupplierName;
});
}
$("#machs_podate").val(hist_podate);
$("#machs_supplier").val(hist_supplier);
}
});
});
$("#addmorebutton").click(function(){
// alert('sda');
// alert(index);
// alert(counter);
// alert(counterConstant);
// var removenum = counterConstant+index;
// if(counter>4){
// alert("allow only 5 files");
// return false;
// }
// else{
counter++;
counterConstant++;
var div = document.createElement('div');
div.id = "divid"+counterConstant;
div.className="row";
div.innerHTML='<div class="col-md-12" >'+
'<div class="col-md-3">'+
'<label>File Name</label>'+
// '<input type="text" id="machs_filename" name="filename'+counterConstant+'" class="form-control"/>'+
'<input type="text" id="machs_filename'+counterConstant+'" name="filename'+counterConstant+'" class="form-control" onkeypress="return false;" readonly/>'+
'</div>'+
'<div class="col-md-4">'+
'<label><br></label>'+
'<input type="file" name="browseFiles'+counterConstant+'" onchange="Copyfilename(this.name);"><br>'+
'</div>'+
'<div class="col-md-3">'+
'<label><br><br></label>'+
'<button class="btn btn-danger remove remove_this" id="removebtn'+counterConstant+'" onclick="removeRow(this.id)"><i class="fa fa-trash"></i> Remove</button>'+
'</div>'+
'</div>';
$('#newdiv').append(div);
$('#hidecounter').val(counter);
$('#hideconstant').val(counterConstant);
//}
});
function deleted(deleteid) {
var number = deleteid.replace(/[^0-9]+/ig,"");
var fileid = $("#hidefileid"+number).val();
var filename = $("#machs_filename"+number).val();
$.ajax({
data:{id:fileid,name:filename},
type:"POST",
url:"<?php echo base_url() ?>batchcard/Removefiledetails",
success:function(data) {
}
});
$("#dbdivid"+number).remove();
}
function removeRow(input) {
// alert(input);
var number = input.replace(/[^0-9]+/ig,"");
//if(counter >= 1){
counter--;
$("#divid"+number).remove();
$('#hidecounter').val(counter);
//}
}
function Copyfilename(id)
{
var size = $('input[name='+id+']')[0].files[0].size;
var number = id.replace(/[^0-9]+/ig,"");
if(size > 2100000){
//alert(id);
alert('Sorry Your File is Large To 2MB');
removeRow(id);
//$('input[name = browseFiles'+number+']').val(' ');
}else {
var name = $('input[name='+id+']')[0].files[0].name;
//alert(name);
$("#machs_filename"+number).val(name);
}
}
</script>