//----------------------------------------------------------------------- function detailpost() { $crudColumns = array( 'id'=>'company_access_id' ,'company_id'=>'company_id' ,'company_code'=>'company_code' ,'company_name'=>'company_name' ); $crudTableName = 'erp_sec_companyaccess'; $postConfig['id'] = 'company_access_id'; $postConfig['search'] = '_search'; /* search */ $postConfig['searchField'] = 'searchField'; /* searchField */ $postConfig['searchOper'] = 'searchOper'; /* searchOper */ $postConfig['searchStr'] = 'searchString'; /* searchString */ $postConfig['action'] = 'oper'; /* action variable */ $postConfig['sortColumn'] = 'sidx'; /* sort column */ $postConfig['sortOrder'] = 'sord'; /* sort order */ $postConfig['page'] = 'page'; /* current requested page */ $postConfig['limit'] = 'rows'; /* restrict number of rows to return */ $crudConfig['row'] = 'cell'; /* row data identifier */ $crudConfig['read'] = 'oper'; /* action READ keyword *//* set to be the same as action keyword for default */ $crudConfig['create'] = 'add'; /* action CREATE keyword */ $crudConfig['update'] = 'edit'; /* action UPDATE keyword */ $crudConfig['delete'] = 'del'; /* action DELETE keyword */ $crudConfig['totalPages'] = 'total'; /* total pages */ $crudConfig['totalRecords'] = 'records'; /* total records */ $crudConfig['responseSuccess'] = 'success'; /* total records */ $crudConfig['responseFailure'] = 'fail'; /* total records */ /* end of jqgrid specific settings */ //$o=null; function fnSearchCondition($searchOperation, $searchString){ switch($searchOperation){ case 'eq': $searchCondition = '= "'.$searchString.'"'; break; case 'ne': $searchCondition = '!= "'.$searchString.'"'; break; case 'bw': $searchCondition = 'LIKE "'.$searchString.'%"'; break; case 'ew': $searchCondition = 'LIKE "%'.$searchString.'"'; break; case 'cn': $searchCondition = 'LIKE "%'.$searchString.'%"'; break; case 'lt': $searchCondition = '< "'.$searchString.'"'; break; case 'gt': $searchCondition = '> "'.$searchString.'"'; break; case 'le': $searchCondition = '<= "'.$searchString.'"'; break; case 'ge': $searchCondition = '>= "'.$searchString.'"'; break; } return $searchCondition; } function fnCleanInputVar($string){ return $string; } foreach ($postConfig as $key => $value){ if(isset($_REQUEST[$value])){ $postConfig[$key] = fnCleanInputVar($_REQUEST[$value]); } } foreach ($crudColumns as $key => $value){ if(isset($_REQUEST[$key])){ $crudColumnValues[$key] = '"'.fnCleanInputVar($_REQUEST[$key]).'"'; } } switch($postConfig['action']){ case $crudConfig['create']: $c = ""; $dt['company_code'] = $this->input->post('company_code'); $sec_exist = $this->Sec_users_db->getDetails($dt); if ($sec_exist) { $c .= 'Company ID already exists.'; $data['action'] = 'exist'; } else { $fields = array( 'company_code' ,'company_name' ); foreach ($fields as $field) {if (isset($_POST[$field])) $dt[$field] = $this->input->post($field);} $item = $this->input->post("item"); $data['item'] = $this->Sec_users_db->save($dt,$item); } break; case $crudConfig['update']: $sql = 'update '.$crudTableName.' set '; foreach($crudColumns as $key => $value){ $updateArray[$key] = $value.'='.$crudColumnValues[$key]; }; $sql .= implode(',',$updateArray); $sql .= ' where company_id = '.$crudColumnValues['id']; mysql_query( $sql ); break; case $crudConfig['delete']: $this->db->where('company_id', $this->input->post('id')); $this->db->delete($crudTableName); break; } if (isset($data)) echo json_encode($data); } //-----------------------------------------------------------------------