service and revenue po changes done

This commit is contained in:
venbatechnologies@gmail.com 2017-07-20 12:34:59 +05:30
parent 02b3ba795b
commit 299e20d987
24 changed files with 23421 additions and 2878 deletions

View File

@ -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 */

237
application/config/constants.php~ Executable file
View File

@ -0,0 +1,237 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| File and Directory Modes
|--------------------------------------------------------------------------
|
| These prefs are used when checking and setting modes when working
| with the file system. The defaults are fine on servers with proper
| security, but you may wish (or even need) to change the values in
| certain environments (Apache running a separate process for each
| user, PHP under CGI with Apache suEXEC, etc.). Octal values should
| always be used to set the mode correctly.
|
*/
define('FILE_READ_MODE', 0644);
define('FILE_WRITE_MODE', 0666);
define('DIR_READ_MODE', 0755);
define('DIR_WRITE_MODE', 0777);
/*
|--------------------------------------------------------------------------
| File Stream Modes
|--------------------------------------------------------------------------
|
| These modes are used when working with fopen()/popen()
|
*/
define('FOPEN_READ', 'rb');
define('FOPEN_READ_WRITE', 'r+b');
define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care
define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care
define('FOPEN_WRITE_CREATE', 'ab');
define('FOPEN_READ_WRITE_CREATE', 'a+b');
define('FOPEN_WRITE_CREATE_STRICT', 'xb');
define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
/**** USER DEFINED CONSTANTS **********/
define('ROLE_ADMIN', '1');
define('ROLE_MANAGER', '2');
define('ROLE_EMPLOYEE', '3');
/*define('ROLE_PRODUCTION', '4');
define('ROLE_QUALITY', '5');
define('ROLE_SECURITY', '6');
define('ROLE_SALES', '7');
define('ROLE_ACCOUNTS', '8');*/
/***** USER DESIGNATION ******/
define('SECURITY', 'SECURITY');
define('SEGMENT', 2);
/************** Requistion Status code */
define('REQ_DRAFT', 'ST001');
define('REQ_PENDING_APPROVAL', 'ST002');
define('REQITEM_NEW', 'ST003');
define('REQ_APPROVED', 'ST004');
define('REQ_PO_CREATED' , 'ST005');
define('REQ_REJECTED', 'ST006');
define('REQ_CLOSED', 'ST007');
define('REQ_ONHOLD', 'ST008');
define('REQITEM_ONHOLD', 'ST009');
define('REQITEM_PARTIALLY_DELIVERED', 'ST010');
define('REQITEM_DELIVERED', 'ST011');
define('REQ_DELETED', 'ST013');
define('REQITEM_POCREATED', 'ST022');
define('REQITEM_PARTIALLY_PO_CREATED', 'ST023');
define('REQITEM_Emergency_PO_CREATED', 'ST024');
define('POLINEITEM_IGR_CREATED', 'ST040');
/*IGR Status */
define('IGR_CREATED', 'ST027');
define('IGR_CLOSED', 'ST028');
define('IGR_CANCELLED', 'ST029');
define('POLINEITEM_IGRPARTIAL_CREATED', 'ST042');
/*IGR Status*/
/*MRIR Status */
define('MRIR_CREATED', 'ST041');
define('MRIR_APPROVED', 'ST044');
define('MRIR_REJECTED', 'ST045');
define('REQUISTSTATUS', '0');
define('REQUISTITEMSTATUS', '1');
/* Purchase Order Status */
define('PO_DRAFT', 'ST014');
define('PO_CREATED', 'ST015');
define('PO_INPROGRESS', 'ST016');
define('PO_DISPATCHED', 'ST017');
define('PO_DELIVERED', 'ST018');
define('PO_CANCELLED', 'ST019');
define('PO_ONHOLD', 'ST020');
define('PO_CLOSED', 'ST021');
define('PO_AMENDED', 'ST030');
define('PO_RELEASED', 'ST026');
define('PO_AWAITING_RELEASE', 'ST025');
define('PO_APPROVED', 'ST025');
/*store Status*/
define('STORE_DRAFT', 'ST043');
define('STORE_CREATED', 'ST015');
/*store requisition*/
define('STORE REQUISTION STATUS', '6');
define('STORE_OPEN', 'ST034');
define('STORE_PENDINGAPPROVAL', 'ST035');
define('STORE_APPROVAL', 'ST036');
define('STORE_ISSUSED', 'ST037');
define('STORE_ONHOLD', 'ST038');
define('STORE_REJECT', 'ST039');
/* Department Code */
define('ADMIN', 'DEP01');
define('QUALITY', 'DEP02');
define('STORE', 'DEP03');
define('SALES', 'DEP04');
define('PRODUCTION', 'DEP05');
define('DELIVERY', 'DEP06');
define('TRP', 'DEP07');
define('COATING', 'DEP08');
define('MAINTENANANCE', 'DEP09');
define('FINANCE', 'DEP10');
define('PURCHASE', 'DEP11');
define('MANAGEMENT', 'DEP12');
/* PO Type */
define('REVENUE', 'REVENUE');
define('SERVICE', 'SERVICE');
define('IMPORT', 'IMPORT');
define('CAPITAL', 'CAPITAL');
// Tax Type
define('PERCENTAGE', 'PERCENTAGE');
define('LUMPSUM', 'LUMP SUM');
define('NILTYPE', 'NIL');
// Freight Type
define('PERUOM', 'PER UOM');
define('PERTRIP', 'PER TRIP');
/* Formula for Tax calculation */
/* Discount*/
define('DIS_PERCENTAGE', '((Discountval/100) * basicValue)');
define('DIS_LUMPSUM', 'Discountval');
// Packaging
define('PACKAGING_PERCENTAGE_BYDISCOUNTVALUE', '((Packagingvalue/100) * (basicValue-AfterDiscount))');
define('PACKAGING_PERCENTAGE_BYBASICVALUE', '(Packagingvalue/100) * basicValue');
define('PACKAGING_LUMPSUM_BYDISCOUNTVALUE', 'Packagingvalue');
define('PACKAGING_LUMPSUM_BYBASICVALUE', 'Packagingvalue');
//Excise
define('EXCISE_ONBASICVALUE', '((ExciseDuty/100) * basicValue)');
define('EXCISE_ONBASIC_DISCOUNT', '((ExciseDuty/100) * (basicValue-AfterDiscount))');
define('EXCISE_ONBASIC_DISCOUNT_PACKAGING', '((ExciseDuty/100) * ((basicValue-AfterDiscount)+ AfterPackaging))');
define('EXCISE_ONBASIC_PACKAGING', '((ExciseDuty/100) * (basicValue + AfterPackaging))');
//Vat
define('VAT_ONBASICVALUE', '((vatValue/100) * basicValue)');
//define('VAT_ONEXICSEVALUE', '((vatValue/100) * (basicValue+ExciseDuty))');
define('VAT_ONEXICSEVALUE', '(((basicValue - discountValue) + (packageValue + ExciseDuty)) * (vatValue/100))');
//CST
define('CST_ONBASICVALUE', '((CSTValue/100) * basicValue)');
//define('CST_ONEXICSEVALUE', '((CSTValue/100) * (basicValue+ExciseDuty))');
define('CST_ONEXICSEVALUE', '(((basicValue - discountValue) + (packageValue + ExciseDuty)) * (CSTValue/100))');
//GST
define('GSTTAX', '((GSTValue/100) * basicValue)');
//Other Tax
define('OTHERTAX', '((OtherTaxValue/100) * basicValue)');
//Freight Tax
define('FREIGHT_PERCENTAGE', '((FreightValue/100) * basicValue)');
define('FREIGHT_LUMPSUM', 'FreightValue');
define('FREIGHT_PERUOM', 'FreightValue * Quantity');
define('FREIGHT_PERTRIP', 'FreightValue');
/* SERVICE PO VARIABLES */
define('SERVICETAX_SERVICETAX_14PERCENT', '((14/100) * basicValue)');
define('SERVICETAX_EDUCESS_2PERCENT', '((2/100) * ServiceTaxAmount)');
define('SERVICETAX_HIGHEREDUCESS_1PERCENT', '((1/100) * ServiceTaxAmount)');
define('SERVICETAX_KRISHIKALYAN', '(((.5)/100) * basicValue)');
define('SERVICETAX_SWACHHBHARAT', '(((.5)/100) * basicValue)');
/*IMPORT PO CALCULATIONS*/
define('LOADING_CHARGE', '(txtlanding*txtbasicprice/100)');
define('HIGHSEAS_SALES', '(totalhighsess*highsesspercentage/100)');
define('CUSTOM_DUTY', '(sumcustom*txtcustompercentage)/100');
define('EXCISE_DUTY', '(txtexcisesum*txtpercentage)/100');
define('EXCISE_ED', '(txtexcise*txtexcisepercentage)/100');
define('EXCISE_SH', '(excisetxt*exciseshcess)/100');
define('CUSTOM_ED', '(totalval*txtedcesspercentage)/100');
define('CUSTOM_SH', '(totcustomsh*txtshpercentage)/100');
define('ADDTNL_EXCISEDUTY', '(totaddtnlexcise*addtnpercentage)/100');
define('GROSS_EXP', '(txtgrossdutypayable-txtmodvat)');
define('AVL_MODVAT', 'txtexciseduty1+txtexciseedcess+txtexciseshcess+txtaddtnlexcise');
define('GROSS_DUTY', 'landingcha+highsesssalless+customcha+excisecha+exciseedcha+exciseshcha+customed+customsh+txtaddtnexciseduty');
define('PURCHASE_RATE', 'txtbasicinrprice/quantity');
define('CUSTOMDUTY_EXP', 'txtgrossexp/quantity');
define('RMC_CAL', 'txtpurchaserate+txtcustomdutyexp');
define('CALCULATE_TOTAL', '(txtrmc*quantity)+basicprice');
/* Capital Po Calculations */
define('Capital_Landing_Charge', 'basicPrice*(landCharge/100)');
define('Capital_Highseas_Charge', '((highSeas/100) * (basicPrice+afterLandingCharge))');
define('Capital_Customduty_Charge', '((Customduty/100) * (basicPrice+afterLandingCharge+afterHighseas))');
define('Capital_Excise_Charge', '((Excise/100) * (basicPrice+afterLandingCharge+afterHighseas+afterCustomduty))');
define('Capital_ExciseEDcess_Charge', '(ExciseEDcessCharge/100) * ExciseDuty');
define('Capital_ExciseSHcess_Charge', '(ExciseSHcessCharge/100) * ExciseDuty');
define('Capital_CustomEDcess_Charge', '((CustomEDcess/100) * (afterLandingCharge+AfterHighseas+AfterCustomduty+AfterExcisedutyTax+AfterExcisedutyEDcess+AfterExcisedutySHcess))');
define('Capital_CustomSHcess_Charge', '((CustomSHcess/100) * (afterLandingCharge+AfterHighseas+AfterCustomduty+AfterExcisedutyTax+AfterExcisedutyEDcess+AfterExcisedutySHcess))');
define('Capital_AdditionalExciseduty_Charge', '((AdditionalExciseduty/100) * (basicPrices+afterLandingCharge+AfterHighseas+AfterCustomduty+AfterExcisedutyTax+AfterExcisedutyEDcess+AfterExcisedutySHcess+AfterCustomEDcess+AfterCustomSHcess))');
define('Capital_Grossdutypayable_Charge', '(AfterAdditionalExciseduty+afterLandingCharge+AfterHighseas+AfterCustomduty+AfterExcisedutyTax+AfterExcisedutyEDcess+AfterExcisedutySHcess+AfterCustomEDcess+AfterCustomSHcess)');
define('Capital_ModvatCharge_Charge', '(AfterExcisedutyTax+AfterExcisedutyEDcess+AfterExcisedutySHcess+AfterAdditionalExciseduty)');
define('Capital_Grossexpenses_Charge', '(Grossdutypayable-AvailableModvat)');
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 */
/* Location: ./application/config/constants.php */

