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

@ -226,7 +226,7 @@ class Auth_OSB extends Auth_ORM {
} }
// If the passwords match, perform a login // If the passwords match, perform a login
if ($user->active AND $user->has_any('group',ORM::factory('group',array('name'=>'Registered Users'))->list_childgrps(TRUE)) AND $user->password === $password) if ($user->status AND $user->has_any('group',ORM::factory('group',array('name'=>'Registered Users'))->list_childgrps(TRUE)) AND $user->password === $password)
{ {
if ($remember === TRUE) if ($remember === TRUE)
{ {

View File

@ -79,7 +79,7 @@ class Controller_Admin_Welcome extends Controller_TemplateDefault_Admin {
'order'=>1, 'order'=>1,
)); ));
// Show un-applied payments // Show un-applied payments
Block_Sub::add(array( Block_Sub::add(array(
'title'=>'Unapplied Payments', 'title'=>'Unapplied Payments',
'body'=>Table::display( 'body'=>Table::display(

View File

@ -73,7 +73,7 @@ class Controller_Tree extends lnApp_Controller_Tree {
$subdata[$sub][$name]['name'] = preg_replace('/^(.*: )/','',$mmo->notes); $subdata[$sub][$name]['name'] = preg_replace('/^(.*: )/','',$mmo->notes);
$subdata[$sub][$name]['id'] = sprintf('%s_%s',$mmo->module_id,$id); $subdata[$sub][$name]['id'] = sprintf('%s_%s',$mmo->module_id,$id);
$subdata[$sub][$name]['href'] = (empty($details['page']) ? $url : $details['page']); $subdata[$sub][$name]['href'] = (empty($details['page']) ? $url : $details['page']);
} else { } else {
// We dont want to show these items again, if we can through on a submenu // We dont want to show these items again, if we can through on a submenu
if (! $idx) if (! $idx)

View File

@ -41,7 +41,7 @@ tinyMCE.init({
theme_advanced_buttons3_add_before : "tablecontrols,separator", theme_advanced_buttons3_add_before : "tablecontrols,separator",
theme_advanced_buttons3_add : "iespell,media,advhr", theme_advanced_buttons3_add : "iespell,media,advhr",
theme_advanced_toolbar_location : "bottom", theme_advanced_toolbar_location : "bottom",
theme_advanced_toolbar_align : "center", theme_advanced_toolbar_align : "center",
plugin_insertdate_dateFormat : "%Y-%m-%d", plugin_insertdate_dateFormat : "%Y-%m-%d",
plugin_insertdate_timeFormat : "%H:%M:%S", plugin_insertdate_timeFormat : "%H:%M:%S",
extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]", extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",

View File

@ -20,7 +20,7 @@ class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 {
public static function handler(Exception $e) public static function handler(Exception $e)
{ {
SystemMessage::add(array( SystemMessage::add(array(
'title'=>_('Page not found'), 'title'=>_('Page not found'),
'type'=>'error', 'type'=>'error',
'body'=>sprintf(_('The page [%s] you requested was not found?'),Request::detect_uri()), 'body'=>sprintf(_('The page [%s] you requested was not found?'),Request::detect_uri()),
)); ));

View File

@ -18,7 +18,7 @@ class Kohana extends Kohana_Core {
* unless each site has exactly the same modules enabled. * unless each site has exactly the same modules enabled.
* This is because Kohana::$file is cached with the enabled modules * This is because Kohana::$file is cached with the enabled modules
* and is not OSB multi-site aware. * and is not OSB multi-site aware.
* *
* @todo It might be nice to cache the Kohana::$file site-aware for improved performance * @todo It might be nice to cache the Kohana::$file site-aware for improved performance
*/ */
public static function shutdown_handler() { public static function shutdown_handler() {

View File

@ -33,13 +33,13 @@ class lnApp_Controller_Login extends Controller_TemplateDefault {
if ($redir = Session::instance()->get('afterlogin')) { if ($redir = Session::instance()->get('afterlogin')) {
Session::instance()->delete('afterlogin'); Session::instance()->delete('afterlogin');
Request::current()->redirect($redir); Request::current()->redirect($redir);
} else } else
Request::current()->redirect('user/welcome/index'); Request::current()->redirect('user/welcome/index');
} else { } else {
SystemMessage::add(array( SystemMessage::add(array(
'title'=>_('Invalid username or password'), 'title'=>_('Invalid username or password'),
'type'=>'error', 'type'=>'error',
'body'=>_('The username or password was invalid.') 'body'=>_('The username or password was invalid.')
)); ));
@ -81,7 +81,7 @@ class lnApp_Controller_Login extends Controller_TemplateDefault {
// Generic validation reason // Generic validation reason
default: default:
SystemMessage::add(array( SystemMessage::add(array(
'title'=>_('Validation failed'), 'title'=>_('Validation failed'),
'type'=>'error', 'type'=>'error',
'body'=>sprintf(_('The defaults on your submission were not valid for field %s (%s).'),$f,$r) 'body'=>sprintf(_('The defaults on your submission were not valid for field %s (%s).'),$f,$r)
)); ));
@ -100,7 +100,7 @@ class lnApp_Controller_Login extends Controller_TemplateDefault {
} }
SystemMessage::add(array( SystemMessage::add(array(
'title'=>_('Already have an account?'), 'title'=>_('Already have an account?'),
'type'=>'info', 'type'=>'info',
'body'=>_('If you already have an account, please login..') 'body'=>_('If you already have an account, please login..')
)); ));
@ -184,7 +184,7 @@ class lnApp_Controller_Login extends Controller_TemplateDefault {
public function action_noaccess() { public function action_noaccess() {
SystemMessage::add(array( SystemMessage::add(array(
'title'=>_('No access to requested resource'), 'title'=>_('No access to requested resource'),
'type'=>'error', 'type'=>'error',
'body'=>_('You do not have access to the requested resource, please contact your administrator.') 'body'=>_('You do not have access to the requested resource, please contact your administrator.')
)); ));

View File

@ -16,7 +16,7 @@ abstract class lnApp_PWgen {
throw new Kohana_Exception('No configuration for host or port (:host/:port)',array(':host'=>Kohana::Config('pwgen.host'),':port'=>Kohana::Config('pwgen.port'))); throw new Kohana_Exception('No configuration for host or port (:host/:port)',array(':host'=>Kohana::Config('pwgen.host'),':port'=>Kohana::Config('pwgen.port')));
$ps = socket_create(AF_INET,SOCK_STREAM,0); $ps = socket_create(AF_INET,SOCK_STREAM,0);
if (! socket_connect($ps,Kohana::Config('pwgen.host'),Kohana::Config('pwgen.port'))) if (! socket_connect($ps,Kohana::Config('pwgen.host'),Kohana::Config('pwgen.port')))
throw new Kohana_Exception('Unable to connect to password server'); throw new Kohana_Exception('Unable to connect to password server');
// echo "Reading response:\n\n"; // echo "Reading response:\n\n";

View File

@ -24,15 +24,15 @@ class Model_Account extends Model_Auth_UserDefault {
); );
protected $_display_filters = array( protected $_display_filters = array(
'active'=>array(
array('StaticList_YesNo::display',array(':value')),
),
'date_orig'=>array( 'date_orig'=>array(
array('Config::date',array(':value')), array('Config::date',array(':value')),
), ),
'date_last'=>array( 'date_last'=>array(
array('Config::date',array(':value')), array('Config::date',array(':value')),
), ),
'status'=>array(
array('StaticList_YesNo::display',array(':value')),
),
); );
/** /**
@ -67,7 +67,7 @@ class Model_Account extends Model_Auth_UserDefault {
} }
public function country($name) { public function country($name) {
return StaticList_Module::form($name,'country',$this->country_id,'id','name',array('active'=>'=:1'),FALSE,array('class'=>'form_button')); return StaticList_Module::form($name,'country',$this->country_id,'id','name',array('status'=>'=:1'),FALSE,array('class'=>'form_button'));
} }
/** /**
@ -133,12 +133,12 @@ class Model_Account extends Model_Auth_UserDefault {
return $alo->saved(); return $alo->saved();
} }
private function _active() { private function _where_active() {
return $this->where('active','=',TRUE); return $this->where('status','=',TRUE);
} }
public function list_active() { public function list_active() {
return $this->_active()->order_by('company,last_name,first_name')->find_all(); return $this->_where_active()->order_by('company,last_name,first_name')->find_all();
} }
public function list_affiliates() { public function list_affiliates() {
@ -152,7 +152,7 @@ class Model_Account extends Model_Auth_UserDefault {
} }
public function count_services($active=TRUE,$afid=NULL) { public function count_services($active=TRUE,$afid=NULL) {
return count($this->list_services($active,$afid)); return $this->list_services($active,$afid)->count();
} }
/** /**
@ -200,7 +200,7 @@ class Model_Account extends Model_Auth_UserDefault {
} }
public function list_services($active=TRUE,$afid=NULL) { public function list_services($active=TRUE,$afid=NULL) {
$svs = $this->service->where('active','=',$active); $svs = $this->service->where_active();
if ($afid) if ($afid)
$svs->where('affiliate_id','=',$afid); $svs->where('affiliate_id','=',$afid);

View File

@ -209,12 +209,22 @@ abstract class ORMOSB extends ORM {
return empty($mc[$key]) ? '' : $mc[$key]; return empty($mc[$key]) ? '' : $mc[$key];
} }
protected function _active() { protected function _where_active() {
return $this->where('active','=',TRUE); return $this->where('status','=',TRUE);
}
public function where_active() {
return $this->_where_active();
} }
public function list_active() { public function list_active() {
return $this->_active()->find_all(); return $this->_where_active()->find_all();
}
public function list_count($active=TRUE) {
$a=($active ? $this->_where_active() : $this);
return $a->find_all()->count();
} }
} }
?> ?>

View File

@ -20,7 +20,7 @@ class Valid extends Kohana_Valid {
* @return boolean * @return boolean
*/ */
public static function matches_ifset($array, $field, $match) public static function matches_ifset($array, $field, $match)
{ {
return isset($array[$match]) ? ($array[$field] === $array[$match]) : TRUE; return isset($array[$match]) ? ($array[$field] === $array[$match]) : TRUE;
} }
} }

View File

@ -25,7 +25,7 @@ class Model_ADSL_Supplier extends ORMOSB {
$a = $this->adsl_supplier_plan; $a = $this->adsl_supplier_plan;
if ($active) if ($active)
$a->where('status','=',TRUE); $a->where_active();
return $a; return $a;
} }
@ -56,27 +56,18 @@ class Model_ADSL_Supplier extends ORMOSB {
// Start with all our ADSL Plans // Start with all our ADSL Plans
foreach (ORM::factory('service')->list_bylistgroup('ADSL') as $so) 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)) if (in_array($so->product->prod_plugin_data,$plans) OR in_array($so->plugin()->provided_adsl_plan_id,$plans))
array_push($services,$so); array_push($services,$so);
// @todo poor cludge, we should find them without using list_bylistgroup() // @todo poor cludge, we should find them without using list_bylistgroup()
if (! $services) if (! $services)
foreach (ORM::factory('service')->list_bylistgroup('HSPA') as $so) 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)) if (in_array($so->product->prod_plugin_data,$plans) OR in_array($so->plugin()->provided_adsl_plan_id,$plans))
array_push($services,$so); array_push($services,$so);
return $services; 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 // If we got here and have data, we had a good fetch, update the stats date
$so->plugin()->service_stats_lastupdate = $lastday; $so->plugin()->service_stats_lastupdate = $lastday;
$so->plugin()->save(); $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 // If we got here and have data, we had a good fetch, update the stats date
$so->plugin()->service_stats_lastupdate = $lastday; $so->plugin()->service_stats_lastupdate = $lastday;
$so->plugin()->save(); $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) { foreach ($day_hour->get('usage') as $usage) {
$fields = $usage->attributes(); $fields = $usage->attributes();
// If we find a field we dont understand, we'll return. // If we find a field we dont understand, we'll return.
if (empty($fields['type']) OR empty($this->fields[$fields['type']])) if (empty($fields['type']) OR empty($this->fields[$fields['type']]))
return array(); return array();

View File

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

View File

@ -34,7 +34,7 @@ class Model_Checkout extends ORMOSB {
$this->and_where('allow_new','=',TRUE); $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 // Check that the cart total meets the minimum requirement
if ($item->total_minimum AND $cart->total() < $item->total_minimum) if ($item->total_minimum AND $cart->total() < $item->total_minimum)
continue; continue;

View File

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

View File

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

View File

@ -5,7 +5,7 @@
</tr> </tr>
<tr> <tr>
<td class="head">Active:</td> <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>
<tr> <tr>
<td class="head">Notes:</td> <td class="head">Notes:</td>

View File

@ -5,7 +5,7 @@
</tr> </tr>
<tr> <tr>
<td class="head">Active:</td> <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>
<tr> <tr>
<td class="head">Notes:</td> <td class="head">Notes:</td>

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@
</tr> </tr>
<tr> <tr>
<td>Method</td> <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>
<tr> <tr>
<td>Amount</td> <td>Amount</td>

View File

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

View File

@ -15,7 +15,7 @@ class Controller_Product extends Controller_TemplateDefault {
$output = '<div id="category">'; $output = '<div id="category">';
$output .= '<ul>'; $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 = '<h3>'.$pco->display('name').'</h3>';
$a .= '<p>'.$pco->description().'</p>'; $a .= '<p>'.$pco->description().'</p>';

View File

@ -26,9 +26,6 @@ class Model_Product extends ORMOSB {
); );
protected $_display_filters = array( protected $_display_filters = array(
'active'=>array(
array('StaticList_YesNo::display',array(':value')),
),
'price_base'=>array( 'price_base'=>array(
array('Tax::add',array(':value')), array('Tax::add',array(':value')),
array('Currency::display',array(':value')), array('Currency::display',array(':value')),
@ -36,6 +33,9 @@ class Model_Product extends ORMOSB {
'price_type'=>array( 'price_type'=>array(
array('StaticList_PriceType::display',array(':value')), array('StaticList_PriceType::display',array(':value')),
), ),
'status'=>array(
array('StaticList_YesNo::display',array(':value')),
),
'taxable'=>array( 'taxable'=>array(
array('StaticList_YesNo::display',array(':value')), array('StaticList_YesNo::display',array(':value')),
), ),
@ -173,6 +173,20 @@ class Model_Product extends ORMOSB {
return array('price_base','price_setup'); 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 * 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; 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 * Return the products for a given category
* @todo This shouldnt be here. * @todo This shouldnt be here.
@ -203,10 +203,7 @@ class Model_Product extends ORMOSB {
public function list_category($cat,$active=TRUE) { public function list_category($cat,$active=TRUE) {
$results = array(); $results = array();
if ($active) $cats = $active ? $this->_where_active() : $this;
$cats = $this->where('active','=',TRUE);
else
$cats = $this;
foreach ($cats->find_all() as $po) { foreach ($cats->find_all() as $po) {
if ($c = unserialize($po->avail_category) AND in_array($cat,$c)) 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'); 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) { public function list_bylistgroup($cat) {
$result = array(); $result = array();

View File

@ -7,7 +7,7 @@
<tr> <tr>
<td style="width: 40%;">Product Active</td> <td style="width: 40%;">Product Active</td>
<td style="width: 5%;">&nbsp;</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>
<tr> <tr>
<td colspan="2">Base Price</td> <td colspan="2">Base Price</td>

View File

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

View File

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

View File

@ -32,9 +32,6 @@ class Model_Service extends ORMOSB {
* Filters used to format the display of values into friendlier values * Filters used to format the display of values into friendlier values
*/ */
protected $_display_filters = array( protected $_display_filters = array(
'active'=>array(
array('StaticList_YesNo::display',array(':value')),
),
'date_last_invoice'=>array( 'date_last_invoice'=>array(
array('Config::date',array(':value')), array('Config::date',array(':value')),
), ),
@ -44,6 +41,9 @@ class Model_Service extends ORMOSB {
'recur_schedule'=>array( 'recur_schedule'=>array(
array('StaticList_RecurSchedule::display',array(':value')), 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 **/ /** 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) { public function list_bylistgroup($cat) {
$result = array(); $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. * @param $days int Additional number of days to add to the query, above the module config.
*/ */
public function list_invoicesoon($days=0) { 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_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) ->where('date_next_invoice','<',time()+(ORM::factory('invoice')->config('GEN_DAYS')+$days)*86400)
->find_all(); ->find_all();
@ -184,7 +176,7 @@ class Model_Service extends ORMOSB {
* List services that need to be provisioned * List services that need to be provisioned
*/ */
public function list_provision() { 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%"> <table width="100%">
<tr> <tr>
<td style="width: 40%;">Service Active</td> <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>
<tr> <tr>
<td>Queue</td> <td>Queue</td>

View File

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

View File

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

View File

@ -81,14 +81,10 @@ class Model_Task extends ORMOSB {
/** LIST FUNCTIONS **/ /** LIST FUNCTIONS **/
private function _list_active() {
return $this->where('status','=',1)->find_all();
}
public function list_active() { public function list_active() {
$return = array(); $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); $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); $c = new Cron($ct,$to->command);