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

[eluser]theprodigy[/eluser]
show me the errors you are getting, and the save_detail method in your Main_company_db, and I will look at it tomorrow. It is late and I have work to do in the morning.
#42

[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1265375150"]show me the errors you are getting, and the save_detail method in your Main_company_db, and I will look at it tomorrow. It is late and I have work to do in the morning.[/quote]

here's my error:
Quote:<p>Severity: Notice</p>
<p>Message: Undefined property: Sec_users::$Main_company_db</p>
<p>Filename: controllers/sec_users.php</p>
<p>Line Number: 537</p>

</div><br />
<b>Fatal error</b>: Call to a member function getDetailList() on a non-object in <b>C:\xampp\htdocs\comunion\system\application\modules\sec_users\controllers\sec_users.php</b> on line <b>537</b><br />


and here is the save for the main_company_db:

Code:
function save($data,$item)
    {
    
        if ($item=='')
            {
            $this->db->trans_start();
            $this->db->insert('maint_company', $data);
            $item = $this->db->insert_id();
            $this->db->trans_complete();                    
            }
        else
            {
            $this->db->trans_start();
            $this->db->where('company_id', $item);
            $this->db->update('maint_company', $data);        
            $this->db->trans_complete();
            }
            
        return $item;    
    }

there's no save_detail in my main_company_db

thanks in advance,
kahtrina
#43

[eluser]theprodigy[/eluser]
Quote:Message: Undefined property: Sec_users::$Main_company_db
Quote:$this->load->model('Dataset_db');
$this->load->model('Users_db','User');
$this->load->model('Main_company_db');
Quote:and while the sec_companyaccess_db and the maint_company_db is for my detail grid..
Quote:there’s no save_detail in my main_company_db
Quote:$data['item'] = $this->Main_company_db->save_detail($id,$item);

based on these quotes, you need to make a couple of changes:
1. is it "Main_company_db" or "maint_company_db"?
2. save_detail($id,$item) does not exist in your maint_company_db, but you are calling it.
#44

[eluser]maria clara[/eluser]
Quote:based on these quotes, you need to make a couple of changes:
1. is it "Main_company_db" or "maint_company_db"?
2. save_detail($id,$item) does not exist in your maint_company_db, but you are calling it.

i used the Main_company_db because it is what being loaded in my Main_company.php and i change the save_detail($id,$item) to save($id,$item).

but i also tried to load two models in one controller but it says that it unable to locate the Main_company_db.

is it possible to load two models in the same controller??? my Main_company_db came from another Module for company details only..
#45

[eluser]maria clara[/eluser]
i have changed my code and i have this error shown in my console:

Quote:<h1>A Database Error Occurred</h1>
<p>Error Number: 1054</p><p>Unknown column 'Array' in 'where clause'</p><p>DELETE FROM `erp_maint_company`
WHERE `company_id` = Array</p> </div>

here's my new code for my controller:

Code:
case $crudConfig['create']:
                $c = "";
                $id['company_code'] = $this->input->post('company_code');
                $sec_exist = $this->User->getCompanyDetails($id);
                
                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])) $id[$field] = $this->input->post($field);}

                $item = $this->input->post("item");        
                $data['item'] = $this->User->savecompany_details($id,$item);
                }
                break;

i have made changes like i created a savecompany_details function and i call the getCompanyDetails funtion for my controller. and im loading the User model.

and here's my code for my model:

Code:
function savecompany_details($id,$rows)
    {
        $this->db->where('company_id', $id);
        $this->db->delete('maint_company');
        
        foreach ($rows as $row)
        {
            $rdata = explode('|', $row);
            
            $data['company_id'] = $id;
            $data['company_id'] = $rdata[3];    
            
            $this->db->insert('maint_company', $data);
        }
    }
    

function getCompanyDetails($data)
    {
        $this->db->where($data);
        return $this->db->get('maint_company')->row_array();        
    }


thanks for replies..
thanks in advance,
kahtrina
#46

[eluser]maria clara[/eluser]
hi,

i got this message in my console when i tried to add details in my detail grid and when i refresh it. it doesn't showing the data i added. my console message was this:

Quote:POST http://localhost/comunion/sec_users/detailpost

{"item":null}<br />
<b>Fatal error</b>: ob_start() [&lt;a href='ref.outcontrol'&gt;ref.outcontrol&lt;/a&gt;]: Cannot use output buffering in output buffering display handlers in <b>C:\xampp\htdocs\comunion\system\libraries\Exceptions.php</b> on line <b>162</b><br />

