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

@@ -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,257 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB Auth driver.
*
* @package OSB
* @subpackage Account
* @category Auth
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Auth_OSB extends Auth_ORM {
/**
* OSB authentication is controlled via database queries.
*
* This method can be used to test two situations:
* 1) Is the user logged in? ($role == FALSE)
* 2) Can the user run the current controller->action ($role == TRUE)
*
* @param boolean If authentication should be done for this module:method (ie: controller:action).
* @return boolean
*/
public function logged_in($role = NULL, $debug = NULL) {
$status = FALSE;
// Get the user from the session
$user = $this->get_user(FALSE);
// If we are not a valid user object, then we are not logged in
if (is_object($user) AND $user instanceof Model_Account AND $user->loaded()) {
if (Config::sitemode() == Kohana::DEVELOPMENT && Kohana::config('config.site_debug'))
SystemMessage::add(array('title'=>'Debug','type'=>'debug','body'=>Kohana::debug(array('user'=>$user->username,'r'=>$role))));
if (! empty($role)) {
// Get the module details
$mo = ORM::factory('module',array('name'=>Request::current()->controller()));
if (! $mo->loaded() OR ! $mo->status) {
SystemMessage::add(array(
'title'=>'Module is not defined or active in the Database',
'type'=>'warning',
'body'=>sprintf('Module not defined: %s',Request::current()->controller()),
));
} else {
if (Request::current()->directory())
$method_name = sprintf('%s_%s',Request::current()->directory(),Request::current()->action());
else
$method_name = Request::current()->action();
// Get the method number
$mmo = ORM::factory('module_method',array('module_id'=>$mo->id,'name'=>$method_name));
if (! $mmo->loaded()) {
SystemMessage::add(array(
'title'=>'Method is not defined or active in the Database',
'type'=>'warning',
'body'=>sprintf('Method not defined: %s for %s',Request::current()->action(),$mo->name),
));
} else {
// If the role has the authorisation to run the method
$gmo = ORM::factory('group_method')
->where('method_id','=',$mmo->id);
$roles = '';
foreach ($gmo->find_all() as $gm) {
$roles .= ($roles ? '|' : '').$gm->group->name;
// $gm->group->id == 0 means all users.
if ($gm->group->id == 0 OR $user->has_any('group',$gm->group->list_childgrps(TRUE))) {
$status = TRUE;
$roles = '';
break;
}
}
if (! $status) {
if (Config::sitemode() == Kohana::DEVELOPMENT)
SystemMessage::add(array(
'title'=>'User is not authorised in Database',
'type'=>'debug',
'body'=>sprintf('Role(s) checked: %s<br/>User: %s</br>Module: %s<br/>Method: %s',$roles,$user->username,$mo->name,$mmo->name),
));
}
}
}
if (Config::sitemode() == Kohana::DEVELOPMENT)
SystemMessage::add(array(
'title'=>'Debug',
'type'=>'debug',
'body'=>sprintf('A-User: <b>%s</b>, Module: <b>%s</b>, Method: <b>%s</b>, Role: <b>%s</b>, Status: <b>%s</b>, Data: <b>%s</b>',
$user->username,Request::current()->controller(),Request::current()->action(),$role,$status,$debug)));
// There is no role, so the method should be allowed to run as anonymous
} else {
if (Config::sitemode() == Kohana::DEVELOPMENT)
SystemMessage::add(array(
'title'=>'Debug',
'type'=>'debug',
'body'=>sprintf('B-User: <b>%s</b>, Module: <b>%s</b>, Method: <b>%s</b>, Status: <b>%s</b>, Data: <b>%s</b>',
$user->username,Request::current()->controller(),Request::current()->action(),'No Role Default Access',$debug)));
$status = TRUE;
}
// Check and see if we have a token to login and run the method
} elseif ((! empty($_REQUEST['token']) AND $token = $_REQUEST['token']) OR $token=Session::instance()->get('token')) {
if ($user=$this->_get_token_user($token) AND $user !== FALSE)
$status = TRUE;
} else {
if (Config::sitemode() == Kohana::DEVELOPMENT)
SystemMessage::add(array('title'=>'Debug','type'=>'debug','body'=>'No user logged in'));
}
return $status;
}
/**
* Gets the currently logged in user from the session.
* Returns FALSE if no user is currently logged in.
*
* @param boolean Check token users too
* @return mixed
*/
public function get_user($tokenuser=TRUE) {
$user = parent::get_user();
// If we are not logged in, see if there is token for the usre
if ($tokenuser AND $user === FALSE AND $token=Session::instance()->get('token')) {
$user = $this->_get_token_user($token);
}
return $user;
}
/**
* Get the user that a token applies to
*
* This will check that the token is valid (not expired and for the request)
*
* @param $token The token
* @return mixed The user
*/
private function _get_token_user($token) {
$mmto = ORM::factory('module_method_token',array('token'=>$token));
$user = FALSE;
if ($mmto->loaded()) {
if ($mmto->date_expire < time()) {
SystemMessage::add(array(
'title'=>_('Token Not Valid'),
'type'=>'warning',
'body'=>_('Token expired')));
Session::instance()->delete('token');
$mmto->delete();
} else {
// Check that the token is for this URI
$mo = ORM::factory('module',array('name'=>Request::current()->controller()));
$mmo = ORM::factory('module_method',
array('name'=>Request::current()->directory() ? sprintf('%s_%s',Request::current()->directory(),Request::current()->action()) : Request::current()->action()));
// Ignore the token if this is not the right method.
if ($mmo->id == $mmto->method_id) {
// @todo Implement single use tokens
Session::instance()->set('token',$token);
$user = ORM::factory('account',$mmto->account_id);
}
}
}
return $user;
}
/**
* Logs a user in.
*
* @param string username
* @param string password
* @param boolean enable autologin
* @return boolean
*/
protected function _login($user, $password, $remember)
{
if ( ! is_object($user))
{
$username = $user;
// Load the user
$user = ORM::factory('account');
$user->where($user->unique_key($username), '=', $username)->find();
}
// If the passwords match, perform a login
if ($user->status AND $user->has_any('group',ORM::factory('group',array('name'=>'Registered Users'))->list_childgrps(TRUE)) AND $user->password === $password)
{
if ($remember === TRUE)
{
// Create a new autologin token
$token = ORM::factory('user_token');
// Set token data
$token->user_id = $user->id;
$token->expires = time() + $this->_config['lifetime'];
$token->save();
// Set the autologin cookie
Cookie::set('authautologin', $token->token, $this->_config['lifetime']);
}
// Record our session ID, we may need to update our DB when we get a new ID
$oldsess = session_id();
// Finish the login
$this->complete_login($user);
// Do we need to update databases with our new sesion ID
// @todo figure out where this is best to go
$session_change_trigger = array('cart'=>'session_id');
if (count($session_change_trigger) AND (session_id() != $oldsess)) {
foreach ($session_change_trigger as $t => $c) {
$orm = ORM::factory($t)
->where($c,'=',$oldsess);
// @todo There must be a way that ORM can update multiple records with 1 SQL
foreach ($orm->find_all() as $o)
$o->set('session_id',session_id())
->update();
}
}
return TRUE;
}
// Login failed
return FALSE;
}
/**
* Determine if a user is authorised to view an account
*
* @param integer Account ID
*
* @return boolean TRUE if authorised, FALSE if not.
*/
public function authorised($aid,$afid=NULL) {
return (($ao = $this->get_user()) AND $ao->loaded() AND ($aid == $ao->id OR $ao->isAdmin() OR (! is_null($afid) AND $afid == $ao->affiliate->id))) ? TRUE : FALSE;
}
}
?>

View File

@@ -1,111 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides User Account Update functions
*
* @package OSB
* @subpackage Account
* @category Controllers/User
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Controller_User_Account extends Controller_TemplateDefault_User {
protected $secure_actions = array(
'edit'=>TRUE,
'resetpassword'=>TRUE,
);
public function action_resetpassword() {
// @todo Fix this next logic, since matches_ifset is not being called when the value is on the form, but empty
if (empty($_POST['password_confirm']))
$_POST['password_confirm'] = ' ';
// Store our new values
$this->ao->values($_POST);
// Run validation and save
if ($this->ao->changed())
if ($this->ao->check()) {
SystemMessage::add(array(
'title'=>_('Record updated'),
'type'=>'info',
'body'=>_('Your account record has been updated.')
));
$this->ao->save();
// Log the password reset
$this->ao->log('Password reset');
Request::current()->redirect('login');
} else {
$output = '';
foreach ($this->ao->validation()->errors('forms/login') as $field => $error)
$output .= sprintf('<li><b>%s</b> %s</li>',$field,$error);
if ($output)
$output = sprintf('<ul>%s</ul>',$output);
SystemMessage::add(array(
'title'=>_('Record NOT updated'),
'type'=>'error',
'body'=>_('Your updates didnt pass validation.').'<br/>'.$output,
));
}
else
SystemMessage::add(array(
'title'=>_('Record NOT updated'),
'type'=>'info',
'body'=>_('Your account has NOT been updated.')
));
Block::add(array(
'title'=>_('Password Reset'),
'body'=>View::factory('account/password_reset')
->set('record',$this->ao),
));
}
/**
* Show a product
*/
public function action_edit() {
// Store our new values
$this->ao->values($_POST);
// Run validation and save
if ($this->ao->changed())
if ($this->ao->check()) {
SystemMessage::add(array(
'title'=>_('Record updated'),
'type'=>'info',
'body'=>_('Your account record has been updated.')
));
$this->ao->save();
} else {
$output = '';
foreach ($this->ao->validation()->errors('forms/login') as $field => $error)
$output .= sprintf('<li><b>%s</b> %s</li>',$field,$error);
if ($output)
$output = sprintf('<ul>%s</ul>',$output);
SystemMessage::add(array(
'title'=>_('Record NOT updated'),
'type'=>'error',
'body'=>_('Your updates didnt pass validation.').'<br/>'.$output,
));
}
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Account Edit'),$this->ao->accnum(),$this->ao->name(TRUE)),
'body'=>View::factory('account/user/edit')
->set('record',$this->ao),
));
}
}
?>

View File

