CHANGE_USER_CURD

This commit is contained in:
aadhavan valli 2024-09-02 17:07:58 +05:30
parent 9f1c0ab40e
commit 0c0170a7cc
5 changed files with 30 additions and 52 deletions

View File

@ -7,6 +7,7 @@ use App\Controllers\BaseController;
use CodeIgniter\Validation\Exceptions\ValidationException;
use App\Models\Costcenter_model;
use App\Models\Department_model;
use App\Models\Dashboard_model;
use App\Models\Employeedetails_model;
use App\Models\User_model;
@ -26,6 +27,7 @@ require_once 'vendor/autoload.php';
class User extends BaseController
{
protected $costcenter_model;
protected $department_model;
protected $dahsboard_Model;
protected $employeedetails_model;
protected $user_model;
@ -42,6 +44,7 @@ class User extends BaseController
$this->dahsboard_Model = new Dashboard_model();
$this->costcenter_model = new Costcenter_model();
$this->department_model = new Department_model();
$this->employeedetails_model = new employeedetails_model();
$this->user_model = new User_model();
$this->ipinvoice_model = new Ipinvoice_model();
@ -918,8 +921,14 @@ class User extends BaseController
// {
$data['EmpList'] = $this->user_model->getAllEmployees();
$data['roles'] = $this->user_model->getUserRoles();
// $data['Department'] = $this->costcenter_model->getDepartment();
$data['Department'] = json_decode(json_encode($this->department_model->departmentListing()), true);
// echo "<pre>";
// print_r($data['Department']);
// die;
// echo "<pre>";
// print_r($data['Department']);die;
$this->global['pageTitle'] = 'Add New User';
$this->loadViews("addUser", $this->global, $data, NULL);
// }

View File

@ -134,14 +134,17 @@ class User_model extends Model
* @param number $userId : This is user id
* @return boolean $result : TRUE / FALSE
*/
function deleteUser($userId, $userInfo)
function deleteUser($userId)
{
// Delete the user record
$this->db->table('tbl_users')
->where('userId', $userId)
->update($userInfo);
->delete();
// Return the number of affected rows to confirm the deletion
return $this->db->affectedRows();
}
/**
@ -215,7 +218,9 @@ class User_model extends Model
$builder = $this->db->table('t_employee_details EMP')
->select('EMP.EmpID,EMP.FirstName,EMP.LastName,EMP.Designation,EMP.EmailId,EMP.ContactNumber,DEPT.DEPCode,DEPT.DepartmentName')
->join('t_departmentdetails DEPT', 'EMP.Departmentcode = DEPT.DEPCode')
->where('EMP.IsActive ', 1);
->join('tbl_users U', 'EMP.EmpID = U.EmpID', 'left')
->where('EMP.IsActive ', 1)
->where('U.EmpID IS NULL');
$query = $builder->get();
return $query->getResult();
}
@ -311,10 +316,9 @@ GROUP BY financial_year ";
function findEmp($EmpId)
{
$builder = $this->db->table('tbl_users')
->select('tbl_users.*, t_employee_details.*')
->join('t_employee_details', 'tbl_users.EmpID = t_employee_details.EmpID' ,'left')
->where('tbl_users.EmpID', $EmpId);
$builder = $this->db->table('t_employee_details')
->select('t_employee_details.*')
->where('t_employee_details.EmpID', $EmpId);
$query = $builder->get();
return $query->getResult();

View File

@ -81,22 +81,6 @@
?>
</select>
</div>
<div class="col-md-3">
<label for="Department">Department</label>
<select class="form-control required" id="Department" name="Department">
<option value="0">Select Department</option>
<?php
if (!empty($departments)) {
foreach ($departments as $dt) {
?>
<option value="<?php echo $dt->departmentId ?>"><?php echo $dt->departments ?></option>
<?php
}
}
?>
</select>
</div>
</div>
<div class="form-row" style="margin-top:20px">
@ -194,7 +178,6 @@
$("#Designation").val(data.userInfo[0].Designation);
$("#MailID").val(data.userInfo[0].EmailId);
$("#ContactNo").val(data.userInfo[0].ContactNumber);
$("#Department").val(data.userInfo[0].DepartmentName);
} else {
alert('Employee not found');
}
@ -210,7 +193,6 @@
$("#Designation").val('');
$("#MailID").val('');
$("#ContactNo").val('');
$("#Department").val('');
}
});
});
@ -218,20 +200,17 @@
$('#addPop').click(function() {
if ($('#distriList option:selected').val() != null) {
if ($('#distriList option:selected').val() == 0) {
alert('please select Department');
} else {
var tempSelect = $('#distriList option:selected').val();
var tempText = $('#distriList option:selected').text();
var o = new Option(tempText, tempSelect);
var hidval = tempSelect;
var orgVal = $('#txtSelectedDepartment').val();
var Selectedval = ''
if (orgVal != '') {
Selectedval = orgVal + ':' + hidval;
} else {
Selectedval = hidval
}
$('#txtSelectedDepartment').val(Selectedval);
$(o).html(tempText);
$("#selectDistriList").append(o);
$('#distriList option:selected').remove();

View File

@ -8,7 +8,6 @@ $LastName = '';
$ContactNo = '';
$EmailId = '';
$Role = '';
$Department = '';
$Designation = '';
$RoleName = '';
if(!empty($EmpRole))
@ -30,7 +29,6 @@ if(!empty($EmpList))
$ContactNo = $Emp->ContactNumber;
$EmailId = $Emp->EmailId;
$Department = $Emp->DepartmentName;
$Designation = $Emp->Designation;
}
@ -79,10 +77,7 @@ if(!empty($EmpList))
</div>
</div>
<div class="form-row">
<div class="col-md-3">
<label class="col-form-label" for="Department">Department</label>
<input type="text" class="form-control required" value="<?php echo $Department ?>" readonly id="Department" name="Department" minlength="10" maxlength="10">
</div>
<div class="col-md-3">
<label for="MailID">Email address</label>
<input type="text" class="form-control required email" value="<?php echo $EmailId ?>" readonly id="MailID" name="MailID" maxlength="128">
@ -91,12 +86,12 @@ if(!empty($EmpList))
<label for="ContactNo">Contact Number</label>
<input type="text" class="form-control required digits" value="<?php echo $ContactNo ?>" readonly id="ContactNo" name="ContactNo" minlength="10" maxlength="10">
</div>
<div class="col-md-3">
</div>
<div class="form-row">
<div class="col-md-3">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" required name="password" maxlength="10">
</div>
</div>
<div class="form-row">
<div class="col-md-3">
<label for="cpassword">Confirm Password</label>
<input type="password" class="form-control equalTo" id="cpassword" name="cpassword" maxlength="10">
@ -105,7 +100,6 @@ if(!empty($EmpList))
</div>
<div class="form-group text-right mt-3">
<input type="hidden" name="txtSelectedDepartment" id="txtSelectedDepartment">
<input type="hidden" name="txtEmpid" id="txtEmpid" value="<?php echo $EmpId ?>">
<input type="reset" id="reset" class="btn btn-reset" style="background-color: red;color: white;margin-right: 15px;" value="Reset">
<input type="submit" class="btn btn-success" value="Submit">
@ -158,7 +152,6 @@ if(!empty($EmpList))
$('#addPop').click(function () {
if ($('#distriList option:selected').val() != null) {
if($('#distriList option:selected').val()==0 ){
alert('please select Department');
}
else{
var tempSelect = $('#distriList option:selected').val();
@ -167,7 +160,6 @@ if(!empty($EmpList))
var o = new Option(tempText,tempSelect);
var hidval = tempSelect;
var orgVal = $('#txtSelectedDepartment').val();
//salert(orgVal);
var Selectedval = ''
@ -179,9 +171,7 @@ if(!empty($EmpList))
{
Selectedval = hidval
}
$('#txtSelectedDepartment').val(Selectedval);
var Department= $('#txtSelectedDepartment').val();
$(o).html(tempText);
@ -196,7 +186,7 @@ if(!empty($EmpList))
$('#content').loader('show');
$.ajax({
data:{Eid:Eid,Department:Department},
data:{Eid:Eid},
type:"POST",
url:"<?php echo base_url() ?>user/Adduserdepartment",
@ -205,7 +195,6 @@ if(!empty($EmpList))
{
$('#content').loader('hide');
alert(data);
$('#txtSelectedDepartment').val('');
$('#txtRowCount').val('');
//window.location = baseurl + 'CostCenter/CostListing';
@ -251,15 +240,13 @@ if(!empty($EmpList))
$("#distriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected");
$("#distriList").val(tempSelect);
$('#txtSelectedDepartment').val(tempSelect);
tempSelect = '';
var Department= $('#txtSelectedDepartment').val();
$('#content').loader('show');
$.ajax({
data:{Eid:Eid,Department:Department},
data:{Eid:Eid},
type:"POST",
url:"<?php echo base_url() ?>user/Deleteuserdepartment",
success:function(data) {
@ -267,7 +254,6 @@ if(!empty($EmpList))
{
$('#content').loader('hide');
alert(data);
$('#txtSelectedDepartment').val('');
$('#txtRowCount').val('');
//window.location = baseurl + 'CostCenter/CostListing';

View File

@ -165,8 +165,8 @@
url: "<?php echo base_url() ?>user/deleteUser",
success: function(data) {
if (data) {
$('#content').loader('hide');
alert(data);
// $('#content').loader('hide');
// alert(data);
location.reload();