1109 lines
31 KiB
PHP
Executable File
1109 lines
31 KiB
PHP
Executable File
<style>
|
|
.edit {
|
|
|
|
background-color: #eeffcc ! important;
|
|
|
|
}
|
|
</style>
|
|
<?php
|
|
//color:red ! important;
|
|
|
|
$invoicenos = array(-1 => 'Select Invoice No');
|
|
foreach ($records as $rec) {
|
|
$invoicenos[$rec->invoice_number] = $rec->invoice_number;
|
|
}
|
|
|
|
//print_r($emplist);
|
|
$approvedby = array(-1 => 'Select Approver Name');
|
|
foreach ($emplist as $r) {
|
|
$approvedby[$r->FirstName . ' ' . $r->LastName] = $r->FirstName . ' ' . $r->LastName . '-' . $r->shortName;
|
|
}
|
|
|
|
?>
|
|
<style>
|
|
th {
|
|
text-align: center !important;
|
|
}
|
|
</style>
|
|
<script src="<?php echo base_url() ?>public/assets/lightswitch/lightswitch/lib/jquery.tabletojson.js"></script>
|
|
<script src="<?php echo base_url() ?>public/assets/lightswitch/lightswitch/lib/jquery.tabletojson.min.js"></script>
|
|
<div class="content-wrapper">
|
|
<!-- Content Header (Page header) -->
|
|
<section class="content-header">
|
|
<h1>
|
|
<center>Pre Dispatch Inspection Report 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="row">
|
|
<div class="col-md-3">
|
|
<label>Invoice No</label>
|
|
<?php echo form_dropdown('name="invoiceno"', $invoicenos, set_value('invoiceno', $invoicenos[-1]), 'id="invoiceno"', 'class="form-control select2', 'style="text-align:center;"'); ?>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<label>Invoice Date</label>
|
|
<input type="text" id="invoicedate" name="invoicedate" class="form-control" readonly>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<label>Customer Name</label>
|
|
<input type="text" id="customername" name="customername" class="form-control" readonly>
|
|
<input type="hidden" id="customerid" name="customerid" readonly>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<label>Product Name</label>
|
|
<input type="text" id="productname" name="productname" class="form-control" readonly>
|
|
<input type="hidden" id="productid" name="productid" readonly>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-3">
|
|
<label>Batch No</label>
|
|
<input type="text" id="batchno" name="batchno" class="form-control" readonly>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<label>Qty</label>
|
|
<input type="text" id="qty" name="qty" class="form-control ;" readonly>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<label>Batch Date</label>
|
|
<input type="text" id="reportdate" name="reportdate" class="form-control">
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
<br />
|
|
<table id="testreport" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;text-align:center;">
|
|
<thead style="background-color: #00d976;;">
|
|
<tr>
|
|
|
|
<th width="3px">SNO</th>
|
|
<th>Description</th>
|
|
<th width="5px">Specification</br>Min</th>
|
|
<th width="5px">Specification</br>Max</th>
|
|
<th width="5px">Specification</br>UOM</th>
|
|
<th>ACT X1</th>
|
|
<th>ACT X2</th>
|
|
<th>ACT X3</th>
|
|
<th width="5px">Average</th>
|
|
<th width="5px">Results</th>
|
|
<th>Remarks</th>
|
|
|
|
|
|
</tr>
|
|
</thead>
|
|
<tbody id="specAppend">
|
|
|
|
</tbody>
|
|
</table>
|
|
<p> </p>
|
|
<hr>
|
|
|
|
<div class="col-md-12">
|
|
|
|
<div class="col-md-3"><b> L.O.I Details </b></div>
|
|
<div class="col-md-1 col-md-offset-8 text-right"><i class="fa fa-expand" id="loibutton"></i></div>
|
|
|
|
</div>
|
|
<div id="loiarea">
|
|
<table id="loitable" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;text-align:center;">
|
|
<thead>
|
|
<tr>
|
|
|
|
<th>
|
|
<center>SNO</center>
|
|
</th>
|
|
<th>
|
|
<center>Heating Time</center></br>
|
|
<center>start</center>
|
|
</th>
|
|
<th>
|
|
<center>Heating Time</center></br>
|
|
<center>end</center>
|
|
</th>
|
|
<th>Temp *c</th>
|
|
<th>
|
|
<center>Crucible Weight</center></br>
|
|
<center>w1(g)<center>
|
|
</th>
|
|
<th>
|
|
<center>Before Heating</center></br>
|
|
<center>w2(g)</center>
|
|
</th>
|
|
<th>
|
|
<center>After Heating<center></br>w3(g)</center>
|
|
</th>
|
|
<th>L.O.I %</th>
|
|
<th>Remarks</th>
|
|
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
<tbody id="loiAppend">
|
|
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
|
|
<div class="col-md-12">
|
|
|
|
<div class="col-md-3"><b> AFS Details </b></div>
|
|
<div class="col-md-1 col-md-offset-8 text-right"><i class="fa fa-expand" id="afsbutton"></i></div>
|
|
|
|
</div>
|
|
<div id="afsarea">
|
|
<table id="afstable" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;text-align:center;">
|
|
<thead>
|
|
<tr>
|
|
|
|
<th>NO</th>
|
|
<th>Sieve Size µm</th>
|
|
<th>Sand Weight</th>
|
|
<th>Percentage</th>
|
|
<th>Multiplier</th>
|
|
<th>Product</th>
|
|
|
|
|
|
</tr>
|
|
</thead>
|
|
<tbody id="afsAppend">
|
|
<tr id="1">
|
|
<td>1</td>
|
|
<td id="1size">1700</td>
|
|
<td id="1sw" class="edit" contenteditable="true" onkeyup="calculateAFS(this.parentNode.id,this.textContent,this.id);">0.00</td>
|
|
<td id="1p">0.00</td>
|
|
<td id="1m">5</td>
|
|
<td id="1pt">0.0000</td>
|
|
</tr>
|
|
<tr id="2">
|
|
<td>2</td>
|
|
<td id="2size">850</td>
|
|
<td id="2sw" class="edit" contenteditable="true" onkeyup="calculateAFS(this.parentNode.id,this.textContent,this.id);">0.00</td>
|
|
<td id="2p">0.00</td>
|
|
<td id="2m">10</td>
|
|
<td id="2pt">0.0000</td>
|
|
</tr>
|
|
<tr id="3">
|
|
<td>3</td>
|
|
<td id="3size">600</td>
|
|
<td id="3sw" class="edit" contenteditable="true" onkeyup="calculateAFS(this.parentNode.id,this.textContent,this.id);">0.00</td>
|
|
<td id="3p">0.00</td>
|
|
<td id="3m">20</td>
|
|
<td id="3pt">0.0000</td>
|
|
</tr>
|
|
<tr id="4">
|
|
<td>4</td>
|
|
<td id="4size">425</td>
|
|
<td id="4sw" class="edit" contenteditable="true" onkeyup="calculateAFS(this.parentNode.id,this.textContent,this.id);">0.00</td>
|
|
<td id="4p">0.00</td>
|
|
<td id="4m">30</td>
|
|
<td id="4pt">0.0000</td>
|
|
</tr>
|
|
<tr id="5">
|
|
<td>5</td>
|
|
<td id="5size">300</td>
|
|
<td id="5sw" class="edit" contenteditable="true" onkeyup="calculateAFS(this.parentNode.id,this.textContent,this.id);">0.00</td>
|
|
<td id="5p">0.00</td>
|
|
<td id="5m">40</td>
|
|
<td id="5pt">0.0000</td>
|
|
</tr>
|
|
<tr id="6">
|
|
<td>6</td>
|
|
<td id="6size">212</td>
|
|
<td id="6sw" class="edit" contenteditable="true" onkeyup="calculateAFS(this.parentNode.id,this.textContent,this.id);">0.00</td>
|
|
<td id="6p">0.00</td>
|
|
<td id="6m">50</td>
|
|
<td id="6pt">0.0000</td>
|
|
</tr>
|
|
<tr id="7">
|
|
<td>7</td>
|
|
<td id="7size">150</td>
|
|
<td id="7sw" class="edit" contenteditable="true" onkeyup="calculateAFS(this.parentNode.id,this.textContent,this.id);">0.00</td>
|
|
<td id="7p">0.00</td>
|
|
<td id="7m">70</td>
|
|
<td id="7pt">0.0000</td>
|
|
</tr>
|
|
<tr id="8">
|
|
<td>8</td>
|
|
<td id="8size">106</td>
|
|
<td id="8sw" class="edit" contenteditable="true" onkeyup="calculateAFS(this.parentNode.id,this.textContent,this.id);">0.00</td>
|
|
<td id="8p">0.00</td>
|
|
<td id="8m">100</td>
|
|
<td id="8pt">0.0000</td>
|
|
</tr>
|
|
<tr id="9">
|
|
<td>9</td>
|
|
<td id="9size">75</td>
|
|
<td id="9sw" class="edit" contenteditable="true" onkeyup="calculateAFS(this.parentNode.id,this.textContent,this.id);">0.00</td>
|
|
<td id="9p">0.00</td>
|
|
<td id="9m">140</td>
|
|
<td id="9pt">0.0000</td>
|
|
</tr>
|
|
<tr id="10">
|
|
<td>10</td>
|
|
<td id="10size">53</td>
|
|
<td id="10sw" class="edit" contenteditable="true" onkeyup="calculateAFS(this.parentNode.id,this.textContent,this.id);">0.00</td>
|
|
<td id="10p">0.00</td>
|
|
<td id="10m">200</td>
|
|
<td id="10pt">0.0000</td>
|
|
</tr>
|
|
<tr id="11">
|
|
<td>11</td>
|
|
<td id="11size">pan</td>
|
|
<td id="11sw" class="edit" contenteditable="true" onkeyup="calculateAFS(this.parentNode.id,this.textContent,this.id);">0.00</td>
|
|
<td id="11p">0.00</td>
|
|
<td id="11m">300</td>
|
|
<td id="11pt">0.0000</td>
|
|
</tr>
|
|
<tr id="12">
|
|
<td> </td>
|
|
<td><b>Total</b></td>
|
|
<td id="12sw">0.00</td>
|
|
<td id="12p">0.00</td>
|
|
<td id="12m"> </td>
|
|
<td id="12pt">0.0000</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="col-md-12">
|
|
|
|
<div class="col-md-3"><b>AFS CHART </b></div>
|
|
<div class="col-md-1 col-md-offset-8 text-right"><i class="fa fa-expand" id="chartbutton"></i></div>
|
|
|
|
</div>
|
|
<div id="chartarea">
|
|
<div>
|
|
<center><canvas id="myCanvas" width="1000" height="350" style="border:1px solid #d3d3d3;">
|
|
Your browser does not support the HTML5 canvas tag.</canvas></center>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="row"> </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>
|
|
<div class="col-md-12">
|
|
|
|
<div class="col-md-3">
|
|
<label>Inspected By :</label>
|
|
<input type="text" id="inspector" class="form-control" value="<?php echo $this->session->get('name'); ?>" readonly>
|
|
<input type="hidden" value="<?php echo $this->session->get('userId'); ?>">
|
|
</div>
|
|
|
|
<div class="col-md-3 col-md-offset-6 ">
|
|
<label>Approved By :</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"> </div>
|
|
<div>
|
|
<div class="row"> </div>
|
|
<div class="row">
|
|
<div class="col-md-3" id="savebutton">
|
|
<input type="button" id="submit" value="Save" class="btn btn-success" 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(); ?>public/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");
|
|
});
|
|
|
|
$('#reportdate').datepicker({
|
|
//minDate : 'year+16',
|
|
maxDate: 'now',
|
|
dateFormat: 'dd-mm-yy',
|
|
changeMonth: true,
|
|
changeYear: true,
|
|
yearRange: '0:+10'
|
|
|
|
});
|
|
|
|
$('#invoiceno').select2();
|
|
|
|
// alert(e);
|
|
// });
|
|
|
|
var jsrecords = <?php echo json_encode($records); ?>;
|
|
|
|
|
|
$('#invoiceno').change(function() {
|
|
|
|
var invoiceid = $('#invoiceno').val();
|
|
//alert(invoiceid);
|
|
////console.log(jsrecords);
|
|
//console.log(jsrecords[0]['invoice_id'])
|
|
$.each(jsrecords, function(index, value) {
|
|
// console.log(index+'-'+value['invoice_id']);
|
|
|
|
if (invoiceid == value['invoice_number']) {
|
|
|
|
$('#testreport tbody').remove();
|
|
$('#testreport').append('<tbody id="specAppend"></tbody>');
|
|
|
|
$('#loitable tbody').remove();
|
|
$('#loitable').append('<tbody id="loiAppend"></tbody>');
|
|
|
|
var d = new Date(value['invoice_date_created']);
|
|
var d = d.getDate() + '-' + (d.getMonth() + 1) + '-' + d.getFullYear();
|
|
$('#invoicedate').val(d);
|
|
$('#customername').val(value['client_id'] + '-' + value['client_name']);
|
|
$('#customerid').val(value['client_id']);
|
|
$('#productname').val(value['item_product_id'] + '-' + value['product_name'] + '-' + value['product_description']);
|
|
$('#productid').val(value['item_product_id']);
|
|
$('#qty').val(value['item_quantity']);
|
|
var batchno = 0;
|
|
if (value['invoice_custom_fieldvalue'] != '') {
|
|
batchno = value['invoice_custom_fieldvalue'];
|
|
}
|
|
$('#batchno').val(batchno);
|
|
}
|
|
});
|
|
|
|
var productid = $('#productid').val();
|
|
var customerid = $('#customerid').val();
|
|
var type = 'OUTWARD';
|
|
$('#loader').show();
|
|
$.ajax({
|
|
data: {
|
|
param1: productid,
|
|
param2: customerid,
|
|
param3: type
|
|
},
|
|
type: "POST",
|
|
url: "<?php echo base_url() ?>quality/getAllSpecforReport",
|
|
success: function(data) {
|
|
if (data) {
|
|
//alert(data);
|
|
var jsdata = data;
|
|
var jsdata = JSON.parse(jsdata);
|
|
// console.log(jsdata);
|
|
var html = '';
|
|
var html2 = '';
|
|
$.each(jsdata, function(i, item) {
|
|
|
|
var index = i + 1;
|
|
var test = item['testtype'];
|
|
var min = item['min'];
|
|
var max = item['max'];
|
|
var uom = item['uom'];
|
|
var temp = item['temp'];
|
|
//console.log(spec);
|
|
|
|
html += '<tr id=' + index + '><td>' + index + '</td><td id=' + index + 'description>' + test + '</td><td id=' + index + 'min>' + min + '</td><td id=' + index + 'max>' + max + '</td><td>' + uom + '</td>';
|
|
|
|
if (test != 'AFS' && test != 'LOI') {
|
|
html += '<td class="edit" contenteditable="true" onkeyup="calculateMaster(this.id);" id=' + index + 'act1>0.00</td> <td class="edit" contenteditable="true" onkeyup="calculateMaster(this.id);" id=' + index + 'act2>0.00</td> <td class="edit" contenteditable="true" onkeyup="calculateMaster(this.id);" id=' + index + 'act3>0.00</td>';
|
|
} else if (test == 'AFS') {
|
|
html += '<td colspan="3" id="AFS" onkeyup="calculateMaster(this.id);">0.00</td>';
|
|
} else if (test == 'LOI') {
|
|
html += '<td onkeyup="calculateMaster(this.id);" id=1loi' + index + '>0.00</td> <td onkeyup="calculateMaster(this.id);" id=2loi' + index + '>0.00</td> <td onkeyup="calculateMaster(this.id);" id=3loi' + index + '>0.00</td>';
|
|
}
|
|
|
|
html += '<td id=' + index + 'avg>0.00</td><td id=' + index + 'result>-</td><td contenteditable="true"></td></tr>';
|
|
|
|
if (test == 'LOI') {
|
|
for (i = 1; i <= 3; i++) {
|
|
html2 += '<tr id=' + i + '> <td>' + i + '</td> <td class="edit" contenteditable="true" id=' + i + 'start onkeyup="calculateMaster(this.id);">0.00</td> <td class="edit" contenteditable="true" id=' + i + 'end onkeyup="calculateMaster(this.id);">0.00</td> <td id=' + i + 'temp>' + temp + '</td>';
|
|
html2 += '<td class="edit" contenteditable="true" id=' + i + 'w1 onkeyup="calculateMaster(this.id);">0.00</td> <td class="edit" contenteditable="true" id=' + i + 'w2 onkeyup="calculateMaster(this.id);">0.00</td> <td class="edit" contenteditable="true" id=' + i + 'w3 onkeyup="calculateMaster(this.id);">0.00</td> <td id=' + i + 'loi>0.00</td> <td contenteditable="true"></td> </tr>';
|
|
}
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
$("#testreport tbody").append(html);
|
|
$("#loitable tbody").append(html2);
|
|
$('#loader').hide();
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
}); //End of invoice change funciton
|
|
|
|
|
|
$('.edit').bind('keypress', function(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)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
if (e.keyCode == 13) {
|
|
|
|
return false;
|
|
}
|
|
if (((e.which || e.keyCode) < 48) || ((e.which || e.keyCode) > 57)) {
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}); // End of document on ready funciton
|
|
|
|
function calculateMaster(id) {
|
|
if (document.getElementById('12sw')) {
|
|
var SW12 = document.getElementById('12sw').textContent;
|
|
if (SW12 != 100) {
|
|
alert('AFS Details Sand Weight Total Should be 100..!');
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if ($('#invoiceno').val() == -1) {
|
|
alert('Select Invoice No');
|
|
return false;
|
|
}
|
|
var cid = id;
|
|
if (document.getElementById(id)) {
|
|
var cvalue = document.getElementById(id).textContent;
|
|
if (cvalue == 0) {
|
|
document.getElementById(id).textContent = '';
|
|
}
|
|
}
|
|
var Rows = $('#testreport').find('tr');
|
|
var size = Object.keys(Rows).length;
|
|
size = size - 5;
|
|
var LOIROWNO = 0;
|
|
|
|
for (i = 1; i <= size; i++) {
|
|
var Row = $('#testreport').find('tr').eq(i).find('td');
|
|
//console.log(Row);
|
|
var desc = '';
|
|
var min = '';
|
|
var max = '';
|
|
var act1 = '';
|
|
var act2 = '';
|
|
var act3 = '';
|
|
var avg = '';
|
|
var res = '';
|
|
|
|
|
|
$.each(Row, function(index, value) {
|
|
|
|
//console.log(index);
|
|
|
|
if (index != 0 && index != 4 && index != 10) {
|
|
//console.log('**************************************');
|
|
//console.log(value.id+'-'+value.textContent);
|
|
if (index == 1) {
|
|
desc = value.textContent;
|
|
}
|
|
if (index == 2) {
|
|
min = value.textContent;
|
|
}
|
|
if (index == 3) {
|
|
max = value.textContent;
|
|
}
|
|
if (index == 5) {
|
|
act1 = value.textContent;
|
|
}
|
|
if (index == 6) {
|
|
act2 = value.textContent;
|
|
}
|
|
if (index == 7) {
|
|
act3 = value.textContent;
|
|
}
|
|
}
|
|
|
|
});
|
|
if (desc == 'LOI') {
|
|
LOIROWNO = i;
|
|
}
|
|
if (desc != 'AFS') {
|
|
if (isNaN(act1) || act1 == '' || act1 == null) {
|
|
act1 = 0.00;
|
|
}
|
|
if (isNaN(act2) || act2 == '' || act2 == null) {
|
|
act2 = 0.00;
|
|
}
|
|
if (isNaN(act3) || act3 == '' || act3 == null) {
|
|
act3 = 0.00;
|
|
}
|
|
avg = ((parseFloat(act1) + parseFloat(act2) + parseFloat(act3)) / 3);
|
|
} else {
|
|
avg = document.getElementById('AFS').textContent;
|
|
}
|
|
|
|
min = parseFloat(min);
|
|
max = parseFloat(max);
|
|
avg = parseFloat(avg);
|
|
//console.log(min+'-'+max+'-'+avg);
|
|
|
|
var curavgid = i + 'avg';
|
|
document.getElementById(curavgid).textContent = parseFloat(avg).toFixed(2);
|
|
if ($.isNumeric(min) && $.isNumeric(max)) {
|
|
if (avg >= min && avg <= max) {
|
|
res = 'OK';
|
|
} else {
|
|
res = 'NG';
|
|
}
|
|
} else if ($.isNumeric(min) && !($.isNumeric(max))) {
|
|
if (avg >= min) {
|
|
res = 'OK';
|
|
//alert(res);
|
|
} else {
|
|
res = 'NG';
|
|
}
|
|
} else if (!$.isNumeric(min) && $.isNumeric(max)) {
|
|
if (avg <= max) {
|
|
res = 'OK';
|
|
} else {
|
|
res = 'NG';
|
|
}
|
|
}
|
|
var curresultid = i + 'result';
|
|
document.getElementById(curresultid).textContent = res;
|
|
}
|
|
|
|
|
|
for (j = 1; j <= 3; j++) {
|
|
var loiRow = $('#loitable').find('tr').eq(j).find('td');
|
|
var start = '';
|
|
var end = '';
|
|
var temp = '';
|
|
var act1 = '';
|
|
var w1 = '';
|
|
var w2 = '';
|
|
var w3 = '';
|
|
var loiid = '';
|
|
var loi = 0;
|
|
$.each(loiRow, function(iter, rec) {
|
|
|
|
|
|
if (iter != 0 && iter != 8) {
|
|
//console.log('**************************************');
|
|
//console.log(iter+'-'+rec.id+'-'+rec.textContent);
|
|
if (iter == 1) {
|
|
start = rec.textContent;
|
|
}
|
|
if (iter == 2) {
|
|
end = rec.textContent;
|
|
}
|
|
if (iter == 3) {
|
|
temp = rec.textContent;
|
|
}
|
|
if (iter == 4) {
|
|
w1 = rec.textContent;
|
|
}
|
|
if (iter == 5) {
|
|
w2 = rec.textContent;
|
|
}
|
|
if (iter == 6) {
|
|
w3 = rec.textContent;
|
|
}
|
|
if (iter == 7) {
|
|
loiid = rec.id;
|
|
}
|
|
}
|
|
|
|
|
|
});
|
|
|
|
w1 = parseFloat(w1);
|
|
w2 = parseFloat(w2);
|
|
w3 = parseFloat(w3);
|
|
//console.log(w1+'-'+w2+'-'+w3);
|
|
loi = ((w2 - w3) / (w2 - w1)) * 100;
|
|
loi = isNaN(loi) ? 0.00 : parseFloat(loi).toFixed(2);
|
|
//console.log(w1+'-'+w2+'-'+w3+'-'+loi);
|
|
var curid = j + 'loi';
|
|
if (document.getElementById(curid)) {
|
|
document.getElementById(curid).textContent = parseFloat(loi).toFixed(2);
|
|
}
|
|
var curid = j + 'loi' + LOIROWNO;
|
|
//console.log(curid);
|
|
if (document.getElementById(curid)) {
|
|
document.getElementById(curid).textContent = parseFloat(loi).toFixed(2);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
function getAllData() {
|
|
|
|
calculateMaster();
|
|
var Rows = $('#testreport').find('tr');
|
|
var size = Object.keys(Rows).length;
|
|
var flag = 0;
|
|
size = size - 5;
|
|
|
|
|
|
if ($('#invoiceno').val() == -1 || $('#reportdate').val() == '') {
|
|
alert('Select Invoice No and Batch Date');
|
|
return false;
|
|
}
|
|
|
|
for (z = 1; z <= size; z++) {
|
|
var ide = z + 'result';
|
|
var res = document.getElementById(ide).textContent;
|
|
//console.log(res)
|
|
if (res != 'OK') {
|
|
flag++;
|
|
}
|
|
}
|
|
// alert(flag);
|
|
var total_sandweight = parseFloat(document.getElementById('12sw').textContent);
|
|
if (flag != 0 || (total_sandweight != 100)) {
|
|
alert('Test Failed, Cant Save Test Report!');
|
|
return false;
|
|
}
|
|
|
|
if ($('#approvedby').val() == -1) {
|
|
alert('Enter Approver Name');
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
var testreportdata = $("#testreport").tableToJSON();
|
|
var testloidata = $("#loitable").tableToJSON();
|
|
var testafsdata = $("#afstable").tableToJSON();
|
|
|
|
testreportdata = JSON.stringify(testreportdata);
|
|
testloidata = JSON.stringify(testloidata);
|
|
testafsdata = JSON.stringify(testafsdata);
|
|
// alert(testreportdata);
|
|
// alert(testloidata);
|
|
// alert(testafsdata);
|
|
|
|
var invoiceno = $('#invoiceno').val();
|
|
var batchno = $('#reportdate').val();
|
|
var approvedby = $('#approvedby').val();
|
|
|
|
var product = $('#product').val();
|
|
var customer = $('#customer').val();
|
|
if (product == -1 || customer == -1) {
|
|
alert('Please Select Product and Customer.');
|
|
} else {
|
|
|
|
var c = document.getElementById("myCanvas");
|
|
var fullQuality = c.toDataURL('image/png', 1.0);
|
|
var formData = new FormData();
|
|
var reportfile = $("#reportfile").prop('files')[0];
|
|
formData.append('rfile', reportfile);
|
|
|
|
var param1 = testreportdata;
|
|
var param2 = testloidata;
|
|
var param3 = testafsdata;
|
|
var param4 = invoiceno;
|
|
var param5 = batchno;
|
|
var param6 = approvedby;
|
|
var param7 = fullQuality;
|
|
|
|
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);
|
|
|
|
$('#loader').show();
|
|
$.ajax({
|
|
data: formData,
|
|
//dataType:"json",{param1:testreportdata,param2:testloidata,param3:testafsdata,param4:invoiceno,param5:batchno,param6:approvedby,param7:fullQuality}
|
|
type: "POST",
|
|
url: "<?php echo base_url() ?>quality/saveTestReportData",
|
|
//async : false,
|
|
cache: false,
|
|
contentType: false,
|
|
processData: false,
|
|
success: function(data) {
|
|
if (data) {
|
|
alert(data);
|
|
$('#loader').hide();
|
|
window.location = "<?php echo base_url() . 'qualityreportlist'; ?>";
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
//
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function calculateAFS(pid, cvalue, cid) {
|
|
|
|
if ($('#invoiceno').val() == -1) {
|
|
alert('Select Invoice No');
|
|
//return false;
|
|
}
|
|
var cid = cid;
|
|
// if(cvalue == 0)
|
|
// {
|
|
// document.getElementById(cid).textContent = '';
|
|
// }
|
|
|
|
var Row = $('#afstable').find('tr').eq(pid).find('td');
|
|
|
|
var sandweight = '';
|
|
var sandweightid = '';
|
|
var percentage = '';
|
|
var percentageid = '';
|
|
var multiplier = '';
|
|
var multiplierid = '';
|
|
var product = '';
|
|
var productid = '';
|
|
|
|
$.each(Row, function(index, item) {
|
|
|
|
|
|
if (index == 2) {
|
|
|
|
//console.log('sanweight'+item.textContent);
|
|
sandweight = item.textContent;
|
|
sandweightid = item.id;
|
|
//console.log('sanweight'+item.textContent);
|
|
} else if (index == 3) {
|
|
percentageid = item.id;
|
|
percentage = item.textContent;
|
|
} else if (index == 4) {
|
|
multiplierid = item.id;
|
|
multiplier = item.textContent;
|
|
} else if (index == 5) {
|
|
product = item.textContent;
|
|
productid = item.id;
|
|
}
|
|
|
|
});
|
|
|
|
if (isNaN(sandweight) || sandweight == '' || sandweight == null) {
|
|
sandweight = 0.00;
|
|
}
|
|
|
|
//console.log('sanweight'+sandweight);
|
|
if (isNaN(cvalue) || cvalue == '' || cvalue == null) {
|
|
cvalue = 0.00;
|
|
}
|
|
document.getElementById(percentageid).textContent = parseFloat(sandweight).toFixed(2);
|
|
prodcut = (sandweight * multiplier);
|
|
document.getElementById(productid).textContent = parseFloat(prodcut).toFixed(4);
|
|
var totalsandweight = 0;
|
|
var totalproduct = 0;
|
|
for (i = 1; i <= 11; i++) {
|
|
var id = i + 'sw';
|
|
var temp = parseFloat(document.getElementById(id).textContent);
|
|
if (isNaN(temp) || temp == '' || temp == null) {
|
|
temp = 0.00;
|
|
}
|
|
totalsandweight = totalsandweight + temp;
|
|
|
|
var id2 = i + 'pt';
|
|
var temp2 = parseFloat(document.getElementById(id2).textContent);
|
|
totalproduct = totalproduct + temp2;
|
|
}
|
|
|
|
|
|
if (isNaN(totalsandweight) || totalsandweight == '' || totalsandweight == null) {
|
|
totalsandweight = 0.00;
|
|
}
|
|
|
|
if (isNaN(totalproduct) || totalproduct == '' || totalproduct == null) {
|
|
totalproduct = 0.00;
|
|
}
|
|
|
|
document.getElementById('12sw').textContent = parseFloat(totalsandweight).toFixed(2);
|
|
document.getElementById('12p').textContent = parseFloat(totalsandweight).toFixed(2);
|
|
document.getElementById('12pt').textContent = parseFloat(totalproduct).toFixed(3);
|
|
if (document.getElementById('AFS') != null) {
|
|
document.getElementById('AFS').textContent = isNaN(totalproduct) ? '0.00' : parseFloat((totalproduct / totalsandweight)).toFixed(2);
|
|
}
|
|
var dataset = [];
|
|
var datalabel = [];
|
|
for (x = 1; x <= 11; x++) {
|
|
var swid = x + 'p';
|
|
var sanddata = document.getElementById(swid).textContent;
|
|
dataset.push(sanddata);
|
|
|
|
var sizeid = x + 'size';
|
|
var sizedata = document.getElementById(sizeid).textContent;
|
|
datalabel.push(sizedata);
|
|
}
|
|
// console.log(dataset);
|
|
//console.log(datalabel);
|
|
drawChart(dataset, datalabel);
|
|
}
|
|
|
|
|
|
$('td').focusin(function(e) {
|
|
|
|
var id = e.target.id;
|
|
var value = document.getElementById(id).textContent;
|
|
if (value == 0) {
|
|
document.getElementById(id).textContent = '';
|
|
}
|
|
});
|
|
|
|
$('td').focusout(function(e) {
|
|
|
|
var id = e.target.id;
|
|
|
|
var value = document.getElementById(id).textContent;
|
|
if (value == '') {
|
|
document.getElementById(id).textContent = parseFloat(0.00).toFixed(2);
|
|
}
|
|
});
|
|
|
|
// $(".edit").focusin(function(){
|
|
|
|
// alert('skjhjkdf');
|
|
// });
|
|
|
|
function drawChart(dataset, datalabel) {
|
|
|
|
|
|
var dashlinestart = [11, 287, 252, 217, 182, 147, 112, 77, 42];
|
|
var c = document.getElementById("myCanvas");
|
|
var ctx = c.getContext("2d");
|
|
ctx.clearRect(0, 0, c.width, c.height);
|
|
var xlabels = datalabel;
|
|
var xlabelscount = xlabels.length;
|
|
console.log(xlabelscount);
|
|
var dataset = dataset;
|
|
|
|
Array.prototype.max = function() {
|
|
return Math.max.apply(null, this);
|
|
};
|
|
var maxdataitem = dataset.max();
|
|
maxdataitem = Math.round((maxdataitem + 10) / 5);
|
|
|
|
|
|
var dataset_locationsX = [];
|
|
var dataset_locationsY = [];
|
|
|
|
var canvaswidth = document.getElementById('myCanvas').offsetWidth;
|
|
var canvasheight = document.getElementById('myCanvas').offsetHeight;
|
|
|
|
ctx.beginPath();
|
|
ctx.lineWidth = 1;
|
|
ctx.moveTo(30, 0);
|
|
ctx.lineTo(30, canvasheight);
|
|
ctx.strokeStyle = "black";
|
|
ctx.stroke();
|
|
ctx.closePath();
|
|
|
|
ctx.beginPath();
|
|
ctx.lineWidth = 1;
|
|
ctx.moveTo(0, (canvasheight - 30));
|
|
ctx.lineTo(canvaswidth, (canvasheight - 30));
|
|
ctx.strokeStyle = "black";
|
|
ctx.stroke();
|
|
ctx.closePath();
|
|
|
|
ctx.beginPath();
|
|
ctx.font = "bold 12px Arial";
|
|
ctx.fillStyle = "black";
|
|
ctx.fillText("Sieve size µm ", (canvaswidth / 2), (canvasheight - 2));
|
|
ctx.closePath();
|
|
|
|
var xaxislabelwidth = (canvaswidth / 12);
|
|
|
|
var startingpointX = 30;
|
|
var startingpointY = (canvasheight - 30);
|
|
|
|
for (i = 1; i <= dashlinestart.length; i++) // Drawing Dashed Lines from Y
|
|
{
|
|
|
|
ctx.beginPath();
|
|
ctx.lineWidth = 0.8;
|
|
ctx.moveTo(startingpointX, dashlinestart[i - 1]);
|
|
//console.log(dataset_locationsY[i]);
|
|
ctx.lineTo(canvaswidth, dashlinestart[i - 1]);
|
|
ctx.setLineDash([3, 6]);
|
|
ctx.strokeStyle = "black";
|
|
|
|
ctx.stroke();
|
|
ctx.closePath();
|
|
|
|
}
|
|
ctx.setLineDash([]);
|
|
for (i = 1; i <= xlabelscount; i++) //X DataLabel
|
|
{
|
|
ctx.beginPath();
|
|
ctx.font = "bold 10px Arial";
|
|
ctx.fillStyle = "black";
|
|
ctx.fillText(xlabels[i - 1], (startingpointX + (xaxislabelwidth * i)), (startingpointY + 15));
|
|
ctx.closePath();
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i <= xlabelscount; i++) // X Data
|
|
{
|
|
ctx.beginPath();
|
|
ctx.arc((startingpointX + (xaxislabelwidth * i)), startingpointY, 4, 0, 2 * Math.PI);
|
|
ctx.fillStyle = "black";
|
|
ctx.fill();
|
|
ctx.closePath();
|
|
var xl = (startingpointX + (xaxislabelwidth * i));
|
|
|
|
dataset_locationsX.push(xl);
|
|
|
|
}
|
|
|
|
|
|
var j = 0;
|
|
var ylabel = 0;
|
|
for (i = 1; i <= maxdataitem; i++) // y Data and Y labels
|
|
{
|
|
|
|
ctx.beginPath();
|
|
ctx.arc(startingpointX, (startingpointY - j), 4, 0, 2 * Math.PI);
|
|
ctx.fillStyle = "black";
|
|
ctx.fill();
|
|
var yl = ((startingpointY - j));
|
|
dataset_locationsY.push(yl);
|
|
ctx.fillStyle = "black";
|
|
ctx.font = "bold 10px Arial";
|
|
ctx.fillText((j / 7), (startingpointX - 30), (startingpointY - j));
|
|
ylabel = ylabel + 5;
|
|
j = j + 35;
|
|
ctx.closePath();
|
|
|
|
}
|
|
|
|
var finallocationofY = [];
|
|
var finallocationofX = [];
|
|
for (i = 1; i <= xlabelscount; i++) //Exact chart Data Draw red points
|
|
{
|
|
ctx.beginPath(); <
|
|
!--ctx.arc((parseFloat(dataset_locationsX[i - 1])), ((startingpointY - parseFloat(dataset[i - 1]) * 7)), 4, 0, 2 * Math.PI);
|
|
-- >
|
|
ctx.fillStyle = "red";
|
|
ctx.lineCap = 'round'; <
|
|
!--ctx.fill();
|
|
-- >
|
|
ctx.fillRect((parseFloat(dataset_locationsX[i - 1]) - 5), ((startingpointY - parseFloat(dataset[i - 1]) * 7) - 5), 10, 10)
|
|
finallocationofY.push((startingpointY - parseFloat(dataset[i - 1]) * 7));
|
|
finallocationofX.push(parseFloat(dataset_locationsX[i - 1]));
|
|
ctx.closePath();
|
|
//Draw text for data points
|
|
ctx.beginPath();
|
|
ctx.font = "bold 12px Arial";
|
|
ctx.fillStyle = "blue";
|
|
ctx.fillText(dataset[i - 1], (parseFloat(dataset_locationsX[i - 1])), ((startingpointY - parseFloat(dataset[i - 1]) * 7) - 10));
|
|
ctx.closePath();
|
|
}
|
|
|
|
|
|
for (i = 0; i <= xlabelscount; i++) //Exact Chart Data Draw line
|
|
{
|
|
|
|
ctx.beginPath();
|
|
ctx.lineWidth = 4;
|
|
ctx.setLineDash([15, 5]);
|
|
ctx.moveTo(finallocationofX[i], finallocationofY[i]);
|
|
ctx.lineTo(finallocationofX[i + 1], finallocationofY[i + 1]);
|
|
|
|
//ctx.strokeStyle="#1a75ff";
|
|
//ctx.lineWidth=3;
|
|
//setInterval(function(){
|
|
ctx.stroke();
|
|
//},30000);
|
|
ctx.closePath();
|
|
|
|
|
|
|
|
}
|
|
|
|
ctx.setLineDash([]);
|
|
//ctx.beginPath();
|
|
|
|
//sctx.closePath();
|
|
|
|
|
|
}
|
|
</script>
|