Internal overhaul

This commit is contained in:
Deon George 2013-11-28 17:41:34 +11:00
parent 0ed5e5163d
commit f8a5b153cf
91 changed files with 1570 additions and 1619 deletions

View File

@ -188,6 +188,10 @@ class Auth_OSB extends Auth_ORM {
return $uo; return $uo;
} }
public function get_groups() {
return is_null($x=$this->get_user()) ? ORM::factory('Group')->where('id','=',0)->find_all() : $x->groups();
}
/** /**
* OSB authentication is controlled via database queries. * OSB authentication is controlled via database queries.
* *

View File

@ -171,13 +171,11 @@ class Controller_Admin_Module extends Controller_Module {
* List our installed modules * List our installed modules
*/ */
public function action_list() { public function action_list() {
$mo = ORM::factory('Module');
Block::factory() Block::factory()
->title('Defined Modules') ->title('Defined Modules')
->title_icon('icon-cog') ->title_icon('icon-cog')
->body(Table::factory() ->body(Table::factory()
->data($mo->find_all()) ->data(ORM::factory('Module')->where('parent_id','is',NULL)->find_all())
->jssort(TRUE) ->jssort(TRUE)
->columns(array( ->columns(array(
'id'=>'ID', 'id'=>'ID',

View File

@ -33,7 +33,7 @@ class Controller_Reseller_Account extends Controller_Account {
'name(TRUE)'=>'Account', 'name(TRUE)'=>'Account',
'email'=>'Email', 'email'=>'Email',
'invoices_due_total(NULL,TRUE)'=>'Invoices', 'invoices_due_total(NULL,TRUE)'=>'Invoices',
'services_count(TRUE)'=>'Services', 'service->list_count()'=>'Services',
)) ))
->prepend(array( ->prepend(array(
'id'=>array('url'=>URL::link('reseller','account/view/')), 'id'=>array('url'=>URL::link('reseller','account/view/')),

View File

@ -22,13 +22,13 @@ class Controller_User_Welcome extends Controller_Welcome {
->span(6) ->span(6)
->body(Table::factory() ->body(Table::factory()
->data($this->ao->service->list_active()) ->data($this->ao->service->list_active())
->columns(array( ->columns(array(
'id'=>'ID', 'id'=>'ID',
'service_name()'=>'Service', 'service_name()'=>'Service',
)) ))
->prepend(array( ->prepend(array(
'id'=>array('url'=>URL::link('user','service/view/')), 'id'=>array('url'=>URL::link('user','service/view/')),
)) ))
); );
Block::factory() Block::factory()
@ -43,15 +43,15 @@ class Controller_User_Welcome extends Controller_Welcome {
->span(6) ->span(6)
->body(Table::factory() ->body(Table::factory()
->data($this->ao->invoice->list_due()) ->data($this->ao->invoice->list_due())
->columns(array( ->columns(array(
'id'=>'ID', 'id'=>'ID',
'due_date'=>'Date Due', 'due_date'=>'Date Due',
'total(TRUE)'=>'Invoice Total', 'total(TRUE)'=>'Invoice Total',
'due(TRUE)'=>'Amount Due', 'due(TRUE)'=>'Amount Due',
)) ))
->prepend(array( ->prepend(array(
'id'=>array('url'=>URL::link('user','invoice/view/')), 'id'=>array('url'=>URL::link('user','invoice/view/')),
)) ))
); );
Block::factory() Block::factory()
@ -60,14 +60,14 @@ class Controller_User_Welcome extends Controller_Welcome {
->span(6) ->span(6)
->body(Table::factory() ->body(Table::factory()
->data($this->ao->service->list_expiring()) ->data($this->ao->service->list_expiring())
->columns(array( ->columns(array(
'id'=>'ID', 'id'=>'ID',
'service_name()'=>'Service', 'service_name()'=>'Service',
'expire(TRUE)'=>'Date', 'expire(TRUE)'=>'Date',
)) ))
->prepend(array( ->prepend(array(
'id'=>array('url'=>URL::link('user','service/view/')), 'id'=>array('url'=>URL::link('user','service/view/')),
)) ))
); );
} }
} }

View File

@ -146,19 +146,6 @@ class Model_Account extends Model_Auth_UserDefault {
return trim(sprintf('%s %s',$this->first_name,$this->last_name).(($withcompany AND $this->company) ? sprintf(' (%s)',$this->company) : '')); return trim(sprintf('%s %s',$this->first_name,$this->last_name).(($withcompany AND $this->company) ? sprintf(' (%s)',$this->company) : ''));
} }
/**
* List all the services for this account
*/
public function services($active=TRUE) {
$o = $this->service;
return $active ? $o->where_active()->find_all() : $o->find_all();
}
public function services_count($active=TRUE) {
return $this->services($active)->count();
}
/** /**
* The key we use to sort entries of this model type * The key we use to sort entries of this model type
*/ */

View File

@ -67,5 +67,12 @@ class Model_Group extends Model_Auth_Role {
return $result; return $result;
} }
/**
* Get a list of groups that have their own pricing
*/
public function list_pricegroups() {
return $this->where_active()->where('pricing','=',TRUE)->find_all();
}
} }
?> ?>

View File

@ -261,8 +261,10 @@ abstract class ORM_OSB extends ORM {
/** /**
* Function help to find records that are active * Function help to find records that are active
*/ */
public function list_active() { public function list_active($active=TRUE) {
return $this->_where_active()->find_all(); $x=($active ? $this->_where_active() : $this);
return $x->find_all();
} }
public function list_count($active=TRUE) { public function list_count($active=TRUE) {

View File

@ -19,6 +19,9 @@ return array
'email_admin_only'=> array( // Override emails and send them to an admin instead 'email_admin_only'=> array( // Override emails and send them to an admin instead
#'task_invoice_list_overdue'=>array('deon@leenooks.net'=>'Deon George'), #'task_invoice_list_overdue'=>array('deon@leenooks.net'=>'Deon George'),
), ),
'email_bcc_admin'=> array( // Blind copy all email to an admin, in the format 'email'=>'name',
// 'deon@leenooks.net'=>'Deon George',
),
'invoice'=>0, // Number of invoices to generate in a pass 'invoice'=>0, // Number of invoices to generate in a pass
'site'=>FALSE, // Glogal site debug 'site'=>FALSE, // Glogal site debug
'show_errors'=>FALSE, // Show errors instead of logging in the DB. 'show_errors'=>FALSE, // Show errors instead of logging in the DB.

View File

@ -1,58 +1,58 @@
<div class="row"> <div class="span11">
<div class="span10 offset1"> <fieldset>
<fieldset> <legend>Update Account Details</legend>
<legend>Update Account Details</legend>
<?php echo Form::input('date_last',$o->display('date_last'),array('label'=>'Last Updated','disabled')); ?> <?php echo Form::input('date_last',$o->display('date_last'),array('label'=>'Last Updated','disabled')); ?>
<?php echo Form::input('username',$o->display('username'),array('label'=>'User Name','disabled')); ?> <?php echo Form::input('username',$o->display('username'),array('label'=>'User Name','disabled')); ?>
<?php echo Form::input('email',$o->display('email'),array('label'=>'Email','class'=>'input-xxlarge','placeholder'=>'Email Address','type'=>'email','required')); ?> <?php echo Form::input('email',$o->display('email'),array('label'=>'Email','class'=>'input-xxlarge','placeholder'=>'Email Address','type'=>'email','required')); ?>
<?php echo Form::select('title',StaticList_Title::table(),$o->display('title'),array('class'=>'input-small','label'=>'Title','required')); ?> <div class="row">
<div class="span1">
<div class="row"> <?php echo Form::select('title',StaticList_Title::table(),$o->display('title'),array('class'=>'input-small','label'=>'Title','required')); ?>
<div class="span2">
<?php echo Form::input('first_name',$o->display('first_name'),array('label'=>'','class'=>'input-medium','placeholder'=>'First Name','required')); ?>
</div>
<div class="span3">
<?php echo Form::input('last_name',$o->display('last_name'),array('label'=>'','class'=>'input-large','placeholder'=>'Last Name','required')); ?>
</div>
</div> </div>
<?php echo Form::input('company',$o->display('company'),array('label'=>'Company','class'=>'input-xxlarge','placeholder'=>'Company Name')); ?> <div class="span2">
<?php echo Form::input('first_name',$o->display('first_name'),array('label'=>'','class'=>'input-medium','placeholder'=>'First Name','required')); ?>
<?php echo Form::input('address1',$o->display('address1'),array('label'=>'Address','class'=>'input-xxlarge','placeholder'=>'Address','required')); ?>
<?php echo Form::input('address2',$o->display('address2'),array('label'=>'','class'=>'input-xxlarge')); ?>
<div class="row">
<div class="span3">
<?php echo Form::input('city',$o->display('city'),array('label'=>'City','placeholder'=>'City','required')); ?>
</div>
<div class="span1">
<?php echo Form::input('state',$o->display('state'),array('label'=>'','class'=>'input-mini','placeholder'=>'State','required')); ?>
</div>
<div class="span1">
<?php echo Form::input('zip',$o->display('zip'),array('label'=>'','class'=>'input-mini','placeholder'=>'Post Code','required')); ?>
</div>
</div> <!-- /row -->
<?php echo Form::select('country_id',ORM::factory('Country')->list_select(),$o->country_id,array('label'=>'Country','required')); ?>
<?php echo Form::select('language_id',ORM::factory('Language')->list_select(),$o->language_id,array('label'=>'Language','required')); ?>
<?php echo Form::select('currency_id',ORM::factory('Currency')->list_select(),$o->currency_id,array('label'=>'Currency','required')); ?>
<div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</div> </div>
</fieldset>
</div> <!-- /span --> <div class="span3">
</div> <!-- /row --> <?php echo Form::input('last_name',$o->display('last_name'),array('label'=>'','class'=>'input-large','placeholder'=>'Last Name','required')); ?>
</div>
</div>
<?php echo Form::input('company',$o->display('company'),array('label'=>'Company','class'=>'input-xxlarge','placeholder'=>'Company Name')); ?>
<?php echo Form::input('address1',$o->display('address1'),array('label'=>'Address','class'=>'input-xxlarge','placeholder'=>'Address','required')); ?>
<?php echo Form::input('address2',$o->display('address2'),array('label'=>'','class'=>'input-xxlarge')); ?>
<div class="row">
<div class="span3">
<?php echo Form::input('city',$o->display('city'),array('label'=>'City','placeholder'=>'City','required')); ?>
</div>
<div class="span1">
<?php echo Form::input('state',$o->display('state'),array('label'=>'','class'=>'input-mini','placeholder'=>'State','required')); ?>
</div>
<div class="span1">
<?php echo Form::input('zip',$o->display('zip'),array('label'=>'','class'=>'input-mini','placeholder'=>'Post Code','required')); ?>
</div>
</div> <!-- /row -->
<?php echo Form::select('country_id',ORM::factory('Country')->list_select(),$o->country_id,array('label'=>'Country','required')); ?>
<?php echo Form::select('language_id',ORM::factory('Language')->list_select(),$o->language_id,array('label'=>'Language','required')); ?>
<?php echo Form::select('currency_id',ORM::factory('Currency')->list_select(),$o->currency_id,array('label'=>'Currency','required')); ?>
</fieldset>
<div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</div>
</div> <!-- /span -->

View File

@ -1,16 +1,14 @@
<div class="row"> <div class="span11">
<div class="span8 offset1"> <fieldset>
<fieldset> <legend>Reset Password</legend>
<legend>Reset Password</legend>
<?php echo Form::input('password','',array('label'=>'Password','type'=>'password','required','minlength'=>8)); ?> <?php echo Form::input('password','',array('label'=>'Password','type'=>'password','required','minlength'=>8)); ?>
<?php echo Form::input('password_confirm','',array('label'=>'Confirm','type'=>'password','required','minlength'=>8)); ?> <?php echo Form::input('password_confirm','',array('label'=>'Confirm','type'=>'password','required','minlength'=>8)); ?>
</fieldset>
<div class="row"> <div class="row">
<div class="offset2"> <div class="offset2">
<button type="submit" class="btn btn-primary">Update</button> <button type="submit" class="btn btn-primary">Update</button>
</div> </div>
</div> </div>
</fieldset> </div> <!-- /span -->
</div> <!-- /span -->
</div> <!-- /row -->

View File

@ -1,18 +1,16 @@
<div class="row"> <div class="span11">
<div class="span10 offset1"> <fieldset>
<fieldset> <legend>Add Method</legend>
<legend>Add Method</legend>
<?php echo Form::input('name',$name,array('label'=>'Method','disabled')); ?> <?php echo Form::input('name',$name,array('label'=>'Method','disabled')); ?>
<?php echo Form::input('notes','',array('label'=>'Description','placeholder'=>'Method Description','class'=>'span8')); ?> <?php echo Form::input('notes','',array('label'=>'Description','placeholder'=>'Method Description','class'=>'span8')); ?>
<?php echo Form::input('menu_display','',array('label'=>'Menu Title','placeholder'=>'Menu Title')); ?> <?php echo Form::input('menu_display','',array('label'=>'Menu Title','placeholder'=>'Menu Title')); ?>
</fieldset>
<div class="row"> <div class="row">
<div class="offset2"> <div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button> <button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button> <button type="button" class="btn">Cancel</button>
</div> </div>
</div> </div>
</fieldset> </div> <!-- /span -->
</div> <!-- /span10 -->
</div> <!-- /row -->

View File

@ -1,29 +1,26 @@
<div class="row"> <div class="span5">
<div class="span10 offset1"> <fieldset>
<fieldset> <legend>Method Details</legend>
<legend>Configure Method </legend>
<?php echo Form::input('notes',$o->notes,array('label'=>'Description','placeholder'=>'Method Description','class'=>'span8')); ?> <?php echo Form::input('notes',$o->notes,array('label'=>'Description','placeholder'=>'Method Description','class'=>'span5')); ?>
<?php echo Form::input('menu_display',$o->menu_display,array('label'=>'Menu Title','placeholder'=>'Menu Title')); ?> <?php echo Form::input('menu_display',$o->menu_display,array('label'=>'Menu Title','placeholder'=>'Menu Title')); ?>
</fieldset> </fieldset>
</div> <!-- /span10 --> </div> <!-- /span -->
</div> <!-- /row -->
<div class="row"> <div class="span6">
<div class="span10 offset1"> <fieldset>
<fieldset> <legend>Method Security</legend>
<legend>Configure Method Security</legend>
<table class="table table-striped table-condensed table-hover" id="list-table"> <table class="table table-striped table-condensed table-hover" id="list-table">
<thead><tr> <thead><tr>
<th>Method</th> <th>Method</th>
<th>Notes</th> <th>Notes</th>
<th>Group Active</th> <th>Group Active</th>
<th>Method Enable</th> <th>Method Enable</th>
</tr></thead> </tr></thead>
<tbody> <tbody>
<?php foreach (ORM::factory('Group')->find_all() as $go) : ?> <?php foreach (ORM::factory('Group')->find_all() as $go) : ?>
<tr> <tr>
<td><?php echo HTML::anchor(URL::link('admin','group/edit/'.$go->id,TRUE),$go->display('name')); ?></td> <td><?php echo HTML::anchor(URL::link('admin','group/edit/'.$go->id,TRUE),$go->display('name')); ?></td>
@ -32,16 +29,14 @@
<td><?php echo Form::checkbox('groups[]',$go->id,$o->has('group',$go)); ?></td> <td><?php echo Form::checkbox('groups[]',$go->id,$o->has('group',$go)); ?></td>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>
</tbody> </tbody>
</table> </table>
</fieldset>
<div class="row"> <div class="row">
<div class="offset2"> <div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button> <button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button> <button type="button" class="btn">Cancel</button>
</div> </div>
</div> </div>
</div> <!-- /span -->
</fieldset>
</div> <!-- /span10 -->
</div> <!-- /row -->

View File

@ -1,44 +1,42 @@
<div class="row"> <div class="span11">
<div class="span10 offset1"> <fieldset>
<fieldset> <legend>Application Setup</legend>
<legend>Application Setup</legend>
<?php echo Form::input('site_details[name]',$o->site_details('name'),array('label'=>'Site Name','class'=>'input-xxlarge','placeholder'=>'Site Name','required')); ?> <?php echo Form::input('site_details[name]',$o->site_details('name'),array('label'=>'Site Name','class'=>'input-xxlarge','placeholder'=>'Site Name','required')); ?>
<?php echo Form::input('site_details[address1]',$o->site_details('address1'),array('label'=>'Address','class'=>'input-xxlarge','placeholder'=>'Address','required')); ?> <?php echo Form::input('site_details[address1]',$o->site_details('address1'),array('label'=>'Address','class'=>'input-xxlarge','placeholder'=>'Address','required')); ?>
<?php echo Form::input('site_details[address2]',$o->site_details('address2')); ?> <?php echo Form::input('site_details[address2]',$o->site_details('address2')); ?>
<div class="row"> <div class="row">
<div class="span3"> <div class="span3">
<?php echo Form::input('site_details[city]',$o->site_details('city'),array('label'=>'City','placeholder'=>'City','required')); ?> <?php echo Form::input('site_details[city]',$o->site_details('city'),array('label'=>'City','placeholder'=>'City','required')); ?>
</div>
<div class="span1">
<?php echo Form::input('site_details[state]',$o->site_details('state'),array('label'=>'','class'=>'input-mini','placeholder'=>'State','required')); ?>
</div>
<div class="span1">
<?php echo Form::input('site_details[pcode]',$o->site_details('pcode'),array('label'=>'','class'=>'input-mini','placeholder'=>'Post Code','required')); ?>
</div>
</div> <!-- /row -->
<?php echo Form::select('country_id',ORM::factory('Country')->list_select(),$o->country_id,array('label'=>'Country','required')); ?>
<?php echo Form::input('site_details[phone]',$o->site_details('phone'),array('label'=>'Phone','type'=>'tel','class'=>'input-medium','placeholder'=>'Phone','required')); ?>
<?php echo Form::input('site_details[fax]',$o->site_details('fax'),array('label'=>'Fax','type'=>'tel','class'=>'input-medium','placeholder'=>'Fax','required')); ?>
<?php echo Form::input('site_details[email]',$o->site_details('email'),array('label'=>'Email','type'=>'email','class'=>'input-large','placeholder'=>'Email','required')); ?>
<?php echo Form::input('site_details[faqurl]',$o->site_details('faqurl'),array('label'=>'FAQ Url','type'=>'url','class'=>'input-xxlarge','placeholder'=>'FAQ Url')); ?>
<div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</div> </div>
</fieldset>
</div> <!-- /span --> <div class="span1">
</div> <!-- /row --> <?php echo Form::input('site_details[state]',$o->site_details('state'),array('label'=>'','class'=>'input-mini','placeholder'=>'State','required')); ?>
</div>
<div class="span1">
<?php echo Form::input('site_details[pcode]',$o->site_details('pcode'),array('label'=>'','class'=>'input-mini','placeholder'=>'Post Code','required')); ?>
</div>
</div> <!-- /row -->
<?php echo Form::select('country_id',ORM::factory('Country')->list_select(),$o->country_id,array('label'=>'Country','required')); ?>
<?php echo Form::input('site_details[phone]',$o->site_details('phone'),array('label'=>'Phone','type'=>'tel','class'=>'input-medium','placeholder'=>'Phone','required')); ?>
<?php echo Form::input('site_details[fax]',$o->site_details('fax'),array('label'=>'Fax','type'=>'tel','class'=>'input-medium','placeholder'=>'Fax','required')); ?>
<?php echo Form::input('site_details[email]',$o->site_details('email'),array('label'=>'Email','type'=>'email','class'=>'input-large','placeholder'=>'Email','required')); ?>
<?php echo Form::input('site_details[faqurl]',$o->site_details('faqurl'),array('label'=>'FAQ Url','type'=>'url','class'=>'input-xxlarge','placeholder'=>'FAQ Url')); ?>
</fieldset>
<div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</div>
</div> <!-- /span -->

View File

@ -1,30 +1,32 @@
<div class="row"> <div class="span11">
<div class="span10 offset1"> <fieldset>
<div class="row"> <legend>Application Setup</legend>
<div class="tabbable span9">
<ul class="nav nav-tabs">
<?php $c=0;foreach ($o->module_config_id($mid) as $id => $data) : ?>
<li class="<?php echo $c++ ? '' : 'active'; ?>"><a href="#tab<?php echo $c; ?>" data-toggle="tab"><?php echo $data['object']->display('name'); ?></a></li>
<?php endforeach ?>
</ul>
<div class="tab-content"> <div class="tabbable span9">
<?php $c=0;foreach ($o->module_config_id($mid) as $id => $data) : ?>
<ul class="nav nav-tabs">
<?php $c=0;foreach ($o->module_config_id($mid) as $id => $data) : ?>
<li class="<?php echo $c++ ? '' : 'active'; ?>"><a href="#tab<?php echo $c; ?>" data-toggle="tab"><?php echo $data['object']->display('name'); ?></a></li>
<?php endforeach ?>
</ul>
<div class="tab-content">
<?php $c=0;foreach ($o->module_config_id($mid) as $id => $data) : ?>
<div class="tab-pane <?php echo $c++ ? '' : 'active'; ?>" id="tab<?php echo $c; ?>"> <div class="tab-pane <?php echo $c++ ? '' : 'active'; ?>" id="tab<?php echo $c; ?>">
<?php foreach ($data['data'] as $k => $v) : ?> <?php foreach ($data['data'] as $k => $v) : ?>
<?php echo Form::input('module_config['.$id.']['.$k.']',$v,array('label'=>$k,'placeholder'=>$k)); ?> <?php echo Form::input('module_config['.$id.']['.$k.']',$v,array('label'=>$k,'placeholder'=>$k)); ?>
<?php endforeach ?> <?php endforeach ?>
</div> <!-- /tab-pane --> </div> <!-- /tab-pane -->
<?php endforeach ?> <!-- /StaticList_RecurSchedule --> <?php endforeach ?> <!-- /StaticList_RecurSchedule -->
</div> <!-- /tab-content --> </div> <!-- /tab-content -->
</div> <!-- /tabbable -->
</div> <!-- /row -->
<div class="row"> </div> <!-- /tabbable -->
<div class="offset2"> </fieldset>
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button> <div class="row">
</div> <div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div> </div>
</div> <!-- /span --> </div>
</div> <!-- /row --> </div> <!-- /span -->

View File

@ -149,7 +149,7 @@ class ADSL_Billing_Exetelvisp {
// @todo This could be optimised better. // @todo This could be optimised better.
foreach ($aso->services(TRUE) as $so) foreach ($aso->services(TRUE) as $so)
$this->haveService($so->plugin()->service_number,$so->plugin()->admin_plan()->adsl_supplier_plan->display('base_cost')); $this->haveService($so->plugin()->service_number,$so->plugin()->admin_plan()->supplier_plan->display('base_cost'));
return $this; return $this;
} }

View File

@ -90,7 +90,7 @@ class Controller_Admin_Adsl extends Controller_Adsl {
->title_icon('icon-th-list') ->title_icon('icon-th-list')
->body(Table::factory() ->body(Table::factory()
->jssort('traffic') ->jssort('traffic')
->data($apo->products()->find_all()) ->data($apo->products())
->columns(array( ->columns(array(
'id'=>'ID', 'id'=>'ID',
'title()'=>'Name', 'title()'=>'Name',

View File

@ -14,7 +14,7 @@ class Model_ADSL_Supplier extends ORM_OSB {
// Relationships // Relationships
protected $_has_many = array( protected $_has_many = array(
'adsl_supplier_plan'=>array('model'=>'ADSL_Supplier_Plan','foreign_key'=>'supplier_id','far_key'=>'id'), 'plan'=>array('model'=>'ADSL_Supplier_Plan','foreign_key'=>'supplier_id','far_key'=>'id'),
'traffic'=>array('model'=>'Service_Plugin_Adsl_Traffic','foreign_key'=>'supplier_id','far_key'=>'id'), 'traffic'=>array('model'=>'Service_Plugin_Adsl_Traffic','foreign_key'=>'supplier_id','far_key'=>'id'),
); );
@ -50,7 +50,7 @@ class Model_ADSL_Supplier extends ORM_OSB {
* Return a list of plans that this supplier makes available * Return a list of plans that this supplier makes available
*/ */
public function find_plans($active=TRUE) { public function find_plans($active=TRUE) {
return $active ? $this->adsl_supplier_plan->where_active() : $this->adsl_supplier_plan; return $active ? $this->plan->where_active() : $this->plan;
} }
/** /**
@ -63,8 +63,8 @@ class Model_ADSL_Supplier extends ORM_OSB {
foreach ($this->find_plans(FALSE)->find_all() as $aspo) { foreach ($this->find_plans(FALSE)->find_all() as $aspo) {
foreach ($aspo->plan->find_all() as $apo) { foreach ($aspo->plan->find_all() as $apo) {
foreach ($apo->products(FALSE)->find_all() as $po) { foreach ($apo->products(FALSE) as $po) {
foreach ($po->services($active)->find_all() as $so) { foreach ($po->service->list_active() as $so) {
array_push($result,$so); array_push($result,$so);
} }
} }

View File

@ -19,9 +19,6 @@ class Model_Product_Plugin_Adsl extends Model_Product_Plugin {
protected $_belongs_to = array( protected $_belongs_to = array(
'supplier_plan'=>array('model'=>'ADSL_Supplier_Plan','foreign_key'=>'adsl_supplier_plan_id'), 'supplier_plan'=>array('model'=>'ADSL_Supplier_Plan','foreign_key'=>'adsl_supplier_plan_id'),
); );
protected $_has_many = array(
'product'=>array('far_key'=>'id','foreign_key'=>'prod_plugin_data'),
);
/** /**
* Filters used to format the display of values into friendlier values * Filters used to format the display of values into friendlier values
@ -59,14 +56,6 @@ class Model_Product_Plugin_Adsl extends Model_Product_Plugin {
'extra_up_offpeak', 'extra_up_offpeak',
); );
// Map the table fields
private $_map = array(
'base_up_offpeak'=>'extra_up_offpeak',
'base_down_offpeak'=>'extra_down_offpeak',
'base_up_peak'=>'extra_up_peak',
'base_down_peak'=>'extra_down_peak',
);
// Our required abstract methods // Our required abstract methods
public function cost($annual=FALSE) { public function cost($annual=FALSE) {
@ -75,25 +64,24 @@ class Model_Product_Plugin_Adsl extends Model_Product_Plugin {
return $annual ? $x*12 : $x; return $annual ? $x*12 : $x;
} }
public function feature_summary() {
return View::factory(sprintf('product/plugin/%s/feature_summary',$this->plugin()))
->set('o',$this);
}
// @todo Select the ADSL Plan for this product. // @todo Select the ADSL Plan for this product.
public function render_edit() { public function render_edit() {
return ''; return '';
} }
public function render_order() {
return View::factory(sprintf('product/plugin/%s/order',$this->plugin()));
}
public function supplier() { public function supplier() {
return $this->supplier_plan->supplier_id; return $this->supplier_plan->supplier_id;
} }
/** LOCAL FUNCTIONS **/ // Local functions
// Map the table fields
private $_map = array(
'base_up_offpeak'=>'extra_up_offpeak',
'base_down_offpeak'=>'extra_down_offpeak',
'base_up_peak'=>'extra_up_peak',
'base_down_peak'=>'extra_down_peak',
);
/** /**
* Calculate the allowance array or traffic used array * Calculate the allowance array or traffic used array
@ -204,19 +192,5 @@ class Model_Product_Plugin_Adsl extends Model_Product_Plugin {
return TRUE; return TRUE;
} }
/**
* Get all the products using this plan
*/
public function products($active=FALSE) {
$x = ORM::factory('Product')
->where('prod_plugin_file','=','ADSL')
->and_where('prod_plugin_data','=',$this);
if ($active)
$x->where_active();
return $x;
}
} }
?> ?>

View File

@ -15,10 +15,6 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
protected $_updated_column = FALSE; protected $_updated_column = FALSE;
// Relationships // Relationships
protected $_belongs_to = array(
'service'=>array(),
);
protected $_has_one = array( protected $_has_one = array(
'provided_plan'=>array('model'=>'Product_Plugin_Adsl','far_key'=>'provided_adsl_plan_id','foreign_key'=>'id'), 'provided_plan'=>array('model'=>'Product_Plugin_Adsl','far_key'=>'provided_adsl_plan_id','foreign_key'=>'id'),
); );
@ -36,7 +32,10 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
), ),
); );
protected $_save_message = TRUE;
// Required abstract functions // Required abstract functions
public function expire() { public function expire() {
// We'll leave it to the Service record to determine when this service expires // We'll leave it to the Service record to determine when this service expires
return NULL; return NULL;
@ -46,43 +45,15 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
return $this->service_number; return $this->service_number;
} }
public function username_value() { public function password() {
return $this->service_username;
}
public function password_value() {
return $this->service_password; return $this->service_password;
} }
// Override our parent function to include some JS. public function username() {
public function admin_update() { return $this->service_username;
Script::factory()
->type('stdin')
->data('
$(document).ready(function() {
$("#service_connect_date_label").datepicker({
autoclose : true,
startDate : now,
format : "dd-M-yyyy",
todayBtn : true,
}).on("hide",function(ev) {
$("input[id=service_connect_date]").val(ev.date.valueOf()/1000);
});
$("#service_contract_date_label").datepicker({
autoclose : true,
startDate : now,
format : "dd-M-yyyy",
todayBtn : true,
}).on("hide",function(ev) {
$("input[id=service_contract_date]").val(ev.date.valueOf()/1000);
});
});
');
return parent::admin_update();
} }
/** LOCAL FUNCTIONS **/ // Local functions
/** /**
* If we override the plan that the customers gets (from what the supplier provides). * If we override the plan that the customers gets (from what the supplier provides).
@ -99,7 +70,8 @@ $(document).ready(function() {
} }
public function contract_date_end($format=FALSE) { public function contract_date_end($format=FALSE) {
$x = strtotime(sprintf('+%s months',$this->contract_term),$this->service_contract_date); // ADSL Contract Terms are held in the ADSL Plan
$x = strtotime(sprintf('+%s months',$this->service->plugin()->contract_term),$this->service_contract_date);
return $format ? Config::date($x) : $x; return $format ? Config::date($x) : $x;
} }
@ -475,6 +447,7 @@ $(document).ready(function() {
->where_open() ->where_open()
->and_where($this->_table_name.'.service_number','like','%'.$term.'%') ->and_where($this->_table_name.'.service_number','like','%'.$term.'%')
->or_where($this->_table_name.'.service_address','like','%'.$term.'%') ->or_where($this->_table_name.'.service_address','like','%'.$term.'%')
->or_where($this->_table_name.'.ipaddress','like','%'.$term.'%')
->where_close(); ->where_close();
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options); return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);

View File

@ -42,10 +42,10 @@ class Service_Traffic_ADSL_iiNetADSL extends Service_Traffic_ADSL {
// Find our services that need to be collected this way. // Find our services that need to be collected this way.
$update = array(); $update = array();
foreach ($this->so->services() as $so) { foreach ($this->aso->services() as $so) {
if ($so->service_adsl->service_stats_collect AND $so->service_adsl->service_stats_lastupdate < $date) { if ($so->service_adsl->service_stats_collect AND $so->service_adsl->service_stats_lastupdate < $date) {
$lastperiod = ''; $lastperiod = '';
for ($servicedate=date('Y-m-d',strtotime($this->so->stats_lastupdate.'+1 day')); for ($servicedate=date('Y-m-d',strtotime($this->aso->stats_lastupdate.'+1 day'));
$servicedate <= $this->today; $servicedate <= $this->today;
$servicedate=date('Y-m-d',strtotime('+1 day',strtotime($servicedate)))) { $servicedate=date('Y-m-d',strtotime('+1 day',strtotime($servicedate)))) {
@ -67,7 +67,7 @@ class Service_Traffic_ADSL_iiNetADSL extends Service_Traffic_ADSL {
if ($debug AND file_exists($debug_file)) if ($debug AND file_exists($debug_file))
$data = file_get_contents($debug_file); $data = file_get_contents($debug_file);
else else
$data = Remote::get($this->so->stats_url,$this->curlopts+array(CURLOPT_POSTFIELDS=>$postfields)); $data = Remote::get($this->aso->stats_url,$this->curlopts+array(CURLOPT_POSTFIELDS=>$postfields));
// @todo There exists a possibility to skip a month, if we get a bad fetch on a previous month. // @todo There exists a possibility to skip a month, if we get a bad fetch on a previous month.
if ($data) if ($data)

View File

@ -1,128 +1,146 @@
<div class="row"> <div class="span6">
<div class="span6"> <fieldset>
<legend>ADSL Plan Details</legend>
<div class="row"> <div class="row">
<div class="span2"> <div class="tabbable span5">
<?php echo Form::input('base_down_peak',$o->base_down_peak,array('label'=>'Base Down Peak','class'=>'span1')); ?> <ul class="nav nav-tabs">
</div> <li class="active"><a href="#tab1" data-toggle="tab">Peak</a></li>
<div class="span2"> <li><a href="#tab2" data-toggle="tab">Offpeak</a></li>
<?php echo Form::input('extra_down_peak',$o->extra_down_peak,array('label'=>'Extra','class'=>'span1')); ?> </ul>
</div>
<div class="tab-content">
<div class="tab-pane active" id="tab1">
<div class="row">
<div class="span2">
<?php echo Form::input('base_down_peak',$o->base_down_peak,array('label'=>'Base Down','class'=>'span1')); ?>
</div>
<div class="span2">
<?php echo Form::input('extra_down_peak',$o->extra_down_peak,array('label'=>'Extra','class'=>'span1')); ?>
</div>
</div>
<div class="row">
<div class="span2">
<?php echo Form::input('base_up_peak',$o->base_up_peak,array('label'=>'Base Up','class'=>'span1')); ?>
</div>
<div class="span2">
<?php echo Form::input('extra_up_peak',$o->extra_up_peak,array('label'=>'Extra','class'=>'span1')); ?>
</div>
</div>
</div> <!-- /tab-pane -->
<div class="tab-pane" id="tab2">
<div class="row">
<div class="span2">
<?php echo Form::input('base_down_offpeak',$o->base_down_offpeak,array('label'=>'Base Down','class'=>'span1')); ?>
</div>
<div class="span2">
<?php echo Form::input('extra_down_offpeak',$o->extra_down_offpeak,array('label'=>'Extra','class'=>'span1')); ?>
</div>
</div>
<div class="row">
<div class="span2">
<?php echo Form::input('base_up_offpeak',$o->base_up_offpeak,array('label'=>'Base Up','class'=>'span1')); ?>
</div>
<div class="span2">
<?php echo Form::input('extra_up_offpeak',$o->extra_up_offpeak,array('label'=>'Extra','class'=>'span1')); ?>
</div>
</div>
</div> <!-- /tab-pane -->
</div> <!-- /tab-content -->
</div> <!-- /tabbable -->
</div> <!-- /row -->
<div class="row">
<?php echo Form::input('contract_term',$o->contract_term,array('label'=>'Contract Term','class'=>'span1')); ?>
</div> </div>
<div class="row"> <div class="row">
<div class="span2"> <?php echo StaticList_YesNo::form('extra_charged',$o->extra_charged,FALSE,array('label'=>'Extra Charged','class'=>'span1')); ?>
<?php echo Form::input('base_down_offpeak',$o->base_down_offpeak,array('label'=>'Base Down Off Peak','class'=>'span1')); ?>
</div>
<div class="span2">
<?php echo Form::input('extra_down_offpeak',$o->extra_down_offpeak,array('label'=>'Extra','class'=>'span1')); ?>
</div>
</div> </div>
<div class="row"> <div class="row">
<div class="span2"> <?php echo Form::select('adsl_supplier_plan_id',ORM::factory('ADSL_Supplier_Plan')->list_select(),$o->adsl_supplier_plan_id,array('label'=>'Supplier Plan','class'=>'span4')); ?>
<?php echo Form::input('base_up_peak',$o->base_up_peak,array('label'=>'Base Up Peak','class'=>'span1')); ?>
</div>
<div class="span2">
<?php echo Form::input('extra_up_peak',$o->extra_up_peak,array('label'=>'Extra','class'=>'span1')); ?>
</div>
</div> </div>
</fieldset>
<div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</div>
</div> <!-- /span -->
<div class="span5">
<fieldset>
<legend>Supplier Details</legend>
<div class="dl-horizontal">
<dt>Supplier</dt>
<dd><?php echo $o->supplier_plan->supplier->name; ?></dd>
<dt>Allowance</dt>
<dd><?php echo $o->allowance($o->supplier_plan->traffic_data(),TRUE); ?></dd>
<dt>Cost</dt>
<dd><?php echo $o->supplier_plan->display('base_cost'); ?></dd>
<dt>Excess</dt>
<dd><?php echo $o->supplier_plan->cost_extra($o->allowance($o->supplier_plan->traffic_data()),TRUE); ?></dd>
<dt>Speed</dt>
<dd><?php echo $o->supplier_plan->speed; ?></dd>
</div>
</fieldset>
</div> <!-- /span -->
<div class="span5">
<fieldset>
<legend>Test Traffic</legend>
<div class="row"> <div class="row">
<div class="span2"> <div class="span2">
<?php echo Form::input('base_up_offpeak',$o->base_up_offpeak,array('label'=>'Base Up Off Peak','class'=>'span1')); ?> <?php echo Form::input('test[base_down_peak]',10000,array('label'=>'Down Peak','class'=>'span1')); ?>
</div> </div>
<div class="span2"> <div class="span2">
<?php echo Form::input('extra_up_offpeak',$o->extra_up_offpeak,array('label'=>'Extra','class'=>'span1')); ?> <?php echo Form::input('test[base_down_offpeak]',30000,array('label'=>'Offpeak','class'=>'span1')); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="span2"> <div class="span2">
<?php echo Form::input('contract_term',$o->contract_term,array('label'=>'Contract Term','class'=>'span1')); ?> <?php echo Form::input('test[base_up_peak]',20000,array('label'=>'Up Peak','class'=>'span1')); ?>
</div>
<div class="span2">
<?php echo Form::input('test[base_up_offpeak]',40000,array('label'=>'Offpeak','class'=>'span1')); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="span2"> <div class="span2">
<?php echo StaticList_YesNo::form('extra_charged',$o->extra_charged,FALSE,array('label'=>'Extra Charged','class'=>'span1')); ?> <?php echo Form::checkbox('test[charge]',1,FALSE,array('label'=>'Charges','class'=>'span1')); ?>
</div> </div>
</div> </div>
</fieldset>
<div class="row"> <?php if ($test_result) : ?>
<div class="span6">
<?php echo Form::select('adsl_supplier_plan_id',ORM::factory('ADSL_Supplier_Plan')->list_select(),$o->adsl_supplier_plan_id,array('label'=>'Supplier Plan')); ?>
</div>
</div>
<div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</div>
</div> <!-- /span -->
<div class="span5">
<fieldset> <fieldset>
<legend>Supplier Details</legend> <legend>Test Traffic Result</legend>
<div class="dl-horizontal">
<dt>Supplier</dt>
<dd><?php echo $o->supplier_plan->supplier->name; ?></dd>
<dt>Allowance</dt> <div class="dl-horizontal">
<dd><?php echo $o->allowance($o->supplier_plan->traffic_data(),TRUE); ?></dd> <?php foreach ($test_result as $k=>$v) : ?>
<dt><?php echo $k; ?></dt>
<dd><?php echo $v; ?></dd>
<?php endforeach ?>
<dt>Cost</dt> <dt>Has Offpeak?</dt>
<dd><?php echo $o->supplier_plan->display('base_cost'); ?></dd> <dd><?php echo $o->hasOffpeak(); ?></dd>
<dt>Excess</dt>
<dd><?php echo $o->supplier_plan->cost_extra($o->allowance($o->supplier_plan->traffic_data()),TRUE); ?></dd>
<dt>Speed</dt>
<dd><?php echo $o->supplier_plan->speed; ?></dd>
</div>
</fieldset>
</div> <!-- /span -->
<div class="span5">
<fieldset>
<legend>Test Traffic</legend>
<div class="row">
<div class="span2">
<?php echo Form::input('test[base_down_peak]',10000,array('label'=>'Down Peak','class'=>'span1')); ?>
</div>
<div class="span2">
<?php echo Form::input('test[base_down_offpeak]',30000,array('label'=>'Offpeak','class'=>'span1')); ?>
</div>
</div>
<div class="row">
<div class="span2">
<?php echo Form::input('test[base_up_peak]',20000,array('label'=>'Up Peak','class'=>'span1')); ?>
</div>
<div class="span2">
<?php echo Form::input('test[base_up_offpeak]',40000,array('label'=>'Offpeak','class'=>'span1')); ?>
</div>
</div>
<div class="row">
<div class="span2">
<?php echo Form::checkbox('test[charge]',1,FALSE,array('label'=>'Charges','class'=>'span1')); ?>
</div>
</div> </div>
</fieldset> </fieldset>
<?php endif ?>
<?php if ($test_result) : ?> </div> <!-- /span -->
<fieldset>
<legend>Test Traffic Result</legend>
<div class="dl-horizontal">
<?php foreach ($test_result as $k=>$v) : ?>
<dt><?php echo $k; ?></dt>
<dd><?php echo $v; ?></dd>
<?php endforeach ?>
<dt>Has Offpeak?</dt>
<dd><?php echo $o->hasOffpeak(); ?></dd>
</div>
</fieldset>
<?php endif ?>
</div> <!-- /span -->
</div> <!-- /row -->

View File

@ -31,5 +31,4 @@
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>
</tbody> </tbody>
</table> </table>

View File

@ -14,14 +14,14 @@
<?php foreach ($aso->services(TRUE) as $so) : ?> <?php foreach ($aso->services(TRUE) as $so) : ?>
<?php $p = $so->plugin(); $po = $p->admin_plan(); $service_number = $p->service_number; ?> <?php $p = $so->plugin(); $po = $p->admin_plan(); $service_number = $p->service_number; ?>
<tr class="<?php echo $o->charge($service_number) == $po->adsl_supplier_plan->display('base_cost') ? '' : 'error'; ?>"> <tr class="<?php echo $o->charge($service_number) == $po->supplier_plan->display('base_cost') ? '' : 'error'; ?>">
<td><?php echo $service_number; ?></td> <td><?php echo $service_number; ?></td>
<td><?php echo HTML::anchor(URL::link('user','service/view/'.$so->id),$so->id); ?></td> <td><?php echo HTML::anchor(URL::link('user','service/view/'.$so->id),$so->id); ?></td>
<td><?php echo $po->adsl_supplier_plan->name().($p->provided_adsl_plan_id ? '*' : ''); ?></td> <td><?php echo $po->supplier_plan->name().($p->provided_adsl_plan_id ? '*' : ''); ?></td>
<td><?php echo $p->contract_date_start(TRUE); ?></td> <td><?php echo $p->contract_date_start(TRUE); ?></td>
<td><?php echo $p->contract_date_end(TRUE); ?></td> <td><?php echo $p->contract_date_end(TRUE); ?></td>
<td><?php echo $po->adsl_supplier_plan->display('base_cost'); ?></td> <td><?php echo $po->supplier_plan->display('base_cost'); ?></td>
<td><?php echo Currency::display($o->charge($service_number)); ?></td> <td><?php echo Currency::display($o->charge($service_number)); ?></td>
<td><?php echo Currency::display($o->excess($service_number)); ?></td> <td><?php echo Currency::display($o->excess($service_number)); ?></td>

View File

@ -1,12 +1,10 @@
<div class="row"> <div class="span11">
<div class="span9 offset1"> <fieldset>
<fieldset>
<legend>Exetel VISP Billing</legend> <legend>Exetel VISP Billing</legend>
<?php echo Form::hidden('sid',$_POST['sid']); ?> <?php echo Form::hidden('sid',$_POST['sid']); ?>
<?php echo Form::file('csv',array('label'=>'Invoice File','required')); ?> <?php echo Form::file('csv',array('label'=>'Invoice File','required')); ?>
</fieldset> </fieldset>
<?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?> <?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?>
</div> <!-- /span --> </div> <!-- /span -->
</div> <!-- /row -->

View File

@ -4,72 +4,76 @@
</div> <!-- /page-title --> </div> <!-- /page-title -->
<div id="container"> <div id="container">
<div class="row"> <div class="tablewrapper">
<div class="grid-12"> <table class="plan plain">
<div class="tablewrapper"> <tr class="plan-header">
<table class="plan plain"> <th class="plan-title">Plan Name</th>
<tr class="plan-header">
<th class="plan-title">Plan Name</th>
<?php $c=0; foreach ($o->products() as $po) : ?>
<td class="plan-title"><?php echo $po->title(); ?> <small>(<?php echo $po->id; ?>)</small></td>
<?php endforeach ?>
</tr>
<tr class="plan-header"> <?php foreach ($o->products() as $po) : ?>
<th class="plan-price" >Price</th> <td class="plan-title"><?php echo $po->title(); ?> <small>(<?php echo $po->id; ?>)</small></td>
<?php $c=0; foreach ($o->products() as $po) : ?> <?php endforeach ?>
<?php $x = (string)Currency::display($po->price(0,1,'price_base',TRUE)); ?> </tr>
<td class="plan-price">
<span class="note">$</span><?php echo substr($x,0,strpos($x,'.')); ?><span class="cents"> .<?php echo substr($x,-2,strpos($x,'.')); ?></span><span class="term"><?php echo StaticList_RecurSchedule::get(1); ?></span>
</td>
<?php endforeach ?>
</tr>
<tr class="plan-features"> <tr class="plan-header">
<th>Connection</th> <th class="plan-price" >Price</th>
<?php $c=0; foreach ($o->products() as $po) : ?>
<td><span class="note">$</span><?php echo Currency::display($po->price(0,1,'price_setup',TRUE)); ?></td>
<?php endforeach ?>
</tr>
<tr class="plan-features"> <?php foreach ($o->products() as $po) : ?>
<th>Speed</th> <?php $go = $po->price_best($o->recur_schedule,TRUE); ?>
<?php $c=0; foreach ($o->products() as $po) : ?> <?php $price = (string)Currency::display($po->price($go->id,$o->recur_schedule,'base',TRUE)); ?>
<td><?php echo $po->plugin()->supplier_plan->display('speed'); ?></td>
<?php endforeach ?>
</tr>
<tr class="plan-features"> <td class="plan-price">
<th>Peak Downloads</th> <span class="note">$</span><?php echo substr($price,0,strpos($price,'.')); ?><span class="cents"> .<?php echo substr($price,-2,strpos($price,'.')); ?></span><span class="term"><?php echo StaticList_RecurSchedule::get($o->recur_schedule); ?></span>
<?php $c=0; foreach ($o->products() as $po) : ?> </td>
<td><?php echo $po->plugin()->base_down_peak/1000; ?><span class="normal">GB</span></td> <?php endforeach ?>
<?php endforeach ?> </tr>
</tr>
<?php if ($po->plugin()->base_down_offpeak) : ?> <tr class="plan-features">
<tr class="plan-features"> <th>Connection</th>
<?php foreach ($o->products() as $po) : ?>
<?php $go = $po->price_best($o->recur_schedule,TRUE); ?>
<td><span class="note">$</span><?php echo Currency::display($po->price($go->id,$o->recur_schedule,'setup',TRUE)); ?></td>
<?php endforeach ?>
</tr>
<tr class="plan-features">
<th>Speed</th>
<?php foreach ($o->products() as $po) : ?>
<td><?php echo $po->plugin()->supplier_plan->display('speed'); ?></td>
<?php endforeach ?>
</tr>
<tr class="plan-features">
<th>Peak Downloads</th>
<?php foreach ($o->products() as $po) : ?>
<td><?php echo $po->plugin()->base_down_peak/1000; ?><span class="normal">GB</span></td>
<?php endforeach ?>
</tr>
<?php if ($po->plugin()->base_down_offpeak) : ?>
<tr class="plan-features">
<th>OffPeak Downloads</th> <th>OffPeak Downloads</th>
<?php $c=0; foreach ($o->products() as $po) : ?> <?php foreach ($o->products() as $po) : ?>
<td><?php echo $po->plugin()->base_down_offpeak/1000; ?><span class="normal">GB</span></td> <td><?php echo $po->plugin()->base_down_offpeak/1000; ?><span class="normal">GB</span></td>
<?php endforeach ?> <?php endforeach ?>
<?php endif ?> </tr>
<?php endif ?>
<tr class="plan-features"> <tr class="plan-features">
<th>Extra Traffic</th> <th>Extra Traffic</th>
<?php $c=0; foreach ($o->products() as $po) : ?> <?php foreach ($o->products() as $po) : ?>
<td><span class="note">$</span><?php echo $po->plugin()->display('extra_down_peak'); ?><span class="normal">/GB</span></td> <td><span class="note">$</span><?php echo $po->plugin()->display('extra_down_peak'); ?><span class="normal">/GB</span></td>
<?php endforeach ?> <?php endforeach ?>
</tr> </tr>
<tr class="plan-features"> <tr class="plan-features">
<th>Contract Term</th> <th>Contract Term</th>
<?php $c=0; foreach ($o->products() as $po) : ?> <?php foreach ($o->products() as $po) : ?>
<td><?php echo $po->plugin()->display('contract_term'); ?> <span class="normal">mths</span></td> <td><?php echo $po->plugin()->display('contract_term'); ?> <span class="normal">mths</span></td>
<?php endforeach ?> <?php endforeach ?>
</tr> </tr>
</table> </table>
</div> <!-- /tablewrapper --> </div> <!-- /tablewrapper -->
</div> <!-- /grid -->
</div> <!-- /row -->
</div> <!-- /container --> </div> <!-- /container -->

View File

@ -4,58 +4,60 @@
</div> <!-- /page-title --> </div> <!-- /page-title -->
<div id="container"> <div id="container">
<div class="row"> <div class="pricing-plans plans-4">
<div class="grid-12"> <div class="row">
<div class="pricing-plans plans-4"> <?php $c=0; foreach ($o->products() as $po) : ?>
<div class="row"> <?php $go = $po->price_best($o->recur_schedule,TRUE); ?>
<?php $c=0; foreach ($o->products() as $po) : ?> <?php $price = (string)Currency::display($po->price($go->id,$o->recur_schedule,'base',TRUE)); ?>
<?php if (! ($c++%4) AND $c>1) : ?>
</div> <!-- /row -->
<hr class="row-divider" />
<div class="row">
<?php endif ?>
<div class="plan-container"> <?php if (is_null($price)) continue; ?>
<div class="plan">
<div class="plan-header"> <?php if (! ($c++%4) AND $c>1) : ?>
</div> <!-- /row -->
<hr class="row-divider" />
<div class="row">
<?php endif ?>
<div class="plan-title"> <div class="plan-container">
<?php echo $po->title(); ?> <small>(<?php echo $po->id; ?>)</small> <div class="plan">
</div> <!-- /plan-title -->
<div class="plan-price"> <div class="plan-header">
<?php $x = (string)Currency::display($po->price(0,1,'price_base',TRUE)); ?>
<span class="note">$</span><?php echo substr($x,0,strpos($x,'.')); ?><span class="cents"> .<?php echo substr($x,-2,strpos($x,'.')); ?></span><span class="term"><?php echo StaticList_RecurSchedule::get(1); ?></span>
</div> <!-- /plan-price -->
</div> <!-- /plan-header --> <div class="plan-title">
<?php echo $po->title(); ?> <small>(<?php echo $po->id; ?>)</small>
</div> <!-- /plan-title -->
<div class="plan-features"> <div class="plan-price">
<ul> <span class="note">$</span><?php echo substr($price,0,strpos($price,'.')); ?><span class="cents"> .<?php echo substr($price,-2,strpos($price,'.')); ?></span><span class="term"><?php echo StaticList_RecurSchedule::get($o->recur_schedule); ?></span>
<li><span class="note">$</span><strong><?php echo Currency::display($po->price(0,1,'price_setup',TRUE)); ?></strong> Connection</li> </div> <!-- /plan-price -->
<li><strong><?php echo $po->plugin()->supplier_plan->display('speed'); ?></strong> Speed</li>
<li><strong><?php echo $po->plugin()->base_down_peak/1000; ?></strong>GB Peak Downloads</li> </div> <!-- /plan-header -->
<?php if ($po->plugin()->base_down_offpeak) : ?>
<div class="plan-features">
<ul>
<li><span class="note">$</span><strong><?php echo Currency::display($po->price($go->id,$o->recur_schedule,'setup',TRUE)); ?></strong> Connection</li>
<li><strong><?php echo $po->plugin()->supplier_plan->display('speed'); ?></strong> Speed</li>
<li><strong><?php echo $po->plugin()->base_down_peak/1000; ?></strong>GB Peak Downloads</li>
<?php if ($po->plugin()->base_down_offpeak) : ?>
<li><strong><?php echo $po->plugin()->base_down_offpeak/1000; ?></strong>GB OffPeak Downloads</li> <li><strong><?php echo $po->plugin()->base_down_offpeak/1000; ?></strong>GB OffPeak Downloads</li>
<?php endif ?> <?php endif ?>
<li><span class="note">$</span><strong><?php echo $po->plugin()->display('extra_down_peak'); ?></strong>/GB Extra Traffic</li>
<li><strong><?php echo $po->plugin()->display('contract_term'); ?></strong> Months Contract</li>
</ul>
</div> <!-- /plan-features -->
<div class="plan-actions"> <li><span class="note">$</span><strong><?php echo $po->plugin()->display('extra_down_peak'); ?></strong>/GB Extra Traffic</li>
<!-- <li><strong><?php echo $po->plugin()->display('contract_term'); ?></strong> Months Contract</li>
<a href="javascript:;" class="btn">Purchase Now</a> </ul>
--> </div> <!-- /plan-features -->
</div> <!-- /plan-actions -->
</div> <!-- /plan --> <div class="plan-actions">
</div> <!-- /plan-container --> <!--
<?php endforeach ?> <a href="javascript:;" class="btn">Purchase Now</a>
-->
</div> <!-- /plan-actions -->
</div> <!-- /row --> </div> <!-- /plan -->
</div> <!-- /pricing-plans --> </div> <!-- /plan-container -->
</div> <!-- /grid --> <?php endforeach ?>
</div> <!-- /row -->
</div> <!-- /row -->
</div> <!-- /pricing-plans -->
</div> <!-- /container --> </div> <!-- /container -->

View File

@ -1,4 +1,4 @@
<fieldset class="span6"> <fieldset>
<legend>ADSL Features</legend> <legend>ADSL Features</legend>
<div class="dl-horizontal"> <div class="dl-horizontal">

View File

@ -1,45 +1,39 @@
<div class="row"> <fieldset>
<div class="span6"> <legend>ADSL Service Details</legend>
<div class="row">
<?php echo Form::input('plugin[service_number]',$o->service_number,array('class'=>'span2','label'=>'Service Number','placeholder'=>'Service Number')); ?> <?php echo Form::input('plugin[service_number]',$o->service_number,array('class'=>'span2','label'=>'Service Number','placeholder'=>'Service Number')); ?>
</div> </div> <!-- /row -->
</div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span6">
<?php echo Form::input('plugin[service_address]',$o->service_address,array('class'=>'span6','label'=>'Service Address','placeholder'=>'Service Address')); ?> <?php echo Form::input('plugin[service_address]',$o->service_address,array('class'=>'span6','label'=>'Service Address','placeholder'=>'Service Address')); ?>
</div> </div> <!-- /row -->
</div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span5 input-append date" id="service_connect_date_label"> <div class="input-append date" id="service_connect_date_label">
<?php echo Form::input('service_connect_date_label',$o->display('service_connect_date'),array('class'=>'span2','label'=>'Service Connected','add-on'=>'<i class="icon-calendar"></i>','disabled')); ?> <?php echo Form::input('service_connect_date_label',$o->display('service_connect_date'),array('class'=>'span2','label'=>'Service Connected','add-on'=>'<i class="icon-calendar"></i>','disabled')); ?>
</div> </div>
<?php echo Form::hidden('plugin[service_connect_date]',$o->service_connect_date,array('id'=>'service_connect_date')); ?> <?php echo Form::hidden('plugin[service_connect_date]',$o->service_connect_date,array('id'=>'service_connect_date')); ?>
</div> <!-- /row --> </div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span5 input-append date" id="service_contract_date_label"> <div class="input-append date" id="service_contract_date_label">
<?php echo Form::input('service_contract_date_label',$o->display('service_contract_date'),array('class'=>'span2','label'=>'Contract Start Date','add-on'=>'<i class="icon-calendar"></i>','disabled')); ?> <?php echo Form::input('service_contract_date_label',$o->display('service_contract_date'),array('class'=>'span2','label'=>'Contract Start Date','add-on'=>'<i class="icon-calendar"></i>','disabled')); ?>
</div> </div>
<?php echo Form::hidden('plugin[service_contract_date]',$o->service_contract_date,array('id'=>'service_contract_date')); ?> <?php echo Form::hidden('plugin[service_contract_date]',$o->service_contract_date,array('id'=>'service_contract_date')); ?>
</div> <!-- /row --> </div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span6">
<?php echo Form::input('plugin[service_username]',$o->service_username,array('class'=>'span6','label'=>'Service Username','placeholder'=>'Service Username')); ?> <?php echo Form::input('plugin[service_username]',$o->service_username,array('class'=>'span6','label'=>'Service Username','placeholder'=>'Service Username')); ?>
</div> </div> <!-- /row -->
</div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span6">
<?php echo Form::input('plugin[service_password]',$o->service_password,array('class'=>'span6','label'=>'Service Password','placeholder'=>'Service Password')); ?> <?php echo Form::input('plugin[service_password]',$o->service_password,array('class'=>'span6','label'=>'Service Password','placeholder'=>'Service Password')); ?>
</div> </div> <!-- /row -->
</div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span6">
<?php echo Form::input('plugin[ipaddress]',$o->ipaddress,array('class'=>'span6','label'=>'Service IP Address','placeholder'=>'Service IP Address')); ?> <?php echo Form::input('plugin[ipaddress]',$o->ipaddress,array('class'=>'span6','label'=>'Service IP Address','placeholder'=>'Service IP Address')); ?>
</div> </div> <!-- /row -->
</div> <!-- /row --> </fieldset>

View File

@ -5,6 +5,7 @@
<th><?php echo $o->friendly($i); ?></th> <th><?php echo $o->friendly($i); ?></th>
<?php endforeach ?> <?php endforeach ?>
</tr></thead> </tr></thead>
<tbody> <tbody>
<?php foreach ($td as $i => $details) : ?> <?php foreach ($td as $i => $details) : ?>
<tr> <tr>

View File

@ -1,80 +1,79 @@
<fieldset class="span5"> <div class="span6">
<legend>Service Details</legend> <fieldset>
<legend>Service Details</legend>
<div class="dl-horizontal">
<dt>Service Number</dt>
<dd><?php echo $o->display('service_number'); ?></dd>
<dt>Service Address</dt>
<dd><?php echo $o->display('service_address'); ?></dd>
<dt>Connect Date</dt>
<dd><?php echo $o->display('service_connect_date'); ?></dd>
<dt>Contract Term</dt>
<dd><?php echo $o->display('contract_term'); ?></dd>
<dt>Contract End Date</dt>
<dd><?php echo $o->contract_date_end(TRUE); ?></dd>
<dt>Service Username</dt>
<dd><?php echo $o->display('service_username'); ?></dd>
<dt>Service Password</dt>
<dd><?php echo $o->display('service_password'); ?></dd>
<dt>Service IP</dt>
<dd><?php echo $o->ipaddress(); ?></dd>
<?php if ($o->hasOffPeak() AND $o->offpeak_start AND $o->offpeak_end) : ?>
<dt>Offpeak Period</dt>
<dd><?php printf('%s-%s',$o->offpeak_start,$o->offpeak_end); ?></dd>
<?php endif ?>
</div> <!-- dl-horizontal -->
</fieldset>
<fieldset class="span6">
<legend>Traffic Usage</legend>
<div class="dl-horizontal">
<dt>Last Month</dt>
<dd>&nbsp;<?php echo $o->traffic_month(strtotime('last month'),TRUE,TRUE); ?></dd>
<dt>This Month</dt>
<dd>&nbsp;<?php echo $o->traffic_month(strtotime('yesterday'),TRUE,TRUE); ?></dd>
<dt>Excess Traffic</dt>
<dd>&nbsp;$<?php echo $o->traffic_excess(strtotime('yesterday'),TRUE,TRUE); ?></dd>
</div> <!-- dl-horizontal -->
</fieldset>
<fieldset class="span6">
<form class="form-inline" method="POST">
<div class="dl-horizontal"> <div class="dl-horizontal">
<dt>View Traffic for</dt> <dt>Service Number</dt>
<dd><?php echo Form::select('month',array_merge(array(''),$o->get_traffic_months()),(isset($_POST['month']) ? $_POST['month'] : ''),array('class'=>'input-small','nocg'=>TRUE)); ?> <dd><?php echo $o->display('service_number'); ?></dd>
<button type="submit" class="btn btn-mini">Submit</button></dd>
<dt>Service Address</dt>
<dd><?php echo $o->display('service_address'); ?></dd>
<dt>Connect Date</dt>
<dd><?php echo $o->display('service_connect_date'); ?></dd>
<dt>Contract Term</dt>
<dd><?php echo $o->display('contract_term'); ?></dd>
<dt>Contract End Date</dt>
<dd><?php echo $o->contract_date_end(TRUE); ?></dd>
<dt>Service Username</dt>
<dd><?php echo $o->display('service_username'); ?></dd>
<dt>Service Password</dt>
<dd><?php echo $o->display('service_password'); ?></dd>
<dt>Service IP</dt>
<dd><?php echo $o->ipaddress(); ?></dd>
<?php if ($o->hasOffPeak() AND $o->offpeak_start AND $o->offpeak_end) : ?>
<dt>Offpeak Period</dt>
<dd><?php printf('%s-%s',$o->offpeak_start,$o->offpeak_end); ?></dd>
<?php endif ?>
</div> <!-- dl-horizontal --> </div> <!-- dl-horizontal -->
</form> </fieldset>
</div> <!-- /span -->
<div class="tabbable"> <div class="span6">
<ul class="nav nav-tabs"> <fieldset>
<li class="active"><a href="#tab1" data-toggle="tab">Graph</a></li> <legend>Traffic Usage</legend>
<li class=""><a href="#tab2" data-toggle="tab">Table</a></li>
</ul>
<div class="tab-content"> <div class="dl-horizontal">
<div class="tab-pane active" id="tab1"> <dt>Last Month</dt>
<?php echo $o->traffic_graph(isset($_POST['month']) ? $_POST['month'] : ''); ?> <dd>&nbsp;<?php echo $o->traffic_month(strtotime('last month'),TRUE,TRUE); ?></dd>
</div> <!-- /tab-pane -->
<div class="tab-pane" id="tab2"> <dt>This Month</dt>
<?php echo $o->traffic_table(isset($_POST['month']) ? $_POST['month'] : ''); ?> <dd>&nbsp;<?php echo $o->traffic_month(strtotime('yesterday'),TRUE,TRUE); ?></dd>
</div> <!-- /tab-pane -->
</div> <!-- /tab-content --> <dt>Excess Traffic</dt>
</div> <!-- /tabbable --> <dd>&nbsp;$<?php echo $o->traffic_excess(strtotime('yesterday'),TRUE,TRUE); ?></dd>
</div> <!-- dl-horizontal -->
</fieldset> <form class="form-inline" method="POST">
<div class="dl-horizontal">
<dt>View Traffic for</dt>
<dd><?php echo Form::select('month',array_merge(array(''),$o->get_traffic_months()),(isset($_POST['month']) ? $_POST['month'] : ''),array('class'=>'input-small','nocg'=>TRUE)); ?>
<button type="submit" class="btn btn-mini">Submit</button></dd>
</div> <!-- dl-horizontal -->
</form>
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active"><a href="#tab1" data-toggle="tab">Graph</a></li>
<li class=""><a href="#tab2" data-toggle="tab">Table</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab1">
<?php echo $o->traffic_graph(isset($_POST['month']) ? $_POST['month'] : ''); ?>
</div> <!-- /tab-pane -->
<div class="tab-pane" id="tab2">
<?php echo $o->traffic_table(isset($_POST['month']) ? $_POST['month'] : ''); ?>
</div> <!-- /tab-pane -->
</div> <!-- /tab-content -->
</div> <!-- /tabbable -->
</fieldset>
</div> <!-- /span -->

View File

@ -69,12 +69,9 @@ class Controller_Reseller_Charge extends Controller_Charge {
->type('stdin') ->type('stdin')
->data(' ->data('
$(document).ready(function() { $(document).ready(function() {
var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
$("#date_charge_label").datepicker({ $("#date_charge_label").datepicker({
autoclose : true, autoclose : true,
endDate : now, endDate : new Date(),
format : "dd-M-yyyy", format : "dd-M-yyyy",
todayBtn : true, todayBtn : true,
}).on("hide",function(ev) { }).on("hide",function(ev) {

View File

@ -1,31 +1,28 @@
<div class="row"> <div class="span11">
<div class="span9 offset1"> <fieldset>
<legend>Charge Details</legend>
<fieldset> <div class="input-append date" id="date_charge_label">
<legend>Charge Details</legend> <?php echo Form::input('date_charge_label',$o->display('date_charge'),array('class'=>'span2','label'=>'Date of Charge','add-on'=>'<i class="icon-calendar"></i>','disabled')); ?>
</div>
<div class="input-append date" id="date_charge_label"> <?php echo Form::hidden('date_charge',$o->date_charge); ?>
<?php echo Form::input('date_charge_label',$o->display('date_charge'),array('class'=>'span2','label'=>'Date of Charge','add-on'=>'<i class="icon-calendar"></i>','disabled')); ?> <?php echo Form::input('account_id_label',$o->account->name(),array('class'=>'span5','label'=>'Account','placeholder'=>'Account','data-provide'=>'typeahead','required')); ?>
</div> <?php echo Form::hidden('account_id',$o->account_id); ?>
<?php echo Form::select('service_id',$o->account_id ? $o->account->service->list_select() : array(),$o->service_id,array('class'=>'span5','label'=>'Service')); ?>
<?php echo StaticList_SweepType::form('sweep_type',is_null($o->sweep_type) ? 6 : $o->sweep_type,FALSE,array('label'=>'Sweep')); ?>
<?php echo StaticList_ItemType::form('type',is_null($o->type) ? 6 : $o->type,FALSE,array('label'=>'Item Type')); ?>
<?php echo Form::hidden('date_charge',$o->date_charge); ?> <?php echo Form::input('quantity',$o->quantity,array('class'=>'span1','label'=>'Quantity','placeholder'=>'Quantity')); ?>
<?php echo Form::input('account_id_label',$o->account->name(),array('class'=>'span5','label'=>'Account','placeholder'=>'Account','data-provide'=>'typeahead','required')); ?> <?php echo Form::input('amount',$o->amount,array('class'=>'span1','label'=>'Amount','placeholder'=>'Total',)); ?>
<?php echo Form::hidden('account_id',$o->account_id); ?> <?php echo StaticList_YesNo::form('taxable',is_null($o->taxable) ? TRUE : $o->taxable,FALSE,array('label'=>'Taxable','class'=>'span1')); ?>
<?php echo Form::select('service_id',$o->account_id ? $o->account->service->list_select() : array(),$o->service_id,array('class'=>'span5','label'=>'Service')); ?> <?php echo Form::input('description',$o->description,array('class'=>'span5','label'=>'Description','placeholder'=>'Any notes about this charge?')); ?>
<?php echo StaticList_SweepType::form('sweep_type',is_null($o->sweep_type) ? 6 : $o->sweep_type,FALSE,array('label'=>'Sweep')); ?>
<?php echo StaticList_ItemType::form('type',is_null($o->type) ? 6 : $o->type,FALSE,array('label'=>'Item Type')); ?>
<?php echo Form::input('quantity',$o->quantity,array('class'=>'span1','label'=>'Quantity','placeholder'=>'Quantity')); ?> <!-- @todo Use JS to dynamically add more lines as required -->
<?php echo Form::input('amount',$o->amount,array('class'=>'span1','label'=>'Amount','placeholder'=>'Total',)); ?> <?php for ($i=0;$i<10;$i++) :
<?php echo StaticList_YesNo::form('taxable',is_null($o->taxable) ? TRUE : $o->taxable,FALSE,array('label'=>'Taxable','class'=>'span1')); ?> echo Form::input("attributes[$i]",isset($o->attributes[$i]) ? $o->attributes[$i] : "",array('class'=>'span5','label'=>'Attributes'));
<?php echo Form::input('description',$o->description,array('class'=>'span5','label'=>'Description','placeholder'=>'Any notes about this charge?')); ?> endfor ?>
</fieldset>
<!-- @todo Use JS to dynamically add more lines as required --> <?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?>
<?php for ($i=0;$i<10;$i++) : </div> <!-- /span -->
echo Form::input("attributes[$i]",isset($o->attributes[$i]) ? $o->attributes[$i] : "",array('class'=>'span5','label'=>'Attributes'));
endfor ?>
</fieldset>
<?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?>
</div> <!-- /span -->
</div> <!-- /row -->

View File

@ -8,13 +8,15 @@
* @author Deon George * @author Deon George
* @copyright (c) 2009-2013 Open Source Billing * @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*
* @todo Does this need to be Serializable? * @todo Does this need to be Serializable?
*/ */
abstract class Checkout_Plugin implements Serializable { abstract class Checkout_Plugin implements Serializable {
protected $co; // Our Checkout Object protected $co; // Our Checkout Object
protected $_object; protected $_object;
// Our required abstract classes // Our required abstract classes
public function serialize() { public function serialize() {
return (string)$this->_object; return (string)$this->_object;
} }
@ -23,6 +25,7 @@ abstract class Checkout_Plugin implements Serializable {
} }
// Required abstract classes // Required abstract classes
// Present pre-plugin processing information // Present pre-plugin processing information
abstract public function before(Cart $co); abstract public function before(Cart $co);
abstract public function notify(Model_Checkout_Notify $cno); abstract public function notify(Model_Checkout_Notify $cno);

View File

@ -47,7 +47,7 @@ $(document).ready(function() {
if ($o->registrar_ns) if ($o->registrar_ns)
return is_array($o->registrar_ns) ? implode(',',$o->registrar_ns) : '&gt;Invalid&lt;'; return is_array($o->registrar_ns) ? implode(',',$o->registrar_ns) : '&gt;Invalid&lt;';
else else
return is_array($o->domain_registrar->whitelabel_ns) ? implode(',',$o->domain_registrar->whitelabel_ns) : '&gt;Unknown&lt;'; return is_array($o->registrar->whitelabel_ns) ? implode(',',$o->registrar->whitelabel_ns) : '&gt;Unknown&lt;';
} }
} }
?> ?>

View File

@ -10,11 +10,8 @@
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Model_Product_Plugin_Domain extends Model_Product_Plugin { class Model_Product_Plugin_Domain extends Model_Product_Plugin {
// This model doesnt have a database table
public function __construct() {
}
// Our required abstract methods // Our required abstract methods
public function cost($annual=FALSE) { public function cost($annual=FALSE) {
// @todo // @todo
$x = 0; $x = 0;
@ -22,8 +19,6 @@ class Model_Product_Plugin_Domain extends Model_Product_Plugin {
return $annual ? $x*12 : $x; return $annual ? $x*12 : $x;
} }
public function feature_summary() {}
public function render_edit() {} public function render_edit() {}
// @todo // @todo
@ -31,7 +26,16 @@ class Model_Product_Plugin_Domain extends Model_Product_Plugin {
return 'internal'; return 'internal';
} }
/** LOCAL FUNCTIONS **/ // Overload functions
// This model doesnt have a database table
public function __construct() {
}
// Not used
public function render_view() {}
// Local functions
// @todo This is not used, but should be. // @todo This is not used, but should be.
public function order_features() { public function order_features() {

View File

@ -11,16 +11,14 @@
*/ */
class Model_Service_Plugin_Domain extends Model_Service_Plugin { class Model_Service_Plugin_Domain extends Model_Service_Plugin {
protected $_table_name = 'service__domain'; protected $_table_name = 'service__domain';
protected $_created_column = FALSE;
protected $_updated_column = FALSE; protected $_updated_column = FALSE;
// Relationships // Relationships
protected $_has_one = array( protected $_has_one = array(
'domain_TLD'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'), 'host'=>array('model'=>'Service_Plugin_Host','through'=>'service','far_key'=>'service_id','foreign_key'=>'service_id'),
'domain_registrar'=>array('foreign_key'=>'id','far_key'=>'domain_registrar_id'), 'registrar'=>array('model'=>'Domain_Registrar','foreign_key'=>'id','far_key'=>'domain_registrar_id'),
'service_plugin_host'=>array('through'=>'service','far_key'=>'service_id','foreign_key'=>'service_id'), 'tld'=>array('model'=>'Domain_TLD','foreign_key'=>'id','far_key'=>'domain_tld_id'),
);
protected $_belongs_to = array(
'service'=>array(),
); );
protected $_display_filters = array( protected $_display_filters = array(
@ -35,44 +33,41 @@ class Model_Service_Plugin_Domain extends Model_Service_Plugin {
), ),
); );
protected $_save_message = TRUE;
// Required abstract functions // Required abstract functions
public function admin_update() {
return '';
}
public function expire() { public function expire() {
return $this->domain_expire; return $this->domain_expire;
} }
public function name() { public function name() {
return sprintf('%s.%s',$this->display('domain_name'),$this->domain_TLD->display('name')); return sprintf('%s.%s',$this->display('domain_name'),$this->tld->display('name'));
} }
public function service_name() { public function password() {
return sprintf('%s - %s',_('Domain Name License'),$this->name()); return $this->registrar_password;
} }
public function username_value() { public function username() {
return $this->registrar_username; return $this->registrar_username;
} }
public function password_value() { // Local functions
return $this->registrar_password;
}
/** /**
* This provides us with a manage button to jump to the registrar * This provides us with a manage button to jump to the registrar
* to manage the domain. * to manage the domain.
*/ */
public function manage_button($t='') { public function manage_button($t='') {
if (! parent::manage_button($t)) if (! parent::manage())
return NULL; return NULL;
return ($this->username_value() AND $this->password_value()) ? $this->domain_registrar->manage_button($this,$t) : _('Please contact us'); return ($this->username() AND $this->password()) ? $this->registrar->manage_button($this,$t) : _('Please contact us');
} }
public function manage_dns_button() { public function manage_button_dns() {
return $this->service_plugin_host->manage_button('service_plugin_host'); return $this->host->manage_button('host');
} }
/** /**

View File

@ -22,8 +22,8 @@ class Service_Domain_PlanetDomain extends Service_Domain {
sprintf('%s/%s',$this->so->whitelabel_url,'newdnr/action/user/login.jsp'), sprintf('%s/%s',$this->so->whitelabel_url,'newdnr/action/user/login.jsp'),
array('target'=>'pd','method'=>'post','id'=>sprintf('id_%s_%s',$spdo->service_id,$t)) array('target'=>'pd','method'=>'post','id'=>sprintf('id_%s_%s',$spdo->service_id,$t))
); );
$output .= Form::input($this->login_user_field,$spdo->username_value(),array('type'=>'hidden','id'=>sprintf('u_%s_%s',$spdo->service_id,$t))); $output .= Form::input($this->login_user_field,$spdo->username(),array('type'=>'hidden','id'=>sprintf('u_%s_%s',$spdo->service_id,$t)));
$output .= Form::input($this->login_pass_field,substr(md5($spdo->password_value()),0,8),array('type'=>'hidden','id'=>sprintf('p_%s_%s',$spdo->service_id,$t))); $output .= Form::input($this->login_pass_field,substr(md5($spdo->password()),0,8),array('type'=>'hidden','id'=>sprintf('p_%s_%s',$spdo->service_id,$t)));
$output .= Form::input('page.next',sprintf('/newdnr/action/dns/getDNSDetails.jsp?domain.name=%s',$d),array('type'=>'hidden')); $output .= Form::input('page.next',sprintf('/newdnr/action/dns/getDNSDetails.jsp?domain.name=%s',$d),array('type'=>'hidden'));
$output .= Form::close(); $output .= Form::close();
$output .= Form::button('submit',_('Manage'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$spdo->service_id,$t))); $output .= Form::button('submit',_('Manage'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$spdo->service_id,$t)));

View File

@ -23,8 +23,8 @@ class Service_Domain_TPP extends Service_Domain {
$debug ? 'debug/site' : sprintf('%s/%s',$this->so->whitelabel_url,'execute/logon'), $debug ? 'debug/site' : sprintf('%s/%s',$this->so->whitelabel_url,'execute/logon'),
array('target'=>'tpp','method'=>'post','id'=>sprintf('id_%s_%s',$spdo->service_id,$t)) array('target'=>'tpp','method'=>'post','id'=>sprintf('id_%s_%s',$spdo->service_id,$t))
); );
$output .= Form::input($this->login_user_field,$spdo->username_value(),array('type'=>'hidden','id'=>sprintf('u_%s_%s',$spdo->service_id,$t))); $output .= Form::input($this->login_user_field,$spdo->username(),array('type'=>'hidden','id'=>sprintf('u_%s_%s',$spdo->service_id,$t)));
$output .= Form::input($this->login_pass_field,substr(md5($spdo->password_value()),0,8),array('type'=>'hidden','id'=>sprintf('p_%s_%s',$spdo->service_id,$t))); $output .= Form::input($this->login_pass_field,substr(md5($spdo->password()),0,8),array('type'=>'hidden','id'=>sprintf('p_%s_%s',$spdo->service_id,$t)));
$output .= Form::close(); $output .= Form::close();
$output .= Form::button('submit',_('Manage'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$spdo->service_id,$t))); $output .= Form::button('submit',_('Manage'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$spdo->service_id,$t)));

View File

@ -0,0 +1,7 @@
<fieldset>
<legend>Domain Service Details</legend>
<div class="row">
<?php echo Form::input('plugin[domain_name]',NULL,array('class'=>'span2','label'=>'Domain Name','placeholder'=>'Domain Name','required')); ?>
</div> <!-- /row -->
</fieldset>

View File

@ -17,7 +17,7 @@
<dd><?php echo $x; ?></dd> <dd><?php echo $x; ?></dd>
<?php endif ?> <?php endif ?>
<?php if ($x=$o->manage_dns_button()) : ?> <?php if ($x=$o->manage_button_dns()) : ?>
<dt>DNS</dt> <dt>DNS</dt>
<dd><?php echo $x; ?></dd> <dd><?php echo $x; ?></dd>
<?php endif ?> <?php endif ?>

View File

@ -134,8 +134,8 @@ class Email_Template {
} }
} }
if (isset($this->_data['bcc'])) if ($x=Arr::merge($this->bcc,Kohana::$config->load('debug.email_bcc_admin')))
$sm->setBcc($this->bcc); $sm->setBcc($x);
if ($admin OR ($admin = Config::testmail($this->_etto->template->name))) { if ($admin OR ($admin = Config::testmail($this->_etto->template->name))) {
$sm->setTo($admin); $sm->setTo($admin);

View File

@ -17,6 +17,10 @@ class Model_Email_Template_Translate extends ORM_OSB {
'template'=>array('model'=>'Email_Template','foreign_key'=>'email_template_id'), 'template'=>array('model'=>'Email_Template','foreign_key'=>'email_template_id'),
); );
protected $_has_one = array(
'language'=>array('foreign_key'=>'id'),
);
protected $_save_message = TRUE; protected $_save_message = TRUE;
public function complete($data,$column) { public function complete($data,$column) {

View File

@ -1,38 +1,30 @@
<div class="row"> <div class="span11">
<div class="span9 offset1"> <fieldset>
<div class="row"> <legend>Update Template</legend>
<div class="span3">
<?php echo Form::input('name',$o->name,array('label'=>'Name','class'=>'span3')); ?>
</div>
</div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span3"> <?php echo Form::input('name',$o->name,array('label'=>'Name','class'=>'span3')); ?>
<?php echo StaticList_YesNo::form('status',$o->status,FALSE,array('label'=>'Email Template Active','class'=>'span1')); ?>
</div>
</div> </div>
<div class="row"> <div class="row">
<div class="span8"> <?php echo StaticList_YesNo::form('status',$o->status,FALSE,array('label'=>'Email Template Active','class'=>'span1')); ?>
<?php echo Form::textarea('notes',$o->notes,array('label'=>'Notes','class'=>'span8')); ?> </div>
</div>
</div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span5"> <?php echo Form::textarea('notes',$o->notes,array('label'=>'Notes','class'=>'span8')); ?>
<?php echo Form::select('language_id',ORM::factory('Language')->list_select(TRUE),'',array('label'=>'Language','required')); ?> </div>
</div>
</div> <!-- /row -->
<div class="row"> <div class="row">
<div id="translate"></div> <?php echo Form::select('language_id',ORM::factory('Language')->list_select(TRUE),'',array('label'=>'Language','required')); ?>
</div> <!-- /row --> </div>
</fieldset>
<div class="row"> <div id="translate"></div>
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button> <div class="row">
<button type="button" class="btn">Cancel</button> <div class="offset2">
</div> <button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div> </div>
</div> </div>
</div> <!-- /row --> </div> <! -- /span -->

View File

@ -1,4 +1,7 @@
<div class="span9"> <fieldset>
<legend><?php echo __(':language description for email template :pid',array(':pid'=>$o->id,':language'=>$o->language->name)); ?></legend>
<div class="row">
<?php echo Form::input('translate[subject]',$o->subject,array( <?php echo Form::input('translate[subject]',$o->subject,array(
'label'=>'Email Subject', 'label'=>'Email Subject',
'placeholder'=>'Email Subject', 'placeholder'=>'Email Subject',
@ -6,7 +9,7 @@
'required', 'required',
'help-block'=>sprintf('This is the subject line on the email. Uses variables: %s',implode(', ',array_values($o->variables('subject')))))); ?> 'help-block'=>sprintf('This is the subject line on the email. Uses variables: %s',implode(', ',array_values($o->variables('subject')))))); ?>
</div> </div>
<div class="span9"> <div class="row">
<?php echo Form::textarea('translate[message_text]',$o->message_text,array( <?php echo Form::textarea('translate[message_text]',$o->message_text,array(
'label'=>'Message Text', 'label'=>'Message Text',
'placeholder'=>'Message Text', 'placeholder'=>'Message Text',
@ -14,7 +17,7 @@
'required', 'required',
'help-block'=>sprintf('The message in plain text that is used in the email for email clients that cannot render HTML. Uses variables: %s',implode(', ',array_values($o->variables('message_text')))))); ?> 'help-block'=>sprintf('The message in plain text that is used in the email for email clients that cannot render HTML. Uses variables: %s',implode(', ',array_values($o->variables('message_text')))))); ?>
</div> </div>
<div class="span9"> <div class="row">
<?php echo Form::textarea('translate[message_html]',$o->message_html,array( <?php echo Form::textarea('translate[message_html]',$o->message_html,array(
'label'=>'Message HTML', 'label'=>'Message HTML',
'placeholder'=>'Message HTML', 'placeholder'=>'Message HTML',
@ -23,6 +26,7 @@
'editor'=>'tinymce', 'editor'=>'tinymce',
'help-block'=>sprintf('The message in HTML that is used in the email. Uses variables: %s',implode(', ',array_values($o->variables('message_html')))))); ?>' 'help-block'=>sprintf('The message in HTML that is used in the email. Uses variables: %s',implode(', ',array_values($o->variables('message_html')))))); ?>'
</div> </div>
</fieldset>
<?php echo Style::factory()->render_all(); ?> <?php echo Style::factory()->render_all(); ?>
<?php echo Script::factory()->render_all(); ?> <?php echo Script::factory()->render_all(); ?>

View File

@ -1,32 +1,34 @@
<div class="row"> <div class="span11">
<div class="span11">
<table> <table>
<tr> <tr>
<td><strong>To:</strong></td> <td><strong>To:</strong></td>
<td><?php printf('%s (%s)',$elo->account->name(),$elo->display('email')); ?></td> <td><?php printf('%s (%s)',$elo->account->name(),$elo->display('email')); ?></td>
</tr> </tr>
<tr>
<td><strong>Date:</strong></td>
<td><?php echo $elo->display('date_orig'); ?></td>
</tr>
<tr>
<td><strong>Subject:</strong></td>
<td><?php echo $elo->resolve('subject'); ?></td>
</tr>
<tr>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td colspan="2">
<table>
<tr>
<td><?php echo $elo->resolve('message_html'); ?></td>
</tr>
</table>
</td>
</tr>
</table>
</div> <!-- /span --> <tr>
</div> <!-- /row --> <td><strong>Date:</strong></td>
<td><?php echo $elo->display('date_orig'); ?></td>
</tr>
<tr>
<td><strong>Subject:</strong></td>
<td><?php echo $elo->resolve('subject'); ?></td>
</tr>
<tr>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td colspan="2">
<table>
<tr>
<td><?php echo $elo->resolve('message_html'); ?></td>
</tr>
</table>
</td>
</tr>
</table>
</div> <!-- /span -->

View File

@ -1,21 +1,19 @@
<div class="row"> <div class="span11">
<div class="span10 offset1"> <fieldset>
<fieldset> <legend>Add Export Data Map</legend>
<legend>Add Export Data Map</legend>
<?php echo Form::select('item_id',$o->list_itemsnoexport($module,$emo->id),NULL,array('label'=>'Product')); ?> <?php echo Form::select('item_id',$o->list_itemsnoexport($module,$emo->id),NULL,array('label'=>'Product')); ?>
<?php echo Form::input('map_data[account]','Internet:ADSL Supply',array('label'=>'Accounting Code','placeholder'=>'Account Code')); ?> <?php echo Form::input('map_data[account]','Internet:ADSL Supply',array('label'=>'Accounting Code','placeholder'=>'Account Code')); ?>
<?php echo Form::input('map_data[item]','ADSL:ADSL2',array('label'=>'Inventory Code','placeholder'=>'Inventory Code')); ?> <?php echo Form::input('map_data[item]','ADSL:ADSL2',array('label'=>'Inventory Code','placeholder'=>'Inventory Code')); ?>
<?php echo Form::hidden('export_module_id',$emo->id); ?> <?php echo Form::hidden('export_module_id',$emo->id); ?>
<?php echo Form::hidden('module_id',$module->mid()); ?> <?php echo Form::hidden('module_id',$module->mid()); ?>
</fieldset>
<div class="row"> <div class="row">
<div class="offset2"> <div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button> <button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button> <button type="button" class="btn">Cancel</button>
</div> </div>
</div> </div>
</fieldset> </div> <!-- /span -->
</div> <!-- /span10 -->
</div> <!-- /row -->

View File

@ -1,20 +1,18 @@
<div class="row"> <div class="span11">
<div class="span10 offset1"> <fieldset>
<fieldset> <legend>Export Module Update</legend>
<legend>Export Module Update</legend>
<p>Available <?php echo $o->module->table_name(); ?> Columns to display</p> <p>Available <?php echo $o->module->table_name(); ?> Columns to display</p>
<?php echo Table::factory() <?php echo Table::factory()
->data($o->module->module()->table_columns()) ->data($o->module->module()->table_columns())
->jssort(FALSE) ->jssort(FALSE)
->columns(array( ->columns(array(
'column_name'=>'Name', 'column_name'=>'Name',
)) ))
->select(URL::link('reseller','export/export'),$o->id,array('export_module_id'=>$o->id)) ->select(URL::link('reseller','export/export'),$o->id,array('export_module_id'=>$o->id))
->prepend(array( ->prepend(array(
'column_name'=>array('input'=>array('key'=>'display[__VALUE__]','values'=>$o->display)), 'column_name'=>array('input'=>array('key'=>'display[__VALUE__]','values'=>$o->display)),
)); ?> )); ?>
</fieldset> </fieldset>
</div> <!-- /span --> </div> <!-- /span -->
</div> <!-- /row -->

View File

@ -91,19 +91,19 @@ class GoogleChart_Legacy extends GoogleChart {
/** CHART FIELDS **/ /** CHART FIELDS **/
private function chd() { private function chd() {
$result = array(); $result = array();
$maxes = $this->maxes(); $maxes = $this->maxes();
// Perform our encoding // Perform our encoding
foreach ($this->_axis as $l => $axis) foreach ($this->_axis as $l => $axis)
array_push($result,$this->encode($this->_data[$l],$maxes[$axis])); array_push($result,$this->encode($this->_data[$l],$maxes[$axis]));
$prefix = (count($maxes) > 1) ? sprintf('%s:',$this->axiscount('yl')) : ':'; $prefix = (count($maxes) > 1) ? sprintf('%s:',$this->axiscount('yl')) : ':';
// If encoding is text, we need to separate the series with a | // If encoding is text, we need to separate the series with a |
return ($this->_encodetype == 't') ? $prefix.implode('|',$result) : $prefix.implode(',',$result); return ($this->_encodetype == 't') ? $prefix.implode('|',$result) : $prefix.implode(',',$result);
} }
private function chm() { private function chm() {
$result = array(); $result = array();

View File

@ -10,10 +10,6 @@
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Model_Product_Plugin_Host extends Model_Product_Plugin { class Model_Product_Plugin_Host extends Model_Product_Plugin {
// @todo This model doesnt have a database table
public function __construct() {
}
// Our required abstract methods // Our required abstract methods
public function cost($annual=FALSE) { public function cost($annual=FALSE) {
// @todo // @todo
@ -22,8 +18,6 @@ class Model_Product_Plugin_Host extends Model_Product_Plugin {
return $annual ? $x*12 : $x; return $annual ? $x*12 : $x;
} }
public function feature_summary() {}
public function render_edit() {} public function render_edit() {}
// @todo // @todo
@ -31,6 +25,17 @@ class Model_Product_Plugin_Host extends Model_Product_Plugin {
return 'internal'; return 'internal';
} }
// Overload functions
// @todo This model doesnt have a database table
public function __construct() {
}
// Not used
public function render_view() {}
// Local functions
// @todo This is not used, but should be. // @todo This is not used, but should be.
public function order_features() {} public function order_features() {}
} }

View File

@ -19,8 +19,8 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
// Relationships // Relationships
protected $_has_one = array( protected $_has_one = array(
'domain_TLD'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'), 'host'=>array('model'=>'Host_Server','far_key'=>'host_server_id','foreign_key'=>'id'),
'host_server'=>array('far_key'=>'host_server_id','foreign_key'=>'id'), 'tld'=>array('model'=>'Domain_TLD','foreign_key'=>'id','far_key'=>'domain_tld_id'),
); );
protected $_belongs_to = array( protected $_belongs_to = array(
'service'=>array(), 'service'=>array(),
@ -35,40 +35,41 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
), ),
); );
protected $_save_message = TRUE;
// Required abstract functions // Required abstract functions
public function admin_update() {
return '';
}
public function expire() { public function expire() {
return $this->host_expire; return $this->host_expire;
} }
public function name() { public function name() {
return sprintf('%s.%s',$this->display('domain_name'),$this->domain_TLD->display('name')); return sprintf('%s.%s',$this->display('domain_name'),$this->tld->display('name'));
} }
public function username_value() { public function password() {
return $this->host_password;
}
public function username() {
return $this->host_username; return $this->host_username;
} }
public function password_value() { // Local functions
return $this->host_password;
}
/** /**
* This provides us with a manage button to jump to the hosting server * This provides us with a manage button to jump to the hosting server
* to manage the domain. * to manage the domain.
*/ */
public function manage_button($t='') { public function manage_button($t='') {
if (! parent::manage_button($t))
return NULL;
// @todo Convert this to a Static_List display // @todo Convert this to a Static_List display
if ($this->service->queue == 'PROVISION') if ($this->service->queue == 'PROVISION')
return _('To Be Provisioned'); return _('To Be Provisioned');
return ($this->username_value() AND $this->password_value() AND $a=$this->host_server->plugin()) ? $a->manage_button($this,$t) : ''; if (! parent::manage($t))
return NULL;
return ($this->username() AND $this->password() AND $a=$this->host->plugin()) ? $a->manage_button($this,$t) : '';
} }
/** /**

View File

@ -4,49 +4,49 @@
</div> <!-- /page-title --> </div> <!-- /page-title -->
<div id="container"> <div id="container">
<div class="row"> <div class="pricing-plans plans-4">
<div class="grid-12"> <div class="row">
<div class="pricing-plans plans-4"> <?php $c=0; foreach ($o->products() as $po) : ?>
<div class="row"> <?php $go = $po->price_best($o->recur_schedule,TRUE); ?>
<?php $c=0; foreach ($o->products() as $po) : ?> <?php $price = (string)Currency::display($po->price($go->id,$o->recur_schedule,'base',TRUE)); ?>
<?php if (! ($c++%4) AND $c>1) : ?>
</div> <!-- /row -->
<hr class="row-divider" />
<div class="row">
<?php endif ?>
<div class="plan-container"> <?php if (is_null($price)) continue; ?>
<div class="plan">
<div class="plan-header"> <?php if (! ($c++%4) AND $c>1) : ?>
</div> <!-- /row -->
<hr class="row-divider" />
<div class="row">
<?php endif ?>
<div class="plan-title"> <div class="plan-container">
<?php echo $po->title(); ?> <div class="plan">
</div> <!-- /plan-title -->
<div class="plan-price"> <div class="plan-header">
<?php $x = (string)Currency::display($po->price(0,4,'price_base',TRUE)); ?>
<span class="note">$</span><?php echo substr($x,0,strpos($x,'.')); ?><span class="cents"> .<?php echo substr($x,-2,strpos($x,'.')); ?></span><span class="term"><?php echo StaticList_RecurSchedule::get(4); ?></span>
</div> <!-- /plan-price -->
</div> <!-- /plan-header --> <div class="plan-title">
<?php echo $po->title(); ?>
</div> <!-- /plan-title -->
<div class="plan-features"> <div class="plan-price">
<ul> <span class="note">$</span><?php echo substr($price,0,strpos($price,'.')); ?><span class="cents"> .<?php echo substr($price,-2,strpos($price,'.')); ?></span><span class="term"><?php echo StaticList_RecurSchedule::get($o->recur_schedule); ?></span>
<li><span class="note">$</span><strong><?php echo Currency::display($po->price(0,4,'price_setup',TRUE)); ?></strong> setup</li> </div> <!-- /plan-price -->
</ul>
</div> <!-- /plan-features -->
<div class="plan-actions"> </div> <!-- /plan-header -->
<a href="<?php echo URL::site('product/view/'.$po->id); ?>" class="btn">More Information</a>
</div> <!-- /plan-actions -->
</div> <!-- /plan --> <div class="plan-features">
</div> <!-- /plan-container --> <ul>
<?php endforeach ?> <li><span class="note">$</span><strong><?php echo Currency::display($po->price($go->id,$o->recur_schedule,'setup',TRUE)); ?></strong> Setup</li>
</ul>
</div> <!-- /plan-features -->
</div> <!-- /row --> <div class="plan-actions">
</div> <!-- /pricing-plans --> <a href="<?php echo URL::site('product/view/'.$po->id); ?>" class="btn">More Information</a>
</div> <!-- /grid --> </div> <!-- /plan-actions -->
</div> <!-- /row -->
</div> <!-- /plan -->
</div> <!-- /plan-container -->
<?php endforeach ?>
</div> <!-- /row -->
</div> <!-- /pricing-plans -->
</div> <!-- /container --> </div> <!-- /container -->

View File

@ -10,6 +10,17 @@
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Task_Invoice_Remindoverdue1 extends Minion_Task { class Task_Invoice_Remindoverdue1 extends Minion_Task {
// @todo This should be moved to somewhere else
private $_css = '
<style type="text/css">
table.box-left { border: 1px solid #AAAACC; margin-right: auto; }
tr.head { font-weight: bold; }
td.head { font-weight: bold; }
td.right { text-align: right; }
tr.odd { background-color: #FCFCFE; }
tr.even { background-color: #F6F6F8; }
</style>';
protected function remind_overdue($notice=1) { protected function remind_overdue($notice=1) {
$action = array(); $action = array();
@ -44,7 +55,7 @@ class Task_Invoice_Remindoverdue1 extends Minion_Task {
'INV_NUM'=>$io->refnum(), 'INV_NUM'=>$io->refnum(),
'INV_URL'=>URL::site(URL::link('user','invoice/view/'.$io->id),'http'), 'INV_URL'=>URL::site(URL::link('user','invoice/view/'.$io->id),'http'),
'LATE_FEE'=>'5.50', // @todo This should come from a config file. 'LATE_FEE'=>'5.50', // @todo This should come from a config file.
'PAYMENTS_TABLE'=>$io->account->payment->list_recent_table(), 'PAYMENTS_TABLE'=>$this->_css.$io->account->payment->list_recent_table(),
'SITE_NAME'=>Company::instance()->name(), 'SITE_NAME'=>Company::instance()->name(),
); );

View File

@ -1,43 +1,43 @@
<div class="row"> <div class="row">
<div class="span11"> <div class="span5">
<div class="span5"> <table>
<div class="row"> <tr>
<table> <td style="vertical-align: top"><?php echo HTML::image('http://www.gth.bgo.co/logo-blue'); ?></td>
<tr> <td style="text-align: right; font-weight: bold">
<td style="vertical-align: top"><?php echo HTML::image('http://www.gth.bgo.co/logo-blue'); ?></td> <?php echo Company::instance()->name(); ?><br/>
<td style="text-align: right; font-weight: bold"> <?php echo Company::instance()->taxid(); ?><br/>
<?php echo Company::instance()->name(); ?><br/> <br/>
<?php echo Company::instance()->taxid(); ?><br/> <?php echo Company::instance()->address(); ?><br/>
<br/> <br/>
<?php echo Company::instance()->address(); ?><br/> <?php echo Company::instance()->contacts(); ?>
<br/> </td>
<?php echo Company::instance()->contacts(); ?> </tr>
</td> </table>
</tr> </div> <!-- /span -->
</table>
</div> <!-- /row -->
</div> <!-- /span -->
<div class="span5"> <div class="span5">
<div class="row"> <div class="dl-horizontal pull-right">
<div class="dl-horizontal pull-right"> <dt>Tax Invoice</dt>
<dt>Tax Invoice</dt> <dd><?php echo $o->id(); ?></dd>
<dd><?php echo $o->id(); ?></dd>
<dt>Issue Date</dt> <dt>Issue Date</dt>
<dd><?php echo $o->display('date_orig'); ?></dd> <dd><?php echo $o->display('date_orig'); ?></dd>
<dt>Due Date</dt>
<dd><?php echo $o->display('due_date'); ?></dd> <dt>Due Date</dt>
<dt>Current Charges</dt> <dd><?php echo $o->display('due_date'); ?></dd>
<dd><?php echo $o->total_charges(TRUE); ?></dd>
<dt>Payments Received</dt> <dt>Current Charges</dt>
<dd><?php echo $o->payments_total(TRUE); ?></dd> <dd><?php echo $o->total_charges(TRUE); ?></dd>
<dt>Credits Applied</dt>
<dd><?php echo $o->total_credits(TRUE); ?></dd> <dt>Payments Received</dt>
<dt>Still Due</dt> <dd><?php echo $o->payments_total(TRUE); ?></dd>
<dd><?php echo $o->due(TRUE); ?></dd>
</div> <dt>Credits Applied</dt>
</div> <!-- /row --> <dd><?php echo $o->total_credits(TRUE); ?></dd>
</div> <!-- /span -->
<dt>Still Due</dt>
<dd><?php echo $o->due(TRUE); ?></dd>
</div>
</div> <!-- /span --> </div> <!-- /span -->
</div> </div>
@ -46,67 +46,60 @@
<h4>Charge Details</h4> <h4>Charge Details</h4>
<?php echo Invoice::instance($o)->render('html','body'); ?> <?php echo Invoice::instance($o)->render('html','body'); ?>
</div> <!-- /span --> </div> <!-- /span -->
</div> </div>
<div class="row"> <div class="row">
<div class="span11"> <div class="span5">
<div class="span5"> <h5>Reminder Details</h5>
<div class="row">
<h5>Reminder Details</h5>
<div class="dl-horizontal pull-left">
<?php foreach ($o->reminders() as $eto) : ?>
<dt><?php echo $o->reminders($eto->name,TRUE); ?></dt>
<dd><?php echo $eto->name(); ?></dd>
<?php endforeach ?>
</div>
</div> <!-- /row -->
</div> <!-- /span -->
<div class="span5"> <div class="dl-horizontal pull-left">
<div class="row"> <?php foreach ($o->reminders() as $eto) : ?>
<div class="dl-horizontal pull-right"> <dt><?php echo $o->reminders($eto->name,TRUE); ?></dt>
<!-- Sub Total --> <dd><?php echo $eto->name(); ?></dd>
<dt>Sub Total</dt> <?php endforeach ?>
<dd><?php echo $o->subtotal(TRUE); ?></dd> </div>
<!-- END Invoice Sub Total --> </div> <!-- /span -->
<!-- Invoice Credits --> <div class="span5">
<?php if ($o->total_credits()) : ?> <div class="dl-horizontal pull-right">
<dt>Credits</dt> <!-- Sub Total -->
<dd><?php echo $o->total_credits(TRUE); ?></dd> <dt>Sub Total</dt>
<?php endif ?> <dd><?php echo $o->subtotal(TRUE); ?></dd>
<!-- END Invoice Credits --> <!-- END Invoice Sub Total -->
<!-- Invoice Discounts Total --> <!-- Invoice Credits -->
<?php if ($o->total_discounts()) : ?> <?php if ($o->total_credits()) : ?>
<dt>Discounts</dt> <dt>Credits</dt>
<dd><?php echo $o->total_discounts(TRUE); ?></dd> <dd><?php echo $o->total_credits(TRUE); ?></dd>
<?php endif ?> <?php endif ?>
<!-- END Invoice Discounts Total --> <!-- END Invoice Credits -->
<!-- Invoice Taxes Total --> <!-- Invoice Discounts Total -->
<dt>Taxes Included:</dt> <?php if ($o->total_discounts()) : ?>
<?php foreach ($o->tax_summary() as $tid => $amount) : <dt>Discounts</dt>
$m = ORM::factory('Tax',$tid); ?> <dd><?php echo $o->total_discounts(TRUE); ?></dd>
<dd><?php printf('%s (%s)',Currency::display($amount),$m->description); ?><dd> <?php endif ?>
<?php endforeach ?> <!-- END Invoice Discounts Total -->
<!-- END Invoice Taxes Total -->
<!-- Invoice Total --> <!-- Invoice Taxes Total -->
<dt>Total Invoice:</dt> <dt>Taxes Included:</dt>
<dd><?php echo $o->total(TRUE); ?></dd> <?php foreach ($o->tax_summary() as $tid => $amount) :
<!-- END Invoice Total --> $m = ORM::factory('Tax',$tid); ?>
<dd><?php printf('%s (%s)',Currency::display($amount),$m->description); ?><dd>
<?php endforeach ?>
<!-- END Invoice Taxes Total -->
<!-- Account Total Due --> <!-- Invoice Total -->
<dt>Account Due:</dt> <dt>Total Invoice:</dt>
<dd><?php echo $o->account->invoices_due_total(NULL,TRUE); ?></dd> <dd><?php echo $o->total(TRUE); ?></dd>
<!-- END Account Total Due --> <!-- END Invoice Total -->
</div> <!-- Account Total Due -->
</div> <!-- /row --> <dt>Account Due:</dt>
</div> <!-- /span --> <dd><?php echo $o->account->invoices_due_total(NULL,TRUE); ?></dd>
<!-- END Account Total Due -->
</div>
</div> <!-- /span --> </div> <!-- /span -->
</div> </div>

@ -1 +1 @@
Subproject commit c13235763045db771ecf2cfeb332cc8f3a314650 Subproject commit 319b4b29db9c1e467b34f75bb03d1d908d17afbc

View File

@ -11,7 +11,7 @@
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
abstract class Auth extends Kohana_Auth { abstract class Auth extends Kohana_Auth {
public static function instance($type=NULL) { public static function instance($type=NULL) {
if (is_null($type) OR (! $type instanceof Model_Oauth)) if (is_null($type) OR (! $type instanceof Model_Oauth))
return parent::instance(); return parent::instance();

View File

@ -37,9 +37,9 @@ class Auth_Facebook extends Auth_ORM_External {
// Create new Facebook object // Create new Facebook object
$this->ao = new Facebook(array( $this->ao = new Facebook(array(
'appId' => $oo->app_id, 'appId' => $oo->app_id,
'secret' => $oo->secret, 'secret' => $oo->secret,
'cookie' => $this->config->cookie, 'cookie' => $this->config->cookie,
'session_type' => $this->config->session_type, 'session_type' => $this->config->session_type,
)); ));

View File

@ -121,12 +121,9 @@ class Controller_Admin_Payment extends Controller_Payment {
->type('stdin') ->type('stdin')
->data(' ->data('
$(document).ready(function() { $(document).ready(function() {
var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
$("#date_payment_label").datepicker({ $("#date_payment_label").datepicker({
autoclose : true, autoclose : true,
endDate : now, endDate : new Date(),
format : "dd-mm-yyyy", format : "dd-mm-yyyy",
todayBtn : true, todayBtn : true,
}).on("hide",function(ev) { }).on("hide",function(ev) {

View File

@ -214,6 +214,22 @@ class Model_Payment extends ORM_OSB {
/** LIST FUNCTIONS **/ /** LIST FUNCTIONS **/
/**
* Show recent payments for this account
*/
public function list_recent_table() {
return Table::factory()
->data($this->limit(10)->find_all())
->columns(array(
'id'=>'ID',
'date_payment'=>'Date',
'checkout->display("name")'=>'Method',
'total_amt'=>'Total',
'balance(TRUE)'=>'Balance',
'invoicelist()'=>'Invoices'
));
}
public function list_unapplied() { public function list_unapplied() {
$pid = array(); $pid = array();
@ -232,32 +248,5 @@ class Model_Payment extends ORM_OSB {
return $this->where('id','IN',$pid)->order_by('account_id')->find_all(); return $this->where('id','IN',$pid)->order_by('account_id')->find_all();
} }
public function list_recent_table() {
// @todo This should be in a config file.
$css = '<style type="text/css">';
$css .= 'table.box-left { border: 1px solid #AAAACC; margin-right: auto; }';
$css .= 'tr.head { font-weight: bold; }';
$css .= 'td.head { font-weight: bold; }';
$css .= 'td.right { text-align: right; }';
$css .= 'tr.odd { background-color: #FCFCFE; }';
$css .= 'tr.even { background-color: #F6F6F8; }';
$css .= '</style>';
return $css.Table::display(
$this->limit(10)->find_all(),
25,
array(
'id'=>array('label'=>'ID'),
'date_payment'=>array('label'=>'Date'),
'checkout->display("name")'=>array('label'=>'Method'),
'total_amt'=>array('label'=>'Total','class'=>'right'),
'balance(TRUE)'=>array('label'=>'Balance','class'=>'right'),
'invoicelist()'=>array('label'=>'Invoices'),
),
array(
'type'=>'list',
));
}
} }
?> ?>

View File

@ -1,23 +1,21 @@
<div class="row"> <div class="span11">
<div class="span9 offset1"> <fieldset>
<legend>Payment Details</legend>
<fieldset> <div class="input-append date" id="date_payment_label">
<legend>Payment Details</legend> <?php echo Form::input('date_payment_label',$o->display('date_payment'),array('class'=>'span2','label'=>'Date Paid','add-on'=>'<i class="icon-calendar"></i>','disabled')); ?>
</div>
<div class="input-append date" id="date_payment_label"> <?php echo Form::hidden('date_payment',$o->date_payment); ?>
<?php echo Form::input('date_payment_label',$o->display('date_payment'),array('class'=>'span2','label'=>'Date Paid','add-on'=>'<i class="icon-calendar"></i>','disabled')); ?> <?php echo Form::select('checkout_id',ORM::factory('Checkout')->list_select(),$o->checkout_id,array('label'=>'Payment Method','required')); ?>
</div> <?php echo Form::input('total_amt',$o->total_amt,array('class'=>'span2','label'=>'Amount','placeholder'=>'Total','help-block'=>sprintf('Credits: %s, Balance: %s',$o->credit(),$o->total()))); ?>
<?php echo Form::input('fees_amt',$o->fees_amt,array('class'=>'span2','label'=>'Fees','placeholder'=>'Fees')); ?>
<?php echo Form::input('account_id_label',$o->account->name(),array('class'=>'span5','label'=>'Account','placeholder'=>'Account','data-provide'=>'typeahead')); ?>
<?php echo Form::hidden('account_id',$o->account_id); ?>
<?php echo Form::input('notes',$o->notes,array('class'=>'span5','label'=>'Notes','placeholder'=>'Any notes about this payment?')); ?>
</fieldset>
<?php echo Form::hidden('date_payment',$o->date_payment); ?> <div class="span8" id="items"</div>
<?php echo Form::select('checkout_id',ORM::factory('Checkout')->list_select(),$o->checkout_id,array('label'=>'Payment Method','required')); ?>
<?php echo Form::input('total_amt',$o->total_amt,array('class'=>'span2','label'=>'Amount','placeholder'=>'Total','help-block'=>sprintf('Credits: %s, Balance: %s',$o->credit(),$o->total()))); ?>
<?php echo Form::input('fees_amt',$o->fees_amt,array('class'=>'span2','label'=>'Fees','placeholder'=>'Fees')); ?>
<?php echo Form::input('account_id_label',$o->account->name(),array('class'=>'span5','label'=>'Account','placeholder'=>'Account','data-provide'=>'typeahead')); ?>
<?php echo Form::hidden('account_id',$o->account_id); ?>
<?php echo Form::input('notes',$o->notes,array('class'=>'span5','label'=>'Notes','placeholder'=>'Any notes about this payment?')); ?>
</fieldset>
<td><div id='items'></div></td> <?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?>
<?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?> </div> <!-- /span -->
</div> <!-- /span -->
</div> <!-- /row -->

View File

@ -1,13 +1,11 @@
<div class="row"> <div class="span11">
<div class="span9 offset1"> <fieldset>
<fieldset> <legend>Ezypay Payment</legend>
<legend>Ezypay Payment</legend>
<?php echo Form::hidden('payer',$_POST['payer']); ?> <?php echo Form::hidden('payer',$_POST['payer']); ?>
<?php echo Form::file('transaction',array('label'=>'Transaction File','required','help-block'=>'AddItems')); ?> <?php echo Form::file('transaction',array('label'=>'Transaction File','required','help-block'=>'AddItems')); ?>
<?php echo Form::file('payment',array('label'=>'Payment File','required','help-block'=>'BillDetails')); ?> <?php echo Form::file('payment',array('label'=>'Payment File','required','help-block'=>'BillDetails')); ?>
</fieldset> </fieldset>
<?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?> <?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?>
</div> <!-- /span --> </div> <!-- /span -->
</div> <!-- /row -->

View File

@ -1,18 +1,16 @@
<div class="row"> <div class="span11">
<div class="span9 offset1"> <fieldset>
<fieldset> <legend>Bulk Payment Details</legend>
<legend>Bulk Payment Details</legend> </fieldset>
</fieldset>
<div class="dl-horizontal"> <div class="dl-horizontal">
<dt>Total</dt> <dt>Total</dt>
<dd><?php echo $total; ?></dd> <dd><?php echo $total; ?></dd>
<dt>Fees</dt> <dt>Fees</dt>
<dd><?php echo $fee; ?></dd> <dd><?php echo $fee; ?></dd>
<dt>Payments</dt> <dt>Payments</dt>
<dd><?php echo $table; ?></dd> <dd><?php echo $table; ?></dd>
</div> <!-- /dl-horizontal --> </div> <!-- /dl-horizontal -->
</div> <!-- /span --> </div> <!-- /span -->
</div> <!-- /row -->

View File

@ -1,16 +1,17 @@
<table class="table table-striped table-condensed table-hover"> <table class="table table-striped table-condensed table-hover">
<thead> <thead>
<tr> <tr>
<th>Invoice</th> <th>Invoice</th>
<th>Date Issue</th> <th>Date Issue</th>
<th>Date Due</th> <th>Date Due</th>
<th class="text-right">Total</th> <th class="text-right">Total</th>
<th class="text-right">Payments</th> <th class="text-right">Payments</th>
<th class="text-right">Due</th> <th class="text-right">Due</th>
<th class="text-right">Alloc</th> <th class="text-right">Alloc</th>
</tr> </tr>
</thead> </thead>
<tbody>
<?php $c=0;foreach ($o->items('ALLOC') as $pio) : ?> <?php $c=0;foreach ($o->items('ALLOC') as $pio) : ?>
<tr> <tr>
<td><?php echo HTML::anchor(URL::link('user','invoice/view/'.$pio->invoice_id),$pio->invoice->id()); ?></td> <td><?php echo HTML::anchor(URL::link('user','invoice/view/'.$pio->invoice_id),$pio->invoice->id()); ?></td>
@ -27,5 +28,5 @@
<td class="text-right" colspan="6">Unapplied</td> <td class="text-right" colspan="6">Unapplied</td>
<td class="text-right"><?php echo Form::input('invoice_item[excess]',$o->balance(TRUE),array('class'=>'span1','nocg'=>TRUE,'disabled'=>'disabled')); ?></td> <td class="text-right"><?php echo Form::input('invoice_item[excess]',$o->balance(TRUE),array('class'=>'span1','nocg'=>TRUE,'disabled'=>'disabled')); ?></td>
</tr> </tr>
</tbody>
</table> </table>

View File

@ -47,7 +47,7 @@ class Controller_Admin_Product extends Controller_Product {
$output = _('Unable to find translate data'); $output = _('Unable to find translate data');
} else { } else {
$pcto = $pco->product_category_translate->where('language_id','=',$_REQUEST['key'])->find(); $pcto = $pco->translate->where('language_id','=',$_REQUEST['key'])->find();
$output = View::factory('product/category/admin/ajaxtranslate') $output = View::factory('product/category/admin/ajaxtranslate')
->set('o',$pcto); ->set('o',$pcto);
@ -161,24 +161,22 @@ $(document).ready(function() {
Block::factory() Block::factory()
->title(_('Products')) ->title(_('Products'))
->title_icon('icon-th') ->title_icon('icon-th')
->body(Table::display( ->body(Table::factory()
$products, ->data($products)
25, ->page_items(25)
array( ->columns(array(
'id'=>array('label'=>'ID','url'=>URL::link('admin','product/view/')), 'id'=>'ID',
'title()'=>array('label'=>'Details'), 'title()'=>'Details',
'status'=>array('label'=>'Active'), 'status'=>'Active',
'prod_plugin_file'=>array('label'=>'Plugin Name'), 'prod_plugin_file'=>'Plugin Name',
'prod_plugin_data'=>array('label'=>'Plugin Data'), 'prod_plugin_data'=>'Plugin Data',
'price_type'=>array('label'=>'Price Type'), 'price_type'=>'Price Type',
'taxable'=>array('label'=>'Taxable'), 'taxable'=>'Taxable',
'count_services()'=>array('label'=>'Services'), 'service->list_count()'=>'Services',
'count_invoices()'=>array('label'=>'Invoices'), 'invoice->list_count()'=>'Invoices',
), ))
array( ->prepend(array(
'page'=>TRUE, 'id'=>array('url'=>URL::link('admin','product/edit/')),
'type'=>'select',
'form'=>URL::link('admin','product/view'),
))); )));
} }
@ -191,21 +189,19 @@ $(document).ready(function() {
Block::factory() Block::factory()
->title(sprintf('%s: %s',_('Current Services Using this Product'),$po->title())) ->title(sprintf('%s: %s',_('Current Services Using this Product'),$po->title()))
->title_icon('icon-th-list') ->title_icon('icon-th-list')
->body(Table::display( ->body(Table::factory()
$po->services()->find_all(), ->data($po->service->where_active()->find_all())
25, ->page_items(25)
array( ->columns(array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')), 'id'=>'ID',
'account->accnum()'=>array(), 'account->accnum()'=>'Acc Num',
'account->name()'=>array('label'=>'Account'), 'account->name()'=>'Account',
'name()'=>array('label'=>'Details'), 'name()'=>'Details',
'status'=>array('label'=>'Active'), 'status'=>'Active',
'price(TRUE,TRUE)'=>array('label'=>'Price','align'=>'right'), 'price(TRUE,TRUE)'=>'Price',
), ))
array( ->prepend(array(
'page'=>TRUE, 'id'=>array('url'=>URL::link('user','service/view/')),
'type'=>'select',
'form'=>URL::link('user','service/view'),
))); )));
} }
} }

View File

@ -48,12 +48,11 @@ class Model_Product extends ORM_OSB {
protected $_save_message = TRUE; protected $_save_message = TRUE;
/** // Our database index for pricing values
* Which categories is this product available in private $_price_options = array(
*/ 'base'=>'price_base',
public function categories() { 'setup'=>'price_setup',
return $this->avail_category; );
}
public function cost($annual=FALSE) { public function cost($annual=FALSE) {
return $this->plugin() ? $this->plugin()->cost($annual) : 0; return $this->plugin() ? $this->plugin()->cost($annual) : 0;
@ -72,7 +71,7 @@ class Model_Product extends ORM_OSB {
* This will render the product feature summary information * This will render the product feature summary information
*/ */
public function feature_summary() { public function feature_summary() {
return (is_null($plugin = $this->plugin())) ? HTML::nbsp('') : $plugin->feature_summary(); return (is_null($x=$this->plugin())) ? HTML::nbsp('') : $x->render_view();
} }
/** /**
@ -116,6 +115,54 @@ class Model_Product extends ORM_OSB {
return (is_null($x = $this->plugin())) ? NULL : $x->render_edit(); return (is_null($x = $this->plugin())) ? NULL : $x->render_edit();
} }
/**
* Return the price for the particular group and price option for the period
*/
public function price($grp,$period,$price_option,$taxed=FALSE) {
if (is_null($option=$this->price_option($price_option)) OR is_null($x=$this->keyget('price_group',$period)))
return NULL;
if (isset($x[$grp][$option]))
return $taxed ? Tax::add($x[$grp][$option]) : $x[$grp][$option];
else
return NULL;
}
/**
* For the specific user, get the best price
*
* @todo change this to be the overall contract price, if there is a contract
*/
public function price_best($period,$taxed=FALSE) {
$result = NULL;
$x = NULL;
foreach (Auth::instance()->get_groups() as $go) {
$price = $this->price($go->id,$period,'base',$taxed);
if ($go->pricing AND ! is_null($price) AND (is_null($result) OR $x > $price)) {
$result = $go;
$x = $price;
}
}
return is_null($result) ? ORM::factory('Group',0) : $result;
}
/**
* Get the database index for a price option
*/
public function price_option($option) {
return isset($this->_price_options[$option]) ? $this->_price_options[$option] : NULL;
}
/**
* Return the available pricing options
*/
public function price_options() {
return $this->_price_options;
}
public function save(Validation $validation=NULL) { public function save(Validation $validation=NULL) {
parent::save($validation); parent::save($validation);
@ -135,13 +182,6 @@ class Model_Product extends ORM_OSB {
return $this; return $this;
} }
/**
* List the services that are linked to this product
*/
public function services($active=FALSE) {
return $active ? $this->service->where_active() : $this->service;
}
public function supplier() { public function supplier() {
return $this->plugin() ? $this->plugin()->supplier() : 'other'; return $this->plugin() ? $this->plugin()->supplier() : 'other';
} }
@ -158,84 +198,5 @@ class Model_Product extends ORM_OSB {
return $x->loaded() ? $x->display('name') : 'No Title'; return $x->loaded() ? $x->display('name') : 'No Title';
} }
public function list_type($type) {
return $this->where('prod_plugin_file','=',$type)->find_all();
}
/**
* Return the best price to the uesr based on the users group's memberships
* @todo This needs to be tested with more than one price group enabled
*/
public function get_price_array() {
// Figure out our eligable groups
// @todo Need to work out our default groups elsewhere, not in product
// All users are members of the all user group "0"
$groups = array(0);
if (Auth::instance()->logged_in())
foreach (Auth::instance()->get_user()->group->find_all() as $go)
array_push($groups,$go->id);
// Work out the best price for the user
$price = array();
if (is_array($this->price_group))
foreach ($this->price_group as $bill_freq => $pg) {
if (isset($pg['show']) AND $pg['show'])
foreach ($groups as $gid) {
if (! empty($pg[$gid])) {
if (empty($price[$bill_freq]['price_base'])
OR ($pg[$gid]['price_base'] AND $price[$bill_freq]['price_base'] > $pg[$gid]['price_base'])) {
$price[$bill_freq]['price_setup'] = $pg[$gid]['price_setup'];
$price[$bill_freq]['price_base'] = $pg[$gid]['price_base'];
}
}
}
}
// @todo Ugly hack
return $price ? $price : array('0'=>array('price_base'=>0,'price_setup'=>0));
}
/**
* Return the configured price groups for this product
*/
public function availPriceGroups() {
// @todo This needs to be worked out dynamically
return array(0,1);
}
/**
* Return the available pricing options
*/
public function availPriceOptions() {
// @todo This needs to be worked out dynamically
return array('price_base','price_setup');
}
/**
* List the number of services using this product
*/
public function count_services() {
return $this->service->list_count(TRUE);
}
/**
* List the number of invoices using this product
*/
public function count_invoices() {
return $this->invoice->list_count(TRUE);
}
/**
* Return the price for the particle group and price option for the period
*/
public function price($grp,$period,$option,$taxed=FALSE) {
$x = $this->keyget('price_group',$period);
if (isset($x[$grp][$option]))
return $taxed ? Tax::add($x[$grp][$option]) : $x[$grp][$option];
else
return NULL;
}
} }
?> ?>

View File

@ -46,7 +46,7 @@ class Model_Product_Category extends ORM_OSB {
$result = array(); $result = array();
foreach (ORM::factory('Product')->where_active()->find_all() as $po) foreach (ORM::factory('Product')->where_active()->find_all() as $po)
if (in_array($this->id,$po->categories())) if (in_array($this->id,$po->avail_category))
array_push($result,$po); array_push($result,$po);
return $result; return $result;

View File

@ -14,8 +14,8 @@ class Model_Product_Category_Translate extends ORM_OSB {
protected $_created_column = FALSE; protected $_created_column = FALSE;
protected $_updated_column = FALSE; protected $_updated_column = FALSE;
protected $_belongs_to = array( protected $_has_one = array(
'product_category'=>array(), 'language'=>array('foreign_key'=>'id'),
); );
protected $_save_message = TRUE; protected $_save_message = TRUE;

View File

@ -18,12 +18,6 @@ abstract class Model_Product_Plugin extends ORM_OSB {
*/ */
abstract public function cost($annual=FALSE); abstract public function cost($annual=FALSE);
/**
* 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();
/** /**
* Return the name of the plugin * Return the name of the plugin
*/ */
@ -31,12 +25,38 @@ abstract class Model_Product_Plugin extends ORM_OSB {
return strtolower(preg_replace('/(.*)_([a-zA-Z]+)$/',"$2",get_class($this))); return strtolower(preg_replace('/(.*)_([a-zA-Z]+)$/',"$2",get_class($this)));
} }
/**
* Get all the products using this plugin
*/
public function products($active=FALSE) {
$x = ORM::factory('Product')
->where('prod_plugin_file','=',$this->plugin())
->and_where('prod_plugin_data','=',$this);
if ($active)
$x->where_active();
return $x->find_all();
}
/** /**
* Form info for admins to update with plugin data * Form info for admins to update with plugin data
*/ */
abstract public function render_edit(); abstract public function render_edit();
abstract public function render_order(); /**
* Form used during service ordering
*/
public function render_order() {
return View::factory(sprintf('product/plugin/%s/order',$this->plugin()));
}
/**
* View the details of the product
*/
public function render_view() {
return View::factory(sprintf('product/plugin/%s/view',$this->plugin()))->set('o',$this);
}
abstract public function supplier(); abstract public function supplier();
} }

View File

@ -17,6 +17,10 @@ class Model_Product_Translate extends ORM_OSB {
'product'=>array(), 'product'=>array(),
); );
protected $_has_one = array(
'language'=>array('foreign_key'=>'id'),
);
protected $_save_message = TRUE; protected $_save_message = TRUE;
} }
?> ?>

View File

@ -1,4 +1,7 @@
<div class="span6"> <fieldset>
<legend><?php echo __(':language description for product :pid',array(':pid'=>$o->id,':language'=>$o->language->name)); ?></legend>
<div class="row">
<?php echo Form::input('translate[name]',$o->name,array( <?php echo Form::input('translate[name]',$o->name,array(
'label'=>'Category Title', 'label'=>'Category Title',
'placeholder'=>'Descriptive Title', 'placeholder'=>'Descriptive Title',
@ -6,7 +9,7 @@
'required', 'required',
'help-block'=>'The title is shown when uses search products by category')); ?> 'help-block'=>'The title is shown when uses search products by category')); ?>
</div> </div>
<div class="span9"> <div class="row">
<?php echo Form::textarea('translate[description_short]',$o->description_short,array( <?php echo Form::textarea('translate[description_short]',$o->description_short,array(
'label'=>'Short Product Description', 'label'=>'Short Product Description',
'placeholder'=>'Short Description', 'placeholder'=>'Short Description',
@ -14,7 +17,7 @@
'required', 'required',
'help-block'=>'Complete description of this category')); ?> 'help-block'=>'Complete description of this category')); ?>
</div> </div>
<div class="span9"> <div class="row">
<?php echo Form::textarea('translate[description_full]',$o->description_full,array( <?php echo Form::textarea('translate[description_full]',$o->description_full,array(
'label'=>'Full Product Description', 'label'=>'Full Product Description',
'placeholder'=>'Full Description', 'placeholder'=>'Full Description',
@ -23,6 +26,7 @@
'editor'=>'wysihtml5', 'editor'=>'wysihtml5',
'help-block'=>'Complete description of this category')); ?> 'help-block'=>'Complete description of this category')); ?>
</div> </div>
</fieldset>
<?php echo Style::factory()->render_all(); ?> <?php echo Style::factory()->render_all(); ?>
<?php echo Script::factory()->render_all(); ?> <?php echo Script::factory()->render_all(); ?>

View File

@ -1,76 +1,70 @@
<div class="row"> <div class="span11">
<div class="span9 offset1"> <fieldset>
<fieldset> <legend>Update Product</legend>
<legend>Update Product</legend>
<div class="row"> <div class="row">
<div class="tabbable span9"> <div class="tabbable span9">
<ul class="nav nav-tabs">
<?php $c=0;foreach (StaticList_RecurSchedule::table() as $k=>$v) : ?> <ul class="nav nav-tabs">
<?php $c=0;foreach (StaticList_RecurSchedule::table() as $k=>$v) : ?>
<li class="<?php echo $c++ ? '' : 'active'; ?>"><a href="#tab<?php echo $k; ?>" data-toggle="tab"><?php echo $v; ?></a></li> <li class="<?php echo $c++ ? '' : 'active'; ?>"><a href="#tab<?php echo $k; ?>" data-toggle="tab"><?php echo $v; ?></a></li>
<?php endforeach ?> <?php endforeach ?>
</ul> </ul>
<div class="tab-content">
<?php $c=0;foreach (StaticList_RecurSchedule::table() as $k=>$v) : ?>
<div class="tab-content">
<?php $c=0;foreach (StaticList_RecurSchedule::table() as $k=>$v) : ?>
<div class="tab-pane <?php echo $c++ ? '' : 'active'; ?>" id="tab<?php echo $k; ?>"> <div class="tab-pane <?php echo $c++ ? '' : 'active'; ?>" id="tab<?php echo $k; ?>">
<?php echo Form::checkbox("price_group[$k][show]",1,$o->is_price_shown($k),array('label'=>'Price Active','class'=>'span2')); ?> <?php echo Form::checkbox("price_group[$k][show]",1,$o->is_price_shown($k),array('label'=>'Price Active','class'=>'span2')); ?>
<?php foreach ($o->availPriceGroups() as $g) : ?> <?php foreach (ORM::factory('Group')->list_pricegroups() as $go) : ?>
<div class="row">
<div class="span2"><?php echo ORM::factory('Group',$g)->name; ?></div> <div class="row">
<?php foreach ($o->availPriceOptions() as $po) : ?> <div class="span2"><?php echo $go->name; ?></div>
<div class="span2">
<?php echo Form::input("price_group[$k][$g][$po]",$o->price($g,$k,$po),array('placeholder'=>$po,'nocg'=>TRUE,'class'=>'span2')); ?> <?php foreach (array_keys($o->price_options()) as $po) : ?>
<div class="span2">
<?php echo Form::input("price_group[$k][{$go->id}][{$o->price_option($po)}]",$o->price($go->id,$k,$po),array('placeholder'=>$po,'nocg'=>TRUE,'class'=>'span2')); ?>
</div>
<?php endforeach ?> <!-- /price_options() -->
</div> </div>
<?php endforeach ?> <!-- /availPriceOptions() -->
</div> <?php endforeach ?> <!-- /list_pricegroups() -->
<?php endforeach ?> <!-- /availPriceGroups() -->
</div> <!-- /tab-pane --> </div> <!-- /tab-pane -->
<?php endforeach ?> <!-- /StaticList_RecurSchedule -->
</div> <!-- /tab-content -->
</div> <!-- /tabbable -->
</div> <!-- /row -->
<br> <?php endforeach ?> <!-- /StaticList_RecurSchedule -->
</div> <!-- /tab-content -->
<div class="row"> </div> <!-- /tabbable -->
<div class="span3"> </div> <!-- /row -->
<?php echo StaticList_YesNo::form('status',$o->status,FALSE,array('label'=>'Product Active','class'=>'span1')); ?>
</div>
</div>
<div class="row"> <br>
<div class="span3">
<?php echo StaticList_RecurSchedule::form('price_recurr_default',$o->price_recurr_default,FALSE,array('label'=>'Default Period','class'=>'span2')); ?></td>
</div>
</div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span3"> <?php echo StaticList_YesNo::form('status',$o->status,FALSE,array('label'=>'Product Active','class'=>'span1')); ?>
<?php echo Form::input('position',$o->position,array('label'=>'Order','class'=>'span1')); ?> </div>
</div>
</div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span5"> <?php echo StaticList_RecurSchedule::form('price_recurr_default',$o->price_recurr_default,FALSE,array('label'=>'Default Period','class'=>'span2')); ?></td>
<?php echo Form::select('language_id',ORM::factory('Language')->list_select(TRUE),'',array('label'=>'Language','required')); ?> </div> <!-- /row -->
</div>
</div> <!-- /row -->
<div class="row"> <div class="row">
<div id="translate"></div> <?php echo Form::input('position',$o->position,array('label'=>'Order','class'=>'span1')); ?>
</div> <!-- /row --> </div> <!-- /row -->
<?php if ($plugin_form) { echo '<br/>'.$plugin_form; } ?> <div class="row">
<?php echo Form::select('language_id',ORM::factory('Language')->list_select(TRUE),'',array('label'=>'Language','required')); ?>
</div> <!-- /row -->
</fieldset>
<div class="row"> <div id="translate"></div>
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</div>
</fieldset> <?php if ($plugin_form) { echo '<br/>'.$plugin_form; } ?>
</div> <!-- /span -->
</div> <!-- /row --> <div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</div>
</div> <!-- /span -->

View File

@ -1,4 +1,7 @@
<div class="span6"> <fieldset>
<legend><?php echo __(':language description for product category :pid',array(':pid'=>$o->id,':language'=>$o->language->name)); ?></legend>
<div class="row">
<?php echo Form::input('translate[name]',$o->name,array( <?php echo Form::input('translate[name]',$o->name,array(
'label'=>'Category Title', 'label'=>'Category Title',
'placeholder'=>'Descriptive Title', 'placeholder'=>'Descriptive Title',
@ -6,7 +9,7 @@
'required', 'required',
'help-block'=>'The title is shown when uses search products by category')); ?> 'help-block'=>'The title is shown when uses search products by category')); ?>
</div> </div>
<div class="span9"> <div class="row">
<?php echo Form::textarea('translate[description]',$o->description,array( <?php echo Form::textarea('translate[description]',$o->description,array(
'label'=>'Category Description', 'label'=>'Category Description',
'placeholder'=>'Description', 'placeholder'=>'Description',
@ -15,6 +18,7 @@
'editor'=>'wysihtml5', 'editor'=>'wysihtml5',
'help-block'=>'Complete description of this category')); ?> 'help-block'=>'Complete description of this category')); ?>
</div> </div>
</fieldset>
<?php echo Style::factory()->render_all(); ?> <?php echo Style::factory()->render_all(); ?>
<?php echo Script::factory()->render_all(); ?> <?php echo Script::factory()->render_all(); ?>

View File

@ -1,36 +1,31 @@
<div class="row"> <div class="span11">
<div class="span9 offset1"> <fieldset>
<fieldset> <legend>Update Category</legend>
<legend>Update Category</legend>
<div class="row"> <div class="row">
<div class="span3"> <?php echo StaticList_YesNo::form('status',$o->status,FALSE,array('label'=>'Active','class'=>'span1')); ?>
<?php echo StaticList_YesNo::form('status',$o->status,FALSE,array('label'=>'Active','class'=>'span1')); ?> </div> <!-- /row -->
</div>
</div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span5"> <?php echo Form::select('template',$o->templates(),$o->template,array('label'=>'List Template')); ?>
<?php echo Form::select('template',$o->templates(),$o->template,array('label'=>'List Template')); ?> </div> <!-- /row -->
</div>
</div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span5"> <?php echo StaticList_RecurSchedule::form('recur_schedule',$o->recur_schedule,FALSE,array('label'=>'Show Pricing Schedule','required'));?>
<?php echo Form::select('language_id',ORM::factory('Language')->list_select(TRUE),'',array('label'=>'Language','required')); ?> </div> <!-- /row -->
</div>
</div> <!-- /row -->
<div class="row"> <div class="row">
<div id="translate"></div> <?php echo Form::select('language_id',ORM::factory('Language')->list_select(TRUE),'',array('label'=>'Language','required')); ?>
</div> <!-- /row --> </div> <!-- /row -->
<div class="row"> </fieldset>
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button> <div id="translate"></div>
<button type="button" class="btn">Cancel</button>
</div> <div class="row">
</div> <div class="offset2">
</fieldset> <button type="submit" class="btn btn-primary">Save changes</button>
</div> <!-- /span --> <button type="button" class="btn">Cancel</button>
</div> <!-- /row --> </div>
</div>
</div> <!-- /span -->

View File

@ -5,23 +5,21 @@
</div> </div>
<?php $c=0;foreach ($o->subcategories->find_all() as $pco) : ?> <?php $c=0;foreach ($o->subcategories->find_all() as $pco) : ?>
<?php if (! ($c++%3) AND $c>1) : ?> <?php if (! ($c++%3) AND $c>1) : ?>
</div> <!-- /row --> </div> <!-- /row -->
<hr class="row-divider" /> <hr class="row-divider" />
<div class="row divider service-container"> <div class="row divider service-container">
<div class="grid-3">&nbsp;</div>
<?php endif ?>
<div class="grid-3"> <div class="grid-3">
&nbsp; <div class="service-item">
<h3><i class="icon-tint"></i><?php echo $pco->title(); ?></h3>
<?php $x=350;echo strlen($pco->description())<$x ? $pco->description() : substr($pco->description(),0,$x).'...'; ?>
<p><a href="<?php echo URL::site('product/category/'.$pco->id); ?>" class="">More Details »</a></p>
</div> <!-- /service -->
</div> </div>
<?php endif ?>
<div class="grid-3">
<div class="service-item">
<h3><i class="icon-tint"></i><?php echo $pco->title(); ?></h3>
<?php $x=350;echo strlen($pco->description())<$x ? $pco->description() : substr($pco->description(),0,$x).'...'; ?>
<p><a href="<?php echo URL::site('product/category/'.$pco->id); ?>" class="">More Details »</a></p>
</div> <!-- /service -->
</div>
<?php endforeach ?> <?php endforeach ?>
</div> <!-- /row --> </div> <!-- /row -->
</div> <!-- /container --> </div> <!-- /container -->

View File

@ -1,15 +1,11 @@
<div id="page-title"> <div id="page-title">
<h1><?php echo $o->title(); ?></h1> <h1><?php echo $o->title(); ?></h1>
<?php echo $o->description(); ?>
<?php echo $o->description(); ?>
</div> <!-- /page-title --> </div> <!-- /page-title -->
<div id="container"> <div id="container">
<div class="row"> <div class="span9">
<div class="span9"> <?php echo $o->description(TRUE); ?>
<?php echo $o->description(TRUE); ?>
</div> <!-- /row -->
</div> <!-- /row --> </div> <!-- /row -->
<!-- <div class="row-divider"></div> -->
</div> <!-- /container --> </div> <!-- /container -->

View File

@ -28,9 +28,6 @@ class Controller_Admin_Service extends Controller_Service {
Script::factory() Script::factory()
->type('stdin') ->type('stdin')
->data(' ->data('
var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
$(document).ready(function() { $(document).ready(function() {
$("select[name=product_id]").change(function() { $("select[name=product_id]").change(function() {
// If we select a blank, then dont continue // If we select a blank, then dont continue
@ -56,11 +53,10 @@ $(document).ready(function() {
$("#date_next_invoice_label").datepicker({ $("#date_next_invoice_label").datepicker({
autoclose : true, autoclose : true,
startDate : now,
format : "dd-M-yyyy", format : "dd-M-yyyy",
todayBtn : true, todayBtn : true,
}).on("hide",function(ev) { }).on("hide",function(ev) {
$("input[name=date_next_invoicel]").val(ev.date.valueOf()/1000); $("input[name=date_next_invoice]").val(ev.date.valueOf()/1000);
}); });
$("input[name=account_id_label]").typeahead({ $("input[name=account_id_label]").typeahead({
@ -127,17 +123,29 @@ $(document).ready(function() {
Script::factory() Script::factory()
->type('stdin') ->type('stdin')
->data(' ->data('
var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
$(document).ready(function() { $(document).ready(function() {
$("#date_next_invoice_label").datepicker({ $("#date_next_invoice_label").datepicker({
autoclose : true, autoclose : true,
startDate : now,
format : "dd-M-yyyy", format : "dd-M-yyyy",
todayBtn : true, todayBtn : true,
}).on("hide",function(ev) { }).on("hide",function(ev) {
$("input[name=date_next_invoicel]").val(ev.date.valueOf()/1000); $("input[name=date_next_invoice]").val(ev.date.valueOf()/1000);
});
$("#service_connect_date_label").datepicker({
autoclose : true,
format : "dd-M-yyyy",
todayBtn : true,
}).on("hide",function(ev) {
$("input[id=service_connect_date]").val(ev.date.valueOf()/1000);
});
$("#service_contract_date_label").datepicker({
autoclose : true,
format : "dd-M-yyyy",
todayBtn : true,
}).on("hide",function(ev) {
$("input[id=service_contract_date]").val(ev.date.valueOf()/1000);
}); });
}); });
'); ');
@ -188,12 +196,12 @@ $(document).ready(function() {
public function action_listdomainservicesbydnshost() { public function action_listdomainservicesbydnshost() {
$svs = ORM::factory('Service')->list_bylistgroup('DOMAIN'); $svs = ORM::factory('Service')->list_bylistgroup('DOMAIN');
Sort::MAsort($svs,'plugin()->service_plugin_host,name()'); Sort::MAsort($svs,'plugin()->host,name()');
$list = array(); $list = array();
foreach ($svs as $so) foreach ($svs as $so)
$list[$so->plugin()->service_plugin_host->host_server_id][] = $so; $list[$so->plugin()->host->host_server_id][] = $so;
foreach (array_keys($list) as $sid) foreach (array_keys($list) as $sid)
Block::add(array( Block::add(array(
@ -204,8 +212,8 @@ $(document).ready(function() {
array( array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')), 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'service_name()'=>array('label'=>'Details'), 'service_name()'=>array('label'=>'Details'),
'plugin()->domain_registrar->id'=>array('label'=>'SID'), 'plugin()->registrar->id'=>array('label'=>'SID'),
'plugin()->domain_registrar->name'=>array('label'=>'Supplier'), 'plugin()->registrar->name'=>array('label'=>'Supplier'),
'display("date_next_invoice")'=>array('label'=>'Next Invoice'), 'display("date_next_invoice")'=>array('label'=>'Next Invoice'),
), ),
array( array(
@ -218,7 +226,7 @@ $(document).ready(function() {
public function action_listhostservicesbysupplier() { public function action_listhostservicesbysupplier() {
$svs = ORM::factory('Service')->list_bylistgroup('HOST'); $svs = ORM::factory('Service')->list_bylistgroup('HOST');
Sort::MAsort($svs,'plugin()->host_server,name()'); Sort::MAsort($svs,'plugin()->host,name()');
$list = array(); $list = array();
@ -264,26 +272,28 @@ $(document).ready(function() {
// Validate the transactions // Validate the transactions
$bt = NULL; $bt = NULL;
$save = (isset($_REQUEST['go']) && $_REQUEST['go']=1) ? 1 : 0; $pr = TRUE; // Next entry is a pro-rata
$xsid=197;
foreach ($so->transactions()->where('item_type','=',0)->find_all() as $iio) { foreach ($so->transactions()->where('item_type','=',0)->find_all() as $iio) {
if (! $iio->invoice->status) continue;
// @todo This hard coding of 3070 should be removed. // @todo This hard coding of 3070 should be removed.
if ($iio->service_id == $xsid AND $iio->invoice_id < 3070) continue; // $xsid=197;
if ($iio->quantity < 0 OR $iio->price_base < 0) // if (($iio->service_id == $xsid AND $iio->invoice_id < 3070) OR in_array($iio->id,array(960))) continue;
continue;
if (in_array($iio->id,array(960))) if (! $iio->invoice->status OR $iio->void)
continue; continue;
if ($iio->invoice_id > 4000 OR $iio->product->prod_plugin_file=="ADSL") if ($iio->quantity < 0 OR $iio->price_base < 0) {
$a = FALSE; $bt = $iio->date_start;
else $pr = TRUE;
$a = TRUE;
continue;
}
if (is_null($bt)) if (is_null($bt))
$bt = $iio->date_start; $bt = $iio->date_start;
$pdata = Period::details($iio->recurring_schedule,$a ? NULL : $iio->product->price_recurr_weekday,$bt,TRUE,TRUE); $a = ($iio->invoice_id > 4000 OR $iio->product->prod_plugin_file == 'ADSL') ? FALSE : TRUE;
$pdata = Period::details($iio->recurring_schedule,$a ? NULL : $iio->product->price_recurr_weekday,$bt,TRUE,$iio->product->price_recurr_strict);
switch ($iio->recurring_schedule) { switch ($iio->recurring_schedule) {
case 1: case 1:
@ -295,22 +305,25 @@ $(document).ready(function() {
$iio->date_start=$pdata['start_time']; $iio->date_start=$pdata['start_time'];
} }
if ($iio->date_stop != $pdata['end_time']) { if (! $pr AND $iio->date_stop != $pdata['end_time']) {
$doutput .= sprintf('%s: Set end_time: %s [%s] <br/>',$iio->id,Config::date($pdata['end_time']),$pdata['end_time']); $doutput .= sprintf('%s: Set end_time: %s [%s] <br/>',$iio->id,Config::date($pdata['end_time']),$pdata['end_time']);
$iio->date_stop=$pdata['end_time']; $iio->date_stop = $pdata['end_time'];
} }
$bt = $pdata['end_time']+86400;
//$doutput .= sprintf('%s: BT now: %s (%s) [%s]<br/>',$iio->id,Config::date($bt),Config::date($pdata['end_time']),$bt); $bt = ($pr ? $iio->date_stop : $pdata['end_time'])+86400;
// $doutput .= sprintf('%s: BT now: %s (%s) [%s]<br/>',$iio->id,Config::date($bt),Config::date($pdata['end_time']),$bt);
break; break;
default: default:
$doutput .= sprintf('%s: %s Not handled',$iio->id,$iio->recurring_schedule); $doutput .= sprintf('%s: %s Not handled',$iio->id,$iio->recurring_schedule);
} }
$pr = FALSE;
//$doutput .= '<br/>'; //$doutput .= '<br/>';
if ($save) { if (($x=$this->request->query('go')) AND $x==1)
$iio->save(); $iio->save();
}
} }
if (isset($_REQUEST['go'])) if (isset($_REQUEST['go']))

View File

@ -25,8 +25,8 @@ class Controller_User_Service extends Controller_Service {
$amo = $so->plugin(isset($_REQUEST['t']) ? $_REQUEST['t'] : ''); $amo = $so->plugin(isset($_REQUEST['t']) ? $_REQUEST['t'] : '');
$o = array( $o = array(
'u'=>$amo->username_value() ? $amo->username_value() : strtolower($amo->name()), 'u'=>$amo->username() ? $amo->username() : strtolower($amo->name()),
'p'=>(! $k OR ! $this->request->is_ajax() OR ! $so->loaded() OR ! isset($_REQUEST['k']) OR $k != $_REQUEST['k']) ? Random::char() : $amo->password_value(), 'p'=>(! $k OR ! $this->request->is_ajax() OR ! $so->loaded() OR ! isset($_REQUEST['k']) OR $k != $_REQUEST['k']) ? Random::char() : $amo->password(),
); );
$this->response->headers('Content-Type','application/json'); $this->response->headers('Content-Type','application/json');

View File

@ -29,6 +29,8 @@ class Model_Service extends ORM_OSB {
'account'=>array(), 'account'=>array(),
); );
protected $_save_message = TRUE;
// Validation rules // Validation rules
public function rules() { public function rules() {
$x = Arr::merge(parent::rules(), array( $x = Arr::merge(parent::rules(), array(
@ -167,7 +169,7 @@ class Model_Service extends ORM_OSB {
$iio->find(); $iio->find();
$x = (! $iio->loaded() AND $this->date_next_invoice) ? $this->date_next_invoice-86400 : $iio->date_stop; $x = (! $iio->loaded() AND $this->date_next_invoice) ? $this->date_next_invoice-86400 : ($iio->total() < 0 ? $iio->date_start-86400 : $iio->date_stop);
return $format ? Config::date($x) : $x; return $format ? Config::date($x) : $x;
} }
@ -255,7 +257,7 @@ class Model_Service extends ORM_OSB {
* Return a descriptive name for this service * Return a descriptive name for this service
*/ */
public function service_name() { public function service_name() {
return is_null($plugin=$this->plugin()) ? $this->name() : $plugin->service_name(); return is_null($x=$this->plugin()) ? $this->name() : $x->service_name();
} }
/** /**
@ -286,16 +288,17 @@ class Model_Service extends ORM_OSB {
case 'invoice_detail_items': case 'invoice_detail_items':
return is_null($plugin) ? array() : $plugin->_details($type); return is_null($plugin) ? array() : $plugin->_details($type);
case 'service_view':
return is_null($plugin) ? HTML::nbsp('') : $plugin->render_view();
default: default:
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type)); throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
} }
} }
public function service_view() {
return ! is_object($x=$this->plugin()) ? HTML::nbsp('') : $x->render_view();
}
public function transactions() { public function transactions() {
return $this->invoice_item->order_by('date_start')->order_by('date_stop'); return $this->invoice_item->order_by('date_start','ASC')->order_by('product_id','ASC')->order_by('date_stop','ASC');
} }
/** LIST FUNCTIONS **/ /** LIST FUNCTIONS **/

View File

@ -13,6 +13,10 @@ abstract class Model_Service_Plugin extends ORM_OSB {
// Reset any sorting that may be defined in our parent // Reset any sorting that may be defined in our parent
protected $_sorting = array(); protected $_sorting = array();
protected $_belongs_to = array(
'service'=>array(),
);
/** /**
* When does our service expire * When does our service expire
*/ */
@ -26,56 +30,43 @@ abstract class Model_Service_Plugin extends ORM_OSB {
/** /**
* The table attributes that provide username/password values * The table attributes that provide username/password values
*/ */
abstract public function password_value(); abstract public function password();
abstract public function username_value(); abstract public function username();
/**
* 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));
}
}
/** /**
* Provide the button that launches the management of this service, generally from a 3rd party * Provide the button that launches the management of this service, generally from a 3rd party
*/ */
public function manage_button() { protected function manage() {
// Dont show the manage button for expired or inactive services
if (! $this->service->status OR $this->service->expiring()) if (! $this->service->status OR $this->service->expiring())
return FALSE; return FALSE;
static $k = ''; static $x = '';
// If $k is already set, we've rendered this JS // If $x is already set, we've rendered this JS
if ($k) if (! $x) {
return TRUE; $x = Random::char();
$k = Random::char(); Session::instance()->set('manage_button',$x);
Session::instance()->set('manage_button',$k);
Script::add(array('type'=>'stdin','data'=>' Script::factory()
$(document).ready(function() { ->type('stdin')
var x=0; ->data('
$("button[name=submit]").click(function() { $(document).ready(function() {
var t=$(this).val().split(":"); var x=0;
if (x++) { alert("Session expired, please refresh the page!"); return false; }
$.getJSON("'.URL::link('user','service/ajaxmanage/'.$this->service_id,TRUE).'", { k: "'.$k.'",t: t[1] }, function(data) { $("button[name=submit]").click(function() {
$.each(data, function(key, val) { $("#"+key+"_"+t[0]+"_"+t[1]).val(val); }); var t=$(this).val().split(":");
}).error(function() { alert("There was a problem with the request"); return false; }).success( if (x++) { alert("Session expired, please refresh the page!"); return false; }
function() { $("form[id=id_"+t[0]+"_"+t[1]+"]").submit(); });
}); $.getJSON("'.URL::link('user','service/ajaxmanage/'.$this->service_id,TRUE).'", { k: "'.$x.'",t: t[1] },
});' function(data) {$.each(data, function(key, val) { $("#"+key+"_"+t[0]+"_"+t[1]).val(val); }); })
)); .error(function() { alert("There was a problem with the request"); return false; })
.success(function() { $("form[id=id_"+t[0]+"_"+t[1]+"]").submit(); });
});
});'
);
}
return TRUE; return TRUE;
} }
@ -109,5 +100,23 @@ function() { $("form[id=id_"+t[0]+"_"+t[1]+"]").submit(); });
public function service_name() { public function service_name() {
return sprintf('%s - %s',$this->service->product->title(),$this->name()); return sprintf('%s - %s',$this->service->product->title(),$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

@ -40,7 +40,7 @@
</div> <!-- /row --> </div> <!-- /row -->
</fieldset> </fieldset>
<div id="plugin"></div> <!-- /row --> <div id="plugin"></div>
<div class="row"> <div class="row">
<div class="offset2"> <div class="offset2">
@ -48,4 +48,4 @@
<button type="button" class="btn">Cancel</button> <button type="button" class="btn">Cancel</button>
</div> </div>
</div> </div>
</div> </div> <!-- /span -->

View File

@ -1,54 +1,42 @@
<div class="row"> <div class="span11">
<div class="span9 offset1"> <fieldset>
<fieldset> <legend>Update Service</legend>
<legend>Update Service</legend>
<div class="row"> <div class="row">
<div class="span3"> <?php echo StaticList_YesNo::form('status',$o->status,FALSE,array('label'=>'Active','class'=>'span1')); ?>
<?php echo StaticList_YesNo::form('status',$o->status,FALSE,array('label'=>'Active','class'=>'span1')); ?> </div> <!-- /row -->
</div>
</div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span5"> <?php echo StaticList_RecurSchedule::form('recur_schedule',$o->recur_schedule,FALSE,array('label'=>'Billing Period','required'));?>
<?php echo StaticList_RecurSchedule::form('recur_schedule',$o->recur_schedule,FALSE,array('label'=>'Billing Period','required'));?> </div> <!-- /row -->
</div>
</div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span5 input-append date" id="date_next_invoice_label"> <div class="input-append date" id="date_next_invoice_label">
<?php echo Form::input('date_next_invoice_label',$o->display('date_next_invoice'),array('class'=>'span2','label'=>'Date Next Invoice','add-on'=>'<i class="icon-calendar"></i>','disabled')); ?> <?php echo Form::input('date_next_invoice_label',$o->display('date_next_invoice'),array('class'=>'span2','label'=>'Date Next Invoice','add-on'=>'<i class="icon-calendar"></i>','disabled')); ?>
</div>
<?php echo Form::hidden('date_next_invoice',$o->date_next_invoice); ?>
</div> <!-- /row -->
<div class="row">
<div class="span3">
<?php echo StaticList_YesNo::form('taxable',$o->taxable,FALSE,array('label'=>'Taxable','class'=>'span1')); ?>
</div>
</div> <!-- /row -->
<div class="row">
<div class="span3">
<?php echo StaticList_YesNo::form('suspend_billing',$o->suspend_billing,FALSE,array('label'=>'Suspend Billing','class'=>'span1')); ?>
</div>
</div> <!-- /row -->
<div class="row">
<div class="span3">
<?php echo Form::input('price_override',$o->price_override,array('label'=>'Override Price','class'=>'span1')); ?>
</div>
</div> <!-- /row -->
<?php if ($plugin_form) { echo $plugin_form; } ?>
<div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</div> </div>
</fieldset>
</div> <!-- /span --> <?php echo Form::hidden('date_next_invoice',$o->date_next_invoice); ?>
</div> <!-- /row --> </div> <!-- /row -->
<div class="row">
<?php echo StaticList_YesNo::form('taxable',$o->taxable,FALSE,array('label'=>'Taxable','class'=>'span1')); ?>
</div> <!-- /row -->
<div class="row">
<?php echo StaticList_YesNo::form('suspend_billing',$o->suspend_billing,FALSE,array('label'=>'Suspend Billing','class'=>'span1')); ?>
</div> <!-- /row -->
<div class="row">
<?php echo Form::input('price_override',$o->price_override,array('label'=>'Override Price','class'=>'span1')); ?>
</div> <!-- /row -->
</fieldset>
<?php if ($plugin_form) { echo $plugin_form; } ?>
<div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</div>
</div> <!-- /span -->

View File

@ -1,40 +1,50 @@
<?php if ($so->pending_change()) {?> <?php if ($o->pending_change()) : ?>
Pending change to: <?php echo $so->service_change->list_details(); ?> <div class="span5">
<?php } ?> Pending change to: <?php echo $o->service_change->list_details(); ?>
<br/> </div> <!-- /span -->
<!-- @todo NEEDS TO BE TRANSLATED --> <?php endif ?>
<table class="list-box-left">
<tr class="list-head"> <div class="span6">
<th>ID</th> <fieldset>
<th>Invoice</th> <legend>Service Transaction Details</legend>
<th>Product</th>
<th>IT</th> <table class="table table-striped table-condensed table-hover" id="list-table">
<th>RS</th> <thead>
<th>Start</th> <tr>
<th>Stop</th> <th>ID</th>
<th>Desc</th> <th>Invoice</th>
<th>Quantity</th> <th>IT</th>
<th>Charge</th> <th>RS</th>
</tr> <th class="text-right">Start</th>
<?php $lp=NULL; foreach ($so->transactions()->find_all() as $iio) { ?> <th class="text-right">Stop</th>
<?php if (! is_null($iio->product_id) AND $lp != $iio->product_id) { <th class="text-right">Quantity</th>
$lp = $iio->product_id; ?> <th class="text-right">Charge</th>
<tr class="list-sub-head"> <th>Desc</th>
<th class="id"><?php echo $iio->product_id; ?></th> </tr>
<th colspan="9"><?php echo $iio->product->title(); ?></th> </thead>
</tr>
<?php } ?> <tbody>
<tr class="list-data"> <?php $lp=NULL; foreach ($o->transactions()->find_all() as $iio) : ?>
<td class="id"><?php echo $iio->id; ?></td> <?php if (! is_null($iio->product_id) AND $lp != $iio->product_id) : $lp = $iio->product_id; ?>
<td><?php echo HTML::anchor(URL::link('user','invoice/view/'.$iio->invoice_id),$iio->invoice_id); ?></td> <tr>
<td><?php echo $iio->display('product_id'); ?></td> <th><?php echo $iio->product_id; ?></th>
<td><?php echo $iio->display('item_type'); ?></td> <th colspan="9"><?php echo $iio->product->title(); ?></th>
<td><?php echo $iio->display('recurring_schedule'); ?></td> </tr>
<td><?php echo $iio->display('date_start'); ?></td> <?php endif ?>
<td><?php echo $iio->display('date_stop'); ?></td>
<td><?php echo $iio->display('product_name'); ?></td> <tr>
<td><?php echo $iio->display('quantity'); ?></td> <td><?php echo $iio->id; ?></td>
<td class="right"><?php echo $iio->display('price_base'); ?></td> <td><?php echo HTML::anchor(URL::link('user','invoice/view/'.$iio->invoice_id),$iio->invoice_id); ?></td>
</tr> <td><?php echo $iio->display('item_type'); ?></td>
<?php } ?> <td><?php echo $iio->display('recurring_schedule'); ?></td>
</table> <td class="text-right"><?php echo $iio->display('date_start'); ?></td>
<td class="text-right"><?php echo $iio->display('date_stop'); ?></td>
<td class="text-right"><?php echo $iio->display('quantity'); ?></td>
<td class="text-right"><?php echo $iio->display('price_base'); ?></td>
<td><?php echo $iio->display('product_name'); ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</fieldset>
</div> <!-- /span -->

View File

@ -1,9 +1,8 @@
<div class="row"> <div class="span5">
<fieldset class="span5"> <fieldset>
<legend>Service Information</legend> <legend>Service Information</legend>
<div class="dl-horizontal"> <div class="dl-horizontal">
<dt>Account</dt> <dt>Account</dt>
<dd><?php printf('%s (%s)',$o->account->name(),$o->account->accnum()); ?></dd> <dd><?php printf('%s (%s)',$o->account->name(),$o->account->accnum()); ?></dd>
@ -16,7 +15,8 @@
<dt>Cost</dt> <dt>Cost</dt>
<dd><?php echo (! is_null($o->price_override) ? sprintf('<strike>%s</strike> ',$o->price(TRUE,TRUE,TRUE)) : ''). $o->price(TRUE,TRUE); if ($o->pending_change()) echo ' *'; ?></dd> <dd><?php echo (! is_null($o->price_override) ? sprintf('<strike>%s</strike> ',$o->price(TRUE,TRUE,TRUE)) : ''). $o->price(TRUE,TRUE); if ($o->pending_change()) echo ' *'; ?></dd>
<?php if (is_null($o->price) OR ($o->price<=$o->product->price($o->price_group,$o->recur_schedule,'price_base'))) : ?> <!-- @todo -->
<?php if (is_null($o->price) OR ($o->price<=$o->product->price($o->price_group,$o->recur_schedule,'base'))) : ?>
<dt>Service</dt> <dt>Service</dt>
<dd><?php echo HTML::anchor('product/view/'.$o->product_id,$o->product->title()); ?></dd> <dd><?php echo HTML::anchor('product/view/'.$o->product_id,$o->product->title()); ?></dd>
<?php endif ?> <?php endif ?>
@ -32,103 +32,109 @@
<dt>Current Invoices Due</dt> <dt>Current Invoices Due</dt>
<dd><?php echo $o->due(TRUE); ?></dd> <dd><?php echo $o->due(TRUE); ?></dd>
</div> <!-- /dl-horizontal --> </div> <!-- /dl-horizontal -->
</fieldset> </fieldset>
<?php if ($o->product->feature_summary()) : <?php echo $o->product->feature_summary(); ?>
echo $o->product->feature_summary(); </div> <!-- /span -->
endif ?>
</div> <!-- /row --> <div class="span5">
<?php echo $o->service_view(); ?>
</div> <!-- /span -->
<div class="row"> <?php if ($o->service_billing->loaded()) : ?>
<?php echo $o->details('service_view'); ?> <div class="span5">
</div> <!-- /row --> <fieldset>
<legend>Automatic Payment Details</legend>
<div class="row"> <div class="dl-horizontal">
<?php if ($o->service_billing->loaded()) : ?> <dt>Direct Payment</dt>
<fieldset class="span5"> <dd><?php echo $o->service_billing->checkout->display('name'); ?></dd>
<legend>Automatic Payment Details</legend> </div> <!-- /dl-horizontal -->
</fieldset>
</div> <!-- /span -->
<?php endif ?>
<dt><?php echo $o->service_billing->checkout->display('name'); ?></dt> <?php if ($o->charges()) : ?>
<dd>&nbsp;</dd> <div class="span5">
<fieldset>
<legend>Service Charges to Bill: <?php echo $o->charges(TRUE,TRUE); ?></legend>
</fieldset> <?php echo Table::factory()
<?php endif ?> ->data($o->charge_list(TRUE))
->columns(array(
'date_orig'=>'Date',
'description'=>'Description',
'total(TRUE)'=>'Amount',
)); ?>
</fieldset>
</div> <!-- /span -->
<?php endif ?>
<?php if ($o->charges()) : ?> <?php if ($o->status) : ?>
<fieldset class="span5"> <div class="span5">
<legend>Service Charges to Bill: <?php echo $o->charges(TRUE,TRUE); ?></legend> <fieldset>
<legend>Next Invoice Charges</legend>
<?php echo Table::factory() <?php echo Invoice::instance()->add_service($o)->render('html','body',array('noid'=>TRUE)); ?>
->data($o->charge_list(TRUE)) </fieldset>
->columns(array( </div> <!-- /span -->
'date_orig'=>'Date', <?php endif ?>
'description'=>'Description',
'total(TRUE)'=>'Amount',
)); ?>
</fieldset> <div class="span5">
<?php endif ?> <fieldset>
<fieldset class="span5">
<legend>Invoices for this Service</legend> <legend>Invoices for this Service</legend>
<?php echo Table::factory() <?php echo Table::factory()
->data($o->invoice_list()) ->data($o->invoice_list())
->columns(array( ->columns(array(
'id'=>'ID', 'id'=>'ID',
'date_orig'=>'Date', 'date_orig'=>'Date',
'due_date'=>'Due', 'due_date'=>'Due',
'total(TRUE)'=>'Amount', 'total(TRUE)'=>'Amount',
'due(TRUE)'=>'Due', 'due(TRUE)'=>'Due',
)) ))
->prepend(array( ->prepend(array(
'id'=>array('url'=>URL::link('user','invoice/view/')), 'id'=>array('url'=>URL::link('user','invoice/view/')),
)); ?> )); ?>
</fieldset> </fieldset>
</div> <!-- /span -->
<?php if ($o->status) : ?>
<fieldset class="span5">
<legend>Next Invoice Charges</legend>
<?php echo Invoice::instance()->add_service($o)->render('html','body',array('noid'=>TRUE)); ?>
</fieldset>
<?php endif ?>
</div> <!-- /row -->
<?php $x=$o->service_memo->find_all(); if ($x->count()) : ?> <?php $x=$o->service_memo->find_all(); if ($x->count()) : ?>
<div class="row"> <div class="span5">
<fieldset class="span5"> <fieldset>
<legend>Service Memos</legend> <legend>Service Memos</legend>
<?php echo Table::factory()
->data($x) <?php echo Table::factory()
->columns(array( ->data($x)
'id'=>'ID', ->columns(array(
'date_orig'=>'Date', 'id'=>'ID',
'account->name()'=>'Account', 'date_orig'=>'Date',
'memo'=>'Memo', 'account->name()'=>'Account',
)); ?> 'memo'=>'Memo',
</fieldset> )); ?>
</div> <!-- /row --> </fieldset>
</div> <!-- /span -->
<?php endif ?> <?php endif ?>
<?php $x=$o->email()->find_all(); if ($x->count()) : ?> <?php $x=$o->email()->find_all(); if ($x->count()) : ?>
<div class="row"> <div class="span5">
<fieldset class="span5"> <fieldset>
<legend>Emails about this service</legend> <legend>Emails about this service</legend>
<?php echo Table::factory()
->data($x) <?php echo Table::factory()
->columns(array( ->data($x)
'id'=>'ID', ->columns(array(
'date_orig'=>'Date', 'id'=>'ID',
'resolve("subject")'=>'Subject', 'date_orig'=>'Date',
)) 'resolve("subject")'=>'Subject',
->prepend(array( ))
'id'=>array('url'=>URL::link('user','email/view/')), ->prepend(array(
)) 'id'=>array('url'=>URL::link('user','email/view/')),
->postproc(array( ))
'resolve("subject")'=>array('trim'=>45), ->postproc(array(
)); ?> 'resolve("subject")'=>array('trim'=>45),
</fieldset> )); ?>
</div> <!-- /row --> </fieldset>
</div> <!-- /span -->
<?php endif ?> <?php endif ?>

View File

@ -13,20 +13,16 @@ class Model_Product_Plugin_Ssl extends Model_Product_Plugin {
protected $_table_name = 'ssl'; protected $_table_name = 'ssl';
// Our required abstract methods // Our required abstract methods
public function render_edit() {}
public function cost($annual=FALSE) { public function cost($annual=FALSE) {
// @todo
$x = 0; $x = 0;
return $annual ? $x*12 : $x; return $annual ? $x*12 : $x;
} }
public function feature_summary() { public function render_edit() {}
// @todo This view should render based on the the results of this::allowance();
return View::factory('product/plugin/ssl/feature_summary')
->set('po',$this);
}
// @todo
public function supplier() { public function supplier() {
return 'internal'; return 'internal';
} }

View File

@ -30,7 +30,10 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
), ),
); );
protected $_save_message = TRUE;
// Required abstract functions // Required abstract functions
public function expire($format=FALSE) { public function expire($format=FALSE) {
return $this->_so->get_valid_to($format); return $this->_so->get_valid_to($format);
} }
@ -39,8 +42,11 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
return ($this->cert AND $this->ca->loaded()) ? sprintf('%s:%s',$this->ca->subject(),$this->display('cert')) : $this->display('csr'); return ($this->cert AND $this->ca->loaded()) ? sprintf('%s:%s',$this->ca->subject(),$this->display('cert')) : $this->display('csr');
} }
public function password_value() {} // Not used public function password() {} // Not used
public function username_value() {} // Not used
public function username() {} // Not used
// Local functions
private $_so = NULL; private $_so = NULL;

View File

@ -1,10 +1,8 @@
<fieldset class="span6"> <fieldset>
<legend>SSL Features</legend> <legend>SSL Features</legend>
<div class="dl-horizontal"> <div class="dl-horizontal">
<dt>Type</dt> <dt>Type</dt>
<dd><?php echo $po->display('extensions'); ?></dd> <dd><?php echo $o->display('extensions'); ?></dd>
</div> <!-- /dl-horizontal --> </div> <!-- /dl-horizontal -->
</fieldset> </fieldset>

View File

@ -1,17 +1,15 @@
<div class="row"> <fieldset>
<div class="span6"> <legend>SSL Certificate Service Details</legend>
<div class="row">
<?php echo Form::textarea('plugin[csr]',$o->service->plugin()->csr,array('class'=>'span6','label'=>'CSR','placeholder'=>'CSR','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->csr))); ?> <?php echo Form::textarea('plugin[csr]',$o->service->plugin()->csr,array('class'=>'span6','label'=>'CSR','placeholder'=>'CSR','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->csr))); ?>
</div> </div>
</div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span6">
<?php echo Form::textarea('plugin[pk]',$o->service->plugin()->pk,array('class'=>'span6','label'=>'Private Key','placeholder'=>'Private Key','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->pk))); ?> <?php echo Form::textarea('plugin[pk]',$o->service->plugin()->pk,array('class'=>'span6','label'=>'Private Key','placeholder'=>'Private Key','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->pk))); ?>
</div> </div>
</div> <!-- /row -->
<div class="row"> <div class="row">
<div class="span6">
<?php echo Form::textarea('plugin[cert]',$o->service->plugin()->cert,array('class'=>'span6','label'=>'Public Certificate','placeholder'=>'Public Certificate','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->cert))); ?> <?php echo Form::textarea('plugin[cert]',$o->service->plugin()->cert,array('class'=>'span6','label'=>'Public Certificate','placeholder'=>'Public Certificate','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->cert))); ?>
</div> </div>
</div> <!-- /row --> </fieldset>

View File

@ -1,57 +1,60 @@
<fieldset class="span5"> <div class="span5">
<legend>Service Details</legend> <fieldset>
<legend>Service Details</legend>
<div class="dl-horizontal"> <div class="dl-horizontal">
<dt>DN</dt>
<dd><?php echo $o->dn(); ?></dd>
<dt>DN</dt> <dt>Serial Number</dt>
<dd><?php echo $o->dn(); ?></dd> <dd><?php echo $o->serial(); ?></dd>
<dt>Serial Number</dt> <dt>Subject Key Id</dt>
<dd><?php echo $o->serial(); ?></dd> <dd><?php echo $o->ski(); ?></dd>
<dt>Subject Key Id</dt> <dt>Issuer</dt>
<dd><?php echo $o->ski(); ?></dd> <dd>
<?php if ($o->validCA() AND $o->authorised($o->ca)) : ?>
<?php echo HTML::anchor(URL::link('reseller','ssl/edit/').$o->ca->id,$o->issuer()); ?>
<?php else : ?>
<?php echo $o->issuer(); ?>
<?php endif ?>
</dd>
<dt>Issuer</dt> <dt>Issuer Serial</dt>
<dd> <dd><?php printf('%s (%s)',$o->aki_keyid(), $o->aki_serial()); ?></dd>
<?php if ($o->validCA() AND $o->authorised($o->ca)) : ?>
<?php echo HTML::anchor(URL::link('reseller','ssl/edit/').$o->ca->id,$o->issuer()); ?>
<?php else : ?>
<?php echo $o->issuer(); ?>
<?php endif ?>
</dd>
<dt>Issuer Serial</dt> <dt>Valid From</dt>
<dd><?php printf('%s (%s)',$o->aki_keyid(), $o->aki_serial()); ?></dd> <dd><?php echo $o->valid_from(TRUE); ?></dd>
<dt>Valid From</dt> <dt>Valid To</dt>
<dd><?php echo $o->valid_from(TRUE); ?></dd> <dd><?php echo $o->valid_to(TRUE); ?></dd>
<dt>Valid To</dt> <dt>Hash</dt>
<dd><?php echo $o->valid_to(TRUE); ?></dd> <dd><?php echo $o->hash(); ?></dd>
<dt>Hash</dt> <dt>Version</dt>
<dd><?php echo $o->hash(); ?></dd> <dd><?php echo $o->version(); ?></dd>
<dt>Version</dt> <dt>Algorithm</dt>
<dd><?php echo $o->version(); ?></dd> <dd><?php echo $o->algorithm(); ?></dd>
<dt>Algorithm</dt> </div> <!-- dl-horizontal -->
<dd><?php echo $o->algorithm(); ?></dd> </fieldset>
</div> <!-- /span -->
</div> <!-- dl-horizontal --> <div class="span6">
</fieldset> <fieldset>
<legend>Certificate</legend>
<pre><?php echo $o->cert; ?></pre>
<fieldset class="span6"> <?php
<legend>Certificate</legend> echo $o->download_button();
<pre><?php echo $o->cert; ?></pre> if ($ao=Auth::instance()->get_user() AND ($ao->isAdmin() OR $ao->isReseller()) AND $o->service->status AND ($o->valid_to()-(Kohana::$config->load('ssl.min_renew_days')*86400) <= time()) AND $o->service->paid_to() > time()) :
echo Form::open(URL::link('reseller','ssl/renew/'.$o->service->id));
echo Form::button('submit','Renew',array('class'=>'btn btn-primary'));
endif
?>
<?php </fieldset>
echo $o->download_button(); </div> <!-- /span -->
if ($ao=Auth::instance()->get_user() AND ($ao->isAdmin() OR $ao->isReseller()) AND $o->service->status AND ($o->valid_to()-(Kohana::$config->load('ssl.min_renew_days')*86400) <= time()) AND $o->service->paid_to() > time()) :
echo Form::open(URL::link('reseller','ssl/renew/'.$o->service->id));
echo Form::button('submit','Renew',array('class'=>'btn btn-primary'));
endif
?>
</fieldset>

View File

@ -1,8 +1,8 @@
<div class="row"> <div class="span11">
<div class="span9"> <fieldset>
<legend>SSL CA Certificate Edit/Update</legend>
<div class="dl-horizontal"> <div class="dl-horizontal">
<dt>Subject</dt> <dt>Subject</dt>
<dd><?php echo $o->subject(); ?></dd> <dd><?php echo $o->subject(); ?></dd>
@ -46,13 +46,11 @@
<dt>Key Algorithm<dt> <dt>Key Algorithm<dt>
<dd><?php echo $o->algorithm(); ?></dd> <dd><?php echo $o->algorithm(); ?></dd>
</div> <!-- /dl-horizontal --> </div> <!-- /dl-horizontal -->
<br/> </fieldset>
<?php echo Form::textarea('sign_pk',$o->sign_pk,array('class'=>'span6','label'=>'Private Key','placeholder'=>'Private Key','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->sign_pk))); ?> <?php echo Form::textarea('sign_pk',$o->sign_pk,array('class'=>'span6','label'=>'Private Key','placeholder'=>'Private Key','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->sign_pk))); ?>
<?php echo Form::textarea('sign_cert',$o->sign_cert,array('class'=>'span6','label'=>'Public Certificate','placeholder'=>'Public Certificate','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->sign_cert))); ?> <?php echo Form::textarea('sign_cert',$o->sign_cert,array('class'=>'span6','label'=>'Public Certificate','placeholder'=>'Public Certificate','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->sign_cert))); ?>
<?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?> <?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?>
</div> <!-- /span --> </div> <!-- /span -->
</div> <!-- /row -->

View File

@ -14,7 +14,7 @@ class Controller_StaticPage_Category extends Controller_TemplateDefault {
* By default show a menu of available categories * By default show a menu of available categories
*/ */
public function action_index() { public function action_index() {
HTTP::redirect('staticpage_category/list'); HTTP::redirect('staticpage_category/list');
} }
public function action_list() { public function action_list() {

View File

@ -24,7 +24,7 @@ class Controller_Admin_Task extends Controller_Task {
->title(_('Task Log')) ->title(_('Task Log'))
->title_icon('icon-th-list') ->title_icon('icon-th-list')
->body(Table::factory() ->body(Table::factory()
->page_items(50) ->page_items(50)
->data(ORM::factory('Task_Log')->find_all()) ->data(ORM::factory('Task_Log')->find_all())
->columns(array( ->columns(array(
'id'=>'ID', 'id'=>'ID',
@ -32,8 +32,7 @@ class Controller_Admin_Task extends Controller_Task {
'task->display("name")'=>'Task', 'task->display("name")'=>'Task',
'result'=>'Result', 'result'=>'Result',
'message'=>'Message', 'message'=>'Message',
)) )));
);
} }
} }
?> ?>

View File

@ -17,41 +17,47 @@ class Task_Task_Clean extends Minion_Task {
foreach ($tl->find_all() as $to) { foreach ($tl->find_all() as $to) {
// Delete Task already running messages. // Delete Task already running messages.
if (preg_match('/^Task\ [0-9]+\ is already running$/',$to->message) AND $to->date_orig < time()+$delay) { if (preg_match('/^Task\ [0-9]+\ is already running$/',$to->message) AND $to->date_orig < time()-$delay) {
$to->delete(); $to->delete();
continue; continue;
} }
// Delete Empty Invoices Sent // Delete Empty Invoices Sent
if (preg_match('/^Invoices Sent:\s+$/',$to->message) AND $to->date_orig < time()+$delay) { if (preg_match('/^Invoices Sent:\s+$/',$to->message) AND $to->date_orig < time()-$delay) {
$to->delete(); $to->delete();
continue; continue;
} }
// Delete Overdue Notes Sent // Delete Overdue Notes Sent
if (preg_match('/^OverDue Notice #[0-9] Reminders Sent:\s+$/',$to->message) AND $to->date_orig < time()+$delay) { if (preg_match('/^OverDue Notice #[0-9] Reminders Sent:\s+$/',$to->message) AND $to->date_orig < time()-$delay) {
$to->delete(); $to->delete();
continue; continue;
} }
// Over Notes Sent // Over Notes Sent
if (preg_match('/^(Overdue|Due) Reminders Sent:\s+$/',$to->message) AND $to->date_orig < time()+$delay) { if (preg_match('/^(Overdue|Due) Reminders Sent:\s+$/',$to->message) AND $to->date_orig < time()-$delay) {
$to->delete(); $to->delete();
continue; continue;
} }
// Services Invoiced // Services Invoiced
if (preg_match('/^Services Invoiced:\s+$/',$to->message) AND $to->date_orig < time()+$delay) { if (preg_match('/^Services Invoiced:\s+$/',$to->message) AND $to->date_orig < time()-$delay) {
$to->delete(); $to->delete();
continue; continue;
} }
if (in_array($to->task_id,array(2,4,13)) AND $to->date_orig < time()+$delay) { // Alerts Sent
if (preg_match('/^0 alerts sent \(\)$/',$to->message) AND $to->date_orig < time()-$delay) {
$to->delete(); $to->delete();
continue; continue;
} }
if (in_array($to->task_id,array(3)) AND $to->date_orig < time()+86400*60) { if (in_array($to->task_id,array(4,13)) AND $to->date_orig < time()-$delay) {
$to->delete();
continue;
}
if (in_array($to->task_id,array(3)) AND $to->date_orig < time()-86400*60) {
$to->delete(); $to->delete();
continue; continue;
} }
@ -63,7 +69,7 @@ class Task_Task_Clean extends Minion_Task {
OR preg_match('/View_Exception\s+/',$to->message) OR preg_match('/View_Exception\s+/',$to->message)
OR preg_match('/Kohana_Exception\s+/',$to->message)) OR preg_match('/Kohana_Exception\s+/',$to->message))
AND $to->date_orig < time()+$delay) { AND $to->date_orig < time()-$delay) {
$to->delete(); $to->delete();
continue; continue;