Changed use of active to status

This commit is contained in:
Deon George
2012-08-01 22:43:33 +10:00
parent e4d600b8d0
commit 4220ade8ac
40 changed files with 123 additions and 145 deletions

View File

@@ -25,7 +25,7 @@ class Model_ADSL_Supplier extends ORMOSB {
$a = $this->adsl_supplier_plan;
if ($active)
$a->where('status','=',TRUE);
$a->where_active();
return $a;
}
@@ -56,27 +56,18 @@ class Model_ADSL_Supplier extends ORMOSB {
// Start with all our ADSL Plans
foreach (ORM::factory('service')->list_bylistgroup('ADSL') as $so)
if (! $active OR $so->active)
if (! $active OR $so->status)
if (in_array($so->product->prod_plugin_data,$plans) OR in_array($so->plugin()->provided_adsl_plan_id,$plans))
array_push($services,$so);
// @todo poor cludge, we should find them without using list_bylistgroup()
if (! $services)
foreach (ORM::factory('service')->list_bylistgroup('HSPA') as $so)
if (! $active OR $so->active)
if (! $active OR $so->status)
if (in_array($so->product->prod_plugin_data,$plans) OR in_array($so->plugin()->provided_adsl_plan_id,$plans))
array_push($services,$so);
return $services;
}
/** LIST FUNCTIONS **/
/**
* Return a list of active suppliers
*/
public function list_active() {
return $this->where('status','=',1)->find_all();
}
}
?>

View File

@@ -160,7 +160,7 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
}
}
}
// If we got here and have data, we had a good fetch, update the stats date
$so->plugin()->service_stats_lastupdate = $lastday;
$so->plugin()->save();

View File

@@ -153,7 +153,7 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL {
}
}
}
// If we got here and have data, we had a good fetch, update the stats date
$so->plugin()->service_stats_lastupdate = $lastday;
$so->plugin()->save();

View File

@@ -89,7 +89,7 @@ class Service_Traffic_ADSL_iiNetADSL extends Service_Traffic_ADSL {
foreach ($day_hour->get('usage') as $usage) {
$fields = $usage->attributes();
// If we find a field we dont understand, we'll return.
if (empty($fields['type']) OR empty($this->fields[$fields['type']]))
return array();

View File

@@ -94,32 +94,32 @@ class Controller_Admin_Charge extends Controller_TemplateDefault_Admin {
source: "'.URL::site('admin/account/autocomplete').'",
minLength: 2,
change: function(event,ui) {
// Send the request and update sub category dropdown
$.ajax({
type: "GET",
data: "aid="+$(this).val(),
dataType: "json",
cache: false,
url: "'.URL::site('admin/service/autolist').'",
timeout: 2000,
error: function() {
alert("Failed to submit");
},
// Send the request and update sub category dropdown
$.ajax({
type: "GET",
data: "aid="+$(this).val(),
dataType: "json",
cache: false,
url: "'.URL::site('admin/service/autolist').'",
timeout: 2000,
error: function() {
alert("Failed to submit");
},
success: function(data) {
// Clear all options from sub category select
$("select[name=service_id] option").remove();
// Clear all options from sub category select
$("select[name=service_id] option").remove();
// Prepopulate a blank
var row = "<option value=\"\">&nbsp;</option>";
$(row).appendTo("select[name=service_id]");
// Fill sub category select
$.each(data, function(i, j){
var row = "<option value=\"" + j.value + "\">" + j.text + "</option>";
$(row).appendTo("select[name=service_id]");
});
}
});
var row = "<option value=\"\">&nbsp;</option>";
$(row).appendTo("select[name=service_id]");
// Fill sub category select
$.each(data, function(i, j){
var row = "<option value=\"" + j.value + "\">" + j.text + "</option>";
$(row).appendTo("select[name=service_id]");
});
}
});
}
});
});'

View File

