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

[eluser]theprodigy[/eluser]
when you post the new company that is created, is it possible to also post the user_id, so that you can populate the sec_companyaccess table as well? That will solve all your problems.

If you are creating a new user, then the only option I can come up with is to create a blank user row, and return the new user_id, then send to an edit form (thus having blank form fields, but already having a user_id).
Otherwise, you may have to re-work your site to the way I described before (create a company elsewhere, use the user-form to just assign the company to them - using a drop down to assign the company, or checkboxes to allow assigning multiple).
#82

[eluser]maria clara[/eluser]
how can i save the Company_code and company_name in Maint_company table and how can i get the company_id to be put in the sec_companyaccess table???

am thinking if i should put it here:

Code:
function savecompany_details($id) //Query for saving the company
    {
    
        $data['company_id'] = $id;
        $this->db->insert('maint_company',$id);
        
        //echo $this->db->last_query();
        
        return $this->db->insert_id();        
    }
#83

[eluser]theprodigy[/eluser]
Quote:how can i save the Company_code and company_name in Maint_company table and how can i get the company_id to be put in the sec_companyaccess table???

am thinking if i should put it here:
Yes, return $this->db->insert_id() (like you are doing) will return the company_id
#84

[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1265790994"]
Yes, return $this->db->insert_id() (like you are doing) will return the company_id[/quote]

yes, i see its returning the company_id. but what i want is to put the company_id to the sec_companyaccess table for it to be posted in the jquery grid. like while it is saving in the maint_company table that it will also save the company_id in the sec_companyaccess table
#85

[eluser]theprodigy[/eluser]
as I was trying to say earlier, if you have the user_id at that time, you can also save the data in the sec_companyaccess table. But if you don't then you will run into problems as both the company_id AND the user_id are required.
#86

[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1265791916"]as I was trying to say earlier, if you have the user_id at that time, you can also save the data in the sec_companyaccess table. But if you don't then you will run into problems as both the company_id AND the user_id are required.[/quote]

i got the logic.. i will have the user_id and company_id in the sec_companyaccess table when i submit the save button above the fields, but the problem is.. i wasn't able to post the company details in the jquery grid first.

because if i have successfully have done that.. i will be able to save the user_id and company_idin the sec_companyaccess table.

so, my real problem is to post the company details in the jquery grid.
#87

[eluser]theprodigy[/eluser]
Quote:so, my real problem is to post the company details in the jquery grid.
which you cannot do without the user_id
#88

[eluser]saidai jagan[/eluser]
WoW... a Thread consisting of 6 pages and still not ended Smile Great.
Thanks guyz for u r Helps.
#89

[eluser]maria clara[/eluser]
hi again to all,

i was able to populate the row in mt console like this:
Quote:{
page: 1,
total: 2,
records: 18,
rows: [{"id":"22","cell":["22",null,null,"59"]},{"id":"17","cell":["17",null,null,"54"]},{"id":"25","cell":["25",null,null,"62"]},{"id":"20","cell":["20",null,null,"57"]},{"id":"15","cell":["15",null,null,"52"]},{"id":"23","cell":["23",null,null,"60"]},{"id":"18","cell":["18",null,null,"55"]},{"id":"21","cell":["21",null,null,"58"]},{"id":"16","cell":["16",null,null,"53"]},{"id":"24","cell":["24",null,null,"61"]},{"id":"19","cell":["19",null,null,"56"]},{"id":"14","cell":["14",null,null,"51"]},{"id":"29","cell":["29","0000-5f","HEXAGON","66"]},{"id":"27","cell":["27","021890","CEZ","64"]},{"id":"26","cell":["26","1234","DELL","63"]},{"id":"30","cell":["30","555","abakada","68"]},{"id":"28","cell":["28","7777","AMA","65"]},{"id":"31","cell":["31","dgsdgsd","gsdgsd","69"]}]
}

but i have this also in my console:
Quote:{"item":null}<br />

here's my new code in CONTROLLER:

Code:
case $crudConfig['create']:
                $c = "";
                $dt['company_code'] = $this->input->post('company_code');
                $sec_exist = $this->User->getCompanyDetails($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");    
                #print_r($_POST);
                $data['item'] = $this->User->save_companydetail($dt,$item);
                }
                break;

and in my MODEL:

Code:
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);
    }

it was populating but i still it wasn't posting.

regards,
kahtrina
#90

[eluser]theprodigy[/eluser]
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)?




Theme © iAndrew 2016 - Forum software by © MyBB