@@ -1,127 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* @package lnApp
* @subpackage Auth
* @category Models
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Account extends Model_Auth_UserDefault {
// Relationships
protected $_has_many = array(
'user_tokens' => array('model' => 'user_token'),
'email_log' => array('far_key'=>'id'),
'group' => array('through' => 'account_group'),
'invoice' => array('far_key'=>'id'),
'payment'=>array('far_key'=>'id'),
'service' => array('far_key'=>'id'),
);
protected $_has_one = array(
'affiliate' => array('far_key'=>'id'),
);
protected $_display_filters = array(
'date_orig'=>array(
array('Config::date',array(':value')),
),
'date_last'=>array(
array('Config::date',array(':value')),
),
'status'=>array(
array('StaticList_YesNo::display',array(':value')),
),
);
/**
* Return an account name
*/
public function name($withcompany=FALSE) {
if ($withcompany)
return sprintf('%s %s (%s)',$this->first_name,$this->last_name,$this->company);
else
return sprintf('%s %s',$this->first_name,$this->last_name);
}
public function accnum() {
return sprintf('%02s-%04s',Config::siteid(),$this->id);
}
public function title($name) {
return StaticList_Title::form($name,$this->title);
}
public function currency($name) {
return StaticListModule::form($name,'currency',$this->currency_id,'id','name',array());
}
public function country($name) {
return StaticListModule::form($name,'country',$this->country_id,'id','name',array());
}
public function language($name) {
// @todo To setup
return 'en';
}
/**
* Get the groups that an account belongs to
*/
public function groups() {
return $this->group->find_all();
}
public function isAdmin() {
// @todo Define admins in the config file or DB
$admins = array(ORM::factory('group',array('name'=>'Root')));
return $this->has('group',$admins);
}
/**
* Get a list of all invoices for this account
*/
public function invoices() {
return $this->invoice->distinct('id')->find_all();
}
/**
* Get a list of due invoices for this account
*
* @param int Date (in secs) to only retrieve invoices prior to this date
*/
public function invoices_due($date=NULL) {
$return = array();
foreach ($this->invoices() as $io)
if ((is_null($date) OR $io->date_orig < $date) AND $io->due())
$return[$io->id] = $io;
return $return;
}
/**
* Calculate the total of invoices due for this account
*/
public function invoices_due_total($date=NULL,$format=FALSE) {
$result = 0;
foreach ($this->invoices_due($date) as $io)
$result += $io->due();
return $format ? Currency::display($result) : $result;
}
public function log($message) {
// Log the logout
$alo = ORM::factory('account_log');
$alo->account_id = $this->id;
$alo->ip = $_SERVER['REMOTE_ADDR'];
$alo->details = $message;
$alo->save();
return $alo->saved();
}
}
?>

View File

@@ -1,13 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* @package lnApp
* @subpackage Auth
* @category Models
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Auth_RoleDefault extends Model_Auth_Role {
}
?>

View File

@@ -1,83 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* @package lnApp
* @subpackage Auth
* @category Models
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Auth_UserDefault extends Model_Auth_User {
// Validation rules
public function rules() {
return array(
'username' => array(
array('not_empty'),
array('min_length', array(':value', 4)),
array('max_length', array(':value', 32)),
),
'password' => array(
array('not_empty'),
array('min_length', array(':value', 5)),
array('max_length', array(':value', 32)),
),
'email' => array(
array('not_empty'),
array('min_length', array(':value', 4)),
array('max_length', array(':value', 127)),
array('email'),
),
// @todo To test
'password_confirm' => array(
array('matches_ifset', array(':validation', 'password', 'password_confirm')),
),
);
}
// Validation callbacks
// @todo _callbacks no longer used
protected $_callbacks = array(
'username' => array('username_available'),
'email' => array('email_available'),
);
// Columns to ignore
protected $_ignored_columns = array('password_confirm');
/*
* Complete our login
*
* For some database logins, we may not want to record the user last login
* details in the repository, so we just override that parent function
* here.
*
* We can also do some other post-login actions here.
* @todo Maybe we can do our session update here.
*/
public function complete_login() {
return $this->log('Logged In');
}
/**
* Test to see if a record has been changed
*/
public function changed() {
return ! (empty($this->_changed));
}
/**
* Debug function to see that has() finds
* @todo This function could be removed
*/
public function has_list($alias, $model) {
// Return list of matches
return DB::select()
->from($this->_has_many[$alias]['through'])
->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk())
->where($this->_has_many[$alias]['far_key'], '=', $model->pk())
->execute($this->_db)
->as_array();
}
}
?>

View File

@@ -1,17 +0,0 @@
<!-- @todo NEEDS TO BE TRANSLATED -->
<br/>
<?php echo Form::open(); ?>
<table class="box-center">
<tr>
<td class="head">Password</td>
<td><input type="password" name="password" value=""/></td>
</tr>
<tr>
<td class="head">Confirm Password</td>
<td><input type="password" name="password_confirm" value=""/></td>
</tr>
<tr>
<td colspan="2" style="text-align: center;"><?php echo Form::submit('update','Update',array('class'=>'form_button')); ?></td>
</tr>
</table>
<?php echo Form::close(); ?>

View File

@@ -1,84 +0,0 @@
<!-- @todo NEEDS TO BE TRANSLATED -->
<?php echo Form::open(); ?>
<table class="box-center">
<tr>
<td class="head">Last Updated</td>
<td><?php echo $record->display('date_last'); ?></td>
</tr>
<tr>
<td class="head">User Name</td>
<td><b><?php echo $record->username; ?></b></td>
</tr>
<!-- //@todo This needs to be done somewhere else
<tr>
<td class="head">Password</td>
<td><input type="password" name="password" value=""/></td>
</tr>
<tr>
<td class="head">Confirm Password</td>
<td><input type="password" name="confirm_password" value=""/></td>
</tr>
-->
<tr>
<td class="head">Email</td>
<td><input type="text" name="email" value="<?php echo $record->email; ?>"/></td>
</tr>
<tr>
<td class="head">Company</td>
<td><input type="text" name="company" value="<?php echo $record->company; ?>"/></td>
</tr>
<tr>
<td class="head">First Name</td>
<td><input type="text" name="first_name" value="<?php echo $record->first_name; ?>"/></td>
</tr>
<tr>
<td class="head">Last Name</td>
<td><input type="text" name="last_name" value="<?php echo $record->last_name; ?>"/></td>
</tr>
<tr>
<td class="head">Title</td>
<td><?php echo $record->title('title'); ?></td>
</tr>
<tr>
<td class="head">Address</td>
<td><input type="text" name="address1" value="<?php echo $record->address1; ?>"/></td>
</tr>
<tr>
<td class="head">&nbsp;</td>
<td><input type="text" name="address2" value="<?php echo $record->address2; ?>"/></td>
</tr>
<tr>
<td class="head">City</td>
<td><input type="text" name="city" value="<?php echo $record->city; ?>"/></td>
</tr>
<tr>
<td class="head">State</td>
<td><input type="text" name="state" value="<?php echo $record->state; ?>"/></td>
</tr>
<tr>
<td class="head">Postal Code</td>
<td><input type="text" name="zip" value="<?php echo $record->zip; ?>"/></td>
</tr>
<tr>
<td class="head">Country</td>
<td><?php echo $record->country('country'); ?></td>
</tr>
<tr>
<td class="head">Language</td>
<td><?php echo $record->language('language_id'); ?></td>
</tr>
<tr>
<td class="head">Currency</td>
<td><?php echo $record->currency('currency_id'); ?></td>
</tr>
<tr>
<!-- @todo NEEDS TO BE CONFIGURABLE -->
<td class="head">HTML Email</td>
<td>Yes</td>
</tr>
<!-- @todo OTHER STATIC VARS -->
<tr>
<td colspan="2" style="text-align: center;"><?php echo Form::submit('update','Update',array('class'=>'form_button')); ?></td>
</tr>
</table>
<?php echo Form::close(); ?>

View File