View File

@ -54,20 +54,19 @@ class emergencypurchaseorder extends BaseController
$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['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';

File diff suppressed because it is too large Load Diff

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -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);
}

View File

@ -0,0 +1,542 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
/**
* Class : requisitionform (requisitionformController)
* User Class to control all user related operations.
* @author : VenbaMail Mali
* @version : 1.1
* @since : 15 Feb 2016
*/
class requisitionform extends BaseController
{
/**
* This is default constructor of the class
*/
public function __construct()
{
parent::__construct();
$this->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 = "<option value='-1'>Select Cost center</option>";
$BudAmount = "";
if(count($CostList) > 0)
{
for ($j = 0; $j < count($CostList); $j++)
{
$Code = $CostList[$j]['CostCenterCode'];
$Name = $CostList[$j]['CostCenterName'];
$HTML .="<option value='".$Code."'>".$Code."-".$Name."</option>";
}
}
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 = "<option value='-1'>Select Material Type</option>";
if(count($MaterialCode) > 0)
{
for ($j = 0; $j < count($MaterialCode); $j++)
{
$Code = $MaterialCode[$j]['MaterialCode'];
$Name = $MaterialCode[$j]['MaterialName'];
$HTML .="<option value='".$Code."'>".$Code."-".$Name."</option>";
}
$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.="<tr id='".$i."'>
<td align='left'>".$SNo."</td>
<td align='left'>". $MaterialCode."</td>
<td align='left'>".$MaterialName."</td>
<td align='left'>".$UOM."</td>
<td align='left'>".$Quantity."</td>
<td align='left'>".$POQTY."</td>
<td align='left'>".$StatusName."</td>
</tr>";
//$index = $index + 1;
}
$CostCode = '';
$ReqType = '';
$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);
}
}
?>

