ria/app/Views/viewIGRDetails.php

947 lines
30 KiB
PHP

<style>
.modal
{
padding-right:25% ! important;
}
.num{
text-align:right;
}
.modal-content
{
width:800px ! important;
}
.modal-footer .btn {
margin-right: 10px; /* Add some spacing between buttons */
}
</style>
<div class="content-wrapper">
<section class="content"><br/>
<div class="box">
<div class="box-header">
<center><b><h3 class="box-title">View Inward Gate Register</h3></b></center>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 text-right">
<div class="form-group">
<a class="btn btn-success" onclick="Test()" href="<?php echo base_url(); ?>Addigr">Add New </a>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<table id="Inwardgateregistertable" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;">
<thead style="background-color: #ddd;">
<tr>
<!-- <th>S.No</th> -->
<th>IGR No</th>
<th>PO No</th>
<th>Supplier Name</th>
<th>Invoice No</th>
<th>Date of Invoice</th>
<th>Vechicle No</th>
<th style="display:none">Created Date</th>
<th>Courier No</th>
<th>File</th>
</tr>
</thead>
<tbody>
<?php
if(!empty($IGR))
{ $index = 0;
// print_r($IGR);
// die;
foreach($IGR as $record)
{
$index = $index +1;
?>
<tr id="<?php echo $index ?>" >
<!-- <td style="text-align: center;"><?php echo $index?></td> -->
<td><a data-toggle="modal" data-target="#Igrshow" data-id="<%=index%>" data-userid="<?php echo $record->IGRNO ?>" data-igrstatus="<?php echo $record->IGRStatus ?>" > <u><?php echo $record->IGRNO ?></u></a></td>
<td><?php echo $record->PONO ?></a></td>
<td><?php echo $record->SupplierName ?></td>
<td><?php echo $record->DeliveryChellanOrInvoiceNo ?></td>
<td align="right"><?php
$date = new DateTime($record->DeliveryChellanDate);
echo $date->format('d-m-Y'); ?></td>
<td><?php echo $record->VehicleNo ?></td>
<td style="display:none"><?php echo $record->CreatedDate ?></td>
<td><?php echo $record->CourierNo ?></td>
<td><?php if(!empty($record->FilePath)){ ?>
<!-- <a target="_blank" href="<?php echo base_url().$record->file ?>"><i class="fa fa-download" ></i></a> -->
<a target="_blank" data-toggle="modal" data-target="#Fileshow" data-id="<%=index%>" title="Attachment Available for Download/View" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>"><button class="btn btn-success btn-sm ">Download</button></a>
<?php } else if(!empty($record->file)){ ?>
<a target="_blank" data-toggle="modal" data-target="#Fileshow" data-id="<%=index%>" title="Attachment Available for Download/View" data-igrno="<?php echo $record->IGRNO ?>" ><button class="btn btn-success btn-sm ">Download</button></a>
<?php } else { ?>
<!-- echo "NO FILE"; -->
<a target="_blank" data-toggle="modal" data-target="#Fileshow" data-id="<%=index%>" title="Attachment Available for Download/View" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>"><button class="btn btn-success btn-sm ">Upload</button></a>
<?php } ?>
<?php if($record->IGRStatus !== "ST074") { ?>
<div style="padding-top:10px"> <a href="<?php echo base_url().'MRIRcontroller/igrdatavalues?IGRNO='.$record->IGRNO; ?>"><button style="font-size:12px;" id="generated" name="generated">Generate MRIR <i class="fa fa-file-text"></i></button></div></a>
<?php } ?>
</td>
<!--<td><?php echo $record->file ?></td>-->
</tr>
<?php
//$SNo++;
}
}
?>
</tbody>
</table>
</div>
</div><!-- .row -->
</div><!-- .containe-fluid -->
</div><!-- .box -->
<!-- ######################################edit file########################### -->
<div class="modal fade" id="Fileshow" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<form id="igrfileform">
<div class="modal-content" style="width:800px;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<center><h4>Inward Gate File Details <span id="title"></span></h4></center> <!-- IGR number should display here-->
</div>
<!-- Table to show the line item of po -->
<div id="contents" > </div>
<table class="table table-bordered" id="Inwardgateregisterfile" style="background-color:#fff;font-size:12px;">
<thead style="background-color: #ddd;">
<tr>
<th>SNo</th>
<th>BillNO</th>
<th>PONO</th>
<th>FileName</th>
<th>Action</th>
</tr>
</thead>
<tbody id="tblefile"></tbody>
</table>
<input type="hidden" name="hidecounter" id="hidecounter" value="0" />
<!-- <input type="hidden" name="hideconstant" id="hideconstant" value="0" /> -->
<input type ="hidden" name ="hiddenIGRNO" id="hiddenIGRNO"/>
<input type ="hidden" name ="hiddenPONO" id="hiddenPONO" />
<div style="text-align: right; margin:5px;">
<div id="newdiv"></div>
<input type="button" class="btn btn-success" id ="addmorebutton" value=" ADD FILES..">
<!-- <a class="btn btn-success" data-dismiss="modal" id='editfileadd' value="">ADD</a> -->
<a class="btn btn-success" data-dismiss="modal" value="Cancel">Cancel</a>
</div>
<br/>
</div>
</form>
</div>
</div>
<div id="billModel" class="modal fade" data-backdrop-limit="1" role="dialog" aria-labelledby="myModalLabel" >
<div class="modal-dialog">
<div class="modal-content" style="width:950px;">
<div class="modal-header">
<h4 class="modal-title">Update Bill Details</h4>
</div>
<form class="tagForm" id="tag-form" method="post" enctype="multipart/form-data" >
<div class="modal-body" style="padding:0px;">
<div class="col-md-12">
<div class="col-md-5">
<!-- onChange="filecheck();" -->
<input type = "file" size = "20" input accept=".docx,.pdf,.doc.JPG,.PNG,.jpg" id="billimag" name="images" />
<label for="images">Select file <br/><small>(only .pdf,.excel,.doc,.png,.jpg)</small></label>
</div>
</div>
<input type="hidden" name="hideoldfile" id="hideoldfile" class="form-control" readonly>
<input type="hidden" name="hidebillno" id="hidebillno" class="form-control"
readonly>
</div><!-- /.modal body -->
<div class="modal-footer">
<div class="col-md-12 text-right">
<div class="col-md-4 col-md-offset-8">
<a class="btn btn-success" onclick="fileupdate()" >&nbsp;&nbsp;<span class="bold">Update</span>
<a class="btn btn-success" data-dismiss="modal" value="Cancel">Cancel</a>
</div>
</div>
</div><!-- /.modal footer -->
</form>
</div><!-- /.modal content -->
</div><!-- /.modal dialog -->
</div><!-- /# bill modal -->
<!-- ################################################################# -->
<div class="modal fade" id="Igrshow" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<form>
<div class="modal-content" style="width:800px;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<center><h4>Inward Gate Register Details</h4></center> <!-- IGR number should display here-->
</div>
<input type="hidden" id="counts">
<!--<div class="col-md-12">
<div class="col-md-3">
<label>IGR Number :</label>
</div>
<div class="col-md-3">
<input type="text" id="IGRNO1" readonly>
</div>
<div class="col-md-3">
<label> Purchase Order Number:</label>
</div>
<div class="col-md-3">
<input type="text" id="PONo" readonly>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<label>Delivery Challan/Invoice NO :</label>
</div>
<div class="col-md-3">
<input type="text" id="Invoice_No" readonly>
</div>
<div class="col-md-3">
<label>Delivery Challan / Invoice Date:</label>
</div>
<div class="col-md-3">
<input type="text" id="Invoice_Date" readonly>
</div>
</div>
<br/>
<div class="col-md-12">
<div class="col-md-3">
<label>Supplier Name :</label>
</div>
<div class="col-md-3">
<input type="text" id="Supplier" readonly>
</div>
</div>-->
<div class="col-md-12">
<div class="col-md-4">
<label>IGR Number </label>
<?php
$data = array('name' => 'IGRNumber','value' => set_value('IGRNumber'),'id'=>'IGRNO1', 'class' => 'form-control', 'required=>"true"' , 'readonly'=>'true' );
echo form_input($data);
?>
</div>
<div class="col-md-4">
<div style="display: flex; justify-content: space-between; align-items: center;">
<label>Purchase Order No</label>
<a id="printLink" data-toggle="tooltip" href="" target="new" style="text-align: right;">
<i class="fa fa-print" data-toggle="tooltip" title="Click here to Print the Purchase Order details"></i>
</a>
</div> <?php
$data = array('name' => 'PurchaseOrderNumber','value' => set_value('PurchaseOrderNumber'),'id'=>'PONo', 'class' => 'form-control', 'required=>"true"' , 'readonly'=>'true' );
echo form_input($data);
?>
</div>
<div class="col-md-4">
<label>Supplier Name </label>
<?php
$data = array('name' => 'SupplierName','value' => set_value('SupplierName'),'id'=>'Supplier', 'class' => 'form-control', 'required=>"true"' , 'readonly'=>'true' );
echo form_input($data);
?>
</div>
</div>
<div class="col-md-12" style=" padding-bottom: 10px;">
<div class="col-md-4">
<label>Invoice Number </label>
<?php
$data = array('name' => 'InvoiceNO','value' => set_value('InvoiceNO'),'id'=>'Invoice_No', 'class' => 'form-control', 'required=>"true"' , 'readonly'=>'true' );
echo form_input($data);
?>
</div>
<div class="col-md-4">
<label>Invoice Date </label>
<?php
$data = array('name' => 'InvoiceDate','value' => set_value('InvoiceDate'),'id'=>'Invoice_Date', 'class' => 'form-control', 'required=>"true"' , 'readonly'=>'true' );
echo form_input($data);
?>
</div>
<div class="col-md-4">
<label>Material Received Date </label>
<?php
$data = array('name' => 'MaterialRcvdDate','value' => set_value('MaterialRcvdDate'),'id'=>'MaterialRcvdDate', 'class' => 'form-control' , 'readonly'=>'true' );
echo form_input($data);
?>
</div>
</div>
<div class="col-md-12" style=" padding-bottom: 10px;">
<div class="col-md-4">
<label>Vehicle Number</label>
<?php
$data = array('name' => 'VehicleNo','value' => set_value('VehicleNo'),'id'=>'Vehicle_No', 'class' => 'form-control', 'required=>"true"' , 'readonly'=>'true' );
echo form_input($data);
?>
</div>
<div class="col-md-4">
<label>Driver Name </label>
<?php
$data = array('name' => 'DriverName','value' => set_value('DriverName'),'id'=>'Driver_Name', 'class' => 'form-control', 'required=>"true"' , 'readonly'=>'true' );
echo form_input($data);
?>
</div>
<div class="col-md-4">
<label>Driver Mobile Number </label>
<?php
$data = array('name' => 'DriverMobileNumber','value' => set_value('DriverMobileNumber'),'id'=>'DriverMobileNumber', 'class' => 'form-control' , 'readonly'=>'true' );
echo form_input($data);
?>
</div>
</div>
<!-- Table to show the line item of po -->
<div id="content" > </div>
<table class="table table-bordered" id="Inwardgateregistertable1" style="background-color:#fff;font-size:12px;">
<thead style="background-color: #ddd;">
<tr>
<th>SNo</th>
<th>Item Code</th>
<th>Item Description</th>
<th>UOM</th>
<th>Ordred Quantity</th>
<th>Received Quantity</th>
<th id="pendingQuantityHeader" style="display:none;">Pending Quantity</th>
<th>Remarks</th>
</tr>
</thead>
<tbody id="tbleAppend1">
</tbody>
</table>
<div class="modal-footer" id="buttonContainer">
<!-- <a class="btn btn-success" data-dismiss="modal" value="Cancel">Cancel</a> -->
<!-- <a class="btn btn-success" id="update" value="Update">Update IGR</a> -->
<a class="btn btn-success" id="draftIGR" onclick="setStatusAndSubmit('draft')">Draft IGR</a>
<a class="btn btn-success" id="generateIGR" onclick="setStatusAndSubmit('generate')">Generate IGR</a>
<a class="btn btn-success" data-dismiss="modal" value="Cancel">Cancel IGR</a>
</div>
</div><!-- .modal-content -->
</form>
</div><!-- .modal-dialog -->
</div> <!--#igrshow modal -->
</section>
</div><!-- .content-wrapper -->
<script>
function filecheck()
{
var sizef = document.getElementById('billimag').files[0].size;
var file = $('#billimag').val();
if(file!='' && sizef < 2100000)
{ // alert('Your file added successfully');
}
else
{
alert('Sorry Your File is Large To 2MB');
$('#billimag').val('');
}
}
function fileupdate(){
var formData = new FormData();
//var file = document.getElementById('billimag').files[0];
var file = $("#billimag").prop('files')[0];
var param1 = $('#hidebillno').val();
// alert(param1);
var param2 = $('#hideoldfile').val();
// alert(param2);
// var filename = $("#billimag").val();
// filename = filename.split('\\');
formData.append('file',file);
formData.append('param1',param1);
formData.append('param2',param2);
$('.content').loader('show');
$.ajax({
data:formData,
type:"POST",
url:"<?php echo base_url() ?>inwardgateregister/edituploadfile",
cache : false,
contentType : false,
processData : false,
success:function(data) {
if(data){
alert(data);
window.location.reload();
$('.content').loader('hide');
// $('#spl').find('td').eq(5).text(filename[2]);
$('#billModel').modal('hide');
}
}
});
}
//$(function () {
$(document).ready(function() {
$("#Fileshow").on("shown.bs.modal",function(e) {
var id = $(this).attr('id');
var igr = $(e.relatedTarget).data('igrno');
var po = $(e.relatedTarget).data('pono');
$('#igrfileform')[0].reset();
$('#title').text(" ("+igr+") ");
$("#hiddenIGRNO").val(igr);
$("#hiddenPONO").val(po);
if(igr != "" && po != ""){
$.ajax({
data:{id:igr,id1:po},
type:"POST",
//dataType: 'json',
url:"<?php echo base_url() ?>inwardgateregister/ViewIGRfile",
success: function(file)
{
$("#counts").val(JSON.parse(file).length);
var trHTML = '';
var FilePath ='';
var Filename = '';
var PONO ='';
var BillNO ='';
$.each(JSON.parse(file), function (i, item)
{
if(item.file == null)
{ if(item.Remarks ==null)
{
console.log("<?php echo base_url()?>public/uploads/Igrfiles/"+item.FilePath);
//alert()
PONO =item.PONO;
BillNO =item.BillNo;
Filename =item.FilePath;
FilePath = "<?php echo base_url()?>public/uploads/Igrfiles/"+item.FilePath;
}else{
Filename ="BillDetails";
PONO =item.PONO;
BillNO =item.BillNo;
FilePath = item.FilePath;
}
}else{
Filename = item.file;
PONO =item.pono;
BillNO = '-';
FilePath =item.file;
}
if(Filename != null)
{
i=i+1;
trHTML += '<tr id='+i+'>' +
'<td align="right">' + i + '</td>' +
'<td id="billno'+i+'">' + BillNO+ '</td>' +
'<td>' + PONO+ '</td>' +
'<td id="file'+i+'"><a target="_blank" href = '+FilePath+'>'+ Filename +'</a></td>' +
'<td name="filepathname" id="filepathname" onclick="openbillmodel('+i+');"><i class="fa fa-pencil"></i></td>' +
'</tr>';
}
});
$("#tblefile").empty();
if(trHTML == ''){
trHTML = '<tr><td colspan="5" style="text-align: center;">NO FILE</td></tr>';
}
$("#tblefile").append(trHTML);
}
});
}
});
});
function openbillmodel(i){
// alert(i);
// return false;
var igr = $("#tblefile").find('tr').find('td').eq(2).text();
// alert(igr);
var Billno = $("#billno"+i).text();
// alert(Billno);
var file = $("#file"+i).text();
//alert(file);
$("#billModel").modal("show");
$("#bill").text(Billno);
$("#hideoldfile").val(file);
$("#hidebillno").val(Billno);
}
</script>
<script src="https://cdn.datatables.net/plug-ins/1.10.16/sorting/datetime-moment.js"></script>
<script>
<!-- script for table , It works under the datatable plugin-->
$(function () {
$.fn.dataTable.moment( 'DD-MM-YYYY' );
$('#Inwardgateregistertable').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"aaSorting": [[ 6, "desc" ]],
"info": true,
"autoWidth": true
});
});
</script>
<script>
$("#Igrshow").on("shown.bs.modal", function(e) {
var igr = $(e.relatedTarget).data('userid');
var igrstatus = $(e.relatedTarget).data('igrstatus');
var buttonContainer = $("#buttonContainer");
if (igrstatus == "ST074") {
// Show buttons in the container
buttonContainer.find("#draftIGR, #generateIGR").css("display", "inline-block");
} else {
// Hide buttons in the container
buttonContainer.find("#draftIGR, #generateIGR").css("display", "none");
}
$("#tbleAppend1").empty();
$('#content').loader('show');
$.ajax({
data:{id:igr},
type:"POST",
//dataType: 'json',
url:"<?php echo base_url() ?>inwardgateregister/ViewIGR",
success:function(data) {
console.log(data);
console.log('d');
// success:function(data) {
$('#content').loader('hide');
var trHTML = '';
$.each(JSON.parse(data), function (i, item) {
if(igr == item.IGRNO)
{
$("#IGRNO1").val(item.IGRNO);
$("#IGRItemNo").val(item.IGRItemNo);
var baseUrl = '<?php echo base_url(); ?>purchaseorder/CreatePOPrint';
var newUrl = baseUrl + '?PONO=' + item.PONO + '&ReqType=' + item.POType;
$('#printLink').attr('href', newUrl);
$("#Vehicle_No").val(item.VehicleNo);
$("#Driver_Name").val(item.DriverName);
$("#DriverMobileNumber").val(item.DriverMobileNumber);
$("#IGRStatus").val(item.IGRStatus);
$("#PONo").val(item.PONO);
$("#Supplier").val(item.SupplierName);
$("#Add1").val(item.Address);
$("#Invoice_No").val(item.DeliveryChellanOrInvoiceNo);
//alert(item.DeliveryChellanDate);
var dcd = new Date(item.DeliveryChellanDate);
//alert(dcd.getDate()+ '.' + (dcd.getMonth() + 1)+ '.' + dcd.getFullYear());
var dcd2 = (dcd.getDate()+ '/' + (dcd.getMonth() + 1)+ '/' + dcd.getFullYear());
$("#Invoice_Date").val(dcd2);
if(item.MaterialRcvdDate === null) {
var Mat_rcv_date = ' '; }
else {
var MR_dt = new Date(item.MaterialRcvdDate);
var Mat_rcv_date = (MR_dt.getDate()+ '/' + (MR_dt.getMonth() + 1)+ '/' + MR_dt.getFullYear());
}
$("#MaterialRcvdDate").val(Mat_rcv_date);
$("#ser").val(item.ServiceDescription);
i=i+1;
if(igrstatus == "ST074"){
// document.getElementById('pendingQuantityHeader').style.display = 'table-cell';
$("#pendingQuantityHeader").css("display", "table-cell");
trHTML += '<tr>' +
'<td align="right">' + i + '</td>' +
'<td name="MaterialName" onchange="test('+i+')">' + item.MaterialCode + '</td>' +
'<td>' + item.MaterialName + '</td>' +
'<td name="UOM">' + item.UOM + '</td>' +
'<td align="right" id="Quantity'+i+'" name="Quantity">' + parseInt(item.Quantity) + '</td>' +
'<td align="right" data-name="sel" ><input type="text" onchange="validateReceivedQuantity('+i+')"id="QuantityAsPerInvoice'+ i +'" name="QuantityAsPerInvoice'+ i +'" value="'+parseInt(item.QuantityAsPerInvoice)+'" onkeypress="return isNumberKey(event);"></td>' +
'<td name="PendingQuantity'+i+'" id="PendingQuantity'+i+'">'+ parseInt(item.Quantity -item.QuantityAsPerInvoice) +'</td>'+
'<td><input type="text" id="Remark'+ i +'" name="Remark'+ i +'" class="form" onchange="SetRemarks('+i+')"> </td>' +
'<input type="hidden" id="IGRNO'+ i +'" name="IGRNO'+ i +'" value="'+ item.IGRNO +'">' +
'<input type="hidden" id="IGRItemNo'+ i +'" name="IGRItemNo'+ i +'" value="'+ item.IGRItemNo +'">' +
'<input type="hidden" id="MaterialCode'+ i +'" name="MaterialCode'+ i +'" value="'+ item.MaterialCode +'">' +
'<input type="hidden" id="txtQuantityAsPerInvoice'+ i +'" name="txtQuantityAsPerInvoice'+ i +'" value="'+ item.QuantityAsPerInvoice +'">' +
'<input type="hidden" id="txtOrderedQuantity'+ i +'" name="txtOrderedQuantity'+ i +'" value="'+ item.Quantity +'">' +
'<input type="hidden" id="txtRemarks'+ i +'" name="txtRemarks'+ i +'">'; // Example with no initial value
'</tr>';
//alert(item.PendingQty);
if((item.Quantity-item.QuantityAsPerInvoice) == 0.00)
{
$('#QuantityAsPerInvoice'+i).attr('readonly', 'true');
}
}else{
$("#pendingQuantityHeader").css("display", "none");
trHTML += '<tr>' +
'<td align="right">' + i + '</td>' +
'<td name="MaterialName" id="MaterialCode" onchange="test('+i+')">' + item.MaterialCode + '</td>' +
'<td>' + item.MaterialName + '</td>' +
'<td name="UOM">' + item.UOM + '</td>' +
'<td align="right" name="Quantity">' + item.Quantity + '</td>' +
'<td align="right" data-name="sel" >'+item.QuantityAsPerInvoice+'</td>' +
'<td>'+ item.Remarks+ '</td>' +
'</tr>';
}
//alert(item.QuantityAsPerInvoice);
}
});
$("#tbleAppend1").empty();
$('#Inwardgateregistertable1 > tbody').append(trHTML);
}
});
});
</script>
<script>
var counter = 0;
//var counterConstant = 0;
$("#addmorebutton").click(function(){
var file_count = $("#counts").val();
counter++;
var bil_count = +counter+ +file_count;
// alert(bil_count);
// alert(file_count);
if(bil_count>=6){
alert("You have to upload five files only");//this allows only 5 files;
$('#addmorebutton').hide();
return false;
}
var div = document.createElement('div');
div.id = "divid";
div.className="row";
//alert(counter);
div.innerHTML='<div class="col-md-12">'+
// '<div class="col-md-3">'+
// '<label>File Name</label>'+
// '<input type="text" id="maint_filename'+counterConstant+'" name="filename'+counterConstant+'" class="form-control" onkeypress="return false;" readonly/>'+
// '</div>'+
'<div class="col-md-3">'+
'<label><br></label>'+
'<input type="file" name="browseFiles" id="images'+counter+'" ><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 class="col-md-2">'+
'<label><br><br></label>'+
'<button class="btn btn-success" type ="button" id="addbtn" onclick="addRow()">ADD</button></div>'+
'</div>'+
'</div>';
$('#newdiv').append(div);
$('#hidecounter').val(counter);
if(counter>1){
alert("Add button click here");//this allows only 5 files;
return false;
}
else{
$('#addmorebutton').hide();
}
//}
});
function addRow()
{
//var file = $('#imag').val();
var file = $('#images'+counter).val();
if (file == '')
{
alert('File not found');
}
else {
fileupload(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);
// $("#maint_filename"+number).val(name);
// }
// }
function fileupload(counter)
{
//alert(counter);
var formData = new FormData();
// var file = $("#images"+counter).prop('file')[0];
var file = document.getElementById('images'+counter).files[0];
// alert(file);
var PONO =$('#hiddenPONO').val();
// alert(PONO);
var igr =$('#hiddenIGRNO').val();
//alert(igr);
formData.append('file',file);
formData.append('PONO',PONO);
formData.append('count',counter);
formData.append('igr',igr);
$('.content').loader('show');
$.ajax({
data:formData,
type:"POST",
url:"<?php echo base_url() ?>inwardgateregister/addloadfile",
cache : false,
contentType : false,
processData : false,
success:function(data) {
if(data){
alert(data);
window.location.reload();
$('.content').loader('hide');
// $('#spl').find('td').eq(5).text(filename[2]);
$('#billModel').modal('hide');
}
}
});
}
</script>
<script>
function SetRemarks(RowId)
{
var remks = $("#Remark"+RowId).val();
if( remks != '')
{
$("#txtRemarks"+RowId).val(remks);
}
}
function validateReceivedQuantity(Rowid) {
var InvoiceQty = parseFloat($('#QuantityAsPerInvoice' + Rowid).val() || '0.00'); // working fine
var OrderedQty = parseFloat($("#Quantity" + Rowid).text());
if (parseInt(OrderedQty) !== 0) {
if ((InvoiceQty) > OrderedQty) {
alert("Advised Quantity is exceeding the Ordered Quantity. Please contact the Purchase Team for further process.");
$("#QuantityAsPerInvoice" + Rowid).focus().val('');
return false;
} else if ((InvoiceQty) - OrderedQty > 0.00) {
alert("Order is completed.");
$("#QuantityAsPerInvoice" + Rowid).focus().val('');
return false;
} else {
var PendingQty = OrderedQty - (InvoiceQty);
$('#PendingQuantity' + Rowid).text(PendingQty.toFixed(0));
$('#txtPendingQty' + Rowid).val(PendingQty.toFixed(0));
$('#txtQuantityAsPerInvoice' + Rowid).val(InvoiceQty.toFixed(2));
return true;
}
} else {
var PendingQty = OrderedQty - (InvoiceQty);
$('#PendingQuantity' + Rowid).text(PendingQty.toFixed(0));
$('#txtPendingQty' + Rowid).val(PendingQty.toFixed(0));
$('#txtQuantityAsPerInvoice' + Rowid).val(InvoiceQty.toFixed(2));
return true;
}
}
</script>
<script>
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31
&& (charCode < 48 || charCode > 57))
return false;
return true;
}
</script>
<script>
function setStatusAndSubmit(status) {
var statuscode = (status == "draft") ? 'ST074' : 'ST027';
// alert('updated function entered');
$('#content').loader('show');
var igrno = $("#IGRNO1").val();
var dataToSend = [];
$('#tbleAppend1 tr').each(function(index, row) {
var rowData = {};
$(row).find('input[type="hidden"]').each(function() {
var fieldName = $(this).attr('name');
var fieldValue = $(this).val();
rowData[fieldName] = fieldValue;
});
dataToSend.push(rowData);
});
$.ajax({
url: "<?php echo base_url() ?>inwardgateregister/updateIGRLineItem",
type: "POST",
dataType: 'json',
data: {
igr: igrno,
status: statuscode,
data: JSON.stringify(dataToSend)
},
success: function(response) {
$('#content').loader('hide');
console.log('Data saved successfully:', response);
alert(response.message);
// Close the modal
$('#Igrshow').modal('hide');
// location.reload();
setTimeout(function() {
location.reload();
}, 500);
},
error: function(jqXHR, textStatus, errorThrown) {
$('#content').loader('hide');
console.error('Error saving data:', textStatus, errorThrown);
alert(response.message);
$('#Igrshow').modal('hide');
}
});
}
</script>