{"item":null}<br />
<b>Fatal error</b>: ob_start() [&lt;a href='ref.outcontrol'&gt;ref.outcontrol&lt;/a&gt;]: Cannot use output buffering in output buffering display handlers in <b>C:\xampp\htdocs\comunion\system\libraries\Exceptions.php</b> on line <b>162</b><br />

POST http://localhost/comunion/sec_users/detaillistview
{
page: 0,
total: 0,
records: 0,
rows: []
}

and i also changed again my code:

CONTROLLER:
Code:
case $crudConfig['create']:
                $c = "";
                $id['company_code'] = $this->input->post('company_code');
                $sec_exist = $this->User->getCompanyDetails($id);
                
                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])) $id[$field] = $this->input->post($field);}

                $id = $this->input->post("ids");        
                $data['item'] = $this->User->savecompany_details($id);
                }
                break;

MODEL:

Code:
function savecompany_details($id)
    {
        $this->db->where('company_id', $id);
        //$this->db->delete('maint_company');
    
    
        $data['company_id'] = $id;
        $this->db->insert('maint_company', $data);
    
    }

thanks in advance,
kahtrina
#47

[eluser]theprodigy[/eluser]
Quote:POST http://localhost/comunion/sec_users/detailpost
{“item”:null}

Fatal error: ob_start() [<a >ref.outcontrol</a>]: Cannot use output buffering in output buffering display handlers in C:\xampp\htdocs\comunion\system\libraries\Exceptions.php on line 162
Where are you calling ob_start()?

Quote:foreach ($fields as $field)
{if (isset($_POST[$field])) $id[$field] = $this->input->post($field);}

$id = $this->input->post("ids");
$data['item'] = $this->User->savecompany_details($id);
What's the point of the foreach loop?

Quote:function savecompany_details($id)
{
$this->db->where('company_id', $id);
//$this->db->delete('maint_company');


$data['company_id'] = $id;
$this->db->insert('maint_company', $data);

}
you might want to comment out the where function as well.
#48

[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1265622040"]
foreach ($fields as $field)
{if (isset($_POST[$field])) $id[$field] = $this->input->post($field);}

$id = $this->input->post("ids");
$data['item'] = $this->User->savecompany_details($id);
[/quote]
this is for when you are adding new data. if the condition above fails it continue to the foreach loop
[/quote]

i have commented the where as you've said.

Code:
function savecompany_details($id)
    {
        //$this->db->where('company_id', $id);
        //$this->db->delete('maint_company');
    
    
        $data['company_id'] = $id;
        $this->db->insert('maint_company', $data);
    
    }

and my console show me this:
Quote:Array
(
[company_code] => sdfsdf
[company_name] => sfsdfs
[id] => _empty
[oper] => add
)
{"id":null}<br />
because i have changed my code:

Code:
print_r($_POST);  // i put this to see what happen to $id
                $id = $this->input->post("id");        
                $data['id'] = $this->User->savecompany_details($id);
                }
                break;
#49

[eluser]theprodigy[/eluser]
$data['id'] is not getting populated because your savecompany_details($id) function in your model is not returning anything.

As for $_POST['id'], I'm not sure why it's not populated. Is it maybe supposed to be auto-incremented in the database and therefore not supposed to be filled in the $_POST array?
#50

[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1265628223"]$data['id'] is not getting populated because your savecompany_details($id) function in your model is not returning anything.

As for $_POST['id'], I'm not sure why it's not populated. Is it maybe supposed to be auto-incremented in the database and therefore not supposed to be filled in the $_POST array?[/quote]

yeah you're right it should be/ was really auto-incremented.

i changed again my code to this:
CONTROLLER:
Code:
case $crudConfig['create']:

                print_r($_POST);
                $id = $this->input->post("id");        
                $data['id'] = $this->User->savecompany_details($id);
                }
                break;

MODEL:

Code:
function savecompany_details($id)
    {
        
        $data['company_id'] = $id;
        $this->db->insert('maint_company', $data);
    
    }

still i have this:

Quote:Array
(
[company_code] => sdfsdf
[company_name] => sdfsdf
[id] => _empty
[oper] => add
)
{"id":null}




Theme © iAndrew 2016 - Forum software by © MyBB