This commit is contained in:
venbatechnologies 2018-07-18 10:39:24 +05:30
parent b24a58b44b
commit 5c210411dc
6 changed files with 339 additions and 168 deletions

View File

@ -37,7 +37,7 @@ class inwardgateregister extends BaseController
function viewIGRDetails()
{
$this->load->model('inwardgateregister_model');
$this->global['pageTitle'] = 'Siddharth : Inward Gate Register Details';
$data['IGR']= $this->inwardgateregister_model->igrListing();
@ -280,7 +280,7 @@ class inwardgateregister extends BaseController
function addloadfile()
{
$upfiles = '';
$pono= $this->input->post('PONO');
$igr= $this->input->post('igr');
@ -408,63 +408,63 @@ function edituploadfile()
// }
}
function addNewigr()
function addNewigr()
{
// echo "add";
// die();
// echo "add";
// die();
$PONO = $this->input->post('PONO');
$DeliveryChellanOrInvoiceNo = $this->input->post('InvoiceNo');
$DeliveryChellan = $this->input->post('InvoiceDate');
$DeliveryChellanDate = $this->getDateformat($DeliveryChellan);
$Mat_Rcvd_Dt = $this->input->post('MaterialRcvdDate');
$MaterialRcvdDt = $this->getDateformat($Mat_Rcvd_Dt);
$DeliveryChellanDate = $this->getDateformat($DeliveryChellan);
$Mat_Rcvd_Dt = $this->input->post('MaterialRcvdDate');
$MaterialRcvdDt = $this->getDateformat($Mat_Rcvd_Dt);
$VehicleNo = $this->input->post('VehicleNo');
$CourierNo = $this->input->post('CourierNo');
$CreatedBy = $this->session->userdata('userId');
//$Remarks = $this->input->post('Remarks');
$RowCount = $this->input->post('txtRowCount');
//echo $RowCount;
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$createddt = $dt->format('Y-m-d H:i:s');
$IGRStatus = IGR_CREATED;
$document = null;
// $fs = 0;
// // if(!empty($_FILES['myfile']['name']))
$RowCount = $this->input->post('txtRowCount');
//echo $RowCount;
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$createddt = $dt->format('Y-m-d H:i:s');
$IGRStatus = IGR_CREATED;
$document = null;
// $fs = 0;
// // if(!empty($_FILES['myfile']['name']))
// // {
// // //echo "FILE AVAILABLE";
// // $config['file_name'] = $_FILES['myfile']['name'];
// // $config['upload_path'] = 'uploads/Igrfiles/';
// // $config['allowed_types'] = 'png|jpg|jpeg|pdf|docx';
// // $path = $config['upload_path'];
// // $filename = $config['file_name'];
// // $document = $path.$filename;
// // //echo $document;
// // $fs = $this->uploadFile();
// // $document = $path.$fs;
// // //echo "FILE AVAILABLE";
// // $config['file_name'] = $_FILES['myfile']['name'];
// // $config['upload_path'] = 'uploads/Igrfiles/';
// // $config['allowed_types'] = 'png|jpg|jpeg|pdf|docx';
// // $path = $config['upload_path'];
// // $filename = $config['file_name'];
// // $document = $path.$filename;
// // //echo $document;
// // $fs = $this->uploadFile();
// // $document = $path.$fs;
// // //echo $document;die();
// // }
// //echo $RowCount;
$igr = array();
$igr = array('PONO'=>$PONO,'VehicleNo'=>$VehicleNo,'DeliveryChellanOrInvoiceNo'=>$DeliveryChellanOrInvoiceNo,'DeliveryChellanDate'=>$DeliveryChellanDate,'MaterialRcvdDate'=>$MaterialRcvdDt,'CourierNo'=>$CourierNo,'IGRStatus'=>$IGRStatus,'CreatedBy'=>$CreatedBy,'CreatedDate' =>$createddt);
//print_r($igr);die();
$igrM = $this->inwardgateregister_model->addigrM($igr);
// // }
// //echo $RowCount;
$igr = array();
$igr = array('PONO'=>$PONO,'VehicleNo'=>$VehicleNo,'DeliveryChellanOrInvoiceNo'=>$DeliveryChellanOrInvoiceNo,'DeliveryChellanDate'=>$DeliveryChellanDate,'MaterialRcvdDate'=>$MaterialRcvdDt,'CourierNo'=>$CourierNo,'IGRStatus'=>$IGRStatus,'CreatedBy'=>$CreatedBy,'CreatedDate' =>$createddt);
//print_r($igr);die();
$igrM = $this->inwardgateregister_model->addigrM($igr);
/*---------------------------------------JUN 11 change----------------------------------------------------*/
/*---------------------------------------JUN 11 change----------------------------------------------------*/
$IGRNO = '';
if(count($igrM)>0)
{
@ -555,136 +555,145 @@ $prefile =array();
/*-------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------*/
$OGRStatus=IGR_CREATED;
$check_OGRPO= $this->inwardgateregister_model->update_OGR($PONO,$OGRStatus);
$IGRNO = '';
if(count($igrM)>0)
{
foreach ($igrM as $key ) {
$IGRNO=$key->IGRNO;
}
}
//echo $IGRNO;
$IGRItemStatus = REQITEM_NEW;
for ($i = 1; $i <= $RowCount; $i++)
{
$MaterialCode = trim($this->input->post('MaterialCode'.$i));
$check_OGRPO= $this->inwardgateregister_model->update_OGR($PONO,$OGRStatus);
$IGRNO = '';
if(count($igrM)>0)
{
foreach ($igrM as $key ) {
$IGRNO=$key->IGRNO;
}
}
//echo $IGRNO;
$IGRItemStatus = REQITEM_NEW;
$TotalPendingQty = '';
for ($i = 1; $i <= $RowCount; $i++)
{
$MaterialCode = trim($this->input->post('MaterialCode'.$i));
$QuantityAsPerInvoice = trim($this->input->post('txtQuantityAsPerInvoice'.$i));
$OrderedQuantity = trim($this->input->post('OrderedQuantity'.$i));
$ReceivedQty = trim($this->input->post('txtReceivedQuantity'.$i));
$QuantityAsPerInvoice = trim($this->input->post('txtQuantityAsPerInvoice'.$i));
$OrderedQuantity = trim($this->input->post('OrderedQuantity'.$i));
$ReceivedQty = trim($this->input->post('txtReceivedQuantity'.$i));
$PendingQty = $this->input->post('txtPendingQty'.$i);
//echo $QuantityAsPerInvoice;
//echo $PendingQty.'ReceivedQty'.$ReceivedQty;
//echo ' ';
if(strlen($QuantityAsPerInvoice)>0 && $QuantityAsPerInvoice != '0')
{
$Remarks = $this->input->post('txtRemarks'.$i);
$ItemStatus = '';
//if($QuantityAsPerInvoice == $OrderedQuantity)
if($PendingQty == 0.00 )
{
$ItemStatus = IGR_CREATED;
$PendingQty = $this->input->post('txtPendingQty'.$i);
//echo $QuantityAsPerInvoice;
//echo $PendingQty.'ReceivedQty'.$ReceivedQty;
//echo ' ';
$TotalPendingQty = $TotalPendingQty + $PendingQty;
if(strlen($QuantityAsPerInvoice)>0 && $QuantityAsPerInvoice != '0')
{
$Remarks = $this->input->post('txtRemarks'.$i);
$ItemStatus = '';
//if($QuantityAsPerInvoice == $OrderedQuantity)
if($PendingQty == 0.00 )
{
$ItemStatus = IGR_CREATED;
}
else
{
$ItemStatus = POLINEITEM_IGRPARTIAL_CREATED;
}
$CreatedBy = $this->session->userdata('userId');
$bankstatus = NO_PAIDIGR;
$igrDetails = array('IGRNO'=>$IGRNO,'MaterialCode'=>$MaterialCode,'QuantityAsPerInvoice'=>$QuantityAsPerInvoice,'Remarks'=>$Remarks,'IGRItemStatus'=>$IGRItemStatus,'CreatedBy'=>$CreatedBy,'CreatedDate'=>$createddt,'BankStatus'=>$bankstatus);
$igrD = $this->inwardgateregister_model->addigrD($igrDetails);
}
else
{
$ItemStatus = POLINEITEM_IGRPARTIAL_CREATED;
}
$CreatedBy = $this->session->userdata('userId');
$bankstatus = NO_PAIDIGR;
$igrDetails = array('IGRNO'=>$IGRNO,'MaterialCode'=>$MaterialCode,'QuantityAsPerInvoice'=>$QuantityAsPerInvoice,'Remarks'=>$Remarks,'IGRItemStatus'=>$IGRItemStatus,'CreatedBy'=>$CreatedBy,'CreatedDate'=>$createddt,'BankStatus'=>$bankstatus);
$igrD = $this->inwardgateregister_model->addigrD($igrDetails);
$igrlineno ='';
$igrlineno ='';
if(!empty($igrD))
{
foreach($igrD as $ig)
{
$igrlineno = $ig->IGRItemNo;
}
}
if(!empty($igrD))
{
foreach($igrD as $ig)
{
$igrlineno = $ig->IGRItemNo;
}
}
$itemvalue='';
$SupplierId='';
$polineitemvalue = $this->inwardgateregister_model->getitemvalue($PONO,$MaterialCode);
foreach($polineitemvalue as $it)
{
foreach($polineitemvalue as $it)
{
$itemvalue =$it->Rate;
$SupplierId =$it->SupplierID;
}
}
$historydetails = array('MaterialCode'=>$MaterialCode,'Transaction_type'=>"Add",'Ref_Type'=>"IGR",'Ref_No'=>$igrlineno,'Quantity'=>$QuantityAsPerInvoice,'CreatedBy'=>$CreatedBy,'CreatedOn'=>$createddt,'SupplierID'=>$SupplierId,'ItemValue'=>$itemvalue);
$historydetails = array('MaterialCode'=>$MaterialCode,'Transaction_type'=>"Add",'Ref_Type'=>"IGR",'Ref_No'=>$igrlineno,'Quantity'=>$QuantityAsPerInvoice,'CreatedBy'=>$CreatedBy,'CreatedOn'=>$createddt,'SupplierID'=>$SupplierId,'ItemValue'=>$itemvalue);
$this->inwardgateregister_model->addmaterialhistory($historydetails);
$this->inwardgateregister_model->addmaterialhistory($historydetails);
$get_pre_qty= $this->inwardgateregister_model->get_CurrentQty($MaterialCode);
$av_qty=0;
if(!empty($get_pre_qty))
{
foreach($get_pre_qty as $gt)
{
$av_qty=$gt->Current_stock;
}
}
$get_pre_qty= $this->inwardgateregister_model->get_CurrentQty($MaterialCode);
$av_qty=0;
if(!empty($get_pre_qty))
{
foreach($get_pre_qty as $gt)
{
$av_qty=$gt->Current_stock;
}
}
$currentav_qty= $QuantityAsPerInvoice+$av_qty;
$currentav_qty= $QuantityAsPerInvoice+$av_qty;
$current_qty= array('Current_stock'=>$currentav_qty);
$this->inwardgateregister_model->addmaterialmaster($current_qty,$MaterialCode);
$Recqty = $this->inwardgateregister_model->getPOLineItemReceivedQty($PONO,$MaterialCode);
$ReceivedQuantity = 0.00;
if(count($Recqty)>0)
{
foreach ($Recqty as $key ) {
$ReceivedQuantity=$key->ReceivedQuantity;
}
}
$totalReceivedqty = $ReceivedQuantity + $QuantityAsPerInvoice;
//echo '';
$POLineItem = array('ReceivedQuantity'=>$totalReceivedqty,'Status'=>$ItemStatus,'UpdateBY'=>$CreatedBy,'UpdatedOn'=>$createddt );
$this->inwardgateregister_model->UpdatePOLineItem($POLineItem,$PONO,$MaterialCode);
}
}
$this->inwardgateregister_model->UpdatePOMaster($PONO,$CreatedBy);
if($TotalPendingQty == 0.00){
$Newstatus = array('Status'=>IGR_CREATED);
$Recqty = $this->inwardgateregister_model->getPOLineItemReceivedQty($PONO,$MaterialCode);
$ReceivedQuantity = 0.00;
if(count($Recqty)>0)
{
foreach ($Recqty as $key ) {
$ReceivedQuantity=$key->ReceivedQuantity;
}
}
$totalReceivedqty = $ReceivedQuantity + $QuantityAsPerInvoice;
//echo '';
$POLineItem = array('ReceivedQuantity'=>$totalReceivedqty,'Status'=>$ItemStatus,'UpdateBY'=>$CreatedBy,'UpdatedOn'=>$createddt );
$this->inwardgateregister_model->UpdatePOLineItem($POLineItem,$PONO,$MaterialCode);
}
}
$this->inwardgateregister_model->UpdatePOMaster($PONO,$CreatedBy);
echo "<script>alert('Successfully Created IGR Number:$IGRNO'); window.location.href='viewIGRDetails';</script>";
$this->inwardgateregister_model->POLineItemsupdatestatus($PONO,$Newstatus);
$this->inwardgateregister_model->pomasterupdatestatus($PONO,$Newstatus);
}
else{ /*echo 'error' ;*/ }
echo "<script>alert('Successfully Created IGR Number:$IGRNO'); window.location.href='viewIGRDetails';</script>";
//echo 'Successfully Created IGR Number:'. $IGRNO;
}
}
function ViewIGR()
{

View File

@ -532,9 +532,13 @@ class report extends BaseController
$PONO= substr($PO,5);
//echo $PONO; die;
$data = $this->dahsboard_Model->getfiles($PONO);
$igrfile= $this->dahsboard_Model->getfiles($PONO);
// $igrfile = $this->inwardgateregister_model->viewIGRFile($IGRNO);
$billfile = $this->dahsboard_Model->viewIGRFile1($PONO);
// print_r( $data);die;
$data = array_merge($igrfile,$billfile);
// print_r( $data);die;
echo json_encode($data);

View File

@ -48,6 +48,24 @@ function getfiles($PONO)
return $result;
}
function viewIGRFile1($PONO)
{
$this->db->distinct();
$this->db->select('igrm.file,igrm.PONO as pono'); //BillNo,IGRNO,FilePath,PONO
$this->db->from('T_IGR_Master igrm');
$this->db->where('igrm.PONO',$PONO);
$query = $this->db->get();
$result = $query->result();
// print_r($result);die;
//print_r($this->db->last_query());
return $result;
}
function selectigrfiles()
{

View File

@ -128,6 +128,27 @@ return $afftectedRows;
}
function viewIGRFile1($IGRNO)
{
$this->db->distinct();
$this->db->select('igrm.file,igrm.PONO as pono'); //BillNo,IGRNO,FilePath,PONO
$this->db->from('T_IGR_Master igrm');
//$this->db->join('T_Inwardgateregister_fileupload igrf','igrm.IGRNO = igrf.IGRNO','left');
//$this->db->join('T_IGR_Details igrd','igrm.IGRNO = igrd.IGRNO','left');
$this->db->where('igrm.IGRNO',$IGRNO);
$query = $this->db->get();
$result = $query->result();
// print_r($result);die;
//print_r($this->db->last_query());
return $result;
}
function getpurchaseorder()
@ -804,5 +825,32 @@ function getPOmaterial($PONO)
$r = $this->db->affected_rows();
return $r;
}
function getpolineqty($NewPO)
{
$this->db->select('sum(Quantity)as Qty,sum(ReceivedQuantity)as rec');
$this->db->from('T_PurchaseOrder_LineItem');
$this->db->where('PONO',$NewPO);
$query = $this->db->get();
return $query->result();
}
function POLineItemsupdatestatus($PONO,$Newstatus)
{
$this->db->where('PONO',$PONO);
$this->db->update('T_PurchaseOrder_LineItem',$Newstatus);
$update = $this->db->affected_rows();
return $update;
}
function pomasterupdatestatus($PONO,$Newstatus)
{
$this->db->where('PONO',$PONO);
$this->db->update('T_PurchaseOrder_Master',$Newstatus);
$update = $this->db->affected_rows();
return $update;
}
}

