From 368e53d43f1541d86a5f1e3f00b74a10d64bf175 Mon Sep 17 00:00:00 2001 From: gandhimathi Bharathirajan Date: Mon, 21 Aug 2017 11:31:06 +0530 Subject: [PATCH] Available Budget amount for Capital PO issue fixed --- application/models/purchaseorder_model.php | 60 +++++++++++----------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/application/models/purchaseorder_model.php b/application/models/purchaseorder_model.php index 700803b0..e13aaa57 100755 --- a/application/models/purchaseorder_model.php +++ b/application/models/purchaseorder_model.php @@ -230,6 +230,33 @@ function purchaseorderListing($forwhat='') } + //Import PO Available Budget Amount + function GetAvailableImportBudgetAmount($CostCode,$Year,$BudgetType) + { + $subQuery='select BudgetAmount,(select ifnull(sum((Quantity*Rate*ExchangeRate)),0)as TValue from T_PurchaseOrder_LineItem LineItem + join T_PurchaseOrder_Master Mast on Mast.PONO=LineItem.PONO where POType=? + and CostCenterCode=? and Mast.status not in (?) )as TotalValue from T_CostCenter_Budget Bud where Bud.CostCenterCode=? and BudgetYear=? and BudgetType=?'; + $query = $this->db->query($subQuery,array($BudgetType,$CostCode,PO_AMENDED,$CostCode,$Year,$BudgetType)); + //print_r($this->db->last_query()); + return $query->result_array(); + + + } + //get available budget for capital + function GetAvailableCapitalBudgetAmount($CostCode,$Year,$BudgetType) + { + + $subQuery ='select BudgetAmount, (select ifnull(sum(IF(POMaster.ExchangeRate>0,Quantity*Rate*POMaster.ExchangeRate,Quantity*Rate)),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 where Item.CostCenterCode=? and mast.ReqType=? and POMaster.status not in (?))as Totalvalue + from T_CostCenter_Budget Bud where Bud.CostCenterCode=? and + BudgetYear = ? and BudgetType =?'; + + $query = $this->db->query($subQuery,array($CostCode,$BudgetType,PO_AMENDED,$CostCode,$Year,$BudgetType)); + + return $query->result_array(); + + } function GetAvailableBudgetAmount($CostCode,$Year,$BudgetType) { $subQuery ='select distinct Bud.CostCenterCode,BudgetAmount, case WHEN BudgetType = ? then (select @@ -254,22 +281,7 @@ function purchaseorderListing($forwhat='') //print_r($this->db->last_query()); return $query->result_array(); - } - - - function GetAvailableImportBudgetAmount($CostCode,$Year,$BudgetType) - { - $subQuery='select BudgetAmount,(select ifnull(sum((Quantity*Rate*ExchangeRate)),0)as TValue from T_PurchaseOrder_LineItem LineItem - join T_PurchaseOrder_Master Mast on Mast.PONO=LineItem.PONO where POType=? - and CostCenterCode=?)as TotalValue from T_CostCenter_Budget Bud where Bud.CostCenterCode=? and BudgetYear=? and BudgetType=?'; - $query = $this->db->query($subQuery,array($BudgetType,$CostCode,$CostCode,$Year,$BudgetType)); - //print_r($this->db->last_query()); - return $query->result_array(); - - - } - - + } /** * This function is used to get the Requsition List for the login user @@ -1472,21 +1484,7 @@ join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode return $query->result(); } - //get available budget for capital - function GetAvailableCapitalBudgetAmount($CostCode,$Year,$BudgetType) - { - - $subQuery ='select BudgetAmount, (select ifnull(sum(IF(POMaster.ExchangeRate>0,Quantity*Rate*POMaster.ExchangeRate,Quantity*Rate)),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 where Item.CostCenterCode=? and mast.ReqType=?)as Totalvalue - from T_CostCenter_Budget Bud where Bud.CostCenterCode=? and - BudgetYear = ? and BudgetType =?'; - - $query = $this->db->query($subQuery,array($CostCode,$BudgetType,$CostCode,$Year,$BudgetType)); - - return $query->result_array(); - - } + // update req deatail if work status is completed function updateReqDetail($PONO,$POStatus)