[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1266227253"]show me your users model, and the javascript code for your ajax company add call.[/quote]
here's my USERS MODEL:
Code:
<?
class Users_db extends Model {
function Users_db()
{
parent::Model();
}
function getCompanyDetails($data)
{
$this->db->where($data);
return $this->db->get('maint_company')->row_array();
}
function getDetailList($ids) //Show the list of registered user with company details
{
$item=$this->input->post('item');
$id = $this->input->post('ids'); //cess code added
$page = $this->input->post('page');
$limit = $this->input->post('rows'); // get how many rows we want to have into the grid
$sidx = $this->input->post('sidx'); // get index row - i.e. user click to sort
$sord = $this->input->post('sord'); // get the direction
if (!$sidx) $sidx = 'sec_companyaccess.user_id'; // if we not pass at first time index use the first column for the index
if (!$sord) $sord = 'desc';
// calculate the total pages for the query - code added by cess
if( $count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
// if for some reasons the requested page is greater than the total
// set the requested page to total page - code added by cess
if ($page > $total_pages) $page=$total_pages;
// calculate the starting position of the rows
$start = $limit * $page - $limit; // do not put $limit*($page - 1)
// if for some reasons start position is negative set it to 0
// typical case is that the user type 0 for the requested page
if($start <0) $start = 0;
$this->db->select("sec_companyaccess.company_access_id as pkey,sec_companyaccess.company_access_id, maint_company.company_code, maint_company.company_name,sec_companyaccess.company_id ");
$this->db->order_by($sidx,$sord);
//$this->db->limit($rp, $start);
$query = $this->db->get("sec_companyaccess");
/* $sql = ("SELECT erp_sec_companyaccess.company_access_id as pkey,erp_sec_companyaccess.company_access_id, erp_maint_company.company_code, erp_maint_company.company_name,erp_sec_companyaccess.company_id
FROM erp_sec_companyaccess
INNER JOIN erp_sec_users
ON erp_sec_companyaccess.user_id= erp_sec_users.user_id
LEFT JOIN erp_maint_company
ON erp_sec_companyaccess.company_id=erp_maint_company.company_id
WHERE erp_sec_companyaccess.user_id= erp_sec_users.user_id");
$query = $this->db->query($sql);
$num = $this->db->count_all_results();*/
$this->db->flush_cache();
$data['db'] = $query;
$data['page'] = $page;
$data['totalpages'] = $total_pages;//code added by cess^^
$data['totalrecords']=$count; //- code added by cess
return $data;