Major work to domain and hosting

Minor updates for ADSL services
Updates to Sort::MAsort()
Move core OSB items under application/
Moved ACCOUNT functions under application
Minor updates to task
This commit is contained in:
Deon George 2011-09-28 16:46:22 +10:00
parent 147d035e46
commit 130a87aa9a
199 changed files with 1536 additions and 10742 deletions

View File

@ -118,12 +118,12 @@ Kohana::modules(array(
/** /**
* Load our modules defined in the DB * Load our modules defined in the DB
*/ */
Kohana::modules(array_merge(Kohana::modules(),Config::appmodules())); Kohana::modules(array_merge(Kohana::modules(),Config::modules()));
/** /**
* Enable specalised interfaces * Enable specalised interfaces
*/ */
Route::set('sections', '<directory>/<controller>(/<action>(/<id>(/<sid>)))', Route::set('sections', '<directory>/<controller>/(<action>(/<id>(/<sid>)))',
array( array(
'directory' => '('.implode('|',Kohana::config('config.method_directory')).')' 'directory' => '('.implode('|',Kohana::config('config.method_directory')).')'
)); ));

View File

@ -226,6 +226,7 @@ class Auth_OSB extends Auth_ORM {
if (count($session_change_trigger) AND (session_id() != $oldsess)) { if (count($session_change_trigger) AND (session_id() != $oldsess)) {
foreach ($session_change_trigger as $t => $c) { foreach ($session_change_trigger as $t => $c) {
if (Config::moduleexist($c)) {
$orm = ORM::factory($t) $orm = ORM::factory($t)
->where($c,'=',$oldsess); ->where($c,'=',$oldsess);
@ -235,6 +236,7 @@ class Auth_OSB extends Auth_ORM {
->update(); ->update();
} }
} }
}
return TRUE; return TRUE;
} }

View File

@ -1,14 +1,14 @@
<?php defined('SYSPATH') or die('No direct access allowed.'); <?php defined('SYSPATH') or die('No direct access allowed.');
/** /**
* This class is for access company informaiton. * This class is for access company information.
* *
* @package OSB * @package OSB
* @subpackage Page * @subpackage System
* @category Helpers * @category Helpers
* @author Deon George * @author Deon George
* @copyright (c) 2010 Deon George * @copyright (c) 2010 Open Source Billing
* @license http://dev.leenooks.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Company { class Company {
public static function instance() { public static function instance() {

View File

@ -1,5 +1,15 @@
<?php defined('SYSPATH') or die('No direct access allowed.'); <?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is for access system configuration.
*
* @package OSB
* @subpackage Config
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Config extends lnApp_Config { class Config extends lnApp_Config {
// Our setup object // Our setup object
public $so; public $so;
@ -28,18 +38,18 @@ class Config extends lnApp_Config {
* Our available modules are defined in the DB (along with method * Our available modules are defined in the DB (along with method
* security). * security).
*/ */
public static function appmodules() { public static function modules() {
$modules = array(); static $return = array();
$module_table = 'module';
if (class_exists('Model_'.ucfirst($module_table))) { if (! count($return))
$mo = ORM::factory($module_table)->where('status','=',1)->find_all()->as_array(); foreach (ORM::factory('module')->where('status','=',1)->find_all() as $mo)
$return[$mo->name] = MODPATH.$mo->name;
foreach ($mo as $o) return $return;
$modules[$o->name] = MODPATH.$o->name;
} }
return $modules; public static function moduleexist($module) {
return array_key_exists($module,static::modules()) ? TRUE : FALSE;
} }
} }
?> ?>

View File

