Work on invoice

This commit is contained in:
Deon George
2013-02-08 22:41:29 +11:00
parent 69645c4eea
commit 96a13548f1
5 changed files with 140 additions and 47 deletions

View File

@@ -9,6 +9,9 @@
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*
* This file contains enhancements for Kohana, that should be considered upstream and maybe havent been yet.
* It also contains some functionality for OSB, which cannot be covered in ORM_OSB.
*/
abstract class ORM extends Kohana_ORM {
protected $_table_names_plural = FALSE;
@@ -18,15 +21,6 @@ abstract class ORM extends Kohana_ORM {
// Our filters used to display values in a friendly format
protected $_display_filters = array();
// Add our OSB site_id to each SELECT query
final protected function _build($type) {
// Exclude tables without site ID's
if (! in_array($this->_table_name,Config::$no_site_id_tables))
$this->where($this->_object_name.'.site_id','=',Config::siteid());
return parent::_build($type);
}
/**
* Format fields for display purposes
*
@@ -94,6 +88,23 @@ abstract class ORM extends Kohana_ORM {
return (int) $count;
}
/** OSB SPECIFIC ENHANCEMENTS **
/**
* Add our OSB site_id to each SELECT query
* @see parent::__build()
*/
final protected function _build($type) {
// Exclude tables without site ID's
if (! in_array($this->_table_name,Config::$no_site_id_tables))
$this->where($this->_object_name.'.site_id','=',Config::siteid());
return parent::_build($type);
}
/**
* Function help to find records that are active
*/
protected function _where_active() {
return $this->where('status','=',TRUE);
}

View File

@@ -37,6 +37,10 @@ abstract class ORM_OSB extends ORM {
);
}
/**
* Auto process some data as it comes from the database
* @see parent::__get()
*/
public function __get($column) {
if (array_key_exists($column,$this->_table_columns)) {
// If the column is a blob, we'll decode it automatically
@@ -216,14 +220,17 @@ abstract class ORM_OSB extends ORM {
return parent::save($validation);
}
/**
* Function help to find records that are active
*/
public function list_active() {
return $this->_where_active()->find_all();
}
public function list_count($active=TRUE) {
$a=($active ? $this->_where_active() : $this);
$x=($active ? $this->_where_active() : $this);
return $a->find_all()->count();
return $x->find_all()->count();
}
}
?>