View File

@ -22,7 +22,7 @@
position: relative;
float: right;
}
}
.btn-success {
background-color: #3c8dbc;
border-color: #3c8dbc;
@ -266,7 +266,10 @@
if(!empty($rel['file'])){ ?>
<a target="_blank" data-toggle="tooltip" data-placement="left" title="Attachment Available for Download/View"><button class="btn btn-info btn-sm splpofile" id="files<?php echo $rel['pono'];?>">Download</button></a>
<?php } elseif(!empty(sizeof($rel['Infiles'])) !=0){?>
<?php } elseif(!empty($rel['ifile'])){?>
<a target="_blank" data-toggle="tooltip" data-placement="left" title="Attachment Available for Download/View"><button class="btn btn-info btn-sm IGRfile" id="files<?php echo $rel['pono'];?>">Download</button></a>
<?php } elseif(!empty(sizeof($rel['Infiles'])) !=0){?>
<a target="_blank" data-toggle="tooltip" data-placement="left" title="Attachment Available for Download/View"><button class="btn btn-info btn-sm IGRfile" id="files<?php echo $rel['pono'];?>">Download</button></a>
@ -339,26 +342,70 @@ $("#Fileshow").modal("show");
success: function(data){
//console.log((data));
// var trHTML = '';
// $.each($.parseJSON(data), function (i, item) {
var trHTML = '';
$.each($.parseJSON(data), function (i, item) {
var trHTML = '';
var FilePath ='';
var Filename = '';
var PONO ='';
var BillNO ='';
$.each($.parseJSON(data), 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;
FilePath = item.FilePath;
}
}else{
Filename = item.file;
PONO =item.pono;
BillNO = '-';
FilePath =item.file;
}
i=i+1;
trHTML += '<tr>' +
'<td align="right">' + i + '</td>' +
// i=i+1;
// trHTML += '<tr>' +
// '<td align="right">' + i + '</td>' +
'<td>' + item.BillNo+ '</td>' +
'<td>' + item.PONO+ '</td>' +
// '<td>' + item.BillNo+ '</td>' +
// '<td>' + item.PONO+ '</td>' +
'<td><a target="_blank" href = <?php echo base_url()?>uploads/Igrfiles/'+item.FilePath+'>'+ item.FilePath +'</a></td>' +
// '<td><a target="_blank" href = <?php echo base_url()?>uploads/Igrfiles/'+item.FilePath+'>'+ item.FilePath +'</a></td>' +
// '<td>' +item.FilePath+"<?php echo base_url().'uploads/BillFiles/'?>"> +'</td>'
// // '<td>' +item.FilePath+"<?php echo base_url().'uploads/BillFiles/'?>"> +'</td>'
'</tr>';
// '</tr>';
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>';
}
});

View File

@ -364,9 +364,9 @@ table.dataTable thead > tr > td.sorting {
if(!empty($rel->file)){ ?><!-- if for Inward po file -->
<a target="_blank" class="yourlink" data-toggle="tooltip" data-placement="left" title="Attachment Available for Download/View"><button class="btn btn-info btn-sm splpofile" id="files<?php echo $rel->pono;?>">Download</button></a>
<?php }
else if(!empty($rel->ifile )) { ?><!-- else if for igr file -->
<a target="_blank" href="<?php echo base_url().''.$rel->ifile ?>" data-toggle="tooltip" data-placement="left" title="Attachment Available for Download/View">
<button class="btn btn-info btn-sm">Download</button>
else if(!empty($rel->ifile )) { ?><!-- else if for igr file -->
<a target="_blank" class="yourlink" data-toggle="tooltip" data-placement="left" title="Attachment Available for Download/View">
<button class="btn btn-info btn-sm IGRfile" id="files<?php echo $rel->pono;?>">Download</button>
</a>
<?php } else if (!empty($rel->Infiles)){ ?><!-- if for Inward po file -->
<a target="_blank" class="yourlink" data-toggle="tooltip" data-placement="left" title="Attachment Available for Download/View"><button class="btn btn-info btn-sm IGRfile" id="files<?php echo $rel->pono;?>">Download</button></a>
@ -566,6 +566,7 @@ $('.splpofile').click(function() {
$('.IGRfile').click(function() {
var id = $(this).attr('id');
$("#Fileshow").modal("show");
$.ajax({
data:{id:id},
@ -575,15 +576,59 @@ $('.IGRfile').click(function() {
var trHTML = '';
$.each($.parseJSON(data), function (i, item) {
var trHTML = '';
var FilePath ='';
var Filename = '';
var PONO ='';
var BillNO ='';
$.each($.parseJSON(data), 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;
FilePath = item.FilePath;
}
}else{
Filename = item.file;
PONO =item.pono;
BillNO = '-';
FilePath =item.file;
}
i=i+1;
trHTML += '<tr>' +
'<td align="right">' + i + '</td>' +
'<td>' + item.BillNo+ '</td>' +
'<td>' + item.PONO+ '</td>' +
'<td><a target="_blank" href = <?php echo base_url()?>uploads/Igrfiles/'+item.FilePath+'>'+ item.FilePath +'</a></td>' +
'</tr>';
// i=i+1;
// trHTML += '<tr>' +
// '<td align="right">' + i + '</td>' +
// '<td>' + item.BillNo+ '</td>' +
// '<td>' + item.PONO+ '</td>' +
// '<td><a target="_blank" href = <?php echo base_url()?>uploads/Igrfiles/'+item.FilePath+'>'+ item.FilePath +'</a></td>' +
// '</tr>';
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>';
}
});