Added Payment, other minor fixes

This commit is contained in:
Deon George
2011-12-20 16:46:10 +11:00
parent c8fd44f844
commit a40ce27a16
31 changed files with 452 additions and 1280 deletions

View File

@@ -71,7 +71,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault_User {
->set('io',$io);
Block::add(array(
'title'=>sprintf('%s: %s',_('Invoice'),$io->refnum()),
'title'=>sprintf('%s: %s - %s',_('Invoice'),$io->refnum(),$io->account->name()),
'body'=>$output,
));
}

View File

@@ -135,7 +135,7 @@ class Model_Invoice extends ORMOSB {
}
public function payments() {
return ($this->loaded() AND ! $this->_changed) ? $this->payment_item->find_all() : NULL;
return ($this->loaded() AND ! $this->_changed) ? $this->payment_item->find_all() : array();
}
public function payments_total($format=FALSE) {
@@ -406,6 +406,30 @@ class Model_Invoice extends ORMOSB {
/** LIST FUNCTIONS **/
/**
* Search for invoices matching a term
*/
public function list_autocomplete($term,$index='id') {
$return = array();
if (is_numeric($term)) {
$this->clear();
$value = 'account->name(TRUE)';
// Build our where clause
$this->where('id','like','%'.$term.'%');
// @todo This should limit the results so that users dont see other users services.
foreach ($this->find_all() as $o)
$return[$o->$index] = array(
'value'=>$o->$index,
'label'=>sprintf('INV %s: %s',$o->id,Table::resolve($o,$value)),
);
}
return $return;
}
private function _list_active() {
return ORM::factory('invoice')->where('status','=',1);
}