From 0493499da7412d6210e356813ec3af33dea81dd5 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Tue, 8 Oct 2024 00:29:13 +0530 Subject: [PATCH] added material category addition in add material section -vadivel J --- app/Controllers/Rawmaterialdetails.php | 13 ++ app/Models/Rawmaterialdetails_model.php | 4 +- app/Views/addRawMaterial.php | 27 +++- app/Views/editRawmaterial.php | 133 +++++++++++++++++- app/Views/factoryMachineMasterDetailsForm.php | 11 +- 5 files changed, 174 insertions(+), 14 deletions(-) diff --git a/app/Controllers/Rawmaterialdetails.php b/app/Controllers/Rawmaterialdetails.php index ed4a2d3b..cc33666b 100755 --- a/app/Controllers/Rawmaterialdetails.php +++ b/app/Controllers/Rawmaterialdetails.php @@ -318,6 +318,19 @@ class Rawmaterialdetails extends BaseController $data['category_name']=$this->request->getpost('category_name'); + $existingCategory = $this->materialCategories_model + ->where('category_name', $data['category_name']) + ->first(); + + if ($existingCategory) { + // Data already exists, handle this case (e.g., return an error or ignore the insert) + return $this->response->setJSON([ + 'status' => '409', + 'message' => 'Category Already Exists..!!', + ]); + } + + $insertResult=$this->materialCategories_model->insert($data); if ($insertResult) { diff --git a/app/Models/Rawmaterialdetails_model.php b/app/Models/Rawmaterialdetails_model.php index 2f6225d9..c13d89d6 100755 --- a/app/Models/Rawmaterialdetails_model.php +++ b/app/Models/Rawmaterialdetails_model.php @@ -152,8 +152,8 @@ class Rawmaterialdetails_model extends Model $subquery = "SELECT SUM(IF(Transaction_type='Add',Quantity,0)) - SUM(IF(Transaction_type='Reduce',Quantity,0))as remainingqty -FROM t_material_stock_history -WHERE MaterialCode=? AND CreatedOn >=? AND CreatedOn <=? "; + FROM t_material_stock_history + WHERE MaterialCode=? AND CreatedOn >=? AND CreatedOn <=? "; $query = $this->db->query($subquery, array($MaterialCode, $startdate, $newdate)); diff --git a/app/Views/addRawMaterial.php b/app/Views/addRawMaterial.php index 007d554a..a74ac841 100755 --- a/app/Views/addRawMaterial.php +++ b/app/Views/addRawMaterial.php @@ -195,7 +195,8 @@ - + +