changes in master details-final vadivel J 21-11-2024

This commit is contained in:
vadivelJ96 2024-11-22 13:50:58 +05:30
parent dd515fafb6
commit 387c2af713
6 changed files with 112 additions and 43 deletions

View File

@ -39,7 +39,8 @@ $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'userListing/(:num)', 'User::us
$routes->get('user/editOld', 'User::editOld');
$routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'editUser', 'User::editUser');
$routes->post('user/Deleteuserdepartment', 'User::Deleteuserdepartment');
$routes->post('user/deleteUser', 'User::deleteUser');
$routes->get('user/deleteUser', 'User::deleteUser');
$routes->get('user/reActivateUser', 'User::reActivateUser');
// Supplier Routes
$routes->get('supplierlisting', 'Supplier::index'); // list supplier

View File

@ -1157,16 +1157,32 @@ class User extends BaseController
*/
function deleteUser()
{
echo 'Delete';
$Uid = $this->request->getPost('id');
$Uid = $this->request->getGet('UID');
$updatedDate = get_current_date_time();
$userInfo = array('isDeleted' => 1, 'updatedBy' => $this->vendorId, 'updatedDtm' => $updatedDate);
$updateInfo = array('isDeleted' => 1, 'updatedBy' => $this->vendorId, 'updatedDtm' => $updatedDate);
$result = $this->user_model->userActivation($Uid, $updateInfo);
$result = $this->user_model->deleteUser($Uid, $userInfo);
return redirect()->route('userListing');
}
echo 'Succssfully change the user status to InAcive';
function reActivateUser()
{
$Uid = $this->request->getGet('UID');
$updatedDate = get_current_date_time();
$updateInfo = array('isDeleted' => 0, 'updatedBy' => $this->vendorId, 'updatedDtm' => $updatedDate);
$result = $this->user_model->userActivation($Uid, $updateInfo);
return redirect()->route('userListing');
}

View File

@ -18,13 +18,12 @@ class User_model extends Model
function userListing()
{
$builder = $this->db->table('t_employee_details EMP')
->select('user.createdDtm,EMP.EmpID,EMP.FirstName,EMP.LastName,EMP.Designation,user.email as EmailId,EMP.ContactNumber,
->select('user.isDeleted,user.createdDtm,EMP.EmpID,EMP.FirstName,EMP.LastName,EMP.Designation,user.email as EmailId,EMP.ContactNumber,
DEPT.DEPCode,DEPT.DepartmentName,role.role,user.userId')
->join('t_departmentdetails DEPT', 'EMP.Departmentcode = DEPT.DEPCode')
->join('tbl_users user', 'user.EmpID = EMP.EmpID')
->join('tbl_roles role', 'user.roleId = role.roleId')
->orderBy('user.createdDtm', 'desc')
->where('user.isDeleted !=', 1);
->orderBy('user.createdDtm', 'desc');
$query = $builder->get();
@ -134,13 +133,13 @@ class User_model extends Model
* @param number $userId : This is user id
* @return boolean $result : TRUE / FALSE
*/
function deleteUser($userId)
function userActivation($Uid, $updateInfo)
{
// Delete the user record
$this->db->table('tbl_users')
->where('userId', $userId)
->delete();
$this->db->table('tbl_users')
->where('userId', $Uid)
->update($updateInfo);
// Return the number of affected rows to confirm the deletion
return $this->db->affectedRows();
}

View File

@ -172,7 +172,7 @@
<a data-toggle="tooltip"
href="<?php echo base_url() ?>loadView_updateFactoryMachineMasterDetail?id=<?php echo $record['id'] ?>">
<i class="fa fa-pencil-alt" data-toggle="tooltip"
<i class="fa fa-edit" data-toggle="tooltip"
title="Click here to Edit machine detail "></i>
&nbsp;&nbsp;&nbsp;
</a>
@ -198,6 +198,7 @@
</tbody>
</table>
<p>( Note :The entries count includes archived data... )</p>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->

View File

@ -97,7 +97,6 @@
</div>
<div class="error" id="error"></div>
</form>

View File

@ -87,6 +87,21 @@
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
<div style="margin-left:auto">
<div class="form-check" style="margin-right: 25px;">
<input class="form-check-input" type="checkbox" id="showArchiveId"
name="showArchive" value="1" onchange="showArchiveList()"
style="width: 18px; height: 18px;">
<label class="form-check-label" for="showArchiveId"
style="font-size: 1rem; margin-left: 8px;">
Show Archive
</label>
</div>
</div>
<div class="error" id="error"></div>
</form>
<div class="card-body" style="overflow-x:scroll;">
@ -109,8 +124,16 @@
<?php
if (!empty($userRecords)) {
foreach ($userRecords as $record) {
?>
<tr>
<tr class="<?php if ($record->isDeleted == 1) {
echo "deactivatedRow";
} ?>"
style="<?php if ($record->isDeleted == 1) {
echo "display:none";
} ?>">
<?php if (date('d-m-Y', strtotime($record->createdDtm)) == "30-11--0001") {
$cdate = '00-00-0000';
} else {
@ -125,9 +148,30 @@
<td><?php echo $record->DepartmentName ?></td>
<td><?php echo $record->role ?></td>
<td>
<a href="<?php echo base_url() . 'user/editOld?UID=' . $record->userId . '&EMPID=' . $record->EmpID; ?>"><i class="fas fa-pencil-alt"></i>&nbsp;&nbsp;&nbsp;</a>
<?php if ($record->isDeleted == 1) { ?>
<a onclick="confirmReActivateUser(event)"
href="<?php echo base_url() . 'user/reActivateUser?UID=' . $record->userId . '&EMPID=' . $record->EmpID; ?>">
<i class="fas fa-key"></i>
</a>
<?php } else { ?>
<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)"
href="<?php echo base_url() . 'user/deleteUser?UID=' . $record->userId . '&EMPID=' . $record->EmpID; ?>">
<i class="fas fa-trash"></i>
</a>
<?php } ?>
<a onclick="deleteUser(<?php echo $record->userId; ?>)"><i class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp;</a>
</td>
</tr>
<?php
@ -137,6 +181,7 @@
</tbody>
</table>
<p>( Note :The entries count includes archived data... )</p>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
@ -150,32 +195,14 @@
<script type="text/javascript">
function confirmReActivateUser(event) {
var answer = confirm(" Do you want to Re activate the user from the List?")
if (answer) {return;}else{event.preventDefault();}
}
function deleteUser(userid) {
function confirmDeleteUser(event) {
var answer = confirm(" Do you want to delete the user from the List?")
if (answer) {
$.ajax({
data: {
id: userid
},
type: "POST",
url: "<?php echo base_url() ?>user/deleteUser",
success: function(data) {
if (data) {
// $('#content').loader('hide');
// alert(data);
location.reload();
} else {
alert("Error");
}
}
});
}
if (answer) {return;}else{event.preventDefault();}
}
</script>
<script>
@ -265,4 +292,30 @@
}
});
});
function showArchiveList() {
let isChecked = $("#showArchiveId").prop('checked');
// Show or hide the rows based on checkbox status
$(".deactivatedRow").each(function () {
if (isChecked) {
$(this).show();
} else {
$(this).hide();
}
});
}
$(document).ready(function () {
let table = $('#user_list_table').DataTable();
showArchiveList();
table.on('draw', function () {
showArchiveList();
});
});
</script>