diff --git a/application/config/constants.php b/application/config/constants.php index ea0074f4..fdc6b80b 100755 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -226,7 +226,11 @@ define('Capital_Grossexpenses_Charge', define('Capital_purchaserate_Charge', '(AfterBasicPriceTax/PurQuantity)'); define('Capital_CustomDutyExpenses_Charge', '(Grossexpenses/PurQuantity)'); define('Capital_RMCIncludingCustomers_Charge', '(purchaserate+CustomDutyExpenses)'); +/* calculate cgst sgst igst calculations for service tax*/ +define('SERVICETAX_CGST', '((Cgst/100) * basicValue)'); +define('SERVICETAX_SGST', '((Sgst/100) * basicValue)'); +define('SERVICETAX_IGST', '((Igst/100) * basicValue)'); /* End of file constants.php */ diff --git a/application/config/constants.php~ b/application/config/constants.php~ new file mode 100755 index 00000000..fdc6b80b --- /dev/null +++ b/application/config/constants.php~ @@ -0,0 +1,237 @@ +requistion_model->getConfigValue('C004'); $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); $data['INRSYMBOL']=$this->purchaseorder_model->GetINRCurrencytype('INR'); - /*$data['DeptList'] = $this->purchaseorder_model->getDepartmentAllList();*/ - $empDetails = $this->requistion_model->GetEmployeeDetails($RequestedBy); - - $DeptCode = $empDetails[0]['DEPCode']; - $data['DeptList'] = $empDetails; - $data['CostList'] = $this->requistion_model->GetCostCenterByDept( $DeptCode); - + $data['DeptList'] = $this->purchaseorder_model->getDepartmentAllList(); + + + $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate(); $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); - $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); - $data['Payment']=$this->purchaseorder_model->getSupplierPayment('C009'); - $data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019'); - + $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); + //$data['Payment']=$this->purchaseorder_model->getSupplierPayment('C009'); + $data['Payment']=$this->purchaseorder_model->getPaymentTermsDetails(); + //$data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019'); + $data['WorkStatus']=$this->purchaseorder_model->getStatus(7); + $data['ServiceOption'] = $this->requistion_model->getConfigValue('C022'); $this->loadViews("alterpurchaseorder", $this->global, $data, Null); } @@ -100,17 +99,12 @@ class emergencypurchaseorder extends BaseController $PODate = $this->getDateformat($POdt); $SupplierID = $this->input->post('drpSupplier'); $DeliveryAddr = $this->input->post('DeliveryAddr'); - $dt = $this->input->post('Deliverydt'); + $CostCenterName = $this->input->post('CostCenterName'); $DeliveryOption = $this->input->post('DateRange'); - if($DeliveryOption==1){ - $Deliverydt = ''; - $DeliverySchedule = $this->input->post('Scheduleby'); - } - else{ - $Deliverydt = $this->getDateformat($dt); - $DeliverySchedule = ''; - } + $DeliverySchedule=''; + $Deliverydt = $this->getDateformat($POdt); + $POType = $this->input->post('POType'); @@ -134,15 +128,16 @@ class emergencypurchaseorder extends BaseController $createddt = $dt->format('Y-m-d H:i:s'); $PaymentTerms=$this->input->post('PaymentMethod'); - $PayableAT=$this->input->post('PayableAT'); - $PaymentDays=$this->input->post('paymentDateOptions'); - $ServiceWorkStatus=$this->input->post('workStatus'); - - + + + $ServiceWorkStatus=$this->input->post('workStatus'); + $ServiceScheduleType = $this->input->post('ScheduleType'); + $ServiceScheduleOptions = $this->input->post('ServiceOptions'); + $ServiceServiceNo = $this->input->post('ServiceNo'); //create T_Requestion_Master - $Request = array('ReqType'=>$POType, 'Requestedby'=>$RequestedBy,'CostCenterCode'=>$CostCenterName,'Status'=>$ReqStatus,'Comments'=>$SpcialInstruction,'ReqDate'=>$createddt,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy); + $Request = array('ReqType'=>$POType, 'Requestedby'=>$RequestedBy,'CostCenterCode'=>$CostCenterName,'Status'=>$ReqStatus,'Comments'=>$SpcialInstruction,'ReqDate'=>$createddt,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy,'Schedule_Type'=>$ServiceScheduleType,'NumberOfService'=>$ServiceServiceNo,'Service_Period'=>$ServiceScheduleOptions); $Req = $this->requistion_model->addRequistion($Request); @@ -154,7 +149,7 @@ class emergencypurchaseorder extends BaseController // PO Master - $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'PaymentDays'=>$PaymentDays,'PayableAT'=>$PayableAT,'ServiceWorkStatus'=>$ServiceWorkStatus,'POType'=>$POType); + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'ServiceWorkStatus'=>$ServiceWorkStatus,'POType'=>$POType); $POMaster = $this->purchaseorder_model->addPOMaster($POList); $PONO = ''; @@ -175,15 +170,18 @@ class emergencypurchaseorder extends BaseController $Quantity = $this->input->post('quantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); - $ServiceTax = $this->input->post('ServiceTax'.$i); - $EduCess = $this->input->post('EduCess'.$i); - $SecHighTax = $this->input->post('SecHighTax'.$i); - $KrishiTax = $this->input->post('KrishiTax'.$i); - $SwachhTax = $this->input->post('SwachhTax'.$i); + $Cgst = $this->input->post('Cgst'.$i); + $Sgst = $this->input->post('Sgst'.$i); + $Igst = $this->input->post('Igst'.$i); + $AfterCgst = $this->input->post('AfterCgst'.$i); + $AfterSgst = $this->input->post('AfterSgst'.$i); + $AfterIgst = $this->input->post('AfterIgst'.$i); + $OtherAmt = $this->input->post('OtherAmt'.$i); $CostCenter = $this->input->post('costCode'.$i); $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); - $ServiceFrequency=$this->input->post('Frequency'.$i); + $ServiceFrequency=$this->input->post('Frequency'.$i).' - '.$this->input->post('FrequencyValue'.$i); + $ServiceMaterialDescription = $this->input->post('ItemServiceDescription'.$i); $SkipInsert = "False"; if( count($comma_separated) > 0) { @@ -210,7 +208,7 @@ class emergencypurchaseorder extends BaseController - $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$RegNo,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'ServiceFrequency'=>$ServiceFrequency); + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$RegNo,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'ServiceMaterialDescription'=>$ServiceMaterialDescription,'ServiceFrequency'=>$ServiceFrequency); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); $LineItemNo = ''; if(count($POLineItem)>0) @@ -223,8 +221,8 @@ class emergencypurchaseorder extends BaseController { // echo 'Success'; - $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt); - + $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'CGST'=>$Cgst,'After_CGST'=>$AfterCgst,'SGST'=>$Sgst,'After_SGST'=>$AfterSgst,'IGST'=>$Igst,'After_IGST'=>$AfterIgst,'otherallowance'=>$OtherAmt,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt); + $ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList); } @@ -290,9 +288,9 @@ class emergencypurchaseorder extends BaseController $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); $PaymentTerms=$this->input->post('PaymentMethod'); - $PayableAT=$this->input->post('PayableAT'); - $PaymentDays=$this->input->post('paymentDateOptions'); + + //add requistion $Request = array('ReqType'=>$POType, 'Requestedby'=>$RequestedBy,'CostCenterCode'=>$CostCenterName,'Status'=>$ReqStatus,'Comments'=>$SpcialInstruction,'ReqDate'=>$createddt,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy); @@ -304,7 +302,7 @@ class emergencypurchaseorder extends BaseController $RegNo = $Req[0]['ReqNo']; } // PO Master - $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'PaymentDays'=>$PaymentDays,'PayableAT'=>$PayableAT,'POType'=>$POType ); + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType ); $POMaster = $this->purchaseorder_model->addPOMaster($POList); @@ -333,26 +331,19 @@ class emergencypurchaseorder extends BaseController $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); $CostCenter = $this->input->post('costCode'.$i); - + $Cgst = $this->input->post('RevenueCgst'.$i); + $Sgst = $this->input->post('RevenueSgst'.$i); + $Igst = $this->input->post('RevenueIgst'.$i); + $AfterCgst = $this->input->post('RevenueAfterCgst'.$i); + $AfterSgst = $this->input->post('RevenueAfterSgst'.$i); + $AfterIgst = $this->input->post('RevenueAfterIgst'.$i); $SkipInsert = "False"; if( count($comma_separated) > 0) { @@ -390,7 +381,7 @@ class emergencypurchaseorder extends BaseController 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); + $RevenueTaxList = array('LineItemNo'=>$LineItemNo, 'DiscountType'=>$DiscountType,'DiscountValue'=>$DiscountValue,'AfterDiscount'=>$AfterDiscount,'PackagingType'=>$PackagingType,'PackagingValue'=>$PackagingValue,'PackagingCalulatedOn'=>$PackagingOption,'AfterPackagingValue'=>$AfterPackagingValue,'FreightType'=>$FreightType, 'FreightValue'=>$FreightValue,'AfterFreightValue'=>$AfterFreightValue,'Insurance'=>$InsuranceValue,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt, 'CGST'=>$Cgst,'AfterCGST'=>$AfterCgst,'SGST'=>$Sgst,'AfterSGST'=>$AfterSgst,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst); $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList); //echo 'Revenue tax Success'; diff --git a/application/controllers/emergencypurchaseorder.php~ b/application/controllers/emergencypurchaseorder.php~ new file mode 100755 index 00000000..1f17f873 --- /dev/null +++ b/application/controllers/emergencypurchaseorder.php~ @@ -0,0 +1,1110 @@ +load->model('purchaseorder_model'); + + $this->load->library('session'); + $this->load->library('form_validation'); + $this->load->model('requistion_model'); + $this->isLoggedIn(); + } + + /** + * This function used to load the first screen of the user + */ + 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); + } + + function CreateEmergencyPO() + { + $RequestedBy = $this->session->userdata ('EmpID'); + $this->global['pageTitle'] = 'Siddharth : Create Emergency Purchase Order'; + $data['RequestType'] = $this->requistion_model->getConfigValue('C004'); + $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); + $data['INRSYMBOL']=$this->purchaseorder_model->GetINRCurrencytype('INR'); + /*$data['DeptList'] = $this->purchaseorder_model->getDepartmentAllList();*/ + $empDetails = $this->requistion_model->GetEmployeeDetails($RequestedBy); + + $DeptCode = $empDetails[0]['DEPCode']; + $data['DeptList'] = $empDetails; + $data['CostList'] = $this->requistion_model->GetCostCenterByDept( $DeptCode); + + $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); + $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate(); + $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); + $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); + $data['Payment']=$this->purchaseorder_model->getSupplierPayment('C009'); + $data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019'); + + $this->loadViews("alterpurchaseorder", $this->global, $data, Null); + + } + /** + * this function used for get all material code using request type + */ + function getMaterialCode(){ + $reqType = $this->input->post('input'); + $materialList = $this->requistion_model->GetMaterialCode($reqType); + echo json_encode($materialList); + + } + + /*This function is used for get cost center list using department code*/ + function getCostCenterName(){ + $CostList=''; + $DeptCode = $this->input->post('id'); + $CostList = $this->requistion_model->GetCostCenterByDept($DeptCode); + // print_r($CostList); + echo json_encode($CostList); + + } + + //This used to Create Service Purchase Order + function addNewServicePurchaseOrder() + { + + + $POdt =$this->input->post('PODate'); + $PODate = $this->getDateformat($POdt); + $SupplierID = $this->input->post('drpSupplier'); + $DeliveryAddr = $this->input->post('DeliveryAddr'); + $dt = $this->input->post('Deliverydt'); + $CostCenterName = $this->input->post('CostCenterName'); + $DeliveryOption = $this->input->post('DateRange'); + if($DeliveryOption==1){ + $Deliverydt = ''; + $DeliverySchedule = $this->input->post('Scheduleby'); + } + else{ + $Deliverydt = $this->getDateformat($dt); + $DeliverySchedule = ''; + } + + + $POType = $this->input->post('POType'); + + $SpcialInstruction = $this->input->post('TextSpcialInstruction'); + $TotalOrderValueSummary = $this->input->post('TextTotalOrderValueSummaryService'); + + $POStatus = $this->input->post('TextStatus'); + $CreateBy = $this->session->userdata ('userId'); + $RequestedBy = $this->session->userdata ('EmpID'); + + $ReqStatus = REQITEM_Emergency_PO_CREATED; + + $RowCount = $this->input->post('TextRowCount'); + + $DeletedRow = $this->input->post('TextDeletedRowCount'); + + $comma_separated = explode(':', $DeletedRow); + + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + + $createddt = $dt->format('Y-m-d H:i:s'); + $PaymentTerms=$this->input->post('PaymentMethod'); + $PayableAT=$this->input->post('PayableAT'); + + $PaymentDays=$this->input->post('paymentDateOptions'); + $ServiceWorkStatus=$this->input->post('workStatus'); + + + + //create T_Requestion_Master + $Request = array('ReqType'=>$POType, 'Requestedby'=>$RequestedBy,'CostCenterCode'=>$CostCenterName,'Status'=>$ReqStatus,'Comments'=>$SpcialInstruction,'ReqDate'=>$createddt,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy); + + $Req = $this->requistion_model->addRequistion($Request); + + $RegNo=''; + if(count($Req)>0) + { + $RegNo = $Req[0]['ReqNo']; + } + + + // PO Master + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'PaymentDays'=>$PaymentDays,'PayableAT'=>$PayableAT,'ServiceWorkStatus'=>$ServiceWorkStatus,'POType'=>$POType); + + $POMaster = $this->purchaseorder_model->addPOMaster($POList); + $PONO = ''; + if(count($POMaster)>0) + { + $PONO = $POMaster[0]['PONO']; + } + + $RegDetailsStatus=REQITEM_POCREATED; + + // PO Line Items + $LineItemStatus = REQITEM_NEW; + + 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); + $ServiceTax = $this->input->post('ServiceTax'.$i); + $EduCess = $this->input->post('EduCess'.$i); + $SecHighTax = $this->input->post('SecHighTax'.$i); + $KrishiTax = $this->input->post('KrishiTax'.$i); + $SwachhTax = $this->input->post('SwachhTax'.$i); + $CostCenter = $this->input->post('costCode'.$i); + + $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); + $ServiceFrequency=$this->input->post('Frequency'.$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") + { + + //add requistion details + $ReqDetails = array('ReqNo'=>$RegNo, 'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Status'=>$RegDetailsStatus,'UpdatedBy'=>$CreateBy,'UpdatedOn'=>$createddt); + + + $ReqDetQuery = $this->requistion_model->addRequistionDetails($ReqDetails); + + + + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$RegNo,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'ServiceFrequency'=>$ServiceFrequency); + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + $LineItemNo = ''; + if(count($POLineItem)>0) + { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } + + + if(trim($POType) == SERVICE ) + { + // echo 'Success'; + + $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt); + + $ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList); + + } + } + else { + + } + + } + + if($POStatus == REQ_DRAFT) + { + echo 'Emergency Service Purchase Order Saved Successfully!The PO NO Is: '.$PONO; + + } + else + { + echo 'Emergency Service Purchase Order Created Successfully!The PO NO Is: '.$PONO; + + } + + + } + + + + //This used to Create Revenue Emergency Purchase Order + function addNewRevenuePurchaseOrder() + { + + + $POdt =$this->input->post('PODate'); + $PODate = $this->getDateformat($POdt); + $SupplierID = $this->input->post('drpSupplier'); + $DeliveryAddr = $this->input->post('DeliveryAddr'); + $dt = $this->input->post('Deliverydt'); + $DeliveryOption = $this->input->post('DateRange'); + if($DeliveryOption==1){ + $Deliverydt = ''; + $DeliverySchedule = $this->input->post('Scheduleby'); + } + else{ + $Deliverydt = $this->getDateformat($dt); + $DeliverySchedule = ''; + } + $CostCenterName = $this->input->post('CostCenterName'); + $POType = $this->input->post('POType'); + $PoRange = $this->input->post('txtPoRange'); + + $SpcialInstruction = $this->input->post('TextSpcialInstruction'); + $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); + $POStatus = $this->input->post('TextStatus'); + + $CreateBy = $this->session->userdata ( 'userId' ); + $RowCount = $this->input->post('TextRowCount'); + $DeletedRow = $this->input->post('TextDeletedRowCount'); + $RequestedBy = $this->session->userdata ('EmpID'); + $ReqStatus = REQITEM_Emergency_PO_CREATED; + + + $comma_separated = explode(':', $DeletedRow); + + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $createddt = $dt->format('Y-m-d H:i:s'); + $PaymentTerms=$this->input->post('PaymentMethod'); + $PayableAT=$this->input->post('PayableAT'); + + $PaymentDays=$this->input->post('paymentDateOptions'); + //add requistion + $Request = array('ReqType'=>$POType, 'Requestedby'=>$RequestedBy,'CostCenterCode'=>$CostCenterName,'Status'=>$ReqStatus,'Comments'=>$SpcialInstruction,'ReqDate'=>$createddt,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy); + + $Req = $this->requistion_model->addRequistion($Request); + + $RegNo=''; + if(count($Req)>0) + { + $RegNo = $Req[0]['ReqNo']; + } + // PO Master + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'PaymentDays'=>$PaymentDays,'PayableAT'=>$PayableAT,'POType'=>$POType ); + + $POMaster = $this->purchaseorder_model->addPOMaster($POList); + + $PONO = ''; + if(count($POMaster)>0) + { + $PONO = $POMaster[0]['PONO']; + } + + // PO Line Items + $RegDetailsStatus=REQITEM_POCREATED; + $LineItemStatus = REQITEM_NEW; + + 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); + $CostCenter = $this->input->post('costCode'.$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") + { + //add requistion details + $ReqDetails = array('ReqNo'=>$RegNo, 'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Status'=>$RegDetailsStatus,'UpdatedBy'=>$CreateBy,'UpdatedOn'=>$createddt); + + + $ReqDetQuery = $this->requistion_model->addRequistionDetails($ReqDetails); + + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$RegNo,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter); + + $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 'Purchase Order Created Successfully! PO Number Is: '.$PONO ; + + } + + + /** + * This function is used to load the purchaseorder list + */ + function PurchaseOrderList() + { + + $this->load->library('pagination'); + + $count = $this->purchaseorder_model->purchaseorderListingCount(''); + + $returns = $this->paginationCompress ( "purchaseorderListing/", $count, 5 ); + + //$this->purchaseorder_model->UpdateRequistItemStatus(); + $this->purchaseorder_model->UpdateRequistionStatus(); + $data['POData'] = $this->purchaseorder_model->purchaseorderListing(); + + $this->global['pageTitle'] = 'Siddharth : Purchase Orders'; + + $this->loadViews("POlist", $this->global, $data, NULL); + + } + function Req_validate($selectValue) + { + //echo 'select_validate method called'; + // 'none' is the first option and the text says something like "-Choose one-" + if(strlen($selectValue) == 0) + { + $this->form_validation->set_message('Req_validate', 'Please Select Requisition Number to Create PO.'); + return false; + } + else // user picked something + { + return true; + } + } + + /** + * This function used to show the Purchase Order Screen + */ + + 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'; + $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 = ''; + $result = array(); + + foreach ($Req as $SID): + $ReqArray[] = $SID->ReqNo ; + $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); + $ReqType = $SID->ReqType; + //echo $SID->ReqNo; + + 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['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); + $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate(); + + $ViewName = ''; + if($ReqType == REVENUE) + { + $ViewName = 'Purchaseorder'; + } + else if($ReqType == SERVICE) + { + $ViewName = 'servicePurchaseorder'; + } + $this->loadViews($ViewName, $this->global,$data, NULL); + } + } + + function CreatePOPrint() + { + $PONO = $_GET['PONO']; + $ReqType = $_GET['ReqType']; + + if($ReqType == SERVICE) + { + $this ->servicepoprint($PONO); + + } + else if($ReqType == REVENUE) + { + $this ->revenuepoprint($PONO); + + } + } + //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); + $Req = $this->purchaseorder_model->getRequistionNoFromPO($PONO); + $data['ReqList'] = $Req ; + $result = array(); + $ReqArray = array(); + foreach ($Req as $SID): + $ReqArray[] = $SID->ReqNo ; + $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); + endforeach; + $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'); + if($ReqType == SERVICE) + { + + $data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetails($PONO); + $this->global['pageTitle'] = 'Siddharth : Edit Service Purchase order form'; + $this->loadViews("EditservicePurchaseorder", $this->global, $data, NULL); + } + else if($ReqType == REVENUE) + { + + $data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetails($PONO); + $this->global['pageTitle'] = 'Siddharth : Edit Revenue Purchase order form'; + $this->loadViews("editRevenuepurchaseorder", $this->global, $data, NULL); + } + + } + + // To get the Material value based on the MaterialCode + function getDetailsforReq() + { + + + $SearchFilter= $this->input->post('id'); + // $reqDate= $this->input->post('ReqDate'); + $DeptCode = $SearchFilter[0]; + $MatType = $SearchFilter[1]; + $ReqNo = $SearchFilter[2]; + // $ReqDetai = $this->purchaseorder_model->getRequistDetails( $EmpID ); + + $CostList = $this->requistion_model->GetCostCenterByDept( $DeptCode); + + $HTML = ""; + $BudAmount = ""; + if(count($CostList) > 0) + { + for ($j = 0; $j < count($CostList); $j++) + { + $Code = $CostList[$j]['CostCenterCode']; + $Name = $CostList[$j]['CostCenterName']; + $HTML .=""; + } + } + $MaterialDetails = $this->purchaseorder_model->getRawMaterialListForPO($MatType,$ReqNo); + + $HTML1 = ""; + + if(count($MaterialDetails) > 0) + { + for ($j = 0; $j < count($MaterialDetails); $j++) + { + $Code = $MaterialDetails[$j]['MaterialCode']; + $Name = $MaterialDetails[$j]['MaterialName']; + $HTML1 .=""; + + } + + } + // print_r($HTML1); + + die(json_encode(array('MatDetail' =>$HTML1,'Cost'=> $HTML))); + } + /* 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))); + } + + // To get the available Budget Amount + function AvilBudgetAmount() + { + $SearchFilter= $this->input->post('id'); + // $reqDate= $this->input->post('ReqDate'); + $CostCode = $SearchFilter[0]; + $ReqType = $SearchFilter[1]; + print_r($SearchFilter); + $CostCode= $this->input->post('id'); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + + $Year = $dt->format('Y'); + $this->load->model('purchaseorder_model'); + $result = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType); + //print_r($result); + $AvilBudAmt = ''; + 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; + } + /* 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 ListPORequistion() + { + $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))); + } + + //This used to Create Revenue Purchase Order + 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'); + $DeletedRow = $this->input->post('txtDeletedRow'); + + $comma_separated = explode(':', $DeletedRow); + + $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); + $CostCenter = $this->input->post('costCode'.$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") + { + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter); + + $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 'Purchase Order Created Successfully! PO Number Is: '.$PONO ; + + } + //This used to Edit the Revenue Purchase Order + function EditRevenuePurchaseOrder() + { + $PONO =$this->input->post('txtPONO'); + $POdt =$this->input->post('PODate'); + $PODate = $this->getDateformat($POdt); + $SupplierID = $this->input->post('drpSupplier'); + $DeliveryAddr = $this->input->post('txtDeliveryAddress'); + $dt = $this->input->post('Deliverydt'); + $Deliverydt = $this->getDateformat($dt); + $POType = $this->input->post('POType'); + $PoRange = $this->input->post('txtPoRange'); + + $SpcialInstruction = $this->input->post('SpcialInstruction'); + $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); + $POStatus = $this->input->post('txtStatus'); + + $updatedBy = $this->session->userdata ( 'userId' ); + $RowCount = $this->input->post('txtRowCount'); + $DeletedRow = $this->input->post('txtDeletedRow'); + + $comma_separated = explode(':', $DeletedRow); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $updateddt = $dt->format('Y-m-d H:i:s'); + // PO Master + // PO Master + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'ServiceDescription'=>$SpcialInstruction,'UpdateBY'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt ); + + $POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); + + $LineItemStatus = REQITEM_NEW; + + + + //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); + $POLineItemNo = $this->input->post('LineItemNo'.$i); + $CostCenter = $this->input->post('costCode'.$i); + $LineItemNo = ''; + + + $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") + { + if(strlen($POLineItemNo) == 0) + { + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CostCenterCode'=>$CostCenter); + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + if(count($POLineItem)>0) + { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } + + } + else + { + $LineItemNo = $POLineItemNo; + + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt,'CostCenterCode'=>$CostCenter); + $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$POLineItemNo,$POLineItemList); + + } + $isExists = $this->purchaseorder_model->LineItemExistsinRevenueTax($LineItemNo); + if(count($isExists) == 0) + { + $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'=>$updatedBy,'CreatedDate'=>$updateddt); + + $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList); + + } + else + { + $RevenueTaxList = array('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, 'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt); + + $this->purchaseorder_model->updateRevenueTax($LineItemNo,$RevenueTaxList); + + } + } + + } + + echo 'Purchase Order Updated Successfully! PO Number Is: '.$PONO ; + } + function pageNotFound() + { + $this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found'; + + $this->loadViews("404", $this->global, NULL, NULL); + } + + public function revenuepoprint($PONO) + { + // Load all views as normal + + + //$PONO = $_GET['PO']; + + $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); + $data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetailsForPDF($PONO); + + + // Add header to pdf + //$this->load->view('includes/pdfheader'); + + // Load the pdf page with multiviews + $this->load->View("revenuepopdf", $data); + + // Add header to pdf + //$this->load->view('includes/pdffooter'); + + // Get output html + $php = $this->output->get_output(); + + // Load library + $this->load->library('dompdf_gen'); + + // Convert to PDF + $this->dompdf->load_html($php); + $this->dompdf->render(); + $data['Attachment'] = FALSE; + $this->dompdf->stream("RevenuePOReport.pdf",$data,$php); + + } + public function servicepoprint($PONO) + { + + // $this->load->view('includes/pdfheader'); + + // Load the pdf page with multiviews + $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); + $data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetailsForPrint($PONO); + + $this->load->View("servicepopdf", $data); + + // Add header to pdf + //$this->load->view('includes/pdffooter'); + + // Get output html + $php = $this->output->get_output(); + + // Load library + $this->load->library('dompdf_gen'); + + // Convert to PDF + $this->dompdf->load_html($php); + $this->dompdf->render(); + $data['Attachment'] = FALSE; + $this->dompdf->stream("ServicePOReport.pdf",$data,$php); + + } + /** + * This function used to load the Delete the Requistion Items + */ + function DeletePODetails() + { + + $ReqList= $this->input->post('id'); + $LineItemNo = ''; + $ReqNo =''; + $MaterialCode = ''; + $POType = ''; + if(count($ReqList) > 0) + { + $LineItemNo = $ReqList[0]; + $ReqNo = $ReqList[1]; + $MaterialCode = $ReqList[2]; + $POType = $ReqList[3]; + } + // print_r($ReqList); + + + If($POType == REVENUE) + { + $this->purchaseorder_model->DeletePORevenueTax($LineItemNo); + } + else If($POType == SERVICE) + { + $this->purchaseorder_model->DeletePOServiceTax($LineItemNo); + } + $this->purchaseorder_model->DeletePOLineItem($LineItemNo , $ReqNo,$MaterialCode); + echo "Successfully Deleted the Line item".$LineItemNo; + + } +} + +?> + diff --git a/application/controllers/purchaseorder.php b/application/controllers/purchaseorder.php index dce940a6..07dd895d 100755 --- a/application/controllers/purchaseorder.php +++ b/application/controllers/purchaseorder.php @@ -120,27 +120,14 @@ class purchaseorder extends BaseController $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); - $data['Payment']=$this->purchaseorder_model->getSupplierPayment('C009'); - $data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019'); - - - foreach ($data['WorkStatus'] as $WST) - { - - $WStatus=$WST->ConfigValue; - //print_r($WStatus); + //$data['Payment']=$this->purchaseorder_model->getSupplierPayment('C009'); + $data['Payment']=$this->purchaseorder_model->getPaymentTermsDetails(); + //$data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019'); + $data['WorkStatus']=$this->purchaseorder_model->getStatus(7); + - } - - - //print_r($data['WorkStatus']); - // foreach ($data['Suplist'] as $SUP) - // { - // $Detail=$SUP->PaymentTerms; - // } + - //print_r($data['Payment']); - //print_r($data['Suplist']); $SelectedReq = json_decode($this->input->post('txtReqNo')); $Req = $SelectedReq->Req; @@ -166,6 +153,7 @@ class purchaseorder extends BaseController Start here */ $ReqDetails = $this->purchaseorder_model->getRequistDetails($ReqArray); $data['RequistionDetails'] = $ReqDetails; + $CostCode = ''; $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); @@ -191,18 +179,6 @@ class purchaseorder extends BaseController $data['INRSYMBOL']=$this->purchaseorder_model->GetINRCurrencytype('INR'); //print_r($data['INRSYMBOL']); - $AvlimportBudget = $this->purchaseorder_model->GetAvailableImportBudgetAmount($CostCode,$Year,$ReqType); - - //print_r($AvlimportBudget); - - - if(count($AvlimportBudget)>0) - { - $data['AvlimportBudAmt'] = $AvlimportBudget[0]['BudgetAmount'] - $AvlimportBudget[0]['TotalValue']; - } - - //print_r($data['AvlimportBudAmt']); - // $data[$Rate->ExchangeRate]=$Rate->ExchangeRate; //$data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency); @@ -279,34 +255,40 @@ class purchaseorder extends BaseController $ReqType = $_GET['ReqType']; $Req = $this->purchaseorder_model->getRequistionNoFromPO($PONO); + $data['ReqList'] = $Req ; + $result = array(); $ReqArray = array(); foreach ($Req as $SID): $ReqArray[] = $SID->ReqNo ; $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); endforeach; + $data['MaterialList'] = $result;//$this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray); $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); - $data['Payment']=$this->purchaseorder_model->getSupplierPayment('C009'); + + $data['Payment']=$this->purchaseorder_model->getPaymentTermsDetails(); $data['INRSYMBOL']=$this->purchaseorder_model->GetINRCurrencytype('INR'); /* Cost code from Requisition - Client Review Fix Start here */ + $ReqDetails = $this->purchaseorder_model->getRequistDetails($ReqArray); + $data['RequistionDetails'] = $ReqDetails; foreach ($data['RequistionDetails'] as $ReqDet) { $Status=$ReqDet->Status; } - //print_r($Status); + $data['POSTATUS']=$this->purchaseorder_model->GetPOStatus($Status); - //print_r($data['POSTATUS']); + foreach ($data['POSTATUS'] as $POST) { $Status=$POST->StatusName; } - //print_r($Status); + $CostCode = ''; $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $Year = $dt->format('Y'); @@ -331,13 +313,8 @@ class purchaseorder extends BaseController { $PAYTERM=$TER->PaymentTerms; } - // foreach ($data['POMaster'] as $STATUSCODE) - // { - // $STATUSNAME=$STATUSCODE->PaymentTerms; - // } - //print_r($PAYTERM); - //print_r($exRate); - //$data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate(); + + $data['MaxPODate'] = $this->purchaseorder_model->getLastReleasedPODate(); $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); @@ -345,9 +322,11 @@ class purchaseorder extends BaseController { $data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetails($PONO); + $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); //$data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019'); - $data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019'); + + $data['WorkStatus']=$this->purchaseorder_model->getStatus(7); $this->global['pageTitle'] = 'Siddharth : Edit Service Purchase order form'; $this->loadViews("EditservicePurchaseorder", $this->global, $data, NULL); } @@ -362,19 +341,15 @@ class purchaseorder extends BaseController } else if($ReqType == IMPORT) { - $AvlBudget = $this->purchaseorder_model->GetAvailableImportBudgetAmount($CostCode,$Year,$ReqType); - - //print_r($AvlBudget); + $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType); if(count($AvlBudget)>0) { - $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['TotalValue']; + $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; } - //echo $AvlBudAmt; - //print_r($data['AvlBudAmt']); + // print_r($data); $data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetails($PONO); - //print_r($data['POItem']); $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); foreach($data['POMaster'] as $CUR) { @@ -386,7 +361,6 @@ class purchaseorder extends BaseController $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); //print_r($data['PaymentTerms']); $unicode =''; - $currencycode = ''; foreach ($data['CurrencyDetail'] as $Detail) { $unicode=$Detail->FontCode2000; diff --git a/application/controllers/purchaseorder.php~ b/application/controllers/purchaseorder.php~ new file mode 100755 index 00000000..07dd895d --- /dev/null +++ b/application/controllers/purchaseorder.php~ @@ -0,0 +1,2691 @@ +load->model('purchaseorder_model'); + + $this->load->library('session'); + $this->load->library('form_validation'); + $this->load->model('requistion_model'); + $this->isLoggedIn(); + } + + /** + * This function used to load the first screen of the user + */ + public function index() + { + $this->global['pageTitle'] = 'Siddharth : AddPO'; + + $this->loadViews("addPO", $this->global, NULL , NULL); + } + function viewfullpurchaseorder() + { + $this->global['pageTitle'] = 'Siddharth : View Purchase Order'; + + $this->loadViews("viewfullpurchaseorder", $this->global,Null); + + } + function advancerequest() + { + $this->global['pageTitle'] = 'Siddharth : Advance Request'; + + $this->loadViews("advancerequest", $this->global, NULL , NULL); + } + function requisition() + { + $data['DeptList'] = $this->purchaseorder_model->getDepartmentListForAllReq(); + + $data['stList'] = $this->purchaseorder_model->getStatusListforAllReq(); + /* Cost code from Requisition - Client Review Fix + Start here */ + // $data['ReqList'] = $this->purchaseorder_model->getRequistionListbySearch(); + + $data['ReqList'] = $this->purchaseorder_model->getAllRequistionListToCreatePO(); + /* End Here */ + $this->global['pageTitle'] = 'Siddharth : Create PO from Requisition List'; + + $this->loadViews("createPOfromRequistion", $this->global, $data,Null); + } + + + /** + * This function is used to load the purchaseorder list + */ + function PurchaseOrderList() + { + + $this->load->library('pagination'); + + // $count = $this->purchaseorder_model->purchaseorderListingCount(''); + + //$returns = $this->paginationCompress ( "purchaseorderListing/", $count, 10 ); + + $this->purchaseorder_model->UpdateRequistionStatus(); + + $data['POData'] = $this->purchaseorder_model->purchaseorderListing(); + + $this->global['pageTitle'] = 'Siddharth : Purchase Orders'; + + $this->loadViews("POlist", $this->global, $data, NULL); + + } + function Req_validate($selectValue) +{ + //echo 'select_validate method called'; + // 'none' is the first option and the text says something like "-Choose one-" + if(strlen($selectValue) == 0) + { + $this->form_validation->set_message('Req_validate', 'Please Select Requisition Number to Create PO.'); + return false; + } + else // user picked something + { + return true; + } +} + + /** + * This function used to show the Purchase Order Screen + */ + function CreatePurchaseOrder() + { + + $this->form_validation->set_rules('txtReqNo', 'txtReqNo', 'callback_Req_validate'); + + if($this->form_validation->run() == FALSE) + { + $this->requisition(); + + } + else + { + + $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(); + //$data['Payment']=$this->purchaseorder_model->getSupplierPayment('C009'); + $data['Payment']=$this->purchaseorder_model->getPaymentTermsDetails(); + //$data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019'); + $data['WorkStatus']=$this->purchaseorder_model->getStatus(7); + + + + + $SelectedReq = json_decode($this->input->post('txtReqNo')); + + $Req = $SelectedReq->Req; + $data['ReqList'] = $Req ; + $ReqArray = array(); + $ReqType = $this->input->post('txtReqType'); + $result = array(); + + foreach ($Req as $SID): + $ReqArray[] = $SID->ReqNo ; + $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); + if($ReqType == '') + { + $ReqType = $SID->ReqType; + } + + endforeach; + + + $data['MaterialList'] = $result; + //print_r($data['MaterialList']); + /* 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(); + $data['MaxPODate'] = $this->purchaseorder_model->getLastReleasedPODate(); + $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); + $data['INRSYMBOL']=$this->purchaseorder_model->GetINRCurrencytype('INR'); + //print_r($data['INRSYMBOL']); + + + // $data[$Rate->ExchangeRate]=$Rate->ExchangeRate; + //$data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency); + + $ViewName = ''; + if($ReqType == REVENUE) + { + $ViewName = 'purchaseorder'; + } + else if($ReqType == SERVICE) + { + $ViewName = 'servicePurchaseorder'; + } + else if($ReqType == IMPORT) + { + $ViewName = 'importpo'; + } + else if($ReqType == CAPITAL) + { + $ViewName = 'capitalpurchaseorder'; + } + $this->loadViews($ViewName, $this->global,$data, NULL); + } + } + function CreatePOPrint() + { + $PONO = $_GET['PONO']; + $ReqType = $_GET['ReqType']; + + if($ReqType == SERVICE) + { + $this ->servicepoprint($PONO); + + } + else if($ReqType == REVENUE) + { + $this ->revenuepoprint($PONO); + + } + + else if($ReqType == IMPORT) + { + $this ->importpoprint($PONO); + + } + else if($ReqType == CAPITAL) + { + $this ->CapitalPoPrint($PONO); + + } + } + + function CreaterevenuePOPrint() + { + $this->load->View("revenuepopdf", NULL); + } + function CreateservicePOPrint() + { + $this->load->View("servicepopdf", NULL); + } + function CreateimportPOPrint() + { + $this->load->View("importpopdf", NULL); + } + function CreatecapitalPOPrint() + { + $this->load->View("capitalpopdf", NULL); + } + //To View/Update Purchase Order + //To View/Update Purchase Order + function EditPurchaseOrder() + { + $PONO = $_GET['PONO']; + $ReqType = $_GET['ReqType']; + + $Req = $this->purchaseorder_model->getRequistionNoFromPO($PONO); + + $data['ReqList'] = $Req ; + + $result = array(); + $ReqArray = array(); + foreach ($Req as $SID): + $ReqArray[] = $SID->ReqNo ; + $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); + endforeach; + + $data['MaterialList'] = $result;//$this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray); + $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); + + $data['Payment']=$this->purchaseorder_model->getPaymentTermsDetails(); + $data['INRSYMBOL']=$this->purchaseorder_model->GetINRCurrencytype('INR'); + /* Cost code from Requisition - Client Review Fix + Start here */ + + $ReqDetails = $this->purchaseorder_model->getRequistDetails($ReqArray); + + $data['RequistionDetails'] = $ReqDetails; + foreach ($data['RequistionDetails'] as $ReqDet) + { + + $Status=$ReqDet->Status; + } + + $data['POSTATUS']=$this->purchaseorder_model->GetPOStatus($Status); + + foreach ($data['POSTATUS'] as $POST) + { + $Status=$POST->StatusName; + } + + $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['POSTATUS']=$this->purchaseorder_model->GetServicePurchaseOrder($PONO); + //print_r($data['POMaster']); + foreach ($data['POMaster'] as $Exc) + { + $exRate=$Exc->ExchangeRate; + } + foreach ($data['POMaster'] as $TER) + { + $PAYTERM=$TER->PaymentTerms; + } + + + $data['MaxPODate'] = $this->purchaseorder_model->getLastReleasedPODate(); + $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); + $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); + if($ReqType == SERVICE) + { + + $data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetails($PONO); + + $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); + //$data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019'); + + $data['WorkStatus']=$this->purchaseorder_model->getStatus(7); + $this->global['pageTitle'] = 'Siddharth : Edit Service Purchase order form'; + $this->loadViews("EditservicePurchaseorder", $this->global, $data, NULL); + } + else if($ReqType == REVENUE) + { + + $data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetails($PONO); + $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); + //$data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019'); + $this->global['pageTitle'] = 'Siddharth : Edit Revenue Purchase order form'; + $this->loadViews("editRevenuepurchaseorder", $this->global, $data, NULL); + } + else if($ReqType == IMPORT) + { + $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType); + + + if(count($AvlBudget)>0) + { + $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; + } + // print_r($data); + $data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetails($PONO); + $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); + foreach($data['POMaster'] as $CUR) + { + //print_r($CUR->CurrencyType); + $Currency=$CUR->CurrencyType; + } + // $data[$Rate->ExchangeRate]=$Rate->ExchangeRate; + $data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency); + $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); + //print_r($data['PaymentTerms']); + $unicode =''; + foreach ($data['CurrencyDetail'] as $Detail) + { + $unicode=$Detail->FontCode2000; + } + foreach ($data['CurrencyDetail'] as $Detail) + { + $currencycode=$Detail->Currency_Code; + } + //print_r($unicode); + $data['unicode']=$unicode; + $data['currencycode']=$currencycode; + $this->global['pageTitle'] = 'Siddharth : Edit Import Purchase order form'; + $this->loadViews("editimportpo", $this->global, $data, NULL); + } + else if($ReqType == CAPITAL) + { + $CapitalRange = $_GET['CapitalRange']; + + $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType); + + + if(count($AvlBudget)>0) + { + $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; + } + if($CapitalRange=='0'){ + $data['POItem'] = $this->purchaseorder_model->getCapitalPurchaseOrderDetails($PONO); + } + else if($CapitalRange=='1'){ + $data['POItem'] = $this->purchaseorder_model->getDomesticCapitalPurchaseOrderDetails($PONO); + } + $data['requestedBy'] = $this->purchaseorder_model->GetRequesedByDetails($PONO); + + + $CapitalRange=''; + foreach($data['POItem'] as $Rate) + { + $exRate=$Rate->ExchangeRate; + $CapitalRange=$Rate->CapitalRange; + } + foreach($data['POItem'] as $CUR) + { + + $Currency=$CUR->CurrencyType; + } + if($CapitalRange=='0'){ + $data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency); + $data['ExchangeRate']=$exRate; + $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); + } + else if($CapitalRange=='1'){ + $data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail('INR'); + $data['ExchangeRate']=$exRate; + $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); + } + + + $this->global['pageTitle'] = 'Siddharth : Edit Capital Purchase order form'; + $this->loadViews("editCapitalPo", $this->global, $data, NULL); + } + + } + + // To get the Material value based on the MaterialCode + function getDetailsforReq() + { + + + $SearchFilter= $this->input->post('id'); + // $reqDate= $this->input->post('ReqDate'); + $DeptCode = $SearchFilter[0]; + $MatType = $SearchFilter[1]; + $ReqNo = $SearchFilter[2]; + // $ReqDetai = $this->purchaseorder_model->getRequistDetails( $EmpID ); + + $CostList = $this->requistion_model->GetCostCenterByDept( $DeptCode); + + $HTML = ""; + $BudAmount = ""; + if(count($CostList) > 0) + { + for ($j = 0; $j < count($CostList); $j++) + { + $Code = $CostList[$j]['CostCenterCode']; + $Name = $CostList[$j]['CostCenterName']; + $HTML .=""; + } + } + $MaterialDetails = $this->purchaseorder_model->getRawMaterialListForPO($MatType,$ReqNo); + + $HTML1 = ""; + + if(count($MaterialDetails) > 0) + { + for ($j = 0; $j < count($MaterialDetails); $j++) + { + $Code = $MaterialDetails[$j]['MaterialCode']; + $Name = $MaterialDetails[$j]['MaterialName']; + $HTML1 .=""; + + } + + } + // print_r($HTML1); + + die(json_encode(array('MatDetail' =>$HTML1,'Cost'=> $HTML))); + } + /* 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))); + } + + // To get the available Budget Amount + function AvilBudgetAmount() + { + $SearchFilter= $this->input->post('id'); + // $reqDate= $this->input->post('ReqDate'); + $CostCode = $SearchFilter[0]; + $ReqType = $SearchFilter[1]; + print_r($SearchFilter); + $CostCode= $this->input->post('id'); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + + $Year = $dt->format('Y'); + $this->load->model('purchaseorder_model'); + $result = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType); + //print_r($result); + $AvilBudAmt = ''; + if(count($result)>0) + { + $AvilBudAmt = $result[0]['BudgetAmount'] - $result[0]['Totalvalue']; + } + + print_r($AvilBudAmt); + + } + + + function getDateformat($Val) + { + $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'); + + $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']; + $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." + "; + } + die(json_encode(array('ReqList' =>$HTML))); + } + + + /* To View the request details*/ + function ListPORequistion() + { + $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 .=""; + } + } + + die(json_encode(array('Items' =>$HTML,'Requist'=>$ReqList,'Cost'=>$CostCenter))); + } + + //This used to Create Revenue Purchase Order + 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'); + $POType = $this->input->post('POType'); +$DeliveryOption = $this->input->post('DateRange'); + if($DeliveryOption==1){ + $Deliverydt = ''; + $DeliverySchedule = $this->input->post('Scheduleby'); + } + else{ + $Deliverydt = $this->getDateformat($dt); + $DeliverySchedule = ''; + } + + + + $PaymentDate=$this->input->post('Payment'); + if($PaymentDate==1) + { + $PaymentDays='After'; + } + else + { + $PaymentDays='Before'; + } + + $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'); + $DeletedRow = $this->input->post('txtDeletedRow'); + + $comma_separated = explode(':', $DeletedRow); + + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $createddt = $dt->format('Y-m-d H:i:s'); + + $PaymentTerms=$this->input->post('PaymentTerms'); + $Payableat=$this->input->post('PayableAT'); + // PO Master + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'PayableAT'=>$Payableat,'PaymentDays'=>$PaymentDays,'POType'=>$POType); + + + $POMaster = $this->purchaseorder_model->addPOMaster($POList); + + $PONO = ''; + if(count($POMaster)>0) + { + $PONO = $POMaster[0]['PONO']; + } + + // PO Line Items + $LineItemStatus = REQITEM_NEW; + + 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); + $CostCenter = $this->input->post('costCode'.$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") + { + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter); + + $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 'Purchase Order Created Successfully! PO Number Is: '.$PONO ; + + } + //This used to Edit the Revenue Purchase Order + function EditRevenuePurchaseOrder() + { + $PONO =$this->input->post('txtPONO'); + $POdt =$this->input->post('PODate'); + $PODate = $this->getDateformat($POdt); + $SupplierID = $this->input->post('drpSupplier'); + $DeliveryAddr = $this->input->post('txtDeliveryAddress'); + $dt = $this->input->post('Deliverydt'); + //$Deliverydt = $this->getDateformat($dt); + $DeliveryOption = $this->input->post('DateRange'); + if($DeliveryOption==1){ + $Deliverydt = ''; + $DeliverySchedule = $this->input->post('Scheduleby'); + } + else{ + $Deliverydt = $this->getDateformat($dt); + $DeliverySchedule = ''; + } + + + + + $PaymentDate=$this->input->post('Payment'); + if($PaymentDate==1) + { + $PaymentDays='After'; + } + else + { + $PaymentDays='Before'; + } + + $POType = $this->input->post('POType'); + $PoRange = $this->input->post('txtPoRange'); + + $SpcialInstruction = $this->input->post('SpcialInstruction'); + $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); + $POStatus = $this->input->post('txtStatus'); + + $updatedBy = $this->session->userdata ( 'userId' ); + $RowCount = $this->input->post('txtRowCount'); + $DeletedRow = $this->input->post('txtDeletedRow'); + + $comma_separated = explode(':', $DeletedRow); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $updateddt = $dt->format('Y-m-d H:i:s'); + + $PaymentTerms=$this->input->post('PaymentTerms'); + $Payableat=$this->input->post('PayableAT'); + // PO Master + // PO Master + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'UpdateBY'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt,'PaymentTerms'=>$PaymentTerms,'PayableAT'=>$Payableat,'PaymentDays'=>$PaymentDays); + + $POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); + + $LineItemStatus = REQITEM_NEW; + + + + //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); + $POLineItemNo = $this->input->post('LineItemNo'.$i); + $CostCenter = $this->input->post('costCode'.$i); + $LineItemNo = ''; + + + $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") + { + if(strlen($POLineItemNo) == 0) + { + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CostCenterCode'=>$CostCenter); + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + if(count($POLineItem)>0) + { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } + + } + else + { + $LineItemNo = $POLineItemNo; + + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt,'CostCenterCode'=>$CostCenter); + $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$POLineItemNo,$POLineItemList); + + } + $isExists = $this->purchaseorder_model->LineItemExistsinRevenueTax($LineItemNo); + if(count($isExists) == 0) + { + $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'=>$updatedBy,'CreatedDate'=>$updateddt); + + $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList); + + } + else + { + $RevenueTaxList = array('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, 'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt); + + $this->purchaseorder_model->updateRevenueTax($LineItemNo,$RevenueTaxList); + + } + } + + } + + echo 'Purchase Order Updated Successfully! PO Number Is: '.$PONO ; + } + function pageNotFound() + { + $this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found'; + + $this->loadViews("404", $this->global, NULL, NULL); + } + + public function revenuepoprint($PONO) + { + // Load all views as normal + + + //$PONO = $_GET['PO']; + + $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); + $data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetailsForPDF($PONO); + $data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO); + $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR'); + + $Currencycode=''; + + $TotalOrderValue=$data['POItem'][0]->TotalOrderValue; + + $totalAmt=sprintf("%.2f", $TotalOrderValue); + + $data['TotalAmountInWords']= $this->convertNumber($totalAmt); + $data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO); + // Add header to pdf + //$this->load->view('includes/pdfheader'); + + // Load the pdf page with multiviews + $this->load->View("revenuepopdf", $data); + + // Add header to pdf + //$this->load->view('includes/pdffooter'); + + // Get output html + $php = $this->output->get_output(); + + // Load library + $this->load->library('dompdf_gen'); + + // Convert to PDF + $this->dompdf->load_html($php); + $this->dompdf->render(); + $data['Attachment'] = FALSE; + $this->dompdf->stream("RevenuePOReport.pdf",$data,$php); + +} + public function servicepoprint($PONO) + { + + // $this->load->view('includes/pdfheader'); + + // Load the pdf page with multiviews + $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); + $data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetailsForPrint($PONO); + + + $data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO); + + $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR'); + + //print_r( $data['CurrencySymbol']); + + $TotalOrderValue=0; + $Currencycode=''; + foreach ($data['POItem'] as $POValue) + { + + $TotalOrderValue=$TotalOrderValue + $POValue->TotalValue; + + + } + + + + $totalAmt=sprintf("%.2f", $TotalOrderValue); + + $data['TotalAmountInWords']= $this->convertNumber($totalAmt); + + $data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO); + + $this->load->View("servicepopdf", $data); + + // Add header to pdf + //$this->load->view('includes/pdffooter'); + + // Get output html + $php = $this->output->get_output(); + + // Load library + $this->load->library('dompdf_gen'); + + // Convert to PDF + $this->dompdf->load_html($php); + $this->dompdf->render(); + $data['Attachment'] = FALSE; + $this->dompdf->stream("ServicePOReport.pdf",$data,$php); + +} + + +public function importpoprint($PONO) + { + + //$this->load->view('includes/pdfheader'); + + // Load the pdf page with multiviews + $Requester=''; + $Depcode=''; + $Currencycode=''; + $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); + $data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetailsForPDF($PONO); + $data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO); + //print_r( $data['releasedetails']); + foreach ($data['POItem'] as $Reqdby) + { + $Requester=$Reqdby->Requestedby; + + } + + foreach ($data['POItem'] as $CURTYPE) + { + $Currencycode=$CURTYPE->CurrencyType; + } + + $data['Requestername']=$this->purchaseorder_model->GerRequesterName($Requester); + + foreach ($data['Requestername'] as $ReqDep) + { + $Depcode=$ReqDep->Departmentcode; + } + + $data['DEPCODE']=$this->purchaseorder_model->GerRequesterDep($Depcode); + //print_r($data['Requestername']); + $data['Currencytype']=$this->purchaseorder_model->GerCurrencyCodeName($Currencycode); + $ProductPrice=''; + $TotalOrderValue = ''; + foreach ($data['POItem'] as $PO ) + { + $TotalOrderValue=$PO->TotalOrderValue; + } + + //$totalAmt=sprintf("%.2f", $ProductPrice); + //$data['TotalAmountInWords']= $this->convertNumber($totalAmt); + //print_r($data['TotalAmountInWords']); + + //$this->load->View("importpopdf", $data); + + + $CurrencyType=''; + if(!empty($data['POItem'])){ + $CurrencyType=$data['POItem'][0]->CurrencyType; + } + //echo $CurrencyType; + + if($CurrencyType=='') + { + $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR'); + } + else + { + $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName($CurrencyType); + } + + // $TotalOrderValue=$data['POItem'][0]->$TotalOrderValue; + //print_r($data['POItem'][0]); + + $totalAmt=sprintf("%.2f", $TotalOrderValue); + + $data['TotalAmountInWords']= $this->convertNumber($totalAmt); + + + + + $SymbolCurrency = ''; + $SymbolCurrencyName =''; + $PaiseVal = ''; + if(!empty($data['CurrencySymbol']) >0) + { + $SymbolCurrency=$data['CurrencySymbol'][0]->FontCode2000; + $SymbolCurrencyName=$data['CurrencySymbol'][0]->Currency; + $PaiseVal=$data['CurrencySymbol'][0]->PaiseVal; + } + $TotalOrderValue=$data['POItem'][0]->TotalOrderValue; + + $totalAmt=sprintf("%.2f", $TotalOrderValue); + + $data['TotalAmountInWords']= $this->convertNumberSymbol($totalAmt,$SymbolCurrency,$SymbolCurrencyName,$PaiseVal); + + + $this->load->View("importpopdf", $data); + + + // Add header to pdf + //s $this->load->view('includes/pdffooter'); + + // Get output html + $php = $this->output->get_output(); + + // Load library + $this->load->library('dompdf_gen'); + + // Convert to PDF + //$this->dompdf->set_paper(array(0, 0, 841.89, 1190.55), 'landscape'); + $this->dompdf->load_html($php); + $this->dompdf->render(); + $data['Attachment'] = FALSE; + $this->dompdf->stream("ImportPOReport.pdf",$data,$php); + +} + + +/** + * This function used to load the Delete the Requistion Items + */ + function DeletePODetails() + { + + $ReqList= $this->input->post('id'); + $LineItemNo = ''; + $ReqNo =''; + $MaterialCode = ''; + $POType = ''; + if(count($ReqList) > 0) + { + $LineItemNo = $ReqList[0]; + $ReqNo = $ReqList[1]; + $MaterialCode = $ReqList[2]; + $POType = $ReqList[3]; + } + // print_r($ReqList); + + + If($POType == REVENUE) + { + $this->purchaseorder_model->DeletePORevenueTax($LineItemNo); + } + else If($POType == SERVICE) + { + $this->purchaseorder_model->DeletePOServiceTax($LineItemNo); + } + else If($POType == IMPORT) + { + $this->purchaseorder_model->DeletePOImportTax($LineItemNo); + } + else If($POType == CAPITAL) + { + $this->purchaseorder_model->DeletePOImportTax($LineItemNo); + $this->purchaseorder_model->DeletePOServiceTax($LineItemNo); + } + $this->purchaseorder_model->DeletePOLineItem($LineItemNo , $ReqNo,$MaterialCode); + echo "Successfully Deleted the Line item".$LineItemNo; + + } + + + +function addNewImportPurchaseOrder() + {//echo ("ggh"); + + $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'); + //$Dispatchinstruction=$this->post('Dispatch'); + //echo $Dispatchinstruction; + //die(); + //$Schedule=$this->post('Scheduleby'); + $DeliveryOption = $this->input->post('DateRange'); + + //echo $DeliveryOption; + //die(); + $DeliverySchedule=''; + $Dispatch=''; + if($DeliveryOption==1) + { + $Dispatch=''; + $DeliverySchedule = $this->input->post('Scheduleby'); + } + + + else + { + $Dispatch = $this->input->post('Dispatch'); + $DeliverySchedule = ''; + } + + + // $PaymentDate=$this->input->post('Payment'); + // if($PaymentDate==1) + // { + // $PaymentDays='After'; + // } + // else + // { + // $PaymentDays='Before'; + // } + + //echo $PaymentDays; + //die(); + + $SpcialInstruction = $this->input->post('txtSpcialInstruction'); + $TotalOrder = $this->input->post('txtToatlOrder'); + $POStatus = $this->input->post('textStatus'); + //echo "$POStatus"; + //die(); + + $CreateBy = $this->session->userdata ( 'userId' ); + $RowCount = $this->input->post('txtRowCount'); + + $DeletedRow = $this->input->post('txtDeletedRow'); + + $comma_separated = explode(':', $DeletedRow); + + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $createddt = $dt->format('Y-m-d H:i:s'); + $Exchangerate=$this->input->post('ExchangeRate'); + $ExchangeRateCalculatedon=$this->input->post('Exchangerateon'); + $CurrencyType=$this->input->post('currencytype'); + + $PaymentTerms=$this->input->post('PaymentTerms'); + $Palaceoforigin=$this->input->post('PlaceOforigin'); + // $Payableat=$this->input->post('PayableAT'); + + + + // $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'CreatedDate'=>$createddt,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType); + + + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'Import_DispatchDetails'=>$Dispatch,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'Import_PlaceofOrgin'=>$Palaceoforigin); + + //print_r($POList); + //die(); + $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++) + { + //echo "AS"; + $MaterialCode = $this->input->post('materialCode'.$i); + $Quantity = $this->input->post('quantity'.$i); + $Reqnumber = $this->input->post('Reqnumber'.$i); + $itemRate = $this->input->post('itemRate'.$i); + + //$Exchangerate = $this->input->post('Exchangerate'.$i); + $BasicPriceinmton = $this->input->post('BasicPriceinUS'.$i); + $Productprice = $this->input->post('BasicAmt'.$i); + $LandingCharge = $this->input->post('LandingChargee'.$i); + $AfterLandingCharge = $this->input->post('AfterLandingChargee'.$i); + $HighSeas = $this->input->post('Highseass'.$i); + $AfterHighSeas = $this->input->post('AfterHighseass'.$i); + + $CustomDuty = $this->input->post('Customduty'.$i); + $AfterCustomDuty = $this->input->post('AfterCustomduty'.$i); + + $ExciseDuty = $this->input->post('ExcisedutyTax'.$i); + $AfterExciseDuty = $this->input->post('AfterExcisedutyTax'.$i); + $ExciseDutyEd = $this->input->post('ExcisedutyED'.$i); + $AfterExciseDutyEd = $this->input->post('AfterExcisedutyED'.$i); + + $ExciseDutySH = $this->input->post('ExcisedutySH'.$i); + $AfterExciseDutySH = $this->input->post('AfterExcisedutySH'.$i); + + $CustomEd= $this->input->post('CustomEDcess'.$i); + $AfterCustomEd= $this->input->post('AfterCustomEDcess'.$i); + + $CustomSH = $this->input->post('CustomSHcess'.$i); + $AfterCustomSH = $this->input->post('AfterCustomSHcess'.$i); + + $AddAdtional = $this->input->post('AdditionalExciseduty'.$i); + $AfterAddAdtional = $this->input->post('AfterAdditionalExciseduty'.$i); + + $Grossdutypayable = $this->input->post('Grossdutypayable'.$i); + $AvailableModvat = $this->input->post('AvilableModvat'.$i); + $Grossexpensesduetocustomduty = $this->input->post('Grossexpenses'.$i); + $purchaseratePerKG = $this->input->post('purchaserate'.$i); + $CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpenses'.$i); + $RMCIncludingCustomersPerKG = $this->input->post('RMCIncludingCustomers'.$i); + $QuantityKG = $this->input->post('PurQuantity'.$i); + + //$currencytypeID = $this->input->post('currencytype'); + $Totalvalueitem=$this->input->post('TotalExp'.$i); + + //echo $BasicPriceinmton; + $CostCenter = $this->input->post('costCode'.$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") + { + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter); + + //print_r($POLineItemList); + //die(); + + + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + + $LineItemNo = ''; + if(count($POLineItem)>0) + { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } + //echo $LineItemNo; + + if(trim($POType) == IMPORT ) + { + // echo 'Success'; + $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem); + //print_r($ImportTaxList); + //die(); + + + $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); + + } + } + + } + echo 'Purchase Order Created Successfully! PO Number Is: '.$PONO ; + } + + + function EditImportPurchaseOrder() + { + + //echo "dfds"; + //die(); + $PONO =$this->input->post('txtPONO'); +$POdt = ''; +$createddt=''; + + $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'); + //$DeliveryOption = $this->input->post('DateRange'); + + $Exchangerate=$this->input->post('ExchangeRate'); + $ExchangeRateCalculatedon=$this->input->post('Exchangerateon'); + $CurrencyType=$this->input->post('currencytype'); + + $DeliveryOption = $this->input->post('DateRange'); + + //echo $DeliveryOption; + //die(); + $DeliverySchedule=''; + $Dispatch=''; + if($DeliveryOption==1) + { + $Dispatch=''; + $DeliverySchedule = $this->input->post('Scheduleby'); + } + + + else + { + $Dispatch = $this->input->post('Dispatch'); + $DeliverySchedule = ''; + } + + + // if($DeliveryOption==1){ + // $Deliverydt = ''; + // $DeliverySchedule = $this->input->post('Scheduleby'); + // } + // else{ + // $Deliverydt = $this->getDateformat($dt); + // $DeliverySchedule = ''; + // } + // $PaymentDate=$this->input->post('Payment'); + // if($PaymentDate==1) + // { + // $PaymentDays='After'; + // } + // else + // { + // $PaymentDays='Before'; + // } + + $SpcialInstruction = $this->input->post('txtSpcialInstruction'); + $TotalOrder = $this->input->post('txtToatlOrder'); + //echo $TotalOrder; + //die(); + $POStatus = $this->input->post('txtStatus'); + + $CreateBy = $this->session->userdata ( 'userId' ); + $RowCount = $this->input->post('txtRowCount'); + $DeletedRow = $this->input->post('txtDeletedRow'); + + $comma_separated = explode(':', $DeletedRow); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $updateddt = $dt->format('Y-m-d H:i:s'); + + $PaymentTerms=$this->input->post('PaymentTerms'); + + $Palaceoforigin=$this->input->post('PlaceOforigin'); + // $Payableat=$this->input->post('PayableAT'); + // PO Master + // PO Master + // $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$updateddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms); + + + + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'Import_DispatchDetails'=>$Dispatch,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'Import_PlaceofOrgin'=>$Palaceoforigin); + //echo $PONO; + //echo $TotalOrder; + //print_r($POList); + //die(); + + $POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); + //echo "sdasds"; + $LineItemStatus = REQITEM_NEW; + //echo $LineItemStatus; + + + + //echo $RowCount; + for ($i = 1; $i <= $RowCount; $i++) + { + + $MaterialCode = $this->input->post('materialCode'.$i); + + $Quantity = $this->input->post('quantity'.$i); + //echo $Quantity; + $Reqnumber = $this->input->post('Reqnumber'.$i); + $itemRate = $this->input->post('itemRate'.$i); + ; + //die(); + + //$Exchangerate = $this->input->post('Exchangerate'.$i); + $BasicPriceinmton = $this->input->post('BasicPriceInMTon'.$i); + $Productprice = $this->input->post('TotalValue'.$i); + //echo $ProductPrice; + //die(); + $LandingCharge = $this->input->post('LandingCharge'.$i); + $AfterLandingCharge = $this->input->post('AfterLandingCharge'.$i); + $HighSeas = $this->input->post('HighSeasSalesCharge'.$i); + $AfterHighSeas = $this->input->post('AfterHighSeasSalesCharge'.$i); + + $CustomDuty = $this->input->post('CustomDuty'.$i); + $AfterCustomDuty = $this->input->post('AfterCustomDuty'.$i); + + $ExciseDuty = $this->input->post('ExciseDuty'.$i); + $AfterExciseDuty = $this->input->post('AfterExciseDuty'.$i); + $ExciseDutyEd = $this->input->post('ExciseDutyEdCess'.$i); + $AfterExciseDutyEd = $this->input->post('AfterExciseDutyEdCess'.$i); + + $ExciseDutySH = $this->input->post('ExciseDutySHCess'.$i); + $AfterExciseDutySH = $this->input->post('AfterExciseDutySHCess'.$i); + + $CustomEd= $this->input->post('CustomEdCess'.$i); + $AfterCustomEd= $this->input->post('AfterCustomEdCess'.$i); + + $CustomSH = $this->input->post('CustomSHCess'.$i); + $AfterCustomSH = $this->input->post('AfterCustomSHCess'.$i); + + $AddAdtional = $this->input->post('AddlExciseDuty'.$i); + $AfterAddAdtional = $this->input->post('AfterAddlExciseDuty'.$i); + + $Grossdutypayable = $this->input->post('Grossdutypayable'.$i); + //echo $Grossdutypayable; + //die(); + + $AvailableModvat = $this->input->post('AvailableModvat'.$i); + + $Grossexpensesduetocustomduty = $this->input->post('Grossexpensesduetocustomduty'.$i); + + + $purchaseratePerKG = $this->input->post('purchaseratePerKG'.$i); + + $CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpensesPerKG'.$i); + + $RMCIncludingCustomersPerKG = $this->input->post('RMCIncludingCustomersPerKG'.$i); + + $QuantityKG = $this->input->post('QuantityKG'.$i); + + $POLineItemNo = $this->input->post('LineItemNo'.$i); + + $CostCenter = $this->input->post('costCode'.$i); + + //$ExciseDutySH = $this->input->post('ExcisedutySH'.$i); + $Totalvalueitem=$this->input->post('TotalValue'.$i); + // echo $Totalvalueitem; + //die(); + $LineItemNo = ''; + //echo "sdsfsd"; + //die(); + + $currencytypeID = $this->input->post('currencytype'); + $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") + { + if(strlen($POLineItemNo) == 0) + { + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter); + $POLineItem=$this->purchaseorder_model->addPOLineItem($POLineItemList); + if(count($POLineItem)>0) + { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } + + } + else + { + + + + $LineItemNo = $POLineItemNo; + //echo $LineItemNo; + //die(); + + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'UpdatedOn'=>$updateddt,'CostCenterCode'=>$CostCenter); + $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$POLineItemNo,$POLineItemList); + + } + $isExists = $this->purchaseorder_model->LineItemExistsinImportTax($LineItemNo); + //echo $isExists; + + //die(); + if(count($isExists) == 0) + { + print_r(count($isExists)); + //echo $isExists; + //die(); + $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'UpdatedOn'=>$updateddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem); + + + //print_r($ImportTaxList); + //die(); + $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); + + } + else + { + //echo "xxcx"; + //die(); + $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'UpdatedOn'=>$updateddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem); + //echo "cxvc "; + //die(); + //print_r($ImportTaxList); + //die(); + $this->purchaseorder_model->updateImportTax($LineItemNo,$ImportTaxList); + + + } + } + + } + + + echo 'Purchase Order Updated Successfully! PO Number Is: '.$PONO ; + } + + + + /* All Function following This command for FINANCE TEAM PO APPROVAL SCREEN*/ + function poapproval(){ + $q="A"; + $this->global['pageTitle'] = 'Siddharth : Purchase Order Approval'; + // $data['Status']= $this->purchaseorder_model->getStatus(); + $userID = $this->session->userdata ( 'userId' ); + //print_r($data['Status']);echo "CON"; + $data['AppList'] = $this->purchaseorder_model->getPOList($q); + $this->loadViews("poapproval_view", $this->global,$data, NULL); + + } + + function getDateformat2($Val) + { + $date = new DateTime($Val); + $retDate = $date->format('Y-m-d H:i:s'); + return $retDate; + } + + + function ApprovePO() + { + $StatusCode= Trim($_POST['SCode']); + + $PONO= Trim($_POST['PONO']); + $Remarks= Trim($_POST['NewRemarks']); + + $ApprovedBy = $this->session->userdata ( 'userId' ); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $ApprovedDate = $dt->format('Y-m-d H:i:s'); + + if($StatusCode == 'ST025') + { + + $store = array('Status'=>$StatusCode,'ApprovedOn'=>$ApprovedDate,'Approvedby'=>$ApprovedBy,'Remarks'=>$Remarks); + $this->purchaseorder_model->UpdatePO($store,$PONO); + echo "Successfully Approve the Purchase Order No: ".$PONO; + } + else{ + $store = array('Status'=>$StatusCode,'OnHoldOn'=>$ApprovedDate,'OnHoldBy'=>$ApprovedBy,'Remarks'=>$Remarks); + $this->purchaseorder_model->UpdatePO($store,$PONO); + echo "The Purchase Order No: ".$PONO ."is On Hold"; + + } + + + + + } + + + + + /* FOLLOWING CODES FOR PO RELEASE SCREEN FUNCTIONALITIES*/ + + + function porelease(){ + + $q="R"; + $this->global['pageTitle'] = 'Siddharth : Purchase Order Release'; + // $data['Status']= $this->purchaseorder_model->getStatus(); + $userID = $this->session->userdata ( 'userId' ); + //print_r($data['Status']);echo "CON"; + $data['AppList'] = $this->purchaseorder_model->getPOList($q); + $this->loadViews("porelease_view", $this->global,$data, NULL); + + } + + + function ReleasePO() + { + $StatusCode= Trim($_POST['SCode']); + + $PONO= Trim($_POST['PONO']); + $Remarks= Trim($_POST['NewRemarks']); + + $ReleasedBy = $this->session->userdata ( 'userId' ); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $ReleasedDate = $dt->format('Y-m-d H:i:s'); + + if($StatusCode == 'ST026') + { + + $store = array('Status'=>$StatusCode,'ReleasedOn'=>$ReleasedDate,'ReleasedBy'=>$ReleasedBy,'Remarks'=>$Remarks); + $this->purchaseorder_model->UpdatePO($store,$PONO); + echo "Successfully Released the Purchase Order No: ".$PONO; + } + else{ + $store = array('Status'=>$StatusCode,'OnHoldOn'=>$ReleasedDate,'OnHoldBy'=>$ReleasedBy,'Remarks'=>$Remarks); + $this->purchaseorder_model->UpdatePO($store,$PONO); + echo "The Purchase Order No: ".$PONO ."is On Hold"; + + } +} +/* Add capital Po*/ + function addNewCapitalPurchaseOrder() + { + + + $POdt =$this->input->post('PODate'); + $PODate = $this->getDateformat($POdt); + $SupplierID = $this->input->post('drpSupplier'); + $DeliveryAddr = $this->input->post('DeliveryAddr'); + $dt = $this->input->post('Deliverydt'); + + $POType = $this->input->post('POType'); + $PoRange = $this->input->post('txtPoRange'); + + $DeliveryOption = $this->input->post('DateRange'); + if($DeliveryOption==1){ + $Deliverydt = ''; + $DeliverySchedule = $this->input->post('Scheduleby'); + } + else{ + $Deliverydt = $this->getDateformat($dt); + $DeliverySchedule = ''; + } + $capitalType = $this->input->post('capitalType'); + if($capitalType=='Domestic'){ + $CapitalRange = '1'; + $ExchangeRateOn = ''; + $ExchangeRate=''; + } + else{ + + $CapitalRange = '0'; + $ExchangeRateOn = $this->input->post('ExchangeRateOn'); + $ExchangeRate=$this->input->post('ExchangeRt'); + } + + $PaymentMethod = $this->input->post('PaymentMethod'); + $PayableAT = $this->input->post('PayableAT'); + + + $PaymentDate=$this->input->post('PaymentDate'); + $SpcialInstruction = $this->input->post('txtSpcialInstruction'); + $TotalOrder = $this->input->post('CapitalToatlOrder'); + $POStatus = $this->input->post('txtStatus'); + + + $CreateBy = $this->session->userdata ( 'userId' ); + $RowCount = $this->input->post('txtRowCount'); + + $DeletedRow = $this->input->post('txtDeletedRow'); + + $comma_separated = explode(':', $DeletedRow); + + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $createddt = $dt->format('Y-m-d H:i:s'); + $currencytypeID = $this->input->post('currencytype'); + + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ExchangeRateCalculatedon'=>$ExchangeRateOn,'ExchangeRate'=>$ExchangeRate,'PaymentTerms'=>$PaymentMethod,'PaymentDays'=>$PaymentDate,'PayableAt'=>$PayableAT,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'CapitalRange'=>$CapitalRange,'POType'=>$POType,'CurrencyType'=>$currencytypeID); + + + $POMaster = $this->purchaseorder_model->addPOMaster($POList); + + $PONO = ''; + if(count($POMaster)>0) + { + $PONO = $POMaster[0]['PONO']; + } + + $LineItemStatus = REQITEM_NEW; + + 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); + + + $BasicPriceinmton = $this->input->post('rateInUs'.$i); + $Productprice = $this->input->post('basicvalInINR'.$i); + $LandingCharge = $this->input->post('beforeLanding'.$i); + $AfterLandingCharge = $this->input->post('landingCharge'.$i); + $HighSeas = $this->input->post('beforeHighSeasSalesCharge'.$i); + $AfterHighSeas = $this->input->post('HighSeasSalesCharge'.$i); + + $CustomDuty = $this->input->post('beforeCustomDuty'.$i); + $AfterCustomDuty = $this->input->post('CustomDuty'.$i); + + $ExciseDuty = $this->input->post('beforeExciseDuty'.$i); + $AfterExciseDuty = $this->input->post('ExciseDuty'.$i); + $ExciseDutyEd = $this->input->post('beforeExciseDutyEDCess'.$i); + $AfterExciseDutyEd = $this->input->post('ExciseDutyEDCess'.$i); + + $ExciseDutySH = $this->input->post('beforeExciseDutySHCess'.$i); + $AfterExciseDutySH = $this->input->post('ExciseDutySHCess'.$i); + + $CustomEd= $this->input->post('beforeCustomEDCess'.$i); + $AfterCustomEd= $this->input->post('CustomEDCess'.$i); + + $CustomSH = $this->input->post('beforeCustomSHCess'.$i); + $AfterCustomSH = $this->input->post('CustomSHCess'.$i); + + $AddAdtional = $this->input->post('beforeAdditionalExciseDuty'.$i); + $AfterAddAdtional = $this->input->post('AdditionalExciseDuty'.$i); + + $Grossdutypayable = $this->input->post('GrossDutyPayable'.$i); + $AvailableModvat = $this->input->post('AvailableModvat'.$i); + $Grossexpensesduetocustomduty = $this->input->post('GrossExpensesDuetoCustom'.$i); + $purchaseratePerKG = $this->input->post('purchaseRate'.$i); + $CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpenses'.$i); + $RMCIncludingCustomersPerKG = $this->input->post('RMCIncludingCustomers'.$i); + $QuantityKG = $this->input->post('PurQuantity'.$i); + + + $Totalvalueitem=$this->input->post('PerKgExpense'.$i); + + //echo $BasicPriceinmton; + $CostCenter = $this->input->post('CPCostCode'.$i); + $ServiceTax = $this->input->post('AfterServiceTax'.$i); + $EduCess = $this->input->post('AfterEduCess'.$i); + $SecHighTax = $this->input->post('AfterSecHighTax'.$i); + $KrishiTax = $this->input->post('AfterKrishiTax'.$i); + $SwachhTax = $this->input->post('AfterSwachhTax'.$i); + + + $TotalOrderValue = $this->input->post('TotalOrderValue'.$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") + { + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter); + + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + + $LineItemNo = ''; + if(count($POLineItem)>0) + { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } + //echo $LineItemNo; + + if(trim($POType) == CAPITAL ) + { + $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt); + + $ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList); + if($CapitalRange=='0'){ + $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem); + + + $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); + } + + + } + } + + } + echo 'Purchase Order Created Successfully! PO Number Is: '.$PONO ; + } + + +/*Edit Capital po*/ + function EditCapitalPurchaseOrder() + { + + + $PONO =$this->input->post('txtPONO'); + $POdt =$this->input->post('PODate'); + $PODate = $this->getDateformat($POdt); + $SupplierID = $this->input->post('drpSupplier'); + $DeliveryAddr = $this->input->post('DeliveryAddr'); + $dt = $this->input->post('Deliverydt'); + + $POType = $this->input->post('POType'); + $PoRange = $this->input->post('txtPoRange'); + + $DeliveryOption = $this->input->post('DateRange'); + if($DeliveryOption==1){ + $Deliverydt = ''; + $DeliverySchedule = $this->input->post('Scheduleby'); + } + else{ + $Deliverydt = $this->getDateformat($dt); + $DeliverySchedule = ''; + } + + $capitalType = $this->input->post('capitalType'); + $currencytypeID = $this->input->post('currencytype'); + if($capitalType=='1'){ + $CapitalRange = '1'; + $ExchangeRateOn = ''; + $ExchangeRate=''; + + } + else{ + + $CapitalRange = '0'; + $ExchangeRateOn = $this->input->post('ExchangeRateOn'); + $ExchangeRate=$this->input->post('ExchangeRt'); + } + $PaymentMethod = $this->input->post('PaymentMethod'); + $PayableAT = $this->input->post('PayableAT'); + + + $PaymentDate=$this->input->post('PaymentDate'); + $SpcialInstruction = $this->input->post('txtSpcialInstruction'); + $TotalOrder = $this->input->post('CapitalToatlOrder'); + $POStatus = $this->input->post('txtStatus'); + + + $CreateBy = $this->session->userdata ( 'userId' ); + $RowCount = $this->input->post('txtRowCount'); + + $DeletedRow = $this->input->post('txtDeletedRow'); + + $comma_separated = explode(':', $DeletedRow); + + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $createddt = $dt->format('Y-m-d H:i:s'); + $updateddt = $dt->format('Y-m-d H:i:s'); + + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ExchangeRate'=>$ExchangeRate,'ExchangeRateCalculatedon'=>$ExchangeRateOn,'PaymentTerms'=>$PaymentMethod,'PaymentDays'=>$PaymentDate,'PayableAt'=>$PayableAT,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'CurrencyType'=>$currencytypeID); + + + $POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); + + $LineItemStatus = REQITEM_NEW; + + + + + 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); + + $Exchangerate = $this->input->post('echangeRate'.$i); + $BasicPriceinmton = $this->input->post('rateInUs'.$i); + $Productprice = $this->input->post('basicvalInINR'.$i); + $LandingCharge = $this->input->post('beforeLanding'.$i); + $AfterLandingCharge = $this->input->post('landingCharge'.$i); + $HighSeas = $this->input->post('beforeHighSeasSalesCharge'.$i); + $AfterHighSeas = $this->input->post('HighSeasSalesCharge'.$i); + + $CustomDuty = $this->input->post('beforeCustomDuty'.$i); + $AfterCustomDuty = $this->input->post('CustomDuty'.$i); + + $ExciseDuty = $this->input->post('beforeExciseDuty'.$i); + $AfterExciseDuty = $this->input->post('ExciseDuty'.$i); + $ExciseDutyEd = $this->input->post('beforeExciseDutyEDCess'.$i); + $AfterExciseDutyEd = $this->input->post('ExciseDutyEDCess'.$i); + + $ExciseDutySH = $this->input->post('beforeExciseDutySHCess'.$i); + $AfterExciseDutySH = $this->input->post('ExciseDutySHCess'.$i); + + $CustomEd= $this->input->post('beforeCustomEDCess'.$i); + $AfterCustomEd= $this->input->post('CustomEDCess'.$i); + + $CustomSH = $this->input->post('beforeCustomSHCess'.$i); + $AfterCustomSH = $this->input->post('CustomSHCess'.$i); + + $AddAdtional = $this->input->post('beforeAdditionalExciseDuty'.$i); + $AfterAddAdtional = $this->input->post('AdditionalExciseDuty'.$i); + + $Grossdutypayable = $this->input->post('GrossDutyPayable'.$i); + $AvailableModvat = $this->input->post('AvailableModvat'.$i); + $Grossexpensesduetocustomduty = $this->input->post('GrossExpensesDuetoCustom'.$i); + $purchaseratePerKG = $this->input->post('purchaseRate'.$i); + $CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpenses'.$i); + $RMCIncludingCustomersPerKG = $this->input->post('RMCIncludingCustomers'.$i); + $QuantityKG = $this->input->post('PurQuantity'.$i); + + + $Totalvalueitem=$this->input->post('PerKgExpense'.$i); + + //echo $BasicPriceinmton; + $CostCenter = $this->input->post('CPCostCode'.$i); + $ServiceTax = $this->input->post('AfterServiceTax'.$i); + $EduCess = $this->input->post('AfterEduCess'.$i); + $SecHighTax = $this->input->post('AfterSecHighTax'.$i); + $KrishiTax = $this->input->post('AfterKrishiTax'.$i); + $SwachhTax = $this->input->post('AfterSwachhTax'.$i); + + + $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); + $POLineItemNo = $this->input->post('LineItemNo'.$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") + { + if(strlen($POLineItemNo) == 0) + { + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter); + + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + + $LineItemNo = ''; + if(count($POLineItem)>0) + { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } + //echo $LineItemNo; + + if(trim($POType) == CAPITAL ) + { + $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt); + + $ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList); + $ImportTaxList = array('LineItemNo'=>$LineItemNo, 'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem); + //print_r($ImportTaxList); + //die(); + + + $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); + + } + + } + else + { + $LineItemNo = $POLineItemNo; + + + + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter); + $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$LineItemNo,$POLineItemList); + + $ServiceTaxList = array('ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt); + + $ServiceTax = $this->purchaseorder_model->updateServiceTax($LineItemNo,$ServiceTaxList); + $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem); + $ImportList= $this->purchaseorder_model->updateImportTax($LineItemNo,$ImportTaxList); + + } + + } + + } + + echo 'Purchase Order Updated Successfully! PO Number Is: '.$PONO ; + } + + /* capital po print/pdf*/ + + public function CapitalPoPrint($PONO) + { + + + // Load the pdf page with multiviews + $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); + + $data['POItem'] = $this->purchaseorder_model->GetCapitalPurchaseOrderDetailsForPDF($PONO); + + $data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO); + + $CurrencyType=''; + if(!empty($data['POItem'])){ + $CurrencyType=$data['POItem'][0]->CurrencyType; + } + + + if($CurrencyType=='' OR $CurrencyType=='0'){ + $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR'); + + $TotalOrderValue=$data['POItem'][0]->TotalOrderValue; + + $totalAmt=sprintf("%.2f", $TotalOrderValue); + + $data['TotalAmountInWords']= $this->convertNumber($totalAmt); + } + + + else{ + $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName($CurrencyType); + $SymbolCurrency=$data['CurrencySymbol'][0]->FontCode2000; + $SymbolCurrencyName=$data['CurrencySymbol'][0]->Currency; + $PaiseVal=$data['CurrencySymbol'][0]->PaiseVal; + + $TotalOrderValue=$data['POItem'][0]->TotalOrderValue; + + $totalAmt=sprintf("%.2f", $TotalOrderValue); + + $data['TotalAmountInWords']= $this->convertNumberSymbol($totalAmt,$SymbolCurrency,$SymbolCurrencyName,$PaiseVal); + } + + + + + + + $data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO); + + + + $this->load->View("capitalpopdf", $data); + + // Add header to pdf + //$this->load->view('includes/pdffooter'); + + // Get output html + $php = $this->output->get_output(); + + // Load library + $this->load->library('dompdf_gen'); + + // Convert to PDF + $this->dompdf->load_html($php); + $this->dompdf->render(); + $data['Attachment'] = FALSE; + $this->dompdf->stream("CapitalPOReport.pdf",$data,$php); + +} + + /*This function is used to convert amount(digit) into words*/ + + public function convertNumber($number) + +{ + + list($integer, $fraction) = explode(".", (string) $number); + + $output = "Rupee"." "; + + if ($integer{0} == "-") + + { + + $output = "negative "; + + $integer = ltrim($integer, "-"); + + } + + else if ($integer{0} == "+") + + { + + $output = "positive "; + + $integer = ltrim($integer, "+"); + + } + + if ($integer{0} == "0") + + { + + $output .= "zero"; + + } + + else + + { + + $integer = str_pad($integer, 36, "0", STR_PAD_LEFT); + + $group = rtrim(chunk_split($integer, 3, " "), " "); + + $groups = explode(" ", $group); + + $groups2 = array(); + + foreach ($groups as $g) + + { + + $groups2[] = $this->convertThreeDigit($g{0}, $g{1}, $g{2}); + + } + + for ($z = 0; $z < count($groups2); $z++) + + { + + if ($groups2[$z] != "") + + { + + $output .= $groups2[$z] . $this->convertGroup(11 - $z) . ( + + $z < 11 + + && !array_search('', array_slice($groups2, $z + 1, -1)) + + && $groups2[11] != '' + + && $groups[11]{0} == '0' + + ? " " + + : ", " + + ); + + } + + } + + $output = rtrim($output, ", "); + + } + + if ($fraction > 0) + + { + + $output .= " paise"; + + for ($i = 0; $i < strlen($fraction); $i++) + + { + + $output .= " " . $this->convertDigit($fraction{$i}); + + } + + } + + return $output; + +} + /* get symbol based amount in words*/ + + + public function convertNumberSymbol($number,$symbol,$name,$paise) + +{ + + list($integer, $fraction) = explode(".", (string) $number); + + $output = $name." "; + + if ($integer{0} == "-") + + { + + $output = "negative "; + + $integer = ltrim($integer, "-"); + + } + + else if ($integer{0} == "+") + + { + + $output = "positive "; + + $integer = ltrim($integer, "+"); + + } + + if ($integer{0} == "0") + + { + + $output .= "zero"; + + } + + else + + { + + $integer = str_pad($integer, 36, "0", STR_PAD_LEFT); + + $group = rtrim(chunk_split($integer, 3, " "), " "); + + $groups = explode(" ", $group); + + $groups2 = array(); + + foreach ($groups as $g) + + { + + $groups2[] = $this->convertThreeDigit($g{0}, $g{1}, $g{2}); + + } + + for ($z = 0; $z < count($groups2); $z++) + + { + + if ($groups2[$z] != "") + + { + + $output .= $groups2[$z] . $this->convertGroup(11 - $z) . ( + + $z < 11 + + && !array_search('', array_slice($groups2, $z + 1, -1)) + + && $groups2[11] != '' + + && $groups[11]{0} == '0' + + ? " " + + : ", " + + ); + + } + + } + + $output = rtrim($output, ", "); + + } + + if ($fraction > 0) + + { + + $output .= $paise; + + for ($i = 0; $i < strlen($fraction); $i++) + + { + + $output .= " " . $this->convertDigit($fraction{$i}); + + } + + } + + return $output; + +} +public function convertGroup($index) + +{ + + switch ($index) + + { + + case 11: + + return " decillion"; + + case 10: + + return " nonillion"; + + case 9: + + return " octillion"; + + case 8: + + return " septillion"; + + case 7: + + return " sextillion"; + + case 6: + + return " quintrillion"; + + case 5: + + return " quadrillion"; + + case 4: + + return " trillion"; + + case 3: + + return " billion"; + + case 2: + + return " million"; + + case 1: + + return " thousand"; + + case 0: + + return ""; + + } + +} + +public function convertThreeDigit($digit1, $digit2, $digit3) + +{ + + $buffer = ""; + + if ($digit1 == "0" && $digit2 == "0" && $digit3 == "0") + + { + + return ""; + + } + + if ($digit1 != "0") + + { + + $buffer .= $this->convertDigit($digit1) . " hundred"; + + if ($digit2 != "0" || $digit3 != "0") + + { + + $buffer .= " and "; + + } + + } + + if ($digit2 != "0") + + { + + $buffer .= $this->convertTwoDigit($digit2, $digit3); + + } + + else if ($digit3 != "0") + + { + + $buffer .= $this->convertDigit($digit3); + + } + + return $buffer; + +} + +public function convertTwoDigit($digit1, $digit2) + +{ + + if ($digit2 == "0") + + { + + switch ($digit1) + + { + + case "1": + + return "ten"; + + case "2": + + return "twenty"; + + case "3": + + return "thirty"; + + case "4": + + return "forty"; + + case "5": + + return "fifty"; + + case "6": + + return "sixty"; + + case "7": + + return "seventy"; + + case "8": + + return "eighty"; + + case "9": + + return "ninety"; + + } + + } else if ($digit1 == "1") + + { + + switch ($digit2) + + { + + case "1": + + return "eleven"; + + case "2": + + return "twelve"; + + case "3": + + return "thirteen"; + + case "4": + + return "fourteen"; + + case "5": + + return "fifteen"; + + case "6": + + return "sixteen"; + + case "7": + + return "seventeen"; + + case "8": + + return "eighteen"; + + case "9": + + return "nineteen"; + + } + + } else + + { + + $temp = $this->convertDigit($digit2); + + switch ($digit1) + + { + + case "2": + + return "twenty-$temp"; + + case "3": + + return "thirty-$temp"; + + case "4": + + return "forty-$temp"; + + case "5": + + return "fifty-$temp"; + + case "6": + + return "sixty-$temp"; + + case "7": + + return "seventy-$temp"; + + case "8": + + return "eighty-$temp"; + + case "9": + + return "ninety-$temp"; + + } + + } + +} + +public function convertDigit($digit) + +{ + + switch ($digit) + + { + + case "0": + + return "zero"; + + case "1": + + return "one"; + + case "2": + + return "two"; + + case "3": + + return "three"; + + case "4": + + return "four"; + + case "5": + + return "five"; + + case "6": + + return "six"; + + case "7": + + return "seven"; + + case "8": + + return "eight"; + + case "9": + + return "nine"; + + } + +} + + + +} + +?> diff --git a/application/controllers/requisitionform.php b/application/controllers/requisitionform.php index f152bc36..a45f0e60 100755 --- a/application/controllers/requisitionform.php +++ b/application/controllers/requisitionform.php @@ -52,7 +52,7 @@ class requisitionform extends BaseController $data['RequestType'] = $this->requistion_model->getConfigValue('C020'); $data['EmpList'] = $this->requistion_model->getAllEmployees(); - + $data['ServiceOption'] = $this->requistion_model->getConfigValue('C022'); $userID = $this->session->userdata ( 'userId' ); $data['Emp'] = $this->requistion_model->getEmpIdByUserID($userID); @@ -99,7 +99,7 @@ class requisitionform extends BaseController $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); } @@ -283,8 +283,8 @@ class requisitionform extends BaseController * This function is used to add new Cost to the system */ function addNewRequistion() - { - + { + $this->form_validation->set_rules('RequestType','RequestType','trim|required'); $this->form_validation->set_rules('EmpID','EmpID','trim|required'); @@ -294,9 +294,9 @@ class requisitionform extends BaseController } else { - $Status= $_GET['ID']; - $RequestType = strtoupper(trim($this->input->post('RequestType'))); - $Requestedby = strtoupper(trim($this->input->post('EmpID'))); + $Status= $_GET['ID']; + $RequestType = strtoupper(trim($this->input->post('RequestType'))); + $Requestedby = strtoupper(trim($this->input->post('EmpID'))); $CostCenter = $this->input->post('CostCenter'); $CreateBy = $this->session->userdata ( 'userId' ); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); @@ -306,7 +306,9 @@ class requisitionform extends BaseController $RowCount = $this->input->post('txtRowCount'); $comma_separated = explode(':', $DeletedRow); - + $serviceSchedule = $this->input->post('serviceSchedule'); + $servicePeriod = $this->input->post('servicePeriod'); + $noOfService = $this->input->post('noOfService'); $IsExists = $this->requistion_model->RequistionIsExists($Requestedby); // print_r($IsExists); @@ -314,7 +316,7 @@ class requisitionform extends BaseController if(count( $IsExists) == 0) { //echo 'Not Exists'; - $Request = array('ReqType'=>$RequestType, 'Requestedby'=>$Requestedby,'ReqDate'=>$createddt,'CostCenterCode'=>$CostCenter,'Status'=>$Status,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy); + $Request = array('ReqType'=>$RequestType, 'Requestedby'=>$Requestedby,'ReqDate'=>$createddt,'CostCenterCode'=>$CostCenter,'Status'=>$Status,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy,'Schedule_Type'=>$serviceSchedule,'NumberOfService'=>$noOfService,'Service_Period'=>$servicePeriod); //print_r($Request); @@ -323,7 +325,7 @@ class requisitionform extends BaseController else { //echo 'Exists'; - $Request = array('ReqType'=>$RequestType, 'Requestedby'=>$Requestedby,'ReqDate'=>$createddt,'Status'=>$Status,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy,'CostCenterCode'=>$CostCenter); + $Request = array('ReqType'=>$RequestType, 'Requestedby'=>$Requestedby,'ReqDate'=>$createddt,'Status'=>$Status,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy,'CostCenterCode'=>$CostCenter,'Schedule_Type'=>$serviceSchedule,'NumberOfService'=>$noOfService,'Service_Period'=>$servicePeriod); $UpdateReq = $this->requistion_model->UpdateRequistion($Request,$IsExists[0]['ReqNo']); } $ReqNumber = ''; @@ -388,15 +390,17 @@ class requisitionform extends BaseController $DeletedRow = $this->input->post('txtDeletedRow'); $RowCount = $this->input->post('txtRowCount'); - + $serviceSchedule = $this->input->post('serviceSchedule'); + $servicePeriod = $this->input->post('servicePeriod'); + $noOfService = $this->input->post('noOfService'); if(strlen($Status) > 1) { - $Request = array( 'Status'=>$Status,'CreatedDate'=>$updatedDate,'CreatedBy'=>$UpdatedBy,'CostCenterCode'=>$CostCenter); + $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); + $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); } diff --git a/application/controllers/requisitionform.php~ b/application/controllers/requisitionform.php~ new file mode 100755 index 00000000..a45f0e60 --- /dev/null +++ b/application/controllers/requisitionform.php~ @@ -0,0 +1,542 @@ +load->model('requistion_model'); + + $this->load->library('session'); + $this->load->library('form_validation'); + + $this->isLoggedIn(); + } + /** + * This function used to load the first screen of the Requistion + */ + function requisitionlisting() + { + $this->global['pageTitle'] = 'Siddharth : Requisition Listing'; + + $userID = $this->session->userdata ( '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'] = 'Siddharth : 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->userdata ( 'userId' ); + + $data['Emp'] = $this->requistion_model->getEmpIdByUserID($userID); + + $data['CostCenter'] = $this->requistion_model->getCostCenterUserID($userID); + + $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'] = 'Siddharth : Requisition Approval'; + + $data['Status']= $this->requistion_model->getStatus(); + + $userID = $this->session->userdata ( '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 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'); + + + $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 + */ + function DeleteRequistionForm() + { + + $ReqList= $this->input->post('id'); + $ReqNo =''; + $MaterialCode = ''; + if(count($ReqList) > 0) + { + $ReqNo = $ReqList[0]; + $MaterialCode = $ReqList[1]; + } + + $this->requistion_model->DeleteRequistionLineItem( $ReqNo,$MaterialCode); + + echo "Successfully Deleted the Line item".$ReqNo; + + } + + /** + * This function used to load the Delete the Requistion Items + */ + function DeleteReqNo() + { + + $ReqNo= $this->input->post('id'); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $updateddt = $dt->format('Y-m-d H:i:s'); + $Request = array('Status'=>REQ_DELETED,'updatedOn'=>$updateddt); + + $this->requistion_model->UpdateRequistion( $Request,$ReqNo); + + echo "Successfully Deleted the ".$ReqNo; + + } + + function SearchRequistList() + { + $userID = $this->session->userdata ( 'userId' ); + $ReqValue = $this->input->post('SearchDate'); + + $Dt = explode("-",$ReqValue); + + $FromDate =''; + $ToDate = ''; + $Status= ''; + if(count( $Dt)>1) + { + $FDate = $Dt[0]."-".$Dt[1]."-".$Dt[2]; + $TDate = $Dt[3]."-".$Dt[4]."-".$Dt[5]; + $FromDate = $this->getDateformat($FDate); + $ToDate = $this->getDateformat($TDate); + } + + $St = $this->input->post('RequisitionStatus'); + + if($St == "-1") + { + $Status = ''; + } + else + { + $Status = $St; + } + + $data['AppList'] = $this->requistion_model->getApproverRequistList($userID,$Status,$FromDate, $ToDate); + + $this->global['pageTitle'] = 'Siddharth : Requisition Approval'; + + $data['Status']= $this->requistion_model->getStatus(); + + $this->loadViews("requisitionlistapproval", $this->global, $data, NULL); + + } + + + + function getDateformat($Val) + { + $date = new DateTime($Val); + $retDate = $date->format('Y-m-d H:i:s'); + return $retDate; + } + /** + * This function used to load the Employee details based on the EmpID selection + */ + function GetSelectedEmpDetails() + { + $ReqType = $_GET['ReqType']; + $EmpID = $this->input->post('id'); + $empDetails = $this->requistion_model->GetEmployeeDetails( $EmpID ); + $DeptCode = $empDetails[0]['DEPCode']; + $CostList = $this->requistion_model->GetCostCenterByDept( $DeptCode); + $HTML = ""; + $BudAmount = ""; + if(count($CostList) > 0) + { + for ($j = 0; $j < count($CostList); $j++) + { + $Code = $CostList[$j]['CostCenterCode']; + $Name = $CostList[$j]['CostCenterName']; + $HTML .=""; + } + } + if(count($CostList) == 1) + { + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + + $Year = $dt->format('Y'); + $CostCode = $CostList[0]['CostCenterCode']; + + $Cost = $this->requistion_model->GetAvailableBudgetAmount( $CostCode,$Year,$ReqType); + if(count($Cost) >0) + { + $BudAmount = $Cost[0]['BudgetAmount']; + } + } + die(json_encode(array('emp' => $empDetails,'Cost' => $HTML,'AvlAmount' => $BudAmount))); + } + + function getAvailableBudAmount() + { + $ReqType = $_GET['ReqType']; + $CostCode= $this->input->post('id'); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + + $Year = $dt->format('Y'); + + $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->input->post('id'); + + $MaterialCode = $this->requistion_model->GetMaterialCode( $ReqType); + $MaterialName = ""; + $UOM = ""; + $HTML = ""; + + if(count($MaterialCode) > 0) + { + for ($j = 0; $j < count($MaterialCode); $j++) + { + $Code = $MaterialCode[$j]['MaterialCode']; + $Name = $MaterialCode[$j]['MaterialName']; + $HTML .=""; + + } + $MaterialName = $MaterialCode[0]['MaterialName']; + $UOM = $MaterialCode[0]['UOM']; + } + + die(json_encode(array('Material' =>$HTML,'MaterialName'=>$MaterialName,'UOM'=>$UOM))); + } + + // To get the Material value based on the MaterialCode + function getMaterialDetails() + { + + $Material= $this->input->post('id'); + + $MaterialDetails = $this->requistion_model->getRawMaterialList($Material); + + + die(json_encode(array('MatDetail' =>$MaterialDetails))); + } + + /* + To Insert the Requistion Details to Database + */ + /** + * This function is used to add new Cost to the system + */ + function addNewRequistion() + { + + $this->form_validation->set_rules('RequestType','RequestType','trim|required'); + $this->form_validation->set_rules('EmpID','EmpID','trim|required'); + + if($this->form_validation->run() == FALSE) + { + $this->requisition(); + } + else + { + $Status= $_GET['ID']; + $RequestType = strtoupper(trim($this->input->post('RequestType'))); + $Requestedby = strtoupper(trim($this->input->post('EmpID'))); + $CostCenter = $this->input->post('CostCenter'); + $CreateBy = $this->session->userdata ( 'userId' ); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $createddt = $dt->format('Y-m-d H:i:s'); + + $DeletedRow = $this->input->post('txtDeletedRow'); + $RowCount = $this->input->post('txtRowCount'); + + $comma_separated = explode(':', $DeletedRow); + $serviceSchedule = $this->input->post('serviceSchedule'); + $servicePeriod = $this->input->post('servicePeriod'); + $noOfService = $this->input->post('noOfService'); + + $IsExists = $this->requistion_model->RequistionIsExists($Requestedby); + // print_r($IsExists); + + if(count( $IsExists) == 0) + { + //echo 'Not Exists'; + $Request = array('ReqType'=>$RequestType, 'Requestedby'=>$Requestedby,'ReqDate'=>$createddt,'CostCenterCode'=>$CostCenter,'Status'=>$Status,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy,'Schedule_Type'=>$serviceSchedule,'NumberOfService'=>$noOfService,'Service_Period'=>$servicePeriod); + + //print_r($Request); + + $Req = $this->requistion_model->addRequistion($Request); + } + else + { + //echo 'Exists'; + $Request = array('ReqType'=>$RequestType, 'Requestedby'=>$Requestedby,'ReqDate'=>$createddt,'Status'=>$Status,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy,'CostCenterCode'=>$CostCenter,'Schedule_Type'=>$serviceSchedule,'NumberOfService'=>$noOfService,'Service_Period'=>$servicePeriod); + $UpdateReq = $this->requistion_model->UpdateRequistion($Request,$IsExists[0]['ReqNo']); + } + $ReqNumber = ''; + if(count($Req)>0) + { + $ReqNumber = $Req[0]['ReqNo']; + } + else + { + $ReqNumber = $IsExists[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->input->post('MaterialCode'.$i); + $Quantity = $this->input->post('Quantity'.$i); + + $ReqDetails = array('ReqNo'=>$ReqNumber, 'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity); + $this->requistion_model->addRequistionDetails($ReqDetails); + } + + } + if($Status == REQ_DRAFT) + { + echo 'Successfully Saved the Requistion details'; + } + else + { + echo 'Successfully Created the Requistion details'; + } + + } + + } + function EditRequistion() + { + $Status = $this->input->post('txtStatus'); + $ReqNumber = $this->input->post('txtReqNo'); + $CostCenter = $this->input->post('CostCenter'); + $UpdatedBy = $this->session->userdata ( 'userId' ); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $updatedDate = $dt->format('Y-m-d H:i:s'); + + $DeletedRow = $this->input->post('txtDeletedRow'); + $RowCount = $this->input->post('txtRowCount'); + $serviceSchedule = $this->input->post('serviceSchedule'); + $servicePeriod = $this->input->post('servicePeriod'); + $noOfService = $this->input->post('noOfService'); + if(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 = 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->input->post('MaterialCode'.$i); + $Quantity = $this->input->post('Quantity'.$i); + $IsExists = $this->requistion_model->LineItemIsExists($ReqNumber,$MaterialCode); + if(count( $IsExists) == 0) + { + $ReqDetails = array('ReqNo'=>$ReqNumber, 'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'UpdatedBy'=>$UpdatedBy,'UpdatedOn'=>$updatedDate); + + $this->requistion_model->addRequistionDetails($ReqDetails); + } + else + { + $ReqDetails = array('ReqNo'=>$ReqNumber, 'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'UpdatedBy'=>$UpdatedBy,'UpdatedOn'=>$updatedDate); + + $this->requistion_model->UpdateRequistionLineItem($ReqDetails,$ReqNumber,$MaterialCode); + } + + + } + + } + echo 'Successfully updated the Requistion details'; + // $this->requisitionlisting(); + + + + + } +/* 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.=" + ".$SNo." + ". $MaterialCode." + + ".$MaterialName." + + ".$UOM." + ".$Quantity." + ".$POQTY." + ".$StatusName." + "; + + //$index = $index + 1; + + } + $CostCode = ''; + $ReqType = ''; + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + + $Year = $dt->format('Y'); + if(count($ReqList)>0) + { + + $ReqType = $ReqList[0]['ReqType']; + + $CostCode = $ReqList[0]['CostCenterCode']; + } + $this->load->model('purchaseorder_model'); + $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$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() + { + $Status= Trim($_GET['Status']); + + $ReqNo= $_GET['ReqNo']; + $Remarks = trim($this->input->post('id')); + $ApprovedBy = $this->session->userdata ( 'userId' ); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $ApprovedDate = $dt->format('Y-m-d H:i:s'); + $Request = array('Status'=>$Status,'Comments'=>$Remarks,'ApprovedOn'=>$ApprovedDate,'Approvedby'=>$ApprovedBy); + $this->requistion_model->UpdateRequistion($Request,$ReqNo); + echo "Successfully Updated the Requistion No: ".$ReqNo; + + } + + function pageNotFound() + { + $this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found'; + + $this->loadViews("404", $this->global, NULL, NULL); + } +} + +?> \ No newline at end of file diff --git a/application/controllers/servicepurchaseorder.php b/application/controllers/servicepurchaseorder.php index 52f01cc9..b645cb8e 100755 --- a/application/controllers/servicepurchaseorder.php +++ b/application/controllers/servicepurchaseorder.php @@ -27,22 +27,7 @@ class servicepurchaseorder extends BaseController $this->isLoggedIn(); } - function viewServicePOReportForBilling() - { - - $this->global['pageTitle'] = 'Siddharth : Service Purchase Order for Billing'; - - $this->loadViews("serviceporeport", $this->global,Null); - - } - - function UpdateServicePOStatus() - { - $this->global['pageTitle'] = 'Siddharth : Update Service PO Status'; - - $this->loadViews("statusofservicepurchaseorder", $this->global,Null); - - } + // To get the available Budget Amount function AvilBudgetAmount() { @@ -80,45 +65,34 @@ class servicepurchaseorder extends BaseController //This used to Create Service Purchase Order function addNewServicePurchaseOrder() { + $POdt =$this->input->post('PODate'); $PODate = $this->getDateformat($POdt); - $SupplierID = $this->input->post('drpSupplier'); + $SupplierID = $this->input->post('drpSupplier'); $DeliveryAddr = $this->input->post('DeliveryAddr'); $dt = $this->input->post('Deliverydt'); //$Deliverydt = $this->getDateformat($dt); - $DeliveryOption = $this->input->post('DateRange'); - if($DeliveryOption==1) - { - $Deliverydt = ''; - $DeliverySchedule = $this->input->post('Scheduleby'); - } - else{ - $Deliverydt = $this->getDateformat($dt); - $DeliverySchedule = ''; - } + $DeliveryOption = $this->input->post('DateRange'); + if($DeliveryOption==1) + { + $Deliverydt = ''; + $DeliverySchedule = $this->input->post('Scheduleby'); + } + else{ + $Deliverydt = $this->getDateformat($dt); + $DeliverySchedule = ''; + } - - - $PaymentDate=$this->input->post('Payment'); - if($PaymentDate==1) - { - $PaymentDays='After'; - } - else - { - $PaymentDays='Before'; - } - - $PaymentTerms=$this->input->post('PaymentTerms'); - $Payableat=$this->input->post('PayableAT'); + $PaymentTerms=$this->input->post('PaymentTerms'); + $POType = $this->input->post('POType'); - $SpcialInstruction = $this->input->post('txtSpcialInstruction'); + $SpcialInstruction = $this->input->post('ScopeOfWork'); $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); - $POStatus = $this->input->post('txtStatus'); + $POStatus = $this->input->post('txtStatus'); - $CreateBy = $this->session->userdata ( 'userId' ); + $CreateBy = $this->session->userdata ( 'userId' ); $RowCount = $this->input->post('txtRowCount'); $DeletedRow = $this->input->post('txtDeletedRow'); @@ -129,9 +103,8 @@ class servicepurchaseorder extends BaseController $WorkStatus=$this->input->post('workstatus'); // PO Master - $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus, 'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption, 'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'PayableAT'=>$Payableat,'PaymentDays'=>$PaymentDays,'ServiceWorkStatus'=>$WorkStatus,'POType'=>$POType ); - //print_r($POList); - //die(); + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus, 'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption, 'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'ServiceWorkStatus'=>$WorkStatus,'POType'=>$POType ); + $POMaster = $this->purchaseorder_model->addPOMaster($POList); $PONO = ''; @@ -150,14 +123,16 @@ class servicepurchaseorder extends BaseController $Quantity = $this->input->post('quantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); - $ServiceTax = $this->input->post('ServiceTax'.$i); - $EduCess = $this->input->post('EduCess'.$i); - $SecHighTax = $this->input->post('SecHighTax'.$i); - $KrishiTax = $this->input->post('KrishiTax'.$i); - $SwachhTax = $this->input->post('SwachhTax'.$i); + $Cgst = $this->input->post('Cgst'.$i); + $Sgst = $this->input->post('Sgst'.$i); + $Igst = $this->input->post('Igst'.$i); + $AfterCgst = $this->input->post('AfterCgst'.$i); + $AfterSgst = $this->input->post('AfterSgst'.$i); + $AfterIgst = $this->input->post('AfterIgst'.$i); $CostCenter = $this->input->post('costCode'.$i); $ServiceFrequency=$this->input->post('Frequency'.$i); - + $ItemDescription = $this->input->post('ItemDescription'.$i); + $OtherAmt = $this->input->post('OtherAmt'.$i); $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); $SkipInsert = "False"; @@ -178,7 +153,7 @@ class servicepurchaseorder extends BaseController if($SkipInsert == "False") { - $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'ServiceFrequency'=>$ServiceFrequency); + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'ServiceFrequency'=>$ServiceFrequency,'ServiceMaterialDescription'=>$ItemDescription); //print_r($POLineItemList); //die(); @@ -195,7 +170,7 @@ class servicepurchaseorder extends BaseController if(trim($POType) == SERVICE ) { // echo 'Success'; - $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt); + $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'CGST'=>$Cgst,'After_CGST'=>$AfterCgst,'SGST'=>$Sgst,'After_SGST'=>$AfterSgst,'IGST'=>$Igst,'After_IGST'=>$AfterIgst,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'otherallowance'=>$OtherAmt); $ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList); @@ -227,22 +202,14 @@ class servicepurchaseorder extends BaseController } - $PaymentDate=$this->input->post('Payment'); - if($PaymentDate==1) - { - $PaymentDays='After'; - } - else - { - $PaymentDays='Before'; - } + $PaymentTerms=$this->input->post('PaymentTerms'); $Payableat=$this->input->post('PayableAT'); $POType = $this->input->post('POType'); - $SpcialInstruction = $this->input->post('SpcialInstruction'); + $SpcialInstruction = $this->input->post('ScopeofWork'); $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); $POStatus = $this->input->post('txtStatus'); @@ -257,7 +224,7 @@ class servicepurchaseorder extends BaseController // PO Master - $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'UpdateBY'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt,'PaymentTerms'=>$PaymentTerms,'PayableAT'=>$Payableat,'PaymentDays'=>$PaymentDays,'ServiceWorkStatus'=>$WorkStatus ); + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'UpdateBY'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt,'PaymentTerms'=>$PaymentTerms,'ServiceWorkStatus'=>$WorkStatus ); $POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); @@ -269,15 +236,18 @@ class servicepurchaseorder extends BaseController $Quantity = $this->input->post('quantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); - $ServiceTax = $this->input->post('ServiceTax'.$i); - $EduCess = $this->input->post('EduCess'.$i); - $SecHighTax = $this->input->post('SecHighTax'.$i); - $KrishiTax = $this->input->post('KrishiTax'.$i); - $SwachhTax = $this->input->post('SwachhTax'.$i); - $CostCenter = $this->input->post('costCode'.$i); + $Cgst = $this->input->post('Cgst'.$i); + $Sgst = $this->input->post('Sgst'.$i); + $Igst = $this->input->post('Igst'.$i); + $AfterCgst = $this->input->post('AfterCgst'.$i); + $AfterSgst = $this->input->post('AfterSgst'.$i); + $AfterIgst = $this->input->post('AfterIgst'.$i); + $CostCenter = $this->input->post('costCode'.$i); + $ServiceFrequency=$this->input->post('Frequency'.$i); $POLineItemNo = $this->input->post('LineItemNo'.$i); $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); - $ServiceFrequency=$this->input->post('Frequency'.$i); + $ItemDescription = $this->input->post('ItemDescription'.$i); + $OtherAmt = $this->input->post('OtherAmt'.$i); $POLineItem = array(); $LineItemNo = ''; @@ -300,7 +270,7 @@ class servicepurchaseorder extends BaseController { if(strlen($POLineItemNo) == 0) { - $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CostCenterCode'=>$CostCenter,'ServiceFrequency'=>$ServiceFrequency); + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CostCenterCode'=>$CostCenter,'ServiceFrequency'=>$ServiceFrequency,'ServiceMaterialDescription'=>$ItemDescription); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); if(count($POLineItem)>0) { @@ -312,7 +282,7 @@ class servicepurchaseorder extends BaseController { $LineItemNo = $POLineItemNo; - $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt,'CostCenterCode'=>$CostCenter); + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt,'CostCenterCode'=>$CostCenter,'ServiceMaterialDescription'=>$ItemDescription); $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$POLineItemNo,$POLineItemList); } @@ -325,14 +295,14 @@ class servicepurchaseorder extends BaseController if(count($isExists) == 0) { - $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt); + $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'CGST'=>$Cgst,'After_CGST'=>$AfterCgst,'SGST'=>$Sgst,'After_SGST'=>$AfterSgst,'IGST'=>$Igst,'After_IGST'=>$AfterIgst,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'otherallowance'=>$OtherAmt); $this->purchaseorder_model->addServiceTax($ServiceTaxList); } else { - $ServiceTaxList1 = array('ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt); + $ServiceTaxList1 = array('CGST'=>$Cgst,'After_CGST'=>$AfterCgst,'SGST'=>$Sgst,'After_SGST'=>$AfterSgst,'IGST'=>$Igst,'After_IGST'=>$AfterIgst,'TotalValue'=>$TotalOrderValue, 'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt,'otherallowance'=>$OtherAmt); $this->purchaseorder_model->updateServiceTax($LineItemNo,$ServiceTaxList1); diff --git a/application/controllers/servicepurchaseorder.php~ b/application/controllers/servicepurchaseorder.php~ new file mode 100755 index 00000000..b645cb8e --- /dev/null +++ b/application/controllers/servicepurchaseorder.php~ @@ -0,0 +1,325 @@ + + +load->model('purchaseorder_model'); + + $this->load->library('session'); + $this->load->library('form_validation'); + $this->load->model('requistion_model'); + $this->isLoggedIn(); + } + + + // To get the available Budget Amount + function AvilBudgetAmount() + { + // echo 'Controller called'; + $CostCode = $this->input->post('id'); + $ReqType = $_GET['ReqType']; + + + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + + $Year = $dt->format('Y'); + $this->load->model('purchaseorder_model'); + $result = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType); + //print_r($result); + $AvilBudAmt = '0'; + 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; + } + + //This used to Create Service Purchase Order + function addNewServicePurchaseOrder() + { + + $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); + $DeliveryOption = $this->input->post('DateRange'); + if($DeliveryOption==1) + { + $Deliverydt = ''; + $DeliverySchedule = $this->input->post('Scheduleby'); + } + else{ + $Deliverydt = $this->getDateformat($dt); + $DeliverySchedule = ''; + } + + $PaymentTerms=$this->input->post('PaymentTerms'); + + + $POType = $this->input->post('POType'); + + $SpcialInstruction = $this->input->post('ScopeOfWork'); + $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); + $POStatus = $this->input->post('txtStatus'); + + $CreateBy = $this->session->userdata ( 'userId' ); + $RowCount = $this->input->post('txtRowCount'); + $DeletedRow = $this->input->post('txtDeletedRow'); + + $comma_separated = explode(':', $DeletedRow); + + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $createddt = $dt->format('Y-m-d H:i:s'); + + $WorkStatus=$this->input->post('workstatus'); + // PO Master + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus, 'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption, 'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'ServiceWorkStatus'=>$WorkStatus,'POType'=>$POType ); + + $POMaster = $this->purchaseorder_model->addPOMaster($POList); + + $PONO = ''; + if(count($POMaster)>0) + { + $PONO = $POMaster[0]['PONO']; + } + + // PO Line Items + $LineItemStatus = REQITEM_NEW; + + 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); + $Cgst = $this->input->post('Cgst'.$i); + $Sgst = $this->input->post('Sgst'.$i); + $Igst = $this->input->post('Igst'.$i); + $AfterCgst = $this->input->post('AfterCgst'.$i); + $AfterSgst = $this->input->post('AfterSgst'.$i); + $AfterIgst = $this->input->post('AfterIgst'.$i); + $CostCenter = $this->input->post('costCode'.$i); + $ServiceFrequency=$this->input->post('Frequency'.$i); + $ItemDescription = $this->input->post('ItemDescription'.$i); + $OtherAmt = $this->input->post('OtherAmt'.$i); + $TotalOrderValue = $this->input->post('TotalOrderValue'.$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") + { + + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'ServiceFrequency'=>$ServiceFrequency,'ServiceMaterialDescription'=>$ItemDescription); + //print_r($POLineItemList); + //die(); + + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + + $LineItemNo = ''; + + if(count($POLineItem)>0) + { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } + //echo $LineItemNo; + + if(trim($POType) == SERVICE ) + { + // echo 'Success'; + $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'CGST'=>$Cgst,'After_CGST'=>$AfterCgst,'SGST'=>$Sgst,'After_SGST'=>$AfterSgst,'IGST'=>$Igst,'After_IGST'=>$AfterIgst,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'otherallowance'=>$OtherAmt); + + $ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList); + + } + } + + } + echo 'Service Purchase Order Created Successfully!The PO NO Is: '.$PONO; + + } + function UpdateServicePurchaseOrder() + { + $PONO =$this->input->post('txtPONO'); + //echo $PONO; + $POdt =$this->input->post('PODate'); + $PODate = $this->getDateformat($POdt); + + $SupplierID = $this->input->post('drpSupplier'); + $DeliveryAddr = $this->input->post('txtDeliveryAddress'); + $dt = $this->input->post('Deliverydt'); + $DeliveryOption = $this->input->post('DateRange'); + if($DeliveryOption==1){ + $Deliverydt = ''; + $DeliverySchedule = $this->input->post('Scheduleby'); + } + else{ + $Deliverydt = $this->getDateformat($dt); + $DeliverySchedule = ''; + } + + + + + $PaymentTerms=$this->input->post('PaymentTerms'); + $Payableat=$this->input->post('PayableAT'); + + $POType = $this->input->post('POType'); + + $SpcialInstruction = $this->input->post('ScopeofWork'); + $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); + $POStatus = $this->input->post('txtStatus'); + + $updatedBy = $this->session->userdata ( 'userId' ); + $RowCount = $this->input->post('txtRowCount'); + $DeletedRow = $this->input->post('txtDeletedRow'); + + $comma_separated = explode(':', $DeletedRow); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $updateddt = $dt->format('Y-m-d H:i:s'); + $WorkStatus=$this->input->post('workstatus'); + + + // PO Master + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'UpdateBY'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt,'PaymentTerms'=>$PaymentTerms,'ServiceWorkStatus'=>$WorkStatus ); + + $POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); + + $LineItemStatus = REQITEM_NEW; + + 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); + $Cgst = $this->input->post('Cgst'.$i); + $Sgst = $this->input->post('Sgst'.$i); + $Igst = $this->input->post('Igst'.$i); + $AfterCgst = $this->input->post('AfterCgst'.$i); + $AfterSgst = $this->input->post('AfterSgst'.$i); + $AfterIgst = $this->input->post('AfterIgst'.$i); + $CostCenter = $this->input->post('costCode'.$i); + $ServiceFrequency=$this->input->post('Frequency'.$i); + $POLineItemNo = $this->input->post('LineItemNo'.$i); + $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); + $ItemDescription = $this->input->post('ItemDescription'.$i); + $OtherAmt = $this->input->post('OtherAmt'.$i); + + $POLineItem = array(); + $LineItemNo = ''; + $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") + { + if(strlen($POLineItemNo) == 0) + { + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CostCenterCode'=>$CostCenter,'ServiceFrequency'=>$ServiceFrequency,'ServiceMaterialDescription'=>$ItemDescription); + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + if(count($POLineItem)>0) + { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } + + } + else + { + $LineItemNo = $POLineItemNo; + + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt,'CostCenterCode'=>$CostCenter,'ServiceMaterialDescription'=>$ItemDescription); + $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$POLineItemNo,$POLineItemList); + + } + + + + if(trim($POType) == SERVICE ) + { + $isExists = $this->purchaseorder_model->LineItemExists($LineItemNo); + + if(count($isExists) == 0) + { + $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'CGST'=>$Cgst,'After_CGST'=>$AfterCgst,'SGST'=>$Sgst,'After_SGST'=>$AfterSgst,'IGST'=>$Igst,'After_IGST'=>$AfterIgst,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'otherallowance'=>$OtherAmt); + + $this->purchaseorder_model->addServiceTax($ServiceTaxList); + + } + else + { + $ServiceTaxList1 = array('CGST'=>$Cgst,'After_CGST'=>$AfterCgst,'SGST'=>$Sgst,'After_SGST'=>$AfterSgst,'IGST'=>$Igst,'After_IGST'=>$AfterIgst,'TotalValue'=>$TotalOrderValue, 'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt,'otherallowance'=>$OtherAmt); + + $this->purchaseorder_model->updateServiceTax($LineItemNo,$ServiceTaxList1); + + } + + } + + } + } + echo 'Successfully updated the Service Purchase Order'; + } + function pageNotFound() + { + $this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found'; + + $this->loadViews("404", $this->global, NULL, NULL); + } +} + +?> diff --git a/application/models/purchaseorder_model.php b/application/models/purchaseorder_model.php index 637bb396..18f900ac 100755 --- a/application/models/purchaseorder_model.php +++ b/application/models/purchaseorder_model.php @@ -214,7 +214,7 @@ function purchaseorderListing($forwhat='') function getRequistDetails($ReqNoList='') { $this->db->distinct(); - $this->db->select('ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,mast.ReqDate,mast.CostCenterCode,mast.Status'); + $this->db->select('ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,mast.Schedule_Type,mast.NumberOfService,mast.Service_Period,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,mast.ReqDate,mast.CostCenterCode,mast.Status'); $this->db->from('T_Requestion_Master mast'); $this->db->join('T_Employee_Details emp', 'mast.Requestedby = emp.EmpID'); $this->db->join('T_DepartmentDetails Dept', 'emp.Departmentcode = Dept.DEPCode'); @@ -505,14 +505,18 @@ function purchaseorderListing($forwhat='') } // This Method to get the Service PO Child Details for Edit the Item + + +// This Method to get the Service PO Child Details for Edit the Item function GetServicePurchaseOrderDetails($PONO = '') { - $subQuery ='SELECT distinct LineItem.LineItemNo,ReqNo,Mat.MaterialCode,Mat.MaterialName,Mat.UOM,Quantity,Rate,Status,ROUND((Quantity *Rate),2 ) as BasicValue ,ROUND((ServiceTax + EducessTax + SecHigherEducessTax + KrishiKalyantax + SwachhBharattax),2)as Taxamount - ,TotalValue,ServiceTax,EducessTax,SecHigherEducessTax,KrishiKalyantax,SwachhBharattax,CostCenterCode,LineItem.ServiceFrequency + $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.ReqNo,Mat.MaterialCode,Mat.MaterialName,Mat.UOM,Quantity,ReceivedQuantity,Rate,LineItem.Status,ROUND((Quantity *Rate),2 ) as BasicValue ,ROUND((After_CGST + After_SGST + After_IGST),2)as Taxamount + ,TotalValue,CGST,After_CGST,SGST,After_SGST,IGST,After_IGST,otherallowance,LineItem.CostCenterCode,LineItem.ServiceFrequency,LineItem.ServiceMaterialDescription,Req.Schedule_Type,Req.NumberOfService,Req.Service_Period FROM T_PurchaseOrder_LineItem LineItem join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode join T_Service_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo + join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo where LineItem.PONO =?'; $query = $this->db->query($subQuery,array($PONO)); @@ -522,25 +526,6 @@ function purchaseorderListing($forwhat='') } -// This Method to get the Service PO Child Details for Edit the Item - function GetServicePurchaseOrderDetailsForPrint($PONO = '') - { - - $subQuery ='SELECT distinct LineItem.LineItemNo,ReqNo,Mat.MaterialCode,Mat.MaterialName,Mat.UOM, - Quantity,Rate,ROUND((Quantity *Rate),2 ) as BasicValue ,ROUND((ServiceTax + EducessTax + SecHigherEducessTax + KrishiKalyantax + SwachhBharattax),2)as Taxamount - ,TotalValue,ServiceTax,EducessTax,SecHigherEducessTax,KrishiKalyantax,SwachhBharattax,CostCenterCode,sup.SupplierName,sup.Address,POMaster.* FROM T_PurchaseOrder_LineItem LineItem - join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - join T_Service_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO - join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID - where LineItem.PONO =?'; - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } - // This Method to get the Revenue PO Child Details for Edit the Item function GetRevenuePurchaseOrderDetails($PONO = '') { @@ -1272,4 +1257,30 @@ join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode return $result->result_array(); } + + //get paymentTerms details + + function getPaymentTermsDetails($Payment_ID='') + { + + + $getpaymentQuery='select distinct PaymentID,PaymentTerms,Details from T_PaymentTerms'; + $paymentQuery=$this->db->query($getpaymentQuery); + + return $paymentQuery->result(); + + } + /** + * This function is used to get status in status table + + */ + function getStatus($StatusType = '') + { + $this->db->select('StatusCode,StatusName '); + $this->db->from('T_Status'); + $this->db->where('StatusType', $StatusType); + $query = $this->db->get(); + + return $query->result(); + } } \ No newline at end of file diff --git a/application/models/purchaseorder_model.php~ b/application/models/purchaseorder_model.php~ new file mode 100755 index 00000000..18f900ac --- /dev/null +++ b/application/models/purchaseorder_model.php~ @@ -0,0 +1,1286 @@ +db->distinct(); + $this->db->select('POMast.PONO,supp.SupplierName,TotalOrderValue,PODate,Stat.StatusName,Req.ReqType,DeliveryDate'); + $this->db->from('T_PurchaseOrder_Master POMast'); + $this->db->join('T_SupplierDetailsN supp', 'supp.SupplierID = POMast.SupplierID'); + $this->db->join('T_Status Stat', 'Stat.StatusCode = POMast.Status'); + $this->db->join('T_PurchaseOrder_LineItem LineItem', 'POMast.PONO = LineItem.PONO'); + $this->db->join('T_Requestion_Master Req', 'Req.ReqNo = LineItem.ReqNo'); + // print_r( $this->db->last_query()); + $query = $this->db->get(); + + return count($query->result()); + } + + /** + * This function is used to get the user listing count + * @param string $searchText : This is optional search text + * @param number $page : This is pagination offset + * @param number $segment : This is pagination limit + * @return array $result : This is result + */ + +function purchaseorderListing($forwhat='') + { + $this->db->distinct(); + $this->db->select('POMast.PONO,supp.SupplierName,TotalOrderValue,PODate,Stat.StatusName,Stat.StatusCode,POMast.POType as ReqType,DeliveryDate,DeliverySchedule,DeliveryOption,POMast.CapitalRange'); + $this->db->from('T_PurchaseOrder_Master POMast'); + $this->db->join('T_SupplierDetailsN supp', 'supp.SupplierID = POMast.SupplierID'); + $this->db->join('T_Status Stat', 'Stat.StatusCode = POMast.Status'); + $this->db->join('T_PurchaseOrder_LineItem LineItem', 'POMast.PONO = LineItem.PONO'); + $this->db->join('T_Requestion_Master Req', 'Req.ReqNo = LineItem.ReqNo'); + if($forwhat=='amendment') + { + $this->db->where('POMast.Status',PO_RELEASED); + } + else + { + $this->db->where('POMast.Status !=',PO_AMENDED); + // $this->db->order_by('POMast.Status !=',PO_AMENDED); + } + $query = $this->db->get(); + //print_r( $this->db->last_query()); + $result = $query->result(); + return $result; + } + + /** + * This function is used to get the SupplierID and SupplierName information + * @return array $result : This is result of the query + */ + function getSupplierName($supID='') + { + $this->db->select('SupplierID, SupplierName,Address,PaymentTerms,PayableAT,PaymentDays'); + $this->db->from('T_SupplierDetailsN'); + if($supID != '') + { + $this->db->where('SupplierID',$supID); + } + //$this->db->where('roleId !=', 1); + $query = $this->db->get(); + + return $query->result(); + } + /** + * This function is used to get the userId information + * @return array $result : This is result of the query + */ + function getusers() + { + $this->db->select('userId, name'); + $this->db->from('tbl_users'); + //$this->db->where('roleId !=', 1); + $query = $this->db->get(); + + return $query->result(); + } +/** + * This function is used to get the Raw Material information + * @return array $result : This is result of the query + */ + function getRawPOMaterialList($ReqNo,$IsArray='') + { + + $result = $this->db-> query("CALL P_GET_REQUISTIONLIST('".$ReqNo."')") or die(mysql_error()); + + $result ->next_result(); + + //print_r($this->db->last_query()); + + if ($result->num_rows > 0) + { + //echo 'PO Line item Inserted successfully'; + if($IsArray != '') + { + return $result->result_array(); + } + else + { + return $result->result(); + } + } + + } + + /** + This Function to get the List of Requistion which require to create PO + */ + function getAllRequistionListToCreatePO() + { + $result = $this->db-> query("CALL P_PURCHASEORDER_DETAILS()") or die(mysql_error()); + + $result ->next_result(); + + + if ($result->num_rows > 0) + { + + return $result->result(); + } + } + + /** + * This function is used to get the Raw Material information + * @return array $result : This is result of the query + */ + function getRawMaterialList($MatType='',$ReqNoList='') + { + + $this->db->select('ReqNo,Req.MaterialCode,MaterialName,UOM,Req.Quantity'); + $this->db->from('T_Requestion_Details Req'); + $this->db->join('T_MaterialMaster mat', 'Req.MaterialCode = mat.MaterialCode'); + $this->db->where('mat.MaterialType', $MatType); + $this->db->where_in('Req.ReqNo', $ReqNoList); + + $query = $this->db->get(); + //print_r($this->db->last_query()); + return $query->result(); + } + /** + * This function is used to get the Raw Material information + * @return array $result : This is result of the query + */ + function getRawMaterialListForPO($MatType='',$ReqNo='') + { + $subQuery ='SELECT ReqNo,Req.MaterialCode,MaterialName,UOM,Req.Quantity + FROM T_Requestion_Details Req + JOIN T_MaterialMaster mat ON Req.MaterialCode = mat.MaterialCode + where mat.MaterialType = ? + AND Req.ReqNo = ? + AND mat.MaterialCode != (SELECT MaterialCode FROM T_PurchaseOrder_LineItem WHERE ReqNo =? + )'; + + $query = $this->db->query($subQuery,array($MatType,$ReqNo,$ReqNo)); + + return $query->result_array(); + + + } + function GetAvailableBudgetAmount($CostCode,$Year,$BudgetType) + { + /* $this->db->select('BudgetAmount'); + $this->db->from('T_CostCenter_Budget'); + $this->db->where('CostCenterCode',$CostCode ); + $this->db->where('BudgetYear',$Year ); + $this->db->where('BudgetType',$BudgetType ); + $query = $this->db->get(); + + return $query->result_array(); */ + + /* $subQuery ='select BudgetAmount, (select ifnull(sum(TotalOrderValue),0) as Totalvalue from + T_PurchaseOrder_Master PO join T_PurchaseOrder_LineItem Item on + Item.PONO = PO.PONO join T_Requestion_Master mast on mast.ReqNo = Item.ReqNo where Item.CostCenterCode=? and mast.ReqType=?)as Totalvalue + from T_CostCenter_Budget Bud where Bud.CostCenterCode=? and + BudgetYear = ? and BudgetType =?'; */ + + $subQuery ='select BudgetAmount, (select ifnull(sum(Quantity*Rate),0) as Totalvalue from + T_PurchaseOrder_LineItem Item join T_Requestion_Master mast on mast.ReqNo = Item.ReqNo where Item.CostCenterCode=? and mast.ReqType=?)as Totalvalue + from T_CostCenter_Budget Bud where Bud.CostCenterCode=? and + BudgetYear = ? and BudgetType =?'; + + $query = $this->db->query($subQuery,array($CostCode,$BudgetType,$CostCode,$Year,$BudgetType)); + //print_r($this->db->last_query()); + return $query->result_array(); + + } + + + function GetAvailableImportBudgetAmount($CostCode,$Year,$BudgetType) + { + $subQuery='select BudgetAmount,(select ifnull(sum((Quantity*Rate*ExchangeRate)),0)as TValue from T_PurchaseOrder_LineItem LineItem + join T_PurchaseOrder_Master Mast on Mast.PONO=LineItem.PONO where POType=? + and CostCenterCode=?)as TotalValue from T_CostCenter_Budget Bud where Bud.CostCenterCode=? and BudgetYear=? and BudgetType=?'; + $query = $this->db->query($subQuery,array($BudgetType,$CostCode,$CostCode,$Year,$BudgetType)); + //print_r($this->db->last_query()); + return $query->result_array(); + + + } + + /** + * This function is used to get the Requsition List for the login user + * @return array $result : This is result of the query + */ + function getRequistDetails($ReqNoList='') + { + $this->db->distinct(); + $this->db->select('ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,mast.Schedule_Type,mast.NumberOfService,mast.Service_Period,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,mast.ReqDate,mast.CostCenterCode,mast.Status'); + $this->db->from('T_Requestion_Master mast'); + $this->db->join('T_Employee_Details emp', 'mast.Requestedby = emp.EmpID'); + $this->db->join('T_DepartmentDetails Dept', 'emp.Departmentcode = Dept.DEPCode'); + $this->db->where_in('mast.ReqNo', $ReqNoList); + + $query = $this->db->get(); + //print_r($this->db->last_query()); + return $query->result(); + } + /** + * This function is used to get the Requsition List for the login user + * @return array $result : This is result of the query + */ + function getRequistDetailsForPO($ReqNoList='') + { + $this->db->distinct(); + $this->db->select('ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,mast.ReqDate'); + $this->db->from('T_Requestion_Master mast'); + $this->db->join('T_Employee_Details emp', 'mast.Requestedby = emp.EmpID'); + $this->db->join('T_DepartmentDetails Dept', 'emp.Departmentcode = Dept.DEPCode'); + $this->db->where_in('mast.ReqNo', $ReqNoList); + + $query = $this->db->get(); + + return $query->result(); + } + /** + * This function is used to get the Cost center information + * @return array $result : This is result of the query + */ + function getCostCenter() + { + + $this->db->select('CostName, Description'); + $this->db->from('T_CostCentre'); + + $query = $this->db->get(); + + return $query->result(); + } + + + /** + * This function is used to get the CostCenter for the Selected Requistion Number + * @return array $result : This is result of the query + */ + function getCostCenterbyRequist($ReqNo='',$BudYear='',$ReqType='') + { + + $this->db->distinct(); + $this->db->select('Mast.CostCenterCode,Mast.CostCenterName,Bud.BudgetAmount,ReqNo'); + $this->db->from('T_CostCenter_Master Mast'); + $this->db->join('T_CostCenter_Departments CostDept', 'CostDept.CostCenterCode = Mast.CostCenterCode'); + $this->db->join('T_CostCenter_Budget Bud', 'Bud.CostCenterCode = Mast.CostCenterCode'); + $this->db->join('T_Employee_Details emp', 'CostDept.DEPCode = emp.Departmentcode'); + $this->db->join('T_Requestion_Master req', 'req.Requestedby = emp.EmpID'); + + $this->db->where('BudgetType ',$ReqType ); + $this->db->where('BudgetYear ',$BudYear ); + if($ReqNo != '') + { + $this->db->where('ReqNo ',$ReqNo); + } + + $query = $this->db->get(); + return $query->result(); + } + +/** + * This function is used to get the Config value from configuration table + * @return array $result : This is result of the query + */ + function getRequistionNoFromPO($PONO='') + { + + $this->db->select('ReqNo,'); + $this->db->from('T_PurchaseOrder_LineItem'); + if($PONO != '') + { + $this->db->where('PONO ',$PONO ); + } + + $query = $this->db->get(); + + return $query->result(); + } + + + /** + * This function is used to get the Config value from configuration table + * @return array $result : This is result of the query + */ + function getConfigValue($ConfigID ,$ConfigValue = '') + { + + $this->db->select('ConfigValue'); + $this->db->from('T_ConfigDetails'); + $this->db->where('Config_id ',$ConfigID ); + if($ConfigValue != '') + { + $this->db->where('ConfigValue != ',$ConfigValue ); + } + $query = $this->db->get(); + + return $query->result(); + } + + + + + /** + * This function is used to get the Company information from T_Company_Details table + * @return array $result : This is result of the query + */ + function getCompanyInformation() + { + + $this->db->select('CompanyName,Address'); + $this->db->from('T_Company_Details'); + + $query = $this->db->get(); + + return $query->result(); + } + /** + * This function is used to get the Employee List + * @return array $result : This is result of the query + */ + function getAllEmployees() + { + $this->db->select('EmpID,FirstName,LastName'); + $this->db->from('T_Employee_Details'); + $query = $this->db->get(); + + return $query->result(); + } + + /** + * This function is used to get the Employee List + * @return array $result : This is result of the query + */ + function getLastCreatedPODate() + { + $this->db->select('max(PODate) as PODate'); + $this->db->from('T_PurchaseOrder_Master'); + $query = $this->db->get(); + + return $query->result(); + } + + function getLastReleasedPODate() + { + $this->db->select('max(ReleasedOn) as PODate'); + $this->db->from('T_PurchaseOrder_Master'); + $query = $this->db->get(); + + return $query->result(); + } + /** + * This function is used to add New Purchase order to the system + + */ + function addPOMaster($POMaster) + { + $this->db->trans_start(); + $this->db->insert('T_PurchaseOrder_Master', $POMaster); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + // print_r($this->db->last_query()); + if($insert_id>0) + { + $subQuery = 'select max(PONO) as PONO from T_PurchaseOrder_Master'; + + $query = $this->db->query($subQuery); + + return $query->result_array(); + } + } + + + function addAmendPOMaster($POMaster,$CreatedBy,$ParentPO) + { + // print_r($POMaster); + $this->db->trans_start(); + $this->db->insert('T_PurchaseOrder_Master', $POMaster); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + // print_r($this->db->last_query()); + if($insert_id>0) + { + $subQuery = 'select max(PONO) as PONO from T_PurchaseOrder_Master where CreatedBy=? and ParentPO=?'; + + $query = $this->db->query($subQuery,array($CreatedBy,$ParentPO)); + + return $query->result_array(); + } + } + + /** + * This function is used to add New Purchase order Line Item to the system + */ + function addPOLineItem($POLineItem) + { + $this->db->trans_start(); + $this->db->insert('T_PurchaseOrder_LineItem', $POLineItem); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + // print_r($this->db->last_query()); + if($insert_id>0) + { + $subQuery = 'select max(LineItemNo) as LineItemNo from T_PurchaseOrder_LineItem'; + + $query = $this->db->query($subQuery); + + return $query->result_array(); + } + } + + /** + * This function is used to add Revenue Tax to the system + */ + function addRevenueTax($RevenueTaxList) + { + $this->db->trans_start(); + $this->db->insert('T_Revenue_Tax', $RevenueTaxList); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + return $insert_id; + } + /** + * This function is used to add Service Tax to the system + */ + function addServiceTax($ServiceTaxList) + { + $this->db->trans_start(); + $this->db->insert('T_Service_Tax', $ServiceTaxList); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + return $insert_id; + } + + + /** + * This function is used to add Service Tax to the system + */ + function addImportTax($ImportTaxList) + { + $this->db->trans_start(); + $this->db->insert('T_Import_Tax', $ImportTaxList); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + return $insert_id; + } + + + /** + * This function used to get user information by id + * @param number $userId : This is user id + * @return array $result : This is user information + */ + function getuserInfo($PO) + { + $this->db->select('POType, PODate, SupplierID,SpecialOrder,UserID,RequestedDate,RequesterEmail,RequesterPh, PurchasingCategory,BudgetManager,BudgetManagerDepartment,'); + $this->db->from('T_PurchaseOrderDetails'); + $this->db->where('PONO', $PO); + $query = $this->db->get(); + + return $query->result(); + } + + // This Method to get the Service PO Details for Edit the Item + + function GetServicePurchaseOrder($PONO = '') + { + $this->db->distinct(); + $this->db->select('ReqNo,POMast.PONO,ServiceDescription,supp.SupplierID,supp.SupplierName,supp.Address,PODate,Stat.StatusName,DeliveryOption,DeliverySchedule,DeliveryDate,DeliveryAddress,POMast.PaymentTerms,POMast.PaymentDays,POMast.PayableAT,POMast.ExchangeRate,POMast.UpdatedOn,Stat.StatusCode,POMast.ServiceWorkStatus,POMast.*'); + $this->db->from('T_PurchaseOrder_Master POMast'); + $this->db->join('T_SupplierDetailsN supp', 'supp.SupplierID = POMast.SupplierID'); + $this->db->join('T_Status Stat', 'Stat.StatusCode = POMast.Status'); + $this->db->join('T_PurchaseOrder_LineItem LineItem', 'POMast.PONO = LineItem.PONO'); + + $this->db->where('POMast.PONO', $PONO); + $query = $this->db->get(); + + $result = $query->result(); + + return $result; + } + + // This Method to get the Service PO Child Details for Edit the Item + + +// This Method to get the Service PO Child Details for Edit the Item + function GetServicePurchaseOrderDetails($PONO = '') + { + + $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.ReqNo,Mat.MaterialCode,Mat.MaterialName,Mat.UOM,Quantity,ReceivedQuantity,Rate,LineItem.Status,ROUND((Quantity *Rate),2 ) as BasicValue ,ROUND((After_CGST + After_SGST + After_IGST),2)as Taxamount + ,TotalValue,CGST,After_CGST,SGST,After_SGST,IGST,After_IGST,otherallowance,LineItem.CostCenterCode,LineItem.ServiceFrequency,LineItem.ServiceMaterialDescription,Req.Schedule_Type,Req.NumberOfService,Req.Service_Period + FROM T_PurchaseOrder_LineItem LineItem + join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode + join T_Service_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo + join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo + where LineItem.PONO =?'; + + $query = $this->db->query($subQuery,array($PONO)); + + return $query->result(); + + + } + + // This Method to get the Revenue PO Child Details for Edit the Item + function GetRevenuePurchaseOrderDetails($PONO = '') + { + + $subQuery ='SELECT distinct LineItem.LineItemNo,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName,Mat.UOM,Quantity,Rate,Req.Status,ROUND((Quantity *Rate),2 ) as BasicValue , ROUND(((AfterPackagingValue + AfterFreightValue + AfterExciseDuty + AfterVAT + AfterCST + AfterGST + AfterOtherTaxes + Insurance) - AfterDiscount ),2)as Taxamount ,TotalValue,Tax.*,Req.CostCenterCode,Dept.DepartmentName + FROM T_PurchaseOrder_LineItem LineItem + join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode + join T_Revenue_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo + join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo + join T_Employee_Details emp on Req.Requestedby = emp.EmpID + join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode + where LineItem.PONO =?'; + + $query = $this->db->query($subQuery,array($PONO)); + + return $query->result(); + + + } + + // This Method to get the Revenue PO Child Details for Edit the Item + function GetRevenuePurchaseOrderDetailsForPDF($PONO = '') + { + + $subQuery ='SELECT distinct LineItem.LineItemNo,ReqNo,Mat.MaterialCode,Mat.MaterialName, + Mat.UOM,Quantity,Rate,ROUND((Quantity *Rate),2 ) as BasicValue , + ROUND(((AfterPackagingValue + AfterFreightValue + AfterExciseDuty + AfterVAT + AfterCST + + AfterGST + AfterOtherTaxes + Insurance)) ,2)as Taxamount , + TotalValue,Tax.*,LineItem.CostCenterCode ,POMaster.*,sup.SupplierName,sup.Address + FROM T_PurchaseOrder_LineItem LineItem + join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode + join T_Revenue_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo + join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO + join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID + where LineItem.PONO =?'; + + $query = $this->db->query($subQuery,array($PONO)); + + return $query->result(); + + + } + + +function GetImportPurchaseOrderDetailsForPDF($PONO = '') + { + + // $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.ReqNo,Mat.MaterialCode,Mat.MaterialName, + // Mat.UOM,Quantity,ReqMas.Requestedby,Rate,ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount, + // ProductPrice,Tax.*,LineItem.CostCenterCode , POMaster.*,sup.SupplierName,sup.Address + // FROM T_PurchaseOrder_LineItem LineItem + // join T_Requestion_Master ReqMas on ReqMas.ReqNo=LineItem.ReqNo + // join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode + // join T_Import_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo + // join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO + // join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID + // where LineItem.PONO =?'; + + $subQuery='SELECT distinct LineItem.LineItemNo,LineItem.ReqNo,Mat.MaterialCode,Mat.MaterialName,Import_DispatchDetails, +Mat.UOM,Quantity,ReqMas.Requestedby,Rate,ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount , +ProductPrice,Tax.*,LineItem.CostCenterCode , POMaster.*,sup.SupplierName,sup.Address +FROM T_PurchaseOrder_LineItem LineItem +join T_Requestion_Master ReqMas on ReqMas.ReqNo=LineItem.ReqNo +join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode +join T_Import_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo +join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO +join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID +where LineItem.PONO =?'; + + $query = $this->db->query($subQuery,array($PONO)); + + return $query->result(); + + + } + + + function GetCurrencyDetail($Currency='') + { + + $subQuery='SELECT * from T_Currency_Details where Currency_Code=?'; + $query=$this->db->query($subQuery,array($Currency)); + //print_r($query); + return $query->result(); + + } + + + function GerRequesterName($Requester='') + { + $subQuery='SELECT EmpID,FirstName,Departmentcode from T_Employee_Details where EmpID=?'; + + $query=$this->db->query($subQuery,array($Requester)); + + return $query->result(); + } + + + function GerRequesterDep($Depcode='') + { + $subQuery='SELECT DepartmentName from T_DepartmentDetails where DEPCode=?'; + $query=$this->db->query($subQuery,array($Depcode)); + + return $query->result(); + + } + + function GerCurrencyCodeName($Currencycode='') + { + $subQuery='SELECT * from T_Currency_Details where Currency_Code=?'; + $query=$this->db->query($subQuery,array($Currencycode)); + //print_r($this->db->last_query()); + return $query->result(); + + } + + + function GetPOStatus($Status='') + { + $subQuery='SELECT StatusName from T_Status where StatusCode=?'; + $query=$this->db->query($subQuery,array($Status)); + return $query->result(); + + } + + + function GetPaymentTerms($PONO='') + { + $subQuery='SELECT PaymentTerms from T_PurchaseOrder_Master where PONO=?'; + $query=$this->db->query($subQuery,array($PONO)); + //print_r($query); + return $query->result(); + + } + + + + + // function getSupplierPayment($Currency='') + // { + + // $subQuery='select distinct PaymentTerms from T_SupplierDetailsN'; + // $query=$this->db->query($subQuery,array($Currency)); + // //print_r($this->db->last_query()); + // return $query->result(); + + // } + + function getSupplierPayment($Config_ID='') + { + + // $subQuery='select distinct PaymentTerms from T_SupplierDetailsN'; + $subQuery='select ConfigValue from T_ConfigDetails where Config_ID=?'; + $query=$this->db->query($subQuery,array($Config_ID)); + //print_r($this->db->last_query()); + return $query->result(); + + } + + function GetWorkStatus($Config_ID='') + { + $subQuery = 'select ConfigValue from T_ConfigDetails where Config_ID=?'; + $query=$this->db->query($subQuery,array($Config_ID)); + //print_r($query); + return $query->result(); + } + + + + + +function GetImportPurchaseOrderDetails($PONO = '') + { + + $subQuery ='SELECT distinct LineItem.LineItemNo,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName, +Mat.UOM,Quantity,Rate,Req.Status,ROUND((Quantity *Rate),2 ) as BasicValue,ReceivedQuantity, +QuantityRejected,ROUND(ReceivedQuantity-QuantityRejected)as PendingQty, + ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount,LandingCharge,HighSeasSalesCharge,CustomDuty,ExciseDuty,ExciseDutyEdCess,CustomEdCess,POMast.ExchangeRate,AfterLandingCharge,AfterHighSeasSalesCharge,AfterCustomDuty,AfterExciseDuty,AfterExciseDutyEdCess,AddlExciseDuty,AfterAddlExciseDuty,Grossdutypayable,AvailableModvat,Grossexpensesduetocustomduty,purchaseratePerKG,CustomDutyExpensesPerKG,RMCIncludingCustomersPerKG,QuantityKG,BasicPriceInMTon,ProductPrice,CustomSHCess,AfterCustomSHCess,AfterExciseDutySHCess,ExciseDutySHCess,AfterCustomEdCess,ROUND((Quantity *Rate)+(RMCIncludingCustomersPerKG*Quantity),2)as TotalOrderValue,ROUND((POMast.ExchangeRate*BasicPriceInMTon),2) as BasicINRValue,TotalValue,CurrencyType,ReceivedQuantity, + + Req.CostCenterCode,Dept.DepartmentName FROM T_PurchaseOrder_LineItem LineItem + join T_PurchaseOrder_Master POMast on POMast.PONO = LineItem.PONO + join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode + join T_Import_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo + join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo + join T_Employee_Details emp on Req.Requestedby = emp.EmpID + + left join T_MRIR_Details Det on Det.MaterialCode=LineItem.MaterialCode + + join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode where LineItem.PONO =?'; + //print_r($subQuery); + + $query = $this->db->query($subQuery,array($PONO)); + + return $query->result(); + + + } + + + +function GetCurrencytype() + { + + $subQuery = 'select * from T_Currency_Details'; + + $query = $this->db->query($subQuery); + + return $query->result(); + } + + function GetINRCurrencytype($Currency_Code='') + { + $subQuery='select * from T_Currency_Details where Currency_Code=?'; + $query=$this->db->query($subQuery,array($Currency_Code)); + //print_r($this->db->last_query()); + return $query->result(); + + } + + + + + + + // To Update the PO + function updatePOMaster($PONO,$PODetails) + { + $this->db->where('PONO', $PONO); + $this->db->update('T_PurchaseOrder_Master', $PODetails); + + return TRUE; + } + + + // To update Parent PO as Amended PO + function updateAmendPOMaster($PONO,$PODetail) + { + echo $PONO."from model"; + + + $this->db->where('PONO', $PONO); + $this->db->update('T_PurchaseOrder_Master', $PODetail); + $insert_id = $this->db->affected_rows(); + + return $insert_id; + } + /** + * This function is used to check the Line Item is already available in the database + * @return array $result : This is result of the query + */ + function LineItemExists($LineItemNo) + { + $this->db->select('LineItemNo,TaxID'); + $this->db->from('T_Service_Tax'); + $this->db->where('LineItemNo ',$LineItemNo ); + //$this->db->where('Requestedby ',$ReqBy ); + $query = $this->db->get(); + + if ($query->num_rows > 0) { + //echo $result->num_rows; + return $query->result_array(); + } + } + /** + * This function is used to check the Revenue Line Item is already available in the database + * @return array $result : This is result of the query + */ + function LineItemExistsinRevenueTax($LineItemNo) + { + $this->db->select('LineItemNo'); + $this->db->from('T_Revenue_Tax'); + $this->db->where('LineItemNo ',$LineItemNo ); + $query = $this->db->get(); + + if ($query->num_rows > 0) { + return $query->result_array(); + } + } + + + function LineItemExistsinImportTax($LineItemNo) + { + $this->db->select('LineItemNo'); + $this->db->from('T_Import_Tax'); + $this->db->where('LineItemNo ',$LineItemNo ); + $query = $this->db->get(); + + if ($query->num_rows > 0) { + return $query->result_array(); + } + } + // To Update the PO Line Item + function updatePOLineItem($PONO,$LineItemNo,$PODetails) + { + $this->db->where('PONO', $PONO); + $this->db->where('LineItemNo', $LineItemNo); + $this->db->update('T_PurchaseOrder_LineItem', $PODetails); + + return TRUE; + } + /*// To Update the Service Tax Item */ + function updateServiceTax($LineItemNo,$PODetails) + { + + $this->db->where('LineItemNo', $LineItemNo); + $this->db->update('T_Service_Tax', $PODetails); + + // print_r($this->db->last_query()); + + return TRUE; + } + + /*// To Update the Revenue Tax Item */ + function updateRevenueTax($LineItemNo,$PODetails) + { + $this->db->where('LineItemNo', $LineItemNo); + $this->db->update('T_Revenue_Tax', $PODetails); + + // print_r($this->db->last_query()); + + return TRUE; + } + + function updateImportTax($LineItemNo,$PODetails) + { + $this->db->where('LineItemNo', $LineItemNo); + $this->db->update('T_Import_Tax', $PODetails); + + // print_r($this->db->last_query()); + + return TRUE; + } + + function getLastInsertedPO() + { + $this->db->select('max(PONO) as PO'); + $this->db->from('T_PurchaseOrderDetails'); + $query = $this->db->get(); + + return $query->result_array(); + } + + + /* This Method to get all the Department name for the requistion */ + function getDepartmentListForAllReq() + { + $subQuery ='SELECT DISTINCT DEPT.DEPCode,DEPT.DepartmentName FROM T_Requestion_Master REQ + JOIN T_Employee_Details EMP ON REQ.Requestedby = EMP.EmpID + JOIN T_DepartmentDetails DEPT ON EMP.Departmentcode = DEPT.DEPCode WHERE REQ.Status not in(?,?,?,?)'; + + $query = $this->db->query($subQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED)); + //print_r($query); + return $query->result(); + } + /* + This Method to get all department list + */ + function getDepartmentAllList() + { + $subQuery ='SELECT DISTINCT DEPCode,DepartmentName FROM T_DepartmentDetails'; + + $query = $this->db->query($subQuery); + //print_r($query); + return $query->result(); + } + + + function getStatusListforAllReq() + { + $subQuery ='SELECT DISTINCT STAT.StatusCode, STAT.StatusName FROM T_Requestion_Master REQ + JOIN T_Status STAT on REQ.Status = STAT.StatusCode where STAT.StatusCode not in (?,?,?,?)'; + $query = $this->db->query($subQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED)); + + // print_r( $this->db->last_query()); + + return $query->result(); + } + + function getStatusByDepartment($DepNo='') + { + + $subQuery ='SELECT DISTINCT STAT.StatusCode ,STAT.StatusName FROM T_Requestion_Master REQ + JOIN T_Employee_Details EMP ON REQ.Requestedby = EMP.EmpID + JOIN T_DepartmentDetails DEPT ON EMP.Departmentcode = DEPT.DEPCode + JOIN T_Status STAT ON REQ.Status = STAT.StatusCode + WHERE DEPT.DEPCode=? AND REQ.Status NOT IN (?,?,?,?)'; + $query = $this->db->query($subQuery,array($DepNo,REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED)); + + return $query->result_array(); + } + + function getRequistionListbySearch($Depid='',$Status='',$FromDate='',$ToDate='') + { + $subQuery =' SELECT ReqNo,ReqType,Requestedby,EMP.FirstName,EMP.Designation,STAT.StatusCode ,STAT.StatusName,ReqDate,DEPT.DEPCode,DEPT.DepartmentName FROM T_Requestion_Master REQ + JOIN T_Employee_Details EMP ON REQ.Requestedby = EMP.EmpID + JOIN T_DepartmentDetails DEPT ON EMP.Departmentcode = DEPT.DEPCode + JOIN T_Status STAT on REQ.Status = STAT.StatusCode + where REQ.Status NOT IN (?,?,?,?,?)'; + + $appendQuery = $subQuery ; + + if($Depid != '' && $Status != '' && $FromDate != '' && $ToDate != '') + { + $appendQuery .= ' AND DEPT.DEPCode=? AND STAT.StatusCode=? AND ReqDate >= ? AND ReqDate <= ?'; + //echo "$appendQuery";die(); + $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid ,$Status,$FromDate,$ToDate)); + //print_r($this->db->last_query()); + return $query->result_array(); + } + else if($Depid != '' && $Status == '' && $FromDate == '' && $ToDate == '') + { + $appendQuery .= ' AND DEPT.DEPCode=?'; + + $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid)); + //print_r($this->db->last_query()); + return $query->result_array(); + } + else if($Depid == '' && $Status != '' && $FromDate == '' && $ToDate == '') + { + $appendQuery .= ' AND STAT.StatusCode=?'; + + $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Status)); + //print_r($this->db->last_query()); + return $query->result_array(); + } + else if($Depid == '' && $Status == '' && $FromDate != '' && $ToDate != '') + { + $appendQuery .= ' AND ReqDate >= ? AND ReqDate <= ?'; + + $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$FromDate,$ToDate)); + //print_r($this->db->last_query()); + return $query->result_array(); + } + else if($Depid != '' && $Status != '' && $FromDate == '' && $ToDate == '') + { + $appendQuery .= ' AND DEPT.DEPCode=? AND STAT.StatusCode=?'; + + $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid ,$Status)); + // print_r($this->db->last_query()); + return $query->result_array(); + } + else if($Depid != '' && $Status == '' && $FromDate != '' && $ToDate != '') + { + $appendQuery .= ' AND DEPT.DEPCode=? AND ReqDate >= ? AND ReqDate <= ?'; + + $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid ,$FromDate,$ToDate)); + //print_r($this->db->last_query()); + return $query->result_array(); + } + else if($Depid == '' && $Status != '' && $FromDate != '' && $ToDate != '') + { + $appendQuery .= ' AND STAT.StatusCode=? AND ReqDate >= ? AND ReqDate <= ?'; + + $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Status ,$FromDate,$ToDate)); + // print_r($this->db->last_query()); + return $query->result_array(); + } + else + { + $query = $this->db->query($subQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED)); + //print_r($this->db->last_query()); + return $query->result(); + } + + } + + function UpdateRequistItemStatus() + { + $query = $this->db->query("update T_Requestion_Details REQ + JOIN T_PurchaseOrder_LineItem line ON REQ.ReqNo = line.ReqNo + JOIN T_PurchaseOrder_Master PO ON PO.PONO = line.PONO + set REQ.Status = CASE WHEN REQ.Quantity = line.Quantity THEN 'ST022' WHEN REQ.Quantity > line.Quantity THEN 'ST023' ELSE 'ST003' END , + REQ.updatedOn= CURRENT_TIMESTAMP + where PO.Status ='".PO_CREATED."'"); + + //$query ->next_result(); + + } + function UpdateRequistionStatus() + { + $result = $this->db-> query("CALL P_UPDATE_REQUISTIONSTATUS_New()") or die(mysql_error()); + + $result ->next_result(); + + } + /** + * This function is used to delete the Line item from details into Database + * @return array $result : This is result of the query + */ + function DeletePOLineItem( $LineItem='',$ReqNo='',$MaterialCode='') + { + $this->db->where('LineItemNo', $LineItem); + $this->db->where('ReqNo', $ReqNo); + $this->db->where('MaterialCode', $MaterialCode); + $this->db->delete('T_PurchaseOrder_LineItem'); + + return TRUE; + } + + /** + * This function is used to delete the Revenue item from details into Database + * @return array $result : This is result of the query + */ + function DeletePORevenueTax( $LineItem='') + { + $this->db->where('LineItemNo', $LineItem); + $this->db->delete('T_Revenue_Tax'); + + return TRUE; + } + + /** + * This function is used to delete Service Tax from details into Database + * @return array $result : This is result of the query + */ + function DeletePOServiceTax( $LineItem='') + { + $this->db->where('LineItemNo', $LineItem); + $this->db->delete('T_Service_Tax'); + + return TRUE; + } + + + function DeletePOImportTax( $LineItem='') + { + $this->db->where('LineItemNo', $LineItem); + $this->db->delete('T_Import_Tax'); + + return TRUE; + } + + /** + * This function is used to get the List of PO details to the approver + * @return array $result : This is result of the query + join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode + */ + function getPOList($Amendment) + { + + $this->db->distinct(); + $this->db->select('mast.PONO,mast.TotalOrderValue,st.StatusCode,st.StatusName,emp.FirstName,mast.CreatedDate,ccm.CostCenterName,mast.POType as ReqType,bud.BudgetAmount,mast.Remarks'); + $this->db->from('T_PurchaseOrder_Master mast'); + $this->db->join('T_Status st', 'st.StatusCode=mast.Status'); + $this->db->join('tbl_users tbl', 'mast.createdby=tbl.userid'); + $this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid'); + $this->db->join('T_PurchaseOrder_LineItem req', 'req.PONO= mast.PONO'); + $this->db->join('T_Requestion_Master rmast','rmast.ReqNo=req.ReqNo'); + $this->db->join('T_CostCenter_Budget bud','bud.CostCenterCode = req.CostCenterCode and bud.BudgetType = rmast.ReqType'); + $this->db->join('T_CostCenter_Master ccm','ccm.CostCenterCode = req.CostCenterCode and ccm.CostCenterCode = bud.CostCenterCode'); + // $this->db->where('mast.Status',PO_AMENDED); // EMERGENGY PO + if($Amendment=='A'){ //A- Approved + $this->db->or_where('mast.Status',PO_CREATED);//PO CREATED + $this->db->or_where('mast.Status',PO_ONHOLD);//ON HOLD + $this->db->or_where('mast.Status',PO_AWAITING_RELEASE);// PO APPROVED + $this->db->or_where('mast.Status',PO_RELEASED);//PO RELEASED + $this->db->or_where('mast.Status',REQITEM_Emergency_PO_CREATED); // EMERGENGY PO + // $this->db->or_where('mast.Status',PO_AMENDED); // EMERGENGY PO + } + else if($Amendment=='R'){ // R -RELEASED + $this->db->or_where('mast.Status',PO_AWAITING_RELEASE);// PO APPROVED + $this->db->or_where('mast.Status',PO_RELEASED); + } + $result=$this->db->get(); + // print_r($this->db->last_query()); + return $result->result(); + + + + + + } + + + function UpdatePO($store, $PONO) + { + + $this->db->where('PONO', $PONO); + $this->db->update('T_PurchaseOrder_Master', $store); + + return TRUE; + } + + function GetReleasedDetails($PONO){ + $this->db->select('mast.ReleasedOn,re.FirstName'); + $this->db->from('T_PurchaseOrder_Master mast'); + $this->db->join('tbl_users tbl','mast.ReleasedBy=tbl.userid'); + $this->db->join('T_Employee_Details re','re.EmpID=tbl.EmpID'); + $this->db->where('mast.PONO',$PONO); + $result=$this->db->get(); + //print_r($this->db->last_query()); +//die(); + return $result->result(); + + } + //This is get the capital po list for edit + +function getCapitalPurchaseOrderDetails($PONO = '') + { + + $subQuery ='SELECT distinct LineItem.LineItemNo,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName, +Mat.UOM,Quantity,Rate,Req.Status,ROUND((ServiceTax.ServiceTax + ServiceTax.EducessTax + ServiceTax.SecHigherEducessTax + ServiceTax.KrishiKalyantax + ServiceTax.SwachhBharattax),2) as ServiceTaxamount + ,ServiceTax.TotalValue,ServiceTax,EducessTax,ServiceTax.SecHigherEducessTax,ServiceTax.KrishiKalyantax,ServiceTax.SwachhBharattax, + ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount,LandingCharge,HighSeasSalesCharge,CustomDuty,ExciseDuty,ExciseDutyEdCess,CustomEdCess,POMast.ExchangeRate,POMast.ExchangeRateCalculatedon,POMast.TotalOrderValue as BasicValue,POMast.CapitalRange,AfterLandingCharge,AfterHighSeasSalesCharge,AfterCustomDuty,AfterExciseDuty,AfterExciseDutyEdCess,AddlExciseDuty,AfterAddlExciseDuty,Grossdutypayable,AvailableModvat,Grossexpensesduetocustomduty,purchaseratePerKG,CustomDutyExpensesPerKG,RMCIncludingCustomersPerKG,QuantityKG,BasicPriceInMTon,ProductPrice,CustomSHCess,AfterCustomSHCess,AfterExciseDutySHCess,ExciseDutySHCess,AfterCustomEdCess,ROUND((POMast.ExchangeRate*BasicPriceInMTon*Quantity),2) as BasicINRValue,Tax.TotalValue as ImportTotalValue,POMast.CurrencyType, + + Req.CostCenterCode,Dept.DepartmentName FROM T_PurchaseOrder_LineItem LineItem + join T_PurchaseOrder_Master POMast on POMast.PONO = LineItem.PONO +join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode + join T_Service_Tax ServiceTax on ServiceTax.LineItemNo = LineItem.LineItemNo + join T_Import_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo + join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo + join T_Employee_Details emp on Req.Requestedby = emp.EmpID + + join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode where LineItem.PONO =?'; + //print_r($subQuery); + + $query = $this->db->query($subQuery,array($PONO)); + + return $query->result(); + + + } + +// This Method to get the Capital PO Details for pdf + function GetCapitalPurchaseOrderDetailsForPDF($PONO = '') + { + + $subQuery ='SELECT distinct LineItem.LineItemNo,ReqNo,Mat.MaterialCode,Mat.MaterialName, + Mat.UOM,Quantity,Rate,ROUND((Quantity *Rate),2 ) as BasicValue , + ROUND((ServiceTax + EducessTax + SecHigherEducessTax + KrishiKalyantax + SwachhBharattax),2)as Taxamount + ,TotalValue,ServiceTax,EducessTax,SecHigherEducessTax,KrishiKalyantax,SwachhBharattax,CostCenterCode , POMaster.*,sup.SupplierName,sup.Address + FROM T_PurchaseOrder_LineItem LineItem + join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode + join T_Service_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo + join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO + join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID + where LineItem.PONO =?'; + $query = $this->db->query($subQuery,array($PONO)); + + return $query->result(); + + + } + // get requested by details + function GetRequesedByDetails($PONO){ + $this->db->select('mast.CreatedBy,re.FirstName,Dept.DEPCode,Dept.DepartmentName'); + $this->db->from('T_PurchaseOrder_Master mast'); + $this->db->join('tbl_users tbl','mast.CreatedBy=tbl.userid'); + $this->db->join('T_Employee_Details re','re.EmpID=tbl.EmpID'); + $this->db->join('T_DepartmentDetails Dept', 're.Departmentcode = Dept.DEPCode'); + + $this->db->where('mast.PONO',$PONO); + $result=$this->db->get(); + + return $result->result(); + + } + + // get domestic capital po list + + + function getDomesticCapitalPurchaseOrderDetails($PONO = '') + { + + $subQuery ='SELECT distinct LineItem.LineItemNo,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName, + Mat.UOM,Quantity,Rate,Req.Status,ROUND((ServiceTax.ServiceTax + ServiceTax.EducessTax + ServiceTax.SecHigherEducessTax + ServiceTax.KrishiKalyantax + ServiceTax.SwachhBharattax),2) as ServiceTaxamount + ,ServiceTax.TotalValue,ServiceTax,EducessTax,ServiceTax.SecHigherEducessTax,ServiceTax.KrishiKalyantax,ServiceTax.SwachhBharattax, + POMast.ExchangeRate,POMast.ExchangeRateCalculatedon,POMast.TotalOrderValue as BasicValue,POMast.CapitalRange,ROUND((POMast.TotalOrderValue),2) as BasicINRValue,POMast.CurrencyType, + + Req.CostCenterCode,Dept.DepartmentName FROM T_PurchaseOrder_LineItem LineItem + join T_PurchaseOrder_Master POMast on POMast.PONO = LineItem.PONO + join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode + join T_Service_Tax ServiceTax on ServiceTax.LineItemNo = LineItem.LineItemNo + join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo + join T_Employee_Details emp on Req.Requestedby = emp.EmpID + + join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode where LineItem.PONO =?'; + //print_r($subQuery); + + $query = $this->db->query($subQuery,array($PONO)); + + return $query->result(); + + + } + //get pdf po requistion details + + + function GetPdfRequistionDetails($PONO){ + $this->db->select('LineItem.ReqNo'); + $this->db->from('T_PurchaseOrder_LineItem LineItem'); + $this->db->where('LineItem.PONO',$PONO); + $result=$this->db->get(); + $ReqNo=''; + + foreach ($result->result() as $res){ + + if($ReqNo==$res->ReqNo){ + + } + else{ + $ReqNo = $res->ReqNo; + $this->db->select('ReqMast.ReqNo,ReqMast.CostCenterCode,re.FirstName,Dept.DEPCode,Dept.DepartmentName'); + $this->db->from('T_Requestion_Master ReqMast'); + $this->db->join('T_Employee_Details re','re.EmpID=ReqMast.Requestedby'); + $this->db->join('T_DepartmentDetails Dept', 're.Departmentcode = Dept.DEPCode'); + $this->db->where('ReqMast.ReqNo',$ReqNo); + $Reqresult=$this->db->get(); + $Details['RequistionNo']= $Reqresult->result()[0]->ReqNo; + $Details['RequestedName']= $Reqresult->result()[0]->FirstName; + $Details['RequestedDept']= $Reqresult->result()[0]->DepartmentName; + $Details['CostCenterCode']= $Reqresult->result()[0]->CostCenterCode; + $ResultArray[]=$Details; + } + + } + + $RequistionDetails = $ResultArray; + return $RequistionDetails; + } + function GetLineItemReceivedQty($ParentPO,$MaterialCode) + { + $this->db->select('ReceivedQuantity'); + $this->db->from('T_PurchaseOrder_LineItem'); + + $this->db->where('PONO',$ParentPO); + $this->db->where('MaterialCode',$MaterialCode); + $result=$this->db->get(); + + return $result->result_array(); + } + + //get paymentTerms details + + function getPaymentTermsDetails($Payment_ID='') + { + + + $getpaymentQuery='select distinct PaymentID,PaymentTerms,Details from T_PaymentTerms'; + $paymentQuery=$this->db->query($getpaymentQuery); + + return $paymentQuery->result(); + + } + /** + * This function is used to get status in status table + + */ + function getStatus($StatusType = '') + { + $this->db->select('StatusCode,StatusName '); + $this->db->from('T_Status'); + $this->db->where('StatusType', $StatusType); + $query = $this->db->get(); + + return $query->result(); + } +} \ No newline at end of file diff --git a/application/models/requistion_model.php b/application/models/requistion_model.php index 5e4ef7e5..eb896e9c 100755 --- a/application/models/requistion_model.php +++ b/application/models/requistion_model.php @@ -283,7 +283,7 @@ class requistion_model extends CI_Model function getRequistDetails($ReqID,$NoArray='') { - $subQuery = 'select distinct ReqNo,ReqType,Status,Requestedby,DATE_FORMAT(mast.CreatedDate, "%d-%m-%Y") as CreatedDate ,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,DATE_FORMAT(mast.ReqDate, "%d-%m-%Y") as ReqDate,CostCenterCode + $subQuery = 'select distinct ReqNo,ReqType,Status,Requestedby,DATE_FORMAT(mast.CreatedDate, "%d-%m-%Y") as CreatedDate,Schedule_Type,NumberOfService,Service_Period ,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,DATE_FORMAT(mast.ReqDate, "%d-%m-%Y") as ReqDate,CostCenterCode from T_Requestion_Master mast join T_Employee_Details emp on mast.Requestedby = emp.EmpID join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode diff --git a/application/models/requistion_model.php~ b/application/models/requistion_model.php~ new file mode 100755 index 00000000..eb896e9c --- /dev/null +++ b/application/models/requistion_model.php~ @@ -0,0 +1,500 @@ +db->select('SupplierID, SupplierName,ADeleteRequistionLineItemddress'); + $this->db->from('T_SupplierDetailsN'); + //$this->db->where('roleId !=', 1); + $query = $this->db->get(); + + return $query->result(); + } + /** + * This function is used to get the userId information + * @return array $result : This is result of the query + */ + function getusers() + { + $this->db->select('userId, name'); + $this->db->from('tbl_users'); + //$this->db->where('roleId !=', 1); + $query = $this->db->get(); + + return $query->result(); + } + /* This function is used to getEditRequistItemList view the information + * @return array $result : This is result of the query + */ + function getEditRequistItemList($ReqNo) + { + + /* $result = $this->db-> query("CALL P_GET_REQUISTITEMLIST('".$ReqNo."')") or die(mysql_error()); + + + //echo 'REQUISTITEMLIST Line item view successfully'; + + + + $result ->next_result(); + + if($result->num_rows > 0) + { + + return $result->result(); + } + + */ + $subQuery ='select distinct Req.ReqNo, Mat.MaterialCode,Mat.MaterialName,Mat.UOM, Req.Quantity,if (Po.Quantity is null,0,Po.Quantity) as POQTY,sta.StatusName from T_MaterialMaster Mat join T_Requestion_Details Req on Req.MaterialCode = Mat.MaterialCode + left join T_PurchaseOrder_LineItem Po on Po.ReqNo = Req.ReqNo and Po.MaterialCode = Req.MaterialCode + left join T_Status sta on sta.StatusCode = Req.Status + where Req.ReqNo = ?'; + + $query = $this->db->query($subQuery, array($ReqNo)); + + // print_r($this->db->last_query()); + return $query->result(); + + } + + /** + * This function is used to get the userId information + * @return array $result : This is result of the query + */ + function getStatus() + { + $this->db->select('StatusCode,StatusName '); + $this->db->from('T_Status'); + $this->db->where('StatusType', REQUISTSTATUS); + $this->db->where('StatusCode !=', REQ_DRAFT); + $query = $this->db->get(); + + return $query->result(); + } + /* This function is used to get the Raw Material information + * @return array $result : This is result of the query + */ + function getRequistionList($ReqNo,$IsArray='') + { + + $result = $this->db-> query("CALL P_GET_AllREQUISTION('".$ReqNo."')") or die(mysql_error()); + + { + //echo 'PO Line item Inserted successfully'; + if($IsArray != '') + { + + return $result->result_array(); + } + else + { + return $result->result(); + } + } + + + } + + /** + * This function is used to get Employee details based on Employee ID Selection + * @return array $result : This is result of the query + */ + function GetEmployeeDetails($EmpID) + { + + $this->db->select(' EMP.EmpID,EMP.Designation,DEPT.DEPCode,DEPT.DepartmentName'); + $this->db->from('T_Employee_Details EMP'); + $this->db->join('T_DepartmentDetails DEPT', 'EMP.Departmentcode = DEPT.DEPCode'); + $this->db->where('EMP.EmpID ',$EmpID ); + $query = $this->db->get(); + + return $query->result_array(); + } + + /** + * This function is used to get the Cost Center details for the Login user department + * @return array $result : This is result of the query + */ + function GetCostCenterByDept($DeptId) + { + + $this->db->select('Mast.CostCenterCode,Mast.CostCenterName'); + $this->db->from('T_CostCenter_Master Mast '); + $this->db->join('T_CostCenter_Departments COST', 'COST.CostCenterCode = Mast.CostCenterCode'); + $this->db->where('COST.DEPCode ',$DeptId ); + $query = $this->db->get(); + // print_r( $this->db->last_query()); + return $query->result_array(); + } + /** + * This function is used to get the Available BudgetAmount for the Cost center + * @return array $result : This is result of the query + */ + function GetAvailableBudgetAmount($CostCode,$Year,$BudgetType) + { + $this->db->select('BudgetAmount'); + $this->db->from('T_CostCenter_Budget'); + $this->db->where('CostCenterCode',$CostCode ); + $this->db->where('BudgetYear',$Year ); + $this->db->where('BudgetType',$BudgetType ); + $query = $this->db->get(); + + return $query->result_array(); + } + + function EditMaterialCode($ReqNo,$ReqType) + { + $subQuery ='SELECT Mat.MaterialCode,Mat.MaterialName,Mat.UOM + from T_MaterialMaster Mat where Mat.MaterialCode not in (select Req.MaterialCode from T_Requestion_Details Req + join T_Requestion_Master mast on Req.ReqNo = mast.ReqNo where mast.ReqNo=? and mast.ReqType=? + ) and Mat.MaterialType=?'; + + $query = $this->db->query($subQuery, array($ReqNo,$ReqType,$ReqType)); + + + return $query->result(); + + } + + + /** + * This function is used to get the Material details for the Request type + * @return array $result : This is result of the query + */ + function GetMaterialCode($ReqType,$NotArray='') + { + $this->db->select('MaterialCode, MaterialName,UOM'); + $this->db->from('T_MaterialMaster'); + $this->db->where('MaterialType',$ReqType ); + + $query = $this->db->get(); + if($NotArray == '') + { + return $query->result_array(); + } + else + { + return $query->result(); + } + } + /** + * This function is used to get the Raw Material information + * @return array $result : This is result of the query + */ + function getRawMaterialList($MaterialCode) + { + $this->db->select('MaterialName,UOM'); + $this->db->from('T_MaterialMaster'); + $this->db->where('MaterialCode',$MaterialCode ); + $query = $this->db->get(); + + return $query->result_array(); + } + + /** + * This function is used to get the Config value from configuration table + * @return array $result : This is result of the query + */ + function getConfigValue($ConfigID ,$ConfigValue = '') + { + + $this->db->select('ConfigValue'); + $this->db->from('T_ConfigDetails'); + $this->db->where('Config_id ',$ConfigID ); + if($ConfigValue != '') + { + $this->db->where('ConfigValue != ',$ConfigValue ); + } + $query = $this->db->get(); + + return $query->result(); + } + + + /** + * This function is used to get the All employees + * @return array $result : This is result of the query + */ + function getAllEmployees() + { + $this->db->select('EmpID,FirstName,LastName'); + $this->db->from('T_Employee_Details'); + $query = $this->db->get(); + + return $query->result(); + } + + /** + * This function is used to get the Employee Details + * @return array $result : This is result of the query + */ + function getEmpIdByUserID($UserID) + { + $subQuery ='SELECT EMP.EmpID,EMP.FirstName,EMP.Designation,DEPT.DEPCode,DEPT.DepartmentName + FROM T_Employee_Details EMP JOIN T_DepartmentDetails DEPT ON + EMP.Departmentcode = DEPT.DEPCode + WHERE EMP.EmpID=(select EmpID from tbl_users where userId=?)'; + + $query = $this->db->query($subQuery, array($UserID)); + + + return $query->result(); + } + + /** + * This function is used to get the CostCenter for the Selected Employee + * @return array $result : This is result of the query + */ + function getCostCenterUserID($UserID) + { + $subQuery ='SELECT Mast.CostCenterCode,Mast.CostCenterName from T_CostCenter_Master Mast + LEFT JOIN T_CostCenter_Departments COST ON COST.CostCenterCode = Mast.CostCenterCode + WHERE COST.DEPCode=(select Departmentcode from T_Employee_Details where EmpID = (select EmpID from tbl_users where userId=?))'; + + $query = $this->db->query($subQuery, array($UserID)); + //print_r($this->db->last_query()); + return $query->result(); + } + + /** + * This function is used to get the Purchase order Type + * @return array $result : This is result of the query + */ + function CheckDraftStatus($UserID) + { + + $subQuery = 'select count(ReqNo) as cnt,ReqNo from T_Requestion_Master where + Requestedby= ( select EmpID from tbl_users where userId=?) and status=?'; + + $query = $this->db->query($subQuery, array($UserID,REQ_DRAFT)); + + return $query->result(); + } + /** + * This function is used to get the Requsition List for the login user + * @return array $result : This is result of the query + */ + function getRequistDetails($ReqID,$NoArray='') + { + + $subQuery = 'select distinct ReqNo,ReqType,Status,Requestedby,DATE_FORMAT(mast.CreatedDate, "%d-%m-%Y") as CreatedDate,Schedule_Type,NumberOfService,Service_Period ,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,DATE_FORMAT(mast.ReqDate, "%d-%m-%Y") as ReqDate,CostCenterCode + from T_Requestion_Master mast + join T_Employee_Details emp on mast.Requestedby = emp.EmpID + join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode + where ReqNo=?'; + + $query = $this->db->query($subQuery, array($ReqID)); + if($NoArray == '') + { + return $query->result_array(); + } + else + { + return $query->result(); + } + } + /** + * This function is used to get the Requsition List for the login user + * @return array $result : This is result of the query + */ + function getRequistListUserID($UserID) + { + + $subQuery = 'select ReqNo, ReqType ,Status,CreatedDate ,StatusName from T_Requestion_Master mast + join T_Status st on st.StatusCode= mast.Status where + Requestedby = ( select EmpID from tbl_users where userId=?) and Status != ? '; + + $query = $this->db->query($subQuery, array($UserID,REQ_DELETED)); + + return $query->result(); + } + /** + * This function is used to get the Requsition List for the login user + * @return array $result : This is result of the query + */ + function getRequistItemList($ReqID,$NoArray='') + { + + $subQuery = 'select distinct Req.ReqNo, Mat.MaterialCode,Mat.MaterialName,Mat.UOM, Req.Quantity,sum(Po.Quantity) as POQTY,sta.StatusName from T_MaterialMaster Mat + left join T_Requestion_Details Req on Req.MaterialCode = Mat.MaterialCode + left join T_PurchaseOrder_LineItem Po on Po.ReqNo = Req.ReqNo and Po.MaterialCode = Req.MaterialCode + left join T_Status sta on sta.StatusCode = Req.Status where Req.ReqNo=? group by Po.ReqNo,Req.MaterialCode'; + + + $query = $this->db->query($subQuery, array($ReqID)); + if($NoArray == '') + { + return $query->result_array(); + } + else + { + return $query->result(); + } + } + + /** + * This function is used to add the Requistion into the Database + * @return array $result : This is result of the query + */ + function addRequistion($Requistion) + { + $this->db->trans_start(); + $this->db->insert('T_Requestion_Master', $Requistion); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + if($insert_id>0) + { + $subQuery = 'select max(ReqNo) as ReqNo from T_Requestion_Master'; + + $query = $this->db->query($subQuery); + + return $query->result_array(); + } + + } + /** + * This function is used to check the Request is in Draft status + * @return array $result : This is result of the query + */ + function RequistionIsExists($ReqBy) + { + $this->db->select('ReqNo'); + $this->db->from('T_Requestion_Master'); + $this->db->where('Status ',REQ_DRAFT ); + $this->db->where('Requestedby ',$ReqBy ); + $query = $this->db->get(); + + if ($query->num_rows > 0) { + //echo $result->num_rows; + return $query->result_array(); + } + } + /** + * This function is used to check the Request Line Item is in Draft status + * @return array $result : This is result of the query + */ + function LineItemIsExists($ReqNo,$MaterialCode) + { + $this->db->select('ReqNo'); + $this->db->from('T_Requestion_Details'); + $this->db->where('ReqNo ',$ReqNo ); + $this->db->where('MaterialCode ',$MaterialCode ); + $query = $this->db->get(); + + if ($query->num_rows > 0) { + //echo $result->num_rows; + return $query->result_array(); + } + } + /** + * This function is used to add the Line item details to the Database + * @return array $result : This is result of the query + */ + function addRequistionDetails($Requistion) + { + $this->db->trans_start(); + $this->db->insert('T_Requestion_Details', $Requistion); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + // print_r($this->db->last_query()); + return $insert_id; + + } + /** + * This function is used to delete the Line item from details into Database + * @return array $result : This is result of the query + */ + function DeleteRequistionLineItem( $ReqNo,$MaterialCode) + { + $this->db->where('ReqNo', $ReqNo); + $this->db->where('MaterialCode', $MaterialCode); + $this->db->delete('T_Requestion_Details'); + + return TRUE; + } + + /** + * This function is used to update the details into Database + * @return array $result : This is result of the query + */ + function UpdateRequistionLineItem($Requist, $ReqNo,$MaterialCode) + { + $this->db->where('ReqNo', $ReqNo); + $this->db->where('MaterialCode', $MaterialCode); + $this->db->update('T_Requestion_Details',$Requist); + + return TRUE; + } + + /** + * This function is used to update the details into Database + * @return array $result : This is result of the query + */ + function UpdateRequistion($Requistion, $ReqNo) + { + $this->db->where('ReqNo', $ReqNo); + $this->db->update('T_Requestion_Master', $Requistion); + + return TRUE; + } + + + + /** + * This function is used to get the List of Requist details to the approver + * @return array $result : This is result of the query + */ + function getApproverRequistList($UserID,$Status = '',$FromDate='' ,$ToDate='') + { + // echo 'UserId: '.$UserID . 'From: '.$FromDate .'TO: '. $ToDate. 'Status: '. $Status; + + $subQuery = 'select distinct ReqNo,Status,mast.CreatedDate,Requestedby,emp.FirstName,mast.Comments,st.StatusName + from T_Requestion_Master mast join T_Employee_Details emp on mast.Requestedby = emp.EmpID + join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode + join T_Status st on st.StatusCode = mast.Status + where status not in(?,?,?) and emp.Departmentcode in (select DEPCode from T_DepartmentDetails where HeadDept= + (select HeadDept from T_DepartmentDetails where DEPCode = (select Departmentcode from T_Employee_Details where + EmpID=(select EmpID from tbl_users where userId=?))))'; + $subQuery1 = $subQuery; + $query =''; + + if($FromDate != '' && $ToDate != '' && $Status !='' ) + { + + $Where = 'and mast.CreatedDate >= ? and mast.CreatedDate <= ? and Status=?'; + $subQuery1 .= $Where; + $query = $this->db->query($subQuery1, array(REQ_DRAFT,REQ_DELETED,REQ_REJECTED,$UserID,$FromDate,$ToDate,$Status)); + } + else if($FromDate != '' && $ToDate != '' && $Status =='') + { + $Where = 'and mast.CreatedDate >= ? and mast.CreatedDate <= ? '; + $subQuery1 .= $Where; + $query = $this->db->query($subQuery1, array(REQ_DRAFT,REQ_DELETED,REQ_REJECTED,$UserID,$FromDate,$ToDate)); + } + else if($Status != '' && $FromDate == '' && $ToDate == '') + { + $Where = 'and Status = ?'; + $subQuery1 .= $Where; + $query = $this->db->query($subQuery1, array(REQ_DRAFT,REQ_DELETED,REQ_REJECTED,$UserID,$Status)); + } + + else + { + $query = $this->db->query($subQuery, array(REQ_DRAFT,REQ_DELETED,REQ_REJECTED,$UserID)); + } + + //print_r($this->db->last_query()); + return $query->result(); + } + + + +} + + \ No newline at end of file diff --git a/application/views/EditservicePurchaseorder.php b/application/views/EditservicePurchaseorder.php index 5f83219a..5bd1a7bf 100755 --- a/application/views/EditservicePurchaseorder.php +++ b/application/views/EditservicePurchaseorder.php @@ -9,15 +9,14 @@ $DeliverOption=''; $DeliveryAddress =''; $PONOStatus = ''; $PONO = ''; - $TotalServiceTax = 0; - $TotalEducessTax = 0.0; - $TotalSecHigherEducessTax = 0.0; - $TotalKrishiKalyantax = 0.0; - $TotalSwachhBharattax = 0.0; + + $TotalCgst = 0.0; + $TotalSgst = 0.0; + $TotalIgst = 0.0; $TotalSummary = 0.0; $TotalBasicAmount = 0.0; $ServiceDescription = ''; - + $OtherAmt = 0.0; $Deliverydt=''; $DeliverSchedule=''; $MaxPoDate = ''; @@ -64,9 +63,8 @@ if(!empty($POMaster)) $PONOStatus = $Req->StatusCode; $PONO = $Req->PONO; $ServiceDescription = $Req->ServiceDescription; - //$PaymentTerms=$Req->PaymentTerms; - $PayableAT=$Req->PayableAT; - $PaymentDays=$Req->PaymentDays; + //Terms=$Req->PaymentTerms; + $WrkStatus=$Req->ServiceWorkStatus; $StatusName=$Req->StatusName; } @@ -92,7 +90,7 @@ if(!empty($RequistionDetails)) if(!empty($AvlBudAmt)) { - $AvlAmount = $AvlBudAmt; + $AvlAmount = number_format($AvlBudAmt, 2, '.', ''); } @@ -172,17 +170,10 @@ $('#drpSupplier').change(function() { if(obj.SupplierID === id) { $("#SupAddress").val(obj.Address); - $("#PayableAT").val(obj.PayableAT); - var a=obj.PaymentDays; - console.log(a); - if (a=="After") - { - //alert(); - document.getElementById("After").checked = true; - - } - else - document.getElementById("Before").checked = true; + $("#PaymentTerms").val(obj.PaymentID); + + + } @@ -260,9 +251,19 @@ for(i=2;i<=rows;i++){ { $("#deptName").val(obj.DepartmentName); $("#CostCenter").val(obj.CostCenterCode); + if(obj.Service_Period!='' && obj.Service_Period!=null){ + $("#Frequency").val(obj.Service_Period +'-' + obj.NumberOfService); + $("#FrequencyNo").val(obj.NumberOfService); + + } + else{ + var text='One Time'; + $("#Frequency").val(text); + $("#FrequencyNo").val(1); + } } }); - $("#AvlBudAmt").val(AvlBudAmt); + $("#AvlBudAmt").val(parseFloat(AvlBudAmt).toFixed(2)); // For Binding Material list center for the selected Requistion Number $("#MaterialCode").append( $('').val("0").html("Select Material Code") ); var isAdded = "0"; @@ -345,9 +346,46 @@ $('#MaterialCode').change(function() { } }); +$('#EditMaterialCode').change(function() { + + var id = $('#EditMaterialCode').val(); + $("#EditItemName").val(''); +$("#EditUOM").val(''); +$("#EditQuantity").val(''); +//$("#EditRate").val(''); +//$("#txtEditBasicValue").val(''); + RequistQuantity = ''; + //clearEditTaxField(); + if(id != '0') + { + var Material = ; + + for(i=0;i -
+
@@ -747,8 +765,8 @@ $(document).ready(function () {
-
-
+
+
Select Delivery By
@@ -765,19 +783,28 @@ $(document).ready(function () { $WrkStatus); - //print_r( $options); + if(!empty($WorkStatus)) { + + foreach ($WorkStatus as $WorkSID): + if($WrkStatus==$WorkSID->StatusCode){ + $optionsWork[$WorkSID->StatusCode] = $WorkSID->StatusName; + } + + + endforeach; foreach ($WorkStatus as $SID): - - $options[$SID->ConfigValue] = $SID->ConfigValue; + if($WrkStatus!=$SID->StatusCode){ + $optionsWork[$SID->StatusCode] = $SID->StatusName; + } + endforeach; } - echo form_dropdown('workstatus', $options,set_value('workstatus'),'id="workstatus"' ,'required="true"' ,'class="form-control select2'); + echo form_dropdown('workstatus', $optionsWork,set_value('workstatus'),'id="workstatus"' ,'required="true"' ,'class="form-control select2'); ?>
@@ -804,45 +831,43 @@ $(document).ready(function () {
Payment Details -
- Payable Terms - -
- -
- Payable AT - - 'PayableAT','value' => set_value('PayableAT',$PayableAT),'id'=>'PayableAT', 'class' => 'form-control' ,'required' => 'true'); - echo form_input($data); - ?> - -
- -
- Payment Date
- - - "Payment", "id"=>"Before", "value"=>"0", 'checked'=>set_radio('Payment', '0', TRUE))); ?>     - - "Payment", "id"=>"After", "value"=>"1", 'checked'=>set_radio('Payment', '1', FALSE))); ?> +
+ + + PaymentID){ + + $optionsPay[$pay2->PaymentID] = $pay2->PaymentTerms; + + } + endforeach; + foreach ($Payment as $pay1): + + if($Terms!=$pay1->PaymentID){ + + $optionsPay[$pay1->PaymentID] = $pay1->PaymentTerms; + + } + endforeach; + } - - -
+ echo form_dropdown('PaymentTerms', $optionsPay,set_value('PaymentTerms'),'id="PaymentTerms"' ,'required="true"' ,'class="form-control select2'); + + ?> + + + + +
+
@@ -862,237 +887,257 @@ $(document).ready(function () {
-
-
- -
- 'Select Req No'); - if(!empty($RequistionDetails)) - { - foreach ($RequistionDetails as $SID): - $RL[$SID->ReqNo] = $SID->ReqNo.' '.' - '.' '.$SID->DepartmentName; - endforeach; - } - - echo form_dropdown('ReqNo', $RL,set_value('ReqNo'),'id="ReqNo"' ,'class="form-control"'); +
+
+ +
+ 'Select Req No'); + if(!empty($RequistionDetails)) + { + foreach ($RequistionDetails as $SID): + $RL[$SID->ReqNo] = $SID->ReqNo.' '.' - '.' '.$SID->DepartmentName; + endforeach; + } + + echo form_dropdown('ReqNo', $RL,set_value('ReqNo'),'id="ReqNo"' ,'class="form-control"'); - ?> -
-
- -
- -
- 'deptName','value' => set_value('deptName'),'id'=>'deptName', 'class' => 'form-control'); - echo form_input($data); - ?> -
-
-
- -
- 'CostCenter','value' => set_value('CostCenter'),'id'=>'CostCenter', 'class' => 'form-control' ,'readonly' => 'true'); - echo form_input($data); - - ?> -
-
-
- -
- 'AvlBudAmt','value' => set_value('AvlBudAmt'),'id'=>'AvlBudAmt', 'class' => 'form-control num' ,'readonly' => 'true'); - echo form_input($data); - ?> -
-
-
-
-
- -
- 'Item Code'); - //print_r( $options); - - - - echo form_dropdown('MaterialCode', $options,set_value('MaterialCode'),'id="MaterialCode"' ,'class="form-control"'); - - ?> -
-
-
- -
- 'ItemName','value' => set_value('ItemName'),'id'=>'ItemName', 'class' => 'form-control' ,'readonly' => 'true'); - echo form_input($data); - ?> -
-
-
- -
- 'UOM','value' => set_value('UOM'),'id'=>'UOM', 'class' => 'form-control' ,'readonly' => 'true'); - echo form_input($data); - ?> -
-
-
- -
- 'Frequency','value' => set_value('Frequency'),'id'=>'Frequency', 'class' => 'form-control' ); - echo form_input($data); - ?> -
-
-
-
-
- -
- 'Quantity','value' => set_value('Quantity'),'id'=>'Quantity', 'class' => 'form-control num' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'Ratechange()'); - echo form_input($data); - ?> -
-
-
- -
- 'Rate','value' => set_value('Rate'),'id'=>'Rate', 'class' => 'form-control num' ,'onkeypress'=>'return isNumberKey(event);' ,'onchange'=>'Ratechange()' ); - echo form_input($data); - ?> -
-
-
- -
- 'txtBasicValue','value' => set_value('txtBasicValue'),'id'=>'txtBasicValue', 'class' => 'form-control num' ,'readonly' => 'true'); - echo form_input($data); - ?> -
-
- -
-
-
-
- - Service Tax @14% : -
- -
-
- 'AfterServiceTax','value' => set_value('AfterServiceTax'),'id'=>'AfterServiceTax', 'class' => 'form-control num' ,'placeholder' => 'After Service Tax','readonly' => 'true'); - echo form_input($data); - ?> -
- -
- -
-
-
- Edu. cess @2% on service Tax : - -
- -
-
- 'AfterEduCess','value' => set_value('AfterEduCess'),'id'=>'AfterEduCess', 'class' => 'form-control num' ,'placeholder' => 'After Edu.','readonly' => 'true'); - echo form_input($data); - ?> -
- -
- -
-
- -
- Sec. & Higher Edu. cess @1 % on service Tax : - -
- -
-
- 'AfterSecHighTax','value' => set_value('AfterSecHighTax'),'id'=>'AfterSecHighTax', 'class' => 'form-control num' ,'placeholder' => 'After High Edu.','readonly' => 'true'); - echo form_input($data); - ?> -
- -
-
-
- -
- Krishi Kalyan tax @.5 % on Basic Amount: - -
- -
-
- 'AfterKrishiTax','value' => set_value('AfterKrishiTax'),'id'=>'AfterKrishiTax', 'class' => 'form-control num' ,'placeholder' => 'After Krishi Kalyan tax.','readonly' => 'true'); - echo form_input($data); - ?> -
- -
-
-
- -
- Swachh Bharat tax @.5 % on Basic Amount: - -
- -
-
- 'AfterSwachhTax','value' => set_value('AfterSwachhTax'),'id'=>'AfterSwachhTax', 'class' => 'form-control num' ,'placeholder' => 'After High Edu.','readonly' => 'true'); - echo form_input($data); - ?> -
- -
-
- -
-
- -
-
-
- 'TotalOrderValue','value' => set_value('TotalOrderValue'),'id'=>'TotalOrderValue', 'class' => 'form-control num' ,'placeholder' => 'Total value','readonly' => 'true'); - echo form_input($data); - ?> + ?> +
-
-
- -
+ +
+ +
+ 'deptName','value' => set_value('deptName'),'id'=>'deptName', 'class' => 'form-control'); + echo form_input($data); + ?> +
+
+
+ +
+ 'CostCenter','value' => set_value('CostCenter'),'id'=>'CostCenter', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + + ?> +
+
+
+ +
+ 'AvlBudAmt','value' => set_value('AvlBudAmt'),'id'=>'AvlBudAmt', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+
+
+
+ +
+ 'Item Code'); + //print_r( $options); + + + + echo form_dropdown('MaterialCode', $options,set_value('MaterialCode'),'id="MaterialCode"' ,'class="form-control"'); + + ?> +
+
+
+ +
+ 'ItemName','value' => set_value('ItemName'),'id'=>'ItemName', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+
+ 'txtSpcialInstruction','value' => set_value('txtSpcialInstruction',$ServiceDescription),'id'=>'txtSpcialInstruction', 'class' => 'form-control'); + echo form_input($data); + ?> + +
+ +
+
+
+ +
+ 'UOM','value' => set_value('UOM'),'id'=>'UOM', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+
+ +
+ 'Frequency','value' => set_value('Frequency'),'id'=>'Frequency', 'class' => 'form-control','readonly' => 'true' ); + echo form_input($data); + ?> + +
+
+
+ +
+ 'Quantity','value' => set_value('Quantity'),'id'=>'Quantity', 'class' => 'form-control num' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'Ratechange()'); + echo form_input($data); + ?> +
+
+
+ +
+ 'Rate','value' => set_value('Rate'),'id'=>'Rate', 'class' => 'form-control num' ,'onkeypress'=>'return isNumberKey(event);' ,'onchange'=>'Ratechange()' ); + echo form_input($data); + ?> +
+
+
+ +
+ 'txtBasicValue','value' => set_value('txtBasicValue'),'id'=>'txtBasicValue', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+ +
+ +
+
+ + CGST In % +
+
+
+ + 'Cgst','value' => set_value('Cgst',0),'id'=>'Cgst', 'class' => 'form-control num' ,'placeholder' => 'CGST TAX PERCENTAGE','onchange'=>'Ratechange()'); + echo form_input($data); + ?> +
+ +
+
+
+ + 'AfterCgst','value' => set_value('AfterCgst'),'id'=>'AfterCgst', 'class' => 'form-control num' ,'placeholder' => 'After CGST','readonly' => 'true'); + echo form_input($data); + ?> +
+ +
+ +
+
+
+ + SGST In % +
+ +
+
+ + 'Sgst','value' => set_value('Sgst',0),'id'=>'Sgst', 'class' => 'form-control num' ,'placeholder' => 'SGST TAX PERCENTAGE','onchange'=>'Ratechange()'); + echo form_input($data); + ?> +
+ +
+
+
+ + 'AfterSgst','value' => set_value('AfterSgst'),'id'=>'AfterSgst', 'class' => 'form-control num' ,'placeholder' => 'After SGST','readonly' => 'true'); + echo form_input($data); + ?> +
+ +
+ +
+ +
+
+ + IGST In % +
+ +
+
+ + 'Igst','value' => set_value('Igst',0),'id'=>'Igst', 'class' => 'form-control num' ,'placeholder' => 'IGST TAX PERCENTAGE','onchange'=>'Ratechange()'); + echo form_input($data); + ?> +
+ +
+
+
+ + 'AfterIgst','value' => set_value('AfterIgst'),'id'=>'AfterIgst', 'class' => 'form-control num' ,'placeholder' => 'After IGST','readonly' => 'true'); + echo form_input($data); + ?> +
+ +
+ +
+ + +
+
+ +
+
+
+ 'OtherAllowances','value' => set_value('OtherAllowances',0),'id'=>'OtherAllowances', 'class' => 'form-control num' ,'placeholder' => 'Other Allowances','onchange'=>'Ratechange()'); + echo form_input($data); + ?> +
+
+
+
+
+ +
+
+
+ 'TotalOrderValue','value' => set_value('TotalOrderValue'),'id'=>'TotalOrderValue', 'class' => 'form-control num' ,'placeholder' => 'Total value','readonly' => 'true'); + echo form_input($data); + ?> +
+
+
-
-
+
@@ -1144,7 +1189,7 @@ $(document).ready(function () {
- +
'EditAvlBudAmt','value' => set_value('EditAvlBudAmt'),'id'=>'EditAvlBudAmt', 'class' => 'form-control num' ,'readonly' => 'true'); @@ -1175,7 +1220,16 @@ $(document).ready(function () { ?>
-
+
+ 'EdittxtSpcialInstruction','value' => set_value('EdittxtSpcialInstruction',$ServiceDescription),'id'=>'EdittxtSpcialInstruction', 'class' => 'form-control'); + echo form_input($data); + ?> +
+ +
+
+
-
+
'EditFrequency','value' => set_value('EditFrequency'),'id'=>'EditFrequency', 'class' => 'form-control' ); + $data = array('name' => 'EditFrequency','value' => set_value('EditFrequency'),'id'=>'EditFrequency', 'class' => 'form-control' ,'readonly' => 'true'); echo form_input($data); - ?> + ?> +
-
-
-
+
-
+
-
+
-
-
-
- - Service Tax @14% : -
- -
-
- 'EditAfterServiceTax','value' => set_value('EditAfterServiceTax'),'id'=>'EditAfterServiceTax', 'class' => 'form-control num','readonly' => 'true'); - echo form_input($data); - ?> -
- -
-
+
+
+ + CGST In % +
+ +
+
+ + 'EditCgst','value' => set_value('EditCgst'),'id'=>'EditCgst', 'class' => 'form-control num' ,'placeholder' => 'CGST TAX PERCENTAGE','onchange'=>'EditRatechange()'); + echo form_input($data); + ?> +
+ +
+
+
+ + 'EditAfterCgst','value' => set_value('EditAfterCgst'),'id'=>'EditAfterCgst', 'class' => 'form-control num' ,'placeholder' => 'After CGST','readonly' => 'true'); + echo form_input($data); + ?> +
+ +
+ +
+
+
+ + SGST In % +
+ +
+
+ + 'EditSgst','value' => set_value('EditSgst'),'id'=>'EditSgst', 'class' => 'form-control num' ,'placeholder' => 'SGST TAX PERCENTAGE','onchange'=>'EditRatechange()'); + echo form_input($data); + ?> +
+ +
+
+
+ + 'EditAfterSgst','value' => set_value('EditAfterSgst'),'id'=>'EditAfterSgst', 'class' => 'form-control num' ,'placeholder' => 'After SGST','readonly' => 'true'); + echo form_input($data); + ?> +
+ +
+ +
+ +
+
+ + IGST In % +
+ +
+
+ + 'EditIgst','value' => set_value('EditIgst'),'id'=>'EditIgst', 'class' => 'form-control num' ,'placeholder' => 'IGST TAX PERCENTAGE','onchange'=>'EditRatechange()'); + echo form_input($data); + ?> +
+ +
+
+
+ + 'EditAfterIgst','value' => set_value('EditAfterIgst'),'id'=>'EditAfterIgst', 'class' => 'form-control num' ,'placeholder' => 'After IGST','readonly' => 'true'); + echo form_input($data); + ?> +
+ +
+ +
+
+
+ > +
+
+
+ 'EditOtherAllowances','value' => set_value('EditOtherAllowances'),'id'=>'EditOtherAllowances', 'class' => 'form-control num','onchange'=>'EditRatechange()'); + echo form_input($data); + ?> +
+
+
-
- Edu. cess @2% on service Tax : - -
- -
-
- 'EditAfterEduCess','value' => set_value('EditAfterEduCess'),'id'=>'EditAfterEduCess', 'class' => 'form-control num' ,'readonly' => 'true'); - echo form_input($data); - ?> -
- -
- -
-
- -
- Sec. & Higher Edu. cess @1 % on service Tax : - -
- -
-
- 'EditAfterSecHighTax','value' => set_value('EditAfterSecHighTax'),'id'=>'EditAfterSecHighTax', 'class' => 'form-control num' ,'readonly' => 'true'); - echo form_input($data); - ?> -
- -
-
-
- -
- Krishi Kalyan tax @.5 % on Basic Amount: - -
- -
-
- 'EditAfterKrishiTax','value' => set_value('EditAfterKrishiTax'),'id'=>'EditAfterKrishiTax', 'class' => 'form-control num' ,'readonly' => 'true'); - echo form_input($data); - ?> -
- -
-
-
- -
- Swachh Bharat tax @.5 % on Basic Amount: - -
- -
-
- 'EditAfterSwachhTax','value' => set_value('EditAfterSwachhTax'),'id'=>'EditAfterSwachhTax', 'class' => 'form-control num' ,'readonly' => 'true'); - echo form_input($data); - ?> -
- -
-
- -
>
@@ -1324,16 +1389,17 @@ $(document).ready(function () {
+ -

-
+
@@ -1350,42 +1416,63 @@ $(document).ready(function () { SNo Requisition No - Item Name + Item Code + Item Description Quantity - UOM + UOM Rate Basic Amount Tax Amount Total Order Amount + Actual Quantity + Received Quantity + Pending Quantity Action Schedule_Type!='Recurring'){ + $FrequencyNo=intval(1); + $Frequency='One Time'; + } + else{ + $FrequencyNo=$record->NumberOfService; + $Frequency=$record->Service_Period; + } + ?> ReqNo ?> - MaterialName ?> + MaterialCode ?> + ServiceMaterialDescription ?> Quantity ?> - UOM ?> + UOM ?> + Rate ?> - BasicValue ?> + BasicValue * $FrequencyNo, 2, '.', ''); ?> Taxamount ?> TotalValue ?> + Quantity ?> + ReceivedQuantity ?> + Quantity - $record->ReceivedQuantity, 2, '.', ''); ?> - + @@ -1394,13 +1481,21 @@ $(document).ready(function () { - - - - - + + + + + + - + + + + + + + + ServiceTax; - $TotalEducessTax = $TotalEducessTax + $record->EducessTax; - $TotalSecHigherEducessTax = $TotalSecHigherEducessTax + $record->SecHigherEducessTax; - $TotalKrishiKalyantax = $TotalKrishiKalyantax + $record->KrishiKalyantax; - $TotalSwachhBharattax = $TotalSwachhBharattax + $record->SwachhBharattax; + $TotalCgst = $TotalCgst + $record->After_CGST; + $TotalSgst = $TotalSgst + $record->After_SGST; + $TotalIgst = $TotalIgst + $record->After_IGST; + $OtherAmt = $OtherAmt + $record->otherallowance; $TotalSummary = $TotalSummary + $record->TotalValue; @@ -1436,69 +1530,71 @@ $(document).ready(function () {
-
- - 'txtTotBasicAmount','value' => set_value('txtTotBasicAmount',number_format($TotalBasicAmount,2)),'id'=>'txtTotBasicAmount', 'class' => 'form-control num' ,'readonly' => 'true'); - echo form_input($data); - ?> -
-
- + +
+ + 'txtTotBasicAmount','value' => set_value('txtTotBasicAmount',number_format($TotalBasicAmount, 2, '.', '')),'id'=>'txtTotBasicAmount', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+ + 'txtTotCgst','value' => set_value('txtTotCgst',number_format($TotalCgst, 2, '.', '')),'id'=>'txtTotCgst', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+ + +
+ + 'txtTotSgst','value' => set_value('txtTotSgst',number_format($TotalSgst, 2, '.', '')),'id'=>'txtTotSgst', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+ + 'txtTotIgst','value' => set_value('txtTotIgst',number_format($TotalIgst, 2, '.', '')),'id'=>'txtTotIgst', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+ +
+ 'txtTotalServiceTax','value' => set_value('txtTotalServiceTax',$TotalServiceTax),'id'=>'txtTotalServiceTax', 'class' => 'form-control num' ,'readonly' => 'true'); - echo form_input($data); - ?> -
-
- - 'txtTotalEducess','value' => set_value('txtTotalEducess',$TotalEducessTax),'id'=>'txtTotalEducess', 'class' => 'form-control num' ,'readonly' => 'true'); - echo form_input($data); - ?> -
-
-
-
- - 'txtTotHigherEdu','value' => set_value('txtTotHigherEdu',$TotalSecHigherEducessTax),'id'=>'txtTotHigherEdu', 'class' => 'form-control num' ,'readonly' => 'true'); - echo form_input($data); - ?> -
-
- + $data = array('name' => 'ToatalOtherAllowances','value' => set_value('ToatalOtherAllowances',number_format($OtherAmt, 2, '.', '')),'id'=>'ToatalOtherAllowances', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> + +
+
+ 'txtTotalKrishiKalyan','value' => set_value('txtTotalKrishiKalyan',$TotalKrishiKalyantax),'id'=>'txtTotalKrishiKalyan', 'class' => 'form-control num' ,'readonly' => 'true'); - echo form_input($data); - ?> -
-
- - 'txtTotSwachhBharat','value' => set_value('txtTotSwachhBharat',$TotalSwachhBharattax),'id'=>'txtTotSwachhBharat', 'class' => 'form-control num' ,'readonly' => 'true'); - echo form_input($data); - ?> -
-
-
-
-
-
- 'txtTotalOrderValueSummary','value' => set_value('txtTotalOrderValueSummary',$TotalSummary),'id'=>'txtTotalOrderValueSummary', 'class' => 'form-control num' ,'readonly' => 'true'); + $data = array('name' => 'txtTotalOrderValueSummary','value' => set_value('txtTotalOrderValueSummary',number_format($TotalSummary, 2, '.', '')),'id'=>'txtTotalOrderValueSummary', 'class' => 'form-control num' ,'readonly' => 'true'); echo form_input($data); ?>
+
+ +
+ 'ScopeofWork','value' => set_value('ScopeofWork',$ServiceDescription),'id'=>'ScopeofWork', 'class' => 'form-control', 'rows' => '10', 'cols' => '40' ); + echo form_textarea($data); + ?> +
+

