siddharth_application/application/views/viewIGRDetails.php
venbatechnologies 8f0b886332 file
2018-07-19 12:48:01 +05:30

805 lines
22 KiB
PHP
Executable File

<style>
.modal
{
padding-right:25% ! important;
}
.num{
text-align:right;
}
.modal-content
{
width:800px ! important;
}
</style>
<div class="content-wrapper">
<section class="content"><br/>
<div class="box">
<div class=" container-fluid">
<div class="box-header">
<CENTER><h3 class="box-title">Siddharth Industries -View Inward Gate Register</h3></CENTER>
</div>
<div class="row">
<div class="col-md-12 text-right" style="margin-bottom:-3%;">
<div class="form-group">
<a class="btn btn-primary" 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:#ddf">
<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>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 ?>" > <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><?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-userid="<?php echo $record->IGRNO.'-'.$record->PONO ?>"><button class="btn btn-info 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-userid="<?php echo $record->IGRNO ?>"><button class="btn btn-info 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-userid="<?php echo $record->IGRNO.'-'.$record->PONO ?>"><i class="fa fa-pencil" style="text-align: center;"></i></a>
<?php }
?>
</td>
<!--<td><?php echo $record->file ?></td>-->
</tr>
<?php
//$SNo++;
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- ######################################edit file########################### -->
<div class="modal fade" id="Fileshow" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<form>
<div class="modal-content" style="width:800px;">
<div class="modal-header" style="background-color: #3c8dbc;color:#fff;">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<center><h4>Inward Gate File Details</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="font-size:12px;">
<thead style="background-color:#ddf">
<tr>
<th>SNo</th>
<th>BillNO</th>
<th>PONO</th>
<th>FileName</th>
<th>Action</th>
</tr>
</thead>
<tbody id="tblefile">
</tbody>
</table>
<div class="col-md-12">
<div class="col-md-offset-10 col-md-8" >
<input type="button" class="btn btn-primary" id ="addmorebutton" value=" ADD FILES..">
</div>
<div id="newdiv"></div>
<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>
<div class="modal-footer">
<!-- <a class="btn btn-primary" data-dismiss="modal" id='editfileadd' value="">ADD</a> -->
<br>
</br>
<a class="btn btn-primary" data-dismiss="modal" value="Cancel">Cancel</a>
</div>
</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-primary" onclick="fileupdate()" >&nbsp;&nbsp;<span class="bold">Update</span>
<a class="btn btn-primary" data-dismiss="modal" value="Cancel">Cancel</a>
</div>
</div>
</div><!-- /.modal footer -->
</form>
</div><!-- /.modal content -->
</div><!-- /.modal dialog -->
</div><!-- /#filemodal -->
<!-- ################################################################# -->
<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" style="background-color: #3c8dbc;color:#fff;">
<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">
<label>Purchase Order Number </label>
<?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>Delivery Challan/Invoice NO </label>
<?php
$data = array('name' => 'DeliveryChallan/InvoiceNO','value' => set_value('DeliveryChallan/InvoiceNO'),'id'=>'Invoice_No', 'class' => 'form-control', 'required=>"true"' , 'readonly'=>'true' );
echo form_input($data);
?>
</div>
<div class="col-md-4">
<label>Delivery Challan / Invoice Date </label>
<?php
$data = array('name' => 'DeliveryChallan/InvoiceDate','value' => set_value('DeliveryChallan/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>
<!-- Table to show the line item of po -->
<div id="content" > </div>
<table class="table table-bordered" id="Inwardgateregistertable1" style="font-size:12px;">
<thead style="background-color:#ddf">
<tr>
<th>SNo</th>
<th>Item Code</th>
<th>Item Description</th>
<th>UOM</th>
<th>Ordred Quantity</th>
<th>Received Quantity</th>
<th>Remarks</th>
</tr>
</thead>
<tbody id="tbleAppend1">
<!-- <tr>
<td>1</td>
<td>RM002</td>
<td>Raw sand</td>
<td>Kgs</td>
<td>10000</td>
<td>10000</td>
<td>Received</td>
</tr>-->
</tbody>
</table>
<div class="modal-footer">
<a class="btn btn-primary" data-dismiss="modal" value="Cancel">Cancel</a>
</div>
</div>
</form>
</div>
</div>
</section>
<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 id = $(e.relatedTarget).data('userid');
// alert(id);
// SIA/2018-2019/10243.01
// IGRNO0505
var igr = id.substring(0, 9);
// alert(igr);
var po = id.substring(10, 33);
//alert(po);
$("#hiddenIGRNO").val(igr);
$("#hiddenPONO").val(po);
if(id !=''){
$.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)
{
//alert()
PONO =item.PONO;
BillNO =item.BillNo;
Filename =item.FilePath;
FilePath = "<?php echo base_url()?>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();
$("#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": [[ 4, "desc" ]],
"info": true,
"autoWidth": true
});
});
</script>
<script>
$("#Igrshow").on("shown.bs.modal", function(e) {
var igr = $(e.relatedTarget).data('userid');
// alert(igr);
$('#content').loader('show');
$.ajax({
data:{id:igr},
type:"POST",
//dataType: 'json',
url:"<?php echo base_url() ?>inwardgateregister/ViewIGR",
success:function(data) {
// success:function(data) {
$('#content').loader('hide');
var trHTML = '';
$.each(JSON.parse(data), function (i, item) {
if(igr == item.IGRNO)
{
$("#IGRNO1").val(item.IGRNO);
$("#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;
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-primary" 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>