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 * This function used to load the Edit Requistion Form
*/ */
function EditRequistionForm() function EditRequistionForm()
{ {
$this->global['pageTitle'] = 'Siddharth : Edit Requisition'; $this->global['pageTitle'] = 'Siddharth : Edit Requisition';
$ReqNo= $_GET['ReqNo']; $ReqNo= $_GET['ReqNo'];
$ReqType= $_GET['ReqType']; $ReqType= $_GET['ReqType'];
$userID = $this->session->userdata ( 'userId' ); $userID = $this->session->userdata ( 'userId' );
$data['ReqDetails'] = $this->requistion_model->getRequistDetails($ReqNo,'Yes'); $data['ReqDetails'] = $this->requistion_model->getRequistDetails($ReqNo,'Yes');
$this->load->model('purchaseorder_model'); $this->load->model('purchaseorder_model');
$POType= $this->purchaseorder_model->GetPOType($ReqNo); $POType= $this->purchaseorder_model->GetPOType($ReqNo);
$ReqPOType = ''; $ReqPOType = '';
if(count($POType) > 0) if(count($POType) > 0)
{ {
for($i=0;$i<count($POType);$i++) for($i=0;$i<count($POType);$i++)
{ {
if($POType[$i]['POType'] == $ReqType) if($POType[$i]['POType'] == $ReqType)
{ {
$ReqPOType = ''; $ReqPOType = '';
break; break;
} }
else else
{ {
$ReqPOType = $POType[$i]['POType']; $ReqPOType = $POType[$i]['POType'];
} }
} }
} }
//print_r($POType); //print_r($POType);
// echo 'ReqType'.$ReqPOType; // echo 'ReqType'.$ReqPOType;
$data['ReqPOType'] = $ReqPOType =='' ? $ReqType:$ReqPOType; $data['ReqPOType'] = $ReqPOType =='' ? $ReqType:$ReqPOType;
$data['LineItem'] = $this->requistion_model->getEditRequistItemList($ReqNo); $data['LineItem'] = $this->requistion_model->getEditRequistItemList($ReqNo);
$data['CostCenter'] = $this->requistion_model->getCostCenterUserID($userID); $data['CostCenter'] = $this->requistion_model->getCostCenterUserID($userID);
$data['MaterialCode'] = $this->requistion_model->EditMaterialCode($ReqNo, $ReqType); $data['MaterialCode'] = $this->requistion_model->EditMaterialCode($ReqNo, $ReqType);
$data['ServiceOption'] = $this->requistion_model->getConfigValue('C022'); $data['ServiceOption'] = $this->requistion_model->getConfigValue('C022');
$this->loadViews("editrequisitionform", $this->global, $data, NULL); $this->loadViews("editrequisitionform", $this->global, $data, NULL);
} }
/** /**
* This function used to load the Delete the Requistion Items * This function used to load the Delete the Requistion Items
*/ */
@ -509,114 +508,138 @@ class requisitionform extends BaseController
} }
/* To Edit the request*/ /* To Edit the request*/
function ViewRequest() function ViewRequest()
{ {
$ReqNo= $this->input->post('id'); $ReqNo= $this->input->post('id');
$result = $this->requistion_model->getRequistItemList($ReqNo); $result = $this->requistion_model->getRequistItemList($ReqNo);
$ReqList = $this->requistion_model->getRequistDetails($ReqNo); $ReqList = $this->requistion_model->getRequistDetails($ReqNo);
$DepNo = $ReqList[0]['DEPCode']; $DepNo = $ReqList[0]['DEPCode'];
//$CostList = $this->requistion_model->GetCostCenterByDept($DepNo); //$CostList = $this->requistion_model->GetCostCenterByDept($DepNo);
$HTML=""; $HTML="";
for ($i = 0; $i < count($result); $i++) for ($i = 0; $i < count($result); $i++)
{ {
$SNo = $i + 1; $SNo = $i + 1;
$MaterialCode = $result[$i]['MaterialCode']; $MaterialCode = $result[$i]['MaterialCode'];
$MaterialName = $result[$i]['MaterialName']; $MaterialName = $result[$i]['MaterialName'];
$UOM = $result[$i]['UOM']; $UOM = $result[$i]['UOM'];
$Quantity = $result[$i]['Quantity']; $Quantity = $result[$i]['Quantity'];
$Quantity = $result[$i]['Quantity']; $Quantity = $result[$i]['Quantity'];
$POQTY = $result[$i]['POQTY']; $POQTY = $result[$i]['POQTY'];
$StatusName= $result[$i]['StatusName']; $StatusName= $result[$i]['StatusName'];
$HTML.="<tr id='".$i."'> $HTML.="<tr id='".$i."'>
<td align='left'>".$SNo."</td> <td align='left'>".$SNo."</td>
<td align='left'>". $MaterialCode."</td> <td align='left'>". $MaterialCode."</td>
<td align='left'>".$MaterialName."</td> <td align='left'>".$MaterialName."</td>
<td align='left'>".$UOM."</td> <td align='left'>".$UOM."</td>
<td align='left'>".$Quantity."</td> <td align='left'>".$Quantity."</td>
<td align='left'>".$POQTY."</td> <td align='left'>".$POQTY."</td>
<td align='left'>".$StatusName."</td> <td align='left'>".$StatusName."</td>
</tr>"; </tr>";
//$index = $index + 1; //$index = $index + 1;
} }
$CostCode = ''; $CostCode = '';
$ReqType = ''; $ReqType = '';
$FYStart = ''; $FYStart = '';
$FYEnd = ''; $FYEnd = '';
$this->load->model('costcenter_model'); $this->load->model('costcenter_model');
$FiscalYear = $this->costcenter_model->getFiscalYear(); $FiscalYear = $this->costcenter_model->getFiscalYear();
if(!empty($FiscalYear)) if(!empty($FiscalYear))
{ {
foreach ($FiscalYear as $Fy) foreach ($FiscalYear as $Fy)
{ {
$FYStart =$Fy->StartYear; $FYStart =$Fy->StartYear;
$FYEnd =$Fy->EndYear; $FYEnd =$Fy->EndYear;
} }
} }
$FYdt = $FYStart." - ".$FYEnd ; $FYdt = $FYStart." - ".$FYEnd ;
$this->load->model('purchaseorder_model'); $this->load->model('purchaseorder_model');
if(count($ReqList)>0) if(count($ReqList)>0)
{ {
$ReqType = $ReqList[0]['ReqType']; $ReqType = $ReqList[0]['ReqType'];
$CostCode = $ReqList[0]['CostCenterCode']; $CostCode = $ReqList[0]['CostCenterCode'];
} }
$POType= $this->purchaseorder_model->GetPOType($ReqNo); $POType= $this->purchaseorder_model->GetPOType($ReqNo);
$ReqPOType = ''; $ReqPOType = '';
if(count($POType) > 0) if(count($POType) > 0)
{ {
for($i=0;$i<count($POType);$i++)
{ for($i=0;$i<count($POType);$i++)
if($POType[$i]['POType'] == $ReqType) {
{ if($POType[$i]['POType'] == $ReqType)
$ReqPOType = ''; {
break; $ReqPOType = '';
} break;
else }
{ else
$ReqPOType = $POType[$i]['POType']; {
} $ReqPOType = $POType[$i]['POType'];
} }
}
}
$RequestType=''; }
$RequestType= $ReqPOType =='' ? $ReqType:$ReqPOType;
$RequestType='';
$AvlBudget = array(); $RequestType= $ReqPOType =='' ? $ReqType:$ReqPOType;
if($ReqType== CAPITAL)
{
$AvlBudget = $this->purchaseorder_model->GetAvailableCapitalBudgetAmount($CostCode,$FYdt,$RequestType); $AvlBudget = array();
}
else if($ReqType== IMPORT) // if($ReqType== CAPITAL&&$RequestType!=IMPORT )
{ // {
$AvlBudget = $this->purchaseorder_model->GetAvailableImportBudgetAmount($CostCode,$FYdt,$RequestType); // $AvlBudget = $this->purchaseorder_model->GetAvailableCapitalBudgetAmount($CostCode,$FYdt,$ReqType);
}
else
{ // }
$AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$FYdt,$RequestType);
}
if($ReqType== CAPITAL&&$RequestType!=IMPORT )
{
// $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$FYdt,$ReqType); $AvlBudget = $this->purchaseorder_model->GetAvailableCapitalBudgetAmount($CostCode,$FYdt,$RequestType);
//print_r($result);
$AvilBudAmt = '0';
if(count($AvlBudget)>0) }
{
$AvilBudAmt = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue'];
} // else if($ReqType== CAPITAL&&$RequestType==IMPORT)
//echo $AvilBudAmt; // {
die(json_encode(array('Items' =>$HTML,'Requist'=>$ReqList,'AvilBudAmount'=>number_format($AvilBudAmt,2))));
} // $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() 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 $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 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 from T_CostCenter_Budget Bud where Bud.CostCenterCode=? and
BudgetYear = ? and BudgetType =?'; BudgetYear = ? and BudgetType =?';