@@ -1517,7 +1613,7 @@ $(document).ready(function () {


-
+
Request On 'Status','value' => set_value('Status',$StatusName),'id'=>'Status', 'class' => 'form-control' ,'readonly' => 'true'); echo form_input($data); ?> -

+
@@ -1557,7 +1653,7 @@ $(document).ready(function () { <%=index%> <%=ReqNo%> - + <%=MaterialCode%> <%=MaterialName%> <%=Quantity%> <%=UOM%> @@ -1565,6 +1661,9 @@ $(document).ready(function () { <%=BasicAmount%> <%=Taxvalue%> <%=TotalValue%> +<%=ActualQuantity%> +<%=ReceivedQuantity%> +<%=PendingQuantity%>     @@ -1584,18 +1683,10 @@ var userid = ''; }; -var paymentday=; -if (paymentday=="After") -{ -//alert(); - document.getElementById("After").checked = true; -} -else -{ - document.getElementById("Before").checked = true; -} + $("#EDITSERVICE").on("shown.bs.modal", function(e) { + userid = $(e.relatedTarget).data('userid'); var tr= document.getElementById(userid); @@ -1612,16 +1703,25 @@ $("#EDITSERVICE").on("shown.bs.modal", function(e) { $('#EditQuantity').val($('#quantity'+userid).val()); RequistQuantity = $('#quantity'+userid).val(); $('#EditRate').val($('#itemRate'+userid).val()); - $('#txtEditBasicValue').val(cellval[6].innerHTML); - $('#EditAfterServiceTax').val($('#ServiceTax'+userid).val()); - $('#EditAfterEduCess').val($('#EduCess'+userid).val()); - $('#EditAfterSecHighTax').val($('#SecHighTax'+userid).val()); - $('#EditAfterKrishiTax').val($('#KrishiTax'+userid).val()); - $('#EditAfterSwachhTax').val($('#SwachhTax'+userid).val()); - $('#EditFrequency').val($('#ServiceFrequency'+userid).val()); + $('#txtEditBasicValue').val(cellval[7].innerHTML); + $('#EditCgst').val($('#Cgst'+userid).val()); + $('#EditSgst').val($('#Sgst'+userid).val()); + $('#EditIgst').val($('#Igst'+userid).val()); + $('#EditAfterCgst').val($('#AfterCgst'+userid).val()); + $('#EditAfterSgst').val($('#AfterSgst'+userid).val()); + $('#EditAfterIgst').val($('#AfterIgst'+userid).val()); + if($('#FrequencyValue'+userid).val()==1){ + $('#EditFrequency').val($('#Frequency'+userid).val()); + $("#EditFrequencyNo").val(1); + } + else{ + $('#EditFrequency').val($('#Frequency'+userid).val()+'-'+$('#FrequencyNo'+userid).val()); + $("#EditFrequencyNo").val($('#FrequencyValue'+userid).val()); + } - $('#EditTotalOrderValue').val(cellval[8].innerHTML); - + $('#EditTotalOrderValue').val(cellval[9].innerHTML); + $('#EditOtherAllowances').val($('#OtherAmt'+userid).val()); + $('#EdittxtSpcialInstruction').val($('#ItemDescription'+userid).val()); RequistQuantity = $('#quantity'+userid).val(); @@ -1690,23 +1790,20 @@ $('.AddService').click(function(){ var materialName = $("#ItemName").val(); var uom = $("#UOM").val(); var quantity = $("#Quantity").val(); - var itemRate = $("#Rate").val(); + var itemRate = parseFloat($("#Rate").val()).toFixed(2); - var AfterServiceTax = $("#AfterServiceTax").val(); - - - var AfterEduCess = $("#AfterEduCess").val(); - - - var AfterSecHighTax = $("#AfterSecHighTax").val(); - + var Cgst = $("#Cgst").val(); + var AfterCgst = $("#AfterCgst").val(); + var Sgst = $("#Sgst").val(); + var AfterSgst = $("#AfterSgst").val(); + var Igst = $("#Igst").val(); + var AfterIgst = $("#AfterIgst").val(); + var FrequencyValue = $("#FrequencyNo").val(); - var AfterKrishiTax = $("#AfterKrishiTax").val(); - - - var AfterSwachhTax = $("#AfterSwachhTax").val(); - + var Frequency=$("#Frequency").val(); + var ServiceDescription = $('#txtSpcialInstruction').val(); + var OtherAmt = $('#OtherAllowances').val(); var TotalOrderValue = $("#TotalOrderValue ").val(); @@ -1732,7 +1829,7 @@ $('.AddService').click(function(){ var template = jQuery("#ServiceList").html(); - $('#ServiceAppend').append(_.template(template,{index:temp,ReqNo:Reqnumber,MaterialName:materialName,Quantity:quantity,UOM:uom,Rate:itemRate,BasicAmount:basicval,Taxvalue:TotalTaxValue,TotalValue:TotalOrderValue})); + $('#ServiceAppend').append(_.template(template,{index:temp,ReqNo:Reqnumber,MaterialCode:materialCode,MaterialName:ServiceDescription,Quantity:quantity,UOM:uom,Rate:itemRate,BasicAmount:basicval,Taxvalue:TotalTaxValue,TotalValue:TotalOrderValue,ActualQuantity:quantity,ReceivedQuantity:0,PendingQuantity:quantity})); @@ -1747,13 +1844,16 @@ $('.AddService').click(function(){ addHidden(theForm,"uom"+temp,uom); addHidden(theForm,"quantity"+temp,quantity); addHidden(theForm,"itemRate"+temp,itemRate); - - addHidden(theForm,"ServiceTax"+temp,AfterServiceTax); - addHidden(theForm,"EduCess"+temp,AfterEduCess); - addHidden(theForm,"SecHighTax"+temp,AfterSecHighTax); - addHidden(theForm,"KrishiTax"+temp,AfterKrishiTax); - addHidden(theForm,"SwachhTax"+temp,AfterSwachhTax); - + addHidden(theForm,"Cgst"+temp,Cgst); + addHidden(theForm,"AfterCgst"+temp,AfterCgst); + addHidden(theForm,"Sgst"+temp,Sgst); + addHidden(theForm,"AfterSgst"+temp,AfterSgst); + addHidden(theForm,"Igst"+temp,Igst); + addHidden(theForm,"AfterIgst"+temp,AfterIgst); + addHidden(theForm,"Frequency"+temp,Frequency); + addHidden(theForm,"FrequencyValue"+temp,FrequencyValue); + addHidden(theForm,"ItemDescription"+temp,ServiceDescription); + addHidden(theForm,"OtherAmt"+temp,OtherAmt); addHidden(theForm,"TotalOrderValue"+temp,TotalOrderValue); $('#txtRowCount').val(temp); @@ -1777,21 +1877,18 @@ $('.AddService').click(function(){ var itemRate = $("#EditRate").val(); + + var Cgst = $("#EditCgst").val(); + var AfterCgst = $("#EditAfterCgst").val(); + var Sgst = $("#EditSgst").val(); + var AfterSgst = $("#EditAfterSgst").val(); + var Igst = $("#EditIgst").val(); + var AfterIgst = $("#EditAfterIgst").val(); - var AfterServiceTax = $("#EditAfterServiceTax").val(); - - - var AfterEduCess = $("#EditAfterEduCess").val(); - - - var AfterSecHighTax = $("#EditAfterSecHighTax").val(); - - - var AfterKrishiTax = $("#EditAfterKrishiTax").val(); - - - var AfterSwachhTax = $("#EditAfterSwachhTax").val(); - + var Frequency=$("#EditFrequency").val(); + var FrequencyValue=$("#EditFrequencyNo").val(); + var ServiceDescription = $('#EdittxtSpcialInstruction').val(); + var OtherAmt = $('#EditOtherAllowances').val(); var TotalOrderValue = $("#EditTotalOrderValue ").val(); @@ -1804,13 +1901,14 @@ $('.AddService').click(function(){ var tr= document.getElementById(userid); var cellval = tr.cells; - cellval[2].innerHTML = editDescription; - cellval[3].innerHTML = editQuantity; - cellval[4].innerHTML =editUOM; - cellval[5].innerHTML =itemRate; - cellval[6].innerHTML =basicval; - cellval[7].innerHTML =TotalTaxValue; - cellval[8].innerHTML =TotalOrderValue; + cellval[2].innerHTML = editMaterialCode; + cellval[3].innerHTML = ServiceDescription; + cellval[4].innerHTML = editQuantity; + cellval[5].innerHTML =editUOM; + cellval[6].innerHTML =parseFloat(itemRate).toFixed(2); + cellval[7].innerHTML =parseFloat(basicval).toFixed(2); + cellval[8].innerHTML =parseFloat(TotalTaxValue).toFixed(2); + cellval[9].innerHTML =parseFloat(TotalOrderValue).toFixed(2); $('#materialCode'+userid).val(editMaterialCode); @@ -1818,13 +1916,16 @@ $('.AddService').click(function(){ $('#uom'+userid).val(editUOM); $('#CostCode'+userid).val(CostCode); $('#quantity'+userid).val(editQuantity); - $('#itemRate'+userid).val(itemRate); - $('#ServiceTax'+userid).val(AfterServiceTax); - $('#EduCess'+userid).val(AfterEduCess); - $('#SecHighTax'+userid).val(AfterSecHighTax); - $('#KrishiTax'+userid).val(AfterKrishiTax); - $('#SwachhTax'+userid).val(AfterSwachhTax); - $('#TotalOrderValue'+userid).val(TotalOrderValue); + $('#itemRate'+userid).val(itemRate); + $('#Cgst'+userid).val(Cgst); + $('#AfterCgst'+userid).val(AfterCgst); + $('#Sgst'+userid).val(Sgst); + $('#AfterSgst'+userid).val(AfterSgst); + $('#Igst'+userid).val(Igst); + $('#AfterIgst'+userid).val(AfterIgst); + $('#TotalOrderValue'+userid).val(TotalOrderValue); + $('#ItemDescription'+userid).val(ServiceDescription); + $('#OtherAmt'+userid).val(OtherAmt); populateValueMainFormForEditServiceTax(); } @@ -1841,11 +1942,10 @@ $('.AddService').click(function(){ function populateValueMainFormForServiceTax() { - var AfterServiceTax = $('#AfterServiceTax').val() == '' ? '0.00' : $('#AfterServiceTax').val(); - var AfterEduCess = $('#AfterEduCess').val() == '' ? '0.00' : $('#AfterEduCess').val(); - var AfterSecHighTax = $('#AfterSecHighTax').val() == '' ? '0.00' : $('#AfterSecHighTax').val(); - var AfterKrishiTax = $('#AfterKrishiTax').val() == '' ? '0.00' : $('#AfterKrishiTax').val(); - var AfterSwachhTax = $('#AfterSwachhTax').val() == '' ? '0.00' : $('#AfterSwachhTax').val(); + var AfterCgst = $('#AfterCgst').val() == '' ? '0.00' : $('#AfterCgst').val(); + var AfterSgst = $('#AfterSgst').val() == '' ? '0.00' : $('#AfterSgst').val(); + var AfterIgst = $('#AfterIgst').val() == '' ? '0.00' : $('#AfterIgst').val(); + var OtherAmt = $('#OtherAllowances').val() == '' ? '0.00' : $('#OtherAllowances').val(); var TotalVal = $('#TotalOrderValue ').val() == '' ? '0.00' : $('#TotalOrderValue').val(); var BasicVal = $('#txtBasicValue').val() == '' ? '0.00' : $('#txtBasicValue').val(); @@ -1854,21 +1954,15 @@ function populateValueMainFormForServiceTax() var TotalOrderValueSummary = $('#txtTotalOrderValueSummary').val() == '' ? '0.00' : $('#txtTotalOrderValueSummary').val(); var totBasicAmt = $('#txtTotBasicAmount').val() == '' ? '0.00' : $('#txtTotBasicAmount').val(); - totBasicAmt = Number(totBasicAmt.replace(/[^0-9\.]+/g,"")); - - var TotalServiceTax = $('#txtTotalServiceTax').val() == '' ? '0.00' : $('#txtTotalServiceTax').val(); - var TotHigherEdu = $('#txtTotHigherEdu').val() == '' ? '0.00' : $('#txtTotHigherEdu').val(); - var TotalEducess = $('#txtTotalEducess').val() == '' ? '0.00' : $('#txtTotalEducess').val(); - var TotalKrishiKalyan = $('#txtTotalKrishiKalyan').val() == '' ? '0.00' : $('#txtTotalKrishiKalyan').val(); - var TotSwachhBharat = $('#txtTotSwachhBharat').val() == '' ? '0.00' : $('#txtTotSwachhBharat').val(); - - + var TotalCgst = $('#txtTotCgst').val() == '' ? '0.00' : $('#txtTotCgst').val(); + var TotSgst = $('#txtTotSgst').val() == '' ? '0.00' : $('#txtTotSgst').val(); + var TotalIgst = $('#txtTotIgst').val() == '' ? '0.00' : $('#txtTotIgst').val(); + var TotalAllowance = $('#ToatalOtherAllowances').val() == '' ? '0.00' : $('#ToatalOtherAllowances').val(); $('#txtTotBasicAmount').val((parseFloat(totBasicAmt) + parseFloat(BasicVal)).toFixed(2) ); - $('#txtTotalServiceTax').val((parseFloat(TotalServiceTax) + parseFloat(AfterServiceTax)).toFixed(2) ); - $('#txtTotHigherEdu').val((parseFloat(TotHigherEdu) + parseFloat(AfterSecHighTax)).toFixed(2) ); - $('#txtTotalEducess').val((parseFloat(TotalEducess) + parseFloat(AfterEduCess)).toFixed(2) ); - $('#txtTotalKrishiKalyan').val((parseFloat(TotalKrishiKalyan) + parseFloat(AfterKrishiTax)).toFixed(2) ); - $('#txtTotSwachhBharat').val((parseFloat(TotSwachhBharat) + parseFloat(AfterSwachhTax)).toFixed(2) ); + $('#txtTotCgst').val((parseFloat(TotalCgst) + parseFloat(AfterCgst)).toFixed(2) ); + $('#txtTotSgst').val((parseFloat(TotSgst) + parseFloat(AfterSgst)).toFixed(2) ); + $('#txtTotIgst').val((parseFloat(TotalIgst) + parseFloat(AfterIgst)).toFixed(2) ); + $('#ToatalOtherAllowances').val((parseFloat(TotalAllowance) + parseFloat(OtherAmt)).toFixed(2) ); $('#txtTotalOrderValueSummary').val((parseFloat(TotalOrderValueSummary) + parseFloat(TotalVal)).toFixed(2) ); } @@ -1876,16 +1970,15 @@ function populateValueMainFormForEditServiceTax() { var rows = document.getElementById('ServiceTable').rows.length; - - var TotServiceTax = 0; - var TotEduCess = 0; - var TotSecHighTax = 0; - var TotKrishiTax = 0; - var TotSwachhTax = 0; + + var TotCgst = 0; + var TotSgst = 0; + var TotIgst = 0; + var TotOther = 0; var TotSummary = 0; var TotBasicAmout = 0; - var i = 0; - do { + var i = 0; + do { i += 1; var tr= document.getElementById(i); //alert(tr); @@ -1896,49 +1989,47 @@ function populateValueMainFormForEditServiceTax() var rowid = cells[0].innerHTML; - var AfterServiceTax = $('#ServiceTax'+rowid).val() == '' ? '0.00' : $('#ServiceTax'+rowid).val(); - var AfterEduCess = $('#EduCess'+rowid).val() == '' ? '0.00' : $('#EduCess'+rowid).val(); - var AfterSecHighTax = $('#SecHighTax'+rowid).val() == '' ? '0.00' : $('#SecHighTax'+rowid).val(); - var AfterKrishiTax =$('#KrishiTax'+rowid).val() == '' ? '0.00' : $('#KrishiTax'+rowid).val(); - var AfterSwachhTax = $('#SwachhTax'+rowid).val() == '' ? '0.00' : $('#SwachhTax'+rowid).val(); + var AfterCgst = $('#AfterCgst'+rowid).val() == '' ? '0.00' : $('#AfterCgst'+rowid).val(); + var AfterSgst = $('#AfterSgst'+rowid).val() == '' ? '0.00' : $('#AfterSgst'+rowid).val(); + var AfterIgst = $('#AfterIgst'+rowid).val() == '' ? '0.00' : $('#AfterIgst'+rowid).val(); + var OtherAmt = $('#OtherAmt'+rowid).val() == '' ? '0.00' : $('#OtherAmt'+rowid).val(); var TotalVal =$('#TotalOrderValue'+rowid).val() == '' ? '0.00' : $('#TotalOrderValue'+rowid).val(); var Quantity = $('#quantity'+rowid).val() == '' ? '0.00' : $('#quantity'+rowid).val(); - var ItemRate = $('#itemRate'+rowid).val() == '' ? '0.00' : $('#itemRate'+rowid).val(); - var BasicVal = parseFloat(Quantity) * parseFloat(ItemRate); + var ItemRate = $('#itemRate'+rowid).val() == '' ? '0.00' : $('#itemRate'+rowid).val(); + var FrequencyValue = $('#FrequencyValue'+rowid).val() == '' ? '1.00' : $('#FrequencyValue'+rowid).val(); + var BasicVal = parseFloat(Quantity) * parseFloat(ItemRate) * parseFloat(FrequencyValue); - TotServiceTax = parseFloat(TotServiceTax) + parseFloat(AfterServiceTax); - TotEduCess = parseFloat(TotEduCess) + parseFloat(AfterEduCess); - TotSecHighTax = parseFloat(TotSecHighTax) + parseFloat(AfterSecHighTax); - TotKrishiTax = parseFloat(TotKrishiTax) + parseFloat(AfterKrishiTax); - TotSwachhTax = parseFloat(TotSwachhTax) + parseFloat(AfterSwachhTax); + TotCgst = parseFloat(TotCgst) + parseFloat(AfterCgst); + TotSgst = parseFloat(TotSgst) + parseFloat(AfterSgst); + TotIgst = parseFloat(TotIgst) + parseFloat(AfterIgst); + TotOther = parseFloat(TotOther) + parseFloat(OtherAmt); TotSummary = parseFloat(TotSummary) + parseFloat(TotalVal); TotBasicAmout = parseFloat(TotBasicAmout) + parseFloat(BasicVal); } - } while (i < rows); + } while (i < rows); $('#txtTotBasicAmount').val(parseFloat(TotBasicAmout).toFixed(2) ); - $('#txtTotalServiceTax').val(parseFloat(TotServiceTax).toFixed(2) ); - $('#txtTotHigherEdu').val(parseFloat(TotSecHighTax).toFixed(2) ); - $('#txtTotalEducess').val(parseFloat(TotEduCess).toFixed(2) ); - $('#txtTotalKrishiKalyan').val(parseFloat(TotKrishiTax).toFixed(2) ); - $('#txtTotSwachhBharat').val(parseFloat(TotSwachhTax).toFixed(2) ); + $('#txtTotCgst').val(parseFloat(TotCgst).toFixed(2) ); + $('#txtTotSgst').val(parseFloat(TotSgst).toFixed(2) ); + $('#txtTotIgst').val(parseFloat(TotIgst).toFixed(2) ); + $('#ToatalOtherAllowances').val(parseFloat(TotOther).toFixed(2) ); $('#txtTotalOrderValueSummary').val(parseFloat(TotSummary).toFixed(2) ); } + function calculateEditTaxValue() { - var ServiceTaxAmount = parseFloat($('#EditAfterServiceTax').val()); - var EduCessTaxAmount = parseFloat($('#EditAfterEduCess').val()); - var SecHighTaxAmount = parseFloat($('#EditAfterSecHighTax').val()); - var KrishiTaxAmount = parseFloat($('#EditAfterKrishiTax').val()); - var SwachhTaxAmount = parseFloat($('#EditAfterSwachhTax').val()); - - var TottaxAmt = ServiceTaxAmount+ EduCessTaxAmount + SecHighTaxAmount+ KrishiTaxAmount + SwachhTaxAmount; - return parseFloat(TottaxAmt.toFixed(2)); + var Cgst = parseFloat($('#EditAfterCgst').val()); + var Sgst = parseFloat($('#EditAfterSgst').val()); + var Igst = parseFloat($('#EditAfterIgst').val()); + + + var TottaxAmt = Cgst + Sgst + Igst; + return parseFloat(TottaxAmt).toFixed(2); } function clearServiceModalFields() { @@ -1954,17 +2045,22 @@ function clearServiceModalFields() $("#Rate").val(''); $("#txtBasicValue").val(''); - $("#AfterServiceTax").val(''); - $("#AfterEduCess").val(''); - $("#AfterSecHighTax").val(''); - $("#AfterKrishiTax").val(''); - $("#AfterSwachhTax").val(''); + $("#AfterCgst").val(0); + $("#AfterSgst").val(0); + $("#AfterIgst").val(0); + $("#Cgst").val(0); + $("#Sgst").val(0); + $("#Igst").val(0); + $("#OtherAllowances").val(0); + $("#txtSpcialInstruction").val(''); $("#TotalOrderValue ").val(''); + $("#Frequency").val(''); } var DeletedMaterialCode=''; var DeletedMaterialName=''; function DeleteRow(rowid) { + var id = []; var DelRows = $('#txtDeletedRow').val(); @@ -1978,11 +2074,12 @@ function DeleteRow(rowid) id[1]= ReqNo; id[2]= MaterialCode; id[3]= POType; - + + var answer = confirm(" Do you want to delete the Item from the List?") if (answer) { - + populateValueMainFormForDeleteItem(rowid); tr.parentNode.removeChild(tr); var removeItem = $('#materialCode'+rowid).val(); @@ -2070,7 +2167,7 @@ function DeleteRow(rowid) }}); } - populateValueMainFormForDeleteItem(rowid); + // populateValueMainFormForDeleteItem(rowid); } @@ -2079,48 +2176,41 @@ function populateValueMainFormForDeleteItem(rowid) { - //alert(rowid); - var TotServiceTax = $('#txtTotalServiceTax').val(); - var TotEduCess = $('#txtTotalEducess').val(); - var TotSecHighTax = $('#txtTotHigherEdu').val(); - var TotKrishiTax = $('#txtTotalKrishiKalyan').val(); - var TotSwachhTax = $('#txtTotSwachhBharat').val(); - var TotSummary = $('#TotalOrderValue').val(); + // alert(rows); + var TotCgst = $('#txtTotCgst').val(); + var TotSgst = $('#txtTotSgst').val(); + var TotIgst = $('#txtTotIgst').val(); + var TotOtherAmt = $('#ToatalOtherAllowances').val(); + var TotSummary = $('#txtTotalOrderValueSummary').val(); var TotBasicAmout = $('#txtTotBasicAmount').val(); - + - var AfterServiceTax = $('#ServiceTax'+rowid).val() == '' ? '0.00' : $('#ServiceTax'+rowid).val(); - var AfterEduCess = $('#EduCess'+rowid).val() == '' ? '0.00' : $('#EduCess'+rowid).val(); - var AfterSecHighTax = $('#SecHighTax'+rowid).val() == '' ? '0.00' : $('#SecHighTax'+rowid).val(); - var AfterKrishiTax =$('#KrishiTax'+rowid).val() == '' ? '0.00' : $('#KrishiTax'+rowid).val(); - var AfterSwachhTax = $('#SwachhTax'+rowid).val() == '' ? '0.00' : $('#SwachhTax'+rowid).val(); + var AfterCgst = $('#AfterCgst'+rowid).val() == '' ? '0.00' : $('#AfterCgst'+rowid).val(); + var AfterSgst = $('#AfterSgst'+rowid).val() == '' ? '0.00' : $('#AfterSgst'+rowid).val(); + var AfterIgst = $('#AfterIgst'+rowid).val() == '' ? '0.00' : $('#AfterIgst'+rowid).val(); + var OtherAmt = $('#OtherAmt'+rowid).val() == '' ? '0.00' : $('#OtherAmt'+rowid).val(); var TotalVal =$('#TotalOrderValue'+rowid).val() == '' ? '0.00' : $('#TotalOrderValue'+rowid).val(); var Quantity = $('#quantity'+rowid).val() == '' ? '0.00' : $('#quantity'+rowid).val(); var ItemRate = $('#itemRate'+rowid).val() == '' ? '0.00' : $('#itemRate'+rowid).val(); - var BasicVal = parseFloat(Quantity) * parseFloat(ItemRate); - // alert(BasicVal); + var FrequencyValue = $('#FrequencyValue'+rowid).val() == '' ? '1.00' : $('#FrequencyValue'+rowid).val(); + var BasicVal = parseFloat(Quantity) * parseFloat(ItemRate) * parseFloat(FrequencyValue); //alert(TotalVal); - - TotServiceTax = parseFloat(TotServiceTax) - parseFloat(AfterServiceTax); - TotEduCess = parseFloat(TotEduCess) - parseFloat(AfterEduCess); - TotSecHighTax = parseFloat(TotSecHighTax) - parseFloat(AfterSecHighTax); - TotKrishiTax = parseFloat(TotKrishiTax) - parseFloat(AfterKrishiTax); - TotSwachhTax = parseFloat(TotSwachhTax) - parseFloat(AfterSwachhTax); - - TotSummary = parseFloat(TotBasicAmout) - parseFloat(TotalVal); + TotCgst = parseFloat(TotCgst) - parseFloat(AfterCgst); + TotSgst = parseFloat(TotSgst) - parseFloat(AfterSgst); + TotIgst = parseFloat(TotIgst) - parseFloat(AfterIgst); + TotOtherAmt = parseFloat(TotOtherAmt) - parseFloat(OtherAmt); + TotSummary = parseFloat(TotSummary) - parseFloat(TotalVal); TotBasicAmout = parseFloat(TotBasicAmout) - parseFloat(BasicVal); - $('#txtTotBasicAmount').val(parseFloat(TotBasicAmout).toFixed(2) ); - $('#txtTotalServiceTax').val(parseFloat(TotServiceTax).toFixed(2) ); - $('#txtTotHigherEdu').val(parseFloat(TotSecHighTax).toFixed(2) ); - $('#txtTotalEducess').val(parseFloat(TotEduCess).toFixed(2) ); - $('#txtTotalKrishiKalyan').val(parseFloat(TotKrishiTax).toFixed(2) ); - $('#txtTotSwachhBharat').val(parseFloat(TotSwachhTax).toFixed(2) ); + $('#txtTotCgst').val(parseFloat(TotCgst).toFixed(2) ); + $('#txtTotSgst').val(parseFloat(TotSgst).toFixed(2) ); + $('#txtTotIgst').val(parseFloat(TotIgst).toFixed(2) ); + $('#ToatalOtherAllowances').val(parseFloat(TotOtherAmt).toFixed(2) ); $('#txtTotalOrderValueSummary').val(parseFloat(TotSummary).toFixed(2) ); @@ -2297,16 +2387,48 @@ $('#Scheduleby').change(function(){ -var Detail = ; -//console.log(Detail); - - $.each(Detail, function (index, value) - { - $("#PaymentTerms").append( $('').val(value.ConfigValue).html(value.ConfigValue) ); +function calculateCgstTax(varBasicValue,Cgst) + { + + var basicValue = parseFloat(varBasicValue); + var Cgst = parseFloat(Cgst); + var ServiceTaxValue = 0.0; + + ServiceTaxValue = ; + + var TAXval = parseFloat(ServiceTaxValue).toFixed(2); + + return TAXval;// $('#AfterServiceTax').val(TAXval); + + } +function calculateSgstTax(varBasicValue,Sgst) + { + + var basicValue = parseFloat(varBasicValue); + var Sgst = parseFloat(Sgst); + var ServiceTaxValue = 0.0; + + ServiceTaxValue = ; + + var TAXval = parseFloat(ServiceTaxValue).toFixed(2); + + return TAXval;// $('#AfterServiceTax').val(TAXval); + + } +function calculateIgstTax(varBasicValue,Igst) + { + + var basicValue = parseFloat(varBasicValue); + var Igst = parseFloat(Igst); + var ServiceTaxValue = 0.0; + + ServiceTaxValue = ; + + var TAXval = parseFloat(ServiceTaxValue).toFixed(2); + + return TAXval;// $('#AfterServiceTax').val(TAXval); + + } - - } ); - - - + \ No newline at end of file diff --git a/application/views/EditservicePurchaseorder.php~ b/application/views/EditservicePurchaseorder.php~ new file mode 100755 index 00000000..5bd1a7bf --- /dev/null +++ b/application/views/EditservicePurchaseorder.php~ @@ -0,0 +1,2434 @@ +FontCode2000; + + } +} + +if(!empty($MaxPODate)) +{ + foreach ($MaxPODate as $date) + { + $MaxPoDate = $date->PODate; + + } +} +if(!empty($POMaster)) +{ + foreach ($POMaster as $Req) + { + + $SupId = $Req->SupplierID; + $SupName = $Req->SupplierName; + $Address = $Req->Address; + $pdt = new DateTime($Req->PODate); + $PODate = $pdt->format('Y-m-d'); + $DeliverOption = $Req->DeliveryOption; + $DeliverSchedule = $Req->DeliverySchedule; + $Ddt = new DateTime($Req->DeliveryDate); + $Deliverydt = $Ddt->format('Y-m-d'); + + $DeliveryAddress =$Req->DeliveryAddress; + $PONOStatus = $Req->StatusCode; + $PONO = $Req->PONO; + $ServiceDescription = $Req->ServiceDescription; + //Terms=$Req->PaymentTerms; + + $WrkStatus=$Req->ServiceWorkStatus; + $StatusName=$Req->StatusName; + } +} + + +if(!empty($RequistionDetails)) +{ + + foreach ($RequistionDetails as $ReqDet) + { + // $Reqon=$ReqDet->ReqDate; + $Reqonn=new DateTime($ReqDet->ReqDate); + $Reqon=$Reqonn->format('Y-m-d'); + $Requestedby=$ReqDet->Requestedby; + $RequesterName=$ReqDet->FirstName; + //$Status=$ReqDet->Status; + } +} + +//echo "$WrkStatus"; + +if(!empty($AvlBudAmt)) +{ + + $AvlAmount = number_format($AvlBudAmt, 2, '.', ''); + +} + + +foreach ($PaymentTerms as $TER) +{ + $Terms=$TER->PaymentTerms; +} + + + +// foreach ($POSTATUS as $PST ) +// { +// $POStatus=$PST->StatusName; +// } +?> + + + + + + +
+ 'form-label-left ServicePO ','name' => 'ServicePO','id' => 'ServicePO'); + + echo form_open($this->config->base_url().'/purchaseorder/addPO/',$attributes); ?> + +
+
+
+

Siddharth Industries - Edit Service Purchase Order -

+
+
+
+
+
+ + + + 'Selected Requisition Numbers'); + if(!empty($ReqList)) + { + foreach ($ReqList as $SID): + + $options[$SID->ReqNo] = $SID->ReqNo ; + endforeach; + } + echo form_multiselect('RequistionNo', $options,set_value('RequistionNo'),'id="RequistionNo"' , 'required="true"'); + + ?> +
+
+ +
+ 'PODate','value' => set_value('PODate',$PODate),'id'=>'PODate', 'class' => 'form-control num' ,'required' => 'true','onkeypress'=>'return false;'); + echo form_input($data); + ?> +
+
+ +
+
+
+
+ + 'Select Supplier'); + //print_r( $options); + + if(!empty($Suplist)) + { + foreach ($Suplist as $SID): + + + $options[$SID->SupplierID] = $SID->SupplierID.' '.' - '.' '.$SID->SupplierName; + + endforeach; + } + + echo form_dropdown('drpSupplier', $options,set_value('drpSupplier',$SupId ),'id="drpSupplier"' ,'required="true"' ,'class="form-control select2'); + + ?> + +
+

+ +
+ 'SupAddress','value' => set_value('SupAddress',$Address),'id'=>'SupAddress', 'class' => 'form-control' ,'readonly' => 'true','rows' => '3', 'cols' => '40'); + echo Form_textarea($data); + ?> +
+
+
+
+
+ +
+ + 'POType','value' => set_value('POType',SERVICE),'id'=>'POType', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+
+ +
+ 'DeliveryAddr','value' => set_value('DeliveryAddr',$DeliveryAddress),'id'=>'DeliveryAddr', 'class' => 'form-control' ,'required' => 'true', 'rows' => '3', 'cols' => '40'); + echo Form_textarea($data); + ?> + +
+
+
+
+
+ Select Delivery By
+ + + 'DateRange', 'value' => '0', 'checked' => ('0' == $DeliverOption) ? TRUE : FALSE, 'id' => 'Date')); ?> + + + + 'DateRange', 'value' => '1', 'checked' => ('1' == $DeliverOption) ? TRUE : FALSE, 'id' => 'Schedule')); ?> + + + +
+
+ + StatusCode){ + $optionsWork[$WorkSID->StatusCode] = $WorkSID->StatusName; + } + + + endforeach; + foreach ($WorkStatus as $SID): + if($WrkStatus!=$SID->StatusCode){ + $optionsWork[$SID->StatusCode] = $SID->StatusName; + } + + + endforeach; + } + + echo form_dropdown('workstatus', $optionsWork,set_value('workstatus'),'id="workstatus"' ,'required="true"' ,'class="form-control select2'); + + ?> +
+

