Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] can't save transaction without details
#95

[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';    
        

        
        if (!$page) $page = 1;
        if (!$limit) $limit = 25;
        
        $start = (($page-1) * $limit);
        
        $this->db->start_cache();
        

        $this->db->join('maint_company','sec_companyaccess.company_id=maint_company.company_id','left');
        $this->db->join('sec_users ','sec_companyaccess.user_id=sec_users.user_id','left');
        //$item = $this->input->post('sec_users.user.id');
        $this->db->from('sec_companyaccess');
        $this->db->where("sec_companyaccess.user_id", $ids);//cess code added
        $count = $this->db->count_all_results(); //code added by cess
    
        
        // 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;            


    }

    
    function save_companydetail($details,$id)
    {

        $this->db->insert('maint_company', $details);
        $DataId = $this->db->insert_id();
        $data['user_id'] = $id;
        $data['company_id'] = $DataId;    
        $this->db->insert('sec_companyaccess', $data);
    }


i'll attached the javascript here


Messages In This Thread
[SOLVED] can't save transaction without details - by El Forum - 02-02-2010, 08:18 PM
[SOLVED] can't save transaction without details - by El Forum - 02-02-2010, 10:59 PM
[SOLVED] can't save transaction without details - by El Forum - 02-02-2010, 11:15 PM
[SOLVED] can't save transaction without details - by El Forum - 02-02-2010, 11:20 PM
[SOLVED] can't save transaction without details - by El Forum - 02-02-2010, 11:28 PM
[SOLVED] can't save transaction without details - by El Forum - 02-03-2010, 07:44 PM
[SOLVED] can't save transaction without details - by El Forum - 02-03-2010, 07:52 PM
[SOLVED] can't save transaction without details - by El Forum - 02-03-2010, 07:59 PM
[SOLVED] can't save transaction without details - by El Forum - 02-03-2010, 08:12 PM
[SOLVED] can't save transaction without details - by El Forum - 02-03-2010, 08:21 PM
[SOLVED] can't save transaction without details - by El Forum - 02-03-2010, 10:00 PM
[SOLVED] can't save transaction without details - by El Forum - 02-03-2010, 10:16 PM
[SOLVED] can't save transaction without details - by El Forum - 02-03-2010, 11:11 PM
[SOLVED] can't save transaction without details - by El Forum - 02-04-2010, 12:17 AM
[SOLVED] can't save transaction without details - by El Forum - 02-04-2010, 12:20 AM
[SOLVED] can't save transaction without details - by El Forum - 02-04-2010, 07:45 PM
[SOLVED] can't save transaction without details - by El Forum - 02-04-2010, 10:13 PM
[SOLVED] can't save transaction without details - by El Forum - 02-04-2010, 11:28 PM
[SOLVED] can't save transaction without details - by El Forum - 02-04-2010, 11:34 PM
[SOLVED] can't save transaction without details - by El Forum - 02-04-2010, 11:35 PM
[SOLVED] can't save transaction without details - by El Forum - 02-04-2010, 11:36 PM
[SOLVED] can't save transaction without details - by El Forum - 02-04-2010, 11:43 PM
[SOLVED] can't save transaction without details - by El Forum - 02-04-2010, 11:45 PM
[SOLVED] can't save transaction without details - by El Forum - 02-04-2010, 11:45 PM
[SOLVED] can't save transaction without details - by El Forum - 02-04-2010, 11:48 PM
[SOLVED] can't save transaction without details - by El Forum - 02-04-2010, 11:50 PM
[SOLVED] can't save transaction without details - by El Forum - 02-04-2010, 11:53 PM
[SOLVED] can't save transaction without details - by El Forum - 02-04-2010, 11:58 PM
[SOLVED] can't save transaction without details - by El Forum - 02-05-2010, 12:01 AM
[SOLVED] can't save transaction without details - by El Forum - 02-05-2010, 12:10 AM
[SOLVED] can't save transaction without details - by El Forum - 02-05-2010, 12:13 AM
[SOLVED] can't save transaction without details - by El Forum - 02-05-2010, 12:18 AM
[SOLVED] can't save transaction without details - by El Forum - 02-05-2010, 12:29 AM
[SOLVED] can't save transaction without details - by El Forum - 02-05-2010, 12:29 AM
[SOLVED] can't save transaction without details - by El Forum - 02-05-2010, 12:33 AM
[SOLVED] can't save transaction without details - by El Forum - 02-05-2010, 12:45 AM
[SOLVED] can't save transaction without details - by El Forum - 02-05-2010, 12:52 AM
[SOLVED] can't save transaction without details - by El Forum - 02-05-2010, 12:58 AM
[SOLVED] can't save transaction without details - by El Forum - 02-05-2010, 01:03 AM
[SOLVED] can't save transaction without details - by El Forum - 02-05-2010, 01:05 AM
[SOLVED] can't save transaction without details - by El Forum - 02-05-2010, 01:05 AM
[SOLVED] can't save transaction without details - by El Forum - 02-05-2010, 01:08 AM
[SOLVED] can't save transaction without details - by El Forum - 02-05-2010, 06:42 PM
[SOLVED] can't save transaction without details - by El Forum - 02-07-2010, 06:57 PM
[SOLVED] can't save transaction without details - by El Forum - 02-07-2010, 07:51 PM
[SOLVED] can't save transaction without details - by El Forum - 02-07-2010, 09:05 PM
[SOLVED] can't save transaction without details - by El Forum - 02-07-2010, 09:40 PM
[SOLVED] can't save transaction without details - by El Forum - 02-07-2010, 09:52 PM
[SOLVED] can't save transaction without details - by El Forum - 02-07-2010, 11:23 PM
[SOLVED] can't save transaction without details - by El Forum - 02-07-2010, 11:30 PM
[SOLVED] can't save transaction without details - by El Forum - 02-07-2010, 11:37 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 12:02 AM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 12:08 AM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 12:13 AM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 12:20 AM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 12:27 AM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 12:33 AM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 12:45 AM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 12:55 AM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 07:37 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 07:55 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 08:01 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 08:06 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 08:10 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 08:11 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 08:16 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 08:23 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 08:32 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 09:11 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 09:38 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 09:41 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 09:45 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 09:54 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 10:07 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 10:17 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 11:03 PM
[SOLVED] can't save transaction without details - by El Forum - 02-08-2010, 11:54 PM
[SOLVED] can't save transaction without details - by El Forum - 02-09-2010, 12:08 AM
[SOLVED] can't save transaction without details - by El Forum - 02-09-2010, 12:29 AM
[SOLVED] can't save transaction without details - by El Forum - 02-09-2010, 12:36 AM
[SOLVED] can't save transaction without details - by El Forum - 02-09-2010, 12:41 AM
[SOLVED] can't save transaction without details - by El Forum - 02-09-2010, 07:33 PM
[SOLVED] can't save transaction without details - by El Forum - 02-09-2010, 08:36 PM
[SOLVED] can't save transaction without details - by El Forum - 02-09-2010, 08:40 PM
[SOLVED] can't save transaction without details - by El Forum - 02-09-2010, 08:51 PM
[SOLVED] can't save transaction without details - by El Forum - 02-09-2010, 08:56 PM
[SOLVED] can't save transaction without details - by El Forum - 02-09-2010, 10:07 PM
[SOLVED] can't save transaction without details - by El Forum - 02-09-2010, 11:27 PM
[SOLVED] can't save transaction without details - by El Forum - 02-14-2010, 09:11 PM
[SOLVED] can't save transaction without details - by El Forum - 02-14-2010, 09:23 PM
[SOLVED] can't save transaction without details - by El Forum - 02-14-2010, 09:32 PM
[SOLVED] can't save transaction without details - by El Forum - 02-14-2010, 09:35 PM
[SOLVED] can't save transaction without details - by El Forum - 02-14-2010, 09:38 PM
[SOLVED] can't save transaction without details - by El Forum - 02-14-2010, 09:47 PM
[SOLVED] can't save transaction without details - by El Forum - 02-14-2010, 09:52 PM
[SOLVED] can't save transaction without details - by El Forum - 02-14-2010, 09:55 PM
[SOLVED] can't save transaction without details - by El Forum - 02-14-2010, 09:59 PM
[SOLVED] can't save transaction without details - by El Forum - 02-14-2010, 10:01 PM
[SOLVED] can't save transaction without details - by El Forum - 02-14-2010, 10:04 PM
[SOLVED] can't save transaction without details - by El Forum - 02-14-2010, 10:07 PM
[SOLVED] can't save transaction without details - by El Forum - 02-14-2010, 10:45 PM
[SOLVED] can't save transaction without details - by El Forum - 02-14-2010, 10:59 PM
[SOLVED] can't save transaction without details - by El Forum - 02-14-2010, 11:01 PM
[SOLVED] can't save transaction without details - by El Forum - 02-15-2010, 01:56 AM
[SOLVED] can't save transaction without details - by El Forum - 02-15-2010, 07:40 PM
[SOLVED] can't save transaction without details - by El Forum - 02-15-2010, 09:08 PM
[SOLVED] can't save transaction without details - by El Forum - 02-15-2010, 09:13 PM
[SOLVED] can't save transaction without details - by El Forum - 02-15-2010, 11:00 PM
[SOLVED] can't save transaction without details - by El Forum - 03-03-2010, 01:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB