From ae1e294c7e60388e52dcddcdacbaa3a7b024e5fe Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Thu, 28 Sep 2017 14:23:45 +0530 Subject: [PATCH] budget amount issue fix --- application/controllers/requisitionform.php | 313 +++++++++++--------- application/models/purchaseorder_model.php | 2 +- 2 files changed, 169 insertions(+), 146 deletions(-) diff --git a/application/controllers/requisitionform.php b/application/controllers/requisitionform.php index 5ebf00f0..14b2b16d 100755 --- a/application/controllers/requisitionform.php +++ b/application/controllers/requisitionform.php @@ -85,44 +85,43 @@ class requisitionform extends BaseController * This function used to load the Edit Requistion Form */ function EditRequistionForm() - { - $this->global['pageTitle'] = 'Siddharth : Edit Requisition'; - - $ReqNo= $_GET['ReqNo']; - $ReqType= $_GET['ReqType']; - - $userID = $this->session->userdata ( 'userId' ); - - $data['ReqDetails'] = $this->requistion_model->getRequistDetails($ReqNo,'Yes'); - $this->load->model('purchaseorder_model'); - $POType= $this->purchaseorder_model->GetPOType($ReqNo); - $ReqPOType = ''; - if(count($POType) > 0) - { - for($i=0;$irequistion_model->getEditRequistItemList($ReqNo); - $data['CostCenter'] = $this->requistion_model->getCostCenterUserID($userID); - $data['MaterialCode'] = $this->requistion_model->EditMaterialCode($ReqNo, $ReqType); - $data['ServiceOption'] = $this->requistion_model->getConfigValue('C022'); - $this->loadViews("editrequisitionform", $this->global, $data, NULL); - } - + { + $this->global['pageTitle'] = 'Siddharth : Edit Requisition'; + + $ReqNo= $_GET['ReqNo']; + $ReqType= $_GET['ReqType']; + + $userID = $this->session->userdata ( 'userId' ); + + $data['ReqDetails'] = $this->requistion_model->getRequistDetails($ReqNo,'Yes'); + $this->load->model('purchaseorder_model'); + $POType= $this->purchaseorder_model->GetPOType($ReqNo); + $ReqPOType = ''; + if(count($POType) > 0) + { + for($i=0;$irequistion_model->getEditRequistItemList($ReqNo); + $data['CostCenter'] = $this->requistion_model->getCostCenterUserID($userID); + $data['MaterialCode'] = $this->requistion_model->EditMaterialCode($ReqNo, $ReqType); + $data['ServiceOption'] = $this->requistion_model->getConfigValue('C022'); + $this->loadViews("editrequisitionform", $this->global, $data, NULL); + } /** * This function used to load the Delete the Requistion Items */ @@ -509,114 +508,138 @@ class requisitionform extends BaseController } /* To Edit the request*/ function ViewRequest() - { - - $ReqNo= $this->input->post('id'); - $result = $this->requistion_model->getRequistItemList($ReqNo); - $ReqList = $this->requistion_model->getRequistDetails($ReqNo); - $DepNo = $ReqList[0]['DEPCode']; - //$CostList = $this->requistion_model->GetCostCenterByDept($DepNo); - $HTML=""; - for ($i = 0; $i < count($result); $i++) - { - $SNo = $i + 1; - $MaterialCode = $result[$i]['MaterialCode']; - $MaterialName = $result[$i]['MaterialName']; - $UOM = $result[$i]['UOM']; - $Quantity = $result[$i]['Quantity']; - $Quantity = $result[$i]['Quantity']; - $POQTY = $result[$i]['POQTY']; - $StatusName= $result[$i]['StatusName']; - $HTML.=" - ".$SNo." - ". $MaterialCode." - - ".$MaterialName." - - ".$UOM." - ".$Quantity." - ".$POQTY." - ".$StatusName." - "; + { + + $ReqNo= $this->input->post('id'); + $result = $this->requistion_model->getRequistItemList($ReqNo); + $ReqList = $this->requistion_model->getRequistDetails($ReqNo); + $DepNo = $ReqList[0]['DEPCode']; + //$CostList = $this->requistion_model->GetCostCenterByDept($DepNo); + $HTML=""; + for ($i = 0; $i < count($result); $i++) + { + $SNo = $i + 1; + $MaterialCode = $result[$i]['MaterialCode']; + $MaterialName = $result[$i]['MaterialName']; + $UOM = $result[$i]['UOM']; + $Quantity = $result[$i]['Quantity']; + $Quantity = $result[$i]['Quantity']; + $POQTY = $result[$i]['POQTY']; + $StatusName= $result[$i]['StatusName']; + $HTML.=" + ".$SNo." + ". $MaterialCode." + + ".$MaterialName." + + ".$UOM." + ".$Quantity." + ".$POQTY." + ".$StatusName." + "; - //$index = $index + 1; - - } - $CostCode = ''; - $ReqType = ''; - $FYStart = ''; - $FYEnd = ''; - $this->load->model('costcenter_model'); - $FiscalYear = $this->costcenter_model->getFiscalYear(); - if(!empty($FiscalYear)) - { - foreach ($FiscalYear as $Fy) - { - $FYStart =$Fy->StartYear; - $FYEnd =$Fy->EndYear; - } - - } - - $FYdt = $FYStart." - ".$FYEnd ; - $this->load->model('purchaseorder_model'); - if(count($ReqList)>0) - { - - $ReqType = $ReqList[0]['ReqType']; - - $CostCode = $ReqList[0]['CostCenterCode']; - } - - $POType= $this->purchaseorder_model->GetPOType($ReqNo); - - $ReqPOType = ''; - if(count($POType) > 0) - { - for($i=0;$ipurchaseorder_model->GetAvailableCapitalBudgetAmount($CostCode,$FYdt,$RequestType); - } - else if($ReqType== IMPORT) - { - $AvlBudget = $this->purchaseorder_model->GetAvailableImportBudgetAmount($CostCode,$FYdt,$RequestType); - } - else - { - $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$FYdt,$RequestType); - } - - - // $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$FYdt,$ReqType); - //print_r($result); - $AvilBudAmt = '0'; - if(count($AvlBudget)>0) - { - $AvilBudAmt = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; - } - //echo $AvilBudAmt; - die(json_encode(array('Items' =>$HTML,'Requist'=>$ReqList,'AvilBudAmount'=>number_format($AvilBudAmt,2)))); - } + //$index = $index + 1; + + } + $CostCode = ''; + $ReqType = ''; + $FYStart = ''; + $FYEnd = ''; + $this->load->model('costcenter_model'); + $FiscalYear = $this->costcenter_model->getFiscalYear(); + if(!empty($FiscalYear)) + { + foreach ($FiscalYear as $Fy) + { + $FYStart =$Fy->StartYear; + $FYEnd =$Fy->EndYear; + } + + } + + $FYdt = $FYStart." - ".$FYEnd ; + $this->load->model('purchaseorder_model'); + if(count($ReqList)>0) + { + + $ReqType = $ReqList[0]['ReqType']; + + $CostCode = $ReqList[0]['CostCenterCode']; + } + + $POType= $this->purchaseorder_model->GetPOType($ReqNo); + + $ReqPOType = ''; + if(count($POType) > 0) + { + + for($i=0;$ipurchaseorder_model->GetAvailableCapitalBudgetAmount($CostCode,$FYdt,$ReqType); + + + // } + + + if($ReqType== CAPITAL&&$RequestType!=IMPORT ) + { + $AvlBudget = $this->purchaseorder_model->GetAvailableCapitalBudgetAmount($CostCode,$FYdt,$RequestType); + + + } + + + // else if($ReqType== CAPITAL&&$RequestType==IMPORT) + // { + + // $AvlBudget = $this->purchaseorder_model->GetAvailableImportBudgetAmount($CostCode,$FYdt,$RequestType); + // } + + + // else if($ReqType== IMPORT) + // { + // $AvlBudget = $this->purchaseorder_model->GetAvailableImportBudgetAmount($CostCode,$FYdt,$RequestType); + // } + else + + { + $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$FYdt,$ReqType); + } + + + // $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$FYdt,$ReqType); + //print_r($result); + $AvilBudAmt = '0'; + if(count($AvlBudget)>0) + { + $AvilBudAmt = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; + } + //echo $AvilBudAmt; + die(json_encode(array('Items' =>$HTML,'Requist'=>$ReqList,'AvilBudAmount'=>number_format($AvilBudAmt,2)))); + } function ApproveRequest() { diff --git a/application/models/purchaseorder_model.php b/application/models/purchaseorder_model.php index 366023e7..d5ca4c5a 100755 --- a/application/models/purchaseorder_model.php +++ b/application/models/purchaseorder_model.php @@ -248,7 +248,7 @@ function purchaseorderListing($forwhat='') $subQuery ='select BudgetAmount, (select ifnull(sum(IF(POMaster.ExchangeRate>0,Quantity*Rate*POMaster.ExchangeRate,Quantity*Rate-tax.Afterdiscountval)),0) as Totalvalue from T_PurchaseOrder_LineItem Item join T_Requestion_Master mast - on mast.ReqNo = Item.ReqNo join T_PurchaseOrder_Master POMaster on POMaster.PONO=Item.PONO left join T_Service_Tax tax on tax.LineItemNo=Item.LineItemNo where Item.CostCenterCode=? and mast.ReqType=? and POMaster.status not in (?))as Totalvalue + on mast.ReqNo = Item.ReqNo join T_PurchaseOrder_Master POMaster on POMaster.PONO=Item.PONO left join T_Service_Tax tax on tax.LineItemNo=Item.LineItemNo where Item.CostCenterCode=? and POMaster.POType=? and POMaster.status not in (?))as Totalvalue from T_CostCenter_Budget Bud where Bud.CostCenterCode=? and BudgetYear = ? and BudgetType =?';