Overhauled export, and other minor updates
This commit is contained in:
@@ -65,7 +65,7 @@ class Config extends Kohana_Config {
|
||||
}
|
||||
|
||||
public static function date($date) {
|
||||
return date(Company::instance()->date_format(),($date ? $date : time()));
|
||||
return is_null($date) ? NULL : date(Company::instance()->date_format(),$date);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -10,6 +10,9 @@
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Module_Method_Token extends ORM_OSB {
|
||||
// This module doesnt keep track of column updates automatically
|
||||
protected $_updated_column = FALSE;
|
||||
|
||||
// Relationships
|
||||
protected $_belongs_to = array(
|
||||
'account'=>array(),
|
||||
@@ -19,9 +22,6 @@ class Model_Module_Method_Token extends ORM_OSB {
|
||||
'record_id'=>array(),
|
||||
);
|
||||
|
||||
// This module doesnt keep track of column updates automatically
|
||||
protected $_update_column = FALSE;
|
||||
|
||||
public function method(array $modmeth) {
|
||||
list($module,$method) = $modmeth;
|
||||
|
||||
|
@@ -115,6 +115,10 @@ abstract class ORM extends Kohana_ORM {
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function display_filters(array $filters) {
|
||||
$this->_display_filters = Arr::merge($this->_display_filters,$filters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function help to find records that are active
|
||||
*/
|
||||
|
@@ -171,6 +171,10 @@ abstract class ORM_OSB extends ORM {
|
||||
return array_key_exists($key,$this->$column) ? $this->{$column}[$key] : NULL;
|
||||
}
|
||||
|
||||
final public function module() {
|
||||
return ORM::factory(Kohana::classname($this->name));
|
||||
}
|
||||
|
||||
final public function mid() {
|
||||
return ORM::factory('Module',array('name'=>$this->_table_name));
|
||||
}
|
||||
|
@@ -1,91 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This is class renders responses and forms based on the values from a module.
|
||||
*
|
||||
* @package OSB
|
||||
* @category Helpers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class StaticList_Module extends StaticList {
|
||||
protected static $record = array();
|
||||
|
||||
protected function _table() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a static name for a value
|
||||
*/
|
||||
public static function display($id) {
|
||||
// Override our argument list as defined in parent
|
||||
list($table,$key,$skey,$value) = func_get_args();
|
||||
$db = DB::select($key)->from($table)->where($skey,'=',$value)->execute();
|
||||
|
||||
if ($db->count() !== 1)
|
||||
return sprintf('No Value (%s)',$value);
|
||||
else
|
||||
return $db->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is to return the cached value of the current active record
|
||||
* This is so that a follow up call to get an attribute of a value retrieved
|
||||
* can reuse the active record values.
|
||||
* This gets over a limitation where the query to form() to get a default
|
||||
* no longer exists (or is invalid) and you want other attributes of the
|
||||
* remaining active record, which may not be the default record.
|
||||
*/
|
||||
public static function record($table,$attribute,$skey,$value) {
|
||||
if (empty(static::$record[$table]))
|
||||
return static::display($table,$attribute,$skey,$value);
|
||||
else
|
||||
return static::$record[$table][$attribute];
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders form input
|
||||
*/
|
||||
public static function form($name,$default='',$addblank=FALSE) {
|
||||
// Override our argument list as defined in parent
|
||||
list($name,$table,$default,$key,$value,$where,$addblank,$attributes) = func_get_args();
|
||||
|
||||
$db = DB::select()->from($table);
|
||||
|
||||
foreach ($where as $k=>$v) {
|
||||
list ($op,$v) = explode(':',$v);
|
||||
$db->where($k,$op,$v);
|
||||
}
|
||||
|
||||
$db = $db->execute();
|
||||
|
||||
// If we only have one record, dont make a select list
|
||||
if ($db->count() == 1) {
|
||||
static::$record[$table] = $db->as_array();
|
||||
static::$record[$table] = array_shift(static::$record[$table]);
|
||||
|
||||
return Form::hidden($name,$db->get($key)).$db->get($value);
|
||||
}
|
||||
|
||||
// Else we return a select list
|
||||
$x = array();
|
||||
if ($addblank)
|
||||
$x[] = '';
|
||||
|
||||
foreach ($db as $record) {
|
||||
$x[$record[$key]] = $record[$value];
|
||||
|
||||
// Save our static record, in case we reference this item again.
|
||||
if ($record[$key] == $default)
|
||||
static::$record[$table] = $record;
|
||||
}
|
||||
|
||||
return Form::select($name,$x,$default,$attributes);
|
||||
}
|
||||
|
||||
public static function get($value) {
|
||||
return static::factory()->_get($value);
|
||||
}
|
||||
}
|
||||
?>
|
@@ -52,8 +52,8 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="offset2">
|
||||
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||
<button type="button" class="btn">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||
<button type="button" class="btn">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
@@ -1,5 +0,0 @@
|
||||
<h1>Oops!</h1>
|
||||
<h2>403 Not Found or Not Authorised?</h2>
|
||||
<div class="error-details">
|
||||
Sorry, either the item doesnt exist, or you are not authorised to see it.
|
||||
</div>
|
@@ -1,5 +0,0 @@
|
||||
<h1>Oops!</h1>
|
||||
<h2>404 Not Found?</h2>
|
||||
<div class="error-details">
|
||||
Sorry, an error has occured, requested page not found?
|
||||
</div>
|
@@ -1,6 +0,0 @@
|
||||
<h1>Oops!</h1>
|
||||
<h2>501 Bother, something went wrong.</h2>
|
||||
<?php echo $message; ?>
|
||||
<div class="error-details">
|
||||
If this keeps happening, please let us know.
|
||||
</div>
|
@@ -57,7 +57,7 @@
|
||||
<tr>
|
||||
<td>Country</td>
|
||||
<!-- @todo - our default currency should be defined in a config -->
|
||||
<td><?php echo StaticList_Module::form('country_id','country',61,'id','name',array());?></td>
|
||||
<td><?php echo Form::select('country_id',ORM::factory('Country')->list_select(),$o->country_id,array('label'=>'Country','required')); ?></td>
|
||||
<!--
|
||||
{if $VAR.account_country_id != ''}
|
||||
{$list->menu('no','account_country_id','country','name',$VAR.account_country_id,'form_field" onchange="taxIdsDisplay(this.value)',true)}
|
||||
|
@@ -26,7 +26,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="head">Country</td>
|
||||
<td><?php echo StaticList_Module::form('country_id','country',61,'id','name',array(),NULL,array('class'=>'form_button'));?></td>
|
||||
<td><?php echo Form::select('country_id',ORM::factory('Country')->list_select(),$o->country_id,array('label'=>'Country','required')); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="spacer" colspan="2"> </td>
|
||||
|
Reference in New Issue
Block a user