From 505f66696b93e2c3a9753c86574c0b9ba1998654 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 19 Apr 2025 13:32:35 +0000 Subject: [PATCH] tracker issues --- app/Config/Routes.php | 1 + app/Controllers/User.php | 40 +++++++----- app/Models/User_model.php | 16 +++++ app/Views/addUser.php | 93 +++++++++++++++------------- app/Views/editOld.php | 28 +++++++++ app/Views/monthlypayinputs.php | 17 ++++- app/Views/userListing.php | 7 +-- app/Views/viewinwardgateregister.php | 7 ++- 8 files changed, 144 insertions(+), 65 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index c92e8115..2ec88ef2 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -41,6 +41,7 @@ $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'editUser', 'User::editUser'); $routes->post('user/Deleteuserdepartment', 'User::Deleteuserdepartment'); $routes->get('user/deleteUser', 'User::deleteUser'); $routes->get('user/reActivateUser', 'User::reActivateUser'); +$routes->get('isEmailExists', 'User::isEmailExists'); // Supplier Routes $routes->match(["GET","POST"],'supplierlisting', 'Supplier::index'); // list supplier diff --git a/app/Controllers/User.php b/app/Controllers/User.php index 66466711..2f55a36d 100755 --- a/app/Controllers/User.php +++ b/app/Controllers/User.php @@ -1020,15 +1020,11 @@ class User extends BaseController // Validation passed $EmpID = $this->request->getPost('EmpList'); - $roleId = !empty($this->request->getPost('role')) ? $this->request->getPost('role') : '2' ; + $roleId = $this->request->getPost('role'); $password = (string)$this->request->getPost('password'); $Createddt = date('Y-m-d H:i:s'); $email = $this->request->getPost('MailID'); - $SelectedDepartment = (string)$this->request->getPost('txtSelectedDepartment'); - $comma_separated = explode(':', $SelectedDepartment); - if (count($comma_separated) == 1 && in_array('DEP27', $comma_separated)) { - $roleId = '6'; - } + $userInfo = [ 'email' => $email, 'EmpID' => $EmpID, @@ -1040,16 +1036,7 @@ class User extends BaseController $result = $this->user_model->addNewUser($userInfo); - if ($SelectedDepartment != '') { - foreach ($comma_separated as $DeptCode) { - $userdept = [ - 'EmpID' => $EmpID, - 'Departmentcode' => $DeptCode - ]; - $access = $this->user_model->addAccess($userdept); - } - } - + if ($result > 0) { // return redirect()->to('userListing')->with('success', 'New user created successfully!'); $this->session->setFlashdata('success', 'New user created successfully!'); @@ -1072,6 +1059,27 @@ class User extends BaseController }; } + function isEmailExists(){ + + + $MailID = $this->request->getPost('MailID'); + $empID = $this->request->getPost('EmpID'); + + + if (!$MailID) { + return $this->response->setJSON(['success' => false, 'message' => 'Mail ID not provided']); + } + + $isEmailExists = $this->user_model->isEmailExists($MailID,$empID); + + if ($isEmailExists) { + return $this->response->setJSON(['success' => true, 'message' => 'Email Already Exsiting']); + } else { + return $this->response->setJSON(['success' => false, 'message' => '']); + } + + } + function Deleteuserdepartment() { diff --git a/app/Models/User_model.php b/app/Models/User_model.php index ebafde7c..b0656cdf 100755 --- a/app/Models/User_model.php +++ b/app/Models/User_model.php @@ -340,4 +340,20 @@ GROUP BY financial_year "; return $query->getResult(); } + + + public function isEmailExists($email, $excludeEmpID = null) + { + $builder = $this->db->table('tbl_users'); + $builder->select('email'); + $builder->where('email', $email); + + if (!empty($excludeEmpID)) { + $builder->where('EmpID !=', $excludeEmpID); + } + + $query = $builder->get(); + return $query->getNumRows() > 0; + } + } \ No newline at end of file diff --git a/app/Views/addUser.php b/app/Views/addUser.php index d23d6733..e2c3a463 100755 --- a/app/Views/addUser.php +++ b/app/Views/addUser.php @@ -18,8 +18,8 @@
-
-
+ +
@@ -63,7 +63,7 @@
- +
-
+
@@ -181,58 +181,67 @@ $("#ContactNo").val(''); } }); + + $('#MailID').change(function() { + var mailID = $(this).val(); + var empID = ''// $('#EmpList').val(); + if (mailID) { + $('#loader').show(); + $.ajax({ + url: "isEmailExists", + type: 'POST', + data: { EmpID:empID,MailID:mailID }, + success: function(data) { + if (data.success) { + $('#loader').hide(); + alert(data.message); + $("#MailID").val(''); + } else { + $('#loader').hide(); + } + }, + error: function() { + $('#loader').hide(); + alert('An Error Occur in this email address'); + $("#MailID").val(''); + } + }); + }else{ + alert("Invalid email address"); + } + }); }); - $('#addPop').click(function() { - if ($('#distriList option:selected').val() != null) { - if ($('#distriList option:selected').val() == 0) {} else { - var tempSelect = $('#distriList option:selected').val(); - var tempText = $('#distriList option:selected').text(); - var o = new Option(tempText, tempSelect); - var hidval = tempSelect; - var Selectedval = '' - if (orgVal != '') { - Selectedval = orgVal + ':' + hidval; - } else { - Selectedval = hidval - } - $(o).html(tempText); - $("#selectDistriList").append(o); - $('#distriList option:selected').remove(); - $("#distriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected"); - $("#selectDistriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected"); - tempSelect = ''; - tempText = ''; - Selectedval = ''; - } - } else { - alert("Before add please select any position."); - } - }); > \ No newline at end of file diff --git a/app/Views/monthlypayinputs.php b/app/Views/monthlypayinputs.php index 4d2e8eef..73838c06 100755 --- a/app/Views/monthlypayinputs.php +++ b/app/Views/monthlypayinputs.php @@ -589,7 +589,6 @@ - @@ -819,6 +818,22 @@ $(document).ready(function () { let ws = XLSX.utils.table_to_sheet(table); // Convert modified table to sheet let wb = XLSX.utils.book_new(); // Create a new workbook + var range = XLSX.utils.decode_range(ws['!ref']); + + // Auto-size columns + let colWidths = []; + for (let R = range.s.r; R <= range.e.r; ++R) { + for (let C = range.s.c; C <= range.e.c; ++C) { + let cell_ref = XLSX.utils.encode_cell({ c: C, r: R }); + let cell = ws[cell_ref]; + if (cell) { + let val = cell.v ? cell.v.toString() : ''; + colWidths[C] = Math.max(colWidths[C] || 10, val.length); + } + } + } + + ws['!cols'] = colWidths.map(w => ({ wch: w + 2 })); XLSX.utils.book_append_sheet(wb, ws, 'Sheet1'); // Append sheet to workbook XLSX.writeFile(wb, filename || 'export.xlsx'); // Save the file } diff --git a/app/Views/userListing.php b/app/Views/userListing.php index 40309e9d..4dcfb81f 100755 --- a/app/Views/userListing.php +++ b/app/Views/userListing.php @@ -160,15 +160,14 @@ - +    - diff --git a/app/Views/viewinwardgateregister.php b/app/Views/viewinwardgateregister.php index edea47f4..2387b09e 100755 --- a/app/Views/viewinwardgateregister.php +++ b/app/Views/viewinwardgateregister.php @@ -1724,15 +1724,16 @@ // let fieldName = str.replace(/([a-z])([A-Z])/g, '$1 $2'); let sentence = " "; if (parseInt(record.is_add) === 1) { - // sentence += record.IGR_No + " was Created by "+record.FullName+ " on "+record.indian_date+" at "+record.indian_time; + sentence += record.IGR_No + " was Created by "+record.FullName+ " on "+record.indian_date+" at "+record.indian_time+"

"; if (record.field === "IGRStatus") { str1 = record.new_data; str2 = str1.replace(/\bIGR\b/i, '').trim(); + str2 = str2 == "CREATED" ? "GENERATED" : str2; sentence += record.IGR_No + " was ` " + str2 + " ` by " + record.FullName + " on " + record.indian_date + " at " + record.indian_time; } else { - sentence += record.IGR_No + " was ` CREATED ` by " + record.FullName + + sentence += record.IGR_No + " was ` GENERATED ` by " + record.FullName + " on " + record.indian_date + " at " + record.indian_time; } } else if (parseInt(record.is_edit) === 1) { @@ -1743,7 +1744,9 @@ let displayNewData = record.new_data === null || record.new_data === "" ? " " : record.new_data; if (record.field === "IGRStatus") { displayOldData = displayOldData.replace(/\bIGR\b/i, '').trim(); + displayOldData = displayOldData == "CREATED" ? "GENERATED" : displayOldData; displayNewData = displayNewData.replace(/\bIGR\b/i, '').trim(); + displayNewData = displayNewData == "CREATED" ? "GENERATED" : displayNewData; } if(displayNewData || displayOldData ){ sentence += ((record.IGRItem_No) ? record.MaterialName+" ( "+ record.MaterialCode + " ) - " : "")+fieldName+" ` "+ displayOldData + " ` was Updated into ` " + displayNewData + " ` by "+record.FullName+ " on "+record.indian_date+" at "+record.indian_time;