@@ -34,7 +34,7 @@ class Model_Checkout extends ORMOSB {
$this->and_where('allow_new','=',TRUE);
foreach ($this->where('active','=',TRUE)->find_all() as $item) {
foreach ($this->list_active() as $item) {
// Check that the cart total meets the minimum requirement
if ($item->total_minimum AND $cart->total() < $item->total_minimum)
continue;

View File

@@ -27,12 +27,12 @@ class Model_Product_Plugin_Domain extends Model_Product_Plugin {
// @todo Change this to a view.
$output = sprintf('<table class="box-full"><tr class="head"><td>%s</td></tr><tr><td>',_('Domains are available with the following suffixes'));
$output .= Table::display(
$t->where('status','=','1')->find_all(),
$t->list_active(),
25,
array(
array(
'display("name")'=>array('label'=>'TLD Suffix'),
),
array(
array(
));
$output .= '</td></tr></table>';

View File

@@ -23,7 +23,7 @@ class Model_Email_Template extends ORMOSB {
);
protected $_display_filters = array(
'active'=>array(
'status'=>array(
array('StaticList_YesNo::display',array(':value')),
),
);

View File

@@ -5,7 +5,7 @@
</tr>
<tr>
<td class="head">Active:</td>
<td><?php echo StaticList_YesNo::form('active',TRUE); ?></td>
<td><?php echo StaticList_YesNo::form('status',TRUE); ?></td>
</tr>
<tr>
<td class="head">Notes:</td>

View File

@@ -5,7 +5,7 @@
</tr>
<tr>
<td class="head">Active:</td>
<td><?php echo StaticList_YesNo::form('active',$template->active); ?></td>
<td><?php echo StaticList_YesNo::form('status',$template->status); ?></td>
</tr>
<tr>
<td class="head">Notes:</td>

View File

@@ -1,4 +1,4 @@
<tr>
<td><a href="<?php echo URL::site('admin/email/templateedit/'.$template->id); ?>" alt=""><?php echo $template->name; ?></a></td>
<td><?php echo $template->display('active'); ?></td>
<td><?php echo $template->display('status'); ?></td>
</tr>

View File

@@ -510,15 +510,11 @@ class Model_Invoice extends ORMOSB {
return $return;
}
private function _list_active() {
return ORM::factory('invoice')->where('status','=',1);
}
private function _list_due() {
static $result = array();
if (! $result)
foreach ($this->_list_active()->find_all() as $io)
foreach ($this->list_active() as $io)
if ($io->due())
array_push($result,$io);

View File

@@ -204,7 +204,7 @@
</tr>
<!-- END Invoice Total -->
<!-- Account Total Due -->
<tr>
<tr>
<td class="head" colspan="2">Total Outstanding This Account:</td>
<td class="bold-right" colspan="2"><?php echo $io->account->invoices_due_total(NULL,TRUE); ?></td>
</tr>

View File

@@ -12,7 +12,7 @@
</tr>
<tr>
<td>Method</td>
<td><?php echo StaticList_Module::form('checkout_plugin_id','checkout',$po->checkout_plugin_id,'id','name',array('active'=>'=:1'),TRUE,array('class'=>'form_button'));?></td>
<td><?php echo StaticList_Module::form('checkout_plugin_id','checkout',$po->checkout_plugin_id,'id','name',array('status'=>'=:1'),TRUE,array('class'=>'form_button'));?></td>
</tr>
<tr>
<td>Amount</td>

View File

@@ -41,7 +41,7 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin {
if ($this->request->param('id'))
$prods = ORM::factory('product')->list_category($this->request->param('id'),FALSE);
else
$prods = ORM::factory('product')->order_by('active DESC,prod_plugin_file')->find_all();
$prods = ORM::factory('product')->order_by('status DESC,prod_plugin_file')->find_all();
Block::add(array(
'title'=>_('Customer Products'),
@@ -51,14 +51,14 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin {
array(
'id'=>array('label'=>'ID','url'=>'product/view/'),
'name()'=>array('label'=>'Details'),
'active'=>array('label'=>'Active'),
'status'=>array('label'=>'Active'),
'prod_plugin_file'=>array('label'=>'Plugin Name'),
'prod_plugin_data'=>array('label'=>'Plugin Data'),
'price_type'=>array('label'=>'Price Type'),
'price_base'=>array('label'=>'Price Base'),
'taxable'=>array('label'=>'Taxable'),
'services_count()'=>array('label'=>'Services'),
'invoices_count()'=>array('label'=>'Invoices'),
'count_services()'=>array('label'=>'Services'),
'count_invoices()'=>array('label'=>'Invoices'),
),
array(
'page'=>TRUE,
@@ -130,7 +130,7 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin {
'account->accnum()'=>array(),
'account->name()'=>array('label'=>'Account'),
'name()'=>array('label'=>'Details'),
'active'=>array('label'=>'Active'),
'status'=>array('label'=>'Active'),
'price(TRUE,TRUE)'=>array('label'=>'Price','align'=>'right'),
),
array(

View File

@@ -15,7 +15,7 @@ class Controller_Product extends Controller_TemplateDefault {
$output = '<div id="category">';
$output .= '<ul>';
foreach (ORM::factory('product_category')->list_active()->find_all() as $pco) {
foreach (ORM::factory('product_category')->list_active() as $pco) {
$a = '<h3>'.$pco->display('name').'</h3>';
$a .= '<p>'.$pco->description().'</p>';

View File

@@ -26,9 +26,6 @@ class Model_Product extends ORMOSB {
);
protected $_display_filters = array(
'active'=>array(
array('StaticList_YesNo::display',array(':value')),
),
'price_base'=>array(
array('Tax::add',array(':value')),
array('Currency::display',array(':value')),
@@ -36,6 +33,9 @@ class Model_Product extends ORMOSB {
'price_type'=>array(
array('StaticList_PriceType::display',array(':value')),
),
'status'=>array(
array('StaticList_YesNo::display',array(':value')),
),
'taxable'=>array(
array('StaticList_YesNo::display',array(':value')),
),
@@ -173,6 +173,20 @@ class Model_Product extends ORMOSB {
return array('price_base','price_setup');
}
/**
* List the number of services using this product
*/
public function count_services() {
return $this->service->list_count(TRUE);
}
/**
* List the number of invoices using this product
*/
public function count_invoices() {
return $this->invoice->list_count(TRUE);
}
/**
* Return the price for the particle group and price option for the period
*/
@@ -182,20 +196,6 @@ class Model_Product extends ORMOSB {
return isset($x[$grp][$option]) ? $x[$grp][$option] : NULL;
}
/**
* List the number of services using this product
*/
public function services_count() {
return $this->service->where('active','=',1)->find_all()->count();
}
/**
* List the number of invoices using this product
*/
public function invoices_count() {
return $this->invoice->where('status','=',1)->find_all()->count();
}
/**
* Return the products for a given category
* @todo This shouldnt be here.
@@ -203,10 +203,7 @@ class Model_Product extends ORMOSB {
public function list_category($cat,$active=TRUE) {
$results = array();
if ($active)
$cats = $this->where('active','=',TRUE);
else
$cats = $this;
$cats = $active ? $this->_where_active() : $this;
foreach ($cats->find_all() as $po) {
if ($c = unserialize($po->avail_category) AND in_array($cat,$c))

View File

@@ -30,10 +30,6 @@ class Model_Product_Category extends ORMOSB {
return ($a=$this->product_category_translate->where('language_id','=',$ao->language_id)->find()->description) ? $a : _('No Description');
}
public function list_active() {
return $this->where('status','=',1);
}
public function list_bylistgroup($cat) {
$result = array();

View File

@@ -7,7 +7,7 @@
<tr>
<td style="width: 40%;">Product Active</td>
<td style="width: 5%;">&nbsp;</td>
<td style="width: 60%;" class="data"><?php echo StaticList_YesNo::form('active',$po->active); ?></td>
<td style="width: 60%;" class="data"><?php echo StaticList_YesNo::form('status',$po->status); ?></td>
</tr>
<tr>
<td colspan="2">Base Price</td>

View File

@@ -34,7 +34,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
public function action_autolist() {
$return = array();
$s = ORM::factory('service')->where('active','=',1);
$s = ORM::factory('service')->where_active();
if (isset($_REQUEST['aid']))
$s = $s->where('account_id','=',$_REQUEST['aid']);
@@ -64,7 +64,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'active'=>array('label'=>'Active'),
'status'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
),
@@ -101,7 +101,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'active'=>array('label'=>'Active'),
'status'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'date_next_invoice'=>array('label'=>'Next Invoice'),
@@ -114,7 +114,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
)),
));
foreach (ORM::factory('checkout')->where('active','=',1)->find_all() as $co) {
foreach (ORM::factory('checkout')->list_active() as $co) {
$svs = array();
foreach ($co->account->find_all() as $ao)
@@ -133,7 +133,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'active'=>array('label'=>'Active'),
'status'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'date_next_invoice'=>array('label'=>'Next Invoice'),
@@ -209,7 +209,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'date_next_invoice'=>array('label'=>'Next Invoice'),
'product->display("active")'=>array('label'=>'Current'),
'product->display("status")'=>array('label'=>'Current'),
),
array(
'type'=>'select',
@@ -603,7 +603,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
'date_next_invoice'=>array('label'=>'Next Invoice'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'charges_new()'=>array('label'=>'Charges','class'=>'right'),
'active'=>array('label'=>'Active'),
'status'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
),

View File

@@ -34,7 +34,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'active'=>array('label'=>'Active'),
'status'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
),
@@ -71,7 +71,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'active'=>array('label'=>'Active'),
'status'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'date_next_invoice'=>array('label'=>'Next Invoice'),
@@ -89,7 +89,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
'body'=>_('None found'),
));
foreach (ORM::factory('checkout')->where('active','=',1)->find_all() as $co) {
foreach (ORM::factory('checkout')->list_active() as $co) {
$svs = array();
foreach ($co->account->find_all() as $ao)
@@ -108,7 +108,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'active'=>array('label'=>'Active'),
'status'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'date_next_invoice'=>array('label'=>'Next Invoice'),

View File

@@ -14,7 +14,7 @@ class Controller_Task_Service extends Controller_Task {
private function _traffic_suppliers($active=FALSE) {
$suppliers = ORM::factory('adsl_supplier');
return $active ? $suppliers->list_active() : $suppliers->find_all();
return $active ? $suppliers->list_active() : $suppliers->find_all();
}
/**

View File

@@ -47,7 +47,7 @@ class Controller_User_Service extends Controller_TemplateDefault_User {
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'active'=>array('label'=>'Active'),
'status'=>array('label'=>'Active'),
),
array(
'page'=>TRUE,

View File

@@ -32,9 +32,6 @@ class Model_Service extends ORMOSB {
* Filters used to format the display of values into friendlier values
*/
protected $_display_filters = array(
'active'=>array(
array('StaticList_YesNo::display',array(':value')),
),
'date_last_invoice'=>array(
array('Config::date',array(':value')),
),
@@ -44,6 +41,9 @@ class Model_Service extends ORMOSB {
'recur_schedule'=>array(
array('StaticList_RecurSchedule::display',array(':value')),
),
'status'=>array(
array('StaticList_YesNo::display',array(':value')),
),
);
/**
@@ -143,14 +143,6 @@ class Model_Service extends ORMOSB {
/** LIST FUNCTIONS **/
private function _list_active() {
return $this->where('active','=',1);
}
public function list_active() {
return $this->_list_active()->find_all();
}
public function list_bylistgroup($cat) {
$result = array();
@@ -174,7 +166,7 @@ class Model_Service extends ORMOSB {
* @param $days int Additional number of days to add to the query, above the module config.
*/
public function list_invoicesoon($days=0) {
return $this->_list_active()
return $this->_where_active()
->where_open()->where('suspend_billing','IS',NULL)->or_where('suspend_billing','=','0')->where_close()
->where('date_next_invoice','<',time()+(ORM::factory('invoice')->config('GEN_DAYS')+$days)*86400)
->find_all();
@@ -184,7 +176,7 @@ class Model_Service extends ORMOSB {
* List services that need to be provisioned
*/
public function list_provision() {
return $this->_list_active()->where('queue','=','PROVISION');
return $this->_where_active()->where('queue','=','PROVISION');
}
}
?>

View File

@@ -6,7 +6,7 @@
<table width="100%">
<tr>
<td style="width: 40%;">Service Active</td>
<td style="width: 60%;" class="data"><?php echo StaticList_YesNo::form('active',$so->active); ?></td>
<td style="width: 60%;" class="data"><?php echo StaticList_YesNo::form('status',$so->status); ?></td>
</tr>
<tr>
<td>Queue</td>

View File

@@ -10,7 +10,7 @@
</tr>
<tr>
<td>Service Active</td>
<td class="data"><?php echo $so->display('active'); ?></td>
<td class="data"><?php echo $so->display('status'); ?></td>
</tr>
<tr>
<td>Billing Period</td>

View File

@@ -25,7 +25,7 @@ class Controller_User_SSL extends Controller_TemplateDefault_User {
$passwd = $_POST['passwd'];
if (strlen($passwd) < Kohana::config('ssl.minpass_length')) {
SystemMessage::add(array(
'title'=>_('Validation failed'),
'title'=>_('Validation failed'),
'type'=>'error',
'body'=>_('Your requested password is too short.'),
));

View File

@@ -121,7 +121,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin {
}
public function download_button() {
if (! $this->service->active OR ! preg_match('/client/',$this->service->product->plugin()->extensions) OR $this->valid_to() < time())
if (! $this->service->status OR ! preg_match('/client/',$this->service->product->plugin()->extensions) OR $this->valid_to() < time())
return '';
// @todo Do some password validation

View File

@@ -81,14 +81,10 @@ class Model_Task extends ORMOSB {
/** LIST FUNCTIONS **/
private function _list_active() {
return $this->where('status','=',1)->find_all();
}
public function list_active() {
$return = array();
foreach ($this->_list_active() as $to) {
foreach ($this->_where_active()->find_all() as $to) {
$ct = sprintf('%s %s %s %s %s',$to->int_min,$to->int_hour,$to->int_month_day,$to->int_month,$to->int_week_day);
$c = new Cron($ct,$to->command);