CodeIgniter Forums
[SOLVED] can't save transaction without details - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: [SOLVED] can't save transaction without details (/showthread.php?tid=27165)

Pages: 1 2 3 4 5 6 7 8 9 10 11


[SOLVED] can't save transaction without details - El Forum - 02-14-2010

[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1266225784"]I'm assuming this is still on saving the new company through the jquery grid.

when submitting the add company form, does it contain the user id in a hidden field with the name "item"? Or, it doesn't even have to be a hidden field. Basically, are you submitting a form field, with the name "item" along with the rest of the form (company_name, company_code)?[/quote]

yes it is.

this part of the code is where my problem occur:

Code:
$item = $this->input->post("item");    
                $data['item'] = $this->User->save_companydetail($dt,$item);

because it was not posting the data but in my database it was added already. Now, my problem is how can i post it to show it in the browser.???


[SOLVED] can't save transaction without details - El Forum - 02-14-2010

[eluser]theprodigy[/eluser]
so, you want $data['item'] to be the new list of companies assigned to the user (the previous list, plus the new one just added)?


[SOLVED] can't save transaction without details - El Forum - 02-14-2010

[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1266226535"]so, you want $data['item'] to be the new list of companies assigned to the user (the previous list, plus the new one just added)?[/quote]

yes, exactly that's what i wanted. and i want it to post the data i added.


[SOLVED] can't save transaction without details - El Forum - 02-14-2010

[eluser]theprodigy[/eluser]
show me your users model, and the javascript code for your ajax company add call.


[SOLVED] can't save transaction without details - El Forum - 02-14-2010

[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


[SOLVED] can't save transaction without details - El Forum - 02-14-2010

[eluser]xeroblast[/eluser]
the switch doesnt work bcoz in your switch()

switch($postConfig['action']){ // has a value of 'oper'

and in your case

case $crudConfig['create']: // is same as case 'add'
case $crudConfig['update']: // is same as case 'edit'
case $crudConfig['delete']: // is same as case 'del'

there is no 'oper' in your case that is why you cant save/edit/delete...


[SOLVED] can't save transaction without details - El Forum - 02-14-2010

[eluser]maria clara[/eluser]
[quote author="xeroblast" date="1266227721"]the switch doesnt work bcoz in your switch()

switch($postConfig['action']){ // has a value of 'oper'

and in your case

case $crudConfig['create']: // is same as case 'add'
case $crudConfig['update']: // is same as case 'edit'
case $crudConfig['delete']: // is same as case 'del'

there is no 'oper' in your case that is why you cant save/edit/delete...[/quote]

what can i do with that???


[SOLVED] can't save transaction without details - El Forum - 02-14-2010

[eluser]theprodigy[/eluser]
Quote:foreach ($postConfig as $key => $value){
if(isset($_REQUEST[$value])){
$postConfig[$key] = fnCleanInputVar($_REQUEST[$value]);
}
}
That is the code that is over-writing it. $_REQUEST['oper'] is being passed in, and is set to 'add', therefore it is setting $postConfig['oper'] to 'add'.


[SOLVED] can't save transaction without details - El Forum - 02-14-2010

[eluser]maria clara[/eluser]
do i need to take this out of my code??

Code:
foreach ($postConfig as $key => $value){
        if(isset($_REQUEST[$value])){
          $postConfig[$key] = fnCleanInputVar($_REQUEST[$value]);
        }
      }



[SOLVED] can't save transaction without details - El Forum - 02-14-2010

[eluser]theprodigy[/eluser]
no, as I was saying, it is the code that is allowing it to work. You take it out and you will have to alter some other things to get your site to function again. I was just letting Xeroblast know the part of the code that is setting the $postConfig element.