View File

@ -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);

View File

@ -0,0 +1,325 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
/**
* Class : purchaseorder (PurchaseorderController)
* User Class to control all user related operations.
* @author : VenbaMail Mali
* @version : 1.1
* @since : 15 Feb 2016
*/
class servicepurchaseorder extends BaseController
{
/**
* This is default constructor of the class
*/
public function __construct()
{
parent::__construct();
$this->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);
}
}
?>

View File

@ -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();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -0,0 +1,500 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class requistion_model extends CI_Model
{
/**
* This function is used to get the SupplierID and SupplierName information
* @return array $result : This is result of the query
*/
function getSupplierName()
{
$this->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();
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,35 +1,73 @@
<?php
$ReqNo = '';
$ReqType = '';
$Requestedby = '';
$FirstName ='';
$ReqNo = '';
$ReqType = '';
$Requestedby = '';
$FirstName ='';
$Designation ='';
$DepartmentName = '';
$Status = '';
$CostCenterCode = '';
$RowCount = '';
$serviceSchedule='';
$servicePeriod='';
$noOfService='';
if(!empty($ReqDetails))
{
foreach ($ReqDetails as $Req)
{
$ReqNo = $Req->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;
}
}
?>
<style>
.table-bordered>thead>tr>th, .table-bordered>tbody>tr>th, .table-bordered>tfoot>tr>th, .table-bordered>thead>tr>td, .table-bordered>tbody>tr>td, .table-bordered>tfoot>tr>td {border: 1px solid #333;}
</style>
<script type="text/javascript">
window.onload = function()
{
var serviceScheduleType = '<?php echo $serviceSchedule; ?>';
if(serviceScheduleType != '')
{
if(serviceScheduleType!='Recurring'){
document.getElementById('DisplayScheduleDiv').style.display = 'block';
document.getElementById('ServicePeriodOption').style.display = 'none';
document.getElementById('NoServices').style.display = 'none';
}
else{
document.getElementById('DisplayScheduleDiv').style.display = 'block';
document.getElementById('ServicePeriodOption').style.display = 'block';
document.getElementById('NoServices').style.display = 'block';
}
}
else
{
document.getElementById('DisplayScheduleDiv').style.display = 'none';
document.getElementById('ServicePeriodOption').style.display = 'none';
document.getElementById('NoServices').style.display = 'none';
}
}
</script>
<div class="content-wrapper">
@ -129,6 +167,74 @@ if(!empty($ReqDetails))
</div>
</div>
<div class="col-md-3" id="DisplayScheduleDiv" style="display:none;">
<label>Select Service Schedule Type</label>
<div class="form-group">
<?php
$Schdule =array("One Time", "Recurring");
if(!empty($Schdule))
{
foreach ($Schdule as $seletedSch):
if($serviceSchedule==$seletedSch){
$SchType[$seletedSch] = $seletedSch ;
}
endforeach;
foreach ($Schdule as $Sch):
if($serviceSchedule!=$Sch){
$SchType[$Sch] = $Sch ;
}
endforeach;
}
echo form_dropdown('ScheduleType', $SchType,set_value('ScheduleType'),'id="ScheduleType"' ,'class = "form-control"');
?>
</div>
</div>
<div class="col-md-3" id="ServicePeriodOption" style="display:none;">
<label>Select Service Period Option</label>
<div class="form-group">
<?php
if(!empty($ServiceOption))
{
foreach ($ServiceOption as $SerOptionsel):
if($servicePeriod==$SerOptionsel->ConfigValue){
$ServiceOptions[$SerOptionsel->ConfigValue] = $SerOptionsel->ConfigValue;
}
endforeach;
foreach ($ServiceOption as $SerOption):
if($servicePeriod!=$SerOption->ConfigValue){
$ServiceOptions[$SerOption->ConfigValue] = $SerOption->ConfigValue;
}
endforeach;
}
echo form_dropdown('ServiceOptions', $ServiceOptions,set_value('ServiceOptions'),'id="ServiceOptions"' ,'class = "form-control"');
?>
</div>
</div>
<div class="col-md-3" id="NoServices" style="display:none;">
<label>Number of Services</label>
<div class="form-group">
<?php
$data = array('name' => 'ServiceNo','value' => set_value('ServiceNo',$noOfService),'id'=>'ServiceNo', 'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);');
echo form_input($data);
?>
</div>
</div>
</div>
@ -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:"<?php echo base_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';
}
});
</script>

