Misc fixes from live site

This commit is contained in:
Deon George
2013-07-05 16:11:37 +10:00
parent a833d452dc
commit 1b057cd1e5
21 changed files with 80 additions and 65 deletions

View File

@@ -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:

View File

@@ -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>

View File

@@ -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',

View File

@@ -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();
}
}

View File

@@ -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();
}

View File

@@ -54,7 +54,8 @@
<?php if ($iio->service_id) : ?>
<tr>
<th>&nbsp;</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>&nbsp;</th>
<th><div class="text-right"><?php echo $o->service_items_total($iio,TRUE); ?></div></th>
</tr>

View File

@@ -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({

View File

@@ -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
))
);
}

View File

@@ -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'];
}

View File

@@ -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(

View File

@@ -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();

View File

@@ -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();
}