+ +
+ 'Deliverydt','value' => set_value('Deliverydt',$Deliverydt),'id'=>'Deliverydt', 'class' => 'form-control num' ,'required' => 'true', 'onkeypress'=>'return false;'); + echo form_input($data); + ?> +
+
+ +
+ +
+
+ Payment Details + +
+ + + PaymentID){ + + $optionsPay[$pay2->PaymentID] = $pay2->PaymentTerms; + + } + endforeach; + foreach ($Payment as $pay1): + + if($Terms!=$pay1->PaymentID){ + + $optionsPay[$pay1->PaymentID] = $pay1->PaymentTerms; + + } + endforeach; + } + + echo form_dropdown('PaymentTerms', $optionsPay,set_value('PaymentTerms'),'id="PaymentTerms"' ,'required="true"' ,'class="form-control select2'); + + ?> + + + + +
+ +
+
+
+
+
+
+ + + + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + Schedule_Type!='Recurring'){ + $FrequencyNo=intval(1); + $Frequency='One Time'; + } + else{ + $FrequencyNo=$record->NumberOfService; + $Frequency=$record->Service_Period; + } + + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + After_CGST; + $TotalSgst = $TotalSgst + $record->After_SGST; + $TotalIgst = $TotalIgst + $record->After_IGST; + $OtherAmt = $OtherAmt + $record->otherallowance; + $TotalSummary = $TotalSummary + $record->TotalValue; + + + $TotalBasicAmount = $TotalBasicAmount + $record->BasicValue; + + } + ?> + + +
SNoRequisition NoItem CodeItem DescriptionQuantityUOMRateBasic AmountTax AmountTotal Order AmountActual QuantityReceived QuantityPending QuantityAction
ReqNo ?>MaterialCode ?>ServiceMaterialDescription ?>Quantity ?>UOM ?>Rate ?>BasicValue * $FrequencyNo, 2, '.', ''); ?>Taxamount ?>TotalValue ?>Quantity ?>ReceivedQuantity ?>Quantity - $record->ReceivedQuantity, 2, '.', ''); ?>     + +    
+
+ + +
+
+ +
+ + 'txtTotBasicAmount','value' => set_value('txtTotBasicAmount',number_format($TotalBasicAmount, 2, '.', '')),'id'=>'txtTotBasicAmount', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+ + 'txtTotCgst','value' => set_value('txtTotCgst',number_format($TotalCgst, 2, '.', '')),'id'=>'txtTotCgst', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+ + +
+ + 'txtTotSgst','value' => set_value('txtTotSgst',number_format($TotalSgst, 2, '.', '')),'id'=>'txtTotSgst', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+ + 'txtTotIgst','value' => set_value('txtTotIgst',number_format($TotalIgst, 2, '.', '')),'id'=>'txtTotIgst', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+ +
+ + 'ToatalOtherAllowances','value' => set_value('ToatalOtherAllowances',number_format($OtherAmt, 2, '.', '')),'id'=>'ToatalOtherAllowances', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> + +
+
+ + 'txtTotalOrderValueSummary','value' => set_value('txtTotalOrderValueSummary',number_format($TotalSummary, 2, '.', '')),'id'=>'txtTotalOrderValueSummary', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> + +
+ +
+ + +
+
+ 'ScopeofWork','value' => set_value('ScopeofWork',$ServiceDescription),'id'=>'ScopeofWork', 'class' => 'form-control', 'rows' => '10', 'cols' => '40' ); + echo form_textarea($data); + ?> +
+ +
+
+

