TRUE, 'list'=>TRUE, 'auditinvoiceitems'=>TRUE, ); /** * Show a list of invoices */ public function action_list() { Block::add(array( 'title'=>_('Customer Charges'), 'body'=>Table::display( ORM::factory('Charge')->where('sweep_type','>=',0)->order_by('date_orig DESC')->find_all(), 25, array( 'id'=>array('label'=>'ID','url'=>URL::link('user','charge/view/')), 'date_orig'=>array('label'=>'Date'), 'sweep_type'=>array('label'=>'Sweep'), 'status'=>array('label'=>'Status'), 'quantity'=>array('label'=>'Quantity','class'=>'right'), 'amount'=>array('label'=>'Total','class'=>'right'), 'description'=>array('label'=>'Description'), 'service_id'=>array('label'=>'Service'), 'account->accnum()'=>array('label'=>'Cust ID'), 'account->name()'=>array('label'=>'Customer'), 'attributes'=>array('label'=>'Attributes'), ), array( 'page'=>TRUE, 'type'=>'select', 'form'=>URL::link('user','charge/view'), )), )); } public function action_add() { $output = ''; $co = ORM::factory('Charge'); if ($_POST) { // Trim down our attributes if (is_array($_POST['attributes'])) foreach ($_POST['attributes'] as $k=>$v) if (! trim($v)) unset($_POST['attributes'][$k]); if ($co->values($_POST)->check()) { $co->status=0; // Entry updated if (! $co->save()) throw new Kohana_Exception('Unable to save charge'); } } $output .= Form::open(); $output .= View::factory($this->viewpath()); $output .= Form::submit('submit','submit'); $output .= Form::close(); Style::add(array( 'type'=>'stdin', 'data'=>'.ui-autocomplete-loading { background: white url("'.URL::site('media/img/ui-anim_basic_16x16.gif').'") right center no-repeat; }' )); Style::add(array( 'type'=>'file', 'data'=>'js/jquery.ui/css/smoothness/jquery-ui-1.8.16.custom.css', )); Script::add(array( 'type'=>'file', 'data'=>'js/jquery-ui-1.8.16.custom.min.js', )); Script::add(array('type'=>'stdin','data'=>' $(document).ready(function() { $("input[name=account_id]").autocomplete({ source: "'.URL::link('admin','account/ajaxlist').'", minLength: 2, change: function(event,ui) { // Send the request and update sub category dropdown $.ajax({ type: "GET", data: "aid="+$(this).val(), dataType: "json", cache: false, url: "'.URL::link('admin','service/ajaxlist',TRUE).'", timeout: 2000, error: function() { alert("Failed to submit"); }, success: function(data) { // Clear all options from sub category select $("select[name=service_id] option").remove(); // Prepopulate a blank var row = ""; $(row).appendTo("select[name=service_id]"); // Fill sub category select $.each(data, function(i, j){ var row = ""; $(row).appendTo("select[name=service_id]"); }); } }); } }); });' )); Block::add(array( 'title'=>_('Add Customer Charges'), 'body'=>$output, )); } } ?>