diff --git a/app/Config/Routes.php b/app/Config/Routes.php index ca7afd44..51dc80fe 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -65,7 +65,7 @@ $routes->get('rawmaterialdetailsautocomplete' , 'Rawmaterialdetails::autocomplet // Cost Center Routes $routes->get('costListing', 'CostCenter::index'); -$routes->get('fetchCostCenterDetails', 'CostCenter::fetchCostCenterDetails');// for Ajax both add and edit.... +$routes->post('fetchCostCenterDetails', 'CostCenter::fetchCostCenterDetails');// for Ajax both add and edit.... $routes->get('deleteCostCenter', 'CostCenter::deleteCostCenter'); $routes->get('exportcost', 'CostCenter::exportcost'); diff --git a/app/Controllers/CostCenter.php b/app/Controllers/CostCenter.php index 11d25da1..0a231e42 100644 --- a/app/Controllers/CostCenter.php +++ b/app/Controllers/CostCenter.php @@ -56,6 +56,7 @@ class CostCenter extends BaseController */ public function fetchCostCenterDetails() { $id = $this->request->getPost('id'); + log_message('error', 'id: ' . $id); $CostCenterName = $this->request->getPost('CostCenterName'); $CostCenterName = ($CostCenterName !== null && is_string($CostCenterName)) ? strtoupper(trim($CostCenterName)) : null; $userId = $this->session->get('userId'); @@ -64,11 +65,15 @@ class CostCenter extends BaseController $data = ['status' => false, 'message' => 'An error occurred while creating cost details']; - if ($id == 0) { + if ((int)$id == 0) { $lastccid = $this->costcenter_model->lastCCID(); - $lastccid = (int)$lastccid++; + log_message('error', 'LAST CodeCenterID : ' . $lastccid); + + $newccid = (int)$lastccid++; + log_message('error', 'CodeCenterID with Incremented : ' . $newccid); + $newccc = generateCostCenterCode($lastccid); - log_message('debug', 'newccc returned: ' . $newccc); + log_message('error', 'newly Generated ccc : ' . $newccc); $Cost = ['CostCenterCode' => $newccc, 'CostCenterName' => $CostCenterName, diff --git a/app/Models/Costcenter_model.php b/app/Models/Costcenter_model.php index 3541c4aa..20789e62 100644 --- a/app/Models/Costcenter_model.php +++ b/app/Models/Costcenter_model.php @@ -36,6 +36,7 @@ class Costcenter_model extends Model $builder = $this->db->table('t_costcenter_master'); $builder->insert($Cost); $aff_row = $this->db->affectedRows(); + log_message('error', 'saveCostCenter Query: ' . $this->db->getLastQuery()->getQuery()); $this->db->transComplete(); return $aff_row; } diff --git a/app/Views/costListing.php b/app/Views/costListing.php index a9aabba5..9bb0564d 100644 --- a/app/Views/costListing.php +++ b/app/Views/costListing.php @@ -20,6 +20,7 @@ + @@ -39,7 +40,8 @@ $date = $createdat->format('d-m-Y'); $time = $createdat->format('h:i A'); ?> - + + @@ -122,7 +124,7 @@
Create Date Create Time Cost Center Code
CreatedDate ?> code ?>