diff --git a/application/controllers/purchaseorder.php b/application/controllers/purchaseorder.php
index f5e23ce2..7504021d 100644
--- a/application/controllers/purchaseorder.php
+++ b/application/controllers/purchaseorder.php
@@ -31,22 +31,281 @@ class purchaseorder extends BaseController
public function index()
{
$this->global['pageTitle'] = 'Siddharth : AddPO';
-
+
+
+
$this->loadViews("addPO", $this->global, NULL , NULL);
}
+ function requisition()
+ {
+ $data['DeptList'] = $this->purchaseorder_model->getDepartmentListForAllReq();
+
+ $data['stList'] = $this->purchaseorder_model->getStatusListforAllReq();
+
+ $data['ReqList'] = $this->purchaseorder_model->getRequistionListbySearch();
+
+ $this->global['pageTitle'] = 'Siddharth : Create PO from Requisition List';
+
+ $this->loadViews("createPOfromRequistion", $this->global, $data,Null);
+ }
+
+ /* This method to get the status based on the Department selection in th
+ */
+ function getStatusByDepartment()
+ {
+ $DepId = $this->input->post('id');
+
+ $data = $this->purchaseorder_model->getStatusByDepartment($DepId);
+
+ $HTML = "";
+ if(count($data) > 0)
+ {
+ for ($j = 0; $j < count($data); $j++)
+ {
+ $Code = $data[$j]['StatusCode'];
+ $Name = $data[$j]['StatusName'];
+ $HTML .="";
+ }
+ }
+ //echo $HTML;
+ die(json_encode(array('depStaus' => $HTML)));
+ }
+
+ 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;
+ }
+ /* 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++)
+ {
+ $SNo = $i + 1;
+ $ReqNo = $result[$i]['ReqNo'];
+ $ReqType = $result[$i]['ReqType'];
+ $Reqedby = $result[$i]['FirstName'];
+ $ReqDate = $result[$i]['ReqDate'];
+ $Status = $result[$i]['StatusName'];
+ $Department = $result[$i]['DepartmentName'];
+ $Designation = $result[$i]['Designation'];
+
+ $HTML.="
+ |
+ ". $ReqNo." |
+
+ ".$ReqType." |
+
+ ".$Reqedby." |
+ ".$ReqDate." |
+ ".$Status." |
+ ".$Department." |
+ ".$Designation." |
+
";
+ }
+ //print_r( $HTML);
+ die(json_encode(array('ReqList' =>$HTML)));
+ }
- /**
+ /* To View the request details*/
+ 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'];
+ $HTML.="
+ | ".$SNo." |
+ ". $MaterialCode." |
+
+ ".$MaterialName." |
+
+ ".$UOM." |
+ ".$Quantity." |
+
";
+
+ //$index = $index + 1;
+
+ }
+
+ $CostCenter = "";
+ if(count($CostList) > 0)
+ {
+ for ($j = 0; $j < count($CostList); $j++)
+ {
+ $Code = $CostList[$j]['CostCenterCode'];
+ $Name = $CostList[$j]['CostCenterName'];
+ $CostCenter .="";
+ }
+ }
+ //echo $HTML;
+ //echo $CostCenter;
+ die(json_encode(array('Items' =>$HTML,'Requist'=>$ReqList,'Cost'=>$CostCenter)));
+ }
+
+ function addNewPurchaseOrder()
+ {
+ $POdt =$this->input->post('PODate');
+ $PODate = $this->getDateformat($POdt);
+ $SupplierID = $this->input->post('drpSupplier');
+ $DeliveryAddr = $this->input->post('DeliveryAddr');
+ $dt = $this->input->post('Deliverydt');
+ $Deliverydt = $this->getDateformat($dt);
+ $POType = $this->input->post('POType');
+ $PoRange = $this->input->post('txtPoRange');
+
+ $SpcialInstruction = $this->input->post('txtSpcialInstruction');
+ $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary');
+ $POStatus = $this->input->post('txtStatus');
+
+ $CreateBy = $this->session->userdata ( 'userId' );
+ $RowCount = $this->input->post('txtRowCount');
+ $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
+ $createddt = $dt->format('Y-m-d H:i:s');
+ // PO Master
+ $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt );
+
+ $POMaster = $this->purchaseorder_model->addPOMaster($POList);
+
+ $PONO = '';
+ if(count($POMaster)>0)
+ {
+ $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++)
+ {
+
+ $MaterialCode = $this->input->post('materialCode'.$i);
+ $Quantity = $this->input->post('quantity'.$i);
+ $Reqnumber = $this->input->post('Reqnumber'.$i);
+ $itemRate = $this->input->post('itemRate'.$i);
+
+ $DiscountType = $this->input->post('DisType'.$i);
+ $DiscountValue = $this->input->post('DisVal'.$i);
+ $AfterDiscount = $this->input->post('AfterDisVal'.$i);
+ $PackagingOption = $this->input->post('PackOption'.$i);
+ $PackagingType = $this->input->post('PackType'.$i);
+ $PackagingValue = $this->input->post('PackVal'.$i);
+ $AfterPackagingValue = $this->input->post('AfterPackVal'.$i);
+ $ExciseOption = $this->input->post('ExciseOption'.$i);
+ $ExciseValue = $this->input->post('ExciseVal'.$i);
+ $AfterExciseValue = $this->input->post('AfterExciseVal'.$i);
+ $VatOption = $this->input->post('VatOption'.$i);
+ $VatValue = $this->input->post('VatVal'.$i);
+ $AfterVatValue = $this->input->post('AfterVatVal'.$i);
+ $CSTOption = $this->input->post('CSTOption'.$i);
+ $CSTValue = $this->input->post('CSTVal'.$i);
+ $AfterCSTValue = $this->input->post('AfterCSTVal'.$i);
+ $GSTValue = $this->input->post('GSTVal'.$i);
+ $AfterGSTValue = $this->input->post('AfterGSTVal'.$i);
+ $OtherTaxValue = $this->input->post('OtherTaxVal'.$i);
+ $AfterOtherTaxValue = $this->input->post('AfterOtherTaxVal'.$i);
+ $FreightType = $this->input->post('FreightType'.$i);
+ $FreightValue = $this->input->post('FreightVal'.$i);
+ $AfterFreightValue = $this->input->post('AfterFreightVal'.$i);
+ $InsuranceValue = $this->input->post('Insval'.$i);
+ $TotalOrderValue = $this->input->post('TotalOrderValue'.$i);
+
+
+ $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt);
+
+ $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
+
+ $LineItemNo = '';
+ if(count($POLineItem)>0)
+ {
+ $LineItemNo = $POLineItem[0]['LineItemNo'];
+ }
+ //echo $LineItemNo;
+
+ if(trim($POType) == REVENUE )
+ {
+ echo 'Success';
+ $RevenueTaxList = array('LineItemNo'=>$LineItemNo, 'DiscountType'=>$DiscountType,'DiscountValue'=>$DiscountValue,'AfterDiscount'=>$AfterDiscount,'PackagingType'=>$PackagingType,'PackagingValue'=>$PackagingValue,'PackagingCalulatedOn'=>$PackagingOption,'AfterPackagingValue'=>$AfterPackagingValue,'FreightType'=>$FreightType, 'FreightValue'=>$FreightValue,'AfterFreightValue'=>$AfterFreightValue,'ExciseDuty'=>$ExciseValue,'ExciseDutyCalulatedOn'=>$ExciseOption,'AfterExciseDuty'=>$AfterExciseValue,'Vat'=>$VatValue,'AfterVAT'=>$AfterVatValue,'VatCalulatedOn'=>$VatOption, 'CST'=>$CSTValue,'AfterCST'=>$AfterCSTValue,'CSTCalulatedOn'=>$CSTOption,'GST'=>$GSTValue,'AfterGST'=>$AfterGSTValue,'OtherTaxes'=>$OtherTaxValue,'AfterOtherTaxes'=>$AfterOtherTaxValue,'Insurance'=>$InsuranceValue,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt);
+
+ $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList);
+ echo 'Revenue tax Success';
+ }
+ echo 'Successfully updated the Record';
+ }
+
+
+ }
+
+ /**
* This function is used to load the purchaseorder list
*/
function purchaseorderListing()
{
-
- $this->global['pageTitle'] = 'Siddharth : PO Listing';
-
- $this->loadViews("POlist", $this->global,NULL);
+ if($this->isAdmin() == TRUE)
+ {
+ $this->loadThis();
+ }
+ else
+ {
+ $this->load->model('purchaseorder_model');
+ $searchText = $this->input->post('searchText');
+ $data['searchText'] = $searchText;
+
+ $this->load->library('pagination');
+
+ $count = $this->purchaseorder_model->purchaseorderListingCount($searchText);
+
+ $returns = $this->paginationCompress ( "purchaseorderListing/", $count, 5 );
+
+ $data['userRecords'] = $this->purchaseorder_model->purchaseorderListing($searchText, $returns["page"], $returns["segment"]);
+
+
+
+ $this->global['pageTitle'] = 'Siddharth : PO Listing';
+
+ $this->loadViews("POlist", $this->global, $data, NULL);
+ }
}
@@ -69,7 +328,45 @@ class purchaseorder extends BaseController
}
}
-
+
+
+ /**
+ * This function used to show the Purchase Order Screen
+ */
+
+ function CreatePurchaseOrder()
+ {
+
+
+ $this->global['pageTitle'] = 'Siddharth : Purchase order form';
+
+ $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006');
+ $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018');
+ $data['Suplist'] = $this->purchaseorder_model->getSupplierName();
+ $SelectedReq = json_decode($this->input->post('txtReqNo'));
+ $Req = $SelectedReq->Req;
+ $data['ReqList'] = $Req ;
+ $ReqArray = array();
+ $ReqType = '';
+
+ foreach ($Req as $SID):
+ $ReqArray[] = $SID->ReqNo ;
+ $ReqType = $SID->ReqType;
+ endforeach;
+
+ $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
+ $Year = $dt->format('Y');
+ $data['CostList'] = $this->purchaseorder_model->getCostCenterbyRequist('',$Year,$ReqType);
+ $data['MaterialList'] = $this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray);
+ $data['RequistionDetails'] = $this->purchaseorder_model->getRequistDetails($ReqArray);
+ //$data['FormulaList'] = $this->purchaseorder_model->getFormula();
+
+
+ $this->loadViews("Purchaseorder", $this->global,$data, NULL);
+
+ }
+
+
/**
* This function is used to load the add new PO */
function addPO()