diff --git a/application/classes/Config.php b/application/classes/Config.php
index 32c7c434..2a9ef5dc 100644
--- a/application/classes/Config.php
+++ b/application/classes/Config.php
@@ -170,7 +170,7 @@ class Config extends Kohana_Config {
public static function theme() {
// If we are using user admin pages (and login), we'll choose the admin theme.
- return URL::admin_url() ? 'theme/'.Kohana::$config->load('config')->theme_admin : 'theme/'.Kohana::$config->load('config')->theme;
+ return 'theme/'.(URL::admin_url() ? Kohana::$config->load('config')->theme_admin : Kohana::$config->load('config')->theme);
}
public static function time($date) {
diff --git a/application/classes/Controller/User/Search.php b/application/classes/Controller/User/Search.php
index b0698fcf..4c612ad6 100644
--- a/application/classes/Controller/User/Search.php
+++ b/application/classes/Controller/User/Search.php
@@ -22,8 +22,8 @@ class Controller_User_Search extends Controller_Search {
if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) {
$result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($_REQUEST['term'],'url','id',array('ACC %s: %s'=>array('id','name(TRUE)')),array(),array('urlprefix'=>'r/account/view/')));
- $result = Arr::merge($result,ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'url','id',array('INV %s: %s'=>array('id','account->name(TRUE)')),array(),array('urlprefix'=>'u/invoice/view/')));
$result = Arr::merge($result,ORM::factory('Service')->list_autocomplete($_REQUEST['term'],'url','id',array('SVC %s: %s'=>array('id','service_name()')),array(),array('urlprefix'=>'u/service/view/')));
+ $result = Arr::merge($result,ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'url','id',array('INV %s: %s'=>array('id','account->name(TRUE)')),array(),array('urlprefix'=>'u/invoice/view/')));
foreach (array('Service_Plugin_Adsl','Service_Plugin_Domain','Service_Plugin_Host') as $o)
$result = Arr::merge($result,ORM::factory($o)->list_autocomplete($_REQUEST['term'],'url','service_id',array('SVC %s: %s'=>array('service_id','service_name()')),array(),array('urlprefix'=>'u/service/view/')));
diff --git a/application/classes/Cookie.php b/application/classes/Cookie.php
index e00da708..0a5590b1 100644
--- a/application/classes/Cookie.php
+++ b/application/classes/Cookie.php
@@ -3,7 +3,7 @@
/**
* This class overrides Kohana's Cookie
*
- * @package OSB
+ * @package OSB/Modifications
* @category Helpers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
diff --git a/application/classes/Currency.php b/application/classes/Currency.php
index 73cf881f..95a0582e 100644
--- a/application/classes/Currency.php
+++ b/application/classes/Currency.php
@@ -11,6 +11,9 @@
*/
class Currency {
public static function display($amount) {
+ if (! is_numeric($amount))
+ $amount = 0;
+
return Num::format($amount,Company::instance()->decimals(),TRUE);
}
diff --git a/application/classes/Database.php b/application/classes/Database.php
new file mode 100644
index 00000000..eaa6264e
--- /dev/null
+++ b/application/classes/Database.php
@@ -0,0 +1,18 @@
+_config['caching']) ? $this->_config['caching'] : FALSE;
+ }
+}
+?>
diff --git a/application/classes/Kohana.php b/application/classes/Kohana.php
index 49c75692..c8ab0e21 100644
--- a/application/classes/Kohana.php
+++ b/application/classes/Kohana.php
@@ -37,11 +37,9 @@ abstract class Kohana extends Kohana_Core {
$prefixes = array('');
// Our search order.
- if (! preg_match('/^theme\//',$file)) {
- array_unshift($prefixes,Config::theme().'/');
- array_unshift($prefixes,sprintf('site/%s/',Config::siteid()));
- array_unshift($prefixes,sprintf('site/%s/%s/',Config::siteid(),Config::theme()));
- }
+ array_unshift($prefixes,Config::theme().'/');
+ array_unshift($prefixes,sprintf('site/%s/',Config::siteid()));
+ array_unshift($prefixes,sprintf('site/%s/%s/',Config::siteid(),Config::theme()));
foreach ($prefixes as $p)
if ($x = parent::find_file($dir,$p.$file,$ext,$array))
diff --git a/application/classes/Kohana/Exception.php b/application/classes/Kohana/Exception.php
index a9bdedf9..da988205 100644
--- a/application/classes/Kohana/Exception.php
+++ b/application/classes/Kohana/Exception.php
@@ -21,7 +21,7 @@ class Kohana_Exception extends Kohana_Kohana_Exception {
try {
$eo = ORM::factory('Log_Error');
$eo->message = Kohana_Exception::text($e);
- $eo->account_id = Auth::instance()->get_user()->id;
+ $eo->account_id = (PHP_SAPI === 'cli' OR ! Auth::instance()->logged_in()) ? NULL : Auth::instance()->get_user()->id;
if (Request::current()) {
$eo->module = (Request::current()->directory() ? Request::current()->directory().'_' : '').Request::current()->controller();
diff --git a/application/classes/ORM.php b/application/classes/ORM.php
index 10fdfff2..452e1153 100644
--- a/application/classes/ORM.php
+++ b/application/classes/ORM.php
@@ -65,6 +65,13 @@ abstract class ORM extends Kohana_ORM {
return $this->where('status','=',TRUE);
}
+ /**
+ * Overrides Kohana cache so that it can be globally disabled.
+ */
+ public function cached($lifetime=NULL) {
+ return $this->_db->caching() ? parent::cached($lifetime) : $this;
+ }
+
public function clear() {
$this->_formated = FALSE;
$this->_object_formated = array();
@@ -151,7 +158,7 @@ abstract class ORM extends Kohana_ORM {
$query->and_where($k,$s,$v);
}
- $c = 0;
+ $c = 0;
foreach ((empty($options['object']) ? $query->find_all() : $query->execute()) as $o) {
// If we got here via a DB query, we need to reload our ORM object from the result.
if (! is_object($o)) {
@@ -174,7 +181,7 @@ abstract class ORM extends Kohana_ORM {
}
$k = '';
- foreach ($label as $k => $details)
+ foreach ($label as $k => $details)
foreach ($details as $lvalue)
$k = preg_replace('/%s/',$o->resolve($lvalue),$k,1);
diff --git a/application/config/cache.php b/application/config/cache.php
index bb07e690..e9a7cb52 100644
--- a/application/config/cache.php
+++ b/application/config/cache.php
@@ -28,6 +28,7 @@ return array(
'payment_item'=>60,
'module'=>86400,
'module_method'=>86400,
+ 'record_id'=>0,
'setup'=>86400,
),
);
diff --git a/modules/adsl/classes/Model/Service/Plugin/Adsl.php b/modules/adsl/classes/Model/Service/Plugin/Adsl.php
index e017a1bb..2a590a8a 100644
--- a/modules/adsl/classes/Model/Service/Plugin/Adsl.php
+++ b/modules/adsl/classes/Model/Service/Plugin/Adsl.php
@@ -112,7 +112,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
/**
* Calculate the total traffic used in a month
*/
- private function get_traffic_data_month($period=NULL,$cache=NULL) {
+ private function get_traffic_data_month($period=NULL,$cache=0) {
$result = array();
foreach ($this->get_traffic_data_daily($period,TRUE,$cache) as $tdata)
@@ -128,11 +128,9 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
/**
* Return an array of the data used in a month by day
*/
- public function get_traffic_data_daily($period=NULL,$bydate=FALSE,$cache=NULL) {
+ public function get_traffic_data_daily($period=NULL,$bydate=FALSE,$cache=0) {
$result = array();
- // @temp - caching is broken?
- $cache=0;
if (is_null($period))
$period = strtotime('yesterday');
@@ -187,7 +185,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
return $result;
}
- public function traffic_month($month,$string=TRUE,$cache=NULL) {
+ public function traffic_month($month,$string=TRUE,$cache=0) {
return $string ? implode('/',$this->get_traffic_data_month($month,$cache)) :
$this->get_traffic_data_month($month,$cache);
}
@@ -354,7 +352,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
case 'invoice_detail_items':
return array(
_('Service Address')=>$this->service_address ? $this->display('service_address') : '>NotSet<',
- _('Contract Until')=>$this->contract_date_end(),
+ _('Contract Until')=>$this->contract_date_end(TRUE),
);
break;
default:
diff --git a/modules/adsl/views/service/admin/listadslbilling/body.php b/modules/adsl/views/service/admin/listadslbilling/body.php
index c41a43df..2065b0f0 100644
--- a/modules/adsl/views/service/admin/listadslbilling/body.php
+++ b/modules/adsl/views/service/admin/listadslbilling/body.php
@@ -1,8 +1,8 @@
plugin()->display('service_number'); ?> |
adsl_supplier_plan->name().($planoverride ? '*' : ''); ?> |
- plugin()->contract_date_start(); ?> |
- plugin()->contract_date_end(); ?> |
+ plugin()->contract_date_start(TRUE); ?> |
+ plugin()->contract_date_end(TRUE); ?> |
adsl_supplier_plan->base_cost); ?> |
adsl_supplier_plan->base_cost+$plan->adsl_supplier_plan->tax()); ?> |
onchange="paid(this);"/> |
diff --git a/modules/export/classes/Controller/Reseller/Export.php b/modules/export/classes/Controller/Reseller/Export.php
index 3242a749..91d36c15 100644
--- a/modules/export/classes/Controller/Reseller/Export.php
+++ b/modules/export/classes/Controller/Reseller/Export.php
@@ -37,6 +37,7 @@ class Controller_Reseller_Export extends Controller_Export {
$output .= Form::open(URL::link('reseller','export/list'));
$output .= Form::select('eid',ORM::factory('Export')->list_select());
$output .= Form::button('submit','Submit',array('class'=>'btn btn-primary'));
+ $output .= Form::hidden('days',$this->request->param('id'));
$output .= Form::close();
Block::factory()
@@ -74,7 +75,7 @@ class Controller_Reseller_Export extends Controller_Export {
$output .= sprintf('',$c++ ? '' : 'active',$emo->id);
$output .= Table::factory()
- ->data($emo->list_export())
+ ->data($emo->list_export($this->request->post('days')))
->jssort($emo->id)
->columns(Arr::merge(array(
'id'=>'ID',
diff --git a/modules/export/classes/Model/Export/Module.php b/modules/export/classes/Model/Export/Module.php
index 246997c5..6d17e94b 100644
--- a/modules/export/classes/Model/Export/Module.php
+++ b/modules/export/classes/Model/Export/Module.php
@@ -26,16 +26,19 @@ class Model_Export_Module extends ORM_OSB {
'display',
);
- public function list_export() {
+ public function list_export($days=NULL) {
+ if (! is_numeric($days))
+ $days = 90;
+
$o = $this->module->module();
- return $o
+ return $o
->select(array($this->export_item->table_name().'.date_orig','exported'))
->join($this->export_item->table_name(),'LEFT OUTER')
->on($this->export_item->table_name().'.site_id','=',$o->table_name().'.site_id') // @todo This should be automatic
->on($this->export_item->table_name().'.item_id','=',$o->table_name().'.id')
->on('export_module_id','=',$this->id)
- ->where($o->table_name().'.date_orig','>=',time()-86400*90)
+ ->where($o->table_name().'.date_orig','>=',time()-86400*$days)
->find_all();
}
}
diff --git a/modules/invoice/classes/Model/Invoice.php b/modules/invoice/classes/Model/Invoice.php
index 94c02b50..d010dfff 100644
--- a/modules/invoice/classes/Model/Invoice.php
+++ b/modules/invoice/classes/Model/Invoice.php
@@ -419,19 +419,8 @@ class Model_Invoice extends ORM_OSB implements Cartable {
* Check the reminder value
*/
public function remind($key) {
- if (! $this->loaded())
- return NULL;
-
- if (! trim($this->reminders))
- return FALSE;
-
- if (! preg_match('/^a:/',$this->reminders))
- throw new Kohana_Exception('Reminder is not an array? (:reminder)',array(':remind',$this->reminders));
-
- $remind = unserialize($this->reminders);
-
- if (isset($remind[$key]))
- return (is_array($remind[$key])) ? end($remind[$key]) : $remind[$key];
+ if (isset($this->reminders[$key]))
+ return (is_array($this->reminders[$key])) ? end($this->reminders[$key]) : $this->reminders[$key];
else
return FALSE;
}
@@ -475,33 +464,21 @@ class Model_Invoice extends ORM_OSB implements Cartable {
}
public function set_remind($key,$value,$add=FALSE) {
- if (! $this->loaded())
- throw new Kohana_Exception('Cant call :method when a record not loaded.',array(':method',__METHOD__));
-
- if (! trim($this->reminders)) {
- $remind = array();
-
- } else {
- if (! preg_match('/^a:/',$this->reminders))
- throw new Kohana_Exception('Reminder is not an array? (:reminder)',array(':remind',$this->reminders));
-
- $remind = unserialize($this->reminders);
- }
-
// If our value is null, we'll remove it.
- if (is_null($value) AND isset($remind[$key]))
- unset($remind[$key]);
- elseif ($add) {
- if (! is_array($a=$remind[$key]))
- $remind[$key] = array($a);
+ if (is_null($value) AND isset($this->reminders[$key]))
+ unset($this->reminders[$key]);
- $remind[$key][] = $value;
+ elseif ($add) {
+ if (! is_array($a=$this->reminders[$key]))
+ $this->reminders[$key] = array($a);
+
+ $this->reminders[$key][] = $value;
} else
- $remind[$key] = $value;
+ $this->reminders[$key] = $value;
- $this->reminders = serialize($remind);
$this->save();
+
return $this->saved();
}
diff --git a/modules/invoice/views/invoice/user/view.php b/modules/invoice/views/invoice/user/view.php
index e3b6a437..0cca3f09 100644
--- a/modules/invoice/views/invoice/user/view.php
+++ b/modules/invoice/views/invoice/user/view.php
@@ -54,7 +54,8 @@
service_id) : ?>
|
- service_id),$iio->service->id()).' '.$iio->service->service_name(); ?> |
+
+ service_id),$iio->service->id()).' '.$iio->product->title(); ?> |
|
service_items_total($iio,TRUE); ?> |
diff --git a/modules/payment/classes/Controller/Admin/Payment.php b/modules/payment/classes/Controller/Admin/Payment.php
index 8f5eae24..3bcb1bf7 100644
--- a/modules/payment/classes/Controller/Admin/Payment.php
+++ b/modules/payment/classes/Controller/Admin/Payment.php
@@ -125,7 +125,7 @@ $(document).ready(function() {
format : "dd-mm-yyyy",
todayBtn : true,
}).on("hide",function(ev) {
- $("input[name=date_payment]").val(ev.date.valueOf());
+ $("input[name=date_payment]").val(ev.date.valueOf()/1000);
});
$("input[name=account_id_label]").typeahead({
diff --git a/modules/payment/classes/Controller/Reseller/Payment.php b/modules/payment/classes/Controller/Reseller/Payment.php
index 7f990950..45c9be6d 100644
--- a/modules/payment/classes/Controller/Reseller/Payment.php
+++ b/modules/payment/classes/Controller/Reseller/Payment.php
@@ -28,13 +28,14 @@ class Controller_Reseller_Payment extends Controller_Payment {
'id'=>'ID',
'date_payment'=>'Date',
'checkout->display("name")'=>'Method',
+ 'total(TRUE)'=>'Total',
'balance(TRUE)'=>'Balance',
'invoicelist()'=>'Invoices',
'account->accnum()'=>'Cust ID',
'account->name()'=>'Customer',
))
->prepend(array(
- //'id'=>array('url'=>URL::link('reseller','payment/view/')), //@todo To Implement
+ //'id'=>array('url'=>URL::link('reseller','payment/edit/')), //@todo To Implement
))
);
}
diff --git a/modules/product/classes/Model/Product.php b/modules/product/classes/Model/Product.php
index 092a980d..33218abc 100644
--- a/modules/product/classes/Model/Product.php
+++ b/modules/product/classes/Model/Product.php
@@ -113,9 +113,9 @@ class Model_Product extends ORM_OSB {
if ($x = array_diff_key($_POST,$this->_object) AND ! empty($_POST['language_id']) AND ! empty($_POST['product_translate']) AND is_array($_POST['product_translate'])) {
$pto = $this->product_translate->where('language_id','=',$_POST['language_id'])->find();
- // For a new entry, we need to set the product_cat_id
+ // For a new entry, we need to set the product_id
if (! $pto->loaded()) {
- $pto->product_cat_id = $this->id;
+ $pto->product_id = $this->id;
$pto->language_id = $_POST['language_id'];
}
diff --git a/modules/product/classes/Model/Product/Translate.php b/modules/product/classes/Model/Product/Translate.php
index 01ccbb22..27193d5a 100644
--- a/modules/product/classes/Model/Product/Translate.php
+++ b/modules/product/classes/Model/Product/Translate.php
@@ -10,6 +10,7 @@
* @license http://dev.osbill.net/license.html
*/
class Model_Product_Translate extends ORM_OSB {
+ protected $_created_column = FALSE;
protected $_updated_column = FALSE;
protected $_belongs_to = array(
diff --git a/modules/ssl/classes/Model/Service/Plugin/Ssl.php b/modules/ssl/classes/Model/Service/Plugin/Ssl.php
index ee84d423..44d1fd82 100644
--- a/modules/ssl/classes/Model/Service/Plugin/Ssl.php
+++ b/modules/ssl/classes/Model/Service/Plugin/Ssl.php
@@ -113,7 +113,7 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
$output = Form::open(URL::link('user','ssl/download'),array('class'=>'form-inline'));
$output .= Form::hidden('sid',$this->service->id);
$output .= '
';
- $output .= Form::password('passwd','',array('label'=>_('Choose a password'),'placeholder'=>'Password','required','nocg'=>TRUE,'pattern'=>'.{6,}','title'=>'Minimum 6 chars'));
+ $output .= Form::password('passwd','',array('placeholder'=>_('Choose a password'),'required','nocg'=>TRUE,'pattern'=>'.{6,}','title'=>'Minimum 6 chars'));
$output .= Form::button('download','Download',array('class'=>'btn btn-default','nocg'=>TRUE));
$output .= '
';
$output .= Form::close();
diff --git a/modules/task/classes/Task/Task/Run.php b/modules/task/classes/Task/Task/Run.php
index eac08fda..5e382e10 100644
--- a/modules/task/classes/Task/Task/Run.php
+++ b/modules/task/classes/Task/Task/Run.php
@@ -18,7 +18,7 @@ class Task_Task_Run extends Minion_Task {
if (! $to->status)
throw new Minion_Exception_InvalidTask('Task :task (:name) NOT active',array(':task'=>$params['id'],':name'=>$to->name));
- Kohana::$config->load('debug')->task_sim ? printf("Would Run task: (%s) %s\n",$to->id,$to->name) : $this->_run($to,$params['force']);
+ Kohana::$config->load('debug')->task_sim ? printf("Would Run task: (%s) %s\n",$to->id,$to->name) : $this->_run($to,$params['force'],$params['verbose']);
} else
throw new Minion_Exception_InvalidTask('Unknown task :task',array(':task'=>$params['id']));
@@ -32,7 +32,10 @@ class Task_Task_Run extends Minion_Task {
}
}
- private function _run(Model_Task $to,$force=FALSE) {
+ private function _run(Model_Task $to,$force=FALSE,$verbose=FALSE) {
+ if ($verbose)
+ printf("Running Task: %s\n",$to->id);
+
$r = rand(0,9999);
$tlo = ORM::factory('Task_Log');
$tlo->task_id = $to->id;
@@ -95,6 +98,9 @@ class Task_Task_Run extends Minion_Task {
$to->save();
}
+ if ($verbose)
+ printf("Message: %s\n",$tlo->message);
+
if ($to->log)
$tlo->save();
}