diff --git a/app/Controllers/Amendmentpurchaseorder.php b/app/Controllers/Amendmentpurchaseorder.php index cecd2007..b5c5c667 100755 --- a/app/Controllers/Amendmentpurchaseorder.php +++ b/app/Controllers/Amendmentpurchaseorder.php @@ -42,23 +42,23 @@ class Amendmentpurchaseorder extends BaseController { - if ($this->request->getMethod() === 'GET') - { - $currentYear = date('Y'); - $currentMonth = date('m'); + if ($this->request->getMethod() === 'GET') + { + $currentYear = date('Y'); + $currentMonth = date('m'); $startOfMonth = "$currentYear-$currentMonth-01"; $endOfMonth = date('Y-m-t'); - $fromDate = $startOfMonth; - $toDate = $endOfMonth; - } elseif ($this->request->getMethod() === 'POST') { - $fromDate = $this->request->getPost('fromDate'); - $toDate = $this->request->getPost('toDate'); + $fromDate = $startOfMonth; + $toDate = $endOfMonth; + } elseif ($this->request->getMethod() === 'POST') { + $fromDate = $this->request->getPost('fromDate'); + $toDate = $this->request->getPost('toDate'); $fromDate = date('Y-m-d', strtotime($fromDate)); $toDate = date('Y-m-d', strtotime($toDate)); } // $this->load->library('pagination'); - $forwhat = 'amendment'; + $forwhat = 'amendment'; $data['POData'] = $this->purchaseorder_model->purchaseorderListing($forwhat,$fromDate,$toDate); $data['fromDate'] = date('d-m-Y', strtotime($fromDate)); @@ -1340,8 +1340,6 @@ class Amendmentpurchaseorder extends BaseController $createddt = get_current_date_time(); $updateddt = get_current_date_time(); - - $PaymentTerms = $this->request->getPost('PaymentTerms'); $beforePaymentTerms = $this->request->getPost('beforePaymentterms'); @@ -1410,20 +1408,17 @@ class Amendmentpurchaseorder extends BaseController } $LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster, $CreateBy, $PONO); $NewPO = ''; - // if (count($LastPO) > 0) { - // $NewPO = $LastPO[0]['PONO']; - // } - // print_r($LastPO);die; + foreach ($LastPO as $PO) : $NewPO = $PO['PONO']; endforeach; $PODetail = array('Status' => PO_AMENDED); //TO SET PARENT PO AS AMENDMENT STATUS - $APO = $this->purchaseorder_model->updateAmendPOMaster($PONO, $PODetail); + $APO = $this->purchaseorder_model->updateAmendPOMaster($PONO, $PODetail); - $LineItemStatus = REQITEM_NEW; + $LineItemStatus = REQITEM_NEW; - $igrvalue = $this->purchaseorder_model->selectigrmaster($PONO); + $igrvalue = $this->purchaseorder_model->selectigrmaster($PONO); $po = ''; $igrno = ''; diff --git a/app/Controllers/Employeedetails.php b/app/Controllers/Employeedetails.php index 1c020e38..5344a673 100755 --- a/app/Controllers/Employeedetails.php +++ b/app/Controllers/Employeedetails.php @@ -199,37 +199,7 @@ class Employeedetails extends BaseController * This function is used to save the new Employee form in the database */ /** - * This function is used to save the new Employee form in the database - */ - /** - * This function is used to save the new Employee form in the database - */ - /** - * This function is used to save the new Employee form in the database - */ - /** - * This function is used to save the new Employee form in the database - */ - /** - * This function is used to save the new Employee form in the database - */ - /** - * This function is used to save the new Employee form in the database - */ - /** - * This function is used to save the new Employee form in the database - */ - /** - * This function is used to save the new Employee form in the database - */ - /** - * This function is used to save the new Employee form in the database - */ - /** - * This function is used to save the new Employee form in the database - */ - /** - * This function is used to save the new Employee form in the database + */ @@ -249,6 +219,10 @@ class Employeedetails extends BaseController $photo->move($uploadDir, $newName); $Picture = $newName; } + else{ + echo "Incorrect file format provided"; + return false; + } } } // $Profile = $this->request->getPost('photo'); @@ -661,38 +635,7 @@ class Employeedetails extends BaseController } /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ - /* To Update the employee details*/ + function UpdateEmployee() @@ -700,41 +643,12 @@ class Employeedetails extends BaseController $EmpId = $this->request->getGet('empId'); - $PictureName = $this->request->getPost('Image'); - $ModifyPictureName = $this->request->getPost('ModifyImage'); + //if it is empty it means the default image is selected + $oldPictureName = $this->request->getPost('oldImageName'); $Picture = ""; - if ($PictureName != '') { - - - if (strlen((string)$ModifyPictureName) == 0) { - - $Picture = $PictureName; - } else { - - $photo = $this->request->getFile('ModifyImage'); - if (!$photo || !$photo->isValid()) { - $photo = $this->request->getFile('photo'); - } - if (isset($photo)) { - if ($photo->isValid() && !$photo->hasMoved()) { - $uploadDir = ROOTPATH . 'public/uploads/images/'; - $allowedTypes = ['jpg', 'jpeg', 'png', 'gif']; - if (in_array($photo->getExtension(), $allowedTypes)) { - $newName = $photo->getRandomName(); - if (!is_dir($uploadDir)) { - mkdir($uploadDir, 0777, true); - } - $photo->move($uploadDir, $newName); - $Picture = $newName; - } - } - } - } - } else { - //echo 'Not Exists'; - $photo = $this->request->getFile('photo'); - if (isset($photo)) { - if ($photo->isValid() && !$photo->hasMoved()) { + $photo = $this->request->getFile('photo'); + + if (isset($photo) && $photo->isValid() && !$photo->hasMoved()) { $uploadDir = ROOTPATH . 'public/uploads/images/'; $allowedTypes = ['jpg', 'jpeg', 'png', 'gif']; if (in_array($photo->getExtension(), $allowedTypes)) { @@ -745,10 +659,11 @@ class Employeedetails extends BaseController $photo->move($uploadDir, $newName); $Picture = $newName; } - } + + }else{ + $Picture=$oldPictureName; } - } - //echo $Picture; + $FirstName = $this->request->getPost('FirstName'); $LastName = $this->request->getPost('LastName'); diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php index ac329ca6..80ab9aca 100755 --- a/app/Controllers/Inwardgateregister.php +++ b/app/Controllers/Inwardgateregister.php @@ -1670,64 +1670,72 @@ function updateIGRWeight(){ } public function downloadFilesAsZip($igrno) -{ - // Get all file details for the given IGR number - $fileDetails = $this->inwardgateregister_model->getAllIgrFileDetails($igrno); - if (empty($fileDetails)) { - // Display an alert message - echo ''; - redirect('ViewIGR', 'refresh'); - return; - } - - // Define the root path for files - $rootPath = ROOTPATH . 'public/uploads/Igrfiles/'; - - // Create a new ZIP archive - $zip = new ZipArchive(); - - // Define the name of the ZIP file - $zipFileName = $igrno . '.zip'; - $zipFilePath = $rootPath . $zipFileName; - - if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) { - $filesAdded = false; - - // Add each file to the ZIP archive - foreach ($fileDetails as $file) { - $filePath = $rootPath . $file->file; - if (file_exists($filePath)) { - if (!$zip->addFile($filePath, $file->filename)) { - // Handle error when adding file to ZIP - echo ''; - $zip->close(); - redirect('ViewIGR', 'refresh'); - return; - } - $filesAdded = true; - } - } - - // Close the ZIP archive - $zip->close(); - - if ($filesAdded) { - // Return the ZIP file as a download - return $this->response->download($zipFilePath, null)->setFileName($zipFileName); - } else { - // Delete the empty ZIP file - if (file_exists($zipFilePath)) { - unlink($zipFilePath); - } - echo ''; - redirect('ViewIGR', 'refresh'); - return; - } - } else { - echo ''; - redirect('ViewIGR', 'refresh'); - return; - } -} + { + // Get all file details for the given IGR number + $fileDetails = $this->inwardgateregister_model->getAllIgrFileDetails($igrno); + if (empty($fileDetails)) { + echo ''; + redirect('ViewIGR', 'refresh'); + return; + } + + // Define the root path for files + $rootPath = ROOTPATH . 'public/uploads/Igrfiles/'; + + // Check if root path is valid + if (!is_dir($rootPath)) { + echo ''; + return; + } + + // Create a new ZIP archive + $zip = new ZipArchive(); + $zipFileName = $igrno . '.zip'; + $zipFilePath = $rootPath . $zipFileName; + + if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) { + $filesAdded = false; + + // Add each file to the ZIP archive + foreach ($fileDetails as $file) { + $filePath = $rootPath . $file->file; + + // Check if file exists + if (!file_exists($filePath)) { + log_message('error', 'File not found: ' . $filePath); + continue; + } + + $sanitizedFilename = preg_replace('/[^a-zA-Z0-9_\-\.]/', '_', $file->filename); + + if (!$zip->addFile($filePath, $sanitizedFilename)) { + log_message('error', 'Failed to add file: ' . $sanitizedFilename); + $zip->close(); + redirect('ViewIGR', 'refresh'); + return; + } + $filesAdded = true; + } + + // Close the ZIP archive + $zip->close(); + + if ($filesAdded) { + return $this->response->download($zipFilePath, null)->setFileName($zipFileName); + } else { + if (file_exists($zipFilePath)) { + unlink($zipFilePath); + } + echo ''; + redirect('ViewIGR', 'refresh'); + return; + } + } else { + echo ''; + redirect('ViewIGR', 'refresh'); + return; + } + } + } \ No newline at end of file diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php index a7f60b98..4df396b0 100755 --- a/app/Controllers/Sales.php +++ b/app/Controllers/Sales.php @@ -24,16 +24,43 @@ class Sales extends BaseController $this->isLoggedIn(); } + function formatIndianCurrency($amount) { + // Convert the amount to a string with 2 decimal places + $formattedAmount = number_format((float)$amount, 2, '.', ''); + + // Split the integer and decimal parts + $parts = explode('.', $formattedAmount); + $integerPart = $parts[0]; + $decimalPart = isset($parts[1]) ? $parts[1] : '00'; + + // Format the integer part for Indian numbering system + if (strlen($integerPart) > 3) { + $lastThreeDigits = substr($integerPart, -3); // Get the last 3 digits (thousands) + $remainingDigits = substr($integerPart, 0, -3); // Get the remaining digits + + // Add commas to the remaining digits in groups of 2 + $remainingDigits = preg_replace('/\B(?=(\d{2})+(?!\d))/', ',', $remainingDigits); + + // Combine the formatted parts + $integerPart = $remainingDigits . ',' . $lastThreeDigits; + } + + // Combine the integer and decimal parts + return $integerPart . '.' . $decimalPart; + } public function sales_dashboard() { $this->global['pageTitle'] = 'Sales Dashboard'; $data = []; $data['today_sales'] = $this->ipinvoice_model->todaySales(); + $data['today_sales']->Sales = $this->formatIndianCurrency($data['today_sales']->Sales, 2, '.', ','); $data['this_month_sales'] = $this->ipinvoice_model->thisMonthSales(); + $data['this_month_sales']->Sales = $this->formatIndianCurrency($data['this_month_sales']->Sales); $data['this_year_sales'] = $this->ipinvoice_model->thisYearSales(); + $data['this_year_sales']->Sales = $this->formatIndianCurrency($data['this_year_sales']->Sales, 2, '.', ','); $data['this_year_sales_trend'] = $this->ipinvoice_model->thisYearSalesTrend(); $data['get_today_invoices'] = $this->ipinvoice_model->getTodayInvoices(); - + // Define months from April to March $months = ['Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan', 'Feb', 'Mar']; diff --git a/app/Models/Employeedetails_model.php b/app/Models/Employeedetails_model.php index 1e2d699c..7b1a7333 100755 --- a/app/Models/Employeedetails_model.php +++ b/app/Models/Employeedetails_model.php @@ -19,7 +19,7 @@ class Employeedetails_model extends Model $builder = $this->db->table('t_employee_details Emp') ->select(' Emp.*,Dep.DepartmentName as DepartmentName') ->join('t_departmentdetails Dep', 'Emp.Departmentcode = Dep.DEPCode', 'left') - ->orderBy("Emp.EmpID", "desc"); + ->orderBy("Emp.EmpID", "asc"); $query = $builder->get(); diff --git a/app/Models/Purchaseorder_model.php b/app/Models/Purchaseorder_model.php index 47e86528..b043b4ed 100755 --- a/app/Models/Purchaseorder_model.php +++ b/app/Models/Purchaseorder_model.php @@ -389,8 +389,6 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath, function purchaseorderListing($forwhat ,$fromDate='',$toDate='') { - - $builder = $this->db->table('t_purchaseorder_master POMast')->distinct() ->select('POMast.PONO,POMast.CreatedDate,supp.SupplierName,TotalOrderValue,PODate,Stat.StatusName,Stat.StatusCode,POMast.POType as ReqType,DeliveryDate,DeliverySchedule,DeliveryOption,POMast.CapitalRange') @@ -1595,8 +1593,6 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath, function getPOList($type, $fromDate , $toDate) { - - $builder = $this->db->table('t_purchaseorder_master mast')->distinct() ->select('mast.PODate,mast.PONO,mast.TotalOrderValue,st.StatusCode,st.StatusName,emp.FirstName,mast.CreatedDate,ccm.CostCenterName,ccm.CostCenterCode,mast.POType as RType,mast.Remarks,DepartmentName,mast.ApprovedBy,(select EmpID from tbl_users where userId=mast.ApprovedBy )as EID,rmast.ReqType,mast.Status,mast.CapitalRange, (select FirstName from t_employee_details where EmpID=EID)as Approver,sup.SupplierName,sup.MSME') diff --git a/app/Views/AmendPOlist.php b/app/Views/AmendPOlist.php index 48768bd1..3b7ddfe9 100755 --- a/app/Views/AmendPOlist.php +++ b/app/Views/AmendPOlist.php @@ -4,8 +4,7 @@ .pagination { margin: 0px !important; } - - - + @@ -609,7 +593,9 @@ @@ -621,6 +607,7 @@ + + @@ -658,16 +650,16 @@