From 5b2014048b66af11121f92913e2e7e77026f7769 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Thu, 31 Aug 2017 10:57:07 +0530 Subject: [PATCH] store updation --- application/config/constants.php | 1 + .../controllers/storerequisitionlist.php | 94 +++++++++++-- application/models/storerequistion_model.php | 51 ++++++- .../views/approvalstorerequisitionslip.php | 4 +- application/views/editstorerequisition.php | 131 ++++++++++++++++-- application/views/issueStoreRequistion.php | 50 +++++-- 6 files changed, 290 insertions(+), 41 deletions(-) diff --git a/application/config/constants.php b/application/config/constants.php index a62da2d2..eebb4ee1 100755 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -115,6 +115,7 @@ define('STORE_OPEN', 'ST034'); define('STORE_PENDINGAPPROVAL', 'ST035'); define('STORE_APPROVAL', 'ST036'); define('STORE_ISSUSED', 'ST037'); +define('STORE_PARTIALLYISSUSED', 'ST055'); define('STORE_ONHOLD', 'ST038'); define('STORE_REJECT', 'ST039'); diff --git a/application/controllers/storerequisitionlist.php b/application/controllers/storerequisitionlist.php index 68e61a75..e916ae25 100755 --- a/application/controllers/storerequisitionlist.php +++ b/application/controllers/storerequisitionlist.php @@ -135,7 +135,7 @@ class storerequisitionlist extends BaseController $StoreReqNo = $Req[0]['StoreReqNo']; //printf_r($ReqNumber); } - echo $StoreReqNo; + //echo $StoreReqNo; @@ -221,6 +221,8 @@ class storerequisitionlist extends BaseController // die(); $ReqNO = $this->input->post('txtReqNo'); $RowCount = $this->input->post('txtRowCount'); + //echo $RowCount; + //die(); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); @@ -229,7 +231,7 @@ class storerequisitionlist extends BaseController $UPdateon = $date->format('Y-m-d H:i:s'); - $ItemStatus = STORE_ISSUSED; + //$ItemStatus = STORE_ISSUSED; for ($i = 1; $i <= $RowCount; $i++) { @@ -238,7 +240,36 @@ class storerequisitionlist extends BaseController // echo $MaterialCode; $IssuedQuantity = $this->input->post('txtIssuedQuantity'.$i); - + $Reqqty= $this->input->post('txtqty'.$i); + // echo $Reqqty; + // die(); + $savedqty=$this->storerequistion_model->getSavedQty($ReqNO,$MaterialCode); + // if($reqstatus==) + // print_r($savedqty); + // die(); + $Qtyissued=0; + foreach($savedqty as $Qty) + { + $Qtyissued=$Qty->QuantityIssued; + } + + $ActQty=$Qtyissued+$IssuedQuantity; + // echo $ActQty; + // die(); + + + if($Reqqty>$ActQty) + { + $ItemStatus = STORE_PARTIALLYISSUSED; + } + + else + { + $ItemStatus = STORE_ISSUSED; + } + + //echo $ItemStatus; + //die(); // echo'Material issed'; if(strlen($IssuedQuantity)>0) { @@ -247,13 +278,18 @@ class storerequisitionlist extends BaseController $Remarks = $this->input->post('txtRemarks'.$i); //echo $IssuedQuantity; + //die (); $CreatedBy = $this->session->userdata('userId'); - $storerequisition = array('StoreReqNo'=>$ReqNO,'MaterialCode'=>$MaterialCode,'QuantityIssued'=>$IssuedQuantity,'Status'=>$ItemStatus,'StoreComments'=>$Remarks,'UpdatedOn'=>$createddt,'UpdatedBy'=>$CreatedBy); + $storerequisition = array('StoreReqNo'=>$ReqNO,'MaterialCode'=>$MaterialCode,'QuantityIssued'=>$ActQty,'Status'=>$ItemStatus,'StoreComments'=>$Remarks,'UpdatedOn'=>$createddt,'UpdatedBy'=>$CreatedBy); + + + //print_r($storerequisition); + //die(); - $this->storerequistion_model->UpdateStoreRequistionItem($storerequisition,$ReqNO,$MaterialCode); + $this->storerequistion_model->UpdateStoreRequistionItem($storerequisition,$ReqNO,$MaterialCode); $getAvailableqty = $this->storerequistion_model->getItemQuantityFromStock(trim($MaterialCode)); @@ -267,10 +303,41 @@ class storerequisitionlist extends BaseController $updatStock = array('Quantity'=>$BalanceQty,'Status'=>'0', 'Remarks'=>'Stock Deducted For'.$ReqNO,'UpdatedOn'=>$UPdateon,'UpdatedBy'=>$UPdateby); - $this->storerequistion_model->UpdateStock($updatStock,trim($MaterialCode)); - + $this->storerequistion_model->UpdateStock($updatStock,trim($MaterialCode)); + + + + $StoreReqNo=$ReqNO; + $reqstatus=$this->storerequistion_model->getstatuscount('ST037',$ReqNO); + $reqstatuscount=0; + //print_r($reqstatus); + foreach ($reqstatus as $Req) + { + $reqstatuscount=$Req->SCount; + } + + + if($reqstatuscount==$RowCount) + { + $reqStatus=STORE_ISSUSED; + } + + else + { + $reqStatus=STORE_PARTIALLYISSUSED; + } + + + // echo $reqstatuscount; + + $updatestatus=array('Status' =>$reqStatus); + + $this->storerequistion_model->updatestoremaster($updatestatus,$StoreReqNo); + + - } + + } } //die(); @@ -287,7 +354,7 @@ class storerequisitionlist extends BaseController $data['AppList'] = $this->storerequistion_model->getApproverRequistList($userID); - + //print_r($data['AppList']); $this->global['pageTitle'] = 'Siddharth : ApprovalStoreRequisitionSlip'; $data['Status']= $this->storerequistion_model->getStatus(); @@ -350,13 +417,17 @@ class storerequisitionlist extends BaseController $MaterialName = $result[$i]['MaterialName']; $UOM = $result[$i]['UOM']; $Quantity = $result[$i]['QuantityRequired']; + $IssuedQty=$result[$i]['QuantityIssued']; + $Status=$result[$i]['StatusName']; $Remarks= $result[$i]['Remarks']; $HTML.=" ".$SNo." ".$MaterialCode." ".$MaterialName." ".$UOM." - ".$Quantity." + ".$Quantity." + ".$IssuedQty." + ".$Status." ".$Remarks." @@ -444,6 +515,9 @@ class storerequisitionlist extends BaseController { $ReqDetails = array('StoreReqNo'=>$StoreReqNo, 'MaterialCode'=>$MaterialCode,'QuantityRequired'=>$QuantityRequired,'Remarks'=>$Remarks,'Status'=>$StoreItemStatus,'UpdatedBy'=>$UpdatedBy,'UpdatedOn'=>$updatedDate); + //print_r($ReqDetails); + //die(); + $this->storerequistion_model->addstoreRequistion($ReqDetails); } else diff --git a/application/models/storerequistion_model.php b/application/models/storerequistion_model.php index 7c51a0c2..5341bdb2 100755 --- a/application/models/storerequistion_model.php +++ b/application/models/storerequistion_model.php @@ -79,11 +79,12 @@ class storerequistion_model extends CI_Model $this->db->join('T_DepartmentDetails Dept','Dept.DEPCode = Sm.DepartmentCode'); $this->db->join('T_Status St','St.StatusCode = Sm.Status'); $this->db->where('Sm.Status ',STORE_APPROVAL); + $this->db->or_where('Sm.Status ',STORE_PARTIALLYISSUSED); $query = $this->db->get(); $result = $query->result(); - //print_r($this->db->last_query()); + // print_r($this->db->last_query()); //print_r($result); return $result; @@ -93,6 +94,7 @@ class storerequistion_model extends CI_Model function addstoreRequistion($Request) { //print_r($Request); + //die(); $this->db->trans_start(); $this->db->insert('T_Store_Requestion_Details',$Request); $insert_id = $this->db->affected_rows(); @@ -250,10 +252,11 @@ class storerequistion_model extends CI_Model function editstorerequistions($StoreReqNo) { - $this->db->select('StoreReqNo,Sr.MaterialCode,Sr.QuantityRequired,Sr.Status,Sr.Remarks,Mm.MaterialName,Mm.UOM '); + $this->db->select('Sr.StoreReqNo,Sr.MaterialCode,Sr.QuantityRequired,Sr.Status,Sr.Remarks,Mm.MaterialName,Mm.UOM,Sr.QuantityIssued,STM.Status '); $this->db->from('T_Store_Requestion_Details Sr'); $this->db->join('T_MaterialMaster Mm' ,' Mm.MaterialCode = Sr.MaterialCode'); - $this->db->where('StoreReqNo',$StoreReqNo); + $this->db->join('T_Store_Requestion_Master STM' ,' STM.StoreReqNo = Sr.StoreReqNo'); + $this->db->where('Sr.StoreReqNo',$StoreReqNo); $query = $this->db->get(); return $query->result(); } @@ -362,7 +365,7 @@ $this->db->select('StoreReqNo,Sr.CostCenterCode,Cc.CostCenterName function getRequistItemListApproval($StoreReqNo,$NoArray='') { - $subQuery = ' select Str.StoreReqNo,Str.MaterialCode,Str.QuantityRequired,Str.Remarks,Mat.MaterialName,Mat.UOM,Ss.StatusName + $subQuery = ' select Str.StoreReqNo,Str.MaterialCode,Str.QuantityRequired,Str.Remarks,Mat.MaterialName,Mat.UOM,Ss.StatusName,Str.Status,Str.QuantityIssued from T_Store_Requestion_Details Str join T_MaterialMaster Mat on Mat.MaterialCode = Str.MaterialCode join T_Status Ss on Ss.StatusCode = Str.Status @@ -393,14 +396,14 @@ $this->db->select('StoreReqNo,Sr.CostCenterCode,Cc.CostCenterName from T_Store_Requestion_Details Str join T_MaterialMaster Mat on Mat.MaterialCode = Str.MaterialCode join T_Status Ss on Ss.StatusCode = Str.Status - join T_Store_Stockdetails St on St.MaterialCode=Str.MaterialCode + left join T_Store_Stockdetails St on St.MaterialCode=Str.MaterialCode where Str.StoreReqNo =?'; $query = $this->db->query($subQuery, array($StoreReqNo)); - // print_r($this->db->last_query()); + //print_r($this->db->last_query()); return $query->result(); @@ -427,6 +430,42 @@ $this->db->select('StoreReqNo,Sr.CostCenterCode,Cc.CostCenterName } + +function getSavedQty($ReqNO,$MaterialCode) +{ + $subQuery='select QuantityIssued from T_Store_Requestion_Details + where StoreReqNo=? and MaterialCode=?'; + + $query = $this->db->query($subQuery, array($ReqNO,$MaterialCode)); + return $query->result(); +} + + + + +function updatestoremaster($updatestatus,$StoreReqNo) +{ + $this->db->where('StoreReqNo', $StoreReqNo); + $this->db->update('T_Store_Requestion_Master', $updatestatus); + + return TRUE; +} + +function getstatuscount($Status,$StoreReqNo) +{ + $this->db->select('count(Status) as SCount'); + $this->db->from('T_Store_Requestion_Details'); + + $this->db->where('Status', $Status); + $this->db->where('StoreReqNo',$StoreReqNo); + //$this->db->where('StoreReqNo', $StoreReqNo); + + $query = $this->db->get(); + //print_r($this->db->last_query()); + return $query->result(); +} + + /*this function used to get the all store requistion list view*/ function Storeall($StoreReqNo,$IsArray='') { diff --git a/application/views/approvalstorerequisitionslip.php b/application/views/approvalstorerequisitionslip.php index a2aaf720..4e1fac89 100755 --- a/application/views/approvalstorerequisitionslip.php +++ b/application/views/approvalstorerequisitionslip.php @@ -111,7 +111,9 @@ Item Code Item Description UOM - Quantity + Requested Quantity + Issued Quantity + Status Remarks diff --git a/application/views/editstorerequisition.php b/application/views/editstorerequisition.php index 3d897f8e..358b2f1b 100755 --- a/application/views/editstorerequisition.php +++ b/application/views/editstorerequisition.php @@ -306,6 +306,86 @@ $(function() { + + + + + + + + + @@ -319,6 +399,7 @@ $(function() { Description UOM Quantity + Issued Quantity Remarks Action @@ -344,14 +425,28 @@ $(function() { UOM ?> QuantityRequired ?> + + QuantityIssued ?> Remarks ?> + Status == STORE_PENDINGAPPROVAL) + {?> + + -     - - +     + + + +     + + @@ -414,6 +509,8 @@ elseif ($StatusCode==STORE_APPROVAL) <%=Quantity%> + <%=IssuedQty%> + <%=Remarks%>     @@ -552,8 +649,7 @@ $("#mypo").on("shown.bs.modal", function(e) { $('.addClick').click(function() { - - if ($("#MaterialCode option:selected").val() =='-1' || $("#MaterialCode").val() == "0" ) + if ($("#MaterialCode option:selected").val() =='-1' ) { alert('Please Select the MaterialCode '); return false; @@ -578,14 +674,14 @@ $("#mypo").on("shown.bs.modal", function(e) { var UOM =$('#UOM').val(); var Quantity =$('#Quantity').val(); var Remarks=$('#Remarks').val(); - + var IssuedQty=0; $('#MaterialCode option[value='+MaterialCode+']').remove(); index = parseInt(index)+1; var template = jQuery("#tempList").html(); - $('#mytab').append(_.template(template,{index:temp,MaterialCode:MaterialCode,MaterialName:Description,UOM:UOM,Quantity:Quantity,Remarks:Remarks})); + $('#mytab').append(_.template(template,{index:temp,MaterialCode:MaterialCode,MaterialName:Description,UOM:UOM,Quantity:Quantity,Remarks:Remarks,IssuedQty:IssuedQty})); var theForm = $(".requistion"); @@ -608,7 +704,7 @@ $("#mypo").on("shown.bs.modal", function(e) { function clear() { - + $('#MaterialCode').val(''); $('#Description').val(''); $('#UOM').val(''); $('#Quantity').val(''); @@ -654,6 +750,22 @@ $("#EditItem").on("shown.bs.modal", function(e) { }); +$("#ViewItem").on("shown.bs.modal", function(e) { + userid = $(e.relatedTarget).data('userid'); + // alert(userid); + var tr= document.getElementById(userid); + var cellval = tr.cells; + //alert(x[1].innerHTML); + $('#ViewMaterialCode').val(cellval[1].innerHTML); + $('#ViewDescription').val(cellval[2].innerHTML); + $('#ViewUOM').val(cellval[3].innerHTML); + $('#ViewQuantity').val(cellval[4].innerHTML); + $('#ViewRemarks').val(cellval[5].innerHTML); +}); + + + + $('.EditItem').click(function(){ var editMaterialCode = $("#EditMaterialCode").val(); var editDescription = $("#EditDescription").val(); @@ -668,7 +780,7 @@ $('.EditItem').click(function(){ cellval[2].innerHTML = editDescription; cellval[3].innerHTML = editUOM; cellval[4].innerHTML = editQuantity; - cellval[5].innerHTML = editRemarks; + cellval[6].innerHTML = editRemarks; $('#MaterialCode'+userid).val(editMaterialCode); $('#Description'+userid).val(editDescription); @@ -1004,4 +1116,3 @@ function validate() }); - diff --git a/application/views/issueStoreRequistion.php b/application/views/issueStoreRequistion.php index 64386947..47239b0a 100755 --- a/application/views/issueStoreRequistion.php +++ b/application/views/issueStoreRequistion.php @@ -149,8 +149,10 @@ span.highlight { UOM Requested Quantity Available Stock + Issued Qty + Pending Qty Requester Remarks - Issued Quantity + Issuing Quantity Comments @@ -175,6 +177,12 @@ span.highlight { UOM ?> QuantityRequired ?> + + QuantityRequired?>> + + + + Quantity)-($record->QuantityRequired)<=0) {?> Quantity?> @@ -185,28 +193,42 @@ span.highlight { Quantity?> + + + QuantityIssued ?> + + QuantityRequired)-($record->QuantityIssued) ?> - Remarks ?> + Remarks ?> - Quantity)-($record->QuantityRequired)>0) + Quantity)-($record->QuantityRequired)>0)&&$record->StatusName!='ISSUED') + {?> + + + - - - - + + - Quantity)-($record->QuantityRequired)>0) + Quantity)-($record->QuantityRequired)>0)&&$record->StatusName!='ISSUED') {?> - + + + + @@ -318,21 +340,21 @@ function isNumberKey(evt) var index = '1'; var userid = ''; -function SaveIssueQuantity(RowId,ReqQty) +function SaveIssueQuantity(RowId,ReqQty,Issued) { - //alert(ReqQty); + //alert(Issued); var qty = $("#issuedQuantity"+RowId).val(); - + var maxqty=ReqQty-Issued; //alert(qty); if( qty != '') { - if(qty <= ReqQty ) + if(qty <= (ReqQty-Issued) ) { $("#txtIssuedQuantity"+RowId).val(qty); } else { - alert('The Issued Quantity cannot be more than the Requested Quantity'); + alert('The Issued Quantity cannot be more than the Requested Quantity, Already Distributed Quantity is ' +Issued+ 'Maximun Qty can enter is '+maxqty); $("#issuedQuantity"+RowId).focus(); $("#issuedQuantity"+RowId).val(''); return false;