File diff suppressed because it is too large Load Diff

View File

@ -16,9 +16,7 @@ if(!empty($Emp))
}
}
?>
<style>
.table-bordered>thead>tr>th, .table-bordered>tbody>tr>th, .table-bordered>tfoot>tr>th, .table-bordered>thead>tr>td, .table-bordered>tbody>tr>td, .table-bordered>tfoot>tr>td {border: 1px solid #333;}
</style>
<div class="content-wrapper">
@ -121,9 +119,66 @@ if(!empty($Emp))
?>
</div>
</div>
<div class="col-md-3" id="DisplayScheduleDiv" style="display:none;">
<label>Select Service Schedule Type</label>
<div class="form-group">
<?php
$Schdule =array("One Time", "Recurring");
if(!empty($Schdule))
{
foreach ($Schdule as $Sch):
$SchType[$Sch] = $Sch ;
endforeach;
}
echo form_dropdown('ScheduleType', $SchType,set_value('ScheduleType'),'id="ScheduleType"' ,'class = "form-control"');
?>
</div>
</div>
<div class="col-md-3" id="ServicePeriodOption" style="display:none;">
<label>Select Service Period Option</label>
<div class="form-group">
<?php
if(!empty($ServiceOption))
{
foreach ($ServiceOption as $SerOption):
$ServiceOptions[$SerOption->ConfigValue] = $SerOption->ConfigValue;
endforeach;
}
echo form_dropdown('ServiceOptions', $ServiceOptions,set_value('ServiceOptions'),'id="ServiceOptions"' ,'class = "form-control"');
?>
</div>
</div>
<div class="col-md-3" id="NoServices" style="display:none;">
<label>Number of Services</label>
<div class="form-group">
<?php
$data = array('name' => 'ServiceNo','value' => set_value('ServiceNo'),'id'=>'ServiceNo', 'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);');
echo form_input($data);
?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@ -296,7 +351,7 @@ if(!empty($Emp))
<input type="hidden" name="txtRowCount" id="txtRowCount" />
<input type="hidden" name="txtDeletedRow" id="txtDeletedRow" />
<a class="btn btn-primary Save" ID="Save" onclick="Save()" >&nbsp;&nbsp;<span class="bold">Save</span></a>
<input type="submit" class="btn btn-primary" >
<input type="reset" class="btn btn-primary">
@ -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:"<?php echo base_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:"<?php echo base_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;
}
});
</script>

