siddharth_application/application/views/inwardgateregister.php
2018-02-15 10:08:49 +05:30

635 lines
16 KiB
PHP
Executable File

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/3.3.4/jquery.inputmask.bundle.min.js"></script>
<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>
$(document).ready(function(){
$("#PONO").select2();
$("#InvoiceDate").datepicker({
maxDate : 'now',
dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,yearRange: '-100:+0'
});
});
//jquery for vechicle masking
$(document).ready(function(){
Inputmask("A{2,3} 9{1,2} A{1,2} 9{4}").mask($("#VehicleNo"));
});
</script>
<style>
.modal {
text-align: center;
padding: 0!important;
}
.modal:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -4px;
}
.modal-dialog {
display: inline-block;
text-align: left;
vertical-align: middle;
}
.select2 {
width: 100% ! important;
}
.num {
text-align:right;
}
.dataTables_wrapper {
padding-bottom: 0px;
}
</style>
<div class="content-wrapper" style="min-height:537px;">
<section class="content-header">
<h1>
<center>Siddharth Industries - Inward Gate Register (IGR) Entry</center>
</h1>
</section>
<section class="content" style="margin: 15px;"><br/>
<div style="border:2px solid #333;">
<div class="row"><br/><br/>
<div id="content" > </div>
<div class="col-md-12">
<div class="col-md-2">
<?php
$attributes = array('class' => 'form-label-left IGR ','name' => 'IGR','id' => 'IGR');
echo form_open($this->config->base_url().'/inwardgateregister/addNewigr/',$attributes); ?>
<label>Select Purchase Order No </label>
<?php
$options = array("-1"=>'Purchase Order No');
if(!empty($PO_NO))
{
//print_r($PO_NO);
foreach ($PO_NO as $SI):
$options[$SI->PONO] = $SI->PONO .'-'. $SI->SupplierName ;
$PONO = $SI->PONO;
endforeach;
}
echo form_dropdown('PONO', $options,set_value('PONO'),'id="PONO"' ,'class="form-control select2"' , 'required="true"');
?>
</div>
<div class="col-md-2">
<label>Supplier Name </label>
<div class="form-group">
<?php
$data = array('name' => 'SupplierName','value' => set_value('SupplierName'),'id'=>'Sup', 'class' => 'form-control' ,'readonly' => 'true');
echo form_input($data);
?>
</div>
</div>
<div class="col-md-2">
<label>Delivery Challan/Inv No</label>
<?php
$data = array('name' => 'InvoiceNo','value' => set_value('InvoiceNo'),'id'=>'InvoiceNo', 'class' => 'form-control', 'required=>"true"','onkeypress'=>'return isNumberKey(event);' );
echo form_input($data);
?>
</div>
<div class="col-md-2">
<label>Delivery Challan/Inv Date</label>
<?php
$data = array('name' => 'InvoiceDate','value' => set_value('InvoiceDate'),'id'=>'InvoiceDate', 'class' => 'form-control num', 'required'=>'true' );
echo form_input($data);
?>
</div>
<div class="col-md-2">
<label>Vechicle No</label>
<?php
$data = array('name' => 'VehicleNo','value' => set_value('VehicleNo'), 'id'=>'VehicleNo', 'class' => 'form-control', );
echo form_input($data);
?>
<span pattern="" required="true"></span>
</div>
<div class="col-md-2">
<label>Courier No</label>
<?php
$data = array('name' => 'CourierNo','value' => set_value('CourierNo'),'id'=>'CourierNo', 'class' => 'form-control','onkeypress'=>'return isNumberKey(event);' );
echo form_input($data);
?>
</div>
</div>
<div class="col-md-12">
<div class="col-md-offset-4">
<div class="box-header">
<input type="file" accept=".png,.jpg,.pdf" onchange="filealert();" id="myfile" name="myfile" />
<label for="photo">Select File to upload<br/></label>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<table id="Inwardgateregistertable" class="table table-bordered table-hover editabletable IGR_Line" style="background-color:#fff;font-size:12px;">
<thead style="background-color:#ddf">
<tr>
<th>S.No</th>
<th>Item Code</th>
<th>Material</th>
<th>UOM</th>
<th>Ordered Quantity</th>
<th>Received Quantity</th>
<th>Pending Quantity</th>
<th>Advised Quantity</th>
<th>Remarks</th>
</tr>
</thead>
<tbody id ="IGRappend">
</tbody>
</table>
<input type="hidden" name="txtRowCount" id="txtRowCount" />
<!--<input type="text" id="tablevalues" value="sample" name="tablevalues"/>
<div class="col-md-12">-->
<!--<table id="specialtable" class="table table-hover table-bordered" style="background-color:#fff;font-size:12px;" >-->
<!--<thead style="background-color:#ddf">
<tr>
<th>MaterialCode1</th>
<th>DeliveryChallanDate</th>
<th>DeliveryChallanNo</th>
<th>VehicleNo</th>
<th>CourierNo</th>
<th>Quantity12</th>
<th>File</th>
</tr>
</thead>-->
<div class="col-md-1 col-md-offset-10">
<a class="btn btn-primary" id='IGRLink' name='IGRLink' onclick="filecheck();">Generate IGR</a>
</div>
</div>
</div>
</div>
<div class="modal fade" id="generateIGR" role="dialog">
<div class="modal-dialog modal_style">
<!-- Modal content-->
<form>
<div class="modal-content">
<div class="modal-header" style="background-color: #3c8dbc;color:#fff;">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<center><h4>Inward Gate Register Number</h4></center>
</div>
<div class="col-md-12"> <br/>
<center><label style="font-size:40px;" id="finaligr" >Default</label> </center>
</div>
<div class="modal-footer">
<center>
<button type="reset" value="Reset" onClick="window.location.reload()"> OK</button>
</center>
</div><!-- footer div closed -->
</div><!-- modal content div closed-->
</form><!-- form closed-->
</div><!-- modal content closed-->
</div><!-- modal fade closed-->
<!-- new modal ended-->
</div>
</section>
</div>
<script>
<!-- script for table , It works under the datatable plugin-->
function validate_Vechicle(){
var reg = /^^[A-Z]{2}\s[0-9]{2}\s[A-Z]{2}\s[0-9]{4}$/;
// alert();
var VehicleNo = $('#VehicleNo').val();
if(VehicleNo != "")
{
if (reg.test(VehicleNo) == false)
{
alert('Please Enter Valid Vehicle Number');
return (false);
}
else
{
return true;
}
}
}
function validate()
{
var rowcount = $("#txtRowCount").val();
var Noval = 0;
var isExceed = 0;
for(k=1;k<=rowcount ; k++)
{
var AdvisedQty = parseFloat( $('#QuantityAsPerInvoice'+k).val() == '' ? '0.00' : $('#QuantityAsPerInvoice'+k).val());
var RecQty = parseFloat( $('#txtReceivedQuantity'+k).val() == '' ? '0.00' : $('#txtReceivedQuantity'+k).val());
var OrderedQty =parseFloat($('#Quantity_1'+k).text());
if(AdvisedQty != '0.00')
{
if(OrderedQty < (AdvisedQty+RecQty))
{
isExceed = 1;
return false;
}
Noval = 1;
}
}
if($('#PONO').val()=='-1')
{
alert("Please select PurchaseOrder");
$('#PONO').focus();
return false;
}
else if($('#InvoiceNo').val() == '' )
{
alert('Please Enter Invoice Number' );
$('#InvoiceNo').focus();
return false;
}
else if($('#InvoiceDate').val() == '' )
{
alert('Please Enter Invoice Date' );
$('#InvoiceDate').focus();
return false;
}
else if (Noval == 0 )
{
alert('Advised Quantity is Empty.Please Enter the value');
return false;
}
else if($('#VehicleNo').val() == '' && $('#CourierNo').val() == '')
{
alert('Please Enter the Vechicle / Courier Number');
return false;
}
else if(isExceed == 1 ){
alert("Advised Quantity is exceeding the Ordered Quantity.Please Contact Purchase Team for further Process ")
return false;
}
else
{
return true;
}
}
</script>
<script>
$(function () {
$('#Inwardgateregistertable').DataTable({
"paging": false,
"lengthChange": false,
"searching": false,
"ordering": false,
"info": false,
"autoWidth": false
});
});
</script>
<script>
// $(function() {
function removeHidden()
{
var rowcount = $("#txtRowCount").val();
for(k=1;k<=rowcount ; k++)
{
$("#MaterialCode"+k).remove();
$("#txtQuantityAsPerInvoice"+k).remove();
$("#OrderedQuantity"+k).remove();
$("#txtReceivedQuantity"+k).remove();
$("#txtRemarks"+k).remove();
$("#txtPendingQty"+k).remove();
}
}
$('#PONO').change(function() {
removeHidden();
$("#IGRappend").empty();
$('#txtRowCount').val('');
var id = $('#PONO').val();
var status= '';
if(id != '-1')
{
$('#content').loader('show');
var y = <?php echo json_encode($PO_NO, JSON_PRETTY_PRINT) ?>;
$.each(y, function(idx, obj) {
if(id == obj.PONO)
{
$("#po").val(obj.PONO);
$("#Sup").val(obj.SupplierName);
//$("#Add").val(obj.Address);
$("#del").val(obj.DeliveryDate);
//$("#ser").val(obj.ServiceDescription);
status = obj.status;
}
});
$.ajax({
data:{id:id},
type:"POST",
url:"<?php echo base_url() ?>inwardgateregister/IGRITEM",
success:function(data) {
//alert(data);
$('#content').loader('hide');
//alert(data);
var trHTML = '';
$.each(JSON.parse(data), function (i, item) {
i=i+1;
trHTML += '<tr>' +
'<td align="right">' + i + '</td>' +
'<td name="MaterialName" id="MaterialCode" >' + item.MaterialCode + '</td>' +
'<td>' + item.MaterialName + '</td>' +
'<td name="UOM">' + item.UOM + '</td>' +
'<td name="Quantity1'+i+'" id="Quantity_1'+i+'">' + item.Quantity + '</td>' +
'<td name="ReceivedQuantity'+i+'" id="ReceivedQuantity'+i+'">'+ item.ReceivedQuantity +'</td>'+
'<td name="PendingQuantity'+i+'" id="PendingQuantity'+i+'">'+ item.PendingQty +'</td>'+
'<td data-name="sel" ><input type="text" onchange="validateReceivedQuantity('+i+')"id="QuantityAsPerInvoice'+ i +'" name="QuantityAsPerInvoice'+ i +'" value="" onkeypress="return isNumberKey(event);"></td>' +
'<td><input type="text" id="Remark'+ i +'" name="Remark'+ i +'" class="form" onchange="SetRemarks('+i+')"> </td>' +
'</tr>';
$('#txtRowCount').val(i);
$('<input>').attr({
type: 'hidden',
id: 'MaterialCode'+i,
value:item.MaterialCode,
name: 'MaterialCode'+i
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'txtQuantityAsPerInvoice'+i,
name: 'txtQuantityAsPerInvoice'+i
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'OrderedQuantity'+i,
value:item.Quantity,
name: 'OrderedQuantity'+i
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'txtReceivedQuantity'+i,
name: 'txtReceivedQuantity'+i,
value:item.ReceivedQuantity
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'txtRemarks'+i,
name: 'txtRemarks'+i
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'txtPendingQty'+i,
name: 'txtPendingQty'+i,
value:item.PendingQty
}).appendTo('form');
//alert(item.PendingQty);
if(item.PendingQty == 0.00)
{
//alert('inside if');
$('#QuantityAsPerInvoice'+i).attr('readonly', 'true');
// $('#txtEditFreight').attr('readonly', 'true');
}
});
$("#IGRappend").empty();
$('#IGRappend').append(trHTML);
}
});
if(status == '<?php echo IGR_CREATED ?>' || status == '<?php echo MRIR_CREATED ?>' || status == '<?php echo MRIR_APPROVED ?>' )
{
alert('The Order is completed!!');
$("#IGRLink").hide();
}
else
{
$("#IGRLink").show();
}
}
else
{
alert('Please Select the Purchase Order Number to Create IGR');
}
});
function SetRemarks(RowId)
{
var remks = $("#Remark"+RowId).val();
if( remks != '')
{
$("#txtRemarks"+RowId).val(remks);
}
}
function validateReceivedQuantity(Rowid){
//alert(Rowid);
var InvoiceQty = parseFloat( $('#QuantityAsPerInvoice'+Rowid).val() == '' ? '0.00' : $('#QuantityAsPerInvoice'+Rowid).val());
var PendingQty = parseFloat( $('#PendingQuantity'+Rowid).text() == '' ? '0.00' : $('#PendingQuantity'+Rowid).text());
var RecQty = parseFloat( $('#txtReceivedQuantity'+Rowid).val() == '' ? '0.00' : $('#txtReceivedQuantity'+Rowid).val());
var OrderedQty =parseFloat($("#Quantity_1"+Rowid).text());
var r =$("#Remark"+Rowid).val();
// alert(RecQty);
//alert(InvoiceQty);
if((InvoiceQty+RecQty) > OrderedQty){
alert("Advised Quantity is exceeding the Ordered Quantity.Please Contact Purchase Team for further Process ")
$("#QuantityAsPerInvoice"+Rowid).focus();
$("#QuantityAsPerInvoice"+Rowid).val('');
return false;
}
else if(((InvoiceQty+RecQty) - OrderedQty) > 0.00){
alert("Order is completed.")
$("#QuantityAsPerInvoice"+Rowid).focus();
$('#QuantityAsPerInvoice'+Rowid).val('');
return false;
}
else {
// alert(RecQty);
$('#PendingQuantity'+Rowid).text((OrderedQty - (InvoiceQty+RecQty)).toFixed(2));
$('#txtPendingQty'+Rowid).val(OrderedQty - (InvoiceQty+RecQty));
$("#ReceivedQuantity"+Rowid).val(InvoiceQty+RecQty);
$("#txtQuantityAsPerInvoice"+Rowid).val(InvoiceQty);
// InvoiceQty
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;
}
function Save()
{
//alert("save function worked ");
if (validate())
{
// alert($('#Inwardgateregistertable').rows.count);
//alert(" if condition validation part ");
// $('#content').loader('show');
// $.ajax({
// data:$('.IGR').serialize(),
// type:"POST",
// url:"<?php echo base_url() ?>inwardgateregister/addNewigr",
// success:function(data) {
// if(data){
// $('#content').loader('hide');
// document.getElementById('finaligr').innerHTML=data;
// $('#generateIGR').modal('show');
// }
// else
// {
// alert("Error");
// }
// }//success function closed
// });//ajax closed
//var tablevalue = $('#specialtable').tableToJSON(); // Convert the table into a javascript object
//var jsondata = JSON.stringify(tablevalue);
//$('#tablevalues').val(jsondata);
$("#IGR").attr("method", "post");
$("#IGR").attr("enctype", "multipart/form-data");
$("#IGR").attr("action", "inwardgateregister/addNewigr");
$('#IGR').submit();
}//validate if closed
}//save function closed
function filecheck()
{
var myfile = $('#myfile').val();
if(myfile=='')
{
alert('File not Found');
Save();
}
}
function filealert()
{
var myfile = $('#myfile').val();
if(myfile!='')
{
alert('Your file added successfully');
}
}
</script>