@ -32,7 +32,8 @@ class Controller_Admin_Welcome extends Controller_TemplateDefault {
'due_date'=>array('label'=>'Due Date'), 'due_date'=>array('label'=>'Due Date'),
'account->name()'=>array('label'=>'Account'), 'account->name()'=>array('label'=>'Account'),
'account->display("status")'=>array('label'=>'Active'), 'account->display("status")'=>array('label'=>'Active'),
'id()'=>array('label'=>'ID'), 'id'=>array('label'=>'ID','url'=>'user/invoice/view/'),
'total_amt'=>array('label'=>'Total','class'=>'right'),
'due(TRUE)'=>array('label'=>'Amount Due','class'=>'right'), 'due(TRUE)'=>array('label'=>'Amount Due','class'=>'right'),
), ),
array('page'=>TRUE)), array('page'=>TRUE)),
@ -49,7 +50,8 @@ class Controller_Admin_Welcome extends Controller_TemplateDefault {
'due_date'=>array('label'=>'Due Date'), 'due_date'=>array('label'=>'Due Date'),
'account->name()'=>array('label'=>'Account'), 'account->name()'=>array('label'=>'Account'),
'account->display("status")'=>array('label'=>'Active'), 'account->display("status")'=>array('label'=>'Active'),
'id()'=>array('label'=>'ID'), 'id'=>array('label'=>'ID','url'=>'user/invoice/view/'),
'total_amt'=>array('label'=>'Total','class'=>'right'),
'due(TRUE)'=>array('label'=>'Amount Due','class'=>'right'), 'due(TRUE)'=>array('label'=>'Amount Due','class'=>'right'),
), ),
array('page'=>TRUE)), array('page'=>TRUE)),
@ -60,13 +62,14 @@ class Controller_Admin_Welcome extends Controller_TemplateDefault {
Block_Sub::add(array( Block_Sub::add(array(
'title'=>'Invoices Due', 'title'=>'Invoices Due',
'body'=>Table::display( 'body'=>Table::display(
$o->list_due($t), $o->list_due(),
25, 25,
array( array(
'due_date'=>array('label'=>'Due Date'), 'due_date'=>array('label'=>'Due Date'),
'account->name()'=>array('label'), 'account->name()'=>array('label'),
'account->display("status")'=>array('label'=>'Active'), 'account->display("status")'=>array('label'=>'Active'),
'id()'=>array('label'=>'ID'), 'id'=>array('label'=>'ID','url'=>'user/invoice/view/'),
'total_amt'=>array('label'=>'Total','class'=>'right'),
'due(TRUE)'=>array('label'=>'Amount Due','class'=>'right'), 'due(TRUE)'=>array('label'=>'Amount Due','class'=>'right'),
), ),
array('show_other'=>'due()')), array('show_other'=>'due()')),
@ -83,9 +86,10 @@ class Controller_Admin_Welcome extends Controller_TemplateDefault {
$o->list_unapplied(), $o->list_unapplied(),
25, 25,
array( array(
'id'=>array('label'=>'ID'), 'date_payment'=>array('label'=>'Pay Date'),
'account->name()'=>array('label'=>'Account'), 'account->name()'=>array('label'=>'Account'),
'account->display("status")'=>array('label'=>'Active'), 'account->display("status")'=>array('label'=>'Active'),
'id'=>array('label'=>'ID','url'=>'user/payment/view/'),
'total_amt'=>array('label'=>'Total','class'=>'right'), 'total_amt'=>array('label'=>'Total','class'=>'right'),
'balance(TRUE)'=>array('label'=>'Balance','class'=>'right'), 'balance(TRUE)'=>array('label'=>'Balance','class'=>'right'),
), ),

View File

@ -152,6 +152,15 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
$this->meta->title = Kohana::Config('config.appname'); $this->meta->title = Kohana::Config('config.appname');
$this->template->title = ''; $this->template->title = '';
// Language
$this->meta->language = Config::instance()->so->language_id;
// Copyright
$this->meta->copywrite = Config::instance()->so->site_name;
// Copyright
$this->meta->description = sprintf('%s::%s',$this->request->controller(),$this->request->action());
// Style Sheets Properties // Style Sheets Properties
$this->meta->styles = Style::factory(); $this->meta->styles = Style::factory();

View File

@ -39,7 +39,7 @@ class Controller_TemplateDefault extends Controller_lnApp_TemplateDefault {
} }
private function _cart() { private function _cart() {
if (! class_exists('cart') OR ! Cart::instance()->contents()->reset(FALSE)->count_all()) if (! Config::moduleexist('cart') OR ! class_exists('cart') OR ! Cart::instance()->contents()->reset(FALSE)->count_all())
return ''; return '';
return Cart::instance()->cart_block(); return Cart::instance()->cart_block();

View File

@ -11,5 +11,20 @@
* @license http://dev.leenooks.net/license.html * @license http://dev.leenooks.net/license.html
*/ */
class Controller_TemplateDefault_Affiliate extends Controller_TemplateDefault_User { class Controller_TemplateDefault_Affiliate extends Controller_TemplateDefault_User {
/**
* This will filter a search query to only return the affiliates
*/
protected function filter($o,$af,$sort='account->name()',$afid='affiliate_id') {
$result = array();
foreach ($o as $x)
if ($x->$afid == $af)
array_push($result,$x);
if ($sort)
Sort::MAsort($result,$sort);
return $result;
}
} }
?> ?>

View File

@ -35,7 +35,7 @@ class Controller_Tree extends Controller_lnApp_Tree {
if ($mmo->menu_display AND empty($modules[$mmo->module_id])) if ($mmo->menu_display AND empty($modules[$mmo->module_id]))
$modules[$mmo->module_id] = $mmo->module; $modules[$mmo->module_id] = $mmo->module;
Sort::masort($modules,'name'); Sort::MAsort($modules,'name');
foreach ($modules as $id => $mo) foreach ($modules as $id => $mo)
if (! $mo->parent_id) if (! $mo->parent_id)
@ -52,7 +52,7 @@ class Controller_Tree extends Controller_lnApp_Tree {
if ($user->has_any('group',$gmo->list_childgrps(TRUE))) if ($user->has_any('group',$gmo->list_childgrps(TRUE)))
$methods[$mmo->id] = $mmo; $methods[$mmo->id] = $mmo;
Sort::masort($modules,'name'); Sort::MASort($modules,'name');
foreach ($methods as $id => $mmo) { foreach ($methods as $id => $mmo) {
if (preg_match('/_/',$mmo->name)) { if (preg_match('/_/',$mmo->name)) {

View File

@ -92,7 +92,7 @@ abstract class lnApp_Config extends Kohana_Config {
* Show a date using a site configured format * Show a date using a site configured format
*/ */
public static function date($date) { public static function date($date) {
return date(Kohana::config('config.date_format'),$date); return $date ? date(Kohana::config('config.date_format'),$date) : '&gtNot Set&lt';
} }
/** /**

View File

@ -20,75 +20,64 @@ class lnApp_Sort {
* @param boolean Whether to reverse sort. * @param boolean Whether to reverse sort.
* @return array Sorted multi demension array. * @return array Sorted multi demension array.
*/ */
public static function masort(&$data,$sortby,$rev=0) { public static function MAsort(&$data,$sortby,$rev=0) {
// if the array to sort is null or empty // if the array to sort is null or empty, or our sortby is bad
if (! $data) if (! preg_match('/^[a-zA-Z0-9_]+(\([a-zA-Z0-9_,]*\))?$/',$sortby) || ! $data)
return; return;
$code = "\$c=0;\n"; $code = '$c=0;';
foreach (explode(',',$sortby) as $key) { foreach (explode(',',$sortby) as $key) {
$code .= "if (is_object(\$a) || is_object(\$b)) {\n"; $code .= 'if (is_object($a) || is_object($b)) {';
foreach (array('a','b') as $x) {
$code .= 'if (is_array($'.$x.'->'.$key.')) {';
$code .= 'asort($'.$x.'->'.$key.');';
$code .= '$x'.$x.' = array_shift($'.$x.'->'.$key.');';
$code .= '} else';
$code .= '$x'.$x.' = $'.$x.'->'.$key.';';
}
$code .= " if (is_array(\$a->$key)) {\n"; $code .= 'if ($xa != $xb)';
$code .= " asort(\$a->$key);\n";
$code .= " \$aa = array_shift(\$a->$key);\n";
$code .= " } else\n";
$code .= " \$aa = \$a->$key;\n";
$code .= " if (is_array(\$b->$key)) {\n";
$code .= " asort(\$b->$key);\n";
$code .= " \$bb = array_shift(\$b->$key);\n";
$code .= " } else\n";
$code .= " \$bb = \$b->$key;\n";
$code .= " if (\$aa != \$bb)";
if ($rev) if ($rev)
$code .= " return (\$aa < \$bb ? 1 : -1);\n"; $code .= 'return ($xa < $xb ? 1 : -1);';
else else
$code .= " return (\$aa > \$bb ? 1 : -1);\n"; $code .= 'return ($xa > $xb ? 1 : -1);';
$code .= "} else {\n"; $code .= '} else {';
$code .= " \$a = array_change_key_case(\$a);\n"; foreach (array('a','b') as $x)
$code .= " \$b = array_change_key_case(\$b);\n"; $code .= '$'.$x.' = array_change_key_case($'.$x.');';
$key = strtolower($key); $key = strtolower($key);
$code .= " if ((! isset(\$a['$key'])) && isset(\$b['$key'])) return 1;\n"; $code .= 'if ((! isset($a[\''.$key.'\'])) && isset($b[\''.$key.'\'])) return 1;';
$code .= " if (isset(\$a['$key']) && (! isset(\$b['$key']))) return -1;\n"; $code .= 'if (isset($a[\''.$key.'\']) && (! isset($b[\''.$key.'\']))) return -1;';
$code .= " if ((isset(\$a['$key'])) && (isset(\$b['$key']))) {\n"; $code .= 'if ((isset($a[\''.$key.'\'])) && (isset($b[\''.$key.'\']))) {';
$code .= " if (is_array(\$a['$key'])) {\n"; foreach (array('a','b') as $x) {
$code .= " asort(\$a['$key']);\n"; $code .= 'if (is_array($'.$x.'[\''.$key.'\'])) {';
$code .= " \$aa = array_shift(\$a['$key']);\n"; $code .= 'asort($'.$x.'[\''.$key.'\']);';
$code .= " } else\n"; $code .= '$x'.$x.' = array_shift($'.$x.'[\''.$key.'\']);';
$code .= " \$aa = \$a['$key'];\n"; $code .= '} else';
$code .= '$x'.$x.' = $'.$x.'[\''.$key.'\'];';
}
$code .= " if (is_array(\$b['$key'])) {\n"; $code .= 'if ($xa != $xb)';
$code .= " asort(\$b['$key']);\n"; $code .= 'if (is_numeric($xa) && is_numeric($xb)) {';
$code .= " \$bb = array_shift(\$b['$key']);\n";
$code .= " } else\n";
$code .= " \$bb = \$b['$key'];\n";
$code .= " if (\$aa != \$bb)\n";
$code .= " if (is_numeric(\$aa) && is_numeric(\$bb)) {\n";
if ($rev) if ($rev)
$code .= " return (\$aa < \$bb ? 1 : -1);\n"; $code .= 'return ($xa < $xb ? 1 : -1);';
else else
$code .= " return (\$aa > \$bb ? 1 : -1);\n"; $code .= 'return ($xa > $xb ? 1 : -1);';
$code .= " } else {\n"; $code .= '} else {';
if ($rev) if ($rev)
$code .= " if ( (\$c = strcasecmp(\$bb,\$aa)) != 0 ) return \$c;\n"; $code .= 'if (($c = strcasecmp($xb,$xa)) != 0) return $c;';
else else
$code .= " if ( (\$c = strcasecmp(\$aa,\$bb)) != 0 ) return \$c;\n"; $code .= 'if (($c = strcasecmp($xa,$xb)) != 0) return $c;';
$code .= " }\n"; $code .= '}}}';
$code .= " }\n";
$code .= "}\n";
} }
$code .= 'return $c;'; $code .= 'return $c;';

View File

@ -201,7 +201,7 @@ $(document).ready(function() {
break; break;
} }
if ($pag OR ($i++ < $rows)) { if ($pag OR ($i++ < $rows) OR is_null($rows)) {
foreach (array_keys($cols) as $col) foreach (array_keys($cols) as $col)
$td[$col]['value'] = Table::resolve($do,$col); $td[$col]['value'] = Table::resolve($do,$col);

View File

@ -0,0 +1,15 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB Country Model
*
* @package OSB
* @subpackage Modules
* @category Models
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Country extends ORMOSB {
}
?>

View File

@ -0,0 +1,21 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB Setup Model
*
* This module must remain in applications/ as it is used very early in the
* OSB initialisation.
*
* @package OSB
* @subpackage Modules
* @category Models
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Setup extends ORMOSB {
protected $_has_one = array(
'country'=>array('foreign_key'=>'id','far_key'=>'country_id'),
);
}
?>

View File

@ -1,4 +1,4 @@
<?php defined('SYSPATH') or die('No direct access allowed.'); <?php defined('SYSPATH') or die('No direct access allowed.');
class sort extends lnApp_Sort {} class Sort extends lnApp_Sort {}
?> ?>

View File

@ -1,9 +1,10 @@
<?php defined('SYSPATH') or die('No direct access allowed.'); <?php defined('SYSPATH') or die('No direct access allowed.');
/** /**
* OSB authentication configuration * OSB Configuration - Authentication
* *
* @package OSB * @package OSB
* @subpackage Authentication
* @category Configuration * @category Configuration
* @author Deon George * @author Deon George
* @copyright (c) 2010 Open Source Billing * @copyright (c) 2010 Open Source Billing

View File

@ -1,20 +1,18 @@
<?php defined('SYSPATH') or die('No direct access allowed.'); <?php defined('SYSPATH') or die('No direct access allowed.');
/** /**
* lnApp Configuration - Cache Driver * OSB Configuration - Cache Driver
* *
* @package lnApp * @package OSB
* @subpackage Cache * @subpackage Cache
* @category Configuration * @category Configuration
* @author Deon George * @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team * @copyright (c) 2010 Open Source Billing
* @license http://phptsmadmin.sf.net/license.html * @license http://dev.osbill.net/license.html
*/ */
return array return array (
( 'file' => array (
'file' => array
(
'driver' => 'file', 'driver' => 'file',
'cache_dir' => Kohana::$cache_dir ? Kohana::$cache_dir : '/dev/shm/lnapp', 'cache_dir' => Kohana::$cache_dir ? Kohana::$cache_dir : '/dev/shm/lnapp',
'default_expire' => 3600, 'default_expire' => 3600,

View File

@ -1,9 +1,10 @@
<?php defined('SYSPATH') or die('No direct access allowed.'); <?php defined('SYSPATH') or die('No direct access allowed.');
/** /**
* OSB system default configurable items. * OSB Configuration - System Default Configurable Items.
* *
* @package OSB * @package OSB
* @subpackage System
* @category Configuration * @category Configuration
* @author Deon George * @author Deon George
* @copyright (c) 2010 Open Source Billing * @copyright (c) 2010 Open Source Billing

View File

@ -1,9 +1,10 @@
<?php defined('SYSPATH') or die('No direct access allowed.'); <?php defined('SYSPATH') or die('No direct access allowed.');
/** /**
* OSB Database configuration * OSB Configuration - Database Driver
* *
* @package OSB * @package OSB
* @subpackage Database
* @category Configuration * @category Configuration
* @author Deon George * @author Deon George
* @copyright (c) 2010 Open Source Billing * @copyright (c) 2010 Open Source Billing

View File

@ -1,14 +1,16 @@
<?php defined('SYSPATH') or die('No direct access allowed.'); <?php defined('SYSPATH') or die('No direct access allowed.');
/** /**
* OSB invoice configuration * OSB Configuration - Invoice Driver
* *
* @package OSB * @package OSB
* @subpackage Invoice
* @category Configuration * @category Configuration
* @author Deon George * @author Deon George
* @copyright (c) 2010 Open Source Billing * @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
return array( return array(
'driver' => 'default', 'driver' => 'default',
); );

View File

@ -1,15 +1,24 @@
<?php defined('SYSPATH') or die('No direct script access.'); <?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB Configuration - Pagination Driver
*
* @package OSB
* @subpackage Pagination
* @category Configuration
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
return array( return array(
// Application defaults
'default' => array( 'default' => array(
'current_page' => array('source' => 'query_string', 'key' => 'page'), // source: "query_string" or "route" 'current_page' => array('source' => 'query_string', 'key' => 'page'),
'total_items' => 0, 'total_items' => 0,
'items_per_page' => 20, 'items_per_page' => 20,
'view' => 'pagination/floating', 'view' => 'pagination/floating',
'auto_hide' => TRUE, 'auto_hide' => TRUE,
'first_page_in_url' => FALSE, 'first_page_in_url' => FALSE,
), ),
); );
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -1,306 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<construct>
<!-- Module name -->
<module>account</module>
<!-- Module supporting database table -->
<table>account</table>
<!-- Module dependancy(s) (module wont install if these modules are not yet installed) -->
<dependancy></dependancy>
<!-- DB cache in seconds -->
<cache>0</cache>
<!-- Default order_by field for SQL queries -->
<order_by>last_name</order_by>
<!-- Default SQL limit for SQL queries -->
<limit>25</limit>
<!-- Schema version (used to determine if the schema has change during upgrades) -->
<version>1</version>
<!-- Database indexes -->
<index>
<login>username,password</login>
<search>first_name,middle_name,last_name</search>
<company>company</company>
<email>email</email>
<affiliate>affiliate_id</affiliate>
<campaign_id>campaign_id</campaign_id>
<country>country_id</country>
<region>city,state</region>
<city>city</city>
<state>state</state>
<postal>zip</postal>
<idmain>id,site_id</idmain>
<fulltext_user>first_name,last_name,email,company</fulltext_user>
</index>
<!-- Database fields -->
<field>
<!-- Record ID -->
<id>
<index>1</index>
<type>I8</type>
<unique>1</unique>
</id>
<!-- Site ID -->
<site_id>
<index>1</index>
<type>I4</type>
</site_id>
<!-- Date record created -->
<date_orig>
<convert>date-now</convert>
<display>Date Created</display>
<type>I8</type>
</date_orig>
<!-- Date record updated -->
<date_last>
<convert>date-now</convert>
<display>Date Updated</display>
<type>I8</type>
</date_last>
<date_expire>
<type>I8</type>
<convert>date</convert>
<display>Date Expire</display>
</date_expire>
<parent_id>
<type>I4</type>
<display>Parent Account</display>
</parent_id>
<language_id>
<type>C(32)</type>
<display>Language</display>
</language_id>
<country_id>
<type>I4</type>
<display>Country</display>
</country_id>
<affiliate_id>
<type>I4</type>
</affiliate_id>
<campaign_id>
<type>I4</type>
</campaign_id>
<reseller_id>
<type>I4</type>
</reseller_id>
<currency_id>
<type>I4</type>
<display>Currency</display>
</currency_id>
<theme_id>
<type>C(32)</type>
<display>Theme</display>
</theme_id>
<username>
<type>C(128)</type>
<min_len>4</min_len>
<max_len>128</max_len>
<validate>any</validate>
<unique>1</unique>
<index>1</index>
<display>User Name</display>
</username>
<password>
<type>C(128)</type>
<min_len>6</min_len>
<max_len>128</max_len>
<validate>password</validate>
<convert>md5</convert>
<display>Password</display>
</password>
<!-- @unknown? -->
<misc>
<type>C2(128)</type>
</misc>
<!-- Record active (BOOL)-->
<status>
<display>Active</display>
<type>I4</type>
</status>
<first_name>
<type>C(128)</type>
<min_len>1</min_len>
<max_len>128</max_len>
<validate>any</validate>
<index>1</index>
<display>First Name</display>
</first_name>
<middle_name>
<type>C(128)</type>
<display>Middle Name</display>
</middle_name>
<last_name>
<type>C(128)</type>
<min_len>1</min_len>
<max_len>128</max_len>
<validate>any</validate>
<index>1</index>
<display>Last Name</display>
</last_name>
<title>
<type>C(128)</type>
<display>Title</display>
</title>
<email>
<type>C(255)</type>
<min_len>4</min_len>
<max_len>128</max_len>
<validate>email</validate>
<unique>1</unique>
<index>1</index>
<display>Email</display>
</email>
<company>
<type>C(255)</type>
<display>Company</display>
</company>
<address1>
<type>C(128)</type>
<min_len>3</min_len>
<max_len>128</max_len>
<validate>any</validate>
<display>Address</display>
</address1>
<address2>
<type>C(128)</type>
<max_len>128</max_len>
<display>Address</display>
</address2>
<city>
<type>C(32)</type>
<min_len>2</min_len>
<max_len>32</max_len>
<validate>any</validate>
<display>City</display>
</city>
<state>
<type>C(32)</type>
<min_len>2</min_len>
<max_len>32</max_len>
<validate>any</validate>
<display>State</display>
</state>
<zip>
<type>C(16)</type>
<min_len>4</min_len>
<max_len>16</max_len>
<validate>any</validate>
<display>Postal Code</display>
</zip>
<email_type>
<type>L</type>
<display>HTML Email</display>
</email_type>
<invoice_delivery>
<type>I4</type>
<display>Invoice Delivery</display>
</invoice_delivery>
<invoice_show_itemized>
<type>L</type>
<default>1</default>
<display>Show Itemised Invoice</display>
</invoice_show_itemized>
<invoice_grace>
<type>I4</type>
<display>Invoice Grace Period</display>
</invoice_grace>
<invoice_advance_gen>
<type>I4</type>
<display>Invoice Advance Generation</display>
</invoice_advance_gen>
<tax_id>
<type>C(64)</type>
<display>Tax ID</display>
</tax_id>
<max_child>
<type>I4</type>
<display>Max Children</display>
</max_child>
<!-- Credit Terms applicable for this account -->
<net_term_id>
<type>I4</type>
<display>Net Terms</display>
</net_term_id>
</field>
<!-- Methods for this class, and the fields they have access to, if applicable -->
<method>
<user_add>date_orig,date_last,language_id,country_id,affiliate_id,reseller_id,campaign_id,currency_id,theme_id,username,password,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,email_type,tax_id,invoice_delivery,invoice_show_itemized,invoice_grace</user_add>
<user_update>id,date_orig,date_last,language_id,country_id,affiliate_id,reseller_id,currency_id,theme_id,username,password,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,email_type,tax_id</user_update>
<user_view>id,parent_id,date_last,language_id,country_id,affiliate_id,reseller_id,currency_id,theme_id,username,password,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,email_type,tax_id,max_child</user_view>
<delete>id</delete>
<add>search,date_expire,language_id,country_id,currency_id,theme_id,username,password,misc,status,first_name,middle_name,last_name,title,email,email_type,company,address1,address2,city,state,zip</add>
<update>id,date_orig,date_last,date_expire,parent_id,language_id,country_id,affiliate_id,campaign_id,reseller_id,currency_id,theme_id,username,password,misc,status,first_name,middle_name,last_name,title,email,email_type,company,address1,address2,city,state,zip,invoice_delivery,invoice_show_itemized,invoice_grace,invoice_advance_gen,tax_id,max_child</update>
<view>id,date_orig,date_last,date_expire,parent_id,language_id,country_id,affiliate_id,campaign_id,reseller_id,currency_id,theme_id,username,password,misc,status,first_name,middle_name,last_name,title,email,email_type,company,address1,address2,city,state,zip,invoice_delivery,invoice_show_itemized,invoice_grace,invoice_advance_gen,tax_id,max_child</view>
<search>id,date_orig,date_last,date_expire,parent_id,language_id,country_id,affiliate_id,campaign_id,reseller_id,currency_id,theme_id,username,password,misc,status,first_name,middle_name,last_name,title,email,email_type,company,address1,address2,city,state,zip,invoice_delivery,invoice_show_itemized,invoice_grace,invoice_advance_gen,tax_id,max_child</search>
<search_export>id,date_orig,date_last,date_expire,parent_id,language_id,country_id,affiliate_id,campaign_id,reseller_id,currency_id,theme_id,username,password,misc,status,first_name,middle_name,last_name,title,email,email_type,company,address1,address2,city,state,zip,tax_id,max_child</search_export>
<export_excel>language_id,country_id,affiliate_id,campaign_id,currency_id,username,password,misc,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,tax_id</export_excel>
<export_xml>language_id,country_id,affiliate_id,campaign_id,currency_id,username,password,misc,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,tax_id</export_xml>
<export_csv>language_id,country_id,affiliate_id,campaign_id,currency_id,username,password,misc,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,tax_id</export_csv>
<export_tab>language_id,country_id,affiliate_id,campaign_id,currency_id,username,password,misc,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,tax_id</export_tab>
</method>
<!-- Method triggers -->
<trigger>
<add>
<success>account:add_account_groups</success>
</add>
<update>
<success>account:update_account_groups</success>
</update>
</trigger>
<!-- Template page display titles -->
<title>
<add>Register User Account</add>
<mail_one>Send Email to User</mail_one>
<merge>Merge User Accounts</merge>
<search_form>Search</search_form>
<user_add>Register User Account</user_add>
<user_view>Update User Account</user_view>
<user_password>Reset Password</user_password>
<user_password_reset>Reset Password</user_password_reset>
<user_verify>Enter Verification Code</user_verify>
<user_verify_resend>Resend Verification Email</user_verify_resend>
<view>Account</view>
</title>
<!-- Template helpers -->
<tpl>
<search_show>
<checkbox>
<field>id</field>
<type>checkbox</type>
<width>25px</width>
</checkbox>
<icon>
<field>status</field>
<type>bool_icon</type>
<width>20px</width>
</icon>
<last_name>
<field>last_name</field>
</last_name>
<first_name>
<field>first_name</field>
</first_name>
<username>
<field>username</field>
<truncate>25</truncate>
</username>
<email>
<field>email</field>
<truncate>25</truncate>
</email>
<last>
<type>literal</type>
<width>120px</width>
<data><![CDATA[<div style="text-align: center;">
<a href="?_page=account_admin:mail_one&amp;mail_account_id=%%id%%"><img title="Send E-mail" src="themes/default/images/icons/mail_16.gif" alt="Email" width="16" height="16" style="border: 0px;"/></a>
<a title="Services" href="?_page=core:search&amp;module=service&amp;service_account_id=%%id%%&amp;_next_page_one=view"><img src="themes/default/images/icons/tools_16.gif" alt="Service" width="16" height="16" style="border: 0px;"/></a>
<a title="Invoices" href="?_page=core:search&amp;module=invoice&amp;invoice_account_id=%%id%%&amp;_next_page_one=view"><img src="themes/default/images/icons/calc_16.gif" alt="Invoice" width="16" height="16" style="border: 0px;"/></a>
</div>]]></data>
</last>
</search_show>
</tpl>
</construct>

View File

@ -1,101 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<!-- Tree Menu Module Properties -->
<module_properties>
<!-- MODULE Dependancy, this module wont be installed if the dependant modules dont exist -->
<dependancy></dependancy>
<!-- Translated display to use on the tree -->
<display>Account</display>
<!-- Display a module in the menu tree -->
<menu_display>1</menu_display>
<!-- MODULE Name -->
<name>account</name>
<!-- MODULE Notes, these notes show up in the modules table, as a description of the module -->
<notes><![CDATA[This is the account module for all accounts and administrators.]]></notes>
<!-- MODULE Parent, the parent node in the tree -->
<parent></parent>
<!-- SUB Modules to install with this one -->
<sub_modules></sub_modules>
<!-- MODULE Type (core|base), core modules cannot be deleted, unrecognised types are ignored. -->
<type>base</type>
</module_properties>
<!-- Tree Menu & Module Methods to load, they will be assigned the group permissions on install time, as selected by the user. -->
<module_method>
<add>
<display>Add</display>
<menu_display>1</menu_display>
<name>add</name>
<notes><![CDATA[Add records]]></notes>
</add>
<delete>
<name>delete</name>
<notes><![CDATA[Delete records]]></notes>
</delete>
<search>
<display>List</display>
<menu_display>1</menu_display>
<name>search</name>
<notes><![CDATA[List records]]></notes>
<page><![CDATA[core:search&module=%%&_next_page_one=view]]></page>
</search>
<search_form>
<display>Search</display>
<menu_display>1</menu_display>
<name>search_form</name>
<notes><![CDATA[Search for records]]></notes>
</search_form>
<search_show>
<name>search_show</name>
<notes><![CDATA[Show the results of a search]]></notes>
</search_show>
<update>
<name>update</name>
<notes><![CDATA[Update a record]]></notes>
</update>
<view>
<name>view</name>
<notes><![CDATA[View a record]]></notes>
</view>
<search_export>
<name>search_export</name>
</search_export>
<install>
<name>install</name>
</install>
<update_account_groups>
<name>update_account_groups</name>
<notes><![CDATA[This method is triggered to add the account to the specified groups when added]]></notes>
</update_account_groups>
<send_verify_email>
<name>send_verify_email</name>
<notes><![CDATA[Sends the user the change password instructions]]></notes>
</send_verify_email>
<send_password_email>
<name>send_password_email</name>
<notes><![CDATA[Sends the user the change password instructions]]></notes>
</send_password_email>
<mail_multi>
<name>mail_multi</name>
</mail_multi>
<mail_one>
<name>mail_one</name>
</mail_one>
<autoselect>
<name>autoselect</name>
</autoselect>
<login>
<name>login</name>
<notes><![CDATA[Login as another user with equal or lesser group access]]></notes>
</login>
<merge>
<name>merge</name>
</merge>
<group_search>
<name>group_search</name>
</group_search>
<product_search>
<name>product_search</name>
</product_search>
</module_method>
</install>

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<account>
<id>1</id>
<site_id>1</site_id>
<date_orig>1075175744</date_orig>
<date_last>1112335769</date_last>
<date_expire>0</date_expire>
<parent_id>0</parent_id>
<language_id>en</language_id>
<country_id>840</country_id>
<reseller_id>0</reseller_id>
<currency_id>1</currency_id>
<theme_id>default</theme_id>
<username>admin</username>
<password>21232f297a57a5a743894a0e4a801fc3</password>
<misc>Notes</misc>
<status>1</status>
<first_name>Admin</first_name>
<last_name>Admin</last_name>
<title>Mrs</title>
<email>email@company.com</email>
<address1><![CDATA[100 Street's]]></address1>
<city>City</city>
<state>State</state>
<zip>12345</zip>
<email_type>0</email_type>
<campaign_id>0</campaign_id>
</account>
<account_id>
<id>33</id>
</account_id>
</install>

View File

@ -1,36 +0,0 @@
<?php
/*
* osBilling - Open Billing Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Originally authored by Deon George
*
* @author Deon George <deonATleenooksDOTnet>
* @copyright 2009 Deon George
* @link http://osb.leenooks.net
* @license http://www.gnu.org/licenses/
* @package AgileBill
* @subpackage Modules:ADSL
*/
/**
* This class provides the ability to define ADSL Supplier Products.
*
* @package osBilling
* @subpackage Modules:ADSL
*/
class adsl extends OSB_module {
}
?>

View File

@ -1,153 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<construct>
<module>adsl</module>
<table>adsl</table>
<dependancy></dependancy>
<cache>0</cache>
<order_by>product_desc</order_by>
<limit>35</limit>
<!-- Page Display Titles -->
<title>
<add>Add ADSL</add>
<view>ADSL</view>
</title>
<field>
<id>
<type>I8</type>
<unique>1</unique>
</id>
<site_id>
<type>I4</type>
</site_id>
<date_orig>
<type>I8</type>
<convert>date-now</convert>
</date_orig>
<date_last>
<type>I8</type>
<convert>date-now</convert>
</date_last>
<status>
<display>Active</display>
<type>L</type>
</status>
<supplier_id>
<display>Supplier</display>
<type>I4</type>
<asso_table>adsl_supplier</asso_table>
<asso_field>name</asso_field>
<validate>any</validate>
</supplier_id>
<product_id>
<display>Product ID</display>
<type>C(16)</type>
<min_len>1</min_len>
<max_len>16</max_len>
</product_id>
<product_desc>
<display>Product Description</display>
<type>C(128)</type>
<min_len>1</min_len>
<max_len>128</max_len>
</product_desc>
<base_cost>
<display>Base Cost</display>
<type>F</type>
</base_cost>
<contract_term>
<description>Contract Term in Months</description>
<display>Contract Term</display>
<type>I4</type>
</contract_term>
<base_down_peak>
<display>Peak Downloads (MB)</display>
<type>F</type>
</base_down_peak>
<base_up_peak>
<display>Peak Uploads (MB)</display>
<type>F</type>
</base_up_peak>
<base_down_offpeak>
<display>OffPeak Downloads (MB)</display>
<type>F</type>
</base_down_offpeak>
<base_up_offpeak>
<display>OffPeak Uploads (MB)</display>
<type>F</type>
</base_up_offpeak>
<extra_charged>
<display>Charge Extra Traffic</display>
<type>L</type>
</extra_charged>
<extra_shaped>
<display>Shaping speed for extra traffic</display>
<type>C(8)</type>
</extra_shaped>
<offpeak_start>
<display>Offpeak Start</display>
<type>I8</type>
<convert>time</convert>
</offpeak_start>
<offpeak_end>
<display>Offpeak End</display>
<type>I8</type>
<convert>time</convert>
</offpeak_end>
<extra_down_peak>
<display>Peak Downloads Rate ($/MB)</display>
<type>F</type>
</extra_down_peak>
<extra_up_peak>
<display>Peak Uploads Rate ($/MB)</display>
<type>F</type>
</extra_up_peak>
<extra_down_offpeak>
<display>OffPeak Downloads Rate ($/MB)</display>
<type>F</type>
</extra_down_offpeak>
<extra_up_offpeak>
<display>OffPeak Uploads Rate ($/MB)</display>
<type>F</type>
</extra_up_offpeak>
</field>
<method>
<add>supplier_id,product_id,product_desc</add>
<update>id,date_last,status,product_id,product_desc,base_cost,contract_term,base_down_peak,base_up_peak,base_down_offpeak,base_up_offpeak,extra_charged,extra_shaped,offpeak_start,offpeak_end,extra_down_peak,extra_up_peak,extra_down_offpeak,extra_up_offpeak</update>
<delete>id</delete>
<view>id,status,supplier_id,product_id,product_desc,base_cost,contract_term,base_down_peak,base_up_peak,base_down_offpeak,base_up_offpeak,extra_charged,extra_shaped,offpeak_start,offpeak_end,extra_down_peak,extra_up_peak,extra_down_offpeak,extra_up_offpeak</view>
<search>id,date_orig,date_last,status,supplier_id,product_id,product_desc,base_cost</search>
</method>
<index>
<adsls>id,site_id</adsls>
<asso>supplier_id</asso>
<service>service_id</service>
<adsl>product</adsl>
</index>
<trigger>0</trigger>
<!-- Template Helpers -->
<tpl>
<search_show>
<checkbox>
<field>id</field>
<type>checkbox</type>
<width>25px</width>
</checkbox>
<supplier_id>
<field>supplier_id</field>
</supplier_id>
<product_id>
<field>product_id</field>
</product_id>
<base_cost>
<field>base_cost</field>
<type>currency</type>
</base_cost>
</search_show>
</tpl>
</construct>

View File

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<!-- Tree Menu Module Properties -->
<module_properties>
<!-- MODULE Dependancy, this module wont be installed if the dependant modules dont exist -->
<dependancy></dependancy>
<!-- Translated display to use on the tree -->
<display>ADSL</display>
<!-- Display a module in the menu tree -->
<menu_display>1</menu_display>
<!-- MODULE Name -->
<name>adsl</name>
<!-- MODULE Notes, these notes show up in the modules table, as a description of the module -->
<notes><![CDATA[This module records the ADSL supplier products]]></notes>
<!-- MODULE Parent, the parent node in the tree -->
<parent>adsl</parent>
<!-- SUB Modules to install with this one -->
<sub_modules>adsl_supplier</sub_modules>
<!-- MODULE Type (core|base), core modules cannot be deleted, unrecognised types are ignored. -->
<type></type>
</module_properties>
<!-- Tree Menu & Module Methods to load, they will be assigned the group permissions on install time, as selected by the user. -->
<module_method>
<add>
<display>Add</display>
<menu_display>1</menu_display>
<name>add</name>
<notes><![CDATA[Add records]]></notes>
</add>
<delete>
<name>delete</name>
<notes><![CDATA[Delete records]]></notes>
</delete>
<search>
<display>Search</display>
<menu_display>1</menu_display>
<name>search</name>
<notes><![CDATA[List records]]></notes>
<page><![CDATA[core:search&module=%%&_next_page_one=view]]></page>
</search>
<search_show>
<name>search_show</name>
<notes><![CDATA[Show the results of a search]]></notes>
</search_show>
<update>
<name>update</name>
<notes><![CDATA[Update a record]]></notes>
</update>
<view>
<name>view</name>
<notes><![CDATA[View a record]]></notes>
</view>
</module_method>
</install>

View File

@ -12,29 +12,30 @@
*/ */
class Model_ADSL_Plan extends ORMOSB { class Model_ADSL_Plan extends ORMOSB {
// Relationships // Relationships
// @todo This model should probably be joined with product_plugin_adsl
protected $_belongs_to = array( protected $_belongs_to = array(
'adsl_supplier_plan'=>array(), 'adsl_supplier_plan'=>array(),
); );
protected $_has_many = array( protected $_has_many = array(
'service'=>array('through'=>'service__adsl'), 'product'=>array('far_key'=>'id','foreign_key'=>'prod_plugin_data'),
); );
protected $_formats = array( protected $_display_filters = array(
'extra_down_peak'=>array( 'extra_down_peak'=>array(
'Tax::add'=>array(), array('Tax::add',array(':value')),
'Currency::display'=>array(), array('Currency::display',array(':value')),
), ),
'extra_down_offpeak'=>array( 'extra_down_offpeak'=>array(
'Tax::add'=>array(), array('Tax::add',array(':value')),
'Currency::display'=>array(), array('Currency::display',array(':value')),
), ),
'extra_up_peak'=>array( 'extra_up_peak'=>array(
'Tax::add'=>array(), array('Tax::add',array(':value')),
'Currency::display'=>array(), array('Currency::display',array(':value')),
), ),
'extra_up_offpeak'=>array( 'extra_up_offpeak'=>array(
'Tax::add'=>array(), array('Tax::add',array(':value')),
'Currency::display'=>array(), array('Currency::display',array(':value')),
), ),
); );
} }

View File

@ -27,11 +27,14 @@ class Model_ADSL_Supplier extends ORMOSB {
$services = array(); $services = array();
// Get a list of plans made for this supplier // Get a list of plans made for this supplier
// @todo This doesnt work if a product adsl plan is overriden.
foreach ($this->adsl_supplier_plan->find_all() as $aspo) foreach ($this->adsl_supplier_plan->find_all() as $aspo)
// Find all the plan who use this supplier plan // Find all the plan who use this supplier plan
foreach ($aspo->adsl_plan->find_all() as $apo) foreach ($aspo->adsl_plan->find_all() as $apo)
// Find all the services who use this plan // Find all the products who use this plan
foreach ($apo->service->find_all() as $so) foreach ($apo->product->find_all() as $po)
// Find all the services who that use this product
foreach ($po->service->find_all() as $so)
if (! $active OR $so->active) if (! $active OR $so->active)
array_push($services,$so); array_push($services,$so);

View File

@ -10,22 +10,42 @@
* @copyright (c) 2010 Open Source Billing * @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Model_Service_ADSL extends Model_Service { class Model_Service_Plugin_ADSL extends Model_Service_Plugin {
protected $_table_name = 'service__adsl'; protected $_table_name = 'service__adsl';
protected $_updated_column = FALSE; protected $_updated_column = FALSE;
// Relationships // Relationships
protected $_belongs_to = array( protected $_belongs_to = array(
'adsl_plan'=>array('foreign_key'=>'adsl_plan_id'),
'service'=>array(), 'service'=>array(),
); );
protected $_has_one = array(
'adsl_plan'=>array('far_key'=>'provided_adsl_plan_id','foreign_key'=>'id'),
);
protected $_display_filters = array( protected $_display_filters = array(
'service_connect_date'=>array( 'service_connect_date'=>array(
array('Config::date',array(':value')), array('Config::date',array(':value')),
), ),
); );
// Required abstract functions
public function service_view() {
return View::factory('service/user/plugin/adsl/view')
->set('so',$this);
}
public function name() {
return $this->service_number;
}
public function product() {
if ($this->provided_adsl_plan_id)
return $this->adsl_plan;
else
return $this->service->product->plugin();
}
/** /**
* Return the IP Address for the service * Return the IP Address for the service
*/ */
@ -91,7 +111,7 @@ class Model_Service_ADSL extends Model_Service {
$return = array(); $return = array();
$to = ORM::factory('service_adsl_traffic') $to = ORM::factory('service_plugin_adsl_traffic')
->where('service','=',$this->service_username) ->where('service','=',$this->service_username)
->and_where('date','>=',date('Y-m-d',mktime(0,0,0,date('m',$period),1,date('Y',$period)))) ->and_where('date','>=',date('Y-m-d',mktime(0,0,0,date('m',$period),1,date('Y',$period))))
->and_where('date','<=',date('Y-m-d',strtotime('last day of '.date('M Y',$period)))); ->and_where('date','<=',date('Y-m-d',strtotime('last day of '.date('M Y',$period))));
@ -99,14 +119,14 @@ class Model_Service_ADSL extends Model_Service {
foreach ($to->find_all() as $traffic) { foreach ($to->find_all() as $traffic) {
// Roll up the charges according to the configuration // Roll up the charges according to the configuration
$data = ADSL::allowance(array( $data = ADSL::allowance(array(
'base_down_peak'=>is_null($this->adsl_plan->base_down_peak) ? NULL : $traffic->down_peak, 'base_down_peak'=>is_null($this->service->product->plugin()->base_down_peak) ? NULL : $traffic->down_peak,
'base_down_offpeak'=>is_null($this->adsl_plan->base_down_offpeak) ? NULL : $traffic->down_offpeak, 'base_down_offpeak'=>is_null($this->service->product->plugin()->base_down_offpeak) ? NULL : $traffic->down_offpeak,
'base_up_peak'=>is_null($this->adsl_plan->base_up_peak) ? NULL : $traffic->up_peak, 'base_up_peak'=>is_null($this->service->product->plugin()->base_up_peak) ? NULL : $traffic->up_peak,
'base_up_offpeak'=>is_null($this->adsl_plan->base_up_offpeak) ? NULL : $traffic->up_offpeak, 'base_up_offpeak'=>is_null($this->service->product->plugin()->base_up_offpeak) ? NULL : $traffic->up_offpeak,
'extra_down_peak'=>$this->adsl_plan->extra_down_peak, 'extra_down_peak'=>$this->service->product->plugin()->extra_down_peak,
'extra_down_offpeak'=>$this->adsl_plan->extra_down_offpeak, 'extra_down_offpeak'=>$this->service->product->plugin()->extra_down_offpeak,
'extra_up_peak'=>$this->adsl_plan->extra_up_peak, 'extra_up_peak'=>$this->service->product->plugin()->extra_up_peak,
'extra_up_offpeak'=>$this->adsl_plan->extra_up_offpeak, 'extra_up_offpeak'=>$this->service->product->plugin()->extra_up_offpeak,
)); ));
$day = date('d',strtotime($traffic->date)); $day = date('d',strtotime($traffic->date));
@ -128,7 +148,7 @@ class Model_Service_ADSL extends Model_Service {
* Return an array of the data used in a year by month * Return an array of the data used in a year by month
*/ */
public function get_traffic_data_monthly($period=NULL,$bydate=FALSE) { public function get_traffic_data_monthly($period=NULL,$bydate=FALSE) {
$cacheable = FALSE; $cacheable = TRUE;
if (is_null($period)) if (is_null($period))
$period = strtotime('yesterday'); $period = strtotime('yesterday');
@ -140,7 +160,7 @@ class Model_Service_ADSL extends Model_Service {
$return = array(); $return = array();
$to = ORM::factory('service_adsl_traffic') $to = ORM::factory('service_plugin_adsl_traffic')
->select( ->select(
array('date_format(date,\'%y-%m\')','month'), array('date_format(date,\'%y-%m\')','month'),
array('sum(up_peak)','up_peak'), array('sum(up_peak)','up_peak'),
@ -156,14 +176,14 @@ class Model_Service_ADSL extends Model_Service {
foreach ($to->find_all() as $traffic) { foreach ($to->find_all() as $traffic) {
// Roll up the charges according to the configuration // Roll up the charges according to the configuration
$data = ADSL::allowance(array( $data = ADSL::allowance(array(
'base_down_peak'=>is_null($this->adsl_plan->base_down_peak) ? NULL : $traffic->down_peak, 'base_down_peak'=>is_null($this->service->product->plugin()->base_down_peak) ? NULL : $traffic->down_peak,
'base_down_offpeak'=>is_null($this->adsl_plan->base_down_offpeak) ? NULL : $traffic->down_offpeak, 'base_down_offpeak'=>is_null($this->service->product->plugin()->base_down_offpeak) ? NULL : $traffic->down_offpeak,
'base_up_peak'=>is_null($this->adsl_plan->base_up_peak) ? NULL : $traffic->up_peak, 'base_up_peak'=>is_null($this->service->product->plugin()->base_up_peak) ? NULL : $traffic->up_peak,
'base_up_offpeak'=>is_null($this->adsl_plan->base_up_offpeak) ? NULL : $traffic->up_offpeak, 'base_up_offpeak'=>is_null($this->service->product->plugin()->base_up_offpeak) ? NULL : $traffic->up_offpeak,
'extra_down_peak'=>$this->adsl_plan->extra_down_peak, 'extra_down_peak'=>$this->service->product->plugin()->extra_down_peak,
'extra_down_offpeak'=>$this->adsl_plan->extra_down_offpeak, 'extra_down_offpeak'=>$this->service->product->plugin()->extra_down_offpeak,
'extra_up_peak'=>$this->adsl_plan->extra_up_peak, 'extra_up_peak'=>$this->service->product->plugin()->extra_up_peak,
'extra_up_offpeak'=>$this->adsl_plan->extra_up_offpeak, 'extra_up_offpeak'=>$this->service->product->plugin()->extra_up_offpeak,
)); ));
if ($bydate) if ($bydate)
@ -202,12 +222,12 @@ class Model_Service_ADSL extends Model_Service {
foreach ($this->traffic_month($date,FALSE) as $k => $v) { foreach ($this->traffic_month($date,FALSE) as $k => $v) {
// We shouldnt need to eval for nulls, since the traffic calc does that // We shouldnt need to eval for nulls, since the traffic calc does that
if ($all OR ($v > $this->adsl_plan->$k)) { if ($all OR ($v > $this->service->product->plugin()->$k)) {
$return[$k]['allowance'] = $this->adsl_plan->$k; $return[$k]['allowance'] = $this->service->product->plugin()->$k;
$return[$k]['used'] = $v; $return[$k]['used'] = $v;
$return[$k]['shaped'] = (! empty($this->adsl_plan->extra_shaped) AND $this->adsl_plan->extra_shaped AND $v > $this->adsl_plan->$k) ? TRUE : FALSE; $return[$k]['shaped'] = (! empty($this->service->product->plugin()->extra_shaped) AND $this->service->product->plugin()->extra_shaped AND $v > $this->service->product->plugin()->$k) ? TRUE : FALSE;
$return[$k]['excess'] = (! empty($this->adsl_plan->extra_charged) AND $this->adsl_plan->extra_charged AND $v > $this->adsl_plan->$k) ? $v-$this->adsl_plan->$k : 0; $return[$k]['excess'] = (! empty($this->service->product->plugin()->extra_charged) AND $this->service->product->plugin()->extra_charged AND $v > $this->service->product->plugin()->$k) ? $v-$this->service->product->plugin()->$k : 0;
$return[$k]['rate'] = $this->adsl_plan->{ADSL::map($k)}; $return[$k]['rate'] = $this->service->product->plugin()->{ADSL::map($k)};
$return[$k]['charge'] = ceil(($return[$k]['excess'])/1000)*$return[$k]['rate']; $return[$k]['charge'] = ceil(($return[$k]['excess'])/1000)*$return[$k]['rate'];
} }
} }
@ -340,31 +360,23 @@ class Model_Service_ADSL extends Model_Service {
return FALSE; return FALSE;
} }
protected function _service_name() {
return sprintf('%s - %s',$this->service->product->name(),$this->service_number);
}
protected function _service_view() {
return View::factory('service/user/adsl/view')
->set('so',$this);
}
/** /**
* Get specific service details for use in other modules * Get specific service details for use in other modules
* For Example: Invoice * For Example: Invoice
* *
* @todo Make the rendered items configurable * @todo Make the rendered items configurable
* @todo Change this method name, now that it is public
*/ */
protected function _details($type) { public function _details($type) {
switch ($type) { switch ($type) {
case 'invoice': case 'invoice_detail_items':
return array( return array(
_('Service Address')=>$this->display('service_address'), _('Service Address')=>$this->display('service_address'),
_('Contract Until')=>$this->contract_date_end(), _('Contract Until')=>$this->contract_date_end(),
); );
break; break;
default: default:
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type)); return parent::$_details($type);
} }
} }
@ -413,7 +425,7 @@ class Model_Service_ADSL extends Model_Service {
} }
public function table_traffic($month=NULL) { public function table_traffic($month=NULL) {
return View::factory('service/user/adsl/table_traffic') return View::factory('service/user/plugin/adsl/table_traffic')
->set('traffic',$this->traffic_month((! is_null($month) AND trim($month)) ? strtotime($month.'-01') : NULL,FALSE)); ->set('traffic',$this->traffic_month((! is_null($month) AND trim($month)) ? strtotime($month.'-01') : NULL,FALSE));
} }
} }

View File

@ -10,9 +10,10 @@
* @copyright (c) 2010 Open Source Billing * @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Model_Service_ADSL_Traffic extends ORMOSB { class Model_Service_Plugin_ADSL_Traffic extends ORMOSB {
protected $_table_name = 'service__adsl_traffic'; protected $_table_name = 'service__adsl_traffic';
protected $_primary_key = 'service'; protected $_primary_key = 'service';
protected $_disable_wild_select = TRUE;
protected $_created_column = FALSE; protected $_created_column = FALSE;
protected $_updated_column = FALSE; protected $_updated_column = FALSE;

View File

@ -87,7 +87,7 @@ class Service_Traffic_ADSL {
break; break;
} }
$traffic = ORM::factory('service_adsl_traffic'); $traffic = ORM::factory('service_plugin_adsl_traffic');
foreach ($data as $item) { foreach ($data as $item) {
$traffic->values($item,array_keys($item)); $traffic->values($item,array_keys($item));
$traffic->supplier_id = $this->so->id; $traffic->supplier_id = $this->so->id;
@ -111,7 +111,7 @@ class Service_Traffic_ADSL {
// @todo need a way to find out services that have traffic charges dynamically. // @todo need a way to find out services that have traffic charges dynamically.
foreach ($this->so->services() as $so) { foreach ($this->so->services() as $so) {
if ($charge = $so->service_adsl->traffic_lastmonth_exceed(FALSE,$date)) { if ($charge = $so->plugin()->traffic_lastmonth_exceed(FALSE,$date)) {
foreach ($charge as $metric => $details) { foreach ($charge as $metric => $details) {
$co = ORM::factory('charge'); $co = ORM::factory('charge');
@ -126,7 +126,7 @@ class Service_Traffic_ADSL {
$co->description = _('Excess Traffic'); $co->description = _('Excess Traffic');
// @todo This need to be improved = strtotime function should be the one used in the function call // @todo This need to be improved = strtotime function should be the one used in the function call
$co->attributes = implode("\n",array( $co->attributes = implode("\n",array(
sprintf('ADSL Service==%s',$so->service_adsl->service_number), sprintf('ADSL Service==%s',$so->plugin()->service_number),
sprintf('Allowance==%s',$details['allowance']), sprintf('Allowance==%s',$details['allowance']),
sprintf('Metric==%s',$metric), sprintf('Metric==%s',$metric),
sprintf('Used==%s',$details['used']), sprintf('Used==%s',$details['used']),
@ -144,12 +144,12 @@ class Service_Traffic_ADSL {
$et = Email_Template::instance('adsl_traffic_notice'); $et = Email_Template::instance('adsl_traffic_notice');
foreach ($this->so->services() as $so) { foreach ($this->so->services() as $so) {
if (! $so->service_adsl->report_traffic()) if (! $so->plugin()->report_traffic())
continue; continue;
// Get our variable data // Get our variable data
$et->to = array('account'=>array($so->account_id)); $et->to = array('account'=>array($so->account_id));
$et->variables = $so->service_adsl->template_variables($et->variables()); $et->variables = $so->plugin()->template_variables($et->variables());
$et->send(); $et->send();
} }

View File

@ -39,17 +39,17 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
$update = array(); $update = array();
foreach ($this->so->services() as $so) { foreach ($this->so->services() as $so) {
if ($so->service_adsl->service_stats_collect AND $so->service_adsl->service_stats_lastupdate < $date) { if ($so->plugin()->service_stats_collect AND $so->plugin()->service_stats_lastupdate < $date) {
// Start Session // Start Session
$request = Request::factory($this->so->stats_url) $request = Request::factory($this->so->stats_url)
->method('POST') ->method('POST')
->post($this->login_user_field,$so->service_adsl->service_username) ->post($this->login_user_field,$so->plugin()->service_username)
->post($this->login_pass_field,$so->service_adsl->service_password) ->post($this->login_pass_field,$so->plugin()->service_password)
->post('doLogin',1) ->post('doLogin',1)
->post('submit','Login'); ->post('submit','Login');
$request->get_client()->options($this->curlopts+array( $request->get_client()->options($this->curlopts+array(
CURLOPT_COOKIEJAR=>sprintf('/tmp/usage.cookies.%s.txt',$so->service_adsl->service_number), CURLOPT_COOKIEJAR=>sprintf('/tmp/usage.cookies.%s.txt',$so->plugin()->service_number),
)); ));
$response = $request->execute(); $response = $request->execute();
@ -57,16 +57,17 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
if (! $data) { if (! $data) {
// @todo Log into a log file // @todo Log into a log file
printf('Bad fetch for %s [%s]',$so->service_adsl->service_number,$this->so->stats_lastupdate); printf('Bad fetch for %s [%s]',$so->plugin()->service_number,$this->so->stats_lastupdate);
#$html = new simple_html_dom(); #$html = new simple_html_dom();
#$html->load($data); #$html->load($data);
#$html->save(sprintf('/afs/local/tmp/usage.%s.%s.login.html',$so->service_adsl->service_number,'login')); #$html->save(sprintf('/afs/local/tmp/usage.%s.%s.login.html',$so->plugin()->service_number,'login'));
continue; continue;
} }
for ($servicedate=date('Y-m-d',strtotime($this->so->stats_lastupdate.'+1 day')); for ($servicedate=date('Y-m-d',strtotime($this->so->stats_lastupdate.'+1 day'));
$servicedate <= $this->today; $servicedate <= $this->today;
$servicedate=date('Y-m-d',strtotime('+1 month',strtotime(date('Y-m',strtotime($servicedate)).'-01')))) { $servicedate=date('Y-m-d',strtotime('+1 month',strtotime(date('Y-m',strtotime($servicedate)).'-01')))) {
#print_r(array('sn'=>$so->plugin()->service_number,'sd'=>$servicedate));
$lastday = date('Y-m-d',strtotime('-1 second',strtotime('+1 month',strtotime(date('Y-m',strtotime($servicedate)).'-01')))); $lastday = date('Y-m-d',strtotime('-1 second',strtotime('+1 month',strtotime(date('Y-m',strtotime($servicedate)).'-01'))));
if (strtotime($lastday) > time()) if (strtotime($lastday) > time())
@ -84,16 +85,16 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
->post('do_usage_search',1); ->post('do_usage_search',1);
$request->get_client()->options($this->curlopts+array( $request->get_client()->options($this->curlopts+array(
CURLOPT_COOKIEFILE=>sprintf('/tmp/usage.cookies.%s.txt',$so->service_adsl->service_number), CURLOPT_COOKIEFILE=>sprintf('/tmp/usage.cookies.%s.txt',$so->plugin()->service_number),
)); ));
$response = $request->execute(); $response = $request->execute();
$result = $response->body(); $result = $response->body();
$html->load($result); $html->load($result);
#$html->save(sprintf('/afs/local/tmp/usage.%s.%s.html',$so->service_adsl->service_number,$servicedate)); #$html->save(sprintf('/afs/local/tmp/usage.%s.%s.html',$so->plugin()->service_number,$servicedate)); die();
} else { } else {
$html->load_file(sprintf('/tmp/usage.%s.%s.txt',$so->service_adsl->service_number,$servicedate)); $html->load_file(sprintf('/afs/local/tmp/usage.%s.%s.html',$so->plugin()->service_number,$servicedate));
} }
$header = array(); $header = array();
@ -103,7 +104,7 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
if (! preg_match('/^Usage Detail/',$fieldset->find('legend',0)->plaintext)) if (! preg_match('/^Usage Detail/',$fieldset->find('legend',0)->plaintext))
continue; continue;
#echo "X:";print_r($fieldset->find('legend',0)->plaintext); echo "\n"; #echo "X:";print_r($fieldset->find('table',0)->find('tr')->plaintext); echo "\n";
foreach ($fieldset->find('table',0)->find('tr') as $key => $values) { foreach ($fieldset->find('table',0)->find('tr') as $key => $values) {
foreach ($values->children() as $a => $b) { foreach ($values->children() as $a => $b) {
#print_r(array('a'=>$a,'b'=>$b)); #print_r(array('a'=>$a,'b'=>$b));
@ -119,6 +120,7 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
case 'Peak Download': $header[$a] = 'down_peak'; break; case 'Peak Download': $header[$a] = 'down_peak'; break;
case 'Download': $header[$a] = 'down_peak'; break; case 'Download': $header[$a] = 'down_peak'; break;
case 'Duration': break; case 'Duration': break;
case 'Total': break;
default: default:
printf('Unkown header :%s',$b->plaintext); printf('Unkown header :%s',$b->plaintext);
$this->fetchresult = FALSE; $this->fetchresult = FALSE;
@ -137,27 +139,28 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
#echo "VALUES: ".$b->plaintext."\n"; #echo "VALUES: ".$b->plaintext."\n";
} }
} }
#print_r($data);
if (isset($data['date']) && preg_match('/^[0-9]{4}/',$data['date'])) { if (isset($data['date']) && preg_match('/^[0-9]{4}/',$data['date'])) {
$sdate = date('Y-m-d',strtotime($data['date'])); $sdate = date('Y-m-d',strtotime($data['date']));
unset($data['date']); unset($data['date']);
if (isset($update[$so->service_adsl->service_number][$sdate])) if (isset($update[$so->plugin()->service_number][$sdate]))
foreach ($data as $key => $value) foreach ($data as $key => $value)
$update[$so->service_adsl->service_number][$sdate][$key] += $value; $update[$so->plugin()->service_number][$sdate][$key] += $value;
else else
$update[$so->service_adsl->service_number][$sdate] = $data; $update[$so->plugin()->service_number][$sdate] = $data;
$update[$so->service_adsl->service_number][$sdate]['service'] = $so->service_adsl->service_number; $update[$so->plugin()->service_number][$sdate]['service'] = $so->plugin()->service_number;
$update[$so->service_adsl->service_number][$sdate]['date'] = $sdate; $update[$so->plugin()->service_number][$sdate]['date'] = $sdate;
} }
} }
} }
} }
// 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->service_adsl->service_stats_lastupdate = $lastday; $so->plugin()->service_stats_lastupdate = $lastday;
$so->service_adsl->save(); $so->plugin()->save();
} }
} }

View File

@ -39,17 +39,17 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL {
$update = array(); $update = array();
foreach ($this->so->services() as $so) { foreach ($this->so->services() as $so) {
if ($so->service_adsl->service_stats_collect AND $so->service_adsl->service_stats_lastupdate < $date) { if ($so->plugin()->service_stats_collect AND $so->plugin()->service_stats_lastupdate < $date) {
// Start Session // Start Session
$request = Request::factory($this->so->stats_url) $request = Request::factory($this->so->stats_url)
->method('POST') ->method('POST')
->post($this->login_user_field,$so->service_adsl->service_username) ->post($this->login_user_field,$so->plugin()->service_username)
->post($this->login_pass_field,$so->service_adsl->service_password) ->post($this->login_pass_field,$so->plugin()->service_password)
->post('doLogin',1) ->post('doLogin',1)
->post('submit','Login'); ->post('submit','Login');
$request->get_client()->options($this->curlopts+array( $request->get_client()->options($this->curlopts+array(
CURLOPT_COOKIEJAR=>sprintf('/tmp/usage.cookies.%s.txt',$so->service_adsl->service_number), CURLOPT_COOKIEJAR=>sprintf('/tmp/usage.cookies.%s.txt',$so->plugin()->service_number),
)); ));
$response = $request->execute(); $response = $request->execute();
@ -57,10 +57,10 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL {
if (! $data) { if (! $data) {
// @todo Log into a log file // @todo Log into a log file
printf('Bad fetch for %s [%s]',$so->service_adsl->service_number,$this->so->stats_lastupdate); printf('Bad fetch for %s [%s]',$so->plugin()->service_number,$this->so->stats_lastupdate);
#$html = new simple_html_dom(); #$html = new simple_html_dom();
#$html->load($data); #$html->load($data);
#$html->save(sprintf('/afs/local/tmp/usage.%s.%s.login.html',$so->service_adsl->service_number,'login')); #$html->save(sprintf('/afs/local/tmp/usage.%s.%s.login.html',$so->plugin()->service_number,'login'));
continue; continue;
} }
@ -84,16 +84,16 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL {
->post('do_usage_search',1); ->post('do_usage_search',1);
$request->get_client()->options($this->curlopts+array( $request->get_client()->options($this->curlopts+array(
CURLOPT_COOKIEFILE=>sprintf('/tmp/usage.cookies.%s.txt',$so->service_adsl->service_number), CURLOPT_COOKIEFILE=>sprintf('/tmp/usage.cookies.%s.txt',$so->plugin()->service_number),
)); ));
$response = $request->execute(); $response = $request->execute();
$result = $response->body(); $result = $response->body();
$html->load($result); $html->load($result);
#$html->save(sprintf('/afs/local/tmp/usage.%s.%s.html',$so->service_adsl->service_number,$servicedate)); #$html->save(sprintf('/afs/local/tmp/usage.%s.%s.html',$so->plugin()->service_number,$servicedate));
} else { } else {
$html->load_file(sprintf('/afs/local/tmp/usage.%s.%s.html',$so->service_adsl->service_number,$servicedate)); $html->load_file(sprintf('/afs/local/tmp/usage.%s.%s.html',$so->plugin()->service_number,$servicedate));
} }
$header = array(); $header = array();
@ -141,22 +141,22 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL {
$sdate = date('Y-m-d',strtotime(str_replace('/','-',$data['date']))); $sdate = date('Y-m-d',strtotime(str_replace('/','-',$data['date'])));
unset($data['date']); unset($data['date']);
if (isset($update[$so->service_adsl->service_number][$sdate])) if (isset($update[$so->plugin()->service_number][$sdate]))
foreach ($data as $key => $value) foreach ($data as $key => $value)
$update[$so->service_adsl->service_number][$sdate][$key] += $value; $update[$so->plugin()->service_number][$sdate][$key] += $value;
else else
$update[$so->service_adsl->service_number][$sdate] = $data; $update[$so->plugin()->service_number][$sdate] = $data;
$update[$so->service_adsl->service_number][$sdate]['service'] = $so->service_adsl->service_number; $update[$so->plugin()->service_number][$sdate]['service'] = $so->plugin()->service_number;
$update[$so->service_adsl->service_number][$sdate]['date'] = $sdate; $update[$so->plugin()->service_number][$sdate]['date'] = $sdate;
} }
} }
} }
} }
// 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->service_adsl->service_stats_lastupdate = $lastday; $so->plugin()->service_stats_lastupdate = $lastday;
$so->service_adsl->save(); $so->plugin()->save();
} }
} }

View File

@ -0,0 +1,11 @@
<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 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>
<td><input type="text" name="payment[<?php echo $service->plugin()->service_number; ?>]" value="<?php echo $amount; ?>" id="p<?php echo $service->plugin()->id; ?>" size="8"/></td>
<td><?php echo $excess ? sprintf('(%s)',$excess) : '&nbsp'; ?></td>
</tr>

View File

@ -0,0 +1,10 @@
<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 Currency::display($service->product->plugin()->adsl_supplier_plan->base_cost); ?></td>
<td><?php echo Currency::display($service->product->plugin()->adsl_supplier_plan->base_cost+$service->product->plugin()->adsl_supplier_plan->tax()); ?></td>
<td><?php echo $amount; ?></td>
<td><?php echo $service->product->plugin()->adsl_supplier_plan->base_cost+$service->product->plugin()->adsl_supplier_plan->tax()-$amount; ?></td>
</tr>

View File

@ -1,10 +1,10 @@
<tr class="<?php echo $i ? 'odd' : 'even'; ?>"> <tr class="<?php echo $i ? 'odd' : 'even'; ?>">
<td><?php echo $service->service_adsl->display('service_number'); ?></td> <td><?php echo $service->plugin()->display('service_number'); ?></td>
<td><?php echo $service->service_adsl->ipaddress(); ?></td> <td><?php echo $service->plugin()->ipaddress(); ?></td>
<td><?php printf('%s (%s)',$service->name(),$service->id); ?></td> <td><?php printf('%s (%s)',$service->product->name(),$service->id); ?></td>
<td><?php echo $service->product->prod_plugin_file ? $service->product->plugin()->allowance() : 'No Details'; ?></td> <td><?php echo $service->product->prod_plugin_file ? $service->product->plugin()->allowance() : 'No Details'; ?></td>
<td><?php echo $service->service_adsl->traffic_thismonth(); ?></td> <td><?php echo $service->plugin()->traffic_thismonth(); ?></td>
<td><?php echo $service->service_adsl->traffic_lastmonth(); ?></td> <td><?php echo $service->plugin()->traffic_lastmonth(); ?></td>
<td><?php echo $service->display('price'); ?></td> <td><?php echo $service->display('price'); ?></td>
<td><?php echo $service->display('recur_schedule'); ?></td> <td><?php echo $service->display('recur_schedule'); ?></td>
<td><?php echo $service->display('date_next_invoice'); ?></td> <td><?php echo $service->display('date_next_invoice'); ?></td>

View File

@ -1,13 +1,13 @@
<!-- //@todo To translate --> <!-- //@todo To translate -->
<table class="box-full"> <table class="box-full">
<tr> <tr>
<td class="head" colspan="2">Service Details</td> <td class="head" colspan="3">Service Details</td>
</tr> </tr>
<tr> <tr>
<td colspan="2">&nbsp;</td> <td colspan="3">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td style="width: 50%"> <td>
<table> <table>
<tr> <tr>
<td style="width: 40%;">Service Number</td> <td style="width: 40%;">Service Number</td>
@ -35,7 +35,7 @@
</tr> </tr>
<tr> <tr>
<td>Service Password</td> <td>Service Password</td>
<td class="data"><?php echo $so->display('service_password'); ?></td> <td class="data"><?php #echo $so->display('service_password'); ?></td>
</tr> </tr>
<tr> <tr>
<td>Service IP</td> <td>Service IP</td>
@ -43,21 +43,21 @@
</tr> </tr>
</table> </table>
</td> </td>
<td style="width: 50%; vertical-align: top;"> <td style="vertical-align: top;" colspan="2">
<table width="100%"> <table>
<tr> <tr>
<td style="width: 40%;">Traffic Used This Month</td> <td style="width: 40%;">Traffic Used This Month</td>
<td style="width: 60%;" class="data"><?php echo $so->traffic_month(null); ?></td> <td style="width: 60%;" class="data"><?php echo $so->traffic_month(null); ?></td>
</tr> </tr>
<tr> <tr>
<td style="width: 40%;">Traffic Used Last Month</td> <td>Traffic Used Last Month</td>
<td style="width: 60%;" class="data"><?php echo $so->traffic_lastmonth(); ?></td> <td class="data"><?php echo $so->traffic_lastmonth(); ?></td>
</tr> </tr>
</table> </table>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td colspan="3">
<table> <table>
<tr> <tr>
<td>View Daily Traffic for Month</td> <td>View Daily Traffic for Month</td>
@ -67,7 +67,7 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td><?php echo $so->graph_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?><td> <td colspan="2"><?php echo $so->graph_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?></td>
<td><?php echo $so->table_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?><td> <td><?php echo $so->table_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?></td>
</tr> </tr>
</table> </table>

View File

@ -1,22 +0,0 @@
<?php
/**
* osBilling - Open Billing Software
*
* Originally authored by Deon George
*
* @author Deon George <deonATleenooksDOTnet>
* @copyright 2009 Deon George
* @link http://osb.leenooks.net
* @package osBilling
* @subpackage Modules:ADSL
*/
/**
* This class provides the ability to define ADSL Suppliers.
*
* @package osBilling
* @subpackage Modules:ADSL
*/
class adsl_supplier extends OSB_module {
}
?>

View File

@ -1,82 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<construct>
<!-- define the module name -->
<module>adsl_supplier</module>
<!-- define the module table name -->
<table>adsl_supplier</table>
<!-- define the module dependancy(s) -->
<dependancy/>
<!-- define the DB cache in seconds -->
<cache>0</cache>
<!-- define the default order_by field for SQL queries -->
<order_by>name</order_by>
<!-- define the methods -->
<limit>25</limit>
<!-- define the fields -->
<field>
<id>
<type>I4</type>
<unique>1</unique>
<index>1</index>
</id>
<site_id>
<type>I4</type>
</site_id>
<status>
<display>Active</display>
<type>L</type>
</status>
<debug>
<type>L</type>
</debug>
<name>
<display>Supplier</display>
<type>C(128)</type>
<min_len>1</min_len>
<max_len>128</max_len>
<validate>any</validate>
</name>
<notes>
<type>C(255)</type>
</notes>
<provision_plugin>
<type>C(128)</type>
<min_len>1</min_len>
<max_len>128</max_len>
</provision_plugin>
<provision_plugin_data>
<type>X2</type>
<convert>array</convert>
</provision_plugin_data>
<max_accounts>
<type>I4</type>
</max_accounts>
</field>
<!-- define all the methods for this class, and the fields they have access to, if applicable. -->
<method>
<add>name</add>
<update>id,status,debug,name,notes,provision_plugin,provision_plugin_data,max_accounts</update>
<delete>id</delete>
<view>id,status,debug,name,notes,provision_plugin,provision_plugin_data,max_accounts</view>
<search>id,status,debug,name,notes,provision_plugin,provision_plugin_data,max_accounts</search>
</method>
<!-- define the method triggers -->
<trigger>0</trigger>
<!-- Template Helpers -->
<tpl>
<search_show>
<checkbox>
<field>id</field>
<type>checkbox</type>
<width>25px</width>
</checkbox>
<supplier_id>
<field>name</field>
</supplier_id>
</search_show>
</tpl>
</construct>

View File

@ -1,44 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<module_properties>
<display>ADSL Suppliers</display>
<name>adsl_supplier</name>
<table>adsl_supplier</table>
<parent>adsl</parent>
<notes><![CDATA[This module records the ADSL suppliers]]></notes>
<dependancy>adsl</dependancy>
<sub_modules></sub_modules>
<menu_display>1</menu_display>
</module_properties>
<sql_inserts>
<module_method>
<add>
<display>Add</display>
<name>add</name>
<page><![CDATA[%%:add]]></page>
<menu_display>1</menu_display>
</add>
<delete>
<name>delete</name>
</delete>
<search>
<name>search</name>
</search>
<search_show>
<display>Search</display>
<name>search_show</name>
<notes><![CDATA[Allow users to view the search results]]></notes>
</search_show>
<update>
<name>update</name>
</update>
<view>
<display>List</display>
<name>view</name>
<page><![CDATA[core:search&module=%%&_escape=1]]></page>
<menu_display>1</menu_display>
</view>
</module_method>
</sql_inserts>
</install>

View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<adsl_supplier>
<id>1</id>
<site_id>1</site_id>
<status>1</status>
<debug></debug>
<name>Exetel</name>
<notes></notes>
<provision_plugin></provision_plugin>
<provision_plugin_data><![CDATA[a:1:{i:0;s:0:"";}]]></provision_plugin_data>
<max_accounts></max_accounts>
</adsl_supplier>
<adsl_supplier>
<id>2</id>
<site_id>1</site_id>
<status>0</status>
<debug></debug>
<name>People</name>
<notes></notes>
<provision_plugin></provision_plugin>
<provision_plugin_data></provision_plugin_data>
<max_accounts></max_accounts>
</adsl_supplier>
<adsl_supplier_id>
<id>3</id>
</adsl_supplier_id>
</install>

View File

@ -1,16 +1,15 @@
<?php defined('SYSPATH') or die('No direct access allowed.'); <?php defined('SYSPATH') or die('No direct access allowed.');
/** /**
* This class supports OSB Web Hosting * This class supports affiliates
* *
* @package OSB * @package OSB
* @subpackage Product * @subpackage Affiliate
* @category Models * @category Models
* @author Deon George * @author Deon George
* @copyright (c) 2010 Open Source Billing * @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Model_HostServer extends ORMOSB { class Model_Affiliate extends ORMOSB {
protected $_table_name = 'service';
} }
?> ?>

View File

@ -223,7 +223,7 @@ function sqlConditions($db,$Conditions=false,$Tables=false) {
# Add the SITE ID # Add the SITE ID
if (! is_array($Tables) || count($Tables) == 1) { if (! is_array($Tables) || count($Tables) == 1) {
if ($Tables == 'setup') if (in_array($Tables,array('setup','currency','tax')))
$where .= sprintf('id=%s',DEFAULT_SITE); $where .= sprintf('id=%s',DEFAULT_SITE);
else else
$where .= sprintf('site_id=%s',DEFAULT_SITE); $where .= sprintf('site_id=%s',DEFAULT_SITE);

View File

@ -169,6 +169,7 @@ class CORE_list {
} }
public function format_currency_decimal($number,$currency_id,$decimals=DEFAULT_DECIMAL_PLACE) { public function format_currency_decimal($number,$currency_id,$decimals=DEFAULT_DECIMAL_PLACE) {
return ($number);
if (empty($number)) if (empty($number))
return 0; return 0;
if (empty($currency_id)) if (empty($currency_id))

View File

@ -0,0 +1,54 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class looks after DOMAIN NAME products
*
* @package OSB
* @subpackage Product
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class DOMAIN {
/**
* Return an instance of this class
*
* @return ADSL
*/
public static function instance() {
return new DOMAIN;
}
public function product_view($data) {
}
public function contract_view($data,$price_base,$price_setup) {
}
/**
* Collect information for the cart
*/
public function product_cart() {
$output = '';
$output .= '<script type="text/javascript">//<![CDATA[
$(document).ready(function() {
$("input[type=submit]").attr("disabled","disabled");
});
//]]></script>
';
$output .= View::factory('domain/cart');
return $output;
}
public static function NS(Model_Service_Plugin_Domain $o) {
if ($o->registrar_ns)
return is_array($o->registrar_ns) ? implode(',',$o->registrar_ns) : '&gtInvalid&lt';
else
return is_array($o->domain_registrar->whitelabel_ns) ? implode(',',$o->domain_registrar->whitelabel_ns) : '&gtUnknown&lt';
}
}
?>

View File

@ -0,0 +1,27 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Domain TLD Registrars
*
* @package OSB
* @subpackage Host_TLD_Registrar
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Domain_Registrar extends ORMOSB {
/**
* The button that provides a login to the Registrar to manage the domain license
*/
public function manage_button($u,$p,$d) {
$c = sprintf('Service_Domain_%s',$this->file);
if (! class_exists($c))
return '';
$po = new $c($this->id);
return $po->manage_button($u,$p,$d);
}
}
?>

View File

@ -0,0 +1,20 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Domain TLD
*
* @package OSB
* @subpackage Domains
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Domain_TLD extends ORMOSB {
protected $_display_filters = array(
'name'=>array(
array('strtoupper',array(':value')),
),
);
}
?>

View File

@ -0,0 +1,71 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Services
*
* @package OSB
* @subpackage DOMAIN
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Service_Plugin_Domain extends Model_Service_Plugin {
protected $_table_name = 'service__domain';
protected $_updated_column = FALSE;
// Relationships
protected $_has_one = array(
'domain_tld'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'),
'domain_registrar'=>array('foreign_key'=>'id','far_key'=>'domain_registrar_id'),
'service_plugin_host'=>array('through'=>'service','far_key'=>'service_id','foreign_key'=>'service_id'),
);
protected $_belongs_to = array(
'service'=>array(),
);
protected $_display_filters = array(
'domain_expire'=>array(
array('Config::date',array(':value')),
),
'domain_name'=>array(
array('strtoupper',array(':value')),
),
'registrar_ns'=>array(
array('Domain::NS',array(':model')),
),
'registrar_lastsync'=>array(
array('Config::date',array(':value')),
),
);
// Required abstract functions
public function service_view() {
return View::factory('service/user/plugin/domain/view')
->set('so',$this);
}
public function name() {
return sprintf('%s.%s',$this->display('domain_name'),$this->domain_tld->display('name'));
}
public function service_name() {
return sprintf('%s - %s',_('Domain Name License'),$this->name());
}
protected function _admin_update() {
}
/**
* This provides us with a manage button to jump to the registrar
* to manage the domain.
*/
public function manage_button() {
return ($this->registrar_username AND $this->registrar_password) ? $this->domain_registrar->manage_button($this->registrar_username,$this->registrar_password,$this->name()) : _('Please contact us');
}
public function manage_dns_button() {
return $this->service_plugin_host->manage_button();
}
}
?>

View File

@ -0,0 +1,56 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class will take care of Domain Registrars.
*
* @package OSB
* @subpackage Service
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
abstract class Service_Domain {
protected $so;
protected $fetchresult = NULL;
// @todo These options should be centrally defined
protected $curlopts = array(
CURLOPT_CONNECTTIMEOUT => 60,
CURLOPT_FAILONERROR => TRUE,
CURLOPT_FOLLOWLOCATION => FALSE,
CURLOPT_HEADER => FALSE,
CURLOPT_HTTPPROXYTUNNEL => FALSE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYHOST => FALSE,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_VERBOSE => FALSE,
);
/**
* Setup this class. We need to get our supplier details out of the database.
*/
public function __construct($sid) {
$this->so = ORM::factory('domain_registrar',$sid);
}
/**
* Our HTML button that will enable us to manage this domain.
*/
abstract public function manage_button($u,$p,$d);
/**
* Return an instance of this class
*
* @return HeadImage
*/
public static function instance($supplier) {
$sc = sprintf('%s_%s',get_called_class(),$supplier);
if (! class_exists($sc))
throw new Kohana_Exception('Class doesnt exist for :supplier',array(':supplier'=>$supplier));
else
return new $sc;
}
}
?>

View File

@ -0,0 +1,23 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is able to interact with TPP
*
* @package OSB
* @subpackage Service
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Service_Domain_Manual extends Service_Domain {
private $login_acnt_field = '';
private $login_user_field = '';
private $login_pass_field = '';
// Our required abstract classes
public function manage_button($u,$p,$d) {
return _('Please contact us');
}
}
?>

View File

@ -0,0 +1,35 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is able to interact with TPP
*
* @package OSB
* @subpackage Service
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Service_Domain_PlanetDomain extends Service_Domain {
private $login_acnt_field = '';
private $login_user_field = 'login.username';
private $login_pass_field = 'login.password';
// Our required abstract classes
public function manage_button($u,$p,$d) {
$output = '';
$output .= Form::open(
sprintf('%s/%s',$this->so->whitelabel_url,'newdnr/action/user/login.jsp'),
array('target'=>'pd','method'=>'post')
);
$output .= Form::input($this->login_user_field,$u,array('type'=>'hidden'));
$output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden'));
$output .= Form::input('page.next',sprintf('/newdnr/action/dns/getDNSDetails.jsp?domain.name=%s',$d),array('type'=>'hidden'));
$output .= Form::button('submit',_('Manage'),array('class'=>'form_button'));
$output .= Form::close();
return $output;
}
}
?>

View File

@ -0,0 +1,34 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is able to interact with TPP
*
* @package OSB
* @subpackage Service
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Service_Domain_TPP extends Service_Domain {
private $login_acnt_field = '';
private $login_user_field = 'login';
private $login_pass_field = 'password';
// Our required abstract classes
public function manage_button($u,$p,$d) {
$output = '';
$output .= Form::open(
sprintf('%s/%s',$this->so->whitelabel_url,'execute/logon'),
array('target'=>'tpp','method'=>'post')
);
$output .= Form::input($this->login_user_field,$u,array('type'=>'hidden'));
$output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden'));
$output .= Form::button('submit',_('Manage'),array('class'=>'form_button'));
$output .= Form::close();
return $output;
}
}
?>

View File

@ -0,0 +1,51 @@
<!-- //@todo To translate -->
<table class="box-full">
<tr>
<td class="head" colspan="2">Service Details</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td style="width: 50%">
<table width="100%">
<tr>
<td style="width: 40%;">Domain Name</td>
<td style="width: 60%;" class="data"><?php echo $so->name(); ?></td>
</tr>
<tr>
<td>Domain Expire</td>
<td class="data"><?php echo $so->display('domain_expire'); ?></td>
</tr>
<tr>
<td>Domain Primary Name Servers</td>
<td class="data"><?php echo $so->display('registrar_ns'); ?> <span style="small">(Last Sync: <?php echo $so->display('registrar_lastsync'); ?>)</span></td>
</tr>
<tr>
<td>Domain Auth Password</td>
<td class="data"><?php echo $so->display('registrar_auth_password'); ?></td>
</tr>
<tr>
<td>Domain Type</td>
<td class="data"><?php echo $so->display('registrar_type'); ?></td>
</tr>
</table>
</td>
<td style="width: 50%">
<table width="100%">
<?php if ($x=$so->manage_button()) { ?>
<tr>
<td style="width: 40%;">Manage Registrar</td>
<td style="width: 60%;" class="data"><?php echo $x; ?></td>
</tr>
<?php } ?>
<?php if ($x=$so->manage_dns_button()) { ?>
<tr>
<td style="width: 40%;">Manage DNS</td>
<td style="width: 60%;" class="data"><?php echo $x; ?></td>
</tr>
<?php } ?>
</table>
</td>
</tr>
</table>

View File

@ -0,0 +1,24 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports OSB Web Hosting
*
* @package OSB
* @subpackage Product
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Host_Server extends ORMOSB {
public function manage_button($u,$p,$d) {
$c = sprintf('Service_Host_%s',$this->provision_plugin);
if (! class_exists($c))
return '';
$po = new $c($this->id);
return $po->manage_button($u,$p,$d);
}
}
?>

View File

@ -0,0 +1,57 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Services
*
* @package OSB
* @subpackage Hosting
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Service_Plugin_Host extends Model_Service_Plugin {
protected $_table_name = 'service__hosting';
protected $_created_column = FALSE;
protected $_updated_column = FALSE;
// Relationships
protected $_has_one = array(
'domain_tld'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'),
'host_server'=>array('far_key'=>'host_server_id','foreign_key'=>'id'),
);
protected $_belongs_to = array(
'service'=>array(),
);
protected $_display_filters = array(
'domain_name'=>array(
array('strtoupper',array(':value')),
),
'host_expire'=>array(
array('Config::date',array(':value')),
),
);
// Required abstract functions
public function service_view() {
return View::factory('service/user/plugin/host/view')
->set('so',$this);
}
public function name() {
return sprintf('%s.%s',$this->display('domain_name'),$this->domain_tld->display('name'));
}
protected function _admin_update() {
}
/**
* This provides us with a manage button to jump to the hosting server
* to manage the domain.
*/
public function manage_button() {
return ($this->host_username AND $this->host_password) ? $this->host_server->manage_button($this->host_username,$this->host_password,$this->name()) : '';
}
}
?>

View File

@ -0,0 +1,56 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class will take care of Domain Registrars.
*
* @package OSB
* @subpackage Service
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
abstract class Service_Host {
protected $so;
protected $fetchresult = NULL;
// @todo These options should be centrally defined
protected $curlopts = array(
CURLOPT_CONNECTTIMEOUT => 60,
CURLOPT_FAILONERROR => TRUE,
CURLOPT_FOLLOWLOCATION => FALSE,
CURLOPT_HEADER => FALSE,
CURLOPT_HTTPPROXYTUNNEL => FALSE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYHOST => FALSE,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_VERBOSE => FALSE,
);
/**
* Setup this class. We need to get our supplier details out of the database.
*/
public function __construct($sid) {
$this->so = ORM::factory('host_server',$sid);
}
/**
* Our HTML button that will enable us to manage this domain.
*/
abstract public function manage_button($u,$p,$d);
/**
* Return an instance of this class
*
* @return HeadImage
*/
public static function instance($supplier) {
$sc = sprintf('%s_%s',get_called_class(),$supplier);
if (! class_exists($sc))
throw new Kohana_Exception('Class doesnt exist for :supplier',array(':supplier'=>$supplier));
else
return new $sc;
}
}
?>

View File

@ -0,0 +1,34 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is able to interact with PLESK
*
* @package OSB
* @subpackage Service
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Service_Host_Plesk extends Service_Host {
private $login_acnt_field = '';
private $login_user_field = 'login_name';
private $login_pass_field = 'passwd';
// Our required abstract classes
public function manage_button($u,$p,$d) {
$output = '';
$output .= Form::open(
sprintf('%s/%s',$this->so->manage_url,'login_up.php3'),
array('target'=>'w24','method'=>'post')
);
$output .= Form::input($this->login_user_field,$u,array('type'=>'hidden'));
$output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden'));
$output .= Form::button('submit',_('Manage'),array('class'=>'form_button'));
$output .= Form::close();
return $output;
}
}
?>

View File

@ -0,0 +1,34 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is able to interact with TPP
*
* @package OSB
* @subpackage Service
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Service_Host_TPP extends Service_Host {
private $login_acnt_field = '';
private $login_user_field = 'login';
private $login_pass_field = 'password';
// Our required abstract classes
public function manage_button($u,$p,$d) {
$output = '';
$output .= Form::open(
sprintf('%s/%s',$this->so->whitelabel_url,'execute/logon'),
array('target'=>'tpp','method'=>'post')
);
$output .= Form::input($this->login_user_field,$u,array('type'=>'hidden'));
$output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden'));
$output .= Form::button('submit',_('Manage'),array('class'=>'form_button'));
$output .= Form::close();
return $output;
}
}
?>

View File

@ -0,0 +1,33 @@
<!-- //@todo To translate -->
<table class="box-full">
<tr>
<td class="head" colspan="2">Service Details</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td style="width: 50%">
<table width="100%">
<tr>
<td style="width: 40%;">Domain Name</td>
<td style="width: 60%;" class="data"><?php echo $so->name(); ?></td>
</tr>
<tr>
<td>Hosting Expire</td>
<td class="data"><?php echo $so->display('host_expire'); ?></td>
</tr>
</table>
</td>
<td style="width: 50%">
<table width="100%">
<?php if ($x=$so->manage_button()) { ?>
<tr>
<td style="width: 40%;">Panel Login</td>
<td style="width: 60%;" class="data"><?php echo $x; ?></td>
</tr>
<?php } ?>
</table>
</td>
</tr>
</table>

View File

@ -1,169 +0,0 @@
<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
*
* Originally authored by Tony Landis, AgileBill LLC
*
* Recent modifications by Deon George
*
* @author Deon George <deonATleenooksDOTnet>
* @copyright 2009 Deon George
* @link http://osb.leenooks.net
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
* @subpackage Module:HostRegistrarPlugin
*/
/**
* The main AgileBill Host Registrar Plugin Class
*
* @package AgileBill
* @subpackage Module:HostRegistrarPlugin
*/
class host_registrar_plugin extends OSB_module {
##############################
## SEARCH ##
##############################
function search($VAR)
{
### Read the contents of the /plugins/affiliate directory:
$count = 0;
chdir(PATH_PLUGINS . 'registrar');
$dir = opendir(PATH_PLUGINS . 'registrar');
while ($file_name = readdir($dir))
{
if($file_name != '..' && $file_name != '.' && !eregi("^_", $file_name))
{
$count++;
}
}
# define the DB vars as a Smarty accessible block
global $smarty;
# create the search record:
if($count > 0)
{
# create the search record
include_once(PATH_CORE . 'search.inc.php');
$search = new CORE_search;
$arr['module'] = $this->module;
$arr['sql'] = '';
$arr['limit'] = '999';
$arr['order_by']= 'name';
$arr['results'] = $count;
$search->add($arr);
# define the search id and other parameters for Smarty
$smarty->assign('search_id', $search->id);
# page:
$smarty->assign('page', '1');
# limit:
$smarty->assign('limit', '999');
# order_by:
$smarty->assign('order_by', 'name');
# define the result count
$smarty->assign('results', $count);
}
}
##############################
## SEARCH SHOW ##
##############################
function search_show($VAR)
{
### Read the contents of the /plugins/db_mapping directory:
$count = 0;
chdir(PATH_PLUGINS . 'registrar');
$dir = opendir(PATH_PLUGINS . 'registrar');
while ($file_name = readdir($dir))
{
if($file_name != '..' && $file_name != '.' && !eregi("^_", $file_name) )
{
$result[$count]['name'] = eregi_replace('.php', '', $file_name);
$result[$count]['id'] = $count;
### Get the status of this plugin:
$db = &DB();
$q = 'SELECT status,id FROM '.AGILE_DB_PREFIX.'host_registrar_plugin WHERE
file = '. $db->qstr($result[$count]['name']) . ' AND
site_id = '. $db->qstr(DEFAULT_SITE);
$dbmap = $db->Execute($q);
### error reporting:
if ($dbmap === false)
{
global $C_debug;
$C_debug->error('affiliate_plugin.inc.php','search_show', $db->ErrorMsg()); return;
}
if($dbmap->RecordCount() > 0)
{
$result[$count]['id'] = $dbmap->fields['id'];
$result[$count]['status'] = 1;
$result[$count]['active'] = $dbmap->fields['status'];
}
else
{
$result[$count]['status'] = 0;
}
$count++;
}
}
$class_name = TRUE;
for ($i=0; $i<count($result); $i++)
{
$smart[$i] = $result[$i];
if($class_name)
{
$smart[$i]['_C'] = 'row1';
$class_name = FALSE;
} else {
$smart[$i]['_C'] = 'row2';
$class_name = TRUE;
}
}
# define the DB vars as a Smarty accessible block
global $smarty;
# define the results
$smarty->assign($this->table, $smart);
$smarty->assign('page', $VAR['page']);
$smarty->assign('order', $smarty_order);
$smarty->assign('sort', $smarty_sort);
$smarty->assign('limit', $search->limit);
$smarty->assign('search_id',$search->id);
$smarty->assign('results', $count);
# total pages
$smarty->assign('pages', 1);
# current page
$smarty->assign('page', 1);
$page_arr = '';
# page array for menu
$smarty->assign('page_arr', $page_arr);
}
}
?>

View File

@ -1,79 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<construct>
<!-- Module name -->
<module>host_registrar_plugin</module>
<!-- Module supporting database table -->
<table>host_registrar_plugin</table>
<!-- Module dependancy(s) (module wont install if these modules are not yet installed) -->
<dependancy></dependancy>
<!-- DB cache in seconds -->
<cache>0</cache>
<!-- Default order_by field for SQL queries -->
<order_by>name</order_by>
<!-- Default SQL limit for SQL queries -->
<limit>25</limit>
<!-- Schema version (used to determine if the schema has change during upgrades) -->
<version>1</version>
<!-- Database indexes -->
<index>
</index>
<!-- Database fields -->
<field>
<!-- Record ID -->
<id>
<index>1</index>
<type>I4</type>
<unique>1</unique>
</id>
<!-- Site ID -->
<site_id>
<index>1</index>
<type>I4</type>
</site_id>
<!-- Record active (BOOL)-->
<status>
<display>Active</display>
<type>L</type>
</status>
<name>
<type>C(32)</type>
<unique>1</unique>
<min_len>2</min_len>
<max_len>32</max_len>
<validate>any</validate>
</name>
<file>
<type>C(32)</type>
<unique>1</unique>
<min_len>2</min_len>
<max_len>32</max_len>
<validate>any</validate>
</file>
<plugin_data>
<type>X2</type>
<convert>array</convert>
</plugin_data>
</field>
<!-- Methods for this class, and the fields they have access to, if applicable -->
<method>
<add>status,name,file,plugin_data</add>
<update>id,site_id,status,name,file,plugin_data</update>
<delete>id,site_id,status,name,file,plugin_data</delete>
<view>id,site_id,status,name,file,plugin_data</view>
<search>id,site_id,status,name,file,plugin_data</search>
</method>
<!-- Method triggers -->
<trigger></trigger>
<!-- Template page display titles -->
<title>
</title>
<!-- Template helpers -->
<tpl>
</tpl>
</construct>

View File

@ -1,57 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<!-- Tree Menu Module Properties -->
<module_properties>
<!-- MODULE Dependancy, this module wont be installed if the dependant modules dont exist -->
<dependancy></dependancy>
<!-- Translated display to use on the tree -->
<display>Host Registrar Plugins</display>
<!-- Display a module in the menu tree -->
<menu_display>1</menu_display>
<!-- MODULE Name -->
<name>host_registrar_plugin</name>
<!-- MODULE Notes, these notes show up in the modules table, as a description of the module -->
<notes><![CDATA[This module controls the settings for the registrar plugins]]></notes>
<!-- MODULE Parent, the parent node in the tree -->
<parent>host_server</parent>
<!-- SUB Modules to install with this one -->
<sub_modules></sub_modules>
<!-- MODULE Type (core|base), core modules cannot be deleted, unrecognised types are ignored. -->
<type></type>
</module_properties>
<!-- Tree Menu & Module Methods to load, they will be assigned the group permissions on install time, as selected by the user. -->
<module_method>
<add>
<name>add</name>
<notes><![CDATA[Add records]]></notes>
</add>
<delete>
<name>delete</name>
<notes><![CDATA[Delete records]]></notes>
</delete>
<search>
<display>List</display>
<menu_display>1</menu_display>
<name>search</name>
<notes><![CDATA[List records]]></notes>
<page><![CDATA[core:search&module=%%&_next_page_one=view]]></page>
</search>
<search_form>
<name>search_form</name>
<notes><![CDATA[Search for records]]></notes>
</search_form>
<search_show>
<name>search_show</name>
<notes><![CDATA[Show the results of a search]]></notes>
</search_show>
<update>
<name>update</name>
<notes><![CDATA[Update a record]]></notes>
</update>
<view>
<name>view</name>
<notes><![CDATA[View a record]]></notes>
</view>
</module_method>
</install>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<host_registrar_plugin>
<id>1</id>
<site_id>1</site_id>
<status>1</status>
<name>manual</name>
<file>MANUAL</file>
<plugin_data><![CDATA[a:1:{i:0;s:0:"";}]]></plugin_data>
</host_registrar_plugin>
<host_registrar_plugin_id>
<id>2</id>
</host_registrar_plugin_id>
</install>

View File

@ -1,221 +0,0 @@
<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
*
* Originally authored by Tony Landis, AgileBill LLC
*
* Recent modifications by Deon George
*
* @author Deon George <deonATleenooksDOTnet>
* @copyright 2009 Deon George
* @link http://osb.leenooks.net
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
* @subpackage Module:HostServer
*/
/**
* The main AgileBill Hosting Server Class
*
* @package AgileBill
* @subpackage Module:HostServer
*/
class host_server extends OSB_module {
# Manual add
function host_manual_new($service, $server, $account) { }
# Manual edit
function host_manual_edit($service, $server, $account) { }
# Manual activate
function host_manual_active($service, $server, $account) { }
# Manual deactivate
function host_manual_inactive($service, $server, $account) { }
# Manual delete
function host_manual_delete($service, $server, $account) { }
# Generate a new login
function generate_login($service,$account,$max_un_len, $max_pw_len, $shared) {
# define username
if($service['host_username'] != '') {
$ret['username'] = $service['host_username'];
} else {
if ($shared == false) {
# is username already in use on this server?
$db = &DB();
$sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'service WHERE
id != ' . $db->qstr( $service['id'] ) . ' AND
host_server_id = ' . $db->qstr( $service['host_server_id'] ) . ' AND
host_username = ' . $db->qstr( $account['username'] ) . ' AND
site_id = ' . $db->qstr(DEFAULT_SITE);
$rs = $db->Execute($sql);
if ($rs->RecordCount() == 0) {
$ret['username'] = $account['username'];
} else {
$ret['username'] = $this->generate_login1($max_un_len);
}
} else {
$ret['username'] = $account['username'];
}
}
# define password
if($service['host_password'] != '') {
$ret['password'] = $service['host_password'];
} else {
$ret['password'] = $this->generate_login1($max_pw_len);
}
# save the username/password for this service
$db = &DB();
$sql = 'UPDATE ' . AGILE_DB_PREFIX . 'service
SET
host_username = ' . $db->qstr( $ret['username'] ) . ',
host_password = ' . $db->qstr( $ret['password'] ) . '
WHERE
id = ' . $db->qstr( $service['id'] ) . ' AND
site_id = ' . $db->qstr(DEFAULT_SITE);
$db->Execute($sql);
return $ret;
}
# random un/pw
function generate_login1($length)
{
srand((double)microtime()*1000000);
$vowels = array("a", "e", "i", "o", "u");
$cons = array("b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p",
"r", "s", "t", "u", "v", "w", "tr", "cr", "br", "fr", "th",
"dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl");
$num_vowels = count($vowels);
$num_cons = count($cons);
for($i = 0; $i < $length; $i++){
@$rand .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)];
}
return $rand;
}
# use ip address
function useipaddress($service, $server)
{
if($service['host_ip'] != '') return $service['host_ip'];
$pat = "\r\n";
$ips_r = '';
@$ips = explode($pat, $server['ip_based_ip']);
for($i=0; $i<count(@$ips); $i++) {
if($i==0)
{
if($ips[0] != '')
$ip = $ips[0];
else
return false;
}
else
{
if($ips[$i] != '')
@$ips_r .= $ips[$i].$pat;
}
}
# update this service
$db = &DB();
$sql = 'UPDATE ' . AGILE_DB_PREFIX . 'service
SET
host_ip = ' . $db->qstr( $ip ) . '
WHERE
id = ' . $db->qstr( $service['id'] ) . ' AND
site_id = ' . $db->qstr(DEFAULT_SITE);
$db->Execute($sql);
# update ip list for this server
$sql = 'UPDATE ' . AGILE_DB_PREFIX . 'host_server
SET
ip_based_ip = ' . $db->qstr( $ips_r ) . '
WHERE
id = ' . $db->qstr( $server['id'] ) . ' AND
site_id = ' . $db->qstr(DEFAULT_SITE);
$db->Execute($sql);
return $ip;
}
# re-use ip address
function unuseipaddress($server, $ip)
{
if(empty($ip)) return false;
# update ip list for this server
$ips = $ip;
if(!empty($server['ip_based_ip']))
$ips .= "\r\n".$server['ip_based_ip'];
# update
$db = &DB();
$sql = 'UPDATE ' . AGILE_DB_PREFIX . 'host_server
SET
ip_based_ip = ' . $db->qstr( $ips ) . '
WHERE
id = ' . $db->qstr( $server['id'] ) . ' AND
site_id = ' . $db->qstr(DEFAULT_SITE);
$db->Execute($sql);
return true;
}
/**
* Add a record
*/
public function add($VAR) {
$VAR['host_server_keycode'] = md5(rand(99,999).microtime());
return parent::add($VAR);
}
##############################
## VIEW ##
##############################
function view($VAR)
{
global $smarty;
$type = "view";
$this->method["$type"] = explode(",", $this->method["$type"]);
$dx = new CORE_database;
$rs = $dx->view($VAR, $this, $type);
# get the list of available servers to define as "next server"
$db = &DB();
$sql= 'SELECT id,name FROM ' . AGILE_DB_PREFIX . 'host_server WHERE
id != ' . $db->qstr( $rs[0]['id'] ) . ' AND
next_host_server_id != ' . $db->qstr( $rs[0]['id'] ) . ' AND
provision_plugin = ' . $db->qstr( $rs[0]['provision_plugin'] ) . ' AND
site_id = ' . $db->qstr(DEFAULT_SITE);
$rs = $db->Execute($sql);
if(@$rs->RecordCount() > 0)
{
$arr[0] = '';
while(!$rs->EOF) {
$arr[$rs->fields['id']] = $rs->fields['name'];
$rs->MoveNext();
}
$smarty->assign('next_server_options', $arr);
$smarty->assign('next_server', true);
} else {
$smarty->assign('next_server', false);
}
}
}
?>

View File

@ -1,141 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<construct>
<!-- Module name -->
<module>host_server</module>
<!-- Module supporting database table -->
<table>host_server</table>
<!-- Module dependancy(s) (module wont install if these modules are not yet installed) -->
<dependancy></dependancy>
<!-- DB cache in seconds -->
<cache>0</cache>
<!-- Default order_by field for SQL queries -->
<order_by>name</order_by>
<!-- Default SQL limit for SQL queries -->
<limit>25</limit>
<!-- Schema version (used to determine if the schema has change during upgrades) -->
<version>0</version>
<!-- Database indexes -->
<index>
</index>
<!-- Database fields -->
<field>
<!-- Record ID -->
<id>
<index>1</index>
<type>I4</type>
<unique>1</unique>
</id>
<!-- Site ID -->
<site_id>
<index>1</index>
<type>I4</type>
</site_id>
<!-- Record active (BOOL)-->
<status>
<display>Active</display>
<type>L</type>
</status>
<debug>
<type>L</type>
</debug>
<name>
<type>C(128)</type>
<min_len>1</min_len>
<max_len>128</max_len>
<validate>any</validate>
</name>
<notes>
<type>C(255)</type>
</notes>
<provision_plugin>
<type>C(128)</type>
<min_len>1</min_len>
<max_len>128</max_len>
</provision_plugin>
<provision_plugin_data>
<type>X2</type>
<convert>array</convert>
</provision_plugin_data>
<max_accounts>
<type>I4</type>
</max_accounts>
<next_host_server_id>
<type>I4</type>
<asso_table>host_server</asso_table>
<asso_field>name</asso_field>
</next_host_server_id>
<name_based>
<type>L</type>
</name_based>
<name_based_ip>
<type>C(32)</type>
</name_based_ip>
<ip_based>
<type>L</type>
</ip_based>
<ip_based_ip>
<type>X2</type>
</ip_based_ip>
<ns_primary>
<type>C(128)</type>
</ns_primary>
<ns_secondary>
<type>C(128)</type>
</ns_secondary>
<ns_ip_primary>
<type>C(128)</type>
</ns_ip_primary>
<ns_ip_secondary>
<type>C(128)</type>
</ns_ip_secondary>
<keycode>
<type>C(64)</type>
</keycode>
</field>
<!-- Methods for this class, and the fields they have access to, if applicable -->
<method>
<add>status,debug,name,notes,provision_plugin,name_based,name_based_ip,ip_based,ip_based_ip,ns_ip_secondary,ns_ip_primary,ns_primary,ns_secondary,keycode</add>
<update>id,site_id,status,debug,name,notes,provision_plugin,provision_plugin_data,max_accounts,next_host_server_id,name_based,name_based_ip,ip_based,ip_based_ip,ns_ip_secondary,ns_ip_primary,ns_primary,ns_secondary,keycode</update>
<delete>id,site_id,status,debug,name,notes,provision_plugin,provision_plugin_data,max_accounts,next_host_server_id,name_based,name_based_ip,ip_based,ip_based_ip,ns_ip_secondary,ns_ip_primary,ns_primary,ns_secondary,keycode</delete>
<view>id,site_id,status,debug,name,notes,provision_plugin,provision_plugin_data,max_accounts,next_host_server_id,name_based,name_based_ip,ip_based,ip_based_ip,ns_ip_secondary,ns_ip_primary,ns_primary,ns_secondary,keycode</view>
<search>id,site_id,status,debug,name,notes,provision_plugin,provision_plugin_data,max_accounts,next_host_server_id,name_based,name_based_ip,ip_based,ip_based_ip,ns_ip_secondary,ns_ip_primary,ns_primary,ns_secondary,keycode</search>
</method>
<!-- Method triggers -->
<trigger></trigger>
<!-- Template page display titles -->
<title>
</title>
<!-- Template helpers -->
<tpl>
<search_show>
<checkbox>
<field>id</field>
<type>checkbox</type>
<width>25px</width>
</checkbox>
<name>
<field>name</field>
</name>
<provision_plugin>
<field>provision_plugin</field>
</provision_plugin>
<name_based_ip>
<field>name_based_ip</field>
</name_based_ip>
<max_accounts>
<field>max_accounts</field>
</max_accounts>
<icon>
<field>status</field>
<type>bool_icon</type>
<width>20px</width>
</icon>
</search_show>
</tpl>
</construct>

View File

@ -1,59 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<!-- Tree Menu Module Properties -->
<module_properties>
<!-- MODULE Dependancy, this module wont be installed if the dependant modules dont exist -->
<dependancy></dependancy>
<!-- Translated display to use on the tree -->
<display>Hosting Servers</display>
<!-- Display a module in the menu tree -->
<menu_display>1</menu_display>
<!-- MODULE Name -->
<name>host_server</name>
<!-- MODULE Notes, these notes show up in the modules table, as a description of the module -->
<notes><![CDATA[This module controls the servers your new accounts/domains can be provisioned on.]]></notes>
<!-- MODULE Parent, the parent node in the tree -->
<parent></parent>
<!-- SUB Modules to install with this one -->
<sub_modules>host_tld,host_registrar_plugin</sub_modules>
<!-- MODULE Type (core|base), core modules cannot be deleted, unrecognised types are ignored. -->
<type></type>
</module_properties>
<!-- Tree Menu & Module Methods to load, they will be assigned the group permissions on install time, as selected by the user. -->
<module_method>
<add>
<display>Add</display>
<menu_display>1</menu_display>
<name>add</name>
<notes><![CDATA[Add records]]></notes>
</add>
<delete>
<name>delete</name>
<notes><![CDATA[Delete records]]></notes>
</delete>
<search>
<display>List</display>
<menu_display>1</menu_display>
<name>search</name>
<notes><![CDATA[List records]]></notes>
<page><![CDATA[core:search&module=%%&_next_page_one=view]]></page>
</search>
<search_form>
<name>search_form</name>
<notes><![CDATA[Search for records]]></notes>
</search_form>
<search_show>
<name>search_show</name>
<notes><![CDATA[Show the results of a search]]></notes>
</search_show>
<update>
<name>update</name>
<notes><![CDATA[Update a record]]></notes>
</update>
<view>
<name>view</name>
<notes><![CDATA[View a record]]></notes>
</view>
</module_method>
</install>

View File

@ -1,8 +0,0 @@
<?php
$auth_methods = Array
(
Array ('module' => 'host_tld', 'method' => 'whois'),
Array ('module' => 'host_tld', 'method' => 'whois_transfer'),
Array ('module' => 'host_tld', 'method' => 'whois_mass')
);
?>

View File

@ -1,348 +0,0 @@
<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
*
* Originally authored by Tony Landis, AgileBill LLC
*
* Recent modifications by Deon George
*
* @author Deon George <deonATleenooksDOTnet>
* @copyright 2009 Deon George
* @link http://osb.leenooks.net
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
* @subpackage Module:Domains
*/
/**
* The main AgileBill Module Domains Class
*
* @package AgileBill
* @subpackage Module:Domains
*/
class host_tld extends OSB_module {
/**
* Get the TLD pricing array
*
* @param string $tld
* @param string $type park, register, renew
* @param int $product_id
* @param array $discount_products
* @param float $discount_rate
* @param int $account
* @return array
*/
function price_tld_arr($tld, $type, $product_id=false, $discount_products=false, $discount_rate=false, $account=SESS_ACCOUNT)
{
# get the plugin for this domain:
$db = &DB();
$result = $db->Execute(sqlSelect($db,"host_tld","*","name=::$tld:: AND status=1"));
if($result == false || $result->RecordCount() == 0) return false;
# serialize:
global $C_auth;
$p_arr = unserialize($result->fields["price_group"]);
# get the pricing for domain parking:
if($type == "park") {
if($p_arr[0]["show"] != "1") {
return false;
} else {
$i = 0;
$type = $register;
while (list ($group, $vals) = each ($p_arr[$i]))
if (gettype($group) != 'string' && $C_auth->auth_group_by_account_id($account, $group))
if(empty($price) || $vals["register"] < $price)
$price = $vals["register"];
return $price;
}
} else {
# get any hosting discounts for this product:
if(!empty($discount_products)) {
$d_arr = unserialize($discount_products);
for($ii=0; $ii<count($d_arr); $ii++) {
if($d_arr[$ii] == $result->fields["id"])
$hosting_discount = $discount_rate;
}
}
if(empty($hosting_discount)) $hosting_discount = false;
# get the pricing details for registrations/transfers for this TLD:
if(count($p_arr) > 0)
for($i=1; $i<=10; $i++)
if($p_arr[$i]["show"] == "1")
while (list ($group, $vals) = each ($p_arr[$i]))
if (gettype($group) != 'string' && $C_auth->auth_group_by_account_id($account, $group))
if(empty($price[$i]) || $vals[$type] < $price[$i])
if(!empty($vals[$type]))
if($hosting_discount != false)
$price[$i] = $vals[$type] - ($vals[$type] * $hosting_discount);
else
$price[$i] = $vals[$type];
return $price;
}
return false;
}
/** SUGGEST RESULTS
*/
function suggest($VAR)
{
$db = &DB();
$dbm = new CORE_database;
$sql = $dbm->sql_select('host_tld','name,default_term_new', "auto_search = 1 AND status = 1", "name", $db);
$rs = $db->Execute($sql);
while(!$rs->EOF) {
$smart[] = $rs->fields;
$rs->MoveNext();
}
$count = count($smart);
$js = "var tldArr = new Array($count); var tldCount = $count; ";
for($i=0; $i<$count; $i++)
$js .= "tldArr[$i] = '{$smart[$i]['name']}'; ";
global $smarty;
$smarty->assign('tlds', $smart);
$smarty->assign('javascript', $js);
}
/** WHOIS LOOKUP
*/
function whois_mass($VAR)
{
global $smarty, $C_debug, $C_translate;
$db = &DB();
if(!empty($VAR['domains']))
{
$arr = explode("\r\n", $VAR['domains']);
$domains ='';
$msg ='';
// loop through each row
for($i=0; $i<count($arr); $i++)
{
# check for correct structure:
if(ereg('\.', $arr[$i]))
{
# split domain & tld
$dt = explode('.', $arr[$i]);
$domain = $dt[0];
# get the current tld
$tld = '';
foreach($dt as $key=>$td) {
if($key > 0) {
if(!empty($tld)) $tld .='.';
$tld .= $td;
}
}
# check for duplicates
$do=true;
for($ii=0; $ii<count(@$domainarr); $ii++) {
if($domainarr[$ii][0] == $domain && $domainarr[$ii][1] == $tld) {
$do = false;
break;
}
}
if($do)
{
$C_translate->value['host_tld']['domain'] = '<b><u>'.$domain.".".$tld.'</u></b>';
$C_translate->value['host_tld']['tld'] = '<b><u>'.$tld.'</u></b>';
# get the plugin for this domain:
$result = $db->Execute(sqlSelect($db,"host_tld","*","name=::$tld:: AND status=1"));
if($result == false || $result->RecordCount() == 0)
{
### INVALID TLD
$msg .= $C_translate->translate('search_mass_err_tld','host_tld','') . '<br>';
}
else
{
# get the whois plugin details for this TLD & check avail
$file = $result->fields['whois_plugin'];
$data = unserialize($result->fields['whois_plugin_data']);
include_once(PATH_PLUGINS . 'whois/'. $file.'.php');
eval ( '$_WHOIS = new plgn_whois_'. strtoupper ( $file ) . ';' );
if($_WHOIS->check($domain, $tld, $data))
{
$smarty->assign("checkout", true);
$domains .= $domain.'.'.$tld."\r\n";
$domainarr[] = Array($domain,$tld);
} else {
### DOMAIN NOT AVAILABLE
$msg .= $C_translate->translate('search_mass_err_dom','host_tld','') . '<br>';
}
}
}
}
}
if($msg) $C_debug->alert($msg);
$smarty->assign('domains', @$domains);
$smarty->assign('domainarr', @$domainarr);
}
}
/**
* WHOIS RESPONSE
*/
function whois_reponse($type, $VAR, $response, $park=0) {
if(defined('AJAX')) {
if($type=='register') {
if($response)
echo 'available('.$park.');';
else
echo 'unavailable();';
} elseif($type=='transfer') {
if($response)
echo 'unavailable();';
else
echo 'available();';
} elseif($type=='suggest') {
if($response)
echo "domainUpdate('{$VAR['domain']}','{$VAR['tld']}','register','{$VAR['element']}',1);";
else
echo "domainUpdate('{$VAR['domain']}','{$VAR['tld']}','register','{$VAR['element']}',0);";
}
}
return $response;
}
/**
* WHOIS LOOKUP
*/
function whois($VAR)
{
if(!empty($VAR['tld']) && !empty($VAR['domain']))
{
$db = &DB();
# check this domain & tld is not already in the service table:
$rs = $db->Execute(sqlSelect($db,"service","id","domain_name = ::{$VAR['domain']}:: AND domain_tld = ::{$VAR['tld']}::"));
if($rs && $rs->RecordCount()) {
//$smarty->assign("whois_result", "0");
//echo 'unavailable();';
return $this->whois_reponse($VAR['type'], $VAR, false);
}
# check this domain & tld is not already in the shopping cart:
$rs = $db->Execute(sqlSelect($db,"cart","id","domain_name = ::{$VAR['domain']}:: AND domain_tld = ::{$VAR['tld']}::"));
if($rs && $rs->RecordCount()) {
return $this->whois_reponse($VAR['type'], $VAR, false);
}
# get the plugin for this domain:
$result = $db->Execute(sqlSelect($db,"host_tld","*","name=::{$VAR['tld']}:: AND status=1"));
if($result == false || $result->RecordCount() == 0) {
return $this->whois_reponse($VAR['type'], $VAR, false);
}
# get the whois plugin details for this TLD
$file = $result->fields['whois_plugin'];
$data = unserialize($result->fields['whois_plugin_data']);
# allow parking?
$price = unserialize ( $result->fields['price_group'] );
$park = $price["0"]["show"];
# initialize the whois plugin:
include_once(PATH_PLUGINS . 'whois/'. $file.'.php');
eval ( '$_WHOIS = new plgn_whois_'. strtoupper ( $file ) . ';' );
if($_WHOIS->check($VAR['domain'], $VAR['tld'], $data))
return $this->whois_reponse($VAR['type'], $VAR, true, $park);
else
return $this->whois_reponse($VAR['type'], $VAR, false, $park);
} else {
return $this->whois_reponse($VAR['type'], $VAR, false, $park);
}
}
/**
* WHOIS TRANSFER LOOKUP
*/
function whois_transfer($VAR)
{
global $smarty;
if(!empty($VAR['tld']) && !empty($VAR['domain']))
{
$db = &DB();
# check this domain & tld is not already in the service table:
$rs = $db->Execute(sqlSelect($db,"service","id","domain_name = ::{$VAR['domain']}:: AND domain_tld = ::{$VAR['tld']}::"));
if($rs && $rs->RecordCount()) {
$smarty->assign("whois_result", "0");
return;
}
# check this domain & tld is not already in the shopping cart:
$rs = $db->Execute(sqlSelect($db,"cart","id","domain_name = ::{$VAR['domain']}:: AND domain_tld = ::{$VAR['tld']}::"));
if($rs && $rs->RecordCount()) {
$smarty->assign("whois_result", "0");
return;
}
# get the plugin for this domain:
$result = $db->Execute(sqlSelect($db,"host_tld","*","name=::{$VAR['tld']}:: AND status=1"));
if($result == false || $result->RecordCount() == 0) {
$smarty->assign("whois_result", "0");
return;
}
# get the pricing details to see if transfers are allowed for this TLD:
$p_arr = unserialize($result->fields["price_group"]);
$transfer = false;
if(count($p_arr) > 0)
for($i=1; $i<=10; $i++)
if($p_arr[$i]["show"] == "1")
while(list($key,$val) = each($p_arr[$i]))
if(isset($val["transfer"]) && $val["transfer"] > 1) $transfer = true;
if(!$transfer)
{
$smarty->assign("whois_result", "0");
return;
}
# get the whois plugin details for this TLD
$file = $result->fields['whois_plugin'];
$data = unserialize($result->fields['whois_plugin_data']);
# initialize the whois plugin:
include_once(PATH_PLUGINS . 'whois/'. $file.'.php');
eval ( '$_WHOIS = new plgn_whois_'. strtoupper ( $file ) . ';' );
if($_WHOIS->check_transfer($VAR['domain'], $VAR['tld'], $data))
{
$smarty->assign("whois_result", "1");
return;
}
else
{
$smarty->assign("whois_result", "0");
return;
}
}
else
{
$smarty->assign("whois_result", "0");
return;
}
}
}
?>

View File

@ -1,141 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<construct>
<!-- Module name -->
<module>host_tld</module>
<!-- Module supporting database table -->
<table>host_tld</table>
<!-- Module dependancy(s) (module wont install if these modules are not yet installed) -->
<dependancy></dependancy>
<!-- DB cache in seconds -->
<cache>15</cache>
<!-- Default order_by field for SQL queries -->
<order_by>name</order_by>
<!-- Default SQL limit for SQL queries -->
<limit>25</limit>
<!-- Schema version (used to determine if the schema has change during upgrades) -->
<version>0</version>
<!-- Database indexes -->
<index>
<status>status</status>
<name>name</name>
<auto_search>auto_search</auto_search>
</index>
<!-- Database fields -->
<field>
<!-- Record ID -->
<id>
<index>1</index>
<type>I4</type>
<unique>1</unique>
</id>
<!-- Site ID -->
<site_id>
<index>1</index>
<type>I4</type>
</site_id>
<!-- Date record created -->
<date_orig>
<display>Date Created</display>
<type>I8</type>
</date_orig>
<!-- Date record updated -->
<date_last>
<convert>date-now</convert>
<display>Date Updated</display>
<type>I8</type>
</date_last>
<!-- Record active (BOOL)-->
<status>
<display>Active</display>
<type>L</type>
</status>
<name>
<display>Extension Name</display>
<type>C(128)</type>
<validate>any</validate>
</name>
<taxable>
<display>Taxable</display>
<type>L</type>
</taxable>
<whois_plugin>
<display>Whois Plugin</display>
<type>C(32)</type>
<min_len>1</min_len>
<max_len>32</max_len>
</whois_plugin>
<whois_plugin_data>
<type>X2</type>
<convert>array</convert>
</whois_plugin_data>
<registrar_plugin_id>
<display>Registrar Plugin</display>
<type>I4</type>
<asso_table>host_registrar_plugin</asso_table>
<asso_field>name</asso_field>
</registrar_plugin_id>
<registrar_plugin_data>
<type>X2</type>
<convert>array</convert>
</registrar_plugin_data>
<auto_search>
<display>Auto Search</display>
<type>L</type>
</auto_search>
<default_term_new>
<display>Default Term</display>
<type>I4</type>
<min_len>1</min_len>
<max_len>2</max_len>
<validate>numeric</validate>
</default_term_new>
<price_group>
<type>X2</type>
<convert>array</convert>
</price_group>
</field>
<!-- Methods for this class, and the fields they have access to, if applicable -->
<method>
<add>status,name,whois_plugin,auto_search,default_term_new,taxable</add>
<update>id,site_id,status,name,whois_plugin,whois_plugin_data,registrar_plugin_id,registrar_plugin_data,auto_search,default_term_new,price_group,taxable</update>
<delete>id,site_id,status,name,whois_plugin,whois_plugin_data,registrar_plugin_id,registrar_plugin_data,auto_search,default_term_new,price_group,taxable</delete>
<view>id,site_id,status,name,whois_plugin,whois_plugin_data,registrar_plugin_id,registrar_plugin_data,auto_search,default_term_new,price_group,taxable</view>
<search>id,site_id,status,name,whois_plugin,whois_plugin_data,registrar_plugin_id,registrar_plugin_data,auto_search,default_term_new,price_group,taxable</search>
</method>
<!-- Method triggers -->
<trigger></trigger>
<!-- Template page display titles -->
<title>
<add>Add TLD</add>
</title>
<!-- Template helpers -->
<tpl>
<search_show>
<checkbox>
<field>id</field>
<type>checkbox</type>
<width>25px</width>
</checkbox>
<name>
<field>name</field>
</name>
<status>
<field>status</field>
<type>bool_icon</type>
<width>20px</width>
</status>
<whois_plugin>
<field>whois_plugin</field>
</whois_plugin>
<registrar_plugin_id>
<field>registrar_plugin_id</field>
</registrar_plugin_id>
</search_show>
</tpl>
</construct>

View File

@ -1,57 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<!-- Tree Menu Module Properties -->
<module_properties>
<!-- MODULE Dependancy, this module wont be installed if the dependant modules dont exist -->
<dependancy></dependancy>
<!-- Translated display to use on the tree -->
<display>Domain TLD</display>
<!-- Display a module in the menu tree -->
<menu_display>1</menu_display>
<!-- MODULE Name -->
<name>host_tld</name>
<!-- MODULE Notes, these notes show up in the modules table, as a description of the module -->
<notes><![CDATA[This module controls the settings for the TLD (top level domains)]]></notes>
<!-- MODULE Parent, the parent node in the tree -->
<parent>host_server</parent>
<!-- MODULE Type (core|base), core modules cannot be deleted, unrecognised types are ignored. -->
<type></type>
</module_properties>
<!-- Tree Menu & Module Methods to load, they will be assigned the group permissions on install time, as selected by the user. -->
<module_method>
<add>
<display>Add</display>
<menu_display>1</menu_display>
<name>add</name>
<notes><![CDATA[Add records]]></notes>
</add>
<delete>
<name>delete</name>
<notes><![CDATA[Delete records]]></notes>
</delete>
<search>
<display>List</display>
<menu_display>1</menu_display>
<name>search</name>
<notes><![CDATA[List records]]></notes>
<page><![CDATA[core:search&module=%%&_next_page_one=view]]></page>
</search>
<search_form>
<name>search_form</name>
<notes><![CDATA[Search for records]]></notes>
</search_form>
<search_show>
<name>search_show</name>
<notes><![CDATA[Show the results of a search]]></notes>
</search_show>
<update>
<name>update</name>
<notes><![CDATA[Update a record]]></notes>
</update>
<view>
<name>view</name>
<notes><![CDATA[View a record]]></notes>
</view>
</module_method>
</install>

View File

@ -1,90 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<host_tld>
<id>1</id>
<site_id>1</site_id>
<status>1</status>
<name>com</name>
<taxable>0</taxable>
<whois_plugin>DEFAULT</whois_plugin>
<whois_plugin_data><![CDATA[a:2:{s:12:"whois_server";s:16:"whois.crsnic.net";s:14:"avail_response";s:12:"No match for";}]]></whois_plugin_data>
<registrar_plugin_id>1</registrar_plugin_id>
<registrar_plugin_data><![CDATA[a:1:{i:0;s:0:"";}]]></registrar_plugin_data>
<auto_search>1</auto_search>
<default_term_new>1</default_term_new>
<price_group><![CDATA[a:11:{i:0;a:3:{s:4:"show";s:1:"0";i:0;a:1:{s:8:"register";s:0:"";}i:2;a:1:{s:8:"register";s:0:"";}}i:1;a:3:{s:4:"show";s:1:"1";i:0;a:3:{s:8:"register";s:2:"10";s:5:"renew";s:2:"10";s:8:"transfer";s:2:"10";}i:2;a:3:{s:8:"register";s:2:"10";s:5:"renew";s:2:"10";s:8:"transfer";s:2:"10";}}i:2;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:3;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:4;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:5;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:6;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:7;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:8;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:9;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:10;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}}]]></price_group>
</host_tld>
<host_tld>
<id>2</id>
<site_id>1</site_id>
<status>1</status>
<name>net</name>
<taxable>1</taxable>
<whois_plugin>DEFAULT</whois_plugin>
<whois_plugin_data><![CDATA[a:2:{s:12:"whois_server";s:16:"whois.crsnic.net";s:14:"avail_response";s:12:"No match for";}]]></whois_plugin_data>
<registrar_plugin_id>1</registrar_plugin_id>
<registrar_plugin_data><![CDATA[a:1:{i:0;s:0:"";}]]></registrar_plugin_data>
<auto_search>1</auto_search>
<default_term_new>1</default_term_new>
<price_group><![CDATA[a:11:{i:0;a:3:{s:4:"show";s:1:"1";i:0;a:1:{s:8:"register";s:2:"10";}i:2;a:1:{s:8:"register";s:2:"10";}}i:1;a:3:{s:4:"show";s:1:"1";i:0;a:3:{s:8:"register";s:2:"15";s:5:"renew";s:2:"15";s:8:"transfer";s:2:"15";}i:2;a:3:{s:8:"register";s:2:"15";s:5:"renew";s:2:"15";s:8:"transfer";s:2:"15";}}i:2;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:3;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:4;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:5;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:6;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:7;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:8;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:9;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:10;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}}]]></price_group>
</host_tld>
<host_tld>
<id>3</id>
<site_id>1</site_id>
<status>1</status>
<name>org</name>
<taxable>1</taxable>
<whois_plugin>DEFAULT</whois_plugin>
<whois_plugin_data><![CDATA[a:2:{s:12:"whois_server";s:32:"whois.publicinterestregistry.net";s:14:"avail_response";s:9:"NOT FOUND";}]]></whois_plugin_data>
<registrar_plugin_id>1</registrar_plugin_id>
<registrar_plugin_data><![CDATA[a:1:{i:0;s:0:"";}]]></registrar_plugin_data>
<auto_search>1</auto_search>
<default_term_new>2</default_term_new>
<price_group><![CDATA[a:11:{i:0;a:3:{s:4:"show";s:1:"0";i:0;a:1:{s:8:"register";s:0:"";}i:2;a:1:{s:8:"register";s:0:"";}}i:1;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:2;a:3:{s:4:"show";s:1:"1";i:0;a:3:{s:8:"register";s:2:"20";s:5:"renew";s:2:"20";s:8:"transfer";s:2:"20";}i:2;a:3:{s:8:"register";s:2:"20";s:5:"renew";s:2:"20";s:8:"transfer";s:2:"20";}}i:3;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:4;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:5;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:6;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:7;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:8;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:9;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:10;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}}]]></price_group>
</host_tld>
<host_tld>
<id>4</id>
<site_id>1</site_id>
<status>1</status>
<name>com.au</name>
<taxable>1</taxable>
<whois_plugin>DEFAULT</whois_plugin>
<whois_plugin_data><![CDATA[a:2:{s:12:"whois_server";s:32:"whois.aunic.net";s:14:"avail_response";s:9:"AVAILABLE";}]]></whois_plugin_data>
<registrar_plugin_id>1</registrar_plugin_id>
<registrar_plugin_data><![CDATA[a:1:{i:0;s:0:"";}]]></registrar_plugin_data>
<auto_search>1</auto_search>
<default_term_new>2</default_term_new>
<price_group><![CDATA[a:11:{i:0;a:3:{s:4:"show";s:1:"0";i:0;a:1:{s:8:"register";s:0:"";}i:2;a:1:{s:8:"register";s:0:"";}}i:1;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:2;a:3:{s:4:"show";s:1:"1";i:0;a:3:{s:8:"register";s:2:"20";s:5:"renew";s:2:"20";s:8:"transfer";s:2:"20";}i:2;a:3:{s:8:"register";s:2:"20";s:5:"renew";s:2:"20";s:8:"transfer";s:2:"20";}}i:3;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:4;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:5;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:6;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:7;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:8;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:9;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:10;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}}]]></price_group>
</host_tld>
<host_tld>
<id>5</id>
<site_id>1</site_id>
<status>1</status>
<name>net.au</name>
<taxable>1</taxable>
<whois_plugin>DEFAULT</whois_plugin>
<whois_plugin_data><![CDATA[a:2:{s:12:"whois_server";s:32:"whois.aunic.net";s:14:"avail_response";s:9:"AVAILABLE";}]]></whois_plugin_data>
<registrar_plugin_id>1</registrar_plugin_id>
<registrar_plugin_data><![CDATA[a:1:{i:0;s:0:"";}]]></registrar_plugin_data>
<auto_search>1</auto_search>
<default_term_new>2</default_term_new>
<price_group><![CDATA[a:11:{i:0;a:3:{s:4:"show";s:1:"0";i:0;a:1:{s:8:"register";s:0:"";}i:2;a:1:{s:8:"register";s:0:"";}}i:1;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:2;a:3:{s:4:"show";s:1:"1";i:0;a:3:{s:8:"register";s:2:"20";s:5:"renew";s:2:"20";s:8:"transfer";s:2:"20";}i:2;a:3:{s:8:"register";s:2:"20";s:5:"renew";s:2:"20";s:8:"transfer";s:2:"20";}}i:3;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:4;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:5;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:6;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:7;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:8;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:9;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:10;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}}]]></price_group>
</host_tld>
<host_tld>
<id>6</id>
<site_id>1</site_id>
<status>1</status>
<name>org.au</name>
<taxable>1</taxable>
<whois_plugin>DEFAULT</whois_plugin>
<whois_plugin_data><![CDATA[a:2:{s:12:"whois_server";s:32:"whois.aunic.net";s:14:"avail_response";s:9:"AVAILABLE";}]]></whois_plugin_data>
<registrar_plugin_id>1</registrar_plugin_id>
<registrar_plugin_data><![CDATA[a:1:{i:0;s:0:"";}]]></registrar_plugin_data>
<auto_search>1</auto_search>
<default_term_new>2</default_term_new>
<price_group><![CDATA[a:11:{i:0;a:3:{s:4:"show";s:1:"0";i:0;a:1:{s:8:"register";s:0:"";}i:2;a:1:{s:8:"register";s:0:"";}}i:1;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:2;a:3:{s:4:"show";s:1:"1";i:0;a:3:{s:8:"register";s:2:"20";s:5:"renew";s:2:"20";s:8:"transfer";s:2:"20";}i:2;a:3:{s:8:"register";s:2:"20";s:5:"renew";s:2:"20";s:8:"transfer";s:2:"20";}}i:3;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:4;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:5;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:6;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:7;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:8;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:9;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}i:10;a:3:{s:4:"show";s:1:"0";i:0;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}i:2;a:3:{s:8:"register";s:0:"";s:5:"renew";s:0:"";s:8:"transfer";s:0:"";}}}]]></price_group>
</host_tld>
<host_tld_id>
<id>6</id>
</host_tld_id>
</install>

View File

@ -53,7 +53,7 @@ class Controller_Task_Invoice extends Controller_Task {
$io = ORM::factory('invoice'); $io = ORM::factory('invoice');
$key = 'remind_due'; $key = 'remind_due';
foreach ($io->list_due(time()-86400*$days) as $io) { foreach ($io->list_due(time()+86400*$days) as $io) {
// If we have already sent a reminder, we'll skip to the next one. // If we have already sent a reminder, we'll skip to the next one.
if ($io->remind($key) AND (is_null($x=$this->request->param('id')) OR $x != 'again')) if ($io->remind($key) AND (is_null($x=$this->request->param('id')) OR $x != 'again'))
continue; continue;

View File

@ -170,7 +170,7 @@ class Model_Invoice extends ORMOSB {
foreach ($this->items_main() as $ito) { foreach ($this->items_main() as $ito) {
$unique = TRUE; $unique = TRUE;
$t = $ito->product->summary(); $t = $ito->product->name();
if (! isset($result[$t])) { if (! isset($result[$t])) {
$result[$t]['quantity'] = 0; $result[$t]['quantity'] = 0;
$result[$t]['subtotal'] = 0; $result[$t]['subtotal'] = 0;
@ -373,29 +373,26 @@ class Model_Invoice extends ORMOSB {
/** LIST FUNCTIONS **/ /** LIST FUNCTIONS **/
private function _list_due() {
// @todo This rounding should be a system configuration
return $this->where('round(total_amt-ifnull(credit_amt,0),2)','>','=billed_amt')
->and_where('status','=',1)
->order_by('due_date,account_id,id');
}
/** /**
* Identify all the invoices that are due * Identify all the invoices that are due
*/ */
private function _list_due($time=NULL,$op='<=') { public function list_overdue($time=NULL) {
if (is_null($time)) if (is_null($time))
$time = time(); $time = time();
// @todo This rounding should be a system configuration // @todo This rounding should be a system configuration
return $this return $this->_list_due()
->where('round(total_amt-ifnull(credit_amt,0),2)','>','=billed_amt') ->and_where('due_date','<=',$time)
->and_where('due_date',$op,$time)
->and_where('status','=',1)
->order_by('due_date,account_id,id')
->find_all(); ->find_all();
} }
/**
* Return a list of invoices that are over their due date.
*/
public function list_overdue($time=NULL) {
return $this->_list_due($time,'<=');
}
/** /**
* Return a list of invoices that are over their due date with/without auto billing * Return a list of invoices that are over their due date with/without auto billing
*/ */
@ -419,7 +416,15 @@ class Model_Invoice extends ORMOSB {
* Return a list of invoices that are due, excluding overdue. * Return a list of invoices that are due, excluding overdue.
*/ */
public function list_due($time=NULL) { public function list_due($time=NULL) {
return $this->_list_due($time,'>'); if (is_null($time))
return $this->_list_due()
->and_where('due_date','>',time())
->find_all();
else
return $this->_list_due()
->and_where('due_date','<=',$time)
->and_where('due_date','>',time())
->find_all();
} }
} }
?> ?>

View File

@ -39,7 +39,7 @@ class Model_Invoice_Item extends ORMOSB {
if ($this->item_type != 0) if ($this->item_type != 0)
return; return;
return $this->service->details('invoice'); return $this->service->details('invoice_detail_items');
} }
public function subtotal() { public function subtotal() {

View File

@ -36,7 +36,7 @@ class Controller_Product extends Controller_TemplateDefault {
* Obtain a list of pages in a category * Obtain a list of pages in a category
*/ */
private function _get_category($id) { private function _get_category($id) {
return ORM::factory('product')->category($id); return ORM::factory('product')->list_category($id);
} }
/** /**

View File

@ -14,6 +14,7 @@ class Model_Product extends ORMOSB {
// @todo this doesnt have our site_id when getting the translation // @todo this doesnt have our site_id when getting the translation
protected $_has_many = array( protected $_has_many = array(
'product_translate'=>array('far_key'=>'id'), 'product_translate'=>array('far_key'=>'id'),
'service'=>array('far_key'=>'id'),
); );
protected $_sorting = array( protected $_sorting = array(
@ -27,21 +28,6 @@ class Model_Product extends ORMOSB {
), ),
); );
/**
* The feature summary should be implemented in child objects.
* It is displayed on the product overview page, as a summary of the products features.
*/
protected function _feature_summary() {
throw new Kohana_Exception(':method not defined in child class :class',array(':method'=>__METHOD__,':class'=>get_class($this)));
}
/**
* The summary should be implemented in child objects.
*/
protected function _summary() {
return _('No Description');
}
/** /**
* Return the object of the product plugin * Return the object of the product plugin
*/ */
@ -52,8 +38,7 @@ class Model_Product extends ORMOSB {
if (! is_numeric($this->prod_plugin_data)) if (! is_numeric($this->prod_plugin_data))
throw new Kohana_Exception('Missing plugin_id for :product (:type)',array(':product'=>$this->id,':type'=>$this->prod_plugin_file)); throw new Kohana_Exception('Missing plugin_id for :product (:type)',array(':product'=>$this->id,':type'=>$this->prod_plugin_file));
$spn = sprintf('%s_%s',get_class($this),$this->prod_plugin_file); return ORM::factory(sprintf('product_plugin_%s',$this->prod_plugin_file),$this->prod_plugin_data);
return new $spn($this->prod_plugin_data);
} }
/** /**
@ -67,36 +52,7 @@ class Model_Product extends ORMOSB {
* This will render the product feature summary information * This will render the product feature summary information
*/ */
public function feature_summary() { public function feature_summary() {
if (is_null($plugin = $this->plugin())) return (is_null($plugin = $this->plugin())) ? HTML::nbsp('') : $plugin->feature_summary();
return HTML::nbsp('');
else
return $plugin->_feature_summary();
}
/**
* Get the summary description
*
* Generally this is used on the invoice summary page
*/
public function summary() {
if (is_null($plugin = $this->plugin()))
return _('Other');
else
return $plugin->_summary();
}
/**
* Return the products for a given category
* @todo This shouldnt be here.
*/
public function category($cat) {
$results = array();
foreach ($this->where('active','=',TRUE)->find_all() as $po) {
if ($c = unserialize($po->avail_category_id) AND in_array($cat,$c))
array_push($results,$po);
}
return $results;
} }
/** /**
@ -155,5 +111,20 @@ class Model_Product extends ORMOSB {
// @todo Change the ALT to the product name. // @todo Change the ALT to the product name.
echo HTML::image($thumb,array('alt'=>_('Thumb Nail'))); echo HTML::image($thumb,array('alt'=>_('Thumb Nail')));
} }
/**
* Return the products for a given category
* @todo This shouldnt be here.
*/
public function list_category($cat) {
$results = array();
foreach ($this->where('active','=',TRUE)->find_all() as $po) {
if ($c = unserialize($po->avail_category_id) AND in_array($cat,$c))
array_push($results,$po);
}
return $results;
}
} }
?> ?>

View File

@ -16,5 +16,14 @@ class Model_Product_Category extends ORMOSB {
protected $_sorting = array( protected $_sorting = array(
'name'=>'asc', 'name'=>'asc',
); );
public function list_bylistgroup($cat) {
$result = array();
foreach ($this->where('list_group','=',$cat)->find_all() as $pco)
$result[$pco->id] = $pco;
return $result;
}
} }
?> ?>

Some files were not shown because too many files have changed in this diff Show More