budget amount issue fix

This commit is contained in:
venbatechnologies@gmail.com 2017-09-28 14:23:45 +05:30
parent 0293bf3e03
commit ae1e294c7e
2 changed files with 169 additions and 146 deletions

View File

@ -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;$i<count($POType);$i++)
{
if($POType[$i]['POType'] == $ReqType)
{
$ReqPOType = '';
break;
}
else
{
$ReqPOType = $POType[$i]['POType'];
}
}
}
//print_r($POType);
// echo 'ReqType'.$ReqPOType;
$data['ReqPOType'] = $ReqPOType =='' ? $ReqType:$ReqPOType;
$data['LineItem'] = $this->requistion_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;$i<count($POType);$i++)
{
if($POType[$i]['POType'] == $ReqType)
{
$ReqPOType = '';
break;
}
else
{
$ReqPOType = $POType[$i]['POType'];
}
}
}
//print_r($POType);
// echo 'ReqType'.$ReqPOType;
$data['ReqPOType'] = $ReqPOType =='' ? $ReqType:$ReqPOType;
$data['LineItem'] = $this->requistion_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.="<tr id='".$i."'>
<td align='left'>".$SNo."</td>
<td align='left'>". $MaterialCode."</td>
<td align='left'>".$MaterialName."</td>
<td align='left'>".$UOM."</td>
<td align='left'>".$Quantity."</td>
<td align='left'>".$POQTY."</td>
<td align='left'>".$StatusName."</td>
</tr>";
{
$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.="<tr id='".$i."'>
<td align='left'>".$SNo."</td>
<td align='left'>". $MaterialCode."</td>
<td align='left'>".$MaterialName."</td>
<td align='left'>".$UOM."</td>
<td align='left'>".$Quantity."</td>
<td align='left'>".$POQTY."</td>
<td align='left'>".$StatusName."</td>
</tr>";
//$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;$i<count($POType);$i++)
{
if($POType[$i]['POType'] == $ReqType)
{
$ReqPOType = '';
break;
}
else
{
$ReqPOType = $POType[$i]['POType'];
}
}
}
$RequestType='';
$RequestType= $ReqPOType =='' ? $ReqType:$ReqPOType;
$AvlBudget = array();
if($ReqType== CAPITAL)
{
$AvlBudget = $this->purchaseorder_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;$i<count($POType);$i++)
{
if($POType[$i]['POType'] == $ReqType)
{
$ReqPOType = '';
break;
}
else
{
$ReqPOType = $POType[$i]['POType'];
}
}
}
$RequestType='';
$RequestType= $ReqPOType =='' ? $ReqType:$ReqPOType;
$AvlBudget = array();
// if($ReqType== CAPITAL&&$RequestType!=IMPORT )
// {
// $AvlBudget = $this->purchaseorder_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()
{

View File

@ -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 =?';