diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 459b9ad8..7da5622c 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -71,6 +71,7 @@ $routes->post('reActivateMaterial', 'Rawmaterialdetails::reActivateMaterial'); // Cost Center Routes $routes->get('costListing', 'CostCenter::index'); $routes->post('fetchCostCenterDetails', 'CostCenter::fetchCostCenterDetails');// for Ajax both add and edit.... +$routes->get('reActivateCostCenter','CostCenter::reActivateCostCenter'); $routes->get('deleteCostCenter', 'CostCenter::deleteCostCenter'); $routes->get('exportcost', 'CostCenter::exportcost'); diff --git a/app/Controllers/CostCenter.php b/app/Controllers/CostCenter.php index 6d00c8ee..8bb19de8 100755 --- a/app/Controllers/CostCenter.php +++ b/app/Controllers/CostCenter.php @@ -92,6 +92,23 @@ class CostCenter extends BaseController return $this->response->setJSON($data); } + + + /** re activate the cost center */ + + public function reActivateCostCenter(){ + + $CostCenterCode = $_GET['CostCenterCode']; + if(!empty($CostCenterCode)){ + $updatedBy = $this->session->get('userId'); + $message = $this->costcenter_model->reActivateCostCenter($CostCenterCode, $updatedBy); + }else{ + $message = "Cost Center Code Not Avalable"; + } + $this->session->setFlashdata('success', $message); + return redirect()->route('costListing'); + + } /** @@ -100,7 +117,7 @@ class CostCenter extends BaseController function deleteCostCenter($CostCode = NULL) { - $CostCenterID = $CostCode ?? $_GET['CostCode']; + $CostCenterID = $CostCode ?? $_GET['CostCenterCode']; if(!empty($CostCenterID)){ $updatedBy = $this->session->get('userId'); $message = $this->costcenter_model->deleteCostCenter($CostCenterID, $updatedBy); diff --git a/app/Controllers/Supplier.php b/app/Controllers/Supplier.php index ffc87275..99473f78 100755 --- a/app/Controllers/Supplier.php +++ b/app/Controllers/Supplier.php @@ -341,7 +341,7 @@ class Supplier extends BaseController $updatedDate = get_current_date_time(); - $SupplierInfo = array('IsActive' => 1, 'updatedBy' => $this->session->get('userId'), 'Updatedon' => $updatedDate); + $SupplierInfo = array('IsActive' => 1, 'updatedBy' => $this->session->get('userId'), 'Updatedon' => $updatedDate); $result = $this->supplier_model->reActivateSupplier($Sid, $SupplierInfo); diff --git a/app/Models/Costcenter_model.php b/app/Models/Costcenter_model.php index f5de56dc..0b4dac08 100755 --- a/app/Models/Costcenter_model.php +++ b/app/Models/Costcenter_model.php @@ -374,7 +374,8 @@ where Dept.DEPCode not in return TRUE; } - function deleteCostCenter($CostCode,$UpdatedBy) + + function reActivateCostCenter( $CostCenterCode , $UpdatedBy) { $tables = [ @@ -387,18 +388,45 @@ where Dept.DEPCode not in foreach ($tables as $table) { $builder = $this->db->table($table); $builder->select('IsActive'); - $builder->where('CostCenterCode', $CostCode); + $builder->where('CostCenterCode', $CostCenterCode); + $query = $builder->get(); + $result = $query->getRowArray(); + + if ($result && $result['IsActive'] != 1) { + // If IsActive is not 1, update it to 1 + $builder->where('CostCenterCode', $CostCenterCode); + $builder->update(['IsActive' => 1,'DeletedBy' => $UpdatedBy ]); + } + } + + return "Cost center $CostCenterCode Reactivated successfully."; + } + + function deleteCostCenter($CostCenterCode,$UpdatedBy) + { + + $tables = [ + 't_costcenter_master', + 't_costcenter_budget', + 't_costcenter_departments' + ]; + + + foreach ($tables as $table) { + $builder = $this->db->table($table); + $builder->select('IsActive'); + $builder->where('CostCenterCode', $CostCenterCode); $query = $builder->get(); $result = $query->getRowArray(); if ($result && $result['IsActive'] != 0) { // If IsActive is not 0, update it to 0 - $builder->where('CostCenterCode', $CostCode); + $builder->where('CostCenterCode', $CostCenterCode); $builder->update(['IsActive' => 0,'DeletedBy' => $UpdatedBy ]); } } - return "Cost center deactivated successfully."; + return "Cost center $CostCenterCode deactivated successfully."; } } ?> \ No newline at end of file diff --git a/app/Models/Supplier_model.php b/app/Models/Supplier_model.php index 1efec261..13a17b8e 100755 --- a/app/Models/Supplier_model.php +++ b/app/Models/Supplier_model.php @@ -43,6 +43,15 @@ class Supplier_model extends Model } + function reActivateSupplier($Sid, $SupplierInfo){ + + $builder = $this->db->table('t_supplierdetailsn') + ->where('SupplierID',$Sid) + ->update($SupplierInfo); + return $this->db->affectedRows(); + + } + function deleteTransporter($Sid, $SupplierInfo){ diff --git a/app/Views/costListing.php b/app/Views/costListing.php index 2805c7d3..831f19ed 100755 --- a/app/Views/costListing.php +++ b/app/Views/costListing.php @@ -43,17 +43,18 @@
- +
-
- Add New Cost List + + +
+ Add New + Cost List
@@ -61,16 +62,35 @@
-
+ - + - + + + + + +
+
+ + +
+
+ - -
@@ -92,22 +112,35 @@ $createdat = new DateTime($record->CreatedDate); $date = $createdat->format('d-m-Y'); $time = $createdat->format('h:i A'); - ?> - + ?> + " style="IsActive == 0) { + echo "display:none"; + } ?>"> code ?> CostCenterName ?> FirstName ?> DeletedBy == '') { - ?> -    -     + if ($record->IsActive == 0) { + ?> + +     + + +    +     - @@ -122,14 +155,13 @@
-