diff --git a/app/Config/Autoload.php b/app/Config/Autoload.php index c89dfd5a..be6c1869 100755 --- a/app/Config/Autoload.php +++ b/app/Config/Autoload.php @@ -90,5 +90,5 @@ class Autoload extends AutoloadConfig * * @var list */ - public $helpers = ['datetime','cias','purchaseorder','alert']; + public $helpers = ['cias','datetime','image','alert','excel']; } diff --git a/app/Config/Routes.php b/app/Config/Routes.php index c794b782..f3ea3138 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -200,6 +200,7 @@ $routes->post('monthlypay/deletePublicHoliday', 'Monthlypay::deletePublicHoliday $routes->get('leaveApplicationForm', 'Monthlypay::leaveApplicationForm'); $routes->post('fetchLeaveApplicationForm', 'Monthlypay::fetchLeaveApplicationForm'); $routes->get('deleteLeaveApplicationForm', 'Monthlypay::deleteLeaveApplicationForm'); +$routes->post('validateDateRange', 'Monthlypay::validateDateRange'); $routes->match(['GET', 'POST'], 'leaveApplicationPDF/(:any)', 'Monthlypay::leaveApplicationPDF/$1'); $routes->match(['GET', 'POST'], 'overTimeDetails', 'Monthlypay::overTimeDetails'); @@ -326,7 +327,9 @@ $routes->post('inwardgateregister/edituploadfile', 'Inwardgateregister::edituplo $routes->post('getIGRRemarks', 'Inwardgateregister::getIGRRemarks'); $routes->post('saveIGRRemarks', 'Inwardgateregister::saveIGRRemarks'); $routes->post('updateGasShortage','Inwardgateregister::updateGasShortage'); -$routes->post('gasShortageList','Inwardgateregister::gasShortageList'); +$routes->get('gasCylinderEntered','Inwardgateregister::gasCylinderEntered'); +$routes->get('gasCylinderPending','Inwardgateregister::gasCylinderPending'); +$routes->get('gasCylinderReturned','Inwardgateregister::gasCylinderReturned'); $routes->post('getGasShortageDetail',"Inwardgateregister::getGasShortageDetail"); diff --git a/app/Controllers/Amendmentpurchaseorder.php b/app/Controllers/Amendmentpurchaseorder.php index 90e58bc8..1ea82013 100755 --- a/app/Controllers/Amendmentpurchaseorder.php +++ b/app/Controllers/Amendmentpurchaseorder.php @@ -229,6 +229,7 @@ class Amendmentpurchaseorder extends BaseController */ function EditRevenuePurchaseOrder() { + helper('numberseries'); $NewPO = ''; $MAD = ''; // $changeStatus ,will havestatus code itself provided from front-end , no need of constants @@ -309,8 +310,9 @@ class Amendmentpurchaseorder extends BaseController if ($PaymentTerms != 'PT08') { $Otherpayment = ''; } + $IsOpenOrder = ($this->request->getPost('IsOpenOrder') !== null && !empty($this->request->getPost('IsOpenOrder')) && $this->request->getPost('IsOpenOrder') === '1') ? $this->request->getPost('IsOpenOrder') : null; $AmendmentNewPoNo = generate_amendment_po_number($PONO); - $POMaster = array('PONO' => $AmendmentNewPoNo, 'ParentPO' => $PONO, 'SupplierID' => $SupplierID, 'POType' => $POType, 'PORange' => $Local_Interstate, 'TotalOrderValue' => $TotalOrderValueSummary, 'PODate' => $PODate, 'Status' => $changeStatus , 'PaymentTerms' => $PaymentTerms, 'PaymentOtherDescription' => $Otherpayment, 'Mode_Of_Shipment' => $Modeofshipment, 'Supplier_Reference' => $supplierreference, 'Supplier_Offer_No' => $supplieroffno, 'Other_Reference' => $otherreference, 'Fincap' => $fincap, 'InsuranceStatus' => $insurancestatus, 'InsuranceNumber' => $InsuranceNumber, 'POSubType' => $revenuetype, 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'ServiceDescription' => $SpecialInstruction, 'CreatedBy' => $updatedBy, 'DeliveryAddress' => $DeliveryAddr, 'DeliveryDate' => $Deliverydt, 'UpdatedOn' => $updateddt, 'ReleasedBy' => $updatedBy, 'ReleasedOn' => $updateddt, 'AmendedDetails' => $MAD, 'IsQualityChkReqired' => $qtycheckresult,'CapitalRange' => $Local_Interstate,'BudgetType' => $BudgetType); // not + $POMaster = array('PONO' => $AmendmentNewPoNo, 'ParentPO' => $PONO, 'SupplierID' => $SupplierID, 'POType' => $POType, 'PORange' => $Local_Interstate, 'TotalOrderValue' => $TotalOrderValueSummary, 'PODate' => $PODate, 'Status' => $changeStatus , 'PaymentTerms' => $PaymentTerms, 'PaymentOtherDescription' => $Otherpayment, 'Mode_Of_Shipment' => $Modeofshipment, 'Supplier_Reference' => $supplierreference, 'Supplier_Offer_No' => $supplieroffno, 'Other_Reference' => $otherreference, 'Fincap' => $fincap, 'InsuranceStatus' => $insurancestatus, 'InsuranceNumber' => $InsuranceNumber, 'POSubType' => $revenuetype, 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'ServiceDescription' => $SpecialInstruction, 'CreatedBy' => $updatedBy, 'DeliveryAddress' => $DeliveryAddr, 'DeliveryDate' => $Deliverydt, 'UpdatedOn' => $updateddt, 'ReleasedBy' => $updatedBy, 'ReleasedOn' => $updateddt, 'AmendedDetails' => $MAD, 'IsQualityChkReqired' => $qtycheckresult,'CapitalRange' => $Local_Interstate,'BudgetType' => $BudgetType, 'IsOpenOrder'=>$IsOpenOrder); // not $file = $this->request->getFile('POFile'); $requestfilename = $file->getName(); $PrePOFile = $this->request->getPost('PrePOFile'); @@ -580,13 +582,13 @@ class Amendmentpurchaseorder extends BaseController $recqty = $qty[0]->rec; // $POno = $qtyvalue->PONO; - if ($ordqty == $recqty) { + if(!$IsOpenOrder):if ($ordqty == $recqty) { $Newstatus = array('Status' => IGR_CREATED); $this->purchaseorder_model->POLineItemsupdatestatus($NewPO, $Newstatus); $this->purchaseorder_model->pomasterupdatestatus($NewPO, $Newstatus); - } + }endif; $message = 'Purchase Order ' . $PONO . ' Amended Successfully! - New PO Number is: ' . $NewPO ; @@ -603,7 +605,7 @@ class Amendmentpurchaseorder extends BaseController function UpdateAmendServicePurchaseOrder() { - // dd($this->request->getPost()); + helper('numberseries'); $PONO = $this->request->getPost('txtPONO'); $changeStatus = $this->request->getPost('changeStatus'); @@ -672,6 +674,7 @@ class Amendmentpurchaseorder extends BaseController $qtycheck = $this->purchaseorder_model->getqtycheck($PONO); $qtycheckresult = ''; + $IsOpenOrder = ($this->request->getPost('IsOpenOrder') !== null && !empty($this->request->getPost('IsOpenOrder')) && $this->request->getPost('IsOpenOrder') === '1') ? $this->request->getPost('IsOpenOrder') : null; foreach ($qtycheck as $qty) { $qtycheckresult = $qty->IsQualityChkReqired; } @@ -685,7 +688,7 @@ class Amendmentpurchaseorder extends BaseController } $AmendmentNewPoNo = generate_amendment_po_number($PONO); - $POMaster = array('PONO' => $AmendmentNewPoNo, 'ParentPO' => $PONO, 'POType' => $POType, 'SupplierID' => $SupplierID, 'TotalOrderValue' => $TotalOrderValueSummary, 'PODate' => $PODate, 'Status' =>$changeStatus , 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'ServiceDescription' => $scopeofwork, 'CreatedBy' => $updatedBy, 'DeliveryAddress' => $DeliveryAddr, 'DeliveryDate' => $Deliverydt, 'CreatedDate' => $updateddt, 'PaymentTerms' => $PaymentTerms, 'PaymentOtherDescription' => $Otherpayment, 'ServiceWorkStatus' => $WorkStatus, 'ReleasedBy' => $updatedBy, 'ReleasedOn' => $updateddt, 'AmendedDetails' => $MAD, 'Supplier_Reference' => $SupplierReference, 'Mode_Of_Shipment' => $ModeOfShipment, 'Supplier_Offer_No' => $SuppliersOfferNo, 'Other_Reference' => $OtherReferences, 'Fincap' => $Fincap, 'Description_Of_Service' => strip_tags((string)$DescriptionOfPo), 'InsuranceStatus' => $InsuranceOptions, 'InsuranceNumber' => $InsuranceNumber, 'POSubType' => $ServiceTypeOptions, 'IsQualityChkReqired' => $qtycheckresult); + $POMaster = array('PONO' => $AmendmentNewPoNo, 'ParentPO' => $PONO, 'POType' => $POType, 'SupplierID' => $SupplierID, 'TotalOrderValue' => $TotalOrderValueSummary, 'PODate' => $PODate, 'Status' =>$changeStatus , 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'ServiceDescription' => $scopeofwork, 'CreatedBy' => $updatedBy, 'DeliveryAddress' => $DeliveryAddr, 'DeliveryDate' => $Deliverydt, 'CreatedDate' => $updateddt, 'PaymentTerms' => $PaymentTerms, 'PaymentOtherDescription' => $Otherpayment, 'ServiceWorkStatus' => $WorkStatus, 'ReleasedBy' => $updatedBy, 'ReleasedOn' => $updateddt, 'AmendedDetails' => $MAD, 'Supplier_Reference' => $SupplierReference, 'Mode_Of_Shipment' => $ModeOfShipment, 'Supplier_Offer_No' => $SuppliersOfferNo, 'Other_Reference' => $OtherReferences, 'Fincap' => $Fincap, 'Description_Of_Service' => strip_tags((string)$DescriptionOfPo), 'InsuranceStatus' => $InsuranceOptions, 'InsuranceNumber' => $InsuranceNumber, 'POSubType' => $ServiceTypeOptions, 'IsQualityChkReqired' => $qtycheckresult,'IsOpenOrder'=>$IsOpenOrder); $file = $this->request->getFile('POFile'); $PrePOFile = $this->request->getPost('PrePOFile'); $requestfilename = $file ? $file->getName() : null; @@ -879,13 +882,13 @@ class Amendmentpurchaseorder extends BaseController $recqty = $qty[0]->rec; // $POno = $qtyvalue->PONO; - if ($ordqty == $recqty) { + if(!$IsOpenOrder):if ($ordqty == $recqty) { $Newstatus = array('Status' => IGR_CREATED); $this->purchaseorder_model->POLineItemsupdatestatus($NewPO, $Newstatus); $this->purchaseorder_model->pomasterupdatestatus($NewPO, $Newstatus); - } + }endif; $message = 'Purchase Order ' . $PONO . ' Amended Successfully! - New PO Number is: ' . $NewPO ; if($changeStatus == 'ST014'){ @@ -900,6 +903,7 @@ class Amendmentpurchaseorder extends BaseController */ function EditAmendCapitalPurchaseOrder() { + helper('numberseries'); $changeStatus = $this->request->getPost('changeStatus'); $PONO = $this->request->getPost('txtPONO'); $MAD = ''; @@ -1309,7 +1313,7 @@ class Amendmentpurchaseorder extends BaseController function EditAmendImportPO() { // echo "
"; print_r($this->request->getPost()); echo"
"; - + helper('numberseries'); $MAD = ''; $PONO = $this->request->getPost('txtPONO'); diff --git a/app/Controllers/Emergencypurchaseorder.php b/app/Controllers/Emergencypurchaseorder.php index 4e7fb046..401cea7d 100755 --- a/app/Controllers/Emergencypurchaseorder.php +++ b/app/Controllers/Emergencypurchaseorder.php @@ -122,6 +122,7 @@ class Emergencypurchaseorder extends BaseController //This used to Create Service Purchase Order function addNewServicePurchaseOrder() { + helper('numberseries'); // print_r($this->request->getPost());die; $txtRowCount = $this->request->getPost('txtRowCount'); $POdt = $this->request->getPost('PODate'); @@ -365,7 +366,7 @@ class Emergencypurchaseorder extends BaseController //This used to Create Revenue Emergency Purchase Order function addNewRevenuePurchaseOrder() { - + helper('numberseries'); // print_r($this->request->getPost());die; $txtspl = $this->request->getPost('txtSpecial'); @@ -617,12 +618,14 @@ class Emergencypurchaseorder extends BaseController $igr = array(); $paymentstatus = NO_PAIDIGR; - $igr = array('PONO' => $PONO, 'VehicleNo' => $Vehicle, 'DeliveryChellanOrInvoiceNo' => $DeliveryChellanInvoiceNo, 'DeliveryChellanDate' => $DeliveryChellanDate, 'MaterialRcvdDate' => $DeliveryChellanDate, 'CourierNo' => $Courier, 'IGRStatus' => $IGRStatus, 'CreatedBy' => $CreatedBy, 'CreatedDate' => $createddt, 'MaterialRcvdDate' => $MaterialReceivedate, 'Paymentstatus' => $paymentstatus); + $last_igrno = $this->inwardgateregister_model->lastIGRNO(); + $newIGRNO = generate_igr_number($last_igrno); + $igr = array('IGRNO'=>$newIGRNO,'PONO' => $PONO, 'VehicleNo' => $Vehicle, 'DeliveryChellanOrInvoiceNo' => $DeliveryChellanInvoiceNo, 'DeliveryChellanDate' => $DeliveryChellanDate, 'MaterialRcvdDate' => $DeliveryChellanDate, 'CourierNo' => $Courier, 'IGRStatus' => $IGRStatus, 'CreatedBy' => $CreatedBy, 'CreatedDate' => $createddt, 'MaterialRcvdDate' => $MaterialReceivedate, 'Paymentstatus' => $paymentstatus); //print_r($igr); $igrM = $this->inwardgateregister_model->addigrM($igr); - $IGRNO = !empty($igrM) ? $igrM : ''; + $IGRNO = $newIGRNO; if ($Qualitycheck == 0) { @@ -1162,6 +1165,7 @@ class Emergencypurchaseorder extends BaseController //This used to Create Revenue Purchase Order function addNewPurchaseOrder() { + helper('numberseries'); $POdt = $this->request->getPost('PODate'); $PODate = get_date_time_format($POdt); $SupplierID = $this->request->getPost('drpSupplier'); diff --git a/app/Controllers/Expense.php b/app/Controllers/Expense.php index 4d4a61d6..5f238411 100755 --- a/app/Controllers/Expense.php +++ b/app/Controllers/Expense.php @@ -48,16 +48,10 @@ class Expense extends BaseController $this->loadViews("expense_list", $this->global, $data, NULL); } - private function generateSerialNumber($financialYear, $lastSerial) - { - // If no last serial number exists, start with 00001 - $lastNumber = $lastSerial ? (int)explode('/', $lastSerial)[2] : 0; - $newNumber = str_pad($lastNumber + 1, 3, '0', STR_PAD_LEFT); - return "NonIGR/$financialYear/$newNumber"; - } public function addExpense() { + helper('numberseries'); try{ $file = $this->request->getFile('transporterfile'); $fileName = ''; @@ -66,28 +60,11 @@ class Expense extends BaseController $file->move(WRITEPATH . 'uploads', $fileName); } - - - // Fetch the current month - $currentMonth = date('n'); // 'n' gives the month without leading zeros (1-12) - - // Calculate the current financial year - if ($currentMonth >= 4) { // If it's April or later - $startYear = date('Y'); // Current year - $endYear = $startYear + 1; // Next year - } else { // If it's January, February, or March - $endYear = date('Y'); // Current year - $startYear = $endYear - 1; // Previous year - } - - // Format the financial year as "yy-yy" - $financialYear = substr($startYear, -2) . '-' . substr($endYear, -2); - // Fetch the last serial number for the financial year - $lastSerial = $this->expense_model->getLastSerialNumber($financialYear); + $lastSerial = $this->expense_model->getLastSerialNumber(); // Generate the next serial number - $newSerialNumber = $this->generateSerialNumber($financialYear, $lastSerial); + $newSerialNumber = generate_non_igr_number($lastSerial); $sesn_uid = $this->session->get('userId'); $data = [ diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php index 4fa4fd29..7d50bf69 100755 --- a/app/Controllers/Inwardgateregister.php +++ b/app/Controllers/Inwardgateregister.php @@ -10,6 +10,7 @@ use App\Models\Inwardgateregister_model; use App\Models\IGRRemarks_model; use App\Models\GasShortageModel; use App\Helpers\Notification; +use App\Models\Rawmaterialdetails_model; use DateTime; use ZipArchive; @@ -27,6 +28,8 @@ class Inwardgateregister extends BaseController protected $inwardgateregister_model; protected $IGRRemarks_model; protected $gasShortage_model; + + protected $rawMaterialDetails_model; protected $session; protected $logger; @@ -40,6 +43,7 @@ class Inwardgateregister extends BaseController $this->inwardgateregister_model = new Inwardgateregister_model(); $this->IGRRemarks_model = new IGRRemarks_model(); $this->gasShortage_model = new GasShortageModel(); + $this->rawMaterialDetails_model = new Rawmaterialdetails_model(); $this->session = session(); helper('form'); //$this->load->library('form_validation'); @@ -401,6 +405,7 @@ class Inwardgateregister extends BaseController function SaveIGR() { #Step 1 IGR Details + helper('numberseries'); $PONO = $this->request->getPost('PONO'); $IsThisOpenOrderPO = $this->request->getPost('hiddenIsOpenOrder'); $DeliveryChellanOrInvoiceNo = $this->request->getPost('InvoiceNo'); @@ -447,7 +452,11 @@ class Inwardgateregister extends BaseController } } #Step 3 Master Details Gathering to Save In DB - $igr = array('PONO' => $PONO, 'VehicleNo' => $VehicleNo, 'TransporterId'=>$TransporterId,'DeliveryChellanOrInvoiceNo' => $DeliveryChellanOrInvoiceNo, 'DeliveryChellanDate' => $DeliveryChellanDate, 'MaterialRcvdDate' => $MaterialRcvdDt, 'DriverName' => $DriverName, 'DriverMobileNumber' => $DriverMobileNumber,'IGRStatus' => $IGRStatus, 'CreatedBy' => $CreatedBy, 'CreatedDate' => $createddt, 'PaymentStatus' => $paymentstatus, 'Remark'=>$MasterRemarks); + $last_igrno = $this->inwardgateregister_model->lastIGRNO(); + // echo $last_igrno; + $newIGRNO = generate_igr_number($last_igrno); + // echo $newIGRNO;die; + $igr = array('IGRNO'=>$newIGRNO,'PONO' => $PONO, 'VehicleNo' => $VehicleNo, 'TransporterId'=>$TransporterId,'DeliveryChellanOrInvoiceNo' => $DeliveryChellanOrInvoiceNo, 'DeliveryChellanDate' => $DeliveryChellanDate, 'MaterialRcvdDate' => $MaterialRcvdDt, 'DriverName' => $DriverName, 'DriverMobileNumber' => $DriverMobileNumber,'IGRStatus' => $IGRStatus, 'CreatedBy' => $CreatedBy, 'CreatedDate' => $createddt, 'PaymentStatus' => $paymentstatus, 'Remark'=>$MasterRemarks); $igr['MasterFile'] = $requestMasterFileName; #Step 4 Calling DB to Save IGR Master $IGRNO = $this->inwardgateregister_model->addigrM($igr); @@ -550,7 +559,16 @@ class Inwardgateregister extends BaseController } $CreatedBy = $this->session->get('userId'); - $igrDetails = array('IGRNO' => $IGRNO, 'MaterialCode' => $MaterialCode, 'QuantityAsPerInvoice' => $QuantityAsPerInvoice, 'Remarks' => $Remarks, 'IGRItemStatus' => $IGRItemStatus,'GrossWeight' => (float)$GrossWeight ,'GrossWeightDate'=> $GrossWeightDate,'TareWeight' => (float)$TareWeight ,'TareWeightDate' => $TareWeightDate ,'NetWeight' => (float)$NetWeight, 'CreatedBy' => $CreatedBy, 'CreatedDate' => $createddt); + + $igrDetails = array( + 'IGRNO' => $IGRNO, 'MaterialCode' => $MaterialCode, 'QuantityAsPerInvoice' => $QuantityAsPerInvoice, + 'Remarks' => $Remarks, 'IGRItemStatus' => $IGRItemStatus,'GrossWeight' => (float)$GrossWeight , + 'GrossWeightDate'=> $GrossWeightDate,'TareWeight' => (float)$TareWeight ,'TareWeightDate' => $TareWeightDate , + 'NetWeight' => (float)$NetWeight, 'CreatedBy' => $CreatedBy, 'CreatedDate' => $createddt, + + //current change 04-04-2025 by vadivel + 'mIGRStatus' => $IGRStatus); + $igrDetails['WeightFile'] = $requestWeightFileName; log_message('error', 'SaveIGR igrDetails result : ' . json_encode($igrDetails)); @@ -928,7 +946,7 @@ function viewIGRDetails() $result_for_email = $this->inwardgateregister_model->getDetailsforEmail($this->session->get('userId'),$roleId); $result_for_history = $this->inwardgateregister_model->getHistoryDetailsforEmail($IGRNo); - + $notification = new Notification(); $history_content = "
IGR History

"; - $email = ""; - for ($i = 0; $i < count($result_for_email['emails']); $i++) { - $email .= $result_for_email['emails'][$i]->email . " , "; + + $to_email_addr = ""; + for ($i = 0; $i < count($result_for_email['to_mails']); $i++) { + $to_email_addr .= $result_for_email['to_mails'][$i]->email . " , "; } - $email = rtrim($email, " ,"); + // $to_email_addr .= "sanjeev.p@venbainfotech.com,gowtham.m@venbainfotech.com"; + $to_email_addr = rtrim($to_email_addr, " ,"); $email_response = $notification->sendEmail([ - 'recipient_email' => $email, + 'recipient_email' => $to_email_addr, 'subject' => $result_for_email['company'].' - IGR Notification', - // 'carboncopy'=>Sales@resicoindustries.com,Factory@resicoindustries.com,Invoice@resicoindustries.com, + 'carboncopy' =>"pavithra.t@venbainfotech.com", // 'description' => 'IGR Number : '.$IGRNo.' is Edited By '.($result_for_email['full_name'] ?? $this->session->get('name'))." On ".date('d-m-Y H:i A', strtotime(get_current_date_time() . ' +30 seconds')). $history_content, 'description' => $result_for_history['first_line']."
" .$history_content, 'company' => $result_for_email['company'], - 'from_mail'=> $result_for_email['from_mail'] + 'from_mail'=> $result_for_email['from_mails'] ]); log_message('error', 'email reponse : ' . json_encode($email_response)); @@ -1006,9 +1026,9 @@ function viewIGRDetails() // Log the result if ($receiving_status) { - $this->logger->info("Email IDs = " . $email . " " . $mail_log); + $this->logger->info("Email IDs = " . $to_email_addr . " " . $mail_log); } else { - $this->logger->error("Email IDs = " . $email . " " . $mail_log); + $this->logger->error("Email IDs = " . $to_email_addr . " " . $mail_log); } // echo "***".$history_content;die; @@ -1424,22 +1444,25 @@ function updateIGRWeight(){ $result_for_email = $this->inwardgateregister_model->getDetailsforEmail($this->session->get('userId'),$roleId); - - $email = ""; - for ($i = 0; $i < count($result_for_email['emails']); $i++) { - $email .= $result_for_email['emails'][$i]->email . " , "; - } - $email = rtrim($email, " ,"); + // print_r($result_for_email);die; + + $to_email_addr = ''; + for ($i = 0; $i < count($result_for_email['to_mails']); $i++) { + $to_email_addr .= $result_for_email['to_mails'][$i]->email . " , "; + } + // $to_email_addr = " venbalap08@gmail.com , sanjeev.p@venbainfotech.com"; + $to_email_addr = rtrim($to_email_addr, " ,"); $content = 'A new remark was created by '.$result_for_email['full_name'].' against IGR no '.$IGRNo.',

"'.$remark.'"'; $notification = new Notification(); $notification->sendEmail([ - 'recipient_email' => $email, + 'recipient_email' => $to_email_addr, 'subject' => $result_for_email['company'].' - IGR Remark Raised', + 'carboncopy' =>"pavithra.t@venbainfotech.com", 'description' => $content, 'company' => $result_for_email['company'], - 'from_mail'=> $result_for_email['from_mail'] + 'from_mail'=> $result_for_email['from_mails'] ]); @@ -1517,60 +1540,166 @@ function updateIGRWeight(){ - public function gasShortageList(){ + /* + ********************************************************* sec_gas_shortage_starts ************************************************************** + */ - $postData = $this->request->getPost(); + public function gasCylinderEntered(){ - $allShortages = $this->gasShortage_model->where('invoiceNo',$postData['invoiceNo'])->findAll(); + $this->global['pageTitle'] = 'Gas Cylinder Entered'; - return $this->response->setJSON(['status' => 'success', 'data' => $allShortages]); + $gasMaterialCodes = $this->rawMaterialDetails_model->getAllGasMaterialCode(); + + $gasMaterialCodes = array_column($gasMaterialCodes,'MaterialCode'); + + $igrDetailsListByMcatGas = $this->inwardgateregister_model->getIgrDetailsListByMcatGas($gasMaterialCodes,"gas_entered"); + + $data['gasCylinderEnteredList'] = $igrDetailsListByMcatGas; + + $this->loadViews("gasCylinderEntered", $this->global, $data, NULL); } + public function gasCylinderPending(){ - public function getGasShortageDetail(){ - $postData = $this->request->getPost(); + $this->global['pageTitle'] = 'Gas Cylinder Pending'; - $shortage = $this->gasShortage_model->where('id',$postData['id'])->find(); + $gasMaterialCodes = $this->rawMaterialDetails_model->getAllGasMaterialCode(); + + $gasMaterialCodes = array_column($gasMaterialCodes,'MaterialCode'); + + $igrDetailsListByMcatGas = $this->inwardgateregister_model->getIgrDetailsListByMcatGas($gasMaterialCodes,"gas_pending"); + + $data['gasCylinderPendingList'] = $igrDetailsListByMcatGas; + + $this->loadViews("gasCylinderPending", $this->global, $data, NULL); - return $this->response->setJSON(['status' => 'success', 'data' => $shortage]); } + public function gasCylinderReturned(){ + $this->global['pageTitle'] = 'Gas Cylinder Returned'; + + $gasMaterialCodes = $this->rawMaterialDetails_model->getAllGasMaterialCode(); + + $gasMaterialCodes = array_column($gasMaterialCodes,'MaterialCode'); + + $igrDetailsListByMcatGas = $this->inwardgateregister_model->getIgrDetailsListByMcatGas($gasMaterialCodes,"gas_returned"); + + $data['gasCylinderReturnedList'] = $igrDetailsListByMcatGas; + + $this->loadViews("gasCylinderReturned", $this->global, $data, NULL); + + + } public function updateGasShortage() { - $postData = $this->request->getPost(); - - // Validate required data - if (!$postData) { - return $this->response->setJSON(['status' => 'error', 'message' => 'Invalid request. No data received.']); - } + try { - // Validate required fields for adding - if ( !isset($postData['invoiceNo']) ) { - return $this->response->setJSON(['status' => 'error', 'message' => 'Missing required fields: invoice No.']); - } + $postData = $this->request->getJSON(true); // Convert JSON to an associative array - // Handle update (edit) - if (isset($postData["id"])) { - return $this->gasShortage_model->update($postData["id"], $postData) - ? $this->response->setJSON(['status' => 'success', 'message' => 'Gas shortage details updated successfully.']) - : $this->response->setJSON(['status' => 'error', 'message' => 'Failed to update gas shortage details.']); - } - - // Insert new shortage (add) - return ($insertId = $this->gasShortage_model->insert($postData)) - ? $this->response->setJSON(['status' => 'success', 'message' => 'Gas shortage details added successfully.', 'data' => ['id' => $insertId]]) - : $this->response->setJSON(['status' => 'error', 'message' => 'Failed to save gas shortage details.']); + // Validate if any data is received + if (!$postData) { + return $this->response->setJSON([ + 'status' => 'error', + 'message' => 'Invalid request. No data received.' + ]); + } + + // Validate required fields + if (empty($postData['invoiceNo']) ) { + return $this->response->setJSON([ + 'status' => 'error', + 'message' => 'Missing invoiceNo data.' + ]); + } + + $updates = []; + $inserts = []; + + if(isset($postData['id'])){ //update operation + + $cylinderData = [ + 'id' => $postData['id'], + 'IGRNO' => $postData['IGRNO'] ?? '', + 'fullCylinderDate' => $postData['fullCylinderDate'] ?? '', + 'emptyCylinderDate' => $postData['emptyCylinderDate'] ?? '', + 'invoiceNo' => $postData['invoiceNo'] ?? '', + 'cylinderNo' => $postData['cylinderNo'], + 'grossWeight' => $postData['grossWeight'], + 'tareWeight' => $postData['tareWeight'] ?? '', + 'netWeight' => $postData['netWeight'] ?? '', + 'actualWeight' => $postData['actualWeight'], + 'shortage' => $postData['shortage'] ?? '', + 'gas_cylinder_status' => "gas_returned" + ]; + + $updates[] = $cylinderData ; + + }else{//Insert Operation + + // Process each cylinder entry + foreach ($postData['cylinders'] as $cylinder) { + + // Ensure cylinder data is valid + if (!isset($cylinder['cylinderNo'], $cylinder['grossWeight'], $cylinder['actualWeight'])) { + continue; // Skip incomplete data + } + + $cylinderData = [ + 'IGRNO' => $postData['IGRNO'] ?? '', + 'fullCylinderDate' => $postData['fullCylinderDate'] ?? '', + 'emptyCylinderDate' => $postData['emptyCylinderDate'] ?? '', + 'invoiceNo' => $postData['invoiceNo'] ?? '', + 'cylinderNo' => $cylinder['cylinderNo'], + 'grossWeight' => $cylinder['grossWeight'], + 'tareWeight' => $cylinder['tareWeight'] ?? '', + 'netWeight' => $cylinder['netWeight'] ?? '', + 'actualWeight' => $cylinder['actualWeight'], + 'shortage' => $cylinder['shortage'] ?? '', + 'gas_cylinder_status' => 'gas_pending' + ]; + + $inserts[] = $cylinderData; + + } + + } + + if (!empty($updates)) { + $this->gasShortage_model->updateBatch($updates, 'id'); + } + + if (!empty($inserts)) { + $this->gasShortage_model->insertBatch($inserts); + } + + return $this->response->setJSON([ + 'status' => 'success', + 'message' => 'Gas shortage details processed successfully.' + ]); + + + } catch (\Throwable $th) { + // Log the error for debugging + log_message('error', 'Gas Shortage Update Error: ' . $th->getMessage()); + + return $this->response->setJSON([ + 'status' => 'error', + 'message' => 'An unexpected error occurred while processing gas shortage details.', + 'error' => $th->getMessage() + ]); + } } - - + /* + ********************************************************* sec_gas_shortage_ends ************************************************************** + */ } \ No newline at end of file diff --git a/app/Controllers/Monthlypay.php b/app/Controllers/Monthlypay.php index b25cd126..453ffa6c 100755 --- a/app/Controllers/Monthlypay.php +++ b/app/Controllers/Monthlypay.php @@ -101,7 +101,7 @@ class Monthlypay extends BaseController function attendanceLoad() { - + $month['month'] = ''; $monthdays = 0; $begin = 0; @@ -111,7 +111,7 @@ class Monthlypay extends BaseController $current = $this->request->getPost('month'); $month_short_name = substr((string)$current, 0, 3); - $year = substr((string)$current, 4); + $year = substr((string)$current, 4);// also used $month_arr = date_parse($month_short_name); $month = $month_arr['month']; $current = $year . "-" . $month . '-01'; @@ -151,7 +151,44 @@ class Monthlypay extends BaseController $data['datefordropdown'] = $current; $data['attendance'] = $this->monthlypay_model->monthlyAttendance($current); $data['emppay'] = $this->monthlypay_model->getEmpPayDetails($current, $string); - // dd($data); + $leavedate = $this->monthlypay_model->employeeLeaveDates($month . "-" . $year); + $employeeLeaveDate = []; + + if(!empty($leavedate)){ + foreach ($leavedate as $entry) { + $empId = $entry['emp_id']; + + list($stYear,$stMonth,$stDate) = explode('-', $entry['start_date']); + list($eYear,$eMonth,$eDate) = explode('-', $entry['end_date']); + + $start = (int)$stDate; + $end = (int)$eDate; + + if ((int)$stYear < (int)$year || ((int)$stYear == (int)$year && (int)$stMonth < (int)$month)) { + $start = 1; + } + // if ((int)$stMonth < (int)$month) $start = 1; // old if + + if ((int)$eYear > (int)$year || ((int)$eYear == (int)$year && (int)$eMonth > (int)$month)) { + $end = $monthdays; + } + // if ((int)$eMonth > (int)$month) $end = $monthdays; // old if + + if ($start > $monthdays) $start = 1; + + for ($i = $start; $i <= $end; $i++) { + $employeeLeaveDate[$empId][] = $i; + // $employeeLeaveDate[$empId][] = str_pad($i, 2, '0', STR_PAD_LEFT); + } + } + + if($employeeLeaveDate){ + array_walk($employeeLeaveDate, fn(&$dates) => $dates = array_unique($dates)); + } + } + + $data['employeeleavedate'] = $employeeLeaveDate; + // dd($data['employeeleavedate']); $this->global['pageTitle'] = 'Monthly Attendance'; $this->loadViews("attendance", $this->global, $data, NULL); } @@ -971,7 +1008,21 @@ class Monthlypay extends BaseController return $this->response->setJSON($data); } - + public function validateDateRange(){ + + $emp_id = $this->request->getPost('emp_id'); + $start_date = $this->request->getPost('start_date'); + $end_date = $this->request->getPost('end_date'); + $array = $this->monthlypay_model->validateDateRange($emp_id,$start_date,$end_date); + if (!empty($array) && count($array) > 0) { + $data = ['status' => true, 'message' => 'The selected date range overlaps with an existing approved leave.','details'=>$array]; + }else{ + $data = ['status' => false, 'message' => '','details'=>$array]; + } + + return $this->response->setJSON($data); + } + function deleteLeaveApplicationForm() { $leave_application_id = $this->request->getGet('leave_application_id') ? $this->request->getGet('leave_application_id') : ''; @@ -994,10 +1045,8 @@ class Monthlypay extends BaseController $data['leave_info'] = $this->monthlypay_model->getheringleaveApplicationForm($leave_application_id); - $data['company_info'] = $this->monthlypay_model->getCompanyInformation(); - - $html = view('leaveApplicationPDF', $data); - // echo $html;die; + $data['company_info'] = $this->monthlypay_model->getCompanyInformation(); + $html = view('leaveApplicationPDF', $data); // echo $html; $mpdf = new Mpdf(); $mpdf->WriteHTML($html); diff --git a/app/Controllers/Payslip.php b/app/Controllers/Payslip.php index 50d81424..5d09e9e2 100755 --- a/app/Controllers/Payslip.php +++ b/app/Controllers/Payslip.php @@ -178,6 +178,8 @@ class Payslip extends BaseController $data['fresh'] = $this->monthlypay_model->getEmpPayDetailsforMonthInputs($current); // dd($data['fresh']); $data['drivermonthinputs'] = $this->driverMonthlyPayInputs($current); + // $leavedate = $this->monthlypay_model->employeeLeaveDates($current); + $employeeSalary = []; $esi = []; $pf = []; @@ -302,8 +304,7 @@ class Payslip extends BaseController $data['esi'] = $esi; $data['pf'] = $pf; $data['over_time'] = $ot; - - + $this->global['pageTitle'] = 'Payroll Monthly Inputs'; $this->loadViews("monthlypayinputs", $this->global, $data, NULL); } diff --git a/app/Controllers/Purchaseorder.php b/app/Controllers/Purchaseorder.php index 0b69cc35..b81c8109 100755 --- a/app/Controllers/Purchaseorder.php +++ b/app/Controllers/Purchaseorder.php @@ -1113,6 +1113,7 @@ class Purchaseorder extends BaseController //This used to Create Revenue Purchase Order function addNewPurchaseOrder() { + helper('numberseries'); try { // Extract POST data @@ -1985,6 +1986,7 @@ class Purchaseorder extends BaseController function addNewImportPurchaseOrder() { + helper('numberseries'); try { $POdt = $this->request->getPost('PODate'); $PODate = get_date_time_format($POdt); @@ -2597,7 +2599,7 @@ class Purchaseorder extends BaseController } else { $store = array('Status' => $StatusCode, 'OnHoldOn' => $ApprovedDate, 'OnHoldBy' => $ApprovedBy, 'Remarks' => $Remarks); $this->purchaseorder_model->UpdatePO($store, $PONO); - echo "The Purchase Order No: " . $PONO . "is On Hold"; + echo "The Purchase Order No: " . $PONO . " is On Hold"; } } @@ -2670,7 +2672,7 @@ class Purchaseorder extends BaseController /* Add capital Po*/ function addNewCapitalPurchaseOrder() { - + helper('numberseries'); try { $POdt = $this->request->getPost('PODate'); $PODate = get_date_time_format($POdt); diff --git a/app/Controllers/Servicepurchaseorder.php b/app/Controllers/Servicepurchaseorder.php index 192e58b2..85305bf9 100755 --- a/app/Controllers/Servicepurchaseorder.php +++ b/app/Controllers/Servicepurchaseorder.php @@ -187,7 +187,7 @@ class Servicepurchaseorder extends BaseController //This used to Create Service Purchase Order function addNewServicePurchaseOrder() { - + helper('numberseries'); $POdt = $this->request->getPost('PODate'); $PODate = get_date_time_format($POdt); $SupplierID = $this->request->getPost('drpSupplier'); diff --git a/app/Controllers/User.php b/app/Controllers/User.php index 2cc02934..66466711 100755 --- a/app/Controllers/User.php +++ b/app/Controllers/User.php @@ -1020,7 +1020,7 @@ class User extends BaseController // Validation passed $EmpID = $this->request->getPost('EmpList'); - $roleId = '2'; + $roleId = !empty($this->request->getPost('role')) ? $this->request->getPost('role') : '2' ; $password = (string)$this->request->getPost('password'); $Createddt = date('Y-m-d H:i:s'); $email = $this->request->getPost('MailID'); diff --git a/app/Helpers/excel_helper.php b/app/Helpers/excel_helper.php new file mode 100755 index 00000000..c4ab8e73 --- /dev/null +++ b/app/Helpers/excel_helper.php @@ -0,0 +1,49 @@ +getActiveSheet()->setTitle('Sheet 1'); + + // Set headers into the spreadsheet + $spreadsheet->getActiveSheet()->fromArray([$headers], null, 'A1'); + + // Set data into the spreadsheet + $spreadsheet->getActiveSheet()->fromArray($data, null, 'A2'); + + + + // Create Excel writer + $writer = new Xlsx($spreadsheet); + + try { + // Save Excel file to the specified path + $writer->save($filename); + return true; // Return true if file was successfully saved + } catch (\Exception $e) { + // Log or handle the exception + return false; // Return false if there was an error saving the file + } + } +} diff --git a/app/Helpers/purchaseorder_helper.php b/app/Helpers/image_helper.php similarity index 97% rename from app/Helpers/purchaseorder_helper.php rename to app/Helpers/image_helper.php index 8946e7b5..5c021c36 100755 --- a/app/Helpers/purchaseorder_helper.php +++ b/app/Helpers/image_helper.php @@ -1,49 +1,4 @@ 1 ? strlen($numeric_part) : 2; - $new_decimal = str_pad($new_numeric_part, $new_decimal_length, '0', STR_PAD_LEFT); - - return $base . '.' . $new_decimal; - } else { - return $PoNo . '.01'; - } -} - if (!function_exists('invoice_logo_pdf')) { function invoice_logo_pdf() diff --git a/app/Helpers/numberseries_helper.php b/app/Helpers/numberseries_helper.php new file mode 100755 index 00000000..a9013bf7 --- /dev/null +++ b/app/Helpers/numberseries_helper.php @@ -0,0 +1,109 @@ + 1 ? strlen($numeric_part) : 2; + $new_decimal = str_pad($new_numeric_part, $new_decimal_length, '0', STR_PAD_LEFT); + + return $base . '.' . $new_decimal; + } else { + return $PoNo . '.01'; + } +} +?> \ No newline at end of file diff --git a/app/Models/Expense_model.php b/app/Models/Expense_model.php index 0de2d711..f5a3c2ad 100755 --- a/app/Models/Expense_model.php +++ b/app/Models/Expense_model.php @@ -12,7 +12,7 @@ class Expense_model extends Model 'serial_number' , 'transporter_file', 'supplier_id', 'remarks', 'item_description', 'cost', 'cgst', 'sgst', 'igst', 'total', 'bill_no' ,'bill_date','status','created_by','updated_by' ]; - public function getLastSerialNumber($financialYear) + public function getLastSerialNumber() { return $this->db->table('t_expense') ->select('serial_number') diff --git a/app/Models/GasShortageModel.php b/app/Models/GasShortageModel.php index 4b8f5be9..5e8f461f 100644 --- a/app/Models/GasShortageModel.php +++ b/app/Models/GasShortageModel.php @@ -6,15 +6,25 @@ use CodeIgniter\Model; class GasShortageModel extends Model { - protected $table = 't_gasShortageDetails'; + protected $table = 't_gasshortagedetails'; protected $primaryKey = 'id'; protected $useAutoIncrement = true; protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; protected $allowedFields = - ['fullCylinderDate','emptyCylinderDate','invoiceNo', - 'cylinderNo','grossWeight','tareWeight','netWeight','actualWeight','shortage' + ['id', + 'IGRNO', + 'fullCylinderDate', + 'emptyCylinderDate', + 'invoiceNo', + 'cylinderNo', + 'grossWeight', + 'tareWeight', + 'netWeight', + 'actualWeight', + 'shortage', + 'gas_cylinder_status' ]; protected bool $allowEmptyInserts = false; diff --git a/app/Models/Inwardgateregister_model.php b/app/Models/Inwardgateregister_model.php index e8c54b66..c162bb3a 100755 --- a/app/Models/Inwardgateregister_model.php +++ b/app/Models/Inwardgateregister_model.php @@ -6,7 +6,7 @@ use CodeIgniter\Model; class Inwardgateregister_model extends Model { - + function updatefile($bill, $Picture, $oldfile) { @@ -21,9 +21,10 @@ class Inwardgateregister_model extends Model $afftectedRows = $this->db->affectedRows(); return $afftectedRows; } - function getAdditionalIGRFile($igr){ + function getAdditionalIGRFile($igr) + { $builder = $this->db->table('t_inwardgateregister_fileupload')->select('*') - ->where('IGRNO', $igr); + ->where('IGRNO', $igr); $query = $builder->get(); return $query->getResult(); } @@ -40,12 +41,12 @@ class Inwardgateregister_model extends Model { $arr = array('Isactive' => 0); $this->db->table('t_inwardgateregister_fileupload') - ->where('BillNo', $fileid) - ->update($arr); + ->where('BillNo', $fileid) + ->update($arr); $aff = $this->db->affectedRows(); return $aff > 0 ? true : false; } - + /*------------------------------------------------------------*/ function addMaterialStockHistory($MaterialstockHistoryadd) @@ -86,7 +87,7 @@ class Inwardgateregister_model extends Model ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') ->join('t_inwardgateregister_fileupload fileup', ' igr.IGRNO = fileup.IGRNO', 'left') ->join('t_supplierdetailsn` sup', 'PO.SupplierID = sup.SupplierID') - ->orderBy('igr.IGRID','desc') + ->orderBy('igr.IGRID', 'desc') ->groupBy('igr.IGRNO', 'desc'); $query = $builder->get(); $result = $query->getResult(); @@ -136,10 +137,10 @@ class Inwardgateregister_model extends Model ->join('t_ogr_master OGM ', 'POM.PONO = OGM.PONO_INV', 'left') // ->where('POM.POType !=', SERVICE) // due to client requirements - he wants to remove the conidition. ->where('POM.Status', PO_RELEASED) - ->orWhere('POM.Status',REQITEM_Emergency_PO_CREATED) - ->orWhere('POM.Status',IGR_CREATED) - ->orWhere('POM.Status', IGR_DRAFT ) - ->where( 'POM.IsOpenOrder', 1) + ->orWhere('POM.Status', REQITEM_Emergency_PO_CREATED) + ->orWhere('POM.Status', IGR_CREATED) + ->orWhere('POM.Status', IGR_DRAFT) + ->where('POM.IsOpenOrder', 1) ->orWhere('POM.Status', MRIR_CREATED) ->orWhere('POM.Status', MRIR_APPROVED) ->orWhere('POM.Status', OGR_COMPLETE) @@ -169,25 +170,26 @@ class Inwardgateregister_model extends Model return $temp; } - public function checkdriverMobile($mobile,$driverName) { + public function checkdriverMobile($mobile, $driverName) + { $builder = $this->db->table('t_igr_master') ->distinct() ->select('DriverMobileNumber') ->like('DriverMobileNumber', $mobile); - if($driverName){ - $builder->where('DriverName', $driverName); - } - + if ($driverName) { + $builder->where('DriverName', $driverName); + } - $query = $builder->get(); - $temparr[] = ''; - foreach ($query->getResult() as $arr) { - $temparr[] = $arr->DriverMobileNumber; - } - // echo $this->db->getLastQuery()->getQuery();die; - $temp['suggestions'] = $temparr; - - return $temp; + + $query = $builder->get(); + $temparr[] = ''; + foreach ($query->getResult() as $arr) { + $temparr[] = $arr->DriverMobileNumber; + } + // echo $this->db->getLastQuery()->getQuery();die; + $temp['suggestions'] = $temparr; + + return $temp; } function viewpurchaseorder($PO) @@ -205,7 +207,7 @@ class Inwardgateregister_model extends Model $query = $this->db->query($subQuery, [$PO]); - + return $query->getResult(); /* @@ -219,48 +221,52 @@ class Inwardgateregister_model extends Model $result = $query->getResult(); return $result; */ } - - public function igr_history($hsty_arr) { - $keysToRemove = ["UpdateBY", "MaterialRcvdDate", "DeliveryChellanDate"]; + + public function igr_history($hsty_arr) + { + + $keysToRemove = ["UpdateBY", "UpdateBy", "MaterialRcvdDate", "DeliveryChellanDate"]; + foreach ($keysToRemove as $key) { if (isset($hsty_arr[$key])) { unset($hsty_arr[$key]); } } - + $builder = $this->db->table('t_igr_history'); $builder->insert($hsty_arr); - - return $this->db->insertID(); // Return last inserted ID + return $this->db->insertID(); } - function get_igr_history($col,$IGR,$IGRITEM = null) + function get_igr_history($col, $IGR, $IGRITEM = null) { $builder = $this->db->table('t_igr_history Hist') - ->select("Hist.*") - ->where('Hist.field', $col); + ->select("Hist.*") + ->where('Hist.field', $col); - if ($IGR) { - $builder->where('Hist.IGR_No', $IGR); - } + if ($IGR) { + $builder->where('Hist.IGR_No', $IGR); + } - if ($IGRITEM !== null) { - $builder->where('Hist.IGRItem_No', $IGRITEM); - } + if ($IGRITEM !== null) { + $builder->where('Hist.IGRItem_No', $IGRITEM); + } - $builder->orderBy('Hist.history_dated', 'DESC'); - $builder->limit(1); - $query = $builder->get(); - $result = $query->getRow(); - return $result; + $builder->orderBy('Hist.history_dated', 'DESC'); + $builder->limit(1); + $query = $builder->get(); + $result = $query->getRow(); + return $result; } - function get_igr_master_for_history($igr_no) { + function get_igr_master_for_history($igr_no) + { return $this->db->table('t_igr_master Master')->where('Master.IGRNO', $igr_no)->get()->getRow(); } - - function get_igr_child_for_history($igr_no, $igr_item_no) { + + function get_igr_child_for_history($igr_no, $igr_item_no) + { $builder = $this->db->table('t_igr_details Child'); // Select only the required field if ($igr_no) { $builder->where('Child.IGRNO', $igr_no); @@ -273,6 +279,13 @@ class Inwardgateregister_model extends Model return $result; // Return the field value directly } + function lastIGRNO() + { + $query = $this->db->table('t_igr_master')->select('IGRNO')->orderBy('IGRID', 'DESC')->limit(1)->get(); + $lastIGRNO = $query->getRow()->IGRNO; + return $lastIGRNO; + } + function addigrM($igrM) { // print_r($igrM);die; @@ -285,34 +298,34 @@ class Inwardgateregister_model extends Model $result = []; if ($YesIAmAffected > 0) { $result = $this->db->table('t_igr_master') - ->select('IGRNO') - ->orderBy('CreatedDate', 'desc') - ->get() - ->getRow(); + ->select('IGRNO') + ->orderBy('CreatedDate', 'desc') + ->get() + ->getRow(); // $result->IGRNO; } $igrno = ($YesIAmAffected && !empty($result)) ? $result->IGRNO : ''; - return $igrno; - } + return $igrno; + } function addigrD($igrD) { $this->db->transStart(); - $builder = $this->db->table('t_igr_details'); + $builder = $this->db->table('t_igr_details'); $builder->insert($igrD); - $aff_row = $this->db->affectedRows(); - log_message('error', 'addigrD Query: ' . $this->db->getLastQuery()->getQuery()); - $this->db->transComplete(); - + $aff_row = $this->db->affectedRows(); + log_message('error', 'addigrD Query: ' . $this->db->getLastQuery()->getQuery()); + $this->db->transComplete(); + $result = $this->db->table('t_igr_details') - ->select('IGRItemNo') - ->orderBy('CreatedDate', 'desc') - ->get() - ->getRow(); + ->select('IGRItemNo') + ->orderBy('CreatedDate', 'desc') + ->get() + ->getRow(); $res = ($aff_row > 0) ? $result->IGRItemNo : 0; - return $res; + return $res; } @@ -363,40 +376,40 @@ class Inwardgateregister_model extends Model return $result; } function ViewigrListing_old() - { + { - // $builder = $this->db->table('t_igr_master igr') - // ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName') - // ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') - // ->join('t_supplierdetailsn` sup', 'PO.SupplierID = sup.SupplierID') + // $builder = $this->db->table('t_igr_master igr') + // ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName') + // ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') + // ->join('t_supplierdetailsn` sup', 'PO.SupplierID = sup.SupplierID') // ->join('t_transporter` trans', 'igr.TransporterId = trans.id' , 'left') - // ->where('igr.IGRStatus !=', MRIR_CREATED) + // ->where('igr.IGRStatus !=', MRIR_CREATED) // ->orderBy('igr.CreatedDate', 'desc'); $builder = $this->db->table('t_igr_details igr_details') - ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName,item.MaterialName, igr_details.QuantityAsPerInvoice as ReceivedQuantity , igr_details.NetWeight as NetWeight') + ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName,item.MaterialName, igr_details.QuantityAsPerInvoice as ReceivedQuantity , igr_details.NetWeight as NetWeight') ->join('t_igr_master igr', 'igr_details.IGRNo = igr.IGRNo') - ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') - ->join('t_supplierdetailsn` sup', 'PO.SupplierID = sup.SupplierID') - ->join('t_transporter` trans', 'igr.TransporterId = trans.id' , 'left') - ->join('t_materialmaster` item', 'igr_details.MaterialCode = item.MaterialCode' , 'left') - ->where('igr.IGRStatus !=', MRIR_CREATED) + ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') + ->join('t_supplierdetailsn` sup', 'PO.SupplierID = sup.SupplierID') + ->join('t_transporter` trans', 'igr.TransporterId = trans.id', 'left') + ->join('t_materialmaster` item', 'igr_details.MaterialCode = item.MaterialCode', 'left') + ->where('igr.IGRStatus !=', MRIR_CREATED) ->orderBy('igr.CreatedDate', 'desc'); - $query = $builder->get(); - $result = $query->getResult(); + $query = $builder->get(); + $result = $query->getResult(); + - // echo $this->db->getLastQuery()->getQuery();die; - return $result; - } + return $result; + } - function ViewigrListing($fromDate,$toDate) - { + function ViewigrListing($fromDate, $toDate) + { $subQuery1 = $this->db->table('t_igr_remarkes') - ->select('COUNT(id)') - ->where('igr_no = igr.IGRNo') - ->getCompiledSelect(); + ->select('COUNT(id)') + ->where('igr_no = igr.IGRNo') + ->getCompiledSelect(); // Build subQuery2 dynamically for rate and tax based on POType $subQuery2 = "(CASE @@ -445,31 +458,30 @@ class Inwardgateregister_model extends Model ->join('t_igr_details IGRD', 'igr.IGRNo = IGRD.IGRNo') ->where('igr.IGRStatus !=', MRIR_CREATED) ->groupBy('IGRD.IGRNo'); - if(session()->get('roleText') == 'Auditor'){ + if (session()->get('roleText') == 'Auditor') { - $builder->where('Date(igr.DeliveryChellanDate) >=', "$fromDate") - ->where('Date(igr.DeliveryChellanDate) <=', "$toDate") - ->orderBy('igr.DeliveryChellanDate', 'desc'); - }else{ - $builder->where('Date(igr.CreatedDate) >=', "$fromDate") - ->where('Date(igr.CreatedDate) <=', "$toDate") - ->orderBy('igr.CreatedDate', 'desc'); + $builder->where('Date(igr.DeliveryChellanDate) >=', "$fromDate") + ->where('Date(igr.DeliveryChellanDate) <=', "$toDate") + ->orderBy('igr.DeliveryChellanDate', 'desc'); + } else { + $builder->where('Date(igr.CreatedDate) >=', "$fromDate") + ->where('Date(igr.CreatedDate) <=', "$toDate") + ->orderBy('igr.CreatedDate', 'desc'); + } - } - - - - $query = $builder->get(); + + + $query = $builder->get(); $result = $query->getResult(); - // echo $this->db->getLastQuery()->getQuery();die; - // dd($result); + // echo $this->db->getLastQuery()->getQuery();die; + // dd($result); - // old - issue in t_igr_remarkes join + // old - issue in t_igr_remarkes join // $builder = $this->db->table('t_igr_master igr') // ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName , SUM(IGRD.QuantityAsPerInvoice) as ReceivedQuantity, SUM(IGRD.NetWeight) as NetWeight , count(IGRD.IGRNo) as itemCount , count(remark.id) as remark_count') // ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') @@ -490,59 +502,59 @@ class Inwardgateregister_model extends Model // $builder2 = $this->db->table('t_igr_details igr_details') - // ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName,item.MaterialName, igr_details.QuantityAsPerInvoice as ReceivedQuantity , igr_details.NetWeight as NetWeight') + // ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName,item.MaterialName, igr_details.QuantityAsPerInvoice as ReceivedQuantity , igr_details.NetWeight as NetWeight') // ->join('t_igr_master igr', 'igr_details.IGRNo = igr.IGRNo') - // ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') - // ->join('t_supplierdetailsn sup', 'PO.SupplierID = sup.SupplierID') + // ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') + // ->join('t_supplierdetailsn sup', 'PO.SupplierID = sup.SupplierID') // ->join('t_transporter trans', 'igr.TransporterId = trans.id' , 'left') // ->join('t_materialmaster` item', 'igr_details.MaterialCode = item.MaterialCode' , 'left') - // ->where('igr.IGRStatus !=', MRIR_CREATED) + // ->where('igr.IGRStatus !=', MRIR_CREATED) // ->orderBy('igr.CreatedDate', 'desc'); // $query2 = $builder2->get(); // $result2 = $query2->getResult(); // echo $this->db->getLastQuery()->getQuery();die; - return [$result,[]]; - } + return [$result, []]; + } - function customViewigrListing($fromDate,$toDate) - { + function customViewigrListing($fromDate, $toDate) + { - $builder = $this->db->table('t_igr_master igr') - ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName , SUM(IGRD.QuantityAsPerInvoice) as ReceivedQuantity, SUM(IGRD.NetWeight) as NetWeight , count(IGRD.IGRNo) as itemCount') - ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') - ->join('t_supplierdetailsn sup', 'PO.SupplierID = sup.SupplierID') - ->join('t_transporter trans', 'igr.TransporterId = trans.id' , 'left') + $builder = $this->db->table('t_igr_master igr') + ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName , SUM(IGRD.QuantityAsPerInvoice) as ReceivedQuantity, SUM(IGRD.NetWeight) as NetWeight , count(IGRD.IGRNo) as itemCount') + ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') + ->join('t_supplierdetailsn sup', 'PO.SupplierID = sup.SupplierID') + ->join('t_transporter trans', 'igr.TransporterId = trans.id', 'left') ->join('t_igr_details IGRD', 'igr.IGRNo = IGRD.IGRNo') - ->where('igr.IGRStatus !=', MRIR_CREATED) + ->where('igr.IGRStatus !=', MRIR_CREATED) ->groupStart() ->where('Date(igr.CreatedDate) >=', $fromDate) ->orWhere('Date(igr.UpdatedOn) >=', $fromDate) ->groupEnd() ->groupStart() - ->where('Date(igr.CreatedDate) <=', $toDate) - ->orWhere('Date(igr.UpdatedOn) <=', $toDate) + ->where('Date(igr.CreatedDate) <=', $toDate) + ->orWhere('Date(igr.UpdatedOn) <=', $toDate) ->groupEnd() ->groupBy('igr.IGRNo') - ->orderBy('igr.CreatedDate', 'desc'); - $query = $builder->get(); - $result = $query->getResult(); + ->orderBy('igr.CreatedDate', 'desc'); + $query = $builder->get(); + $result = $query->getResult(); $builder2 = $this->db->table('t_igr_details igr_details') - ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName,item.MaterialName, igr_details.QuantityAsPerInvoice as ReceivedQuantity , igr_details.NetWeight as NetWeight') + ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName,item.MaterialName, igr_details.QuantityAsPerInvoice as ReceivedQuantity , igr_details.NetWeight as NetWeight') ->join('t_igr_master igr', 'igr_details.IGRNo = igr.IGRNo') - ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') - ->join('t_supplierdetailsn sup', 'PO.SupplierID = sup.SupplierID') - ->join('t_transporter trans', 'igr.TransporterId = trans.id' , 'left') - ->join('t_materialmaster` item', 'igr_details.MaterialCode = item.MaterialCode' , 'left') - ->where('igr.IGRStatus !=', MRIR_CREATED) + ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') + ->join('t_supplierdetailsn sup', 'PO.SupplierID = sup.SupplierID') + ->join('t_transporter trans', 'igr.TransporterId = trans.id', 'left') + ->join('t_materialmaster` item', 'igr_details.MaterialCode = item.MaterialCode', 'left') + ->where('igr.IGRStatus !=', MRIR_CREATED) ->orderBy('igr.CreatedDate', 'desc'); - $query2 = $builder2->get(); - $result2 = $query2->getResult(); + $query2 = $builder2->get(); + $result2 = $query2->getResult(); // echo $this->db->getLastQuery()->getQuery();die; - return [$result,$result2]; - } - + return [$result, $result2]; + } + function viewigr($IGRNO) @@ -551,7 +563,7 @@ class Inwardgateregister_model extends Model // ->select('igrd.IGRItemNo','igrd.IGRNO','igrd.MaterialCode','igrd.QuantityAsPerInvoice') // ->select('igrd.Remarks','igrd.IGRItemStatus','igrd.CancelNote','igrd.BankStatus') // ->select('MM.MaterialName,MM.UOM,sup.Address,sup.SupplierName,POM.ServiceDescription,POL.Quantity,POM.POType') - + $builder = $this->db->table('t_igr_master igr') ->distinct() ->select(" @@ -571,10 +583,10 @@ class Inwardgateregister_model extends Model ->join('t_purchaseorder_lineitem POL', 'igr.PONO = POL.PONO and POL.MaterialCode=igrd.MaterialCode ') ->join('t_supplierdetailsn sup', 'sup.SupplierID = POM.SupplierID') ->join('t_materialmaster MM', 'MM.MaterialCode = igrd.MaterialCode') - ->join('t_service_tax st', 'st.LineItemNo = POL.LineItemNo' , 'left') - ->join('t_revenue_tax rt', 'rt.LineItemNo = POL.LineItemNo' , 'left') - ->join('t_import_tax it', 'it.LineItemNo = POL.LineItemNo' , 'left') - ->join('t_configdetails cd','cd.key = MM.Category','left') + ->join('t_service_tax st', 'st.LineItemNo = POL.LineItemNo', 'left') + ->join('t_revenue_tax rt', 'rt.LineItemNo = POL.LineItemNo', 'left') + ->join('t_import_tax it', 'it.LineItemNo = POL.LineItemNo', 'left') + ->join('t_configdetails cd', 'cd.key = MM.Category', 'left') ->where('igr.IGRNO', $IGRNO); $query = $builder->get(); @@ -629,7 +641,7 @@ class Inwardgateregister_model extends Model } } - function UpdatePOMaster($PONO, $updatedBy,$IGRStatus) + function UpdatePOMaster($PONO, $updatedBy, $IGRStatus) { $builder = $this->db->table('t_purchaseorder_lineitem')->select('*') @@ -961,16 +973,16 @@ class Inwardgateregister_model extends Model // $query = $this->db->query($subQuery); // return $query->getResult(); $result = $this->db->table('t_ogr_master') - ->select('OGRNO') - ->orderBy('CreatedOn', 'desc') - ->get() - ->getRow(); + ->select('OGRNO') + ->orderBy('CreatedOn', 'desc') + ->get() + ->getRow(); $OGRNO = ($aff_row && $result !== null) ? $result->OGRNO : 0; - return $OGRNO; + return $OGRNO; } } - + @@ -1065,7 +1077,8 @@ class Inwardgateregister_model extends Model $r = $this->db->affectedRows(); return $r; } - function updateIGRLineItem($igrlineitemarr, $IGRitemNo){ + function updateIGRLineItem($igrlineitemarr, $IGRitemNo) + { $this->db->table('t_igr_details') ->where('IGRItemNo', $IGRitemNo) ->update($igrlineitemarr); @@ -1104,133 +1117,144 @@ class Inwardgateregister_model extends Model } public function ViewIGRHistory($igr) - { - $builder = $this->db->table('t_igr_history'); - - $builder->select('t_igr_history.*, DATE_FORMAT(t_igr_history.history_dated, "%d-%m-%Y") AS indian_date, DATE_FORMAT(t_igr_history.history_dated, "%h:%i:%s %p") AS indian_time, CONCAT_WS(" ", t_employee_details.FirstName, t_employee_details.LastName) AS FullName,t_materialmaster.MaterialName,t_materialmaster.MaterialName,t_materialmaster.MaterialCode'); - $builder->join('tbl_users', 'tbl_users.userId = t_igr_history.by', 'left'); - $builder->join('t_employee_details', 'tbl_users.EmpID = t_employee_details.EmpID', 'left'); + { + $builder = $this->db->table('t_igr_history'); + + $builder->select('t_igr_history.*, DATE_FORMAT(t_igr_history.history_dated, "%d-%m-%Y") AS indian_date, DATE_FORMAT(t_igr_history.history_dated, "%h:%i:%s %p") AS indian_time, CONCAT_WS(" ", t_employee_details.FirstName, t_employee_details.LastName) AS FullName,t_materialmaster.MaterialName,t_materialmaster.MaterialName,t_materialmaster.MaterialCode'); + $builder->join('tbl_users', 'tbl_users.userId = t_igr_history.by', 'left'); + $builder->join('t_employee_details', 'tbl_users.EmpID = t_employee_details.EmpID', 'left'); $builder->join('t_igr_details', 'CONVERT(t_igr_history.IGRItem_No USING utf8) = CONVERT(t_igr_details.IGRItemNo USING utf8)', 'left'); $builder->join('t_materialmaster', 'CONVERT(t_materialmaster.MaterialCode USING utf8) = CONVERT(t_igr_details.MaterialCode USING utf8)', 'left'); $builder->where('CONVERT(IGR_No USING utf8)', $igr); - $builder->orderBy('t_igr_history.history_dated', 'asc'); - // $builder->where('IGR_No', $igr); + $builder->orderBy('t_igr_history.history_dated', 'asc'); + // $builder->where('IGR_No', $igr); - $query = $builder->get(); - $result = $query->getResult(); + $query = $builder->get(); + $result = $query->getResult(); return $result; - - } + } public function isFileExistsInIGRmaster($filename) - { + { $result = $this->db->table('t_igr_master')->where('MasterFile', $filename); $query = $result->get(); return $query->getResult(); - } + } public function isFileExistsInIGRdetails($filename) - { + { $result = $this->db->table('t_igr_details')->where('WeightFile', $filename); $query = $result->get(); return $query->getResult(); - } + } public function getCostCenterData($pono) - { - $builder = $this->db->table('t_purchaseorder_lineitem'); - - $builder->select('t_purchaseorder_lineitem.ReqNo,reqMaster.CostCenterCode,CSMaster.CostCenterName'); + { + $builder = $this->db->table('t_purchaseorder_lineitem'); + + $builder->select('t_purchaseorder_lineitem.ReqNo,reqMaster.CostCenterCode,CSMaster.CostCenterName'); $builder->join('t_requestion_master reqMaster', 't_purchaseorder_lineitem.ReqNo = reqMaster.ReqNo', 'left'); $builder->join('t_costcenter_master CSMaster', 'reqMaster.CostCenterCode = CSMaster.CostCenterCode', 'left'); - $builder->where('PONO', $pono); + $builder->where('PONO', $pono); $builder->groupBy('t_purchaseorder_lineitem.ReqNo'); - $query = $builder->get(); - $result = $query->getResult(); + $query = $builder->get(); + $result = $query->getResult(); return $result; - - - } + } public function getAllIgrFileDetails($igrno) - { - - // Query 1: Get FilePath and Remarks from t_inwardgateregister_fileupload + { + + // Query 1: Get FilePath and Remarks from t_inwardgateregister_fileupload $builder1 = $this->db->table('t_inwardgateregister_fileupload IFU'); - $query1 = $builder1->select('IFU.FilePath as file, IFU.Remarks as filename') - ->where('IFU.IGRNO', $igrno) - ->where('IFU.Isactive', 1) - ->get(); - $result1 = $query1->getResult(); + $query1 = $builder1->select('IFU.FilePath as file, IFU.Remarks as filename') + ->where('IFU.IGRNO', $igrno) + ->where('IFU.Isactive', 1) + ->get(); + $result1 = $query1->getResult(); - // Query 2: Get MasterFile from t_igr_master - $builder2 = $this->db->table('t_igr_master IM'); - $query2 = $builder2->select('IM.MasterFile as file, IM.MasterFile as filename') - ->where('IM.IGRNO', $igrno) - ->where('IM.MasterFile IS NOT NULL') - ->get(); - $result2 = $query2->getResult(); + // Query 2: Get MasterFile from t_igr_master + $builder2 = $this->db->table('t_igr_master IM'); + $query2 = $builder2->select('IM.MasterFile as file, IM.MasterFile as filename') + ->where('IM.IGRNO', $igrno) + ->where('IM.MasterFile IS NOT NULL') + ->get(); + $result2 = $query2->getResult(); - // Query 3: Get WeightFile from t_igr_details - $builder3 = $this->db->table('t_igr_details ID'); - $query3 = $builder3->select('ID.WeightFile as file, ID.WeightFile as filename') - ->where('ID.IGRNO', $igrno) - ->where('ID.WeightFile IS NOT NULL') - ->get(); - $result3 = $query3->getResult(); + // Query 3: Get WeightFile from t_igr_details + $builder3 = $this->db->table('t_igr_details ID'); + $query3 = $builder3->select('ID.WeightFile as file, ID.WeightFile as filename') + ->where('ID.IGRNO', $igrno) + ->where('ID.WeightFile IS NOT NULL') + ->get(); + $result3 = $query3->getResult(); - // Merging results into a single array - $results = array_merge($result1, $result2, $result3); + // Merging results into a single array + $results = array_merge($result1, $result2, $result3); - return $results; - } + return $results; + } public function transporter() - { + { $builder = $this->db->table('t_transporter t'); - $query = $builder->select('t.*')->get(); - $result = $query->getResult(); + $query = $builder->select('t.*')->get(); + $result = $query->getResult(); return $result; } - public function findIgrDetailsForIncomingSilicaSand($materialCodes, $month ,$remark) - { - $builder = $this->db->table('t_igr_details') - ->select( - 't_igr_details.IGRNO, - t_igr_details.MaterialCode, - igrMast.DeliveryChellanOrInvoiceNo as invoiceNo, - igrMast.DeliveryChellanDate as invoiceDate, - igrMast.MaterialRcvdDate as materialRecievedDate, - igrMast.VehicleNo, - supplierDetails.SupplierName, - cd.ConfigValue as sandType , - t_igr_details.QuantityAsPerInvoice as Qty, - issd.*') - ->whereIn('t_igr_details.MaterialCode', $materialCodes) - ->where('t_igr_details.QuantityAsPerInvoice <>', 0) - ->like('t_igr_details.CreatedDate', $month, 'after'); - - // remark needed for those who selected any remark. - if ($remark != "noRemark") { - $builder->where('issd.remark', $remark); - } - - $builder->groupBy('t_igr_details.IGRNO, t_igr_details.MaterialCode') - ->join('t_igr_master igrMast', 'igrMast.IGRNO = t_igr_details.IGRNO') - ->join('t_incomingsilicasanddetails issd','issd.igrNo_fk = t_igr_details.IGRNO AND issd.materialCode = t_igr_details.MaterialCode','left') - ->join('t_materialmaster materialMaster', 'materialMaster.MaterialCode = t_igr_details.MaterialCode') - ->join('t_configdetails cd','cd.key = materialMaster.Category','left') - ->join('t_purchaseorder_master poMaster', 'poMaster.PONO = igrMast.PONO', 'left') - ->join('t_supplierdetailsn supplierDetails', 'supplierDetails.SupplierID = poMaster.SupplierID', 'left') - ->orderBy('t_igr_details.CreatedDate', 'asc '); + public function findIgrDetailsForIncomingSilicaSand($materialCodes, $month, $remark) + { - $query = $builder->get(); - $result = $query->getResultArray(); - - return $result; + $month = new \DateTime($month . "-01"); // Create DateTime for the first day of the month + + + $builder = $this->db->table('t_igr_details'); + + + $builder->select( + 't_igr_details.IGRNO, + t_igr_details.MaterialCode, + igrMast.DeliveryChellanOrInvoiceNo as invoiceNo, + igrMast.DeliveryChellanDate as invoiceDate, + igrMast.MaterialRcvdDate as materialRecievedDate, + igrMast.VehicleNo, + supplierDetails.SupplierName, + cd.ConfigValue as sandType, + t_igr_details.QuantityAsPerInvoice as Qty, + issd.*' + ); + + + $builder->join('t_igr_master igrMast', 'igrMast.IGRNO = t_igr_details.IGRNO'); + $builder->join('t_incomingsilicasanddetails issd', 'issd.igrNo_fk = t_igr_details.IGRNO AND issd.materialCode = t_igr_details.MaterialCode', 'left'); + $builder->join('t_materialmaster materialMaster', 'materialMaster.MaterialCode = t_igr_details.MaterialCode'); + $builder->join('t_configdetails cd', 'cd.key = materialMaster.Category', 'left'); + $builder->join('t_purchaseorder_master poMaster', 'poMaster.PONO = igrMast.PONO', 'left'); + $builder->join('t_supplierdetailsn supplierDetails', 'supplierDetails.SupplierID = poMaster.SupplierID', 'left'); + + $builder->where('Date(t_igr_details.CreatedDate) >=', $month->format('Y-m-01 00:00:00')); + $builder->where('Date(t_igr_details.CreatedDate) <=', $month->format('Y-m-t 23:59:59')); + $builder->whereIn('t_igr_details.MaterialCode', $materialCodes); + $builder->where('t_igr_details.QuantityAsPerInvoice <>', 0); + + // Conditional WHERE clause for remark + if ($remark != "noRemark") { + $builder->where('issd.remark', $remark); + } + + + $builder->groupBy('t_igr_details.IGRNO, t_igr_details.MaterialCode'); + + $builder->orderBy('t_igr_details.CreatedDate', 'asc '); + + $query = $builder->get(); + + return $query->getResultArray(); + } - public function getHistoryDetailsforEmail($igr){ - $date = date('Y-m-d H:i:s'); + public function getHistoryDetailsforEmail($igr) + { + $date = date('Y-m-d H:i:s'); $to = date('Y-m-d H:i:s', strtotime($date . ' +30 seconds')); $from = date('Y-m-d H:i:s', strtotime($date . ' -30 seconds')); @@ -1239,13 +1263,13 @@ class Inwardgateregister_model extends Model from t_igr_history LEFT JOIN tbl_users ON tbl_users.userId = t_igr_history.by LEFT JOIN t_employee_details ON tbl_users.EmpID = t_employee_details.EmpID - where is_add = 1 and IGR_No = '".$igr."'"); - $first_line = $query3->getRow(); - - // 392 po + where is_add = 1 and IGR_No = '" . $igr . "'"); + $first_line = $query3->getRow(); -$builder = $this->db->table('t_igr_history') - ->select(' + // 392 po + + $builder = $this->db->table('t_igr_history') + ->select(' t_igr_history.id, t_igr_history.field, t_igr_history.is_add, @@ -1280,97 +1304,215 @@ $builder = $this->db->table('t_igr_history') END AS old_data, t_igr_history.old_data as original_old_data,t_materialmaster.MaterialName,t_materialmaster.MaterialCode ') - // ->join('t_igr_details IGRD', 'IGRD.IGRItemNo = t_igr_history.IGRItem_No','left') - // ->join('t_materialmaster MM','MM.MaterialCode = IGRD.MaterialCode','left') - ->join('tbl_users', 'tbl_users.userId = t_igr_history.by','left') - ->join('t_employee_details','tbl_users.EmpID = t_employee_details.EmpID','left') - ->join('t_igr_details', 'CONVERT(t_igr_history.IGRItem_No USING utf8) = CONVERT(t_igr_details.IGRItemNo USING utf8)', 'left') - ->join('t_materialmaster', 'CONVERT(t_materialmaster.MaterialCode USING utf8) = CONVERT(t_igr_details.MaterialCode USING utf8)', 'left') - ->where('CONVERT(t_igr_history.IGR_No USING utf8)', $igr) - ->where('t_igr_history.is_edit', 1) - ->where('t_igr_history.history_dated BETWEEN "'.$from.'" AND "'.$to.'"'); + // ->join('t_igr_details IGRD', 'IGRD.IGRItemNo = t_igr_history.IGRItem_No','left') + // ->join('t_materialmaster MM','MM.MaterialCode = IGRD.MaterialCode','left') + ->join('tbl_users', 'tbl_users.userId = t_igr_history.by', 'left') + ->join('t_employee_details', 'tbl_users.EmpID = t_employee_details.EmpID', 'left') + ->join('t_igr_details', 'CONVERT(t_igr_history.IGRItem_No USING utf8) = CONVERT(t_igr_details.IGRItemNo USING utf8)', 'left') + ->join('t_materialmaster', 'CONVERT(t_materialmaster.MaterialCode USING utf8) = CONVERT(t_igr_details.MaterialCode USING utf8)', 'left') + ->where('CONVERT(t_igr_history.IGR_No USING utf8)', $igr) + ->where('t_igr_history.is_edit', 1) + ->where('t_igr_history.history_dated BETWEEN "' . $from . '" AND "' . $to . '"'); - $query = $builder->get(); - $result = $query->getResult(); + $query = $builder->get(); + $result = $query->getResult(); // echo $this->db->getLastQuery()->getQuery(); die; return [ 'history' => $result, - 'first_line' => $first_line ? $first_line->IGR_No ." was Created by ". $first_line->history_by ." on ". $first_line->indian_date ." at ". $first_line->indian_time : null, - ]; + 'first_line' => $first_line ? $first_line->IGR_No . " was Created by " . $first_line->history_by . " on " . $first_line->indian_date . " at " . $first_line->indian_time : null, + ]; } - public function getDetailsforEmail($userId,$roleId) - { + public function getDetailsforEmail($userId, $roleId) + { $query0 = $this->db->query(" SELECT CompanyName,EmailAddress FROM t_company_details"); - $company = $query0->getRow(); + $company = $query0->getRow(); - $query1 = $this->db->query(" + $query1 = $this->db->query( + " SELECT CONCAT_WS(' ', t_employee_details.FirstName, t_employee_details.LastName) AS FullName FROM tbl_users LEFT JOIN t_employee_details ON tbl_users.EmpID = t_employee_details.EmpID - WHERE tbl_users.userId = ?", [$userId] - ); - $fullName = $query1->getRow(); - - $query2 = $this->db->query(" - SELECT email FROM tbl_users - WHERE isDeleted = 0 AND roleId =".$roleId // hardcoded because auditor role only. refer with gwm 29/01/2025 - ); - $emails = $query2->getResult(); + WHERE tbl_users.userId = ?", + [$userId] + ); + $fullName = $query1->getRow(); - return [ - 'from_mail' => $company ? $company->EmailAddress : null, - 'full_name' => $fullName ? $fullName->FullName : null, + $query2 = $this->db->query( + " + SELECT email FROM tbl_users + WHERE isDeleted = 0 AND roleId =" . $roleId + ); + $to_mails = $query2->getResult(); + + $query3 = $this->db->query( + " + SELECT email FROM tbl_users + WHERE isDeleted = 0 AND userId =" . $userId + ); + $from_mails = $query3->getRow(); + + return [ 'company' => $company ? $company->CompanyName : null, - 'emails' => $emails - ]; - } + 'company_mail' => $company ? $company->EmailAddress : null, + 'full_name' => $fullName ? $fullName->FullName : null, + 'from_mails' => $from_mails ? $from_mails->email : null, + 'to_mails' => $to_mails, + ]; + } public function getdriverlist() - { + { - $query = $this->db->query('SELECT DriverName,DriverMobileNumber + $query = $this->db->query('SELECT DriverName,DriverMobileNumber FROM t_igr_master WHERE DriverName != "" GROUP BY DriverName,DriverMobileNumber'); - $result = $query->getResultArray(); - return $result; + $result = $query->getResultArray(); + return $result; } - public function getigrstatus($IGRNo){ + public function getigrstatus($IGRNo) + { $builder = $this->db->table('t_igr_master') - ->select('IGRStatus') - ->where('IGRNO',$IGRNo) - ->get(); - $result = $builder->getRow(); - return $result; + ->select('IGRStatus') + ->where('IGRNO', $IGRNo) + ->get(); + $result = $builder->getRow(); + return $result; } - public function get_status($value){ + public function get_status($value) + { $builder = $this->db->table('t_status') - ->select('StatusCode,StatusName') - ->where('StatusCode', $value); + ->select('StatusCode,StatusName') + ->where('StatusCode', $value); - $query = $builder->get()->getRow(); + $query = $builder->get()->getRow(); - $StatusName = $query ? $query->StatusName : null; - return $StatusName; + $StatusName = $query ? $query->StatusName : null; + return $StatusName; } - public function get_TransporterId($value){ + public function get_TransporterId($value) + { $builder = $this->db->table('t_transporter') - ->select('id,name') - ->where('id', $value); + ->select('id,name') + ->where('id', $value); - $query = $builder->get()->getRow(); + $query = $builder->get()->getRow(); - $transportername = $query ? $query->name : null; - return $transportername; + $transportername = $query ? $query->name : null; + return $transportername; } - -} \ No newline at end of file + //Mcat -materialCategory + public function getIgrDetailsListByMcatGas($gasMaterialCodes, $gas_status) + { + + + + + switch ($gas_status) { + + + case "gas_entered": + + $builder = $this->db->table('t_igr_details as t_igrd') + ->select(" + t_igrd.IGRNO as IGRNO-, + (t_igrd.QuantityAsPerInvoice) as gasCylinderCount, + t_sd.SupplierName, + t_igrm.*, + t_mm.MaterialName, + t_gsd.* + ") + ->join('t_igr_master t_igrm', 't_igrm.IGRNO = t_igrd.IGRNO') + ->join('t_purchaseorder_master t_pom', 't_igrm.PONO = t_pom.PONO', 'left') + ->join('t_supplierdetailsn t_sd', 't_sd.SupplierID = t_pom.SupplierID') + + ->join('t_gasshortagedetails t_gsd', 't_gsd.IGRNO = t_igrm.IGRNO', 'left') + + ->join('t_materialmaster t_mm', 't_mm.MaterialCode = t_igrd.MaterialCode', 'left') + ->whereIn('t_igrd.MaterialCode', $gasMaterialCodes) + ->where("DATE(t_igrd.CreatedDate) >= '2025-04-01' ") + + ->where('t_gsd.gas_cylinder_status IS NULL'); + + break; + + + case "gas_pending": + + $builder = $this->db->table('t_igr_details as t_igrd') + ->select(" + t_igrd.IGRNO as IGRNO-, + (t_igrd.QuantityAsPerInvoice) as gasCylinderCount, + t_sd.SupplierName, + t_igrm.*, + t_mm.MaterialName, + t_gsd.* + ") + ->join('t_igr_master t_igrm', 't_igrm.IGRNO = t_igrd.IGRNO') + ->join('t_purchaseorder_master t_pom', 't_igrm.PONO = t_pom.PONO', 'left') + ->join('t_supplierdetailsn t_sd', 't_sd.SupplierID = t_pom.SupplierID') + + ->join('t_gasshortagedetails t_gsd', 't_gsd.IGRNO = t_igrm.IGRNO', 'left') + + ->join('t_materialmaster t_mm', 't_mm.MaterialCode = t_igrd.MaterialCode', 'left') + ->whereIn('t_igrd.MaterialCode', $gasMaterialCodes) + ->where("DATE(t_igrd.CreatedDate) >= '2025-04-01' ") + + ->where('t_gsd.gas_cylinder_status', 'gas_pending'); + + break; + + + + case "gas_returned": + + $builder = $this->db->table('t_igr_details as t_igrd') + ->select(" + t_igrd.IGRNO as IGRNO-, + (t_igrd.QuantityAsPerInvoice) as gasCylinderCount, + t_sd.SupplierName, + t_igrm.*, + t_mm.MaterialName, + t_gsd.*, + SUM(t_gsd.grossWeight) as grossWeight, + SUM(t_gsd.tareWeight) as tareWeight, + SUM(t_gsd.netWeight) as netWeight, + SUM(t_gsd.actualWeight) as actualWeight, + SUM(t_gsd.shortage) as shortage, + Count(t_gsd.gas_cylinder_status) as gasCylinderCompletedCount, + (t_igrd.QuantityAsPerInvoice - Count(t_gsd.gas_cylinder_status)) as gasCylinderPendingCount + ") + ->join('t_igr_master t_igrm', 't_igrm.IGRNO = t_igrd.IGRNO') + ->join('t_purchaseorder_master t_pom', 't_igrm.PONO = t_pom.PONO', 'left') + ->join('t_supplierdetailsn t_sd', 't_sd.SupplierID = t_pom.SupplierID') + + ->join('t_gasshortagedetails t_gsd', 't_gsd.IGRNO = t_igrm.IGRNO', 'left') + + ->join('t_materialmaster t_mm', 't_mm.MaterialCode = t_igrd.MaterialCode', 'left') + ->whereIn('t_igrd.MaterialCode', $gasMaterialCodes) + ->where("DATE(t_igrd.CreatedDate) >= '2025-04-01' ") + + ->where('t_gsd.gas_cylinder_status', 'gas_returned') + + ->groupBy('t_igrd.IGRNO'); + + break; + } + + + $result = $builder->get()->getResultArray(); + + + + return $result; + } +} diff --git a/app/Models/Monthlypay_model.php b/app/Models/Monthlypay_model.php index db7f7cb7..d984d3d6 100755 --- a/app/Models/Monthlypay_model.php +++ b/app/Models/Monthlypay_model.php @@ -72,6 +72,8 @@ class Monthlypay_model extends Model ->orderBy('EmpID', 'asc'); $query = $builder->get(); $result = $query->getResult(); + // $last_query = $this->db->getLastQuery(); + // echo $last_query;die; return $result; } @@ -177,6 +179,8 @@ class Monthlypay_model extends Model $year_val = date('Y', strtotime($current)); $date_val = cal_days_in_month(CAL_GREGORIAN, $month_val, $year_val); $lastdate = $year_val . '-' . $month_val . '-' . $date_val; +// echo $current; +// echo "last date - ".$lastdate;die; $builder = $this->db->table('t_attendance') ->select('t_attendance.*,t_employee_details.FirstName,t_employee_details.LastName') @@ -191,6 +195,8 @@ class Monthlypay_model extends Model $query = $builder->get(); $result = $query->getResult(); + // $last_query = $this->db->getLastQuery(); + // echo $last_query;die; return $result; } @@ -571,6 +577,26 @@ where Month_Year = ? and att.EmpID in (select EmpID from t_attendance)"; return $this->db->affectedRows(); } } + public function validateDateRange($emp_id,$start_date,$end_date){ + + $array = $this->db->table('t_employee_leave_application_form') + ->where('emp_id', $emp_id) + ->where('status', 'Approved') + ->groupStart() // Start grouping OR conditions + ->where("'$start_date' BETWEEN start_date AND end_date", null, false) + ->orWhere("'$end_date' BETWEEN start_date AND end_date", null, false) + ->orWhere("start_date BETWEEN '$start_date' AND '$end_date'", null, false) + ->orWhere("end_date BETWEEN '$start_date' AND '$end_date'", null, false) + ->groupEnd() // End grouping + ->get() + ->getRowArray(); + + // $last_query = $this->db->getLastQuery(); + // echo $last_query; + + return $array; + + } function getEmpPayDetailsforOTListing($current = "") { @@ -617,5 +643,25 @@ where Month_Year = ? and att.EmpID in (select EmpID from t_attendance)"; return $query->getResult(); } + function employeeLeaveDates($current){ + $current =get_date_time_dynamical_format('m-Y','Y-m',"$current"); + $array = $this->db->table('t_employee_leave_application_form') + ->select("emp_id,start_date,end_date,status") + ->where('status', 'Approved') + ->groupStart() // Start grouping OR conditions + ->where("DATE_FORMAT(start_date, '%Y-%m') = '$current'", null, false) + ->orWhere("DATE_FORMAT(end_date, '%Y-%m') = '$current'", null, false) + ->orWhere("DATE_FORMAT(start_date, '%Y-%m') <= '$current' AND DATE_FORMAT(end_date, '%Y-%m') >= '$current'", null, false) + ->groupEnd() // End grouping + ->get() + ->getResultArray(); + + // $last_query = $this->db->getLastQuery(); + // echo $last_query; + + return $array; + // return [$current]; + } + } \ No newline at end of file diff --git a/app/Models/Rawmaterialdetails_model.php b/app/Models/Rawmaterialdetails_model.php index 22b261bb..51e60c69 100755 --- a/app/Models/Rawmaterialdetails_model.php +++ b/app/Models/Rawmaterialdetails_model.php @@ -232,6 +232,18 @@ class Rawmaterialdetails_model extends Model } + function getAllGasMaterialCode(){ + + $builder = $this->db->table('t_materialmaster') + ->select('MaterialCode') + ->where('Category', '334') + ->orderBy('MaterialCode', 'asc'); + $query = $builder->get(); + $materialResults = $query->getResultArray(); + + return $materialResults; + } + function getMaterialstock($MaterialCode, $currentdate) diff --git a/app/Views/EditservicePurchaseorder.php b/app/Views/EditservicePurchaseorder.php index df67aeac..401b562d 100755 --- a/app/Views/EditservicePurchaseorder.php +++ b/app/Views/EditservicePurchaseorder.php @@ -1252,10 +1252,12 @@ if (!empty($getlogpodtl)) {
- + > IS THIS OPEN ORDER FORMAT + +
@@ -1504,34 +1506,37 @@ if (!empty($getlogpodtl)) {
- - - -
- - -
- +
+
+
+
+ +
+
+ +
+ +
- -
+
+
+ - + + + - @@ -1547,7 +1552,9 @@ if (!empty($getlogpodtl)) { -
Bill No FileAction
FilePath)) ? $gd->FilePath : "No File"; ?> + + +     FilePath)) { ?> @@ -1561,6 +1568,7 @@ if (!empty($getlogpodtl)) {
+ - +
--> + +
@@ -1715,10 +1723,9 @@ if (!empty($getlogpodtl)) {
- - + @@ -1895,7 +1902,7 @@ if (!empty($getlogpodtl)) {
'AfterSgst', 'value' => set_value('AfterSgst'), 'id' => 'AfterSgst', 'class' => 'form-control num', 'placeholder' => 'After SGST'); + $data = array('name' => 'AfterSgst', 'value' => set_value('AfterSgst'), 'id' => 'AfterSgst', 'class' => 'form-control num', 'placeholder' => 'After SGST', 'readonly' => 'true'); echo form_input($data); ?>
@@ -1969,26 +1976,25 @@ if (!empty($getlogpodtl)) { - + + + +
No Coating Machine Details present in this month
+ +
+

Note :- (A) -> Average

+ + + @@ -1838,8 +1857,10 @@ div.style.height = "100%"; // Reset .table-responsive height when exiting fullscreen - if (tableResponsive) { - tableResponsive.style.height = "auto"; + // If .table-responsive exists, set its height to 90vh + if (tableResponsive) { + tableResponsive.style.maxHeight = "450px"; + tableResponsive.style.overflowY = "auto"; // Allow scrolling if needed } }).catch(err => console.log("Error exiting fullscreen:", err)); } @@ -1912,3 +1933,26 @@ + + diff --git a/app/Views/stock/bagStockDetails.php b/app/Views/stock/bagStockDetails.php index f819e15e..13341b9f 100644 --- a/app/Views/stock/bagStockDetails.php +++ b/app/Views/stock/bagStockDetails.php @@ -212,7 +212,7 @@ background-color: #50bbd9; /* Green background */ color: #ffffff; - border: 1px solid #ddd; + border: 2px solid ; padding: 10px; white-space: normal; /* Allows text to wrap */ @@ -349,7 +349,7 @@ foreach ($period as $day) { @@ -358,7 +358,7 @@ foreach ($period as $day) { if ($month == date('M-Y')) { ?> @@ -373,25 +373,25 @@ foreach ($period as $day) { title="Navigation" data-toggle="modal" data-target="#bs-example-modal-lg" - style="font-size: x-large; cursor:pointer;"> + style="font-size: x-large; cursor:pointer; color: #bd0906"> @@ -1364,13 +1364,15 @@ foreach ($period as $day) { }).catch(err => console.log("Error enabling fullscreen:", err)); } else { document.exitFullscreen().then(() => { + div.style.width = "100%"; + div.style.height = "100%"; // Reset .table-responsive height when exiting fullscreen - if (tableResponsive) { - tableResponsive.style.height = "auto"; + // If .table-responsive exists, set its height to 90vh + if (tableResponsive) { + tableResponsive.style.maxHeight = "450px"; + tableResponsive.style.overflowY = "auto"; // Allow scrolling if needed } - - }).catch(err => console.log("Error exiting fullscreen:", err)); } diff --git a/app/Views/stock/dieselStockDetails.php b/app/Views/stock/dieselStockDetails.php index 1999e936..5adc25eb 100644 --- a/app/Views/stock/dieselStockDetails.php +++ b/app/Views/stock/dieselStockDetails.php @@ -213,7 +213,7 @@ background-color: #50bbd9; /* Green background */ color: #ffffff; - border: 1px solid #ddd; + border: 2px solid ; padding: 10px; } @@ -337,8 +337,8 @@ foreach ($period as $day) { + style=" padding: 8px;margin-bottom: 10px;width: 250px;border: 2px solid rgb(123, 11, 214); + border-radius: 5px;margin-right:15px;"> @@ -361,25 +361,26 @@ foreach ($period as $day) { title="Navigation" data-toggle="modal" data-target="#bs-example-modal-lg" - style="font-size: x-large; cursor:pointer;"> + style="font-size: x-large; cursor:pointer; color: #bd0906"> + + style="font-size: x-large; cursor:pointer; color: #0b7cba" + id="bagStockExport"> @@ -574,11 +575,11 @@ foreach ($period as $day) { - $dieselStockDetails) { + foreach ($groupedDieselMachineStockDetails as $rowIndex => $dieselStockDetails) { ?> format('d-m-Y'); + $startDate = DateTime::createFromFormat('Y-m-d', $totalDiesel[$rowIndex]['date'])->format('d-m-Y'); ?> @@ -603,37 +604,37 @@ foreach ($period as $day) { + oninput="openingTDStockChange(this)" contenteditable="true" - > + > - + + data-id=""> - + + data-id=""> - + @@ -643,15 +644,15 @@ foreach ($period as $day) { //before closing outer loop if (!isset($summary['totalPurchaseDiesel'])) { - $summary['opening_diesel'] = '-'; + $summary['openingStock'] = '-'; $summary['totalPurchaseDiesel'] = 0; $summary['totalFillingDiesel'] = 0; $summary['balanceStock'] = 0; } - - $summary['totalPurchaseDiesel'] += is_numeric($totalDiesel[$groupedDieselMachineStockDetailsIndex]['purchase_diesel']) ? $totalDiesel[$groupedDieselMachineStockDetailsIndex]['purchase_diesel'] : 0; - $summary['totalFillingDiesel'] += is_numeric($totalDiesel[$groupedDieselMachineStockDetailsIndex]['total_filling_diesel']) ? $totalDiesel[$groupedDieselMachineStockDetailsIndex]['total_filling_diesel'] : 0; - $summary['balanceStock'] = is_numeric($totalDiesel[$groupedDieselMachineStockDetailsIndex]['balance_stock']) ? $totalDiesel[$groupedDieselMachineStockDetailsIndex]['balance_stock'] : 0; + $summary['openingStock'] = is_numeric($totalDiesel[$rowIndex]['opening_stock']) ? $totalDiesel[$rowIndex]['opening_stock'] : 0; + $summary['totalPurchaseDiesel'] += is_numeric($totalDiesel[$rowIndex]['purchase_diesel']) ? $totalDiesel[$rowIndex]['purchase_diesel'] : 0; + $summary['totalFillingDiesel'] += is_numeric($totalDiesel[$rowIndex]['total_filling_diesel']) ? $totalDiesel[$rowIndex]['total_filling_diesel'] : 0; + $summary['balanceStock'] = is_numeric($totalDiesel[$rowIndex]['balance_stock']) ? $totalDiesel[$rowIndex]['balance_stock'] : 0; ?> @@ -675,7 +676,7 @@ foreach ($period as $day) { + oninput="openingReadingChange(this)" contenteditable="true" > @@ -781,7 +782,7 @@ foreach ($period as $day) { - + @@ -836,41 +837,115 @@ foreach ($period as $day) { - - - oninput="openingTDStockChange(this)" - contenteditable="true" - - > - - - - - - - - - - - - + + + + + + + oninput="openingTDStockChange(this)" + contenteditable="true" + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + oninput="openingTDStockChange(this)" + contenteditable="true" + + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $dieselMachine) { ?> @@ -1566,8 +1641,7 @@ foreach ($period as $day) { const box = child.getBoundingClientRect(); const offset = y - box.top - box.height / 2; - return offset < 0 && offset > closest.offset ? - { + return offset < 0 && offset > closest.offset ? { offset, element: child } : @@ -1660,8 +1734,10 @@ foreach ($period as $day) { div.style.height = "100%"; // Reset .table-responsive height when exiting fullscreen - if (tableResponsive) { - tableResponsive.style.height = "auto"; + // If .table-responsive exists, set its height to 90vh + if (tableResponsive) { + tableResponsive.style.maxHeight = "450px"; + tableResponsive.style.overflowY = "auto"; // Allow scrolling if needed } }).catch(err => console.log("Error exiting fullscreen:", err)); } diff --git a/app/Views/stock/drierMachineDetails.php b/app/Views/stock/drierMachineDetails.php index 3e2976ef..79ac5c1f 100644 --- a/app/Views/stock/drierMachineDetails.php +++ b/app/Views/stock/drierMachineDetails.php @@ -339,13 +339,13 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); + style="padding: 8px;margin-bottom: 10px;width: 250px;border: 2px solid rgb(123, 11, 214); + border-radius: 5px;margin-right:15px; "> @@ -353,13 +353,13 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); @@ -368,7 +368,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); title="Add Entry" data-target="#additionalEntriesModalId" data-toggle="modal" - style="font-size: x-large; cursor:pointer;"> + style="font-size: x-large; cursor:pointer; color:rgb(31, 132, 3)"> @@ -462,14 +462,16 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
@@ -752,7 +754,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
- + @@ -867,22 +869,22 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); - + - + - + - + @@ -942,7 +944,10 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); $summary['input_sand_qty'] += $a['input_sand_qty'] == "-" ? 0 : (float) $a['input_sand_qty']; $summary['moisture_loss_qty'] += $a['moisture_loss_qty'] == "-" ? 0 : (float) $a['moisture_loss_qty']; $summary['sand_dried_qty'] += $a['sand_dried_qty'] == "-" ? 0 : (float) $a['sand_dried_qty']; + $summary['gas_per_ton'] = round(($summary['total_gas_consumption'] / $summary['sand_dried_qty'])); + $summary['qty_per_hrs'] = round( ($summary['sand_dried_qty'] / $summary['drier_running_hours']) ); $summary['dust_qty'] += $a['dust_qty'] == "-" ? 0 : (float) $a['dust_qty']; + } ?> @@ -962,8 +967,8 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); - - - + (A) + (A) @@ -979,7 +984,12 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');

