siddharth_application/application/views/newresinbatchcard.php
2023-05-30 18:45:55 +05:30

1476 lines
40 KiB
PHP

<style>
.edit{
background-color:#ada5d2;
}
.editrst{
background-color:#b9b5b5 ;
}
.editcst{
background-color:#ada5d2 ;
}
.loader ,.loader-overlay ,.overlay{
height: 4000px !important;
}
</style>
<?php
//color:red ! important;
//print_r($igrno);
//print_r($operatorslist);
$operators = array(-1=>'Select Employee');
$newoperator = array(-1=>'Select Operator');
foreach($operatorslist as $re)
{
$operators[$re->EmpID] = $re->EmpID.'-'.$re->FirstName.'-'.$re->LastName;
$newoperator[$re->EmpID] = $re->EmpID.'-'.$re->FirstName.'-'.$re->LastName;
}
$products = array(-1=>'Select Product');
foreach($productsoutward as $rec)
{
$products[$rec->product_id] = $rec->product_name.'-'.$rec->product_description;
}
$customers = array(-1=>'Select Customer');
foreach($customersoutward as $rec)
{
$customers[$rec->client_id] = $rec->client_name;
}
//print_r($emplist);
$approvedby = array(-1=>'Select Approver Name');
foreach($emplist as $r)
{
$approvedby[$r->FirstName.' '.$r->LastName] = $r->FirstName.' '.$r->LastName.'-'.$r->shortName;
}
$machines = array(-1=>'Select Machine Name');
$trpbatchnos = array(-1=>'Select TRP Batch Card No');
$igrnos = array(-1=>'Select IGRNO');
$igrlinenos = array(-1=>'Select IGR Line Item');
foreach($igrno as $r)
{
$igrnos[$r->IGRNO] = $r->IGRNO;
}
foreach($machinelist as $r)
{
$machines[$r->Machine_Code] = $r->Machine_Code.'-'.$r->Machine_Name;
}
foreach($trpbatchcardnos as $r)
{
$trpbatchnos[$r->dailyid] = $r->dailyid;
}
?>
<style>
th{
text-align:center !important;
}
</style>
<script src="<?php echo base_url()?>assets/lightswitch/lightswitch/lib/jquery.tabletojson.js"></script>
<script src="<?php echo base_url()?>assets/lightswitch/lightswitch/lib/jquery.tabletojson.min.js"></script>
<script src="<?php echo base_url().'assets/jquery.plugin.js'?>"></script>
<script src="<?php echo base_url().'assets/jquery.timeentry.js'?>"></script>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center>New Resin Batch Card Screen</center>
</h1>
</section>
<section class="content">
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<!--<center><h3 class="box-title">-->
<div class="box-tools">
<!-- <form action="<?php echo base_url() ?>assetListing" method="POST" id="searchList">-->
<form action="<?php echo base_url() ?>monthlypay/monthlyListing" method="POST" id="searchList">
</form>
</div><!--</h3></center>-->
</div><!-- /.box-header -->
<div class="box-body">
<div class="col-md-12">
<div class="col-md-4">
<label>Customer</label>
<?php echo form_dropdown('customer',$customers,set_value('customer',$customers[-1]),'id="customer"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
<div class="col-md-4">
<label>Grade&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
<?php echo form_dropdown('product',$products,set_value('product',$products[-1]),'id="product"' ,'class="form-control select2', 'style="text-align:center;"');?>
</div>
<!-- <div class="col-md-3">
<label>Resin Batch Card No</label>
<input type="text" id="batchno" name="batchno" class="form-control" >
</div> -->
<div class="col-md-4">
<label>Batch Date</label>
<input type="text" id="batchdate" name="batchdate" class="form-control" >
</div>
</div>
</br>
<div class="col-md-12">
<div class="col-md-4">
<label>Resin Name</label>
<input type="text" id="resinname" name="resinname" class="form-control" >
</div>
<div class="col-md-4">
<label>Shift Name</label>
<input type="text" id="plantname" name="plantname" class="form-control" >
</div>
<div class="col-md-4">
<label>Machine Name</label>
<?php echo form_dropdown('machines',$machines,set_value('machines',$machines[-1]),'id="machines"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
</div>
</br>
<div class="col-md-12">
<div class="col-md-4">
<label>TRP Batch No(For TRP Sand)</label>
<?php echo form_dropdown('trpbatchnos',$trpbatchnos,set_value('trpbatchnos',$trpbatchnos[-1]), 'id="trpbatchnos"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
<div class="col-md-4">
<label>IGR No(For Fresh Sand)</label>
<?php echo form_dropdown('igrnos',$igrnos,set_value('igrnos',$igrnos[-1]),'id="igrnos"' ,'class="form-control select2','style="text-align:center;"','onChange="some_function();"');?>
</div>
<div class="col-md-4">
<label>IGR Line Item No</label>
<?php echo form_dropdown('igrlinenos',$igrlinenos,set_value('igrlinenos',$igrlinenos[-1]),'id="igrlinenos"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
</div>
</br>
<div class="col-md-12">
<div class="col-md-2">
<label>IGR No(For Resin )</label>
<?php echo form_dropdown('Resinigrnos',$igrnos,set_value('Resinigrnos',$igrnos[-1]),'id="Resinigrnos"' ,'class="form-control select2','style="text-align:center;"','onchange="getComboA()"');?>
</div>
<div class="col-md-2">
<label>IGR Line Item No</label>
<?php echo form_dropdown('Resinigrlinenos',$igrlinenos,set_value('Resinigrlinenos',$igrlinenos[-1]),'id="Resinigrlinenos"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
<div class="col-md-2">
<label>IGR No(For Hexamine)</label>
<?php echo form_dropdown('Hexamineigrnos',$igrnos,set_value('Hexamineigrnos',$igrnos[-1]),'id="Hexamineigrnos"' ,'class="form-control select2','style="text-align:center;"','onchange="getComboA(this)"');?>
</div>
<div class="col-md-2">
<label>IGR Line Item No</label>
<?php echo form_dropdown('Hexamineigrlinenos',$igrlinenos,set_value('Hexamineigrlinenos',$igrlinenos[-1]),'id="Hexamineigrlinenos"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
<div class="col-md-2">
<label>IGR No(For CS)</label>
<?php echo form_dropdown('CSigrnos',$igrnos,set_value('CSigrnos',$igrnos[-1]),'id="CSigrnos"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
<div class="col-md-2">
<label>IGR Line Item No</label>
<?php echo form_dropdown('CSigrlinenos',$igrlinenos,set_value('CSigrlinenos',$igrlinenos[-1]),'id="CSigrlinenos"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
</div>
</br>
<div class="col-md-12">
<div class="col-md-2">
<label>IGR No(For Catalyst)</label>
<?php echo form_dropdown('Catalystigrnos',$igrnos,set_value('Catalystigrnos',$igrnos[-1]),'id="Catalystigrnos"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
<div class="col-md-2">
<label>IGR Line Item No</label>
<?php echo form_dropdown('Catalystigrlinenos',$igrlinenos,set_value('Catalystigrlinenos',$igrlinenos[-1]),'id="Catalystigrlinenos"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
<div class="col-md-2">
<label>IGR No(For 50 Bags)</label>
<?php echo form_dropdown('bagsigrnos',$igrnos,set_value('bagsigrnos',$igrnos[-1]),'id="bagsigrnos"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
<div class="col-md-2">
<label>IGR Line Item No</label>
<?php echo form_dropdown('bagsigrlinenos',$igrlinenos,set_value('bagsigrlinenos',$igrlinenos[-1]),'id="bagsigrlinenos"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
<div class="col-md-2">
<label>IGR No(For 1 ton Bag)</label>
<?php echo form_dropdown('tonigrnos',$igrnos,set_value('tonigrnos',$igrnos[-1]),'id="tonigrnos"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
<div class="col-md-2">
<label>IGR Line Item No</label>
<?php echo form_dropdown('tonigrlinenos',$igrlinenos,set_value('tonigrlinenos',$igrlinenos[-1]),'id="tonigrlinenos"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
</div>
<p>&nbsp;</p>
<table id="testreport" class="table table-bordered" style="background-color:#fff;font-size:12px;text-align:center;">
<thead style="background-color:#ddf;">
<tr id="firstrowheader"><th>SNO</th><th>Time</th></tr>
<tr id="specname"><th>Particulars</th><th>Time</th></tr>
<tr id="huom"><th rowspan="2" style="text-align:center;">SNO</th><th>Unit</th></tr>
<tr id="spec"><th >Spec</th></tr>
</thead>
<tbody id="specAppend">
</tbody>
</table>
<br>
<div class="row">
<div class="col-md-offset-11 col-md-1" id="savebutton">
<input type="button" id="submit" value = "Add Row" class="btn btn-primary" onclick="addNewRow();">
</div>
</div>
<p><b>Raw/Packing Material Consumption<b></p>
<table id="finaltable" class="table table-bordered" style="background-color:#fff;font-size:12px;text-align:center;">
<thead style="background-color:#ddf;">
<tr><th>Particulars</th><th>Sand</th><th>Resin</th><th>Hexamine</th><th>CS</th><th>Catalyst</th><th>50 Bags</th><th>1 ton Bag</th><th>Production Loss <br> Lump</th><th>Finished Prodcut <br> PCS</th></tr>
<tr><th>Unit</th><th>Kgs</th><th>Kgs</th><th>Kgs</th><th>Kgs</th><th>Kgs</th><th>Kgs</th><th>Nos</th><th>Kgs</th><th>Kgs</th></tr>
</thead>
<tbody id="">
<tr><td>Qty</td><td id="sandtotal">0.00</td><td id="resintotal">0.00</td><td id="hextotal">0.00</td><td id="cstotal">0.00</td><td id="catalysttotal">0.00</td><td id="50bagtotal" contenteditable="true">0.00</td><td id="1tonbagtotal" contenteditable="true">0.00</td><td id="lumptotal" contenteditable="true">0.00</td><td id="pcstotal" contenteditable="true">0.00</td></tr>
</tbody>
</table>
<hr>
</div>
<div class="col-md-12">
<div class="row">&nbsp;</div>
<div class="col-md-12">
<div class="col-md-3">
<label>File Upload:</label>
<form id="report_file" name="report_file" enctype="multipart/form-data" accept-charset="utf-8" method="POST" action="">
<input type="file" id="reportfile" name="reportfile">
</form>
</div>
<div class="col-md-3">
<label>Helpers:</label>
<select name="listops" id="listops" multiple>
</select>
</div>
<div class="col-md-6">
<label>Remarks:</label>
<textarea id="remarks" class="form-control" rows="1"></textarea>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<!-- <label>Created By :</label>
<input type="text" id="inspector" class="form-control" value="<?php echo $this->session->userdata ( 'name' );?>" readonly> -->
<label>Select Operator :</label>
<?php echo form_dropdown('newoperator',$newoperator,set_value('newoperator',$newoperator[-1]),'id="newoperator"' ,'class="form-control select2', 'style="text-align:center;"');?>
<input type="hidden" value="<?php echo $this->session->userdata ( 'userId' );?>">
</div>
<div class="col-md-3">
<label>Select Helpers :</label>
<?php echo form_dropdown('operators',$operators,set_value('operators',$operators[-1]),'id="operators"' ,'class="form-control select2', 'style="text-align:center;"');?>
</div>
<div class="col-md-3 col-md-offset-3 ">
<label>Production In charge :</label>
<?php echo form_dropdown('name="approvedby"',$approvedby,set_value('approvedby',$approvedby[-1]),'id="approvedby"' ,'class="form-control select2', 'style="text-align:center;"');?>
<!-- <input type="text" id="approvedby" class="form-control"> -->
</div>
</div>
<div class="row">&nbsp;</div>
<div>
<div class="row">&nbsp;</div>
<div class="row">
<div class="col-md-3" id="savebutton">
<input type="button" id="submit" value = "Save" class="btn btn-primary" onclick="getAllData();">
</div>
</div>
</div><!-- /.box-body -->
<!-- <div class="box-footer clearfix">
</div> -->
</div>
</div>
</section>
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/common.js" charset="utf-8"></script>
<script type="text/javascript">
$(function () {
$('#monthlylisting').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"aaSorting": [[ 0, "asc" ]],
"info": true,
"autoWidth": true
});
});
</script>
<script>
$(document).ready(function(){
$("#loibutton").click(function(){
$("#loiarea").toggle("slow");
});
$("#afsbutton").click(function(){
$("#afsarea").toggle("slow");
});
$("#chartbutton").click(function(){
$("#chartarea").toggle("slow");
});
$('#batchdate').datepicker({
//minDate : 'year+16',
maxDate : 'now',
dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,yearRange: '0:+10'
});
$('#customer').select2();
$('#product').select2();
$('#machines').select2();
$('#igrnos').select2();
$('#trpbatchnos').select2();
$('#approvedby').select2();
$('#igrlinenos').select2();
$('#Resinigrnos').select2();
$('#Resinigrlinenos').select2();
$('#Hexamineigrnos').select2();
$('#Hexamineigrlinenos').select2();
$('#CSigrnos').select2();
$('#CSigrlinenos').select2();
$('#Catalystigrnos').select2();
$('#Catalystigrlinenos').select2();
$('#bagsigrnos').select2();
$('#bagsigrlinenos').select2();
$('#tonigrnos').select2();
$('#tonigrlinenos').select2();
$('#operators').select2();
$('#newoperator').select2();
//show_hide_column(13,false);
}); // End of document on ready funciton
function keyValidate(e)
{
if(((e.which || e.keyCode) == 8) || ((e.which || e.keyCode) == 9) || ((e.which || e.keyCode) == 46) || ((e.which || e.keyCode) == 37) || ((e.which || e.keyCode) == 39) || ((e.which || e.keyCode) == 45))
{
return true;
}
if(e.keyCode == 13)
{
return false;
}
if(((e.which || e.keyCode) < 48) || ((e.which || e.keyCode) > 57))
{
return false;
}
}
$('#product').change(function(){
getAllSpec();
});
$('#customer').change(function(){
getAllSpec();
});
var index = 0;
var allspecs = [];
var allspecvalues = [];
var flag = 0;
var totalcells = 0;
var overallrows = 0;
$('#igrnos').change(function(){
var html = '<option value = -1>Select IGRItemNo</option>';
var igrno = $('#igrnos').val();
$('.content').loader('show');
$.ajax({
data:{param1:igrno},
type:"POST",
url:"<?php echo base_url() ?>resinbatchcard/getIGRLineNo",
success:function(data) {
$('.content').loader('hide');
// alert(data);
data = JSON.parse(data);
if(data != ''){
$.each(data,function(index,value){
html+='<option value='+value.IGRItemNo+'>'+value.IGRItemNo+'</option>';
});
$('#igrlinenos').find('option').remove();
$('#igrlinenos').append(html);
}
else{
alert('No Line Item Available');
}
}
});
});
$('#Resinigrnos').change(function(){
var html = '<option value = -1>Select IGRItemNo</option>';
var igrno = $('#Resinigrnos').val();
//alert(igrno);
$('.content').loader('show');
$.ajax({
data:{param1:igrno},
//dataType:"json",
type:"POST",
url:"<?php echo base_url() ?>resinbatchcard/getIGRLineNo",
success:function(data) {
$('.content').loader('hide');
// alert(data);
data = JSON.parse(data);
if(data != ''){
$.each(data,function(index,value){
html+='<option value='+value.IGRItemNo+'>'+value.IGRItemNo+'</option>';
});
$('#Resinigrlinenos').find('option').remove();
$('#Resinigrlinenos').append(html);
}
else{
alert('No Line Item Available');
}
}
});
});
$('#Hexamineigrnos').change(function(){
var html = '<option value = -1>Select IGRItemNo</option>';
var igrno = $('#Hexamineigrnos').val();
//alert(igrno);
$('.content').loader('show');
$.ajax({
data:{param1:igrno},
//dataType:"json",
type:"POST",
url:"<?php echo base_url() ?>resinbatchcard/getIGRLineNo",
success:function(data) {
$('.content').loader('hide');
// alert(data);
data = JSON.parse(data);
if(data != ''){
$.each(data,function(index,value){
html+='<option value='+value.IGRItemNo+'>'+value.IGRItemNo+'</option>';
});
$('#Hexamineigrlinenos').find('option').remove();
$('#Hexamineigrlinenos').append(html);
}
else{
alert('No Line Item Available');
}
}
});
});
$('#CSigrnos').change(function(){
var html = '<option value = -1>Select IGRItemNo</option>';
var igrno = $('#CSigrnos').val();
//alert(igrno);
$('.content').loader('show');
$.ajax({
data:{param1:igrno},
//dataType:"json",
type:"POST",
url:"<?php echo base_url() ?>resinbatchcard/getIGRLineNo",
success:function(data) {
$('.content').loader('hide');
// alert(data);
data = JSON.parse(data);
if(data != ''){
$.each(data,function(index,value){
html+='<option value='+value.IGRItemNo+'>'+value.IGRItemNo+'</option>';
});
$('#CSigrlinenos').find('option').remove();
$('#CSigrlinenos').append(html);
}
else{
alert('No Line Item Available');
}
}
});
});
$('#Catalystigrnos').change(function(){
var html = '<option value = -1>Select IGRItemNo</option>';
var igrno = $('#Catalystigrnos').val();
//alert(igrno);
$('.content').loader('show');
$.ajax({
data:{param1:igrno},
//dataType:"json",
type:"POST",
url:"<?php echo base_url() ?>resinbatchcard/getIGRLineNo",
success:function(data) {
$('.content').loader('hide');
// alert(data);
data = JSON.parse(data);
if(data != ''){
$.each(data,function(index,value){
html+='<option value='+value.IGRItemNo+'>'+value.IGRItemNo+'</option>';
});
$('#Catalystigrlinenos').find('option').remove();
$('#Catalystigrlinenos').append(html);
}
else{
alert('No Line Item Available');
}
}
});
});
$('#bagsigrnos').change(function(){
var html = '<option value = -1>Select IGRItemNo</option>';
var igrno = $('#bagsigrnos').val();
//alert(igrno);
$('.content').loader('show');
$.ajax({
data:{param1:igrno},
//dataType:"json",
type:"POST",
url:"<?php echo base_url() ?>resinbatchcard/getIGRLineNo",
success:function(data) {
$('.content').loader('hide');
// alert(data);
data = JSON.parse(data);
if(data != ''){
$.each(data,function(index,value){
html+='<option value='+value.IGRItemNo+'>'+value.IGRItemNo+'</option>';
});
$('#bagsigrlinenos').find('option').remove();
$('#bagsigrlinenos').append(html);
}
else{
alert('No Line Item Available');
}
}
});
});
$('#tonigrnos').change(function(){
var html = '<option value = -1>Select IGRItemNo</option>';
var igrno = $('#tonigrnos').val();
//alert(igrno);
$('.content').loader('show');
$.ajax({
data:{param1:igrno},
//dataType:"json",
type:"POST",
url:"<?php echo base_url() ?>resinbatchcard/getIGRLineNo",
success:function(data) {
$('.content').loader('hide');
// alert(data);
data = JSON.parse(data);
if(data != ''){
$.each(data,function(index,value){
html+='<option value='+value.IGRItemNo+'>'+value.IGRItemNo+'</option>';
});
$('#tonigrlinenos').find('option').remove();
$('#tonigrlinenos').append(html);
}
else{
alert('No Line Item Available');
}
}
});
});
function getAllSpec()
{
var p = $('#product').val();
var c = $('#customer').val();
var type = 'RESINBATCHCARD';
if(p == -1 || c == -1)
{
return false;
}
else
{
$('.content').loader('show');
$.ajax({
data:{param1:p,param2:c,param3:type},
//dataType:"json",
type:"POST",
url:"<?php echo base_url() ?>quality/getAllSpecforReport",
success:function(data) {
// alert(data);
data = JSON.parse(data);
//alert(data);
// $('#testreport tbody').remove();
// $('#testreport').append('<tbody id="specAppend"></tbody>');
// $('#testreport2 tbody').remove();
// $('#testreport2').append('<tbody id="specAppend2"></tbody>');
if(data != '')
{
htmlspecname = '';
htmlspecid = '';
htmlspecuom = '';
htmlspec = '';
flag = 1;
$('.content').loader('hide');
$.each(data,function(i,item){
var ide='';
//console.log(item);
//console.log('master1');
ide = item.testtype;
ide = ide.replace(/\s/g, "");
ide = ide.toLowerCase();
htmlspecname +='<td>'+item.testtype+'</td>';
htmlspecid += '<td>'+item.productspecmaster_id+'</td>';
htmlspecuom += '<td>'+item.uom+'</td>';
htmlspec += '<td>'+item.min+'-'+item.max+'</td>';
allspecs.push(ide);
allspecvalues.push(item.min+'-'+item.max);
});
// console.log(allspecs);
//console.log(allspecvalues);
$("#specname").append(htmlspecname);
$("#firstrowheader").append(htmlspecid);
$("#huom").append(htmlspecuom);
$("#spec").append(htmlspec);
document.getElementById('firstrowheader').style.display = 'none';
totalcells = $('#testreport').find('tr').eq(1).find('td');
//console.log(totalcells);
totalcells = totalcells.length;
//alert('totalcellsbefore'+totalcells);
totalcells+=2;
//alert('totalcells'+totalcells);
index +=1;
htmlbody = '';
//var i = 0;
for(i=1;i<=totalcells;i++)
{
if(i == 1)
{
htmlbody+='<tr id='+index+'><td>'+index+'</td>';
//alert('1');
}
else if( i == 2)
{
htmlbody+='<td class="edit" id="time'+index+'" contenteditable="true" onblur="timeCheck(this.id,this.textContent)"></td>';
//alert('not 1');
}
else
{
//var temp = index;
//console.log(allspecs[temp]);
var temp = index+''+allspecs[i-3];
htmlbody+='<td class="edit" id="'+temp+'" contenteditable="true" onkeypress="return keyValidate(event);" onblur="masterCalculationCheck(this.id,this.textContent)"></td>';
//temp++;
}
//alert('inside for loop'+i);
}
htmlbody+='</tr>'
$("#testreport tbody").append(htmlbody);
overallrows++;
// $("#testreport2 tbody").append(htmlmaster2);
}
else
{
alert('No Master Records Found..!');
$('.content').loader('hide');
}
}
});
}
}
function addNewRow()
{
//alert(flag);
if(flag != 1)
{
alert('There is no report,Cannot Save');
return false;
}
index++;
if(index > 50)
{
alert('You have reached 50 Entries, No More...!');
return false;
}
console.log(index);
//var htmlrow = '<tr id='+index+'><td contenteditable="true" class="edit" id="time'+index+'">';
var htmlrow = '';
for(i=1;i<=totalcells;i++)
{
if(i == 1)
{
htmlrow+='<tr id='+index+'><td>'+index+'</td>';
//alert('1');
}
else if( i == 2)
{
htmlrow+='<td class="edit" id="time'+index+'" contenteditable="true" onblur="timeCheck(this.id,this.textContent)"></td>';
//alert('not 1');
}
else
{
//var temp = index;
//console.log(allspecs[temp]);
var temp = index+''+allspecs[i-3];
htmlrow+='<td class="edit" id="'+temp+'" contenteditable="true" onkeypress="return keyValidate(event);" onblur="masterCalculationCheck(this.id,this.textContent)"></td>';
//temp++;
}
//alert('inside for loop'+i);
}
htmlrow+='</tr>'
$("#testreport tbody").append(htmlrow);
overallrows++;
var ide = '#time'+index;
window.setTimeout(function() {
$(ide).focus();
}, 0);
}
function timeCheck(id,val)
{
var id = id;
//alert('timecheck'+id);
if(val == '')
{
alert('Please Enter Time..!');
document.getElementById(id).textContent='';
var ide = '#'+id;
//alert(ide);
window.setTimeout(function() {
$(ide).focus();
}, 0);
return false;
}
if(val.length != 5)
{
alert('Please Enter Valid 24 Hrs Time..!');
var ide = '#'+id;
//alert(ide);
window.setTimeout(function() {
$(ide).focus();
}, 0);
document.getElementById(id).textContent='';
return false;
}
if(val.length == 5)
{
var cur = val.split(':');
if(isNaN(cur[0]) || isNaN(cur[1]) || cur[0] > 24 || cur[1] > 59)
{
var ide = '#'+id;
//alert(ide);
window.setTimeout(function() {
$(ide).focus();
}, 0);
document.getElementById(id).textContent='';
alert('Please Enter Valid 24Hrs Time Format..!');
return false;
}
}
}
function masterCalculationCheck(id,val)
{
// console.log(id+'-'+val);
//console.log(val);
console.log(id);
//alert("sdaf");
var totalsandqty = 0;
var totalhexqty = 0;
var totalresinqty = 0;
var totalcsqty = 0;
var ide = id.substr(1)
var ide2 = id.substr(2);
//console.log(ide+'-'+ide2);
//For Total Sand Calculation
if(ide == 'sand')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
console.log("if "+parseFloat(currentvalue));
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalsandqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('sandtotal'))
{
document.getElementById('sandtotal').textContent = parseFloat(totalsandqty).toFixed(2);
}
}
else if(ide2 == 'sand')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide2;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalsandqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('sandtotal'))
{
document.getElementById('sandtotal').textContent = parseFloat(totalsandqty).toFixed(2);
}
}
//FOr total Hexamine Calculaiton
if(ide == 'hexamine')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalhexqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('hextotal'))
{
document.getElementById('hextotal').textContent = parseFloat(totalhexqty).toFixed(2);
}
}
else if(ide2 == 'hexamine')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide2;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalhexqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('hextotal'))
{
document.getElementById('hextotal').textContent = parseFloat(totalhexqty).toFixed(2);
}
}
if(ide == 'catalyst')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalsandqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('catalysttotal'))
{
document.getElementById('catalysttotal').textContent = parseFloat(totalsandqty).toFixed(2);
}
}
else if(ide2 == 'catalyst')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide2;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalsandqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('catalysttotal'))
{
document.getElementById('catalysttotal').textContent = parseFloat(totalsandqty).toFixed(2);
}
}
//FOr total Hexamine Calculaiton
if(ide == 'resin')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalresinqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('resintotal'))
{
document.getElementById('resintotal').textContent = parseFloat(totalresinqty).toFixed(2);
}
}
else if(ide2 == 'resin')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide2;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalresinqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('resintotal'))
{
document.getElementById('resintotal').textContent = parseFloat(totalresinqty).toFixed(2);
}
}
//FOr total Hexamine Calculaiton
if(ide == 'cs')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalcsqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('cstotal'))
{
document.getElementById('cstotal').textContent = parseFloat(totalcsqty).toFixed(2);
}
}
else if(ide2 == 'cs')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide2;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalcsqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('cstotal'))
{
document.getElementById('cstotal').textContent = parseFloat(totalcsqty).toFixed(2);
}
}
if(val == '')
{
//alert('Please Enter Time..!');
document.getElementById(id).textContent='0.00';
return false;
}
}
listopsforstore = [];
function getAllData()
{
//alert("inside function");
if(flag != 1)
{
alert('Cannot Save');
return false;
}
var testreportdata = $("#testreport").tableToJSON();
var finaltable = $("#finaltable").tableToJSON();
testreportdata=JSON.stringify(testreportdata);
// alert(testreportdata);
finaltable=JSON.stringify(finaltable);
//alert(finaltable);
var productid = $('#product').val();
var customerid = $('#customer').val();
var batchdate = $('#batchdate').val();
if(batchdate =='')
{
alert("Please Enter Batchdate");
return false;
}
var plantname = $('#plantname').val();
if(plantname =='')
{
alert("Please Enter Shiftname");
return false;
}
var resinname = $('#resinname').val();
if(resinname =='')
{
alert("Please Enter Resinname ");
return false;
}
var macinecode = $('#machines').val();
if(macinecode == -1)
{
alert("Please Select Machines");
return false;
}
var trpbatchcard = $('#trpbatchnos').val();
if(trpbatchcard == -1)
{
alert("Please Select Trpbatchcardno");
return false;
}
var igrnos = $('#igrnos').val();
var igrlinenos = $('#igrlinenos').val();
if(igrnos == -1 && igrlinenos == -1 )
{
igrnos = "";
igrlinenos = "";
}
if(igrnos != -1 && igrlinenos == -1 )
{
igrlinenos = "";
}
var Resinigrnos = $('#Resinigrnos').val();
var Resinigrlinenos = $('#Resinigrlinenos').val();
if(Resinigrnos== -1 && Resinigrlinenos== -1 )
{
Resinigrnos = "";
Resinigrlinenos = "";
}
if(Resinigrnos != -1 && Resinigrlinenos== -1 )
{
Resinigrlinenos = "";
}
var Hexamineigrnos = $('#Hexamineigrnos').val();
var Hexamineigrlinenos = $('#Hexamineigrlinenos').val();
if(Hexamineigrnos == -1 && Hexamineigrlinenos == -1 )
{
Hexamineigrnos = "";
Hexamineigrlinenos = "";
}
if(Hexamineigrnos != -1 && Hexamineigrlinenos == -1 )
{
Hexamineigrlinenos = "";
}
var CSigrnos = $('#CSigrnos').val();
var CSigrlinenos = $('#CSigrlinenos').val();
if(CSigrnos == -1 && CSigrlinenos == -1 )
{
CSigrnos= "";
CSigrlinenos = "";
}
if(CSigrnos != -1 && CSigrlinenos == -1 )
{
CSigrlinenos = "";
}
var Catalystigrnos = $('#Catalystigrnos').val();
var Catalystigrlinenos = $('#Catalystigrlinenos').val();
if(Catalystigrnos == -1 && Catalystigrlinenos== -1 )
{
Catalystigrnos = "";
Catalystigrlinenos = "";
}
if(Catalystigrnos != -1 && Catalystigrlinenos== -1 )
{
Catalystigrlinenos = "";
}
var bagsigrnos = $('#bagsigrnos').val();
var bagsigrlinenos = $('#bagsigrlinenos').val();
if(bagsigrnos == -1 && bagsigrlinenos== -1 )
{
bagsigrnos = "";
bagsigrlinenos = "";
}
if(bagsigrnos != -1 && bagsigrlinenos== -1 )
{
bagsigrlinenos = "";
}
var tonigrnos = $('#tonigrnos').val();
var tonigrlinenos = $('#tonigrlinenos').val();
if(tonigrnos== -1 && tonigrlinenos== -1 )
{
tonigrnos = "";
tonigrlinenos = "";
}
if(tonigrnos!= -1 && tonigrlinenos== -1 )
{
tonigrlinenos = ""; }
var remarks = $('#remarks').val();
var approvedby = $('#approvedby').val();
var operatorby = $('#newoperator').val();
if(productid == -1 || customerid == -1 || batchdate == '' || plantname == '' || macinecode == -1 || approvedby == -1 || listopsforstore.length == 0 || resinname == '' || operatorby == -1 )
{
alert('Please Enter All Master Details..!');
return false;
}
if(( igrnos == -1 || igrlinenos == -1) && trpbatchcard == -1 )
{
alert('Please Enter All Master Details...!');
return false;
}
var f = 0;
for(i=1;i<=overallrows;i++)
{
if(document.getElementById('time'+i).textContent == '')
{
f++;
}
}
// console.log('F value'+f);
if(f != 0)
{
alert('Please Enter Time for All Entry..! ');
return false;
}
listopsforstore = JSON.stringify(listopsforstore);
if(trpbatchcard == -1 )
{
trpbatchcard ="";
}
if(igrnos == -1 )
{
igrnos = "";
}
if(igrlinenos == -1 )
{
igrlinenos = "";
}
var formData = new FormData();
var reportfile = $("#reportfile").prop('files')[0];
formData.append('rfile',reportfile);
var param1 = productid;
var param2 = customerid;
var param3 = batchdate;
var param4 = plantname;
var param5 = macinecode;
var param6 = trpbatchcard;
var param7 = igrnos;
var param8 = igrlinenos;
var param9 = remarks;
var param10 = approvedby;
var param11 = testreportdata;
var param12 = finaltable;
var param13 = resinname;
var param14 = listopsforstore;
var param15 = operatorby;
var param16 = igrnos+'-'+igrlinenos;
var param17 = Resinigrnos+'-'+Resinigrlinenos;
var param18 = Hexamineigrnos+'-'+Hexamineigrlinenos
var param19 = CSigrnos+'-'+CSigrlinenos ;
var param20 = Catalystigrnos+'-'+Catalystigrlinenos;
var param21 = bagsigrnos+'-'+bagsigrlinenos;
var param22 = tonigrnos+'-'+tonigrlinenos;
formData.append('param1',param1);
formData.append('param2',param2);
formData.append('param3',param3);
formData.append('param4',param4);
formData.append('param5',param5);
formData.append('param6',param6);
formData.append('param7',param7);
formData.append('param8',param8);
formData.append('param9',param9);
formData.append('param10',param10);
formData.append('param11',param11);
formData.append('param12',param12);
formData.append('param13',param13);
formData.append('param14',param14);
formData.append('param15',param15);
formData.append('param16',param16);
formData.append('param17',param17);
formData.append('param18',param18);
formData.append('param19',param19);
formData.append('param20',param20);
formData.append('param21',param21);
formData.append('param22',param22);
$('.content').loader('show');
$.ajax({
data:formData,
type:"POST",
url:"<?php echo base_url() ?>resinbatchcard/saveTestReportData",
//async : false,
cache : false,
contentType : false,
processData : false,
success:function(data) {
if(data){
alert(data);
$('.content').loader('hide');
window.location = "<?php echo base_url().'resinbatchcard/resinBatchCardLisitng';?>";
}
}
});
}
$('#operators').change(function(){
var val = $('#operators').val();
var text = $("#operators option:selected").text();
//alert(val);
//alert(text);
var totalelements = listopsforstore.length
if(totalelements != 0)
{
$.each(listopsforstore,function(key,value){
//alert(value);
if(value == val)
{
alert('Helper Already Added..!Choose Another One.!');
brea();
}
});
}
listopsforstore.push(val);
//console.log(listopsforstore);
$("#listops").append('<option value='+val+'>'+text+'</option>');
});
$("#listops").dblclick(function(){
var text = $("#listops option:selected").text();
var val = $('#listops').val();
//alert(text+'-'+val);
$('option:selected', this).remove();
listopsforstore = listopsforstore.filter(item => item != val);
//console.log(listopsforstore);
});
</script>