581 lines
19 KiB
PHP
Executable File
581 lines
19 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Controllers\BaseController;
|
|
|
|
use CodeIgniter\Validation\Exceptions\ValidationException;
|
|
|
|
use App\Models\Costcenter_model;
|
|
use App\Models\Purchaseorder_model;
|
|
use App\Models\Requistion_model;
|
|
|
|
/**
|
|
* Module : requisition
|
|
* Requisitionform Class to control all Requisition related operations.
|
|
* @author : Venba
|
|
* @version : 1.1
|
|
* @since : 15 Feb 2016
|
|
* @example : Revised at 15th april 2024
|
|
*/
|
|
class Requisitionform extends BaseController
|
|
{
|
|
protected $requistion_model;
|
|
protected $costcenter_model;
|
|
protected $purchaseorder_model;
|
|
protected $session;
|
|
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->requistion_model = new Requistion_model();
|
|
$this->costcenter_model = new Costcenter_model();
|
|
$this->purchaseorder_model = new Purchaseorder_model();
|
|
|
|
$this->session = session();
|
|
helper('form'); //$this->load->library('form_validation');
|
|
|
|
$this->isLoggedIn();
|
|
}
|
|
/**
|
|
* This function used to load the first screen of the Requistion
|
|
*/
|
|
function requisitionlisting()
|
|
{
|
|
$this->global['pageTitle'] = 'Requisition Listing';
|
|
|
|
$userID = $this->session->get('userId');
|
|
|
|
// $data['ReqList'] = $this->requistion_model->getRequistListUserID($userID);
|
|
$data['Status'] = $this->requistion_model->CheckDraftStatus($userID);
|
|
|
|
$data['TotNoOfLine'] = $this->requistion_model->getRequistionList($userID);
|
|
|
|
|
|
|
|
$this->loadViews("requisitionlisting", $this->global, $data, NULL);
|
|
}
|
|
/**
|
|
* This function used to load the first screen of the requisition Form
|
|
*/
|
|
|
|
function requisition()
|
|
{
|
|
$this->global['pageTitle'] = 'Raise Requisition';
|
|
|
|
$data['RequestType'] = $this->requistion_model->getConfigValue('C020');
|
|
|
|
$data['EmpList'] = $this->requistion_model->getAllEmployees();
|
|
$data['ServiceOption'] = $this->requistion_model->getConfigValue('C022');
|
|
$userID = $this->session->get('userId');
|
|
|
|
$data['Emp'] = $this->requistion_model->getEmpIdByUserID($userID);
|
|
|
|
$data['CostCenter'] = $this->requistion_model->getCostCenterUserID($userID);
|
|
$data['RequestBy'] = $this->requistion_model->getRequestBy();
|
|
|
|
$this->loadViews("requisitionform", $this->global, $data, null);
|
|
}
|
|
|
|
/**
|
|
* This function used to load the first screen of the Requistion List Approval Screen
|
|
*/
|
|
function requisitionlistApproval()
|
|
{
|
|
$this->global['pageTitle'] = 'Requisition Approval';
|
|
|
|
$data['Status'] = $this->requistion_model->getStatus();
|
|
|
|
$userID = $this->session->get('userId');
|
|
|
|
$data['AppList'] = $this->requistion_model->getApproverRequistList($userID);
|
|
|
|
|
|
|
|
$this->loadViews("requisitionlistapproval", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
/**
|
|
* This function used to load the Edit Requistion Form
|
|
*/
|
|
function EditRequisitionForm()
|
|
{
|
|
$this->global['pageTitle'] = 'Edit Requisition';
|
|
|
|
$ReqNo = $_GET['ReqNo'];
|
|
$ReqType = $_GET['ReqType'];
|
|
|
|
$userID = $this->session->get('userId');
|
|
|
|
$data['ReqDetails'] = $this->requistion_model->getRequistDetails($ReqNo, 'Yes');
|
|
//print_r($data['ReqDetails']);
|
|
|
|
$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['description'] = '';
|
|
$data['CostCenter'] = $this->requistion_model->getCostCenterUserID($userID);
|
|
// $data['MaterialCode'] = $this->requistion_model->EditMaterialCode($ReqNo, $ReqType); // Old Based on Type..
|
|
$data['MaterialCode'] = $this->requistion_model->EditMaterialCode($ReqNo);
|
|
$data['ServiceOption'] = $this->requistion_model->getConfigValue('C022');
|
|
$this->loadViews("editrequisitionform", $this->global, $data, NULL);
|
|
}
|
|
/**
|
|
* This function used to load the Delete the Requistion Items
|
|
*/
|
|
function DeleteRequistionForm()
|
|
{
|
|
|
|
$ReqList = $this->request->getPost('id');
|
|
$ReqNo = '';
|
|
$MaterialCode = '';
|
|
if (count($ReqList) > 0) {
|
|
$ReqNo = $ReqList[0];
|
|
$MaterialCode = $ReqList[1];
|
|
}
|
|
|
|
$this->requistion_model->DeleteRequistionLineItem($ReqNo, $MaterialCode);
|
|
return $this->response->setJSON("Successfully Deleted the Line item " . $ReqNo);
|
|
}
|
|
|
|
/**
|
|
* This function used to load the Delete the Requistion Items
|
|
*/
|
|
function DeleteReqNo()
|
|
{
|
|
|
|
$ReqNo = $this->request->getPost('id');
|
|
|
|
$updateddt = get_current_date_time();
|
|
$Request = array('Status' => REQ_DELETED, 'updatedOn' => $updateddt);
|
|
|
|
$this->requistion_model->UpdateRequistion($Request, $ReqNo);
|
|
return $this->response->setJSON(['message' => "Successfully Deleted the " . $ReqNo]);
|
|
|
|
}
|
|
|
|
function SearchRequistList()
|
|
{
|
|
$userID = $this->session->get('userId');
|
|
$ReqValue = $this->request->getPost('SearchDate');
|
|
$Dt = (is_string($ReqValue)) ? explode("-", $ReqValue) : [];
|
|
$FromDate = '';
|
|
$ToDate = '';
|
|
$Status = '';
|
|
|
|
if (count($Dt) > 1) {
|
|
$FDate = $Dt[0] . "-" . $Dt[1] . "-" . $Dt[2];
|
|
$TDate = $Dt[3] . "-" . $Dt[4] . "-" . $Dt[5];
|
|
$FromDate = get_date_time_format($FDate);
|
|
$ToDate = get_date_time_format($TDate);
|
|
}
|
|
|
|
$St = $this->request->getPost('RequisitionStatus');
|
|
|
|
if ($St == "-1") {
|
|
$Status = '';
|
|
} else {
|
|
$Status = $St;
|
|
}
|
|
|
|
$data['AppList'] = $this->requistion_model->getApproverRequistList($userID, $Status, $FromDate, $ToDate);
|
|
|
|
$this->global['pageTitle'] = 'Requisition Approval';
|
|
|
|
$data['Status'] = $this->requistion_model->getStatus();
|
|
|
|
$this->loadViews("requisitionlistapproval", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
function getAvailableBudAmount()
|
|
{
|
|
$ReqType = $_GET['ReqType'];
|
|
$CostCode = $this->request->getPost('id');
|
|
$FYStart = '';
|
|
$FYEnd = '';
|
|
$FiscalYear = $this->costcenter_model->getFiscalYear();
|
|
if (!empty($FiscalYear)) {
|
|
foreach ($FiscalYear as $Fy) {
|
|
$FYStart = $Fy->StartYear;
|
|
$FYEnd = $Fy->EndYear;
|
|
}
|
|
}
|
|
|
|
$FYdt = $FYStart . " - " . $FYEnd;
|
|
$this->purchaseorder_model = new purchaseorder_model();
|
|
|
|
$Cost = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode, $FYdt, $ReqType);
|
|
|
|
|
|
//$Cost = $this->requistion_model->GetAvailableBudgetAmount( $CostCode,$Year,$ReqType);
|
|
|
|
die(json_encode(array('Cost' => $Cost)));
|
|
}
|
|
// To get the Material code based on the Request type
|
|
function getMaterialCode()
|
|
{
|
|
|
|
$ReqType = $this->request->getPost('id');
|
|
$CatType = $this->request->getPost('cid');
|
|
|
|
$MaterialCode = $this->requistion_model->GetMaterialCode($ReqType);
|
|
$MaterialName = "";
|
|
$UOM = "";
|
|
$HTML = "<option value='-1'>Select Material Type</option>";
|
|
|
|
if (count($MaterialCode) > 0) {
|
|
for ($j = 0; $j < count($MaterialCode); $j++) {
|
|
$Code = $MaterialCode[$j]['MaterialCode'];
|
|
$Name = $MaterialCode[$j]['MaterialName'];
|
|
$HSN = $MaterialCode[$j]['HSNCODE'] ? $MaterialCode[$j]['HSNCODE']." - " : "";
|
|
// $HTML .= "<option value='" . $Code . "'>" . $HSN . "-" . $Name . "</option>";
|
|
$HTML .= "<option value='" . $Code . "'>" . $HSN . $Name . " ( ".$Code." ) "."</option>";
|
|
}
|
|
$MaterialName = $MaterialCode[0]['MaterialName'];
|
|
$UOM = $MaterialCode[0]['UOM'];
|
|
}
|
|
|
|
$response = ['Material' => $HTML, 'MaterialName' => $MaterialName, 'UOM' => $UOM];
|
|
return $this->response->setJSON($response);
|
|
}
|
|
|
|
// To get the Material value based on the MaterialCode
|
|
function getMaterialDetails()
|
|
{
|
|
|
|
$Material = $this->request->getPost('id');
|
|
|
|
$MaterialDetails = $this->requistion_model->getRawMaterialList($Material);
|
|
|
|
return $this->response->setJSON(['MatDetail' => $MaterialDetails]);
|
|
}
|
|
|
|
|
|
function getCategoryDetails()
|
|
{
|
|
|
|
$CategoryDetails = $this->requistion_model->getmaterialCategory();
|
|
$HTML = "<option value='-1'>Select Category</option>";
|
|
|
|
if (count($CategoryDetails) > 0) {
|
|
for ($j = 0; $j < count($CategoryDetails); $j++) {
|
|
$Code = $CategoryDetails[$j]['Key'];
|
|
$Name = $CategoryDetails[$j]['ConfigValue'];
|
|
|
|
$HTML .= "<option value='" . $Code . "'>" . $Name . "</option>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$response = ['Category' => $HTML];
|
|
return $this->response->setJSON($response);
|
|
}
|
|
|
|
/**
|
|
* To Insert the Requistion Details to Database
|
|
*/
|
|
function addNewRequisition()
|
|
{
|
|
// print_r($this->request->getPost());die();
|
|
|
|
log_message('error', " add new Requisition Fns Called");
|
|
|
|
// $this->validator->setRules(['RequestType'=> 'trim|required',
|
|
// 'EmpID'=> 'trim|required']);
|
|
|
|
// if ($this->validator->run() == FALSE) {
|
|
// $this->requisition();
|
|
// } else {}
|
|
|
|
$Status = $this->request->getPost('ID');
|
|
$RequestType = $this->request->getPost('RequestType');
|
|
$RequestType = (is_string($RequestType)) ? strtoupper(trim($RequestType)) : null;
|
|
$Requestedby = $this->request->getPost('EmpID');
|
|
$Requestedby = (is_string($Requestedby)) ? strtoupper(trim($Requestedby)) : null;
|
|
log_message('error', " add new Requisition empid " . $Requestedby);
|
|
$RequestedbyDept = $this->session->get('DEPCode');
|
|
$CostCenter = $this->request->getPost('CostCenter');
|
|
$CreateBy = $this->session->get('userId');
|
|
$UpdatedBy = $this->session->get('userId');
|
|
$createddt = get_current_date_time();
|
|
$RowCount = $this->request->getPost('txtRowCount');
|
|
$DeletedRow = $this->request->getPost('txtDeletedRow');
|
|
$comma_separated = ($DeletedRow !== null && is_string($DeletedRow))
|
|
? explode(':', $DeletedRow)
|
|
: [];
|
|
$serviceSchedule = $this->request->getPost('serviceSchedule');
|
|
$servicePeriod = $this->request->getPost('serviceSchedule');
|
|
// $noOfService = $this->request->getPost('noOfService');
|
|
$noOfService = 1;
|
|
// $IsExists = $this->requistion_model->RequistionIsExists($Requestedby);
|
|
|
|
|
|
$Request = array('ReqType' => $RequestType, 'Requestedby' => $Requestedby, 'ReqDate' => $createddt, 'CostCenterCode' => $CostCenter, 'Status' => $Status, 'CreatedDate' => $createddt, 'CreatedBy' => $CreateBy, 'Schedule_Type' => $serviceSchedule, 'NumberOfService' => $noOfService, 'Service_Period' => $servicePeriod, 'RequestedDept' => $RequestedbyDept);
|
|
|
|
if ($Status == REQ_APPROVED) {
|
|
$Request['Comments'] = "Default Approved";
|
|
$Request['Approvedby'] = $this->session->get('userId');
|
|
$Request['ApprovedOn'] = get_current_date_time();
|
|
}
|
|
|
|
$Req = $this->requistion_model->addRequisition($Request);
|
|
|
|
|
|
$ReqNumber = $Req[0]['ReqNo'];
|
|
|
|
$SkipInsert = "false";
|
|
for ($i = 1; $i <= $RowCount; $i++) {
|
|
$SkipInsert = "false";
|
|
if (count($comma_separated) > 0) {
|
|
for ($j = 1; $j < count($comma_separated); $j++) {
|
|
$deletedRow = $comma_separated[$j];
|
|
if ($deletedRow == $i) {
|
|
$SkipInsert = "true";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($SkipInsert == "false") {
|
|
$MaterialCode = $this->request->getPost('MaterialCode' . $i);
|
|
$Quantity = $this->request->getPost('Quantity' . $i);
|
|
$OtherD = $this->request->getPost('otherD' . $i);
|
|
|
|
$ReqDetails = array('ReqNo' => $ReqNumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'MaterialDescription' => $OtherD, 'UpdatedBy' => $UpdatedBy);
|
|
$this->requistion_model->addRequistionDetails($ReqDetails, $ReqNumber);
|
|
}
|
|
}
|
|
|
|
if ($Status == REQ_DRAFT) {
|
|
$display_message = "Successfully Saved the Requisition details in Draft!\nRequistion Number Is: ". $ReqNumber;
|
|
// $display_message = "Requistion Saved as Draft!\nRequistion Number Is: ". $ReqNumber;
|
|
}else if($Status == REQ_APPROVED) {
|
|
$display_message = "Successfully Updated the Requistion details as Approved!\nRequistion Number Is: ". $ReqNumber;
|
|
// $display_message = "Requistion Created Successfully!\nRequistion Number Is: ". $ReqNumber;
|
|
}else{
|
|
$display_message = "Successfully Created the Requistion details!\nRequistion Number Is: ". $ReqNumber;
|
|
}
|
|
|
|
return $this->response->setJSON([$display_message]);
|
|
// return redirect()->route('supplierlisting')->with('success', $display_message);
|
|
|
|
|
|
}
|
|
function EditRequisition()
|
|
{
|
|
$Status = $this->request->getPost('txtStatus');
|
|
$ReqNumber = $this->request->getPost('txtReqNo');
|
|
$CostCenter = $this->request->getPost('CostCenter');
|
|
$UpdatedBy = $this->session->get('userId');
|
|
$updatedDate = get_current_date_time();
|
|
$DeletedRow = $this->request->getPost('txtDeletedRow');
|
|
|
|
$RowCount = $this->request->getPost('txtRowCount');
|
|
$serviceSchedule = $this->request->getPost('serviceSchedule');
|
|
$servicePeriod = $this->request->getPost('serviceSchedule');
|
|
// $noOfService = $this->request->getPost('noOfService');
|
|
$noOfService = 1;
|
|
|
|
if (is_string($Status) && strlen($Status) > 1) {
|
|
$Request = array('Status' => $Status, 'CreatedDate' => $updatedDate, 'CreatedBy' => $UpdatedBy, 'CostCenterCode' => $CostCenter, 'Schedule_Type' => $serviceSchedule, 'NumberOfService' => $noOfService, 'Service_Period' => $servicePeriod);
|
|
$UpdateReq = $this->requistion_model->UpdateRequistion($Request, $ReqNumber);
|
|
} else {
|
|
$Request = array('Status' => REQ_PENDING_APPROVAL, 'updatedOn' => $updatedDate, 'CostCenterCode' => $CostCenter, 'Schedule_Type' => $serviceSchedule, 'NumberOfService' => $noOfService, 'Service_Period' => $servicePeriod);
|
|
$UpdateReq = $this->requistion_model->UpdateRequistion($Request, $ReqNumber);
|
|
}
|
|
|
|
|
|
$comma_separated = ($DeletedRow !== null && is_string($DeletedRow))
|
|
? explode(':', $DeletedRow)
|
|
: [];
|
|
|
|
/* Table value update and Insert in the table */
|
|
//echo "RowCOunt:" .$RowCount;
|
|
|
|
|
|
$SkipInsert = "false";
|
|
for ($i = 1; $i <= $RowCount; $i++) {
|
|
$SkipInsert = "false";
|
|
if (count($comma_separated) > 0) {
|
|
for ($j = 1; $j < count($comma_separated); $j++) {
|
|
$deletedRow = $comma_separated[$j];
|
|
if ($deletedRow == $i) {
|
|
$SkipInsert = "true";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if ($SkipInsert == "false") {
|
|
$MaterialCode = $this->request->getPost('MaterialCode' . $i);
|
|
$Quantity = $this->request->getPost('Quantity' . $i);
|
|
$OtherD = $this->request->getPost('otherD' . $i);
|
|
$IsExists = $this->requistion_model->LineItemIsExists($ReqNumber, $MaterialCode);
|
|
if ($IsExists === null || count($IsExists) == 0) {
|
|
$ReqDetails = array('ReqNo' => $ReqNumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'MaterialDescription' => $OtherD, 'UpdatedBy' => $UpdatedBy);
|
|
$this->requistion_model->addRequistionDetails($ReqDetails, $ReqNumber);
|
|
}
|
|
else {
|
|
$ReqDetails = array('ReqNo' => $ReqNumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'UpdatedBy' => $UpdatedBy, 'UpdatedOn' => $updatedDate, 'MaterialDescription' => $OtherD);
|
|
$this->requistion_model->UpdateRequistionLineItem($ReqDetails, $ReqNumber, $MaterialCode);
|
|
}
|
|
}
|
|
}
|
|
|
|
$display_message = "Successfully Updated the Requistion details!\nRequistion Number Is: ". $ReqNumber;
|
|
return $this->response->setJSON([$display_message]);
|
|
|
|
}
|
|
/* To Edit the request*/
|
|
function ViewRequest()
|
|
{
|
|
|
|
$ReqNo = $this->request->getPost('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 = '';
|
|
|
|
$FiscalYear = $this->costcenter_model->getFiscalYear();
|
|
if (!empty($FiscalYear)) {
|
|
foreach ($FiscalYear as $Fy) {
|
|
$FYStart = $Fy->StartYear;
|
|
$FYEnd = $Fy->EndYear;
|
|
}
|
|
}
|
|
|
|
$FYdt = $FYStart . " - " . $FYEnd;
|
|
$this->purchaseorder_model = new 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))));
|
|
}
|
|
|
|
/** This function used approve or reject request - Ajax Call*/
|
|
function ApproveRequest()
|
|
{
|
|
$Status = $this->request->getVar('Status');
|
|
$ReqNo = $this->request->getVar('ReqNo');
|
|
$Remarks = $this->request->getVar('Remarks');
|
|
|
|
$ApprovedBy = $this->session->get('userId');
|
|
$ApprovedDate = get_current_date_time();
|
|
|
|
$Request = array('Status' => $Status, 'Comments' => $Remarks, 'ApprovedOn' => $ApprovedDate, 'Approvedby' => $ApprovedBy);
|
|
$this->requistion_model->UpdateRequistion($Request, $ReqNo);
|
|
|
|
return $this->response->setJSON(['message' => "Requistion Updated Successfully!\nRequistion Number Is: ".$ReqNo]);
|
|
|
|
}
|
|
}
|