- + +
+

Note :- (A) -> Average

+ + + @@ -1471,8 +1481,10 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); div.style.height = "100%"; // Reset .table-responsive height when exiting fullscreen - if (tableResponsive) { - tableResponsive.style.height = "auto"; + // If .table-responsive exists, set its height to 90vh + if (tableResponsive) { + tableResponsive.style.maxHeight = "450px"; + tableResponsive.style.overflowY = "auto"; // Allow scrolling if needed } }).catch(err => console.log("Error exiting fullscreen:", err)); } @@ -1543,4 +1555,27 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); + + + \ No newline at end of file diff --git a/app/Views/stock/dustAndRoughStockDetails.php b/app/Views/stock/dustAndRoughStockDetails.php index 331eb25e..4f14fd9a 100644 --- a/app/Views/stock/dustAndRoughStockDetails.php +++ b/app/Views/stock/dustAndRoughStockDetails.php @@ -217,7 +217,7 @@ background-color: #50bbd9; /* Green background */ color: #ffffff; - border: 1px solid #ddd; + border: 2px solid ; padding: 10px; } @@ -342,7 +342,7 @@
-
+
" class="form-control " @@ -359,13 +359,13 @@ @@ -373,20 +373,20 @@ @@ -394,7 +394,7 @@
-
+
@@ -967,8 +967,10 @@ div.style.height = "100%"; // Reset .table-responsive height when exiting fullscreen - if (tableResponsive) { - tableResponsive.style.height = "auto"; + // If .table-responsive exists, set its height to 90vh + if (tableResponsive) { + tableResponsive.style.maxHeight = "450px"; + tableResponsive.style.overflowY = "auto"; // Allow scrolling if needed } }).catch(err => console.log("Error exiting fullscreen:", err)); } diff --git a/app/Views/stock/gasStockDetails.php b/app/Views/stock/gasStockDetails.php index 029b2079..b4110044 100644 --- a/app/Views/stock/gasStockDetails.php +++ b/app/Views/stock/gasStockDetails.php @@ -202,7 +202,7 @@ background-color: #50bbd9; /* Green background */ color: #ffffff; - border: 1px solid #ddd; + border: 2px solid ; padding: 10px; } @@ -222,7 +222,7 @@ .table-responsive { overflow-x: auto; overflow-y: auto; - max-height: 500px; + max-height: 450px; max-width: 100%; position: relative; } @@ -335,13 +335,13 @@ @@ -349,20 +349,20 @@ @@ -453,16 +453,15 @@ RIPL Gas Stock - FBD 10 Ton Dryer - Sand Dried - Coating Machine - Sand Coated - TRP + FBD 10 Ton Dryer + Coating Machine + TRP Sand TRP Rotary Drier + Date Opening Stock Purchase(Bharath) @@ -470,10 +469,12 @@ Total Consumption Balance Stock + + Consumption - Ton + Sand Dried Qty Consumption - Ton + Sand Coated Qty Panel Consumption Physical Consumption Ton @@ -1272,8 +1273,10 @@ div.style.height = "100%"; // Reset .table-responsive height when exiting fullscreen - if (tableResponsive) { - tableResponsive.style.height = "auto"; + // If .table-responsive exists, set its height to 90vh + if (tableResponsive) { + tableResponsive.style.maxHeight = "450px"; + tableResponsive.style.overflowY = "auto"; // Allow scrolling if needed } }).catch(err => console.log("Error exiting fullscreen:", err)); } diff --git a/app/Views/stock/incomingSilicaSandDetails.php b/app/Views/stock/incomingSilicaSandDetails.php index 7a015ea9..e2afc565 100644 --- a/app/Views/stock/incomingSilicaSandDetails.php +++ b/app/Views/stock/incomingSilicaSandDetails.php @@ -340,27 +340,27 @@ @@ -1577,11 +1577,16 @@ if (i === 0 || i === 1) { newPlus20Loss += Number(result[i]['WEIGH OF SAND']); + + + newSieveLossQty = (parseFloat(qty) * newPlus20Loss) / 100; + + } if (i === 0 || i === 1 || i === 2) { newPlus30Loss += Number(result[i]['WEIGH OF SAND']); - newSieveLossQty = (parseFloat(qty) * newPlus20Loss) / 100; + } totalWeighOfSand += Number(result[i]['WEIGH OF SAND']); @@ -1958,8 +1963,10 @@ div.style.height = "100%"; // Reset .table-responsive height when exiting fullscreen - if (tableResponsive) { - tableResponsive.style.height = "auto"; + // If .table-responsive exists, set its height to 90vh + if (tableResponsive) { + tableResponsive.style.maxHeight = "450px"; + tableResponsive.style.overflowY = "auto"; // Allow scrolling if needed } }).catch(err => console.log("Error exiting fullscreen:", err)); } diff --git a/app/Views/stock/powerConsumptionDetails.php b/app/Views/stock/powerConsumptionDetails.php index 3d052ec8..d51596cc 100644 --- a/app/Views/stock/powerConsumptionDetails.php +++ b/app/Views/stock/powerConsumptionDetails.php @@ -213,7 +213,7 @@ background-color: #50bbd9; /* Green background */ color: #ffffff; - border: 1px solid #ddd; + border: 2px solid; padding: 10px; } @@ -261,6 +261,11 @@ .card { margin-bottom: 5px; } + + #powerStockDetailsTableId { + /* Replace with your table's actual ID or selector */ + border-collapse: collapse; + } @@ -339,8 +344,8 @@ foreach ($period as $day) { + style=" padding: 8px;margin-bottom: 10px;width: 250px;border: 2px solid rgb(123, 11, 214); + border-radius: 5px;margin-right:15px;"> @@ -363,25 +368,25 @@ foreach ($period as $day) { title="Navigation" data-toggle="modal" data-target="#bs-example-modal-lg" - style="font-size: x-large; cursor:pointer;"> + style="font-size: x-large; cursor:pointer; color: #bd0906"> + style="font-size: x-large; cursor:pointer; color: #0b7cba" + id="bagStockExport"> @@ -400,7 +405,7 @@ foreach ($period as $day) { 2)choose which material/machines you want ------------------------------------------------------------> - +
-
+
@@ -583,7 +588,7 @@ foreach ($period as $day) { $currentDate = date('d-m-Y'); $dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $resinStockDetails[0]['date'])->format('d-m-Y'); if ($dateInMonthDmYFormat === $currentDate) { - echo 'style="background: rgb(232, 245, 231);"'; + echo 'style="background: #cef0ad;"'; } ?>> $resinStock) { @@ -671,126 +676,122 @@ foreach ($period as $day) { - - + + - - Total - + + Total + - + - - - - + + + + - - - - - - - - - - - $dateInMonth) { ?> - format('d-m-Y'); - if ($dateInMonthDmYFormat === $currentDate) { - echo 'style="background: rgb(232, 245, 231);"'; - } - ?>> - $resinMaterial) { ?> - - - - format('d-m-Y'); - ?> - - - - - - - - - - - - - - - - - - - - oninput="openingStockChange(this)" - contenteditable="true" - - > - - $previousMonthResinStockDetail) - { - if($previousMonthResinStockDetail['materialCode'] == $resinMaterial['MaterialCode']){ - echo $previousMonthResinStockDetail['balanceStock'] ; - break; - } - - } - ?> - - - - - - - - - - $previousMonthResinStockDetail) - { - if($previousMonthResinStockDetail['materialCode'] == $resinMaterial['MaterialCode']){ - echo $previousMonthResinStockDetail['balanceStock'] ; - break; - } - - } - ?> - - - - - + + + - + + + + + $dateInMonth) { ?> + format('d-m-Y'); + if ($dateInMonthDmYFormat === $currentDate) { + echo 'style="background: #cef0ad ;"'; + } + ?>> + $resinMaterial) { ?> + + + + format('d-m-Y'); + ?> + + + + + + + + + + + + + + + + + + + + oninput="openingStockChange(this)" + contenteditable="true" + + > + + $previousMonthResinStockDetail) { + if ($previousMonthResinStockDetail['materialCode'] == $resinMaterial['MaterialCode']) { + echo $previousMonthResinStockDetail['balanceStock']; + break; + } + } + ?> + + + + + + + + + + $previousMonthResinStockDetail) { + if ($previousMonthResinStockDetail['materialCode'] == $resinMaterial['MaterialCode']) { + echo $previousMonthResinStockDetail['balanceStock']; + break; + } + } + ?> + + + + + + + + + @@ -812,7 +813,7 @@ foreach ($period as $day) { @@ -867,9 +868,9 @@ foreach ($period as $day) { targetColumnIndex = targetColumnIndex * 7; targetRow.cells[targetColumnIndex].scrollIntoView({ - behavior: 'smooth', - inline: 'center', - block: 'center' + behavior: 'smooth', + inline: 'center', + block: 'center' }); const highlightDuration = 10000; @@ -1099,24 +1100,24 @@ foreach ($period as $day) { $(document).ready(function() { function exportTableToExcel(tableID, filename = '') { - let table = document.getElementById(tableID); - + let table = document.getElementById(tableID); + let cloneTable = table.cloneNode(true); // Clone the table to modify - + // Remove hidden rows - $(cloneTable).find('tr').filter(function () { + $(cloneTable).find('tr').filter(function() { return $(this).css('display') === 'none'; }).remove(); - + // Remove hidden columns - $(cloneTable).find('th, td').each(function () { + $(cloneTable).find('th, td').each(function() { if ($(this).css('display') === 'none') { $(this).remove(); } }); $(cloneTable).find('tbody tr').each(function() { let firstTd = $(this).find('td').eq(0); // Get the first column (Date) - + // Convert Date Format (Assuming it's in YYYY-MM-DD format) let originalDate = firstTd.text().trim(); // Get the text value let parts = originalDate.split('-'); // Split into [YYYY, MM, DD] @@ -1189,72 +1190,77 @@ foreach ($period as $day) { - + \ No newline at end of file diff --git a/app/Views/stock/trpProductionStockDetails.php b/app/Views/stock/trpProductionStockDetails.php index 194b1364..2e3892e3 100644 --- a/app/Views/stock/trpProductionStockDetails.php +++ b/app/Views/stock/trpProductionStockDetails.php @@ -210,7 +210,7 @@ background-color: #50bbd9; /* Green background */ color: #ffffff; - border: 1px solid #ddd; + border: 2px solid ; white-space: normal; /* Allows text to wrap */ word-wrap: break-word; @@ -305,6 +305,12 @@ .card { margin-bottom: 5px; } + + #trpProductionStockDetailsTableId { /* Replace with your table's actual ID or selector */ + border-collapse: collapse; + } + + @@ -399,10 +405,7 @@ $timeOtions[] = "12:00 AM";
" - class="form-control " - data-provide="datepicker" - data-date-format="M-yyyy" - data-date-min-view-mode="1" readonly + class="form-control " readonly style="max-width: 175px;">
@@ -413,13 +416,13 @@ $timeOtions[] = "12:00 AM"; @@ -427,20 +430,20 @@ $timeOtions[] = "12:00 AM"; @@ -1498,16 +1501,18 @@ $timeOtions[] = "12:00 AM";
- - - - + + + + -
@@ -1703,36 +1708,36 @@ $timeOtions[] = "12:00 AM"; 'absRunningHrs' => "", 'absPerHour' => "", 'absOpeningStock' => '', - 'absReceipt' => $totalWcsReceived, - 'absTotal' => $totalWcsReceived, - 'absConsumption' => $summary['edProduction'], - 'absClosingStock' => ($totalWcsReceived) - $summary['edProduction'], + 'absReceipt' => $totalWcsReceived == 0 ? " " : $totalWcsReceived, + 'absTotal' => $totalWcsReceived == 0 ? " " : $totalWcsReceived, + 'absConsumption' => $summary['edProduction'] == 0 ? " " : $summary['edProduction'] , + 'absClosingStock' => ($totalWcsReceived) - $summary['edProduction'] == 0 ? " " : $totalWcsReceived - $summary['edProduction'], 'absPhysicalStock' => '', 'absRemarks' => '', ], [ 'absParticulars' => "ED Details", - 'absRunningHrs' => $summary['edRunningHours'], - 'absPerHour' => number_format($summary['edProduction'] / ($summary['edRunningHours'] == 0 ? 1 : $summary['edRunningHours']), 2), + 'absRunningHrs' => $summary['edRunningHours'] == 0 ? " " : $summary['edRunningHours'], + 'absPerHour' => number_format($summary['edProduction'] / ($summary['edRunningHours'] == 0 ? 1 : $summary['edRunningHours']), 2) == 0 ? " " : number_format($summary['edProduction'] / ($summary['edRunningHours'] == 0 ? 1 : $summary['edRunningHours']), 2), 'absOpeningStock' => '', - 'absReceipt' => $summary['edProduction'], - 'absTotal' => $summary['edProduction'], - 'absConsumption' => $summary['edUsage'] + ($summary['coolerBags'] * 1250) + ($summary['cycloneWaste'] * 1250) + ($summary['edWaste'] * 1250), - 'absClosingStock' => $summary['edProduction'] - $summary['edUsage'] + ($summary['coolerBags'] * 1250) + ($summary['cycloneWaste'] * 1250) + ($summary['edWaste'] * 1250), + 'absReceipt' => $summary['edProduction'] == 0 ? " " : $summary['edProduction'], + 'absTotal' => $summary['edProduction'] == 0 ? " " : $summary['edProduction'], + 'absConsumption' => $summary['edUsage'] + ($summary['coolerBags'] * 1250) + ($summary['cycloneWaste'] * 1250) + ($summary['edWaste'] * 1250) == 0 ? " " : $summary['edUsage'] + ($summary['coolerBags'] * 1250) + ($summary['cycloneWaste'] * 1250) + ($summary['edWaste'] * 1250), + 'absClosingStock' => $summary['edProduction'] - $summary['edUsage'] + ($summary['coolerBags'] * 1250) + ($summary['cycloneWaste'] * 1250) + ($summary['edWaste'] * 1250) == 0 ? " " : $summary['edProduction'] - ($summary['edUsage'] + ($summary['coolerBags'] * 1250) + ($summary['cycloneWaste'] * 1250) + ($summary['edWaste'] * 1250)), 'absPhysicalStock' => '', 'absRemarks' => '', ], [ 'absParticulars' => "TRP Total Sand", - 'absRunningHrs' => $summary['sandFeedingHours'], - 'absPerHour' => $summary['trpProductionPerHour'], + 'absRunningHrs' => $summary['sandFeedingHours'] == 0 ? " " : $summary['sandFeedingHours'], + 'absPerHour' => $summary['trpProductionPerHour'] == 0 ? " " : $summary['trpProductionPerHour'], 'absOpeningStock' => '', - 'absReceipt' => $summary['trpProduction'], - 'absTotal' => $summary['trpProduction'], - 'absConsumption' => $totalCrsReceived, - 'absClosingStock' => $summary['trpProduction'] - $totalCrsReceived, + 'absReceipt' => $summary['trpProduction'] == 0 ? " " : $summary['trpProduction'], + 'absTotal' => $summary['trpProduction'] == 0 ? " " : $summary['trpProduction'], + 'absConsumption' => $totalCrsReceived == 0 ? " " : $totalCrsReceived, + 'absClosingStock' => $summary['trpProduction'] - $totalCrsReceived == 0 ? " " : $summary['trpProduction'] - $totalCrsReceived, 'absPhysicalStock' => '', 'absRemarks' => '', ], @@ -1740,12 +1745,12 @@ $timeOtions[] = "12:00 AM"; 'absParticulars' => "Trp Physical Gas Consumption", 'absRunningHrs' => "", - 'absPerHour' => number_format(($summary['trpPlusDrierGasConsumption']) / (($summary['trpProduction'] == 0 ? 1000 : $summary['trpProduction']) / 1000), 2, '.', ''), + 'absPerHour' => number_format(($summary['trpPlusDrierGasConsumption']) / (($summary['trpProduction'] == 0 ? 1000 : $summary['trpProduction']) / 1000), 2, '.', '') == 0 ? " " : number_format(($summary['trpPlusDrierGasConsumption']) / (($summary['trpProduction'] == 0 ? 1000 : $summary['trpProduction']) / 1000), 2, '.', ''), 'absOpeningStock' => '', - 'absReceipt' => $summary['gasReceiptBg'] + $summary['gasReceiptPg'], - 'absTotal' => $summary['gasReceiptBg'] + $summary['gasReceiptPg'], - 'absConsumption' => $summary['physicalGasConsumption'], - 'absClosingStock' => ($summary['gasReceiptBg'] + $summary['gasReceiptPg']) - $summary['physicalGasConsumption'], + 'absReceipt' => $summary['gasReceiptBg'] + $summary['gasReceiptPg'] == 0 ? " " : $summary['gasReceiptBg'] + $summary['gasReceiptPg'], + 'absTotal' => $summary['gasReceiptBg'] + $summary['gasReceiptPg'] == 0 ? " " : $summary['gasReceiptBg'] + $summary['gasReceiptPg'], + 'absConsumption' => $summary['physicalGasConsumption'] == 0 ? " " : $summary['physicalGasConsumption'], + 'absClosingStock' => ($summary['gasReceiptBg'] + $summary['gasReceiptPg']) - $summary['physicalGasConsumption'] == 0 ? " " : ($summary['gasReceiptBg'] + $summary['gasReceiptPg']) - $summary['physicalGasConsumption'], 'absPhysicalStock' => '', 'absRemarks' => '', ], @@ -1753,12 +1758,12 @@ $timeOtions[] = "12:00 AM"; 'absParticulars' => "Trp Panel Gas Consumption", 'absRunningHrs' => "", - 'absPerHour' => number_format(($summary['panelGasConsumption']) / (($summary['trpProduction'] == 0 ? 1000 : $summary['trpProduction']) / 1000), 2), + 'absPerHour' => number_format(($summary['panelGasConsumption']) / (($summary['trpProduction'] == 0 ? 1000 : $summary['trpProduction']) / 1000), 2) == 0 ? " " : number_format(($summary['panelGasConsumption']) / (($summary['trpProduction'] == 0 ? 1000 : $summary['trpProduction']) / 1000), 2), 'absOpeningStock' => '', - 'absReceipt' => $summary['gasReceiptBg'] + $summary['gasReceiptPg'], - 'absTotal' => $summary['gasReceiptBg'] + $summary['gasReceiptPg'], - 'absConsumption' => $summary['panelGasConsumption'], - 'absClosingStock' => ($summary['gasReceiptBg'] + $summary['gasReceiptPg']) - $summary['panelGasConsumption'], + 'absReceipt' => $summary['gasReceiptBg'] + $summary['gasReceiptPg'] == 0 ? " " : $summary['gasReceiptBg'] + $summary['gasReceiptPg'], + 'absTotal' => $summary['gasReceiptBg'] + $summary['gasReceiptPg'] == 0 ? " " : $summary['gasReceiptBg'] + $summary['gasReceiptPg'], + 'absConsumption' => $summary['panelGasConsumption'] == 0 ? " " : $summary['panelGasConsumption'] , + 'absClosingStock' => ($summary['gasReceiptBg'] + $summary['gasReceiptPg']) - $summary['panelGasConsumption'] == 0 ? " " : ($summary['gasReceiptBg'] + $summary['gasReceiptPg']) - $summary['panelGasConsumption'], 'absPhysicalStock' => '', 'absRemarks' => '', ], @@ -1768,9 +1773,9 @@ $timeOtions[] = "12:00 AM"; 'absRunningHrs' => "", 'absPerHour' => "", 'absOpeningStock' => '', - 'absReceipt' => $summary['waterReceipt'], - 'absTotal' => $summary['waterReceipt'], - 'absConsumption' => $summary['waterReceipt'] - $summary['waterConsumption'], + 'absReceipt' => $summary['waterReceipt'] == 0 ? " " : $summary['waterReceipt'], + 'absTotal' => $summary['waterReceipt'] == 0 ? " " : $summary['waterReceipt'], + 'absConsumption' => $summary['waterReceipt'] - $summary['waterConsumption'] == 0 ? " " : $summary['waterReceipt'] - $summary['waterConsumption'], 'absClosingStock' => '', 'absPhysicalStock' => '', 'absRemarks' => '', @@ -1778,12 +1783,12 @@ $timeOtions[] = "12:00 AM"; [ 'absParticulars' => "Power Consumption", - 'absRunningHrs' => $summary['ebReadingPerUnitTon'], + 'absRunningHrs' => $summary['ebReadingPerUnitTon'] == 0 ? " " : $summary['ebReadingPerUnitTon'], 'absPerHour' => "", 'absOpeningStock' => '', 'absReceipt' => '', 'absTotal' => '', - 'absConsumption' => $summary['ebReading'], + 'absConsumption' => $summary['ebReading'] == 0 ? " " : $summary['ebReading'], 'absClosingStock' => '', 'absPhysicalStock' => '', 'absRemarks' => '', @@ -2325,8 +2330,8 @@ $timeOtions[] = "12:00 AM"; // Convert to numbers for calculations let openingStock = validateInput(openingStockTd) || 0; - let receipt = validateInput(receiptTd) || 0; - let consumption = validateInput(consumptionTd) || 0; + let receipt = validateInput(receiptTd) || 0; + let consumption = validateInput(consumptionTd) || 0; // Calculate values let totalStock = parseFloat(openingStock) + parseFloat(receipt); @@ -2528,8 +2533,6 @@ $timeOtions[] = "12:00 AM"; }) - -