Some cleanup, setup improvements and other misc items
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user