tracker issues

This commit is contained in:
VE10-Sanjeev 2025-04-19 13:32:35 +00:00
parent cc531612c0
commit 505f66696b
8 changed files with 144 additions and 65 deletions

View File

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

View File

@ -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()
{

View File

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

View File

@ -18,8 +18,8 @@
<div class="card-body">
<div class="row">
<div class="col-12">
<div class="p-2">
<form role="form" id="addUser" action="<?php echo base_url() ?>addNewUser" method="post">
<form role="form" id="addUser" action="<?php echo base_url() ?>addNewUser" method="post">
<div class="p-2">
<div class="box-body">
<!-- Supplier Information -->
<div class="col-md-12" style="margin-bottom: 27px;">
@ -63,7 +63,7 @@
<input type="text" class="form-control required digits" readonly id="ContactNo" name="ContactNo" minlength="10" maxlength="10">
</div>
<div class="col-md-3">
<label for="Role">Role</label>
<label for="Role">Role<span class="badge">*</span></label>
<select class="form-control required" id="role" name="role" required>
<option value="0">Select Role</option>
<?php
@ -90,7 +90,7 @@
<input type="reset" id="reset" class="btn btn-reset" style="background-color: red;color: white; margin-right: 15px;width: 80px;" value="Reset" />
<input type="submit" onclick="return Validate();" value="Submit" class="btn btn-success">
</div>
</div>
</div>
</form>
</div>
</div>
@ -181,58 +181,67 @@
$("#ContactNo").val('');
}
});
$('#MailID').change(function() {
var mailID = $(this).val();
var empID = ''// $('#EmpList').val();
if (mailID) {
$('#loader').show();
$.ajax({
url: "<?php echo base_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.");
}
});
</script>
<script>
function Validate() {
var isValid = true;
var isValid;
var fname = document.getElementById('FirstName').value;
var role = document.getElementById('role').value;
var email = document.getElementById('MailID').value;
var emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
var password = document.getElementById('password').value;
var cpassword = document.getElementById('cpassword').value;
if (!fname) {
alert('First Name is required');
isValid = false;
}
var email = document.getElementById('MailID').value;
var emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailPattern.test(email)) {
}else if (!emailPattern.test(email)) {
alert('Invalid email address');
isValid = false;
}
var password = document.getElementById('password').value;
var cpassword = document.getElementById('cpassword').value;
if (password !== cpassword) {
}else if (role === "0") {
alert('Role is required');
isValid = false;
}else if(!password){
alert('Missing Passwords');
isValid = false;
}else if (password !== cpassword) {
alert('Passwords do not match');
isValid = false;
}else{
isValid = true;
$('#loader').show();
}
return isValid;

View File

@ -285,4 +285,32 @@ if (!empty($EmpList)) {
alert("Before remove please select any position.");
}
});
$('#MailID').change(function() {
var mailID = $(this).val();
var empID = ''// $('#EmpList').val();
if (mailID) {
$('#loader').show();
$.ajax({
url: "<?php echo base_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");
}
});
</script>>

View File

@ -589,7 +589,6 @@
</td>
<td style="max-width:80px;text-align:right;">
<!-- $record->driver_salary_amount -->
<?php echo number_format($sum_of_amount, 2, '.', ''); $totalworkedSalary[] = $sum_of_amount; ?>
</td>
@ -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
}

View File

@ -160,15 +160,14 @@
<?php } else { ?>
<a
class="auditor-restricted-btn"
href="<?php echo base_url() . 'user/editOld?UID=' . $record->userId . '&EMPID=' . $record->EmpID; ?>">
<a href="<?php echo base_url() . 'user/editOld?UID=' . $record->userId . '&EMPID=' . $record->EmpID; ?>">
<i class="fas fa-edit"></i>
</a>
&nbsp;&nbsp;
<a onclick="confirmDeleteUser(event)"
<a class="auditor-restricted-btn"
onclick="confirmDeleteUser(event)"
href="<?php echo base_url() . 'user/deleteUser?UID=' . $record->userId . '&EMPID=' . $record->EmpID; ?>">
<i class="fas fa-trash"></i>
</a>

View File

@ -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+" </br></br>";
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 <b> ` " + str2 + " ` </b> by " + record.FullName +
" on " + record.indian_date + " at " + record.indian_time;
} else {
sentence += record.IGR_No + " was <b> ` CREATED ` </b> by " + record.FullName +
sentence += record.IGR_No + " was <b> ` GENERATED ` </b> 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+" <b> ` "+ displayOldData + " ` </b> was Updated into <b> ` " + displayNewData + " ` </b> by "+record.FullName+ " on "+record.indian_date+" at "+record.indian_time;