diff --git a/app/Controllers/User.php b/app/Controllers/User.php index c3f79358..34702d83 100644 --- a/app/Controllers/User.php +++ b/app/Controllers/User.php @@ -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 "
";
+        // print_r($data['Department']);
+        // die;
+        
+        // echo "
";
+        // print_r($data['Department']);die;
         $this->global['pageTitle'] = 'Add New User';
         $this->loadViews("addUser", $this->global, $data, NULL);
         // }
diff --git a/app/Models/User_model.php b/app/Models/User_model.php
index 0d996a9b..2cd57b27 100644
--- a/app/Models/User_model.php
+++ b/app/Models/User_model.php
@@ -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();
diff --git a/app/Views/addUser.php b/app/Views/addUser.php
index 4b7e8135..b1a13a43 100644
--- a/app/Views/addUser.php
+++ b/app/Views/addUser.php
@@ -81,22 +81,6 @@
                                                                 ?>
                                                             
                                                         
-
-                                                        
- - -
@@ -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(); diff --git a/app/Views/editOld.php b/app/Views/editOld.php index c12f76cd..b2b8d5d8 100644 --- a/app/Views/editOld.php +++ b/app/Views/editOld.php @@ -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))
-
- - -
+
@@ -91,12 +86,12 @@ if(!empty($EmpList))
-
+
+
+
-
-
@@ -105,7 +100,6 @@ if(!empty($EmpList))
- @@ -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:"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:"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'; diff --git a/app/Views/userListing.php b/app/Views/userListing.php index a4d87552..8df509ef 100644 --- a/app/Views/userListing.php +++ b/app/Views/userListing.php @@ -165,8 +165,8 @@ url: "user/deleteUser", success: function(data) { if (data) { - $('#content').loader('hide'); - alert(data); + // $('#content').loader('hide'); + // alert(data); location.reload();