View File

@ -0,0 +1,901 @@
<?php
$EmpID = "";
$Designation = "";
$DepartmentName = "";
$FirstName = "";
if(!empty($Emp))
{
foreach ($Emp as $Emp)
{
$EmpID = $Emp->EmpID ;
$FirstName = $Emp->FirstName ;
$Designation = $Emp->Designation;
$DepartmentName =$Emp->DepartmentName;
}
}
?>
<div class="content-wrapper">
<section class="content">
<div>
<center><b><h2>Siddharth Industries - Requisition Form</h2></b></center>
<div class="container-fluid">
<div id="content"></div>
<?php
$attributes = array('class' => 'form-label-left requistion ','name' => 'requistion','id' => 'requistion');
echo form_open($this->config->base_url().'requisitionform/SearchRequistList',$attributes); ?>
<div class="row">
<div class="col-md-12">
<div class="col-md-3">
<label>Request Type</label>
<div>
<?php
$options = array("-1"=>'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"');
?>
</div>
</div>
<div class="col-md-3">
<label>Requested By</label>
<div>
<?php
$data = array('name' => 'EmpID','value' => set_value('EmpID',$FirstName),'id'=>'EmpID', 'class' => 'form-control' ,'readonly' => 'true');
echo form_input($data);
?>
<input type="hidden" name="EmpID" id="EmpID" value=<?php echo $EmpID?> />
</div>
</div>
<div class="col-md-3">
<label>Department Name</label>
<div class="form-group">
<?php
$data = array('name' => 'DeptName','value' => set_value('DeptName',$DepartmentName),'id'=>'DeptName', 'class' => 'form-control' ,'readonly' => 'true');
echo form_input($data);
?>
</div>
</div>
<div class="col-md-3">
<label>Designation</label>
<div class="form-group">
<?php
$data = array('name' => 'Designation','value' => set_value('Designation',$Designation),'id'=>'Designation', 'class' => 'form-control' ,'readonly' => 'true');
echo form_input($data);
?>
</div>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<label>Cost Center Name</label>
<div>
<?php
$Costs = array("-1"=>'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"');
?>
</div>
</div>
<div class="col-md-3">
<label>Available Budget Amount</label>&nbsp;<img id="AlertImg" src="<?php echo base_url(); ?>assets/dist/img/red.png" alt="your image" width="25px" style="display:none"/>
<div class="form-group">
<?php
$data = array('name' => 'AvlBudgetAmount','value' => set_value('AvlBudgetAmount'),'id'=>'AvlBudgetAmount', 'class' => 'form-control' ,'readonly' => 'true');
echo form_input($data);
?>
</div>
</div>
<div class="col-md-3" id="DisplayScheduleDiv" style="display:none;">
<label>Select Service Schedule Type</label>
<div class="form-group">
<?php
$Schdule =array("One Time", "Recurring");
if(!empty($Schdule))
{
foreach ($Schdule as $Sch):
$SchType[$Sch] = $Sch ;
endforeach;
}
echo form_dropdown('ScheduleType', $SchType,set_value('ScheduleType'),'id="ScheduleType"' ,'class = "form-control"');
?>
</div>
</div>
<div class="col-md-3" id="ServicePeriodOption" style="display:none;">
<label>Select Service Period Option</label>
<div class="form-group">
<?php
if(!empty($ServiceOption))
{
foreach ($ServiceOption as $SerOption):
$ServiceOptions[$SerOption->ConfigValue] = $SerOption->ConfigValue;
endforeach;
}
echo form_dropdown('ServiceOptions', $ServiceOptions,set_value('ServiceOptions'),'id="ServiceOptions"' ,'class = "form-control"');
?>
</div>
</div>
<div class="col-md-3" id="NoServices" style="display:none;">
<label>Number of Services</label>
<div class="form-group">
<?php
$data = array('name' => 'ServiceNo','value' => set_value('ServiceNo'),'id'=>'ServiceNo', 'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);');
echo form_input($data);
?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<table class="table table-bordered" style="border:1px solid #333">
<div align="right" style="padding-right:10px">
<div align="right">
<a onclick="return validateBeforeAdd();" class="btn btn-primary">Add Line Item</a>
<div class="modal fade" id="myModal1" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<center><h4>Add Line Item </h4></center>
</div>
<div align="left">
<div class="col-md-6">
<label>Material Code</label>
<div >
<?php
$options = array("0"=>'Material Code');
//print_r( $options);
if(!empty($MaterialList))
{
foreach ($MaterialList as $MID):
$options[$MID->MaterialCode] = $MID->MaterialCode.' '.' - '.' '.$MID->MaterialName;
endforeach;
}
echo form_dropdown('MaterialCode', $options,set_value('MaterialCode'),'id="MaterialCode"' ,'class="form-control"');
?>
</div>
</div>
<div class="col-md-6">
<label>Description</label>
<div class="form-group">
<?php
$data = array('name' => 'Description','value' => set_value('Description'),'id'=>'Description', 'class' => 'form-control','readonly' => 'true' );
echo form_input($data);
?>
</div>
</div>
<div class="col-md-6">
<label>UOM</label>
<div>
<?php
$data = array('name' => 'UOM','value' => set_value('UOM'),'id'=>'UOM', 'class' => 'form-control','readonly' => 'true' );
echo form_input($data);
?>
</div>
</div>
<div class="col-md-6">
<label>Quantity</label>
<div class="form-group">
<?php
$data = array('name' => 'Quantity','value' => set_value('Quantity'),'id'=>'Quantity', 'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event)','maxlength'=>'20');
echo form_input($data);
?>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-info font addClick" ID="addClick" ><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Add</span></a>
<a class="btn btn-info" data-dismiss="modal" value="Cancel">cancel</a>
</div>
</div>
</div>
</div>
</div><br/> <div class="modal fade" id="EditItem" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<center><h4>Edit Line Item </h4></center>
</div>
<div align="left">
<div class="col-md-6">
<label>Material Code</label>
<div >
<?php
$data = array('name' => 'EditMaterialCode', 'value' => set_value('EditMaterialCode'),'id'=>'EditMaterialCode', 'class' => 'form-control','readonly'=>'true');
echo form_input($data);
?>
</div>
</div>
<div class="col-md-6">
<label>Description</label>
<div class="form-group">
<?php
$data = array('name' => 'EditDescription','value' => set_value('EditDescription'),'id'=>'EditDescription', 'class' => 'form-control','readonly' => 'true' );
echo form_input($data);
?>
</div>
</div>
<div class="col-md-6">
<label>UOM</label>
<div>
<?php
$data = array('name' => 'EditUOM','value' => set_value('EditUOM'),'id'=>'EditUOM', 'class' => 'form-control','readonly' => 'true' );
echo form_input($data);
?>
</div>
</div>
<div class="col-md-6">
<label>Quantity</label>
<div class="form-group">
<?php
$data = array('name' => 'EditQuantity','value' => set_value('EditQuantity'),'id'=>'EditQuantity', 'class' => 'form-control','onkeypress'=>'return isNumberKey(event)','maxlength'=>'20');
echo form_input($data);
?>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-info font EditClick" ID="EditClick" ><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Edit</span></a>
<a class="btn btn-info" data-dismiss="modal" value="Cancel">Cancel</a>
</div>
</div>
</div>
</div>
</div></br>
<table id="Items" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;">
<thead style="background-color:#ddf">
<tr>
<th>SNo</th>
<th>Material Code</th>
<th>Material Name</th>
<th>Uom</th>
<th>Quantity</th>
<th>Action</th>
</tr>
</thead>
<tbody id="tempAppend">
</tbody>
</table>
<div align="right" style="padding-right:10px">
<input type="hidden" name="txtRowCount" id="txtRowCount" />
<input type="hidden" name="txtDeletedRow" id="txtDeletedRow" />
<a class="btn btn-primary Save" ID="Save" onclick="Save()" >&nbsp;&nbsp;<span class="bold">Save</span></a>
<input type="submit" class="btn btn-primary" >
<input type="reset" class="btn btn-primary">
</div>
<br>
</div>
</div>
</section>
</div>
<script>
var isExceed = 0;
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31
&& (charCode < 48 || charCode > 57))
return false;
return true;
}
$(function() {
$( ".datePicker" ).datepicker({ dateFormat: 'dd/mm/yy' });
//Initialize Select2 Elements
$(".select2").select2();
$('#CostCenter').change(function() {
var id = $('#CostCenter').val();
$("#AvlBudgetAmount").val('');
var ReqType = $('#RequestType').val();
if(id != '-1' && ReqType != '-1')
{
$('#content').loader('show');
$.ajax({
data:{id:id},
type:"POST",
url:"<?php echo base_url() ?>servicepurchaseorder/AvilBudgetAmount?ReqType="+ReqType,
success:function(data) {
if(data)
{
$('#content').loader('hide');
$("#AvlBudgetAmount").val(parseFloat(data).toFixed(2));
if(parseFloat($("#AvlBudgetAmount").val()) <= 0)
{
$('#AlertImg').removeAttr("style");
isExceed = 1;
}
else
{
$('#AlertImg').attr("style","display:none;");
isExceed =0;
}
}
else
{
$('#content').loader('hide');
alert("Error");
}
}
});
}
else
{
alert('Please select the Requistion Type');
$('#CostCenter').val("-1");
return false;
}
});
$('#RequestType').change(function()
{
$("#AvlBudgetAmount").val('');
$('#AlertImg').attr("style","display:none;");
$('#txtRowCount').val('');
$('#txtDeletedRow').val('');
$("#Description").val('');
$("#UOM").val('');
$('#CostCenter').val("-1");
removeHiddenRows($('#Items').find('tr').length);
$('#tempAppend').empty();
var id = $('#RequestType').val();
if(id != '-1')
{
$('#content').loader('show');
$.ajax({
data:{id:id},
dataType: 'json',
type:"POST",
url:"<?php echo base_url();?>requisitionform/getMaterialCode",
success:function(json) {
$('#content').loader('hide');
$("#MaterialCode").empty();
$("#MaterialCode").append(json.Material);
// $("#Description").val(json.MaterialName);
//$("#UOM").val(json.UOM);
if(id!='SERVICE'){
$('#DisplayScheduleDiv').hide();
$('#ServicePeriodOption').hide();
$('#NoServices').hide();
}
else{
$('#DisplayScheduleDiv').show();
}
}
});
//$('#content').loader('hide');
}
else
{
alert('Please select the RequestType');
return false;
}
});
$('#MaterialCode').change(function() {
var id = $('#MaterialCode').val();
$("#Description").val('');
$("#UOM").val('');
if(id != '-1')
{
$('#content').loader('show');
$.ajax({
data:{id:id},
dataType: 'json',
type:"POST",
url:"<?php echo base_url();?>requisitionform/getMaterialDetails",
success:function(json) {
$('#content').loader('hide');
//alert(json.MatDetail);
$("#Description").val(json.MatDetail[0]['MaterialName']);
$("#UOM").val(json.MatDetail[0]['UOM']);
}
});
//$('#content').loader('hide');
}
else
{
alert('Please select the RequestType');
return false;
}
});
});
</script>
<script type="text/html" id="tempList">
<tr id="<%=index%>">
<td align="left"><%=index%></td>
<td align="left"><%=MaterialCode%></td>
<td align="left"><%=MaterialName%></td>
<td align="left"><%=UOM%></td>
<td align="left"><%=Quantity%></td>
<td>
<a data-target='#EditItem' data-id="<%=index%>" data-userid="<%=index%>" data-toggle="modal" href="#EditItem"><i class="fa fa-pencil" data-toggle="tooltip" title="Click here to view/Edit the <%=MaterialCode%> Material details"></i>&nbsp;&nbsp;&nbsp;</a> <a href='#' onclick = "Deleterow(<%=index%>)" class="link" data-id="<%=index%>" data-userid="<%=index%>" id="Del" ><span class="glyphicon glyphicon-trash"></span></a>
</td>
</tr>
</script>
<script>
var index = '1';
var userid = '';
function removeHiddenRows(rowcount)
{
var step;
if(rowcount > 2)
{
for (step = 1; step < rowcount ; step++) {
var td = document.getElementById(step);
td.parentNode.removeChild(td);
$("#MaterialCode"+step).remove();
$("#Description"+step).remove();
$("#UOM"+step).remove();
$("#Quantity"+step).remove();
index = '1';
userid = '';
}
}
}
function Save()
{
var id = '<?php echo REQ_DRAFT;?>'
if(validate())
{
if(document.getElementById('Items').rows.length < 0)
{
alert('Please Select Line item to Create Requisition');
$('#Deliverydt').focus();
return false;
}
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()+"&serviceSchedule="+serviceSchedule+"&servicePeriod="+servicePeriod+"&noOfService="+noOfService,
type:"POST",
url:"<?php echo base_url() ?>requisitionform/addNewRequistion?ID="+id,
success:function(data) {
if(data)
{
$('#content').loader('hide');
alert(data);
$('#txtRowCount').val('');
$('#txtDeletedRow').val('');
window.location = "Requisition";
}
else
{
alert("Error");
}
}
});
}
}
}
function validate()
{
if($("option:selected", $("#RequestType")).val() == '-1')
{
alert('Please Select ReqType Names');
return false;
}
else if($("option:selected", $("#EmpID")).val() == '-1')
{
alert('Please Select Reqby');
return false;
}
else if($("#txtRowCount").val().length < 1)
{
alert('Please Add Line Item');
return false;
}
else if(isExceed == 1)
{
alert('You dont have Budget and You cant Raise New Requisition');
return false;
}
else
{
return true;
}
}
function Deleterow(rowid)
{
var DelRows = $('#txtDeletedRow').val();
var answer = confirm(" Do you want to delete the Item from the List?")
if (answer)
{
var td = document.getElementById(rowid);
td.parentNode.removeChild(td);
if(DelRows != '')
{
DelRows = DelRows + ":" + rowid;
}
else
{
DelRows= "0" + ":" + rowid;
}
$('#txtDeletedRow').val(DelRows);
}
}
function validateBeforeAdd()
{
if($("option:selected", $("#RequestType")).val() == '-1')
{
alert('Please select the Request Type ');
$("#RequestType").focus();
return false;
}
else if($("#CostCenter").val() == '-1')
{
alert('Please select the Cost center to check the Budget Availablity ');
$("#CostCenter").focus();
return false;
}
else if( isExceed == '1')
{
alert('You dont have available Budget Amount. You cant raise new Requisition');
return false;
}
else
{
$('#myModal1').modal('show');
}
}
$('.addClick').click(function(){
if ($("#MaterialCode option:selected").val() =='-1' )
{
alert('Please Select the MaterialCode ');
return false;
}
if(document.getElementById('Quantity').value == '' )
{
alert('Please Enter the Quantity');
return false;
}
if ($("#MaterialCode option:selected").val() !='-1' && $('#Quantity').val() != '' )
{
var temp = index;
var materialCode = $("#MaterialCode option:selected").val();
var materialName = $("#Description").val();
var uom = $("#UOM").val();
var quantity = $("#Quantity").val();
$('#MaterialCode option[value='+materialCode+']').remove();
$('#Description').val('');
$('#UOM').val('');
$('#Quantity').val('');
index = parseInt(index)+1;
var template = jQuery("#tempList").html();
$('#tempAppend').append(_.template(template,{index:temp,MaterialCode:materialCode,MaterialName:materialName,UOM:uom,Quantity:quantity}));
var theForm = $(".requistion");
addHidden(theForm,"MaterialCode"+temp,materialCode);
addHidden(theForm,"Description"+temp,materialName);
addHidden(theForm,"UOM"+temp,uom);
addHidden(theForm,"Quantity"+temp,quantity);
$('#txtRowCount').val(temp);
}
});
function addHidden(theForm, key, value) {
// Create a hidden input element, and append it to the form:
var input = document.createElement('input');
input.type = 'hidden';
input.name = key;'name-as-seen-at-the-server';
input.id = key;'name-as-seen-at-the-server';
input.value = value;
theForm.append(input);
}
$("#myModal1").on("shown.bs.modal", function(e) {
if($("option:selected", $("#RequestType")).val() == '-1')
{
alert('Please select the Request Type ');
e.close();
}
});
$("#EditItem").on("shown.bs.modal", function(e) {
userid = $(e.relatedTarget).data('userid');
// alert(userid);
var tr= document.getElementById(userid);
var cellval = tr.cells;
//alert(x[1].innerHTML);
$('#EditMaterialCode').val(cellval[1].innerHTML);
$('#EditDescription').val(cellval[2].innerHTML);
$('#EditUOM').val(cellval[3].innerHTML);
$('#EditQuantity').val(cellval[4].innerHTML);
});
$('.EditClick').click(function(){
if(document.getElementById('EditQuantity').value == '' )
{
alert('Please Enter the Quantity' );
}
if ( $('#EditQuantity').val() != '' )
{
var editMaterialCode = $("#EditMaterialCode").val();
var editDescription = $("#EditDescription").val();
var editUOM = $('#EditUOM').val();
var editQuantity = $('#EditQuantity').val();
var tr= document.getElementById(userid);
var cellval = tr.cells;
cellval[1].innerHTML = editMaterialCode;
cellval[2].innerHTML = editDescription;
cellval[3].innerHTML =editUOM;
cellval[4].innerHTML = editQuantity;
$('#MaterialCode'+userid).val(editMaterialCode);
$('#Description'+userid).val(editDescription);
$('#UOM'+userid).val(editUOM);
$('#Quantity'+userid).val(editQuantity);
}
});
$(".requistion").submit(function(e) {
var id='<?php echo REQ_PENDING_APPROVAL;?>'
e.preventDefault();
if(validate())
{
if(document.getElementById('Items').rows.length < 0)
{
alert('Please Select Line item to Create Requisition');
$('#Deliverydt').focus();
return false;
}
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()+"&serviceSchedule="+serviceSchedule+"&servicePeriod="+servicePeriod+"&noOfService="+noOfService,
type:"POST",
url:"<?php echo base_url() ?>requisitionform/addNewRequistion?ID="+id,
success:function(data) {
if(data)
{
$('#content').loader('hide');
alert(data);
$('#txtRowCount').val('');
$('#txtDeletedRow').val('');
window.location = "Requisition";
}
else
{
alert("Error");
}
}
});
}
}
});
<!-- script for table , It works under the datatable plugin-->
$(function () {
$('#Items').DataTable({
"paging": false,
"lengthChange": true,
"searching": false,
"ordering": false,
"info": false,
"autoWidth": true
});
});
$("#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;
}
});
</script>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff