From 69b87bddf905e10d67a9b8fb5473e5306d1bae01 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Mon, 5 Mar 2018 10:25:50 +0530 Subject: [PATCH] auto search box in add and edit material screen --- .../controllers/rawmaterialdetails.php | 79 +++++- .../models/rawmaterialdetails_model.php | 36 +++ application/views/addRawMaterial.php | 202 ++++++++------- application/views/editOldRawmaterial.php | 236 ++++++++++-------- 4 files changed, 341 insertions(+), 212 deletions(-) diff --git a/application/controllers/rawmaterialdetails.php b/application/controllers/rawmaterialdetails.php index fec56302..31e18765 100755 --- a/application/controllers/rawmaterialdetails.php +++ b/application/controllers/rawmaterialdetails.php @@ -116,6 +116,9 @@ class rawmaterialdetails extends BaseController function addNewRawMaterial() { + + //echo "HI";die(); + $TempArr = []; $this->form_validation->set_rules('MaterialName','Material Name','trim|required|'); $this->form_validation->set_rules('MaterialType','MaterialType','trim|callback_MaterialType_validate'); @@ -128,16 +131,34 @@ class rawmaterialdetails extends BaseController } else { - $MaterialName = $this->input->post('MaterialName');//print_r($MaterialName); + $MaterialName = $this->input->post('MaterialName'); $MaterialType = $this->input->post('MaterialType'); $UOM = $this->input->post('UOM'); - $MaterialCategory = $this->input->post('MaterialCategory'); + $MaterialCategory = $this->input->post('MatCate'); + $materialcategoryarray = $this->rawmaterialdetails_model->getmaterialCategory(); + + foreach($materialcategoryarray as $mc){ + $TempArr[] = $mc->ConfigValue; + + } + //print_r($TempArr); + if (in_array($MaterialCategory, $TempArr)) + { + //echo "Match found"; + } +else + { + //echo "Match not found"; + $configcode = 'C023'; + $config = array('Config_ID'=>$configcode,'ConfigValue'=>$MaterialCategory); + $query= $this->rawmaterialdetails_model->insertvalueintoconfig($config); + } $Remarks = $this->input->post('remarks'); - $asset = $this->input->post('Assetcode');//print_r($AssetCode); - $costcentercode = $this->input->post('Costcenter');//print_r($CostCenterCode); + $asset = $this->input->post('Assetcode'); + $costcentercode = $this->input->post('Costcenter'); $ConversionFactor = $this->input->post('conversionfactor'); - $cfuom = $this->input->post('conversionfactorUOM');//print_r( $ConversionFactorUOM); - $HSN = $this->input->post('HSNcode');//print_r($HSNcode); + $cfuom = $this->input->post('conversionfactorUOM'); + $HSN = $this->input->post('HSNcode'); $CreatedBy = $this->session->userdata('userId'); $chked = $this->input->post('isactive'); @@ -241,6 +262,7 @@ class rawmaterialdetails extends BaseController */ function editRawmaterial() { + // if($this->isAdmin() == TRUE) // { // $this->loadThis(); @@ -264,6 +286,24 @@ class rawmaterialdetails extends BaseController $MaterialName = $this->input->post('MaterialName'); $MaterialType = $this->input->post('MaterialType'); $MaterialCategory =$this->input->post('MaterialCategory'); + $materialcategoryarray = $this->rawmaterialdetails_model->getmaterialCategory(); + + foreach($materialcategoryarray as $mc){ + $TempArr[] = $mc->ConfigValue; + + } + //print_r($TempArr); + if (in_array($MaterialCategory, $TempArr)) + { + //echo "Match found"; + } +else + { + //echo "Match not found"; + $configcode = 'C023'; + $config = array('Config_ID'=>$configcode,'ConfigValue'=>$MaterialCategory); + $query= $this->rawmaterialdetails_model->insertvalueintoconfig($config); + } $UOM = $this->input->post('UOM'); $rmcode = $this->input->post('RMcode'); $Remarks = $this->input->post('remarks'); @@ -318,7 +358,7 @@ class rawmaterialdetails extends BaseController $RawMaterial = array(); $RawMaterial = array('MaterialName'=>$MaterialName,'MaterialType'=>$MaterialType,'UpdatedBy'=>$UpdatedBy, 'UOM'=>$UOM,'IsActive' => $IsActive,'Category'=>$MaterialCategory,'ConversionFactorUnit'=>$ConversionFactor,'ConversionFactorUOM'=>$ConversionFactorUOM,'Remarks'=>$Remarks,'assetcode'=>$AssetCode,'CostCenterCode'=>$CostCenterCode,'HSNCODE'=>$HSNcode);//,'RMCode'=>$rmcode); - //print_r($RawMaterial);//die(); + $result = $this->rawmaterialdetails_model->editRawmaterial($RawMaterial, $MaterialCode); if($result == true) @@ -336,7 +376,32 @@ class rawmaterialdetails extends BaseController } //} } + function autocomplete() +{ + $this->load->model('model','rawmaterialdetails_model'); + $mc = $this->input->get('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(){ + $this->load->model('model','rawmaterialdetails_model'); + $mc = $this->input->post('id'); + $configcode = 'C023'; + $config = array('Config_ID'=>$configcode,'ConfigValue'=>$mc); + + $query= $this->rawmaterialdetails_model->insertvalueintoconfig($config); + + + +} + /** this function can be use for excel report **/ function export_material(){ diff --git a/application/models/rawmaterialdetails_model.php b/application/models/rawmaterialdetails_model.php index 967c002a..25485397 100755 --- a/application/models/rawmaterialdetails_model.php +++ b/application/models/rawmaterialdetails_model.php @@ -96,6 +96,12 @@ class rawmaterialdetails_model extends CI_Model $this->db->insert('T_MaterialMaster', $RawMaterial); return TRUE; } + + function insertvalueintoconfig($config){ + + $this->db->insert('T_ConfigDetails', $config); + return TRUE; + } /** * This function used to get user information by id @@ -189,5 +195,35 @@ class rawmaterialdetails_model extends CI_Model return $query->result(); } + function checkMaterialCategory($mc){ + + // $this->db->select('ConfigValue'); + // $this->db->from('T_ConfigDetails'); + // $this->db->where(Config_ID,'C023'); + // $this->db->like('ConfigValue',$mc); + // $query = $this->db->get(); + // //print_r($query->result()); + // return $query->result(); + + // //return $this->db->get('T_MaterialMaster'); + // } + $temp[] = '' ; + echo $materialcategory; + $this->db->distinct(); + $this->db->select('ConfigValue'); + $this->db->from('T_ConfigDetails'); + $this->db->where('Config_ID','C023'); + $this->db->like('ConfigValue',$mc); + $query = $this->db->get(); + //print_r($query->result());die; + $temparr[] = '' ; + foreach($query->result() as $arr){ + $temparr[] = $arr->ConfigValue ; + } + $temp['suggestions'] = $temparr; + //print_r($temp); + + return $temp; + } } ?> \ No newline at end of file diff --git a/application/views/addRawMaterial.php b/application/views/addRawMaterial.php index 9eed59e2..75fa6df1 100755 --- a/application/views/addRawMaterial.php +++ b/application/views/addRawMaterial.php @@ -1,59 +1,17 @@ - + +

    +
    Siddharth Industries - Add New Material

    @@ -74,12 +32,14 @@ function isNumberKey(evt)
    + +
    * - +
    @@ -103,31 +63,21 @@ function isNumberKey(evt)
    + -
    -
    - * - -
    +
    +
    + * + + + +
    * - \ No newline at end of file + var x = document.getElementById("MatCate"); + if(x.value=='Spares') + { + document.getElementById("Assetcode").disabled=false; + document.getElementById("Costcenter").disabled=false; + } + else + { + document.getElementById("Assetcode").disabled=true; + document.getElementById("Costcenter").disabled=true; } + } + \ No newline at end of file diff --git a/application/views/editOldRawmaterial.php b/application/views/editOldRawmaterial.php index 8de20347..681ffc10 100755 --- a/application/views/editOldRawmaterial.php +++ b/application/views/editOldRawmaterial.php @@ -46,100 +46,15 @@ if(!empty($materialDetails)) ?> - - - - + +
    @@ -208,11 +123,19 @@ function changeTextBox() {
    -
    -
    - - - -
    -
    + -> -> +
    --> +
    * - assets/js/editUser.js" type="text/javascript">