+
+ + + + +   Save +   Submit + + + +

+
+
+
+

+
+
+ Request On + 'Requeston','value' => set_value('Requeston',$Reqon),'id'=>'Requeston', 'class' => 'form-control num' ,'required' => 'true', 'onkeypress'=>'return false;'); + echo form_input($data); + ?> +
+
+ Request By + 'RequestBy','value' => set_value('RequestBy',$RequesterName),'id'=>'RequestBy', 'class' => 'form-control' ,'required' => 'true'); + echo form_input($data); + ?> +
+
+ Status + 'Select Status'); + // echo form_dropdown('Status', $options,set_value('Status'),'id="Status"' ,'required="true"' ,'class="form-control select2') + // $options = array("0"=>$PONOStatus); + // echo form_dropdown('Status', $options,set_value('Status',$StatusName),'id="Status"' ,'required="true"' ,'class="form-control select2') + + + $data = array('name' => 'Status','value' => set_value('Status',$StatusName),'id'=>'Status', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+
+
+ +
+
+
+
+ + + \ No newline at end of file diff --git a/application/views/alterpurchaseorder.php b/application/views/alterpurchaseorder.php index 76796d5c..7f743988 100755 --- a/application/views/alterpurchaseorder.php +++ b/application/views/alterpurchaseorder.php @@ -55,13 +55,15 @@ if(!empty($INRSYMBOL)) { text-align:left; } - + .nopad { + padding:0px; + } - + \ No newline at end of file diff --git a/application/views/alterpurchaseorder.php~ b/application/views/alterpurchaseorder.php~ new file mode 100755 index 00000000..7f743988 --- /dev/null +++ b/application/views/alterpurchaseorder.php~ @@ -0,0 +1,6915 @@ + +format('Y-m-d'); +$MaxPoDate = ''; +if(!empty($MaxPODate)) +{ + foreach ($MaxPODate as $date) + { + $MaxPoDate = $date->PODate; + } +} +if(!empty($CompanyDetails)) +{ + foreach ($CompanyDetails as $Req) + { + $CompanyAddress = $Req->Address; + } +} + +if(!empty($INRSYMBOL)) +{ + + foreach($INRSYMBOL as $INRS) + { + $INRSYM=$INRS->FontCode2000; + + } +} +?> + + + + + +
+ 'form-label-left CreatealterPO ','name' => 'CreatealterPO','id' => 'CreatealterPO'); + + echo form_open($this->config->base_url().'/purchaseorder/addalterPO/',$attributes); ?> + +
+
+
+

