From 5c210411dcf3e5d2c53371c1ff1cff85881141e2 Mon Sep 17 00:00:00 2001 From: venbatechnologies Date: Wed, 18 Jul 2018 10:39:24 +0530 Subject: [PATCH] igr file --- .../controllers/inwardgateregister.php | 297 +++++++++--------- application/controllers/report.php | 8 +- application/models/dahsboard_model.php | 18 ++ .../models/inwardgateregister_model.php | 48 +++ application/views/Report_attach_inward.php | 69 +++- application/views/Report_purchase_inward.php | 67 +++- 6 files changed, 339 insertions(+), 168 deletions(-) diff --git a/application/controllers/inwardgateregister.php b/application/controllers/inwardgateregister.php index 8a835f3c..71a77e82 100644 --- a/application/controllers/inwardgateregister.php +++ b/application/controllers/inwardgateregister.php @@ -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 ""; + $this->inwardgateregister_model->POLineItemsupdatestatus($PONO,$Newstatus); + $this->inwardgateregister_model->pomasterupdatestatus($PONO,$Newstatus); + } + else{ /*echo 'error' ;*/ } + echo ""; //echo 'Successfully Created IGR Number:'. $IGRNO; - } - + } + function ViewIGR() { diff --git a/application/controllers/report.php b/application/controllers/report.php index 39fc39c2..6df1c2e8 100755 --- a/application/controllers/report.php +++ b/application/controllers/report.php @@ -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); diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php index abbdb5ae..3641eae5 100644 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -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() { diff --git a/application/models/inwardgateregister_model.php b/application/models/inwardgateregister_model.php index db56f4e7..2310fc96 100755 --- a/application/models/inwardgateregister_model.php +++ b/application/models/inwardgateregister_model.php @@ -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; +} } \ No newline at end of file diff --git a/application/views/Report_attach_inward.php b/application/views/Report_attach_inward.php index 8cc6f688..3ebd23f8 100755 --- a/application/views/Report_attach_inward.php +++ b/application/views/Report_attach_inward.php @@ -22,7 +22,7 @@ position: relative; float: right; - } + } .btn-success { background-color: #3c8dbc; border-color: #3c8dbc; @@ -266,7 +266,10 @@ if(!empty($rel['file'])){ ?> - + + + + @@ -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 = "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 += '' + - '' + i + '' + + // i=i+1; + // trHTML += '' + + // '' + i + '' + - '' + item.BillNo+ '' + - '' + item.PONO+ '' + + // '' + item.BillNo+ '' + + // '' + item.PONO+ '' + - 'uploads/Igrfiles/'+item.FilePath+'>'+ item.FilePath +'' + + // 'uploads/Igrfiles/'+item.FilePath+'>'+ item.FilePath +'' + - // '' +item.FilePath+""> +'' + // // '' +item.FilePath+""> +'' - ''; + // ''; + if(Filename != null) + { + i=i+1; + trHTML += '' + + '' + i + '' + + '' + BillNO+ '' + + '' + PONO+ '' + + + ''+ Filename +'' + + + // '' + + ''; + } + }); diff --git a/application/views/Report_purchase_inward.php b/application/views/Report_purchase_inward.php index d28fe845..b1f46127 100755 --- a/application/views/Report_purchase_inward.php +++ b/application/views/Report_purchase_inward.php @@ -364,9 +364,9 @@ table.dataTable thead > tr > td.sorting { if(!empty($rel->file)){ ?> ifile )) { ?> - - + else if(!empty($rel->ifile )) { ?> + + Infiles)){ ?> @@ -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 = "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 += '' + - '' + i + '' + - '' + item.BillNo+ '' + - '' + item.PONO+ '' + - 'uploads/Igrfiles/'+item.FilePath+'>'+ item.FilePath +'' + - ''; + // i=i+1; + // trHTML += '' + + // '' + i + '' + + // '' + item.BillNo+ '' + + // '' + item.PONO+ '' + + // 'uploads/Igrfiles/'+item.FilePath+'>'+ item.FilePath +'' + + // ''; + + if(Filename != null) + { + i=i+1; + trHTML += '' + + '' + i + '' + + '' + BillNO+ '' + + '' + PONO+ '' + + + ''+ Filename +'' + + + // '' + + ''; + + } });