@@ -1,135 +0,0 @@
<br/>
<?php echo Form::open(); ?>
<table class="login">
<tr>
<td>User Name</td>
<td><?php echo Form::input('username',$account->username,
array('id'=>'login-uid','size'=>40,'class'=>(array_key_exists('username',$errors) ? 'error' : 'ok'))); ?></td>
</tr>
<tr>
<td>Password</td>
<td><?php echo Form::password('password',null,array('id'=>'login-pwd','size'=>16));?></td>
</tr>
<tr>
<td>Confirm Password</td>
<td><?php echo Form::password('password_confirm',null,array('id'=>'login-pwd-confirm','size'=>16));?></td>
</tr>
<tr>
<td>Email Address</td>
<td><?php echo Form::input('email',$account->email,array('size'=>40));?></td>
</tr>
<tr>
<td>Company</td>
<td><?php echo Form::input('company',$account->company,array('size'=>40));?></td>
</tr>
<tr>
<td>First Name</td>
<td><?php echo Form::input('first_name',$account->first_name,array('size'=>40));?></td>
</tr>
<tr>
<td>Last Name</td>
<td><?php echo Form::input('last_name',$account->last_name,array('size'=>40));?></td>
</tr>
<tr>
<td>Title</td>
<td><?php echo StaticList_Title::form('title',$account->title);?></td>
</tr>
<tr>
<td>Address Line 1</td>
<td><?php echo Form::input('address1',$account->address1,array('size'=>40));?></td>
</tr>
<tr>
<td>Address Line 2</td>
<td><?php echo Form::input('address2',$account->address2,array('size'=>40));?></td>
</tr>
<tr>
<td>City</td>
<td><?php echo Form::input('city',$account->city,array('size'=>40));?></td>
</tr>
<tr>
<td>State</td>
<td><?php echo Form::input('state',$account->state,array('size'=>20));?></td>
</tr>
<tr>
<td>Post Code</td>
<td><?php echo Form::input('zip',$account->zip,array('size'=>20));?></td>
</tr>
<tr>
<td>Country</td>
<!-- @todo - our default currency should be defined in a config -->
<td><?php echo StaticList_Module::form('country_id','country',61,'id','name',array());?></td>
<!--
{if $VAR.account_country_id != ''}
{$list->menu('no','account_country_id','country','name',$VAR.account_country_id,'form_field" onchange="taxIdsDisplay(this.value)',true)}
{else}
{$list->menu('no','account_country_id','country','name',$smarty.const.DEFAULT_COUNTRY,'form_field" onchange="taxIdsDisplay(this.value)',true)}
{/if}
{$method->exe_noauth('tax','get_tax_ids')}
{if $tax_ids}
<script type="text/javascript" language="javascript">
{if $VAR.account_country_id != ""}
var countryId='{$VAR.account_country_id}';
{else}
var countryId='{$smarty.const.DEFAULT_COUNTRY}';
{/if}
{literal}
function taxIdsDisplay(id) {
try{ document.getElementById('tax_country_id_'+id).style.display='block'; } catch(e) {}
try{ document.getElementById('tax_country_id_'+countryId).style.display='none'; } catch(e) {}
countryId=id;
}
{/literal}
</script>
</td>
</tr>
{foreach from=$tax_ids item=tax}
<tr valign="top" id="tax_country_id_{$tax.country_id}" {if $VAR.account_country_id !=''}{if $VAR.account_country_id!=$tax.country_id}{osb f=style_hide}{/if}{else}{if $smarty.const.DEFAULT_COUNTRY!=$tax.country_id}{osb f=style_hide}{/if}{/if}>
<td width="29%">{$tax.tax_id_name}</td>
<td width="71%">
<input type="text" name="account_tax_id[{$tax.country_id}]" value="{$VAR.account_tax_id[$tax.country_id]}" {if $account_tax_id == true}class="form_field_error"{/if}/>
<!-* {if $tax.tax_id_exempt}
(or) exempt
<input type="checkbox" name="account_tax_id_exempt[{$tax.country_id}]" value="1"/>
{/if} -*>
{/foreach}
{/if}
</td>
-->
</tr>
<!--
{$method->exe('account','static_var')}
{foreach from=$static_var item=record}
<tr valign="top">
<td>{$record.name}</td>
<td>{$record.html}</td>
</tr>
{/foreach}
-->
<!--
{if $smarty.const.NEWSLETTER_REGISTRATION == "1"}
<tr valign="top">
<td>{t module=account}subscribe_newsletters{/t}</td>
<td>{$method->exe('newsletter','check_list_registration')}</td>
</tr>
{/if}
-->
<tr>
<td>Use HTML for Email</td>
<!-- // @todo default should be specified in a global confi -->
<td><?php echo StaticList_YesNo::form('email_type',true); ?></td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2" style="text-align: center;"><?php echo Form::submit('submit',_('Register'),array('class'=>'form_button'));?></td></tr>
</table>
<?php echo Form::close(); ?>
<!-- @todo The following focus() is not ajax/jscript friendly -->
<!-- @todo Provide field validation highlighting -->
<!-- @todo Add javascript to stop submission when password fields dont match -->
<script type="text/javascript">document.getElementById('login-uid').focus();</script>

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 {
// Relationships
// @todo This model should probably be joined with product_plugin_adsl
protected $_belongs_to = array(
'adsl_supplier_plan'=>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(
'Tax::add'=>array(),
'Currency::display'=>array(),
array('Tax::add',array(':value')),
array('Currency::display',array(':value')),
),
'extra_down_offpeak'=>array(
'Tax::add'=>array(),
'Currency::display'=>array(),
array('Tax::add',array(':value')),
array('Currency::display',array(':value')),
),
'extra_up_peak'=>array(
'Tax::add'=>array(),
'Currency::display'=>array(),
array('Tax::add',array(':value')),
array('Currency::display',array(':value')),
),
'extra_up_offpeak'=>array(
'Tax::add'=>array(),
'Currency::display'=>array(),
array('Tax::add',array(':value')),
array('Currency::display',array(':value')),
),
);
}

View File

@@ -27,13 +27,16 @@ class Model_ADSL_Supplier extends ORMOSB {
$services = array();
// 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)
// Find all the plan who use this supplier plan
foreach ($aspo->adsl_plan->find_all() as $apo)
// Find all the services who use this plan
foreach ($apo->service->find_all() as $so)
if (! $active OR $so->active)
array_push($services,$so);
// Find all the products who use this plan
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)
array_push($services,$so);
return $services;
}

View File

