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 "