Misc fixes from live site
This commit is contained in:
parent
a833d452dc
commit
1b057cd1e5
@ -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) {
|
||||
|
@ -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/')));
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
18
application/classes/Database.php
Normal file
18
application/classes/Database.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class extends the core Kohana class by adding some core application
|
||||
* specific functions, and configuration.
|
||||
*
|
||||
* @package OSB
|
||||
* @category Modifications
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
abstract class Database extends Kohana_Database {
|
||||
public function caching() {
|
||||
return isset($this->_config['caching']) ? $this->_config['caching'] : FALSE;
|
||||
}
|
||||
}
|
||||
?>
|
@ -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))
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -28,6 +28,7 @@ return array(
|
||||
'payment_item'=>60,
|
||||
'module'=>86400,
|
||||
'module_method'=>86400,
|
||||
'record_id'=>0,
|
||||
'setup'=>86400,
|
||||
),
|
||||
);
|
||||
|
@ -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:
|
||||
|
@ -1,8 +1,8 @@
|
||||
<tr class="<?php echo $i ? 'odd' : 'even'; ?>">
|
||||
<td><?php echo $service->plugin()->display('service_number'); ?></td>
|
||||
<td><?php echo $plan->adsl_supplier_plan->name().($planoverride ? '*' : ''); ?></td>
|
||||
<td><?php echo $service->plugin()->contract_date_start(); ?></td>
|
||||
<td><?php echo $service->plugin()->contract_date_end(); ?></td>
|
||||
<td><?php echo $service->plugin()->contract_date_start(TRUE); ?></td>
|
||||
<td><?php echo $service->plugin()->contract_date_end(TRUE); ?></td>
|
||||
<td><?php echo Currency::display($plan->adsl_supplier_plan->base_cost); ?></td>
|
||||
<td><?php echo Currency::display($plan->adsl_supplier_plan->base_cost+$plan->adsl_supplier_plan->tax()); ?></td>
|
||||
<td><input type="checkbox" <?php echo $checked; ?> onchange="paid(this);"/></td>
|
||||
|
@ -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('<div class="tab-pane %s" id="tab%s">',$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',
|
||||
|
@ -26,7 +26,10 @@ 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
|
||||
@ -35,7 +38,7 @@ class Model_Export_Module extends ORM_OSB {
|
||||
->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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,8 @@
|
||||
<?php if ($iio->service_id) : ?>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th colspan="2"><?php echo HTML::anchor(URL::link('user','service/view/'.$iio->service_id),$iio->service->id()).' '.$iio->service->service_name(); ?></th>
|
||||
<!-- @todo product->title() should be changed to show the service_name() for the invoice product item -->
|
||||
<th colspan="2"><?php echo HTML::anchor(URL::link('user','service/view/'.$iio->service_id),$iio->service->id()).' '.$iio->product->title(); ?></th>
|
||||
<th> </th>
|
||||
<th><div class="text-right"><?php echo $o->service_items_total($iio,TRUE); ?></div></th>
|
||||
</tr>
|
||||
|
@ -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({
|
||||
|
@ -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
|
||||
))
|
||||
);
|
||||
}
|
||||
|
@ -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'];
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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 .= '<div class="input-append">';
|
||||
$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 .= '</div>';
|
||||
$output .= Form::close();
|
||||
|
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user