@@ -10,22 +10,42 @@
* @copyright (c) 2010 Open Source Billing
* @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 $_updated_column = FALSE;
// Relationships
protected $_belongs_to = array(
'adsl_plan'=>array('foreign_key'=>'adsl_plan_id'),
'service'=>array(),
);
protected $_has_one = array(
'adsl_plan'=>array('far_key'=>'provided_adsl_plan_id','foreign_key'=>'id'),
);
protected $_display_filters = array(
'service_connect_date'=>array(
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
*/
@@ -91,7 +111,7 @@ class Model_Service_ADSL extends Model_Service {
$return = array();
$to = ORM::factory('service_adsl_traffic')
$to = ORM::factory('service_plugin_adsl_traffic')
->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',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) {
// Roll up the charges according to the configuration
$data = ADSL::allowance(array(
'base_down_peak'=>is_null($this->adsl_plan->base_down_peak) ? NULL : $traffic->down_peak,
'base_down_offpeak'=>is_null($this->adsl_plan->base_down_offpeak) ? NULL : $traffic->down_offpeak,
'base_up_peak'=>is_null($this->adsl_plan->base_up_peak) ? NULL : $traffic->up_peak,
'base_up_offpeak'=>is_null($this->adsl_plan->base_up_offpeak) ? NULL : $traffic->up_offpeak,
'extra_down_peak'=>$this->adsl_plan->extra_down_peak,
'extra_down_offpeak'=>$this->adsl_plan->extra_down_offpeak,
'extra_up_peak'=>$this->adsl_plan->extra_up_peak,
'extra_up_offpeak'=>$this->adsl_plan->extra_up_offpeak,
'base_down_peak'=>is_null($this->service->product->plugin()->base_down_peak) ? NULL : $traffic->down_peak,
'base_down_offpeak'=>is_null($this->service->product->plugin()->base_down_offpeak) ? NULL : $traffic->down_offpeak,
'base_up_peak'=>is_null($this->service->product->plugin()->base_up_peak) ? NULL : $traffic->up_peak,
'base_up_offpeak'=>is_null($this->service->product->plugin()->base_up_offpeak) ? NULL : $traffic->up_offpeak,
'extra_down_peak'=>$this->service->product->plugin()->extra_down_peak,
'extra_down_offpeak'=>$this->service->product->plugin()->extra_down_offpeak,
'extra_up_peak'=>$this->service->product->plugin()->extra_up_peak,
'extra_up_offpeak'=>$this->service->product->plugin()->extra_up_offpeak,
));
$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
*/
public function get_traffic_data_monthly($period=NULL,$bydate=FALSE) {
$cacheable = FALSE;
$cacheable = TRUE;
if (is_null($period))
$period = strtotime('yesterday');
@@ -140,7 +160,7 @@ class Model_Service_ADSL extends Model_Service {
$return = array();
$to = ORM::factory('service_adsl_traffic')
$to = ORM::factory('service_plugin_adsl_traffic')
->select(
array('date_format(date,\'%y-%m\')','month'),
array('sum(up_peak)','up_peak'),
@@ -156,14 +176,14 @@ class Model_Service_ADSL extends Model_Service {
foreach ($to->find_all() as $traffic) {
// Roll up the charges according to the configuration
$data = ADSL::allowance(array(
'base_down_peak'=>is_null($this->adsl_plan->base_down_peak) ? NULL : $traffic->down_peak,
'base_down_offpeak'=>is_null($this->adsl_plan->base_down_offpeak) ? NULL : $traffic->down_offpeak,
'base_up_peak'=>is_null($this->adsl_plan->base_up_peak) ? NULL : $traffic->up_peak,
'base_up_offpeak'=>is_null($this->adsl_plan->base_up_offpeak) ? NULL : $traffic->up_offpeak,
'extra_down_peak'=>$this->adsl_plan->extra_down_peak,
'extra_down_offpeak'=>$this->adsl_plan->extra_down_offpeak,
'extra_up_peak'=>$this->adsl_plan->extra_up_peak,
'extra_up_offpeak'=>$this->adsl_plan->extra_up_offpeak,
'base_down_peak'=>is_null($this->service->product->plugin()->base_down_peak) ? NULL : $traffic->down_peak,
'base_down_offpeak'=>is_null($this->service->product->plugin()->base_down_offpeak) ? NULL : $traffic->down_offpeak,
'base_up_peak'=>is_null($this->service->product->plugin()->base_up_peak) ? NULL : $traffic->up_peak,
'base_up_offpeak'=>is_null($this->service->product->plugin()->base_up_offpeak) ? NULL : $traffic->up_offpeak,
'extra_down_peak'=>$this->service->product->plugin()->extra_down_peak,
'extra_down_offpeak'=>$this->service->product->plugin()->extra_down_offpeak,
'extra_up_peak'=>$this->service->product->plugin()->extra_up_peak,
'extra_up_offpeak'=>$this->service->product->plugin()->extra_up_offpeak,
));
if ($bydate)
@@ -202,12 +222,12 @@ class Model_Service_ADSL extends Model_Service {
foreach ($this->traffic_month($date,FALSE) as $k => $v) {
// We shouldnt need to eval for nulls, since the traffic calc does that
if ($all OR ($v > $this->adsl_plan->$k)) {
$return[$k]['allowance'] = $this->adsl_plan->$k;
if ($all OR ($v > $this->service->product->plugin()->$k)) {
$return[$k]['allowance'] = $this->service->product->plugin()->$k;
$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]['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]['rate'] = $this->adsl_plan->{ADSL::map($k)};
$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->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->service->product->plugin()->{ADSL::map($k)};
$return[$k]['charge'] = ceil(($return[$k]['excess'])/1000)*$return[$k]['rate'];
}
}
@@ -340,31 +360,23 @@ class Model_Service_ADSL extends Model_Service {
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
* For Example: Invoice
*
* @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) {
case 'invoice':
case 'invoice_detail_items':
return array(
_('Service Address')=>$this->display('service_address'),
_('Contract Until')=>$this->contract_date_end(),
);
break;
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) {
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));
}
}

View File

@@ -10,9 +10,10 @@
* @copyright (c) 2010 Open Source Billing
* @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 $_primary_key = 'service';
protected $_disable_wild_select = TRUE;
protected $_created_column = FALSE;
protected $_updated_column = FALSE;

View File

@@ -87,7 +87,7 @@ class Service_Traffic_ADSL {
break;
}
$traffic = ORM::factory('service_adsl_traffic');
$traffic = ORM::factory('service_plugin_adsl_traffic');
foreach ($data as $item) {
$traffic->values($item,array_keys($item));
$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.
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) {
$co = ORM::factory('charge');
@@ -126,7 +126,7 @@ class Service_Traffic_ADSL {
$co->description = _('Excess Traffic');
// @todo This need to be improved = strtotime function should be the one used in the function call
$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('Metric==%s',$metric),
sprintf('Used==%s',$details['used']),
@@ -144,12 +144,12 @@ class Service_Traffic_ADSL {
$et = Email_Template::instance('adsl_traffic_notice');
foreach ($this->so->services() as $so) {
if (! $so->service_adsl->report_traffic())
if (! $so->plugin()->report_traffic())
continue;
// Get our variable data
$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();
}

View File

@@ -39,17 +39,17 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
$update = array();
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
$request = Request::factory($this->so->stats_url)
->method('POST')
->post($this->login_user_field,$so->service_adsl->service_username)
->post($this->login_pass_field,$so->service_adsl->service_password)
->post($this->login_user_field,$so->plugin()->service_username)
->post($this->login_pass_field,$so->plugin()->service_password)
->post('doLogin',1)
->post('submit','Login');
$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();
@@ -57,16 +57,17 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
if (! $data) {
// @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->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;
}
for ($servicedate=date('Y-m-d',strtotime($this->so->stats_lastupdate.'+1 day'));
$servicedate <= $this->today;
$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'))));
if (strtotime($lastday) > time())
@@ -84,16 +85,16 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
->post('do_usage_search',1);
$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();
$result = $response->body();
$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 {
$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();
@@ -103,7 +104,7 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
if (! preg_match('/^Usage Detail/',$fieldset->find('legend',0)->plaintext))
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 ($values->children() as $a => $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 'Download': $header[$a] = 'down_peak'; break;
case 'Duration': break;
case 'Total': break;
default:
printf('Unkown header :%s',$b->plaintext);
$this->fetchresult = FALSE;
@@ -137,27 +139,28 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
#echo "VALUES: ".$b->plaintext."\n";
}
}
#print_r($data);
if (isset($data['date']) && preg_match('/^[0-9]{4}/',$data['date'])) {
$sdate = date('Y-m-d',strtotime($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)
$update[$so->service_adsl->service_number][$sdate][$key] += $value;
$update[$so->plugin()->service_number][$sdate][$key] += $value;
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->service_adsl->service_number][$sdate]['date'] = $sdate;
$update[$so->plugin()->service_number][$sdate]['service'] = $so->plugin()->service_number;
$update[$so->plugin()->service_number][$sdate]['date'] = $sdate;
}
}
}
}
// If we got here and have data, we had a good fetch, update the stats date
$so->service_adsl->service_stats_lastupdate = $lastday;
$so->service_adsl->save();
$so->plugin()->service_stats_lastupdate = $lastday;
$so->plugin()->save();
}
}

View File

@@ -39,17 +39,17 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL {
$update = array();
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
$request = Request::factory($this->so->stats_url)
->method('POST')
->post($this->login_user_field,$so->service_adsl->service_username)
->post($this->login_pass_field,$so->service_adsl->service_password)
->post($this->login_user_field,$so->plugin()->service_username)
->post($this->login_pass_field,$so->plugin()->service_password)
->post('doLogin',1)
->post('submit','Login');
$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();
@@ -57,10 +57,10 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL {
if (! $data) {
// @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->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;
}
@@ -84,16 +84,16 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL {
->post('do_usage_search',1);
$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();
$result = $response->body();
$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 {
$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();
@@ -141,22 +141,22 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL {
$sdate = date('Y-m-d',strtotime(str_replace('/','-',$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)
$update[$so->service_adsl->service_number][$sdate][$key] += $value;
$update[$so->plugin()->service_number][$sdate][$key] += $value;
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->service_adsl->service_number][$sdate]['date'] = $sdate;
$update[$so->plugin()->service_number][$sdate]['service'] = $so->plugin()->service_number;
$update[$so->plugin()->service_number][$sdate]['date'] = $sdate;
}
}
}
}
// If we got here and have data, we had a good fetch, update the stats date
$so->service_adsl->service_stats_lastupdate = $lastday;
$so->service_adsl->save();
$so->plugin()->service_stats_lastupdate = $lastday;
$so->plugin()->save();
}
}

View File

@@ -29,7 +29,7 @@ class Service_Traffic_ADSL_ExetelVisp extends Service_Traffic_ADSL {
$request->get_client()->options($this->curlopts+array(
CURLOPT_POST => TRUE,
));
));
$response = $request->execute();
$data = $response->body();

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'; ?>">
<td><?php echo $service->service_adsl->display('service_number'); ?></td>
<td><?php echo $service->service_adsl->ipaddress(); ?></td>
<td><?php printf('%s (%s)',$service->name(),$service->id); ?></td>
<td><?php echo $service->plugin()->display('service_number'); ?></td>
<td><?php echo $service->plugin()->ipaddress(); ?></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->service_adsl->traffic_thismonth(); ?></td>
<td><?php echo $service->service_adsl->traffic_lastmonth(); ?></td>
<td><?php echo $service->plugin()->traffic_thismonth(); ?></td>
<td><?php echo $service->plugin()->traffic_lastmonth(); ?></td>
<td><?php echo $service->display('price'); ?></td>
<td><?php echo $service->display('recur_schedule'); ?></td>
<td><?php echo $service->display('date_next_invoice'); ?></td>

View File

@@ -1,13 +1,13 @@
<!-- //@todo To translate -->
<table class="box-full">
<tr>
<td class="head" colspan="2">Service Details</td>
<td class="head" colspan="3">Service Details</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td style="width: 50%">
<td>
<table>
<tr>
<td style="width: 40%;">Service Number</td>
@@ -35,7 +35,7 @@
</tr>
<tr>
<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>
<td>Service IP</td>
@@ -43,21 +43,21 @@
</tr>
</table>
</td>
<td style="width: 50%; vertical-align: top;">
<table width="100%">
<td style="vertical-align: top;" colspan="2">
<table>
<tr>
<td style="width: 40%;">Traffic Used This Month</td>
<td style="width: 60%;" class="data"><?php echo $so->traffic_month(null); ?></td>
</tr>
<tr>
<td style="width: 40%;">Traffic Used Last Month</td>
<td style="width: 60%;" class="data"><?php echo $so->traffic_lastmonth(); ?></td>
<td>Traffic Used Last Month</td>
<td class="data"><?php echo $so->traffic_lastmonth(); ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<td colspan="3">
<table>
<tr>
<td>View Daily Traffic for Month</td>
@@ -67,7 +67,7 @@
</td>
</tr>
<tr>
<td><?php echo $so->graph_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?><td>
<td><?php echo $so->table_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>
</tr>
</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.');
/**
* This class supports OSB Web Hosting
* This class supports affiliates
*
* @package OSB
* @subpackage Product
* @subpackage Affiliate
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_HostServer extends ORMOSB {
protected $_table_name = 'service';
class Model_Affiliate extends ORMOSB {
}
?>

View File

@@ -223,7 +223,7 @@ function sqlConditions($db,$Conditions=false,$Tables=false) {
# Add the SITE ID
if (! is_array($Tables) || count($Tables) == 1) {
if ($Tables == 'setup')
if (in_array($Tables,array('setup','currency','tax')))
$where .= sprintf('id=%s',DEFAULT_SITE);
else
$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) {
return ($number);
if (empty($number))
return 0;
if (empty($currency_id))

View File

@@ -1,21 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Country routines
*
* @package OSB
* @subpackage Cart
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Country {
public static function icon($cid) {
// @todo alt character should be country specific
// @todo This doesnt correctly get the right 3 character country code - it should be obtained from a join with country/currency
return HTML::image(sprintf('media/img/country/%s.gif',StaticList_Module::record('country','two_code','id',$cid)),array('alt'=>'$','style'=>'border: 0px;'));
return sprintf('media/img/country/%s.gif',StaticList_Module::record('country','three_code','id',$cid));
}
}
?>

View File

@@ -1,18 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This is class is for all page attributes.
*
* @package OSB
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Currency {
public static function display($amount) {
// @todo $cid and therefore precision should come from a global session value.
return Num::format($amount,2,TRUE);
}
}
?>

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

@@ -1,23 +1,19 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Account Login Logging
* This class supports Domain TLD
*
* @package OSB
* @subpackage Account
* @subpackage Domains
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Account_Log extends ORMOSB {
protected $_belongs_to = array(
'account'=>array(),
);
class Model_Domain_TLD extends ORMOSB {
protected $_display_filters = array(
'date_orig'=>array(
array('Config::datetime',array(':value')),
'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

@@ -1,84 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* @package lnApp
* @subpackage Auth
* @category Models
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Group extends Model_Auth_RoleDefault {
// Relationships
protected $_has_many = array(
'account'=>array('through'=>'account_group'),
'module_method'=>array('through'=>'group_method','far_key'=>'method_id'),
);
protected $_sorting = array(
'name'=>'ASC',
);
// Validation rules
protected $_rules = array(
'name' => array(
'not_empty' => NULL,
'min_length' => array(4),
'max_length' => array(32),
),
'description' => array(
'max_length' => array(255),
),
);
protected $_display_filters = array(
'status'=>array(
array('StaticList_YesNo::display',array(':value')),
),
);
/**
* This function will, given a group, list all of the children that
* are also related to this group, in the group heirarchy.
*/
public function list_childgrps($incParent=FALSE) {
$return = array();
if (! $this->loaded())
return $return;
foreach (ORM::factory('group')->where('status','=',1)->and_where('parent_id','=',$this)->find_all() as $go) {
array_push($return,$go);
$return = array_merge($return,$go->list_childgrps());
}
if ($incParent)
array_push($return,$this);
return $return;
}
/**
* This function will, given a group, list all of the parent that
* are also related to this group, in the group heirarchy.
*/
public function list_parentgrps($incParent=FALSE) {
$return = array();
if (! $this->loaded())
return $return;
foreach (ORM::factory('group')->where('status','=',1)->and_where('id','=',$this->parent_id)->find_all() as $go) {
array_push($return,$go);
$return = array_merge($return,$go->list_parentgrps());
}
if ($incParent)
array_push($return,$this);
return $return;
}
}
?>

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');
$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 ($io->remind($key) AND (is_null($x=$this->request->param('id')) OR $x != 'again'))
continue;

View File

@@ -170,7 +170,7 @@ class Model_Invoice extends ORMOSB {
foreach ($this->items_main() as $ito) {
$unique = TRUE;
$t = $ito->product->summary();
$t = $ito->product->name();
if (! isset($result[$t])) {
$result[$t]['quantity'] = 0;
$result[$t]['subtotal'] = 0;
@@ -373,29 +373,26 @@ class Model_Invoice extends ORMOSB {
/** 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
*/
private function _list_due($time=NULL,$op='<=') {
public function list_overdue($time=NULL) {
if (is_null($time))
$time = time();
// @todo This rounding should be a system configuration
return $this
->where('round(total_amt-ifnull(credit_amt,0),2)','>','=billed_amt')
->and_where('due_date',$op,$time)
->and_where('status','=',1)
->order_by('due_date,account_id,id')
return $this->_list_due()
->and_where('due_date','<=',$time)
->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
*/
@@ -419,7 +416,15 @@ class Model_Invoice extends ORMOSB {
* Return a list of invoices that are due, excluding overdue.
*/
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)
return;
return $this->service->details('invoice');
return $this->service->details('invoice_detail_items');
}
public function subtotal() {

View File

@@ -36,7 +36,7 @@ class Controller_Product extends Controller_TemplateDefault {
* Obtain a list of pages in a category
*/
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
protected $_has_many = array(
'product_translate'=>array('far_key'=>'id'),
'service'=>array('far_key'=>'id'),
);
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
*/
@@ -52,8 +38,7 @@ class Model_Product extends ORMOSB {
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));
$spn = sprintf('%s_%s',get_class($this),$this->prod_plugin_file);
return new $spn($this->prod_plugin_data);
return ORM::factory(sprintf('product_plugin_%s',$this->prod_plugin_file),$this->prod_plugin_data);
}
/**
@@ -67,36 +52,7 @@ class Model_Product extends ORMOSB {
* This will render the product feature summary information
*/
public function feature_summary() {
if (is_null($plugin = $this->plugin()))
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;
return (is_null($plugin = $this->plugin())) ? HTML::nbsp('') : $plugin->feature_summary();
}
/**
@@ -155,5 +111,20 @@ class Model_Product extends ORMOSB {
// @todo Change the ALT to the product name.
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(
'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;
}
}
?>

View File

@@ -0,0 +1,23 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Product Plugins.
*
* @package OSB
* @subpackage Product/Plugin
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
abstract class Model_Product_Plugin extends ORMOSB {
// Reset any sorting that may be defined in our parent
protected $_sorting = array();
/**
* The feature summary should be implemented in plugins.
* It is displayed on the product overview page, as a summary of the products features.
*/
abstract public function feature_summary();
}
?>

View File

@@ -10,11 +10,11 @@
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Product_ADSL extends Model_Product {
class Model_Product_Plugin_ADSL extends Model_Product_Plugin {
protected $_table_name = 'adsl_plan';
protected $_primary_key = 'id';
protected $_sorting = array(
protected $_belongs_to = array(
'adsl_supplier_plan'=>array(),
);
protected $_display_filters = array(
@@ -28,15 +28,13 @@ class Model_Product_ADSL extends Model_Product {
),
);
protected function _feature_summary() {
return View::factory('product/adsl/feature_summary')
// Our required abstract methods
public function feature_summary() {
// @todo This view should render based on the the results of this::allowance();
return View::factory('product/plugin/adsl/feature_summary')
->set('po',$this);
}
protected function _summary() {
return sprintf('%s: %s %s','ADSL Services',$this->speed,$this->allowance(TRUE));
}
/**
* Show the ADSL allowance as a peak/offpeak metric
*/

View File

@@ -0,0 +1,41 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports DOMAIN products
*
* @package OSB
* @subpackage Product/Domain
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Product_Plugin_Domain extends Model_Product_Plugin {
// This model doesnt have a database table
public function __construct() {
}
// Our required abstract methods
public function feature_summary() {}
// @todo This is not used, but should be.
public function order_features() {
$output = '';
$t = ORM::factory('domain_tld');
// @todo Change this to a view.
$output = sprintf('<table class="box-full"><tr class="head"><td>%s</td></tr><tr><td>',_('Domains are available with the following suffixes'));
$output .= Table::display(
$t->where('status','=','1')->find_all(),
25,
array(
'display("name")'=>array('label'=>'TLD Suffix'),
),
array(
));
$output .= '</td></tr></table>';
return $output;
}
}
?>

View File

@@ -0,0 +1,25 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Host products
*
* @package OSB
* @subpackage Product/Host
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Product_Plugin_Host extends Model_Product_Plugin {
// @todo This model doesnt have a database table
public function __construct() {
}
// Our required abstract methods
public function feature_summary() {}
// @todo This is not used, but should be.
public function order_features() {
}
}
?>

View File

@@ -42,6 +42,13 @@ echo Form::open('cart/add');
echo '<td style="vertical-align: top;">'.$pio->contract_view($record->prod_plugin_data,$record->price_base,$record->price_setup).'</td>';
} ?>
</tr>
<tr>
<?php if ($record->prod_plugin && method_exists($record->prod_plugin_file,'feature_summary')) {
// @todo This doesnt work, it needs to be product_plugin_xx class
$pio = new $record->prod_plugin_file;
echo '<td style="vertical-align: top;">'.$pio->feature_summary().'</td>';
} ?>
</tr>
<tr>
<td class="spacer" colspan="2">&nbsp;</td>
</tr>
@@ -77,7 +84,16 @@ echo Form::open('cart/add');
</td>
</tr>
<tr>
<td style="text-align: center;"><?php echo Form::submit('submit','Add to Cart',array('class'=>'form_button')); ?> | <?php echo Form::submit('submit','Add to Cart & Checkout',array('disabled'=>'disabled'),array('class'=>'form_button')); ?></td>
<td class="spacer" colspan="2">&nbsp;</td>
</tr>
<tr>
<?php if ($record->prod_plugin && method_exists($record->prod_plugin_file,'product_cart')) {
$pio = new $record->prod_plugin_file;
echo '<td style="vertical-align: top;">'.$pio->product_cart($record->prod_plugin_data).'</td>';
} ?>
</tr>
<tr>
<td style="text-align: center;"><?php echo Form::submit('submit','Add to Cart',array('class'=>'form_button','disabled'=>'disabled')); ?> | <?php echo Form::submit('submit','Add to Cart & Checkout',array('disabled'=>'disabled'),array('class'=>'form_button')); ?></td>
</tr>
</table>
</td>

View File

@@ -1,7 +1,7 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides OSB service admin capabilities.
* This class provides Admin Service functions
*
* @package OSB
* @subpackage Service
@@ -11,13 +11,13 @@
* @license http://dev.osbill.net/license.html
*/
class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
protected $control = array('Services'=>'services');
protected $secure_actions = array(
'list'=>TRUE,
'listbycheckout'=>TRUE,
'listadslbilling'=>TRUE,
'listadslservices'=>TRUE,
'listdomainservices'=>TRUE,
'listhostservices'=>TRUE,
'listhspaservices'=>TRUE,
'update'=>TRUE,
);
@@ -26,17 +26,14 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
* Show a list of services
*/
public function action_list() {
$so = ORM::factory('service');
Block::add(array(
'title'=>_('System Customer Services'),
'title'=>_('Customer Services'),
'body'=>Table::display(
$so->find_all(),
ORM::factory('service')->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
'type'=>array('label'=>'Type'),
'name()'=>array('label'=>'Details'),
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price'=>array('label'=>'Price','class'=>'right'),
'active'=>array('label'=>'Active'),
@@ -46,7 +43,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/email/view',
'form'=>'user/service/view',
)),
));
}
@@ -124,181 +121,163 @@ ORDER BY c.id,s.recur_schedule,c.name,a.company,a.last_name,a.first_name
));
}
//@todo this should really be in a different class, since adsl wont be part of the main app
public function action_listadslservices() {
// @todo need to add the DB prefix here
$services = DB::query(Database::SELECT,'
SELECT A.service_id
FROM ab_service__adsl A,ab_service B,ab_account C,ab_service D,ab_product E
WHERE B.active=1 AND A.service_id=B.id AND A.site_id=B.site_id
AND B.account_id=C.id AND B.site_id=C.site_id
AND A.service_id=D.id AND A.site_id=D.site_id
AND D.product_id=E.id AND D.site_id=E.site_id
AND E.sku like "%ADSL%"
ORDER BY C.last_name,B.account_id,A.service_number
')
->execute();
private function consoltraffic($svs,$date) {
$data = array();
// @todo If no items, show a nice message. This is not correct for ORM.
if (! count($services)) {
echo Kohana::debug('No services for ADSL');
die();
}
foreach ($svs as $so) {
$c = array();
foreach ($so->plugin()->get_traffic_data_monthly($date) as $metric => $ma) {
foreach ($ma as $month => $traffic) {
// Only count the service once, not for each metric.
if (! isset($c[$month])) {
if (isset($data['svs'][$month]))
$data['svs'][$month] += 1;
else
$data['svs'][$month] = 1;
$last_account = '';
$i = 0;
$output = '<table class="box-left">';
foreach ($services as $service) {
$so = ORM::factory('service',$service['service_id']);
$c[$month] = 1;
}
if ($last_account != $so->account_id) {
if ($i)
$output .= '<tr><td colspan="10">&nbsp;</td></tr>';
$output .= View::factory('service/admin/list/adslservices_header')
->set('service',$so);
$last_account = $so->account_id;
if (isset($data['data'][$metric][$month]))
$data['data'][$metric][$month] += (int)$traffic;
else
$data['data'][$metric][$month] = (int)$traffic;
}
}
$output .= View::factory('service/admin/list/adslservices_body')
->set('service',$so)
->set('i',$i++%2);
}
$output .= '</table>';
// Chart the traffic for the last 12 months.
// @todo need to add the DB prefix here
$traffic = DB::query(Database::SELECT,sprintf('
SELECT DATE_FORMAT(DATE,"%%y-%%m") AS MONTH,SID,MAX(NUM) AS NUM,SUM(DOWN_PEAK) AS DOWN_PEAK,SUM(IFNULL(DOWN_OFFPEAK,0)+IFNULL(PEER,0)+IFNULL(INTERNAL,0)) AS DOWN_OFFPEAK
FROM ab_view_traffic_adsl_daily
WHERE SID in (%s) AND DATE>"%s"
GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
','1,2',date('Y-m',time()-365*86400)))
->execute();
ksort($data['svs']);
foreach ($data['data'] as $metric => $details)
ksort($data['data'][$metric]);
$peak = $offpeak = $services = array();
return $data;
}
foreach ($traffic as $a => $v) {
$peak[$v['SID']]['Peak'][$v['MONTH']] = $v['DOWN_PEAK'];
$peak[$v['SID']]['OffPeak'][$v['MONTH']] = $v['DOWN_OFFPEAK'];
$peak[$v['SID']]['Services'][$v['MONTH']] = $v['NUM'];
}
public function action_listadslservices() {
$svs = ORM::factory('service')->list_bylistgroup('ADSL');
$data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('vertical_bar');
$google->title = sprintf('ADSL traffic as at %s',date('Y-m-d',strtotime('yesterday')));
$google->series(array(
'title'=>array('Exetel-Peak','Exetel-Offpeak'),
'axis'=>'x',
'data'=>array('Exetel-Peak'=>$peak[1]['Peak'],'Exetel-OffPeak'=>$peak[1]['OffPeak'])));
$google->series(array(
'title'=>array('People-Peak','People-Offpeak'),
'axis'=>'x',
'data'=>array('People-Peak'=>$peak[2]['Peak'],'People-OffPeak'=>$peak[2]['OffPeak'])));
$google->series(array(
'title'=>'Exetel-Services',
'axis'=>'r',
'data'=>array('Exetel-Services'=>$peak[1]['Services'])));
$google->series(array(
'title'=>'People-Services',
'axis'=>'r',
'data'=>array('People-Services'=>$peak[2]['Services'])));
$google->series(array('title'=>array_keys($data['data']),'axis'=>'x','data'=>$data['data']));
$google->series(array('title'=>'Services','axis'=>'r','data'=>array('Services'=>$data['svs'])));
Block::add(array('body'=>$google));
Block::add(array(
'body'=>$google,
'title'=>_('ADSL Services'),
'body'=>Table::display(
$svs,
NULL,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
'name()'=>array('label'=>'Service'),
'plugin()->ipaddress()'=>array('label'=>'IP Address'),
'product->plugin()->allowance()'=>array('label'=>'Allowance'),
'plugin()->traffic_thismonth()'=>array('label'=>'This Month'),
'plugin()->traffic_lastmonth()'=>array('label'=>'Last Month'),
'recur_schedule'=>array('label'=>'Billing'),
'price'=>array('label'=>'Price','class'=>'right'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'date_next_invoice'=>array('label'=>'Next Invoice'),
),
array(
'type'=>'select',
'form'=>'user/service/view',
)),
));
Block::add(array(
'title'=>_('List all ADSL Services'),
'body'=>$output,
));
Style::add(array(
'type'=>'file',
'data'=>'css/list.css',
));
}
public function action_listhspaservices() {
// @todo need to add the DB prefix here
$services = DB::query(Database::SELECT,'
SELECT A.service_id
FROM ab_service__adsl A,ab_service B,ab_account C,ab_service D,ab_product E
WHERE B.active=1 AND A.service_id=B.id AND A.site_id=B.site_id
AND B.account_id=C.id AND B.site_id=C.site_id
AND A.service_id=D.id AND A.site_id=D.site_id
AND D.product_id=E.id AND D.site_id=E.site_id
AND E.sku like "%HSPA%"
ORDER BY C.last_name,B.account_id,A.service_number
')
->execute();
// @todo If no items, show a nice message. This is not correct for ORM.
if (! count($services)) {
echo Kohana::debug('No services for HSPA');
die();
}
$last_account = '';
$i = 0;
$output = '<table class="box-left">';
foreach ($services as $service) {
$so = ORM::factory('service',$service['service_id']);
if ($last_account != $so->account_id) {
if ($i)
$output .= '<tr><td colspan="10">&nbsp;</td></tr>';
$output .= View::factory('service/admin/list/adslservices_header')
->set('service',$so);
$last_account = $so->account_id;
}
$output .= View::factory('service/admin/list/adslservices_body')
->set('service',$so)
->set('i',$i++%2);
}
$output .= '</table>';
// Chart the traffic for the last 12 months.
// @todo need to add the DB prefix here
$traffic = DB::query(Database::SELECT,sprintf('
SELECT DATE_FORMAT(DATE,"%%y-%%m") AS MONTH,SID,MAX(NUM) AS NUM,SUM(DOWN_PEAK)*1000 AS DOWN_PEAK,SUM(IFNULL(DOWN_OFFPEAK,0)+IFNULL(PEER,0)+IFNULL(INTERNAL,0))*1000 AS DOWN_OFFPEAK
FROM ab_view_traffic_adsl_daily
WHERE SID=%s AND DATE>"%s"
GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
',3,date('Y-m',time()-365*86400)))
->execute();
$peak = $offpeak = $services = array();
foreach ($traffic as $a => $v) {
$peak['Peak'][$v['MONTH']] = $v['DOWN_PEAK'];
$peak['OffPeak'][$v['MONTH']] = $v['DOWN_OFFPEAK'];
$peak['Services'][$v['MONTH']] = $v['NUM'];
}
$svs = ORM::factory('service')->list_bylistgroup('HSPA');
$data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('vertical_bar');
$google->title = sprintf('HSPA traffic as at %s',date('Y-m-d',strtotime('yesterday')));
$google->series(array('title'=>array('Peak','Offpeak'),'axis'=>'x','data'=>array('Peak'=>$peak['Peak'],'OffPeak'=>$peak['OffPeak'])));
$google->series(array('title'=>'Services','axis'=>'r','data'=>array('Services'=>$peak['Services'])));
$google->series(array('title'=>array_keys($data['data']),'axis'=>'x','data'=>$data['data']));
$google->series(array('title'=>'Services','axis'=>'r','data'=>array('Services'=>$data['svs'])));
Block::add(array('body'=>$google));
Block::add(array(
'body'=>$google,
'title'=>_('HSPA Services'),
'body'=>Table::display(
$svs,
NULL,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
'name()'=>array('label'=>'Service'),
'plugin()->ipaddress()'=>array('label'=>'IP Address'),
'product->plugin()->allowance()'=>array('label'=>'Allowance'),
'plugin()->traffic_thismonth()'=>array('label'=>'This Month'),
'plugin()->traffic_lastmonth()'=>array('label'=>'Last Month'),
'recur_schedule'=>array('label'=>'Billing'),
'price'=>array('label'=>'Price','class'=>'right'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'date_next_invoice'=>array('label'=>'Next Invoice'),
),
array(
'type'=>'select',
'form'=>'user/service/view',
)),
));
Block::add(array(
'title'=>_('List all HSPA Services'),
'body'=>$output,
));
Style::add(array(
'type'=>'file',
'data'=>'css/list.css',
));
}
public function action_listdomainservices() {
$svs = ORM::factory('service')->list_bylistgroup('DOMAIN');
Sort::MAsort($svs,'name()');
Block::add(array(
'title'=>_('Domain Names'),
'body'=>Table::display(
$svs,
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
'service_name()'=>array('label'=>'Details'),
'plugin()->display("domain_expire")'=>array('label'=>'Expire'),
'recur_schedule'=>array('label'=>'Billing'),
'price'=>array('label'=>'Price','class'=>'right'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'display("date_next_invoice")'=>array('label'=>'Next Invoice'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/service/view',
)),
));
}
public function action_listhostservices() {
$svs = ORM::factory('service')->list_bylistgroup('HOST');
Sort::MAsort($svs,'name()');
Block::add(array(
'title'=>_('Hosting Services'),
'body'=>Table::display(
$svs,
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
'service_name()'=>array('label'=>'Details'),
'plugin()->display("host_expire")'=>array('label'=>'Expire'),
'recur_schedule'=>array('label'=>'Billing'),
'price'=>array('label'=>'Price','class'=>'right'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'display("date_next_invoice")'=>array('label'=>'Next Invoice'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/service/view',
)),
));
}
/**
* Reconcile billing for an ADSL supplier
*
@@ -328,18 +307,24 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
$output = View::factory('service/admin/list/adslbilling_head');
$output .= '<table class="box-left">';
foreach ($aso->services(TRUE) as $so) {
$po = $so->plugin()->product();
// Reset our uploaded data
$uploaded = array();
$uploaded['excess'] = empty($csv[$so->plugin()->service_number]['excess']) ? 0 : $csv[$so->plugin()->service_number]['excess'];
// If our uploaded file has some cost data.
if (! empty($csv[$so->service_adsl->service_number])) {
if (! empty($csv[$so->plugin()->service_number])) {
$uploaded['amount'] =
(empty($csv[$so->service_adsl->service_number]['cost']) ? 0 : $csv[$so->service_adsl->service_number]['cost']) +
(empty($csv[$so->service_adsl->service_number]['credit']) ? 0 : $csv[$so->service_adsl->service_number]['credit']);
(empty($csv[$so->plugin()->service_number]['cost']) ? 0 : $csv[$so->plugin()->service_number]['cost']) +
(empty($csv[$so->plugin()->service_number]['credit']) ? 0 : $csv[$so->plugin()->service_number]['credit']);
// Record the the exception if the cost is not expected
if (round($so->service_adsl->adsl_plan->adsl_supplier_plan->base_cost+$so->service_adsl->adsl_plan->adsl_supplier_plan->tax(),2) != $uploaded['amount']) {
if (round($po->adsl_supplier_plan->base_cost+$po->adsl_supplier_plan->tax(),2) != $uploaded['amount']) {
$summary .= View::factory('service/admin/list/adslbilling_summary')
->set('service',$so)
->set('plan',$po)
->set('planoverride',$so->plugin()->provided_adsl_plan_id ? TRUE : FALSE)
->set('amount',$uploaded['amount'])
->set('i',$j++%2);
@@ -348,19 +333,23 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
$uploaded['checked'] = 'checked="checked"';
}
unset($csv[$so->service_adsl->service_number]);
unset($csv[$so->plugin()->service_number]);
} else {
$uploaded['checked'] = '';
$uploaded['amount'] = 0;
}
$total += $uploaded['amount'];
$output .= View::factory('service/admin/list/adslbilling_body')
->set('service',$so)
->set('plan',$po)
->set('planoverride',$so->plugin()->provided_adsl_plan_id ? TRUE : FALSE)
->set('checked',$uploaded['checked'])
->set('amount',$uploaded['amount'])
->set('adsl',$so->service_adsl)
->set('excess',$uploaded['excess'])
->set('adsl',$so->plugin())
->set('i',$i++%2);
}
@@ -435,7 +424,7 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
// If the description says VISP credit, we know this is commission.
elseif (preg_match('/^VISP Credit/',$description))
$return[$service]['credit'] = preg_replace('/\$/','',$total);
// If the description says Excess, we know this is commission.
// If the description says Excess, we know this is excess charges.
elseif (preg_match('/^Excess usage/',$description))
$return[$service]['excess'] = preg_replace('/\$/','',$total);
else

View File

@@ -1,7 +1,7 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides OSB service affiliate capabilities.
* This class provides Affiliate Service functions
*
* @package OSB
* @subpackage Service
@@ -11,12 +11,12 @@
* @license http://dev.osbill.net/license.html
*/
class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate {
protected $control = array('Services'=>'services');
protected $secure_actions = array(
'list'=>TRUE,
'listbycheckout'=>TRUE,
'listadslservices'=>TRUE,
'listdomainservices'=>TRUE,
'listhostservices'=>TRUE,
'listhspaservices'=>TRUE,
);
@@ -24,17 +24,14 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
* Show a list of services
*/
public function action_list() {
$so = ORM::factory('service');
Block::add(array(
'title'=>_('System Customer Services'),
'title'=>_('Customer Services'),
'body'=>Table::display(
$so->where('affiliate_id','=',$this->ao->affiliate->id)->find_all(),
$this->filter(ORM::factory('service')->list_active(),$this->ao->affiliate->id),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
'type'=>array('label'=>'Type'),
'name()'=>array('label'=>'Details'),
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price'=>array('label'=>'Price','class'=>'right'),
'active'=>array('label'=>'Active'),
@@ -44,7 +41,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/email/view',
'form'=>'user/service/view',
)),
));
}
@@ -123,181 +120,156 @@ ORDER BY c.id,s.recur_schedule,c.name,a.company,a.last_name,a.first_name
));
}
//@todo this should really be in a different class, since adsl wont be part of the main app
public function action_listadslservices() {
// @todo need to add the DB prefix here
// @todo need to restrict this to affiliate services
$services = DB::query(Database::SELECT,'
SELECT A.service_id
FROM ab_service__adsl A,ab_service B,ab_account C,ab_service D,ab_product E
WHERE B.active=1 AND A.service_id=B.id AND A.site_id=B.site_id
AND B.account_id=C.id AND B.site_id=C.site_id
AND A.service_id=D.id AND A.site_id=D.site_id
AND D.product_id=E.id AND D.site_id=E.site_id
AND E.sku like "%ADSL%"
ORDER BY C.last_name,B.account_id,A.service_number
')
->execute();
private function consoltraffic($svs,$date) {
$data = array();
// @todo If no items, show a nice message. This is not correct for ORM.
if (! count($services)) {
echo Kohana::debug('No services for ADSL');
die();
}
foreach ($svs as $so) {
$c = array();
foreach ($so->plugin()->get_traffic_data_monthly($date) as $metric => $ma) {
foreach ($ma as $month => $traffic) {
// Only count the service once, not for each metric.
if (! isset($c[$month])) {
if (isset($data['svs'][$month]))
$data['svs'][$month] += 1;
else
$data['svs'][$month] = 1;
$last_account = '';
$i = 0;
$output = '<table class="box-left">';
foreach ($services as $service) {
$so = ORM::factory('service',$service['service_id']);
$c[$month] = 1;
}
if ($last_account != $so->account_id) {
if ($i)
$output .= '<tr><td colspan="10">&nbsp;</td></tr>';
$output .= View::factory('service/admin/list/adslservices_header')
->set('service',$so);
$last_account = $so->account_id;
if (isset($data['data'][$metric][$month]))
$data['data'][$metric][$month] += (int)$traffic;
else
$data['data'][$metric][$month] = (int)$traffic;
}
}
$output .= View::factory('service/admin/list/adslservices_body')
->set('service',$so)
->set('i',$i++%2);
}
$output .= '</table>';
// Chart the traffic for the last 12 months.
// @todo need to add the DB prefix here
$traffic = DB::query(Database::SELECT,sprintf('
SELECT DATE_FORMAT(DATE,"%%y-%%m") AS MONTH,SID,MAX(NUM) AS NUM,SUM(DOWN_PEAK) AS DOWN_PEAK,SUM(IFNULL(DOWN_OFFPEAK,0)+IFNULL(PEER,0)+IFNULL(INTERNAL,0)) AS DOWN_OFFPEAK
FROM ab_view_traffic_adsl_daily
WHERE SID in (%s) AND DATE>"%s"
GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
','1,2',date('Y-m',time()-365*86400)))
->execute();
ksort($data['svs']);
foreach ($data['data'] as $metric => $details)
ksort($data['data'][$metric]);
$peak = $offpeak = $services = array();
return $data;
}
foreach ($traffic as $a => $v) {
$peak[$v['SID']]['Peak'][$v['MONTH']] = $v['DOWN_PEAK'];
$peak[$v['SID']]['OffPeak'][$v['MONTH']] = $v['DOWN_OFFPEAK'];
$peak[$v['SID']]['Services'][$v['MONTH']] = $v['NUM'];
}
public function action_listadslservices() {
$svs = $this->filter(ORM::factory('service')->list_bylistgroup('ADSL'),$this->ao->affiliate->id,'name()');
$data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('vertical_bar');
$google->title = sprintf('ADSL traffic as at %s',date('Y-m-d',strtotime('yesterday')));
$google->series(array(
'title'=>array('Exetel-Peak','Exetel-Offpeak'),
'axis'=>'x',
'data'=>array('Exetel-Peak'=>$peak[1]['Peak'],'Exetel-OffPeak'=>$peak[1]['OffPeak'])));
$google->series(array(
'title'=>array('People-Peak','People-Offpeak'),
'axis'=>'x',
'data'=>array('People-Peak'=>$peak[2]['Peak'],'People-OffPeak'=>$peak[2]['OffPeak'])));
$google->series(array(
'title'=>'Exetel-Services',
'axis'=>'r',
'data'=>array('Exetel-Services'=>$peak[1]['Services'])));
$google->series(array(
'title'=>'People-Services',
'axis'=>'r',
'data'=>array('People-Services'=>$peak[2]['Services'])));
$google->series(array('title'=>array_keys($data['data']),'axis'=>'x','data'=>$data['data']));
$google->series(array('title'=>'Services','axis'=>'r','data'=>array('Services'=>$data['svs'])));
Block::add(array('body'=>$google));
Block::add(array(
'body'=>$google,
'title'=>_('ADSL Services'),
'body'=>Table::display(
$svs,
NULL,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
'name()'=>array('label'=>'Service'),
'plugin()->ipaddress()'=>array('label'=>'IP Address'),
'product->plugin()->allowance()'=>array('label'=>'Allowance'),
'plugin()->traffic_thismonth()'=>array('label'=>'This Month'),
'plugin()->traffic_lastmonth()'=>array('label'=>'Last Month'),
'recur_schedule'=>array('label'=>'Billing'),
'price'=>array('label'=>'Price','class'=>'right'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'date_next_invoice'=>array('label'=>'Next Invoice'),
),
array(
'type'=>'select',
'form'=>'user/service/view',
)),
));
Block::add(array(
'title'=>_('List all ADSL Services'),
'body'=>$output,
));
Style::add(array(
'type'=>'file',
'data'=>'css/list.css',
));
}
public function action_listhspaservices() {
// @todo need to add the DB prefix here
// @todo need to restrict this to affiliate services
$services = DB::query(Database::SELECT,'
SELECT A.service_id
FROM ab_service__adsl A,ab_service B,ab_account C,ab_service D,ab_product E
WHERE B.active=1 AND A.service_id=B.id AND A.site_id=B.site_id
AND B.account_id=C.id AND B.site_id=C.site_id
AND A.service_id=D.id AND A.site_id=D.site_id
AND D.product_id=E.id AND D.site_id=E.site_id
AND E.sku like "%HSPA%"
ORDER BY C.last_name,B.account_id,A.service_number
')
->execute();
// @todo If no items, show a nice message. This is not correct for ORM.
if (! count($services)) {
echo Kohana::debug('No services for HSPA');
die();
}
$last_account = '';
$i = 0;
$output = '<table class="box-left">';
foreach ($services as $service) {
$so = ORM::factory('service',$service['service_id']);
if ($last_account != $so->account_id) {
if ($i)
$output .= '<tr><td colspan="10">&nbsp;</td></tr>';
$output .= View::factory('service/admin/list/adslservices_header')
->set('service',$so);
$last_account = $so->account_id;
}
$output .= View::factory('service/admin/list/adslservices_body')
->set('service',$so)
->set('i',$i++%2);
}
$output .= '</table>';
// Chart the traffic for the last 12 months.
// @todo need to add the DB prefix here
$traffic = DB::query(Database::SELECT,sprintf('
SELECT DATE_FORMAT(DATE,"%%y-%%m") AS MONTH,SID,MAX(NUM) AS NUM,SUM(DOWN_PEAK)*1000 AS DOWN_PEAK,SUM(IFNULL(DOWN_OFFPEAK,0)+IFNULL(PEER,0)+IFNULL(INTERNAL,0))*1000 AS DOWN_OFFPEAK
FROM ab_view_traffic_adsl_daily
WHERE SID=%s AND DATE>"%s"
GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
',3,date('Y-m',time()-365*86400)))
->execute();
$peak = $offpeak = $services = array();
foreach ($traffic as $a => $v) {
$peak['Peak'][$v['MONTH']] = $v['DOWN_PEAK'];
$peak['OffPeak'][$v['MONTH']] = $v['DOWN_OFFPEAK'];
$peak['Services'][$v['MONTH']] = $v['NUM'];
}
$svs = $this->filter(ORM::factory('service')->list_bylistgroup('HSPA'),$this->ao->affiliate->id,'name()');
$data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('vertical_bar');
$google->title = sprintf('HSPA traffic as at %s',date('Y-m-d',strtotime('yesterday')));
$google->series(array('title'=>array('Peak','Offpeak'),'axis'=>'x','data'=>array('Peak'=>$peak['Peak'],'OffPeak'=>$peak['OffPeak'])));
$google->series(array('title'=>'Services','axis'=>'r','data'=>array('Services'=>$peak['Services'])));
$google->series(array('title'=>array_keys($data['data']),'axis'=>'x','data'=>$data['data']));
$google->series(array('title'=>'Services','axis'=>'r','data'=>array('Services'=>$data['svs'])));
Block::add(array('body'=>$google));
Block::add(array(
'body'=>$google,
'title'=>_('HSPA Services'),
'body'=>Table::display(
$svs,
NULL,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
'name()'=>array('label'=>'Service'),
'plugin()->ipaddress()'=>array('label'=>'IP Address'),
'product->plugin()->allowance()'=>array('label'=>'Allowance'),
'plugin()->traffic_thismonth()'=>array('label'=>'This Month'),
'plugin()->traffic_lastmonth()'=>array('label'=>'Last Month'),
'recur_schedule'=>array('label'=>'Billing'),
'price'=>array('label'=>'Price','class'=>'right'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'date_next_invoice'=>array('label'=>'Next Invoice'),
),
array(
'type'=>'select',
'form'=>'user/service/view',
)),
));
}
public function action_listdomainservices() {
Block::add(array(
'title'=>_('List all HSPA Services'),
'body'=>$output,
'title'=>_('Domain Names'),
'body'=>Table::display(
$this->filter(ORM::factory('service')->list_bylistgroup('DOMAIN'),$this->ao->affiliate->id,'name()'),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
'service_name()'=>array('label'=>'Details'),
'plugin()->display("domain_expire")'=>array('label'=>'Expire'),
'recur_schedule'=>array('label'=>'Billing'),
'price'=>array('label'=>'Price','class'=>'right'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'display("date_next_invoice")'=>array('label'=>'Next Invoice'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/service/view',
)),
));
}
Style::add(array(
'type'=>'file',
'data'=>'css/list.css',
));
public function action_listhostservices() {
Block::add(array(
'title'=>_('Hosting Services'),
'body'=>Table::display(
$this->filter(ORM::factory('service')->list_bylistgroup('HOST'),$this->ao->affiliate->id,'name()'),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
'service_name()'=>array('label'=>'Details'),
'plugin()->display("host_expire")'=>array('label'=>'Expire'),
'recur_schedule'=>array('label'=>'Billing'),
'price'=>array('label'=>'Price','class'=>'right'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'display("date_next_invoice")'=>array('label'=>'Next Invoice'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/service/view',
)),
));
}
}
?>

View File

@@ -7,8 +7,8 @@
* @subpackage Service
* @category Controllers/User
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_User_Service extends Controller_TemplateDefault_User {
protected $secure_actions = array(
@@ -27,8 +27,7 @@ class Controller_User_Service extends Controller_TemplateDefault_User {
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
'type'=>array('label'=>'Type'),
'name()'=>array('label'=>'Details'),
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price'=>array('label'=>'Price','class'=>'right'),
'active'=>array('label'=>'Active'),
@@ -65,7 +64,7 @@ class Controller_User_Service extends Controller_TemplateDefault_User {
->set('so',$so);
Block::add(array(
'title'=>sprintf('%s: %s',$so->id(),$so->product->name()),
'title'=>sprintf('%s: %s',$so->id(),$so->service_name()),
'body'=>$output,
));
}

View File

@@ -15,10 +15,6 @@ class Model_Service extends ORMOSB {
protected $_has_many = array(
'invoice'=>array('through'=>'invoice_item'),
);
protected $_has_one = array(
'service_adsl'=>array('far_key'=>'id'),
'service_domain'=>array('far_key'=>'id'),
);
protected $_belongs_to = array(
'product'=>array(),
'account'=>array(),
@@ -76,15 +72,14 @@ class Model_Service extends ORMOSB {
/**
* Return the object of the product plugin
*/
private function plugin() {
public function plugin() {
if (! $this->product->prod_plugin_file)
return NULL;
if (! is_numeric($this->product->prod_plugin_data))
throw new Kohana_Exception('Missing plugin_id for :product (:type)',array(':product'=>$this->product->id,':type'=>$this->product->prod_plugin_file));
$spn = sprintf('%s_%s',get_class($this),$this->product->prod_plugin_file);
return new $spn(array('service_id'=>$this->id));
return ORM::factory(sprintf('service_plugin_%s',$this->product->prod_plugin_file),array('service_id'=>$this->id));
}
/**
@@ -98,7 +93,15 @@ class Model_Service extends ORMOSB {
* Display the service product name
*/
public function name() {
return $this->product->name();
return is_null($plugin=$this->plugin()) ? $this->product->name() : $plugin->name();
}
public function service_name() {
return is_null($plugin=$this->plugin()) ? $this->name() : $plugin->service_name();
}
public function service_view() {
return is_null($plugin=$this->plugin()) ? HTML::nbsp('') : $plugin->service_view();
}
/**
@@ -108,29 +111,12 @@ class Model_Service extends ORMOSB {
return $this->product->feature_summary();
}
/**
* Display the service details
*/
public function service_view() {
if (is_null($plugin = $this->plugin()))
return HTML::nbsp('');
else
return $plugin->_service_view();
}
public function service_name() {
if (is_null($plugin = $this->plugin()))
return $this->name();
else
return $plugin->_service_name();
}
/**
* Render some details for specific calls, eg: invoice
*/
public function details($type) {
switch ($type) {
case 'invoice':
case 'invoice_detail_items':
if (is_null($plugin = $this->plugin()))
return array();
else
@@ -156,5 +142,26 @@ class Model_Service extends ORMOSB {
public function tax() {
return $this->price * .1;
}
public function list_active() {
return $this->where('active','=','1')->find_all();
}
public function list_bylistgroup($cat) {
$result = array();
$cats = ORM::factory('product_category')->list_bylistgroup($cat);
foreach ($this->list_active() as $so) {
if (! $so->product->avail_category_id OR ! preg_match('/^a:/',$so->product->avail_category_id))
continue;
$pc = unserialize($so->product->avail_category_id);
if (array_intersect($pc,array_keys($cats)))
array_push($result,$so);
}
return $result;
}
}
?>

View File

@@ -1,59 +0,0 @@
<?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_DOMAIN extends Model_Service {
protected $_table_name = 'service__domain';
protected $_updated_column = FALSE;
// Relationships
protected $_has_one = array(
'host_tld'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'),
'host_registrar_plugin'=>array('foreign_key'=>'id','far_key'=>'domain_registrar_id'),
);
protected $_belongs_to = array(
'service'=>array(),
);
protected $_display_filters = array(
'domain_expire'=>array(
array('Config::date',array(':value')),
),
);
protected function _service_name() {
return sprintf('%s - %s','Domain',$this->name());
}
protected function _service_view() {
}
/**
* Get specific service details for use in other modules
* For Example: Invoice
*
* @todo Make the rendered items configurable
*/
protected function _details($type) {
switch ($type) {
default:
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
}
}
protected function _admin_update() {
}
public function name() {
return sprintf('%s.%s',$this->domain_name,$this->host_tld->name);
}
}
?>

View File

@@ -0,0 +1,52 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Service Plugins.
*
* @package OSB
* @subpackage Product/Service
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
abstract class Model_Service_Plugin extends ORMOSB {
// Reset any sorting that may be defined in our parent
protected $_sorting = array();
/**
* View details of the service
*/
abstract public function service_view();
/**
* Our service name as defined in the DB
*/
abstract public function name();
/**
* Show our service name as defined in the DB with product suffix.
*/
public function service_name() {
return sprintf('%s - %s',$this->service->product->name(),$this->name());
}
/**
* Get specific service details for use in other modules
* For Example: Invoice
*
* @todo Make the rendered items configurable
* @todo Change this method name, now that it is public
*/
public function _details($type) {
switch ($type) {
// Nothing to add for invoices
case 'invoice_detail_items':
return array();
default:
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
}
}
}
?>

View File

@@ -1,10 +0,0 @@
<tr class="<?php echo $i ? 'odd' : 'even'; ?>">
<td><?php echo $service->service_adsl->display('service_number'); ?></td>
<td><?php echo $service->service_adsl->adsl_plan->adsl_supplier_plan->name(); ?></td>
<td><?php echo $service->service_adsl->contract_date_start(); ?></td>
<td><?php echo $service->service_adsl->contract_date_end(); ?></td>
<td><?php echo Currency::display($service->service_adsl->adsl_plan->adsl_supplier_plan->base_cost); ?></td>
<td><?php echo Currency::display($service->service_adsl->adsl_plan->adsl_supplier_plan->base_cost+$service->service_adsl->adsl_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->service_adsl->service_number; ?>]" value="<?php echo $amount; ?>" id="p<?php echo $service->service_adsl->id; ?>" size="8"/></td>
</tr>

View File

@@ -1,10 +0,0 @@
<tr class="<?php echo $i ? 'odd' : 'even'; ?>">
<td><?php echo $service->service_adsl->display('service_number'); ?></td>
<td><?php echo $service->service_adsl->adsl_plan->adsl_supplier_plan->name(); ?></td>
<td><?php echo $service->service_adsl->contract_date_start(); ?></td>
<td><?php echo $service->service_adsl->contract_date_end(); ?></td>
<td><?php echo Currency::display($service->service_adsl->adsl_plan->adsl_supplier_plan->base_cost); ?></td>
<td><?php echo Currency::display($service->service_adsl->adsl_plan->adsl_supplier_plan->base_cost+$service->service_adsl->adsl_plan->adsl_supplier_plan->tax()); ?></td>
<td><?php echo $amount; ?></td>
<td><?php echo $service->service_adsl->adsl_plan->adsl_supplier_plan->base_cost+$service->service_adsl->adsl_plan->adsl_supplier_plan->tax()-$amount; ?></td>
</tr>

View File

@@ -0,0 +1,40 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Admin TASK management
*
* @package lnApp
* @subpackage Page/Task
* @category Controllers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Controller_Admin_Task extends Controller_TemplateDefault_Admin {
protected $secure_actions = array(
'listlog'=>TRUE,
);
/**
* Show a list of tasks run
*/
public function action_listlog() {
Block::add(array(
'title'=>_('Task Log'),
'body'=>Table::display(
ORM::factory('task_log')->order_by('id','DESC')->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'admin/task/view/'),
'date_orig'=>array('label'=>'Date'),
'task->display("name")'=>array('label'=>'Task'),
'result'=>array('label'=>'Result'),
'message'=>array('label'=>'Message'),
),
array(
'page'=>TRUE,
)),
));
}
}
?>

View File

@@ -1,16 +1,15 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides account management
* This class provides task management
*
* @package lnApp
* @subpackage Page/Account
* @subpackage Page/Task
* @category Controllers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
* @also [logout]
*/
class Controller_Account extends Controller_TemplateDefault {
class Controller_Task extends Controller_TemplateDefault {
}
?>

View File

@@ -42,6 +42,7 @@ class Model_Task extends ORMOSB {
$this->save();
// Check we are the winning host to run this task
// @todo We need to test that the lock is not stale
$this->reload();
if ($this->running_host != $r)
return;

View File

@@ -11,6 +11,10 @@
* @license http://dev.osbill.net/license.html
*/
class Model_Task_Log extends ORMOSB {
protected $_belongs_to = array(
'task'=>array(),
);
protected $_display_filters = array(
'date_orig'=>array(
array('Config::datetime',array(':value')),