[eluser]stuartr[/eluser]
I have a table of schools, and an action button for each row of the table.
One of the actions generates a modal form to allow additional data to be entered for the relevant school, with the following code
Code:
<!-- Add Invoice -->
<li><?php echo anchor('admin/add_invoice/'.$row['school_id'], lang('add_invoice'), array( 'id' => 'id_add_invoice_' . $row['school_id'], 'class' => 'setup bold clsAddInvoice', 'data-school_id' => $row['school_id']));?></li>
Code:
$(".clsAddInvoice").click(function(){
var schoolid = $(this).attr('data-school_id');
$("#dialog-form").find("#school_id").val(schoolid);
$( "#dialog-form" ).dialog( "open" );
return false;
});
This then triggers the modal form
Code:
<div id="dialog-form" title="Enter Invoice Details" auto;">
<p class="validateTips">All form fields are required.</p>
<p><span id="form_mesg"></span></p>
<?php
$attributes = array('class' => 'invoice', 'id' => 'add_invoice');
echo form_open('admin/add_invoice', $attributes);
echo "Enter Invoice Details Below<br />";
echo form_label('School ID: ', 'school_id');
echo form_input('school_id', '', 'id="school_id"');
echo br(2);
echo form_label('Inv Ref: ', 'inv_ref');
echo form_input('inv_ref', '', 'id="inv_ref"');
echo br(2);
echo form_label('Inv Date: ', 'inv_date');
echo form_input('inv_date', '', 'id="inv_date"');
echo br(2);
echo "Subscription Details<br />";
echo form_label('From: ', 'inv_period_start');
echo form_input('inv_period_start', '', 'id="inv_period_start"');
echo br(2);
echo form_label('To: ', 'inv_period_end');
echo form_input('inv_period_end', '', 'id="inv_period_end"');
?>
<p><span id="alert_mesg"></span></p>
</div>
which after validation posts the data via ajax (currently hard-coded the data for testing purposes)
Code:
$.ajax({
type: 'POST',
url: url,
//data: data,
data: { school_id: "13",
inv_ref: "XYZABC",
inv_date: "2012/12/31",
inv_period_start: "2012/12/31",
inv_period_end: "2012/12/31"
},
cache: false,
success: function (msg) {
alert( "Ajax Success: " + msg );
},
error: function (msg) {
alert( "Ajax Failure: " + msg );
}
});
I can see from firebug the post command, but the server is responding with a 500 error.
Post Summary from Firebug
Code:
POST http://test.local/admin/add_invoice 500 Internal Server Error
Code:
school_id=13&inv_ref=XYZABC&inv_date=2012%2F12%2F31&inv_period_start=2012%2F12%2F31&inv_period_end=2012%2F12%2F31
The server nginx error log shows the following error:
Code:
[error] 20977#0 *23 FastCGI sent in stderr: "PHP message: PHP Fatal error: Class 'CI_Controller' not found in /home/www-data/website/system/core/CodeIgniter.php on line 231" while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: localhost, request: "GET /admin/add_invoice?school_id=13&inv_ref=XYZABC&inv_date=2012%2F12%2F31&inv_period_start=2012%2F12%2F31&inv_period_end=2012%2F12%2F31 HTTP/1.1, upstream: "fastcgi://127.0.0.1:9000, host "test.local"
The controller that is being called has largely been stripped on its functionality while I was trying to diagnose the issue, and isn't making any call on the model at the moment.
Code:
function add_invoice()
{
if(!$this->tank_auth->is_admin_logged_in()) {
redirect('admin/admin_login');
} else {
//stripped out content
redirect('admin/invoices');
}
if($this->config->item('show_profiler'))
$this->output->enable_profiler(TRUE, get_defined_vars());
}