diff --git a/application/controllers/purchaseorder.php b/application/controllers/purchaseorder.php index c746ad38..c564e74e 100755 --- a/application/controllers/purchaseorder.php +++ b/application/controllers/purchaseorder.php @@ -5,9 +5,9 @@ require APPPATH . '/libraries/BaseController.php'; /** * Class : purchaseorder (PurchaseorderController) * User Class to control all user related operations. - * @author : VenbaMail Mali + * @author : Venba InfoTech * @version : 1.1 - * @since : 15 Feb 2016 + * @since : 09/06 Feb 2017 */ class purchaseorder extends BaseController { @@ -37,10 +37,11 @@ class purchaseorder extends BaseController function requisition() { - // $data['DeptList'] = $this->purchaseorder_model->getDepartmentListForAll$ReqNoReq(); + $Req_No=''; $IsArray=''; - $data['stList'] = $this->purchaseorder_model->getStatusListforAllReq(); + + $data['stList'] = $this->purchaseorder_model->getStatusListforAllReq(); $data['ReqList'] = $this->purchaseorder_model->getRawPOMaterialList($Req_No,$IsArray); @@ -49,24 +50,7 @@ class purchaseorder extends BaseController $this->loadViews("createPOfromRequistion", $this->global, $data,Null); } - /*function CreateEmergencyPO() - { - - $this->global['pageTitle'] = 'Siddharth : Create Emergency Purchase Order'; - - $data['RequestType'] = $this->requistion_model->getConfigValue('C004'); - - $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); - - $data['DeptList'] = $this->purchaseorder_model->getDepartmentListForAllReq(); - - $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); - - $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate(); - - $this->loadViews("alterpurchaseorder", $this->global, $data,Null); - - } */ + /** * This function is used to load the purchaseorder list */ @@ -77,10 +61,10 @@ class purchaseorder extends BaseController $count = $this->purchaseorder_model->purchaseorderListingCount(''); - $returns = $this->paginationCompress ( "purchaseorderListing/", $count, 5 ); - - //$this->purchaseorder_model->UpdateRequistItemStatus(); - $this->purchaseorder_model->UpdateRequistionStatus(); + $returns = $this->paginationCompress ( "purchaseorderListing/", $count, 10 ); + + $this->purchaseorder_model->UpdateRequistionStatus(); + $data['POData'] = $this->purchaseorder_model->purchaseorderListing(); $this->global['pageTitle'] = 'Siddharth : Purchase Orders'; @@ -109,21 +93,19 @@ class purchaseorder extends BaseController function CreatePurchaseOrder() { - - - $this->load->library('form_validation'); + $this->form_validation->set_rules('txtReqNo', 'txtReqNo', 'callback_Req_validate'); if($this->form_validation->run() == FALSE) { $this->requisition(); - //echo 'Validate method called'; + } else { - $this->global['pageTitle'] = 'Siddharth : Purchase order form'; + $this->global['pageTitle'] = 'Siddharth : Purchase order' ; $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); @@ -138,17 +120,34 @@ class purchaseorder extends BaseController foreach ($Req as $SID): $ReqArray[] = $SID->ReqNo ; $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); - $ReqType = $SID->ReqType; - // echo $SID->ReqNo; + $ReqType = $SID->ReqType; endforeach; - //print_r ($result); - $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); - $Year = $dt->format('Y'); - $data['CostList'] = $this->purchaseorder_model->getCostCenterbyRequist('',$Year,$ReqType); - $data['MaterialList'] = $result; //$this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray); - //print_r ($data['MaterialList']); - $data['RequistionDetails'] = $this->purchaseorder_model->getRequistDetails($ReqArray); + + + $data['MaterialList'] = $result; + /* Cost code from Requisition - Client Review Fix + Start here */ + $ReqDetails = $this->purchaseorder_model->getRequistDetails($ReqArray); + $data['RequistionDetails'] = $ReqDetails; + $CostCode = ''; + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + + $Year = $dt->format('Y'); + + foreach ($ReqDetails as $Rs): + $CostCode = $Rs->CostCenterCode; + endforeach; + + $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType); + + + if(count($AvlBudget)>0) + { + $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; + } + /* End Here */ + $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate(); @@ -209,11 +208,9 @@ class purchaseorder extends BaseController //To View/Update Purchase Order function EditPurchaseOrder() { - $PONO = $_GET['PONO']; - $ReqType = $_GET['ReqType']; - $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); - $Year = $dt->format('Y'); - $data['CostList'] = $this->purchaseorder_model->getCostCenterbyRequist('',$Year,$ReqType); + $PONO = $_GET['PONO']; + $ReqType = $_GET['ReqType']; + $Req = $this->purchaseorder_model->getRequistionNoFromPO($PONO); $data['ReqList'] = $Req ; $result = array(); @@ -222,13 +219,34 @@ class purchaseorder extends BaseController $ReqArray[] = $SID->ReqNo ; $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); endforeach; - $data['MaterialList'] = $result;//$this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray); + $data['MaterialList'] = $result;//$this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray); $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); - $data['RequistionDetails'] = $this->purchaseorder_model->getRequistDetails($ReqArray); - $data['POMaster'] = $this->purchaseorder_model->GetServicePurchaseOrder($PONO); - $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate(); - $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); - $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); + /* Cost code from Requisition - Client Review Fix + Start here */ + $ReqDetails = $this->purchaseorder_model->getRequistDetails($ReqArray); + $data['RequistionDetails'] = $ReqDetails; + $CostCode = ''; + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + + $Year = $dt->format('Y'); + + foreach ($ReqDetails as $Rs): + $CostCode = $Rs->CostCenterCode; + endforeach; + + $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType); + + + if(count($AvlBudget)>0) + { + $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; + } + /* End Here */ + + $data['POMaster'] = $this->purchaseorder_model->GetServicePurchaseOrder($PONO); + $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate(); + $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); + $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); if($ReqType == SERVICE) { @@ -331,50 +349,47 @@ class purchaseorder extends BaseController if(count($result)>0) { $AvilBudAmt = $result[0]['BudgetAmount'] - $result[0]['Totalvalue']; - } - - // echo 'Test'; + } + print_r($AvilBudAmt); - //die(json_encode(array('Cost' => $AvilBudAmt))); + } function getDateformat($Val) { - $date = new DateTime($Val,new DateTimeZone('Asia/Kolkata')); - // print_r($date); - $retDate = $date->format('Y-m-d H:i:s'); - return $retDate; + $date = new DateTime($Val,new DateTimeZone('Asia/Kolkata')); + $retDate = $date->format('Y-m-d H:i:s'); + return $retDate; } /* Method to get the Requistion list based on the search filter*/ function SearchListofRequistion() { - $SearchFilter= $this->input->post('id'); - // $reqDate= $this->input->post('ReqDate'); - $DEPCode = $SearchFilter[0]; - $Status = $SearchFilter[1]; - $rng = $SearchFilter[2];; - // $ToDate = $SearchFilter[3]; - $FromDate =''; - $ToDate = ''; - // echo $rng; - $Dt = explode("-",$rng); - // print_r( $Dt); - if(count( $Dt)>1) - { - $FDate = $Dt[0]; - $TDate = $Dt[1]; - $FromDate = $this->getDateformat($FDate); - $ToDate = $this->getDateformat($TDate); - } - //echo $FromDate; - // print_r($Dt); - $result = $this->purchaseorder_model->getRequistionListbySearch($DEPCode,$Status,$FromDate,$ToDate); - - - $HTML=""; - for ($i = 0; $i < count($result); $i++) + $SearchFilter= $this->input->post('id'); + + $DEPCode = $SearchFilter[0]; + $Status = $SearchFilter[1]; + $rng = $SearchFilter[2];; + + $FromDate =''; + $ToDate = ''; + + $Dt = explode("-",$rng); + + if(count( $Dt)>1) + { + $FDate = $Dt[0]; + $TDate = $Dt[1]; + $FromDate = $this->getDateformat($FDate); + $ToDate = $this->getDateformat($TDate); + } + + $result = $this->purchaseorder_model->getRequistionListbySearch($DEPCode,$Status,$FromDate,$ToDate); + + + $HTML=""; + for ($i = 0; $i < count($result); $i++) { $SNo = $i + 1; $ReqNo = $result[$i]['ReqNo']; @@ -398,8 +413,7 @@ class purchaseorder extends BaseController ".$Designation." "; } - //print_r( $HTML); - die(json_encode(array('ReqList' =>$HTML))); + die(json_encode(array('ReqList' =>$HTML))); } @@ -443,8 +457,7 @@ class purchaseorder extends BaseController $CostCenter .=""; } } - //echo $HTML; - //echo $CostCenter; + die(json_encode(array('Items' =>$HTML,'Requist'=>$ReqList,'Cost'=>$CostCenter))); } @@ -482,12 +495,10 @@ class purchaseorder extends BaseController { $PONO = $POMaster[0]['PONO']; } - //echo $PONO; - //echo $POType; + // PO Line Items $LineItemStatus = REQITEM_NEW; - //echo ' test:'.REVENUE; - //echo $RowCount; + for ($i = 1; $i <= $RowCount; $i++) {