Some cleanup, setup improvements and other misc items

This commit is contained in:
Deon George
2013-10-09 16:43:41 +11:00
parent 638d123739
commit c473bf6e7d
54 changed files with 477 additions and 3991 deletions

View File

@@ -48,8 +48,8 @@ abstract class ORM extends Kohana_ORM {
/**
* Format fields for display purposes
*
* @param string column name
* @return mixed
* @param string column name
* @return mixed
*/
private function _format() {
foreach ($this->_display_filters as $column => $formats)
@@ -137,6 +137,21 @@ abstract class ORM extends Kohana_ORM {
$this->_display_filters = Arr::merge($this->_display_filters,$filters);
}
/**
* Show a bootstrap label button for a field with a boolean value
*/
public function label_bool($column,$render=FALSE) {
if (! isset($this->_table_columns[$column]))
return NULL;
if (! $render)
return $this->display($column);
return View::factory(Config::theme().'/label/bool')
->set('label',$this->$column ? 'label-success' : '')
->set('column',$this->display($column));
}
/**
* Function help to find records that are active
*/
@@ -203,8 +218,19 @@ abstract class ORM extends Kohana_ORM {
return $x;
}
public function status($render=FALSE) {
return $this->label_bool('status',$render);
}
public function where_active() {
return $this->_where_active();
}
public function where_authorised(Model_Account $ao=NULL,$aid='account_id') {
if (is_null($ao))
$ao = Auth::instance()->get_user();
return $this->where($aid,'IN',$ao->RTM->customers($ao->RTM));
}
}
?>