Siddharth Industries - Emergency Purchase Order

+
+ +
+
+
+
+ + 'Select Request Type'); + + if(!empty($RequestType)) + { + + foreach ($RequestType as $RID): + if($RID->ConfigValue=="SERVICE" || $RID->ConfigValue=="REVENUE") + { + $options[$RID->ConfigValue] = $RID->ConfigValue; + } + endforeach; + } + + echo form_dropdown('RequestType', $options,set_value('ConfigValue'),'id="purpose"' ,'class = "form-control select2"','required="true"'); + + ?> + +
+
+ +
+ 'PODate','value' => set_value('PODate',$CurrentDate),'id'=>'PODate', 'class' => 'form-control num' ,'required' => 'true'); + echo form_input($data); + ?> +
+
+
+ +
+ + 'POType','value' => set_value('POType',$ReqType),'id'=>'POType', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+ + + + + + +
+
+
+ +
+ 'Select Supplier'); + //print_r( $options); + + if(!empty($Suplist)) + { + foreach ($Suplist as $SID): + + + $options[$SID->SupplierID] = $SID->SupplierID.' '.' - '.' '.$SID->SupplierName; + + endforeach; + } + + echo form_dropdown('drpSupplier', $options,set_value('drpSupplier'),'id="drpSupplier"' ,'required="true"' ,'class="form-control select2"'); + + ?> +
+
+ +
+ +
+ 'SupAddress','value' => set_value('SupAddress'),'id'=>'SupAddress', 'class' => 'form-control' ,'readonly' => 'true' ,'rows' => '3', 'cols' => '40'); + echo Form_textarea($data); + ?> +
+
+
+ +
+ 'DeliveryAddr','value' => set_value('DeliveryAddr',$CompanyAddress),'id'=>'DeliveryAddr', 'class' => 'form-control' ,'required' => 'true' ,'rows' => '3', 'cols' => '40'); + echo Form_textarea($data); + ?> + +
+
+ + + +
+
+
+ +
+ 'Select Department Name'); + + if(!empty($DeptList)) + { + + foreach ($DeptList as $DID): + + $options1[$DID->DEPCode] = $DID->DEPCode.' '.' - '.' '.$DID->DepartmentName; + + endforeach; + } + + echo form_dropdown('drpDepartment', $options1,set_value('drpDepartment'),'id="DepartmentName"' ,'class = "form-control select2"','required="true"', 'disabled="disabled"'); + + ?> + +
+
+
+ +
+ 'Cost Center Name'); + + + if(!empty($CostList)) + { + + foreach ($CostList as $cost): + + + $options2[$cost['CostCenterCode']] = $cost['CostCenterCode'].' '.' - '.' '.$cost['CostCenterName']; + + endforeach; + } + + echo form_dropdown('CostCenterName', $options2,set_value('CostCenterName'),'id="CostCenterName"','class="form-control select2"' , 'required="true"' ,'multiple="true"'); + + ?> +
+
+
+ +
+ 'AvalBuget','value' => set_value('AvalBuget'),'id'=>'AvalBuget', 'class' => 'form-control num' ,'required' => 'true' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+ + + + + + + +
+
+
+ + + +
+
+
+ +
+
+ Payment Details + +
+ Payable Terms + 'Select Payment method'); + //print_r( $options); + if(!empty($Payment)) + { + foreach ($Payment as $payment): + + + $options1[$payment->PaymentID] = $payment->PaymentTerms; + + endforeach; + } + echo form_dropdown('PaymentMethod', $options1,set_value('PaymentMethod'),'id="PaymentMethod"' ,'class="form-control"'); + ?> +
+
+
+
+ + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + +
SNoRequisition NoItem CodeItem DescriptionQuantityUOMRateBasic AmountTax AmountTotal Order AmountAction
+
+ + + + + + +
+ +
+ + + + + +
+
+ +
+ + + + \ No newline at end of file diff --git a/application/views/editrequisitionform.php b/application/views/editrequisitionform.php index 4a7e2ab9..0a482937 100755 --- a/application/views/editrequisitionform.php +++ b/application/views/editrequisitionform.php @@ -1,35 +1,73 @@ ReqNo; - $ReqType = $Req->ReqType; - $Requestedby = $Req->Requestedby; - $FirstName =$Req->FirstName; + $ReqType = $Req->ReqType; + $Requestedby = $Req->Requestedby; + $FirstName =$Req->FirstName; $Designation =$Req->Designation; $DepartmentName = $Req->DepartmentName; $Status = $Req->Status; - $CostCenterCode = $Req->CostCenterCode; + $CostCenterCode = $Req->CostCenterCode; + $serviceSchedule=$Req->Schedule_Type; + + $servicePeriod=$Req->Service_Period; + $noOfService=$Req->NumberOfService; + } } ?> - + +
@@ -129,6 +167,74 @@ if(!empty($ReqDetails))
+ + + @@ -416,7 +522,7 @@ $(function() { if(data) { $('#content').loader('hide'); - $("#AvlBudgetAmount").val(data); + $("#AvlBudgetAmount").val(parseFloat(data).toFixed(2)); if(parseFloat($("#AvlBudgetAmount").val()) <= 0) { @@ -453,7 +559,7 @@ $('#CostCenter').change(function() { if(data) { $('#content').loader('hide'); - $("#AvlBudgetAmount").val(number_format(data,2)); + $("#AvlBudgetAmount").val(parseFloat(data).toFixed(2)); if(parseFloat($("#AvlBudgetAmount").val()) <= 0) { @@ -620,8 +726,30 @@ else //alert(document.getElementById('Items').rows.length); $('#content').loader('show'); $('#txtStatus').val(stat); + + var serviceSchedule=''; + var servicePeriod=''; + var noOfService=''; + if($('#RequestType').val()=='SERVICE'){ + if($('#ScheduleType').val()=='Recurring'){ + serviceSchedule=$('#ScheduleType').val(); + servicePeriod=$('#ServiceOptions').val(); + noOfService=$('#ServiceNo').val(); + } + else{ + serviceSchedule=$('#ScheduleType').val(); + servicePeriod=''; + noOfService=0; + } + + } + else{ + var serviceSchedule=''; + var servicePeriod=''; + var noOfService=''; + } $.ajax({ - data:$('.requistion').serialize(), + data:$('.requistion').serialize()+"&serviceSchedule="+serviceSchedule+"&servicePeriod="+servicePeriod+"&noOfService="+noOfService, type:"POST", url:"requisitionform/EditRequistion", success:function(data) { @@ -902,4 +1030,18 @@ $('.EditClick').click(function(){ }); }); +$("#ScheduleType").change(function(){ +if($('#ScheduleType').val().trim()!='Recurring'){ +document.getElementById('ServicePeriodOption').style.display = 'none'; +document.getElementById('NoServices').style.display = 'none'; + + +} +else{ +document.getElementById('ServicePeriodOption').style.display = 'block'; +document.getElementById('NoServices').style.display = 'block'; + +} + +}); diff --git a/application/views/editrequisitionform.php~ b/application/views/editrequisitionform.php~ new file mode 100755 index 00000000..0a482937 --- /dev/null +++ b/application/views/editrequisitionform.php~ @@ -0,0 +1,1047 @@ + +ReqNo; + $ReqType = $Req->ReqType; + $Requestedby = $Req->Requestedby; + $FirstName =$Req->FirstName; + $Designation =$Req->Designation; + $DepartmentName = $Req->DepartmentName; + $Status = $Req->Status; + $CostCenterCode = $Req->CostCenterCode; + $serviceSchedule=$Req->Schedule_Type; + + $servicePeriod=$Req->Service_Period; + $noOfService=$Req->NumberOfService; + + } +} + + +?> + + +
+ + +
+ +
+

Siddharth Industries - Edit Requisition Form

+
+
+ + 'form-label-left requistion ','name' => 'requistion','id' => 'requistion'); + + echo form_open($this->config->base_url().'requisitionform/EditRequistion',$attributes); ?> +
+
+ +
+ +
+ + 'RequestType','value' => set_value('RequestType',$ReqType),'id'=>'RequestType', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + + ?> + + +
+
+
+ +
+ + 'EmpID','value' => set_value('EmpID',$FirstName),'id'=>'EmpID', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + + ?> + +
+
+
+ +
+ 'DeptName','value' => set_value('DeptName',$DepartmentName),'id'=>'DeptName', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+
+ +
+ 'Designation','value' => set_value('Designation',$Designation),'id'=>'Designation', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+
+
+ +
+ + +
+ $CostCenterCode); + //print_r( $options); + + if(!empty($CostCenter)) + { + foreach ($CostCenter as $SID): + // echo $SID->ConfigValue; + $Costs[$SID->CostCenterCode] = $SID->CostCenterCode .'-'. $SID->CostCenterName ; + + endforeach; + + } + echo form_dropdown('CostCenter', $Costs,set_value('CostCenter'),'id="CostCenter"' ,'class = "form-control"'); + + ?> +
+
+ +
+   +
+ 'AvlBudgetAmount','value' => set_value('AvlBudgetAmount'),'id'=>'AvlBudgetAmount', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + ?> + +
+ +
+ + + + +
+ +
+
+ +
+ +
+
+ + Add Line Item + + + + +

+ + +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SNoMaterial CodeMaterial NameUomRequestedQuantityPoQuantityStatusAction
MaterialCode ; ?>MaterialName ; ?>UOM ; ?>Quantity ; ?>POQTY ; ?>StatusName ;?> +     + + +
+ +
+ + + + +   Save +   Submit + + + + +   Update + + + + + +
+
+
+
+ +
+
+ + + + diff --git a/application/views/requisitionform.php b/application/views/requisitionform.php index 94e45eb2..7964887f 100755 --- a/application/views/requisitionform.php +++ b/application/views/requisitionform.php @@ -16,9 +16,7 @@ if(!empty($Emp)) } } ?> - +
@@ -121,9 +119,66 @@ if(!empty($Emp)) ?>
+ + + + + + + + + - @@ -296,7 +351,7 @@ if(!empty($Emp))   Save - + @@ -346,7 +401,7 @@ $('#CostCenter').change(function() { if(data) { $('#content').loader('hide'); - $("#AvlBudgetAmount").val(data); + $("#AvlBudgetAmount").val(parseFloat(data).toFixed(2)); if(parseFloat($("#AvlBudgetAmount").val()) <= 0) { $('#AlertImg').removeAttr("style"); @@ -379,10 +434,10 @@ $('#CostCenter').change(function() { $('#RequestType').change(function() { $("#AvlBudgetAmount").val(''); - $('#AlertImg').attr("style","display:none;"); + $('#AlertImg').attr("style","display:none;"); $('#txtRowCount').val(''); $('#txtDeletedRow').val(''); - $("#Description").val(''); + $("#Description").val(''); $("#UOM").val(''); $('#CostCenter').val("-1"); @@ -405,7 +460,19 @@ $('#CostCenter').change(function() { $("#MaterialCode").empty(); $("#MaterialCode").append(json.Material); // $("#Description").val(json.MaterialName); - //$("#UOM").val(json.UOM); + //$("#UOM").val(json.UOM); + if(id!='SERVICE'){ + $('#DisplayScheduleDiv').hide(); + $('#ServicePeriodOption').hide(); + $('#NoServices').hide(); + + + } + else{ + $('#DisplayScheduleDiv').show(); + + } + } }); @@ -507,9 +574,30 @@ function Save() else { + var serviceSchedule=''; + var servicePeriod=''; + var noOfService=''; + if($('#RequestType').val()=='SERVICE'){ + if($('#ScheduleType').val()=='Recurring'){ + serviceSchedule=$('#ScheduleType').val(); + servicePeriod=$('#ServiceOptions').val(); + noOfService=$('#ServiceNo').val(); + } + else{ + serviceSchedule=$('#ScheduleType').val(); + servicePeriod=''; + noOfService=0; + } + + } + else{ + var serviceSchedule=''; + var servicePeriod=''; + var noOfService=''; + } $('#content').loader('show'); $.ajax({ - data:$('.requistion').serialize(), + data:$('.requistion').serialize()+"&serviceSchedule="+serviceSchedule+"&servicePeriod="+servicePeriod+"&noOfService="+noOfService, type:"POST", url:"requisitionform/addNewRequistion?ID="+id, success:function(data) { @@ -733,9 +821,30 @@ $('.EditClick').click(function(){ } else { + var serviceSchedule=''; + var servicePeriod=''; + var noOfService=''; + if($('#RequestType').val()=='SERVICE'){ + if($('#ScheduleType').val()=='Recurring'){ + serviceSchedule=$('#ScheduleType').val(); + servicePeriod=$('#ServiceOptions').val(); + noOfService=$('#ServiceNo').val(); + } + else{ + serviceSchedule=$('#ScheduleType').val(); + servicePeriod=''; + noOfService=0; + } + + } + else{ + var serviceSchedule=''; + var servicePeriod=''; + var noOfService=''; + } $('#content').loader('show'); $.ajax({ - data:$('.requistion').serialize(), + data:$('.requistion').serialize()+"&serviceSchedule="+serviceSchedule+"&servicePeriod="+servicePeriod+"&noOfService="+noOfService, type:"POST", url:"requisitionform/addNewRequistion?ID="+id, success:function(data) { @@ -774,4 +883,19 @@ $('.EditClick').click(function(){ }); }); + +$("#ScheduleType").change(function(){ +if($('#ScheduleType').val().trim()!='Recurring'){ +document.getElementById('ServicePeriodOption').style.display = 'none'; +document.getElementById('NoServices').style.display = 'none'; + + $('#ServiceNo').val(''); +} +else{ +document.getElementById('ServicePeriodOption').style.display = 'block'; +document.getElementById('NoServices').style.display = 'block'; +document.getElementById('ServiceNo').value = 1; +} + +}); diff --git a/application/views/requisitionform.php~ b/application/views/requisitionform.php~ new file mode 100755 index 00000000..7964887f --- /dev/null +++ b/application/views/requisitionform.php~ @@ -0,0 +1,901 @@ + +EmpID ; + $FirstName = $Emp->FirstName ; + $Designation = $Emp->Designation; + $DepartmentName =$Emp->DepartmentName; + } +} +?> + +
+ + +
+ +
+

Siddharth Industries - Requisition Form

+
+
+ 'form-label-left requistion ','name' => 'requistion','id' => 'requistion'); + + echo form_open($this->config->base_url().'requisitionform/SearchRequistList',$attributes); ?> +
+
+
+ +
+ 'Select Request Type'); + + //print_r( $options); + + if(!empty($RequestType)) + { + foreach ($RequestType as $RID): + + + $options[$RID->ConfigValue] = $RID->ConfigValue; + + endforeach; + } + + echo form_dropdown('RequestType', $options,set_value('ConfigValue'),'id="RequestType"' ,'class = "form-control select2"','required="true"'); + + ?> + +
+
+
+ +
+ + 'EmpID','value' => set_value('EmpID',$FirstName),'id'=>'EmpID', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + ?> + /> +
+
+
+ +
+ 'DeptName','value' => set_value('DeptName',$DepartmentName),'id'=>'DeptName', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+
+ +
+ 'Designation','value' => set_value('Designation',$Designation),'id'=>'Designation', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+
+
+ +
+ +
+ 'Select Cost Center Name'); + //print_r( $options); + + if(!empty($CostCenter)) + { + foreach ($CostCenter as $SID): + // echo $SID->ConfigValue; + $Costs[$SID->CostCenterCode] = $SID->CostCenterCode .'-'. $SID->CostCenterName ; + + endforeach; + + } + echo form_dropdown('CostCenter', $Costs,set_value('CostCenter'),'id="CostCenter"' ,'class = "form-control"'); + + ?> + +
+
+
+   +
+ 'AvlBudgetAmount','value' => set_value('AvlBudgetAmount'),'id'=>'AvlBudgetAmount', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+ + + + + +
+ +
+ + +
+
+
+ +
+ +
+
+ Add Line Item + + + + +

+ + +

+ +
+ + + + + + + + + + + + + + + +
SNoMaterial CodeMaterial NameUomQuantityAction
+ +
+ + +   Save + + + + +
+
+
+ + + + + + + + diff --git a/application/views/servicePurchaseorder.php b/application/views/servicePurchaseorder.php index 67c32d62..489cddd7 100755 --- a/application/views/servicePurchaseorder.php +++ b/application/views/servicePurchaseorder.php @@ -69,7 +69,7 @@ var AvilBudAmt = ''; - +document.getElementById("Date").checked = true; $('#drpSupplier').change(function() { @@ -80,7 +80,7 @@ $('#drpSupplier').change(function() { if(id != '0') { var y = ; - + $.each(y, function(idx, obj) { if(obj.SupplierID === id) @@ -88,22 +88,14 @@ $('#drpSupplier').change(function() { $("#SupAddress").val(obj.Address); $("#SupAddress").val(obj.Address); - $("#PayableAT").val(obj.PayableAT); - $("#PaymentTerms").val(obj.PaymentTerms); - var a=obj.PaymentDays; - console.log(a); - if (a=="After") - { - //alert(); - document.getElementById("After").checked = true; - - } - else - document.getElementById("Before").checked = true; + PaymentID = obj.PaymentID; + $("#PaymentTerms").val(obj.PaymentID); + } }); + } else @@ -142,10 +134,20 @@ $("#txtBasicValue").val(''); { $("#deptName").val(obj.DepartmentName); $("#CostCenter").val(obj.CostCenterCode); + if(obj.Service_Period!='' && obj.Service_Period!=null){ + $("#Frequency").val(obj.Service_Period +'-' + obj.NumberOfService); + $("#FrequencyNo").val(obj.NumberOfService); + + } + else{ + var text='One Time'; + $("#Frequency").val(text); + $("#FrequencyNo").val(1); + } } }); - $("#AvlBudAmt").val(AvlBudAmt); + $("#AvlBudAmt").val(parseFloat(AvlBudAmt).toFixed(2)); // For Binding Material list center for the selected Requistion Number @@ -239,10 +241,10 @@ $('#EditMaterialCode').change(function() { $("#EditItemName").val(''); $("#EditUOM").val(''); $("#EditQuantity").val(''); -$("#EditRate").val(''); -$("#txtEditBasicValue").val(''); +//$("#EditRate").val(''); +//$("#txtEditBasicValue").val(''); RequistQuantity = ''; - clearEditTaxField(); +// clearEditTaxField(); if(id != '0') { var Material = ; @@ -299,25 +301,17 @@ function Ratechange(){ { var txtQuantity = parseFloat( $('#Quantity').val()); var txtUnitPrice = parseFloat($('#Rate').val()); - var Tot = txtQuantity * txtUnitPrice - $('#txtBasicValue').val(Tot); + var frequencyValue = parseFloat($('#FrequencyNo').val()); + var Tot = txtQuantity * frequencyValue * txtUnitPrice; + $('#txtBasicValue').val(parseFloat(Tot).toFixed(2)); //Service Tax calculation - $('#AfterServiceTax').val(calculateServiceTax($('#txtBasicValue').val())); // calculateServiceTax(); + + $('#AfterCgst').val(calculateCgstTax($('#txtBasicValue').val(),$('#Cgst').val())); + $('#AfterSgst').val(calculateSgstTax($('#txtBasicValue').val(),$('#Sgst').val())); + $('#AfterIgst').val(calculateIgstTax($('#txtBasicValue').val(),$('#Igst').val())); - //Edu. cess @2% on service Tax - $('#AfterEduCess').val( calculateEduess($('#AfterServiceTax').val())); - - //Sec. & Higher Edu. cess @1 % on service Tax - - $('#AfterSecHighTax').val(calculateHigherEdu($('#AfterServiceTax').val())); - //Krishi Kalyan tax - - $('#AfterKrishiTax').val(calculateKrishiKalyantax($('#txtBasicValue').val())); - //Swachh Bharat tax - - $('#AfterSwachhTax').val(calculateSwachhBharattax($('#txtBasicValue').val())); - + calculateTotalOrdervalue(); var res = ExceedBudget($('#TotalOrderValue').val(), $('#AvlBudAmt').val()); @@ -344,26 +338,15 @@ function EditRatechange(){ { var txtQuantity = parseFloat( $('#EditQuantity').val()); var txtUnitPrice = parseFloat($('#EditRate').val()); - var Tot = txtQuantity * txtUnitPrice - $('#txtEditBasicValue').val(Tot); + var frequencyValue = parseFloat($('#EditFrequencyNo').val()); + var Tot = txtQuantity * frequencyValue * txtUnitPrice + $('#txtEditBasicValue').val(parseFloat(Tot).toFixed(2)); ExceedBudget(Tot, $('#EditAvlBudAmt').val()); - //Service Tax calculation - $('#EditAfterServiceTax').val(calculateServiceTax($('#txtEditBasicValue').val())); // calculateServiceTax(); - - //Edu. cess @2% on service Tax - $('#EditAfterEduCess').val( calculateEduess($('#EditAfterServiceTax').val())); - - //Sec. & Higher Edu. cess @1 % on service Tax - - $('#EditAfterSecHighTax').val(calculateHigherEdu($('#EditAfterServiceTax').val())); - //Krishi Kalyan tax - - $('#EditAfterKrishiTax').val(calculateKrishiKalyantax($('#txtEditBasicValue').val())); - //Swachh Bharat tax - - $('#EditAfterSwachhTax').val(calculateSwachhBharattax($('#txtEditBasicValue').val())); + $('#EditAfterCgst').val(calculateCgstTax($('#txtEditBasicValue').val(),$('#EditCgst').val())); + $('#EditAfterSgst').val(calculateSgstTax($('#txtEditBasicValue').val(),$('#EditSgst').val())); + $('#EditAfterIgst').val(calculateIgstTax($('#txtEditBasicValue').val(),$('#EditIgst').val())); calculateTotalEditOrdervalue(); } @@ -414,79 +397,17 @@ function ExceedQuantityCheck() return true; } } - function calculateServiceTax(varBasicValue) - { - - var basicValue = parseFloat(varBasicValue); - - var ServiceTaxValue = 0.0; - - ServiceTaxValue = ; - - var TAXval = parseFloat(ServiceTaxValue).toFixed(2); - - return TAXval;// $('#AfterServiceTax').val(TAXval); - - } - function calculateEduess(varAfterServiceTax) - { - var ServiceTaxAmount = parseFloat(varAfterServiceTax); - - var ServiceTaxValue = 0.0; - - ServiceTaxValue = ; - - var TAXval = parseFloat(ServiceTaxValue).toFixed(2); - - return TAXval;// $('#AfterEduCess').val(TAXval); - } - function calculateHigherEdu(varAfterServiceTax) - { - var ServiceTaxAmount = parseFloat(varAfterServiceTax); - - var ServiceTaxValue = 0.0; - - ServiceTaxValue = ; - - var TAXval = parseFloat(ServiceTaxValue).toFixed(2); - - return TAXval;//$('#AfterSecHighTax').val(TAXval); - } - function calculateKrishiKalyantax(varBasicValue) - { - var basicValue = parseFloat(varBasicValue); - - var ServiceTaxValue = 0.0; - - ServiceTaxValue = ; - - var TAXval = parseFloat(ServiceTaxValue).toFixed(2); - - return TAXval;//$('#AfterKrishiTax').val(TAXval); - } - function calculateSwachhBharattax(varBasicValue) - { - var basicValue = parseFloat(varBasicValue); - - var ServiceTaxValue = 0.0; - - ServiceTaxValue = ; - - var TAXval = parseFloat(ServiceTaxValue).toFixed(2); - - return TAXval; //$('#AfterSwachhTax').val(TAXval); - } + function calculateTotalOrdervalue() { var basicValue = parseFloat($('#txtBasicValue').val()); - var ServiceTaxAmount = parseFloat($('#AfterServiceTax').val()); - var EduCessTaxAmount = parseFloat($('#AfterEduCess').val()); - var SecHighTaxAmount = parseFloat($('#AfterSecHighTax').val()); - var KrishiTaxAmount = parseFloat($('#AfterKrishiTax').val()); - var SwachhTaxAmount = parseFloat($('#AfterSwachhTax').val()); + var Cgst = parseFloat($('#AfterCgst').val()); + var Sgst = parseFloat($('#AfterSgst').val()); + var Igst = parseFloat($('#AfterIgst').val()); + var OtherAmt = parseFloat($('#OtherAllowances').val()); - var TotAmt = basicValue + ServiceTaxAmount+ EduCessTaxAmount + SecHighTaxAmount+ KrishiTaxAmount + SwachhTaxAmount; + var TotAmt = basicValue + Cgst+ Sgst + Igst + OtherAmt; $('#TotalOrderValue').val( parseFloat(TotAmt).toFixed(2)); @@ -494,65 +415,65 @@ function ExceedQuantityCheck() function calculateTotalEditOrdervalue() { var basicValue = parseFloat($('#txtEditBasicValue').val()); - var ServiceTaxAmount = parseFloat($('#EditAfterServiceTax').val()); - var EduCessTaxAmount = parseFloat($('#EditAfterEduCess').val()); - var SecHighTaxAmount = parseFloat($('#EditAfterSecHighTax').val()); - var KrishiTaxAmount = parseFloat($('#EditAfterKrishiTax').val()); - var SwachhTaxAmount = parseFloat($('#EditAfterSwachhTax').val()); + var Cgst = parseFloat($('#EditAfterCgst').val()); + var Sgst = parseFloat($('#EditAfterSgst').val()); + var Igst = parseFloat($('#EditAfterIgst').val()); + var OtherAmt = parseFloat($('#EditOtherAllowances').val()); - var TotAmt = basicValue + ServiceTaxAmount+ EduCessTaxAmount + SecHighTaxAmount+ KrishiTaxAmount + SwachhTaxAmount; + var TotAmt = basicValue + Cgst+ Sgst + Igst + OtherAmt; + + $('#EditTotalOrderValue').val( parseFloat(TotAmt).toFixed(2)); - $('#EditTotalOrderValue').val( parseFloat(TotAmt).toFixed(2)); } function calculateTaxValue() { - var ServiceTaxAmount = parseFloat($('#AfterServiceTax').val()); - var EduCessTaxAmount = parseFloat($('#AfterEduCess').val()); - var SecHighTaxAmount = parseFloat($('#AfterSecHighTax').val()); - var KrishiTaxAmount = parseFloat($('#AfterKrishiTax').val()); - var SwachhTaxAmount = parseFloat($('#AfterSwachhTax').val()); + var Cgst = parseFloat($('#AfterCgst').val()); + var Sgst = parseFloat($('#AfterSgst').val()); + var Igst = parseFloat($('#AfterIgst').val()); - var TottaxAmt = ServiceTaxAmount+ EduCessTaxAmount + SecHighTaxAmount+ KrishiTaxAmount + SwachhTaxAmount; - return parseFloat(TottaxAmt.toFixed(2)); + var TottaxAmt = Cgst+ Sgst + Igst; + return parseFloat(TottaxAmt).toFixed(2); } function clearTaxField() { $('#txtBasicValue').val(''); - $('#AfterServiceTax').val(''); - $('#AfterEduCess').val(''); - $('#AfterSecHighTax').val(''); - $('#AfterKrishiTax').val(''); - $('#AfterSwachhTax').val(''); + $('#AfterCgst').val(0); + $('#AfterSgst').val(0); + $('#AfterIgst').val(0); + $('#Cgst').val(0); + $('#Sgst').val(0); + $('#Igst').val(0); $('#TotalOrderValue ').val(''); - $('#Rate').val(''); + $('#Rate').val(0); $("#ItemName").val(''); $("#UOM").val(''); $("#Quantity").val(''); - RequistQuantity = ''; + RequistQuantity = ''; } function clearEditTaxField() { $('#txtEditBasicValue').val(''); - $('#EditAfterEduCess').val(''); - $('#EditAfterSecHighTax').val(''); - $('#EditAfterServiceTax').val(''); - $('#EditAfterKrishiTax').val(''); - $('#EditAfterSwachhTax').val(''); + $('#EditTotalOrderValue ').val(''); $('#EditRate').val(''); - + $('#EditAfterCgst').val(0); + $('#EditAfterSgst').val(0); + $('#EditAfterIgst').val(0); + $('#EditCgst').val(0); + $('#EditSgst').val(0); + $('#EditIgst').val(0); $("#EditItemName").val(''); $("#EditUOM").val(''); $("#EditQuantity").val(''); RequistQuantity = ''; } -$(document).ready(function () { +/* $(document).ready(function () { $('#Date').click(function () { //for Date range selection $('#Schedulediv').hide(); @@ -563,7 +484,7 @@ $(document).ready(function () { $('#Deliverydtdiv').hide(); $('#Schedulediv').show(); }); - }); + }); */ +
+ 'form-label-left ServicePO ','name' => 'ServicePO','id' => 'ServicePO'); + + echo form_open($this->config->base_url().'/purchaseorder/addPO/',$attributes); ?> + +
+
+
+
+

Siddharth Industries - Service Purchase Order

+
+ +
+
+
+
+ + + + 'Selected Requisition Numbers'); + if(!empty($ReqList)) + + { + foreach ($ReqList as $SID): + + // print_r($SID->ReqNo); + $options[$SID->ReqNo] = $SID->ReqNo ."-". $SID->ReqBy; + $ReqType = $SID->ReqType; + endforeach; + } + echo form_multiselect('RequistionNo', $options,set_value('RequistionNo'),'id="RequistionNo"' , 'required="true"'); + + ?> +
+
+ +
+ 'PODate','value' => set_value('PODate',$CurrentDate),'id'=>'PODate', 'class' => 'form-control num' ,'required' => 'true', 'onkeypress'=>'return false;'); + echo form_input($data); + ?> +
+
+ +
+
+
+
+ + + 'Select Supplier'); + //print_r( $options); + + if(!empty($Suplist)) + { + foreach ($Suplist as $SID): + + + $options[$SID->SupplierID] = $SID->SupplierID.' '.' - '.' '.$SID->SupplierName; + + endforeach; + } + + echo form_dropdown('drpSupplier', $options,set_value('drpSupplier'),'id="drpSupplier"' ,'required="true"' ,'class="form-control select2'); + + ?> + +
+

+ +
+ 'SupAddress','value' => set_value('SupAddress'),'id'=>'SupAddress', 'class' => 'form-control' ,'readonly' => 'true','rows' => '3', 'cols' => '40'); + echo Form_textarea($data); + ?> +
+
+
+
+
+ +
+ + 'POType','value' => set_value('POType',SERVICE),'id'=>'POType', 'class' => 'form-control' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+
+ +
+ 'DeliveryAddr','value' => set_value('DeliveryAddr',$CompanyAddress),'id'=>'DeliveryAddr', 'class' => 'form-control' ,'required' => 'true', 'rows' => '3', 'cols' => '40'); + echo Form_textarea($data); + ?> +
+
+
+
+
+ Select Delivery By
+ + + "DateRange", "id"=>"Date", "value"=>"0", 'checked'=>set_radio('DateRange', '0', TRUE))); ?> + + "DateRange", "id"=>"Schedule", "value"=>"1", 'checked'=>set_radio('DateRange', '1', FALSE))); ?> + + + + +
+
+ + 'Select Work Status'); + //print_r( $options); + + if(!empty($WorkStatus)) + { + foreach ($WorkStatus as $WID): + + + $optionsWork[$WID->StatusCode] = $WID->StatusName; + + endforeach; + } + + echo form_dropdown('workstatus', $optionsWork,set_value('workstatus'),'id="workstatus"' ,'required="true"' ,'class="form-control select2'); + + + ?> +
+

+ +
+ 'Deliverydt','value' => set_value('Deliverydt',$CurrentDate),'id'=>'Deliverydt', 'class' => 'form-control num' ,'required' => 'true', 'onkeypress'=>'return false;'); + echo form_input($data); + ?> +
+
+ +
+ +
+
+ Payment Details + +
+ + + 'Select Payment Terms '); + foreach ($Payment as $pay): + + + + $options6[$pay->PaymentID] = $pay->PaymentTerms; + + + endforeach; + } + + echo form_dropdown('PaymentTerms', $options6,set_value('PaymentTerms'),'id="PaymentTerms"' ,'required="true"' ,'class="form-control select2'); + + ?> + + + + +
+ + + +
+
+
+ +
+ +
+
+ + + + + + + + + + +
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + +
SNoRequisition NoItem CodeItem DescriptionQuantityUOMRateBasic AmountTax AmountTotal Order AmountAction
+
+ + +
+
+ +
+ + 'txtTotBasicAmount','value' => set_value('txtTotBasicAmount'),'id'=>'txtTotBasicAmount', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+ + 'txtTotCgst','value' => set_value('txtTotCgst'),'id'=>'txtTotCgst', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+ + +
+ + 'txtTotSgst','value' => set_value('txtTotSgst'),'id'=>'txtTotSgst', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+
+ + 'txtTotIgst','value' => set_value('txtTotIgst'),'id'=>'txtTotIgst', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> +
+ +
+ + 'TotalOtherAllowances','value' => set_value('TotalOtherAllowances'),'id'=>'TotalOtherAllowances', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> + +
+
+ + 'txtTotalOrderValueSummary','value' => set_value('txtTotalOrderValueSummary'),'id'=>'txtTotalOrderValueSummary', 'class' => 'form-control num' ,'readonly' => 'true'); + echo form_input($data); + ?> + +
+
+
+
+ 'ScopeOfWork','value' => set_value('ScopeOfWork'),'id'=>'ScopeOfWork', 'class' => 'form-control' ,'rows' => '10', 'cols' => '40' ); + echo form_textarea($data); ?> +
+ +
+
+
+
+
+ + + + + +   Save +   Submit + +

+
+
+
+

+
+ +
+
+ + + + + + \ No newline at end of file