From a28862ba31f8811cb7c9a98f21802a8cfbcb56bb Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 13 Feb 2025 11:51:12 +0000 Subject: [PATCH] bug fixes 2 : ps --- app/Config/Routes.php | 2 +- app/Controllers/Configurationctrl.php | 8 ++ app/Controllers/Rawmaterialdetails.php | 34 ------ app/Models/Config_model.php | 12 +++ app/Models/Purchaseorder_model.php | 2 +- app/Models/Rawmaterialdetails_model.php | 29 ++---- app/Models/Requistion_model.php | 7 +- app/Views/addRawMaterial.php | 81 ++++----------- app/Views/configlisting.php | 65 ++++++++++-- app/Views/editRawmaterial.php | 77 ++++---------- app/Views/editRevenuepurchaseorder.php | 132 +++++++++++++++++++++++- app/Views/editconfig.php | 62 ++++++++--- app/Views/editrequisitionform.php | 19 +++- app/Views/purchaseorder.php | 116 +++++++++++++++++++++ app/Views/rawmaterialListing.php | 2 +- app/Views/requisitionform.php | 38 +++++-- 16 files changed, 469 insertions(+), 217 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 3e22539f..b08ca39c 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -63,7 +63,6 @@ $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'rawmaterialListing/(:num)', 'R $routes->post('materialExist', 'Rawmaterialdetails::checkmaterial'); $routes->get('viewRawmaterial', 'Rawmaterialdetails::viewRawmaterial'); $routes->post('rawmaterialdetails/editRawmaterial', 'Rawmaterialdetails::editRawmaterial'); -$routes->post('rawmaterialdetails/addMaterialCategories', 'Rawmaterialdetails::addMaterialCategories'); $routes->get('exportmaterial', 'Rawmaterialdetails::exportmaterial'); $routes->post('deleteMaterial', 'Rawmaterialdetails::deleteMaterial'); $routes->post('reActivateMaterial', 'Rawmaterialdetails::reActivateMaterial'); @@ -144,6 +143,7 @@ $routes->post('configurationctrl/configValueCheck', 'Configurationctrl::configVa $routes->get('configurationctrl/deleteConfigValue', 'Configurationctrl::deleteConfigValue'); $routes->get('configurationctrl/reActivateConfigValue', 'Configurationctrl::reActivateConfigValue'); $routes->get('activeInactiveConfigValue', 'Configurationctrl::activeInactiveConfigValue'); +$routes->post('getPONOcreatedBasedOnConfig', 'Configurationctrl::getPONOcreatedBasedOnConfig'); $routes->get('configurationctrl/editconfig', 'Configurationctrl::editconfig'); $routes->post('configurationctrl/updateconfig', 'Configurationctrl::updateconfig'); $routes->post('configurationctrl/configNameCheck', 'Configurationctrl::configNameCheck'); diff --git a/app/Controllers/Configurationctrl.php b/app/Controllers/Configurationctrl.php index 83b09a79..1ff5b1fe 100755 --- a/app/Controllers/Configurationctrl.php +++ b/app/Controllers/Configurationctrl.php @@ -190,6 +190,14 @@ class Configurationctrl extends BaseController $result = $this->configmodel->activeInactiveConfigValue($key, $where); return redirect()->back(); } + public function getPONOcreatedBasedOnConfig(){ + $data = $this->request->getPost(); + $key_id = $data['key_id']; + $result = $this->configmodel->getPONOcreatedBasedOnConfig($key_id); + return $this->response->setJSON($result); + // return $result; + + } public function deleteConfigValue(){ diff --git a/app/Controllers/Rawmaterialdetails.php b/app/Controllers/Rawmaterialdetails.php index 31f51c2f..e05b1b11 100755 --- a/app/Controllers/Rawmaterialdetails.php +++ b/app/Controllers/Rawmaterialdetails.php @@ -352,40 +352,6 @@ class Rawmaterialdetails extends BaseController } - function addMaterialCategories(){ - - $configCode = 'C023'; - $configVal = $this->request->getpost('category_name'); - $configArr = array('Config_ID' => $configCode, 'ConfigValue' => $configVal); - $existingCategory = $this->rawmaterialdetails_model->checkMaterialCategory($configVal); - - 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->rawmaterialdetails_model->insertvalueintoconfig($configArr); - - if ($insertResult) { - // Send a success response as JSON - return $this->response->setJSON([ - 'status' => '201', - 'message' => 'Category added successfully', - ]); - } else { - // Send an error response as JSON - return $this->response->setJSON([ - 'status' => '400', - 'message' => 'Failed to add category', - ]); - } - - } - - function insertvalueintoconfig() { diff --git a/app/Models/Config_model.php b/app/Models/Config_model.php index f854f137..ef2109e9 100755 --- a/app/Models/Config_model.php +++ b/app/Models/Config_model.php @@ -228,4 +228,16 @@ class Config_model extends Model return $res; } + public function getPONOcreatedBasedOnConfig($key_id){ + $builder = $this->db->table('t_purchaseorder_lineitem PL') + ->select('PL.PONO, MM.MaterialName, CD.ConfigValue as CategoryName') + ->join('t_materialmaster MM', 'MM.MaterialCode = PL.MaterialCode', 'left') + ->join('t_configdetails CD', 'CD.Key = MM.Category', 'left') + ->where('CD.Key', $key_id); + + $query = $builder->get(); + $result = $query->getResultArray(); + return $result; + } + } \ No newline at end of file diff --git a/app/Models/Purchaseorder_model.php b/app/Models/Purchaseorder_model.php index 42f7d670..99fd3837 100755 --- a/app/Models/Purchaseorder_model.php +++ b/app/Models/Purchaseorder_model.php @@ -1142,7 +1142,7 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath, { $subQuery = 'SELECT distinct LineItem.LineItemNo,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName,Mat.UOM,Quantity,Per,ServiceMaterialDescription,ReceivedQuantity,Rate,Req.Status,(Quantity *Rate) as BasicValue , (( AfterSGST + AfterCGST + - AfterIGST )) as Taxamount ,TotalValue,Tax.*,Req.CostCenterCode,Dept.DepartmentName + AfterIGST )) as Taxamount ,TotalValue,Tax.*,Req.CostCenterCode,Dept.DepartmentName,LineItem.LineitemDescription FROM t_purchaseorder_lineitem LineItem join t_materialmaster Mat on Mat.MaterialCode = LineItem.MaterialCode left join t_revenue_tax Tax on Tax.LineItemNo = LineItem.LineItemNo diff --git a/app/Models/Rawmaterialdetails_model.php b/app/Models/Rawmaterialdetails_model.php index 1eaa36bb..f530ada6 100755 --- a/app/Models/Rawmaterialdetails_model.php +++ b/app/Models/Rawmaterialdetails_model.php @@ -18,9 +18,10 @@ class Rawmaterialdetails_model extends Model { $builder = $this->db->table('t_materialmaster') - ->select('t_materialmaster.* , emp.FirstName as createdby_user') + ->select('t_materialmaster.* , emp.FirstName as createdby_user,cd.ConfigValue as CategoryName') ->join('tbl_users as user', 'user.UserId = t_materialmaster.createdby', 'left') ->join('t_employee_details as emp', 'emp.EmpID = user.EmpID', 'left') + ->join('t_configdetails as cd', 'cd.Key = t_materialmaster.Category', 'left') ->orderBy('CreatedDate','desc'); $query = $builder->get(); $result = $query->getResult(); @@ -76,7 +77,7 @@ class Rawmaterialdetails_model extends Model { $Config_ID = 'C023'; $builder = $this->db->table('t_configdetails') - ->select('Config_ID,ConfigValue') + ->select('Key,Config_ID,ConfigValue') ->where('isActive', 1) ->where('Config_id', $Config_ID); if ($MaterialCategory != '') { @@ -329,15 +330,18 @@ class Rawmaterialdetails_model extends Model // on 28/jan/2025. both add and edit. category condition added. + // on 13/Feb/2025. Change based On Config Child Values. function checkMaterialExists($materialCode , $materialName ,$materialCategory) { - $builder = $this->db->table('t_materialmaster') - ->select('MaterialCode,MaterialName,MaterialType,Category,IsActive'); + + $builder = $this->db->table('t_materialmaster MM') + ->select('MM.MaterialCode,MM.MaterialName,MM.MaterialType,MM.Category,MM.IsActive,CD.ConfigValue as CategoryName') + ->join('t_configdetails as CD', ' CD.Key = MM.Category', 'left'); if(!empty($materialCode)){ - $builder = $builder->where('MaterialCode !=' , $materialCode); + $builder = $builder->where('MM.MaterialCode !=' , $materialCode); } - $builder->where('Category' , $materialCategory); - $builder->where('REPLACE(MaterialName, " ", "")' , $materialName); + $builder->where('MM.Category' , $materialCategory); + $builder->where('REPLACE(MM.MaterialName, " ", "")' , $materialName); $query = $builder->get(); if ($query->getNumRows() > 0) { @@ -347,17 +351,6 @@ class Rawmaterialdetails_model extends Model } } - function checkMaterialCategory($mc) - { - $builder = $this->db->table('t_configdetails') - ->select('ConfigValue') - ->where('Config_ID', 'C023') - ->like('ConfigValue', $mc); - $query = $builder->get()->getRow(); - return $query; - } - - function reOrderListing() { diff --git a/app/Models/Requistion_model.php b/app/Models/Requistion_model.php index d5f5230a..bfeed261 100755 --- a/app/Models/Requistion_model.php +++ b/app/Models/Requistion_model.php @@ -196,9 +196,10 @@ class Requistion_model extends Model */ function getRawMaterialList($MaterialCode) { - $builder = $this->db->table('t_materialmaster') - ->select('MaterialName,UOM,Category') - ->where('MaterialCode',$MaterialCode ); + $builder = $this->db->table('t_materialmaster MM') + ->select('MM.MaterialName,MM.UOM,MM.Category,CD.ConfigValue as CategoryName') + ->join('t_configdetails CD', 'CD.Key = MM.Category', 'left') + ->where('MM.MaterialCode',$MaterialCode ); $query = $builder->get(); return $query->getResultArray(); diff --git a/app/Views/addRawMaterial.php b/app/Views/addRawMaterial.php index 93ccd7d1..cedc94c8 100755 --- a/app/Views/addRawMaterial.php +++ b/app/Views/addRawMaterial.php @@ -70,17 +70,17 @@
- - + --> - + = 1) { $('#loader').hide(); - if(data[0]?.IsActive == 1){ - alert('Material name already existed ! '); - $('#MaterialName').val(''); - }else{ - alert('Material name already existing in the deleted section.!!'); - $('#MaterialName').val(''); - } - var related_name = ""; - $.each(data, function(i, obj) { + let message = ""; + if (data[0]?.IsActive == 1) { + message = "Material name already exists!\n\n"; + } else { + message = "Material name already exists in the deleted section!\n\n"; + } - related_name += obj.MaterialCode + " - " + obj.MaterialName + " - " + obj.MaterialType + " - " + obj.Category + "\n"; + let related_name = ""; + $.each(data, function(i, obj) { + related_name += obj.MaterialCode + " - " + obj.MaterialName + " - " + obj.MaterialType + " - " + obj.CategoryName + "\n"; + }); - }); + message += "'" + materialName + "' - related materials are:\n\n" + related_name; - alert("'" + materialName + "' - related materials are , " + " \n \n" + related_name); - $("#MaterialName").val(''); - $("#MaterialName").focus(); + alert(message); + + $("#MaterialName").val(''); + $("#MaterialName").focus(); } else { $('#loader').hide(); console.log("working") @@ -479,48 +480,6 @@ if ($total <= $reorder) { return false; } - $.ajax({ - url: "", - type: 'POST', - data: { - category_name: materialCategory - }, - success: function(response) { - - if(response.status== 201 ){ - - $("#addMaterialCaterogyModal").modal('hide'); - $("#materialCategoryInput").val(''); - $("#MaterialCategory").append(``) - } - else if(response.status=="409"){ - - $("#addMaterialCaterogyModal").modal('hide'); - $("#materialCategoryInput").val(''); - // $('#MaterialCategory').val(materialCategory); - - $('#MaterialCategory').trigger('change'); - - setTimeout(()=>{ alert(`${response.message}`) },1000) - } - else{ - $("#addMaterialCaterogyModal").modal('hide'); - $("#materialCategoryInput").val(''); - - setTimeout(()=>{ alert('Error Adding Category..!!'); },1000) - - } - - - }, - error: function(xhr, status, error) { - // Handle errors - alert('Error adding category'); - console.log(error); - } - }); - - } diff --git a/app/Views/editRevenuepurchaseorder.php b/app/Views/editRevenuepurchaseorder.php index 95f727b0..649c0f7c 100755 --- a/app/Views/editRevenuepurchaseorder.php +++ b/app/Views/editRevenuepurchaseorder.php @@ -1,5 +1,110 @@ +