diff --git a/app/Config/Routes.php b/app/Config/Routes.php index d177174c..3e22539f 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -65,7 +65,6 @@ $routes->get('viewRawmaterial', 'Rawmaterialdetails::viewRawmaterial'); $routes->post('rawmaterialdetails/editRawmaterial', 'Rawmaterialdetails::editRawmaterial'); $routes->post('rawmaterialdetails/addMaterialCategories', 'Rawmaterialdetails::addMaterialCategories'); $routes->get('exportmaterial', 'Rawmaterialdetails::exportmaterial'); -$routes->get('rawmaterialdetailsautocomplete', 'Rawmaterialdetails::autocomplete'); $routes->post('deleteMaterial', 'Rawmaterialdetails::deleteMaterial'); $routes->post('reActivateMaterial', 'Rawmaterialdetails::reActivateMaterial'); @@ -144,6 +143,7 @@ $routes->post('configurationctrl/saveconfig', 'Configurationctrl::saveconfig'); $routes->post('configurationctrl/configValueCheck', 'Configurationctrl::configValueCheck'); $routes->get('configurationctrl/deleteConfigValue', 'Configurationctrl::deleteConfigValue'); $routes->get('configurationctrl/reActivateConfigValue', 'Configurationctrl::reActivateConfigValue'); +$routes->get('activeInactiveConfigValue', 'Configurationctrl::activeInactiveConfigValue'); $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 68061b09..83b09a79 100755 --- a/app/Controllers/Configurationctrl.php +++ b/app/Controllers/Configurationctrl.php @@ -182,6 +182,16 @@ class Configurationctrl extends BaseController } + public function activeInactiveConfigValue(){ + + $key = $this->request->getVar('key'); + $value = $this->request->getVar('value'); + $where = ['isActive'=> $value]; + $result = $this->configmodel->activeInactiveConfigValue($key, $where); + return redirect()->back(); + } + + public function deleteConfigValue(){ $configId = $this->request->getVar('ConfigID'); diff --git a/app/Controllers/Rawmaterialdetails.php b/app/Controllers/Rawmaterialdetails.php index e2f5681a..31f51c2f 100755 --- a/app/Controllers/Rawmaterialdetails.php +++ b/app/Controllers/Rawmaterialdetails.php @@ -69,6 +69,7 @@ class Rawmaterialdetails extends BaseController $this->rawmaterialdetails_model = new rawmaterialdetails_model();; $data['userRecords'] = $this->rawmaterialdetails_model->rawmaterialListing(); + $data['materialCategoryList']= $this->materialCategories_model->where('is_active',1)->findAll(); $this->global['pageTitle'] = 'RawMaterial Listing'; $this->loadViews("rawmaterialListing", $this->global, $data, NULL); @@ -133,7 +134,7 @@ class Rawmaterialdetails extends BaseController $this->rawmaterialdetails_model = new rawmaterialdetails_model();; $data['material'] = $this->rawmaterialdetails_model->getmaterialType(); $data['materialcategory'] = $this->rawmaterialdetails_model->getmaterialCategory(); - $data['materialCategoryList']= $this->materialCategories_model->where('is_active',1)->findAll(); + // $data['materialCategoryList']= $this->materialCategories_model->where('is_active',1)->findAll(); $data['UOM'] = $this->rawmaterialdetails_model->getUOM(); $data['assetcode'] = $this->rawmaterialdetails_model->getAssetcode(); $data['costcentercode'] = $this->rawmaterialdetails_model->getcostcentercode(); @@ -283,7 +284,7 @@ class Rawmaterialdetails extends BaseController $data['currentstock'] = $this->rawmaterialdetails_model->getMaterialstock($RawMaterialID, $currentdate); $data['materialType'] = $this->rawmaterialdetails_model->getmaterialType($MaterialType); $data['materialCategory'] = $this->rawmaterialdetails_model->getmaterialCategory($MaterialCategory); - $data['materialCategoryList']= $this->materialCategories_model->where('is_active',1)->findAll(); + $data['materialCategoryList']= $this->materialCategories_model->where('is_active',1)->findAll(); // Told by Pavithra $data['UOMList'] = $this->rawmaterialdetails_model->getUOM($UOM); $data['costcentercode'] = $this->rawmaterialdetails_model->getCostCenterCode(); $data['cfUOM'] = $this->rawmaterialdetails_model->getConversionfactorUOM(); @@ -351,13 +352,12 @@ class Rawmaterialdetails extends BaseController } - function addMaterialCategories(){ + function addMaterialCategories(){ - $data['category_name']=$this->request->getpost('category_name'); - - $existingCategory = $this->materialCategories_model - ->where('category_name', $data['category_name']) - ->first(); + $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) @@ -367,8 +367,7 @@ class Rawmaterialdetails extends BaseController ]); } - - $insertResult=$this->materialCategories_model->insert($data); + $insertResult=$this->rawmaterialdetails_model->insertvalueintoconfig($configArr); if ($insertResult) { // Send a success response as JSON @@ -386,19 +385,6 @@ class Rawmaterialdetails extends BaseController } - function autocomplete() - { - - - $mc = $this->request->getGet('query'); - //echo $mc;die; - $query = $this->rawmaterialdetails_model->checkMaterialCategory($mc); - - echo json_encode($query); - // foreach($query->result() as $row): - // echo "
  • ".$row->Category."
  • "; - // endforeach; - } function insertvalueintoconfig() { diff --git a/app/Models/Config_model.php b/app/Models/Config_model.php index f810f571..f854f137 100755 --- a/app/Models/Config_model.php +++ b/app/Models/Config_model.php @@ -202,6 +202,14 @@ class Config_model extends Model return $query->getResultArray(); } + public function activeInactiveConfigValue($key, $value){ + $builder = $this->db->table('t_configdetails') + ->where('Key',$key) + ->update($value); + $res = $this->db->affectedRows(); + return $res; + } + public function deleteConfigValue($configId, $configValue){ $builder = $this->db->table('t_configdetails') ->where('Config_ID',$configId) diff --git a/app/Models/Rawmaterialdetails_model.php b/app/Models/Rawmaterialdetails_model.php index 105489f7..1eaa36bb 100755 --- a/app/Models/Rawmaterialdetails_model.php +++ b/app/Models/Rawmaterialdetails_model.php @@ -77,6 +77,7 @@ class Rawmaterialdetails_model extends Model $Config_ID = 'C023'; $builder = $this->db->table('t_configdetails') ->select('Config_ID,ConfigValue') + ->where('isActive', 1) ->where('Config_id', $Config_ID); if ($MaterialCategory != '') { $builder->where('ConfigValue !=', $MaterialCategory); @@ -348,22 +349,12 @@ class Rawmaterialdetails_model extends Model function checkMaterialCategory($mc) { - $temp = []; $builder = $this->db->table('t_configdetails') - ->distinct() ->select('ConfigValue') ->where('Config_ID', 'C023') ->like('ConfigValue', $mc); - $query = $builder->get(); - - $temparr = []; - foreach ($query->getResult() as $arr) { - $temparr[] = $arr->ConfigValue; - } - - $temp['suggestions'] = $temparr; - - return $temp; + $query = $builder->get()->getRow(); + return $query; } diff --git a/app/Views/addRawMaterial.php b/app/Views/addRawMaterial.php index 7f407380..93ccd7d1 100755 --- a/app/Views/addRawMaterial.php +++ b/app/Views/addRawMaterial.php @@ -1,11 +1,11 @@ - + --> - +
    @@ -75,12 +75,12 @@ title="Add Material Caterogy"> - - - + + + + ?>
    @@ -331,43 +329,6 @@ if ($total <= $reorder) { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -