First start at retiring Affiliate in favour of RTM

This commit is contained in:
Deon George
2013-04-05 09:42:29 +11:00
parent 9d4b2f50ff
commit 43dfd88bce
49 changed files with 680 additions and 570 deletions

View File

@@ -32,7 +32,7 @@ class ADSL {
if (preg_match('/^a:/',$data))
throw new Kohana_Exception('Data shouldnt be a serialized array');
$ao = ORM::factory('Adsl_Plan',$data);
$ao = ORM::factory('ADSL_Plan',$data);
$output = View::factory('adsl/contract_view')
->set('record',$ao)
->set('price_base',$price_base)

View File

@@ -9,7 +9,7 @@
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Adsl_Plan extends ORM_OSB {
class Model_ADSL_Plan extends ORM_OSB {
// Relationships
// @todo This model should probably be joined with product_plugin_adsl
protected $_belongs_to = array(

View File

@@ -19,7 +19,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
);
protected $_has_one = array(
'adsl_plan'=>array('far_key'=>'provided_adsl_plan_id','foreign_key'=>'id'),
'adsl_plan'=>array('model'=>'ADSL_Plan','far_key'=>'provided_adsl_plan_id','foreign_key'=>'id'),
);
protected $_display_filters = array(

View File

@@ -26,7 +26,7 @@ class Controller_Admin_Charge extends Controller_TemplateDefault_Admin {
ORM::factory('Charge')->where('sweep_type','>=',0)->order_by('date_orig DESC')->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>URL::site('user','charge/view/')),
'id'=>array('label'=>'ID','url'=>URL::link('user','charge/view/')),
'date_orig'=>array('label'=>'Date'),
'sweep_type'=>array('label'=>'Sweep'),
'status'=>array('label'=>'Status'),
@@ -41,7 +41,7 @@ class Controller_Admin_Charge extends Controller_TemplateDefault_Admin {
array(
'page'=>TRUE,
'type'=>'select',
'form'=>URL::site('user','charge/view'),
'form'=>URL::link('user','charge/view'),
)),
));
}
@@ -90,7 +90,7 @@ class Controller_Admin_Charge extends Controller_TemplateDefault_Admin {
Script::add(array('type'=>'stdin','data'=>'
$(document).ready(function() {
$("input[name=account_id]").autocomplete({
source: "'.URL::site('a/account/ajaxlist').'",
source: "'.URL::link('admin','account/ajaxlist').'",
minLength: 2,
change: function(event,ui) {
// Send the request and update sub category dropdown

View File

@@ -10,6 +10,11 @@
* @license http://dev.osbill.net/license.html
*/
class Model_Checkout extends ORM_OSB {
protected $_has_many = array(
'account'=>array('through'=>'account_billing','foreign_key'=>'checkout_plugin_id'),
'payment'=>array(),
);
/**
* Calcuale the fee for this checkout method
*

View File

@@ -42,7 +42,7 @@ class Controller_User_Email extends Controller_TemplateDefault_User {
$elo = ORM::factory('Email_Log',$id);
if (! $elo->loaded() OR ! Auth::instance()->authorised($elo->account_id)) {
if (! $elo->loaded() OR ! Auth::instance()->authorised($elo->account)) {
$this->template->content = 'Unauthorised or doesnt exist?';
return FALSE;
}

View File

@@ -10,5 +10,129 @@
* @license http://dev.osbill.net/license.html
*/
class Controller_Invoice extends Controller_TemplateDefault {
protected $secure_actions = array(
'download'=>TRUE,
'list'=>TRUE,
'view'=>TRUE,
);
/**
* Show a list of invoices
*/
public function action_list() {
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Invoices For'),$this->ao->accnum(),$this->ao->name(TRUE)),
'body'=>Table::display(
$this->ao->invoice->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','invoice/view/')),
'date_orig'=>array('label'=>'Date Issued'),
'due_date'=>array('label'=>'Date Due'),
'total(TRUE)'=>array('label'=>'Total','class'=>'right'),
'total_credits(TRUE)'=>array('label'=>'Credits','class'=>'right'),
'payments_total(TRUE)'=>array('label'=>'Payments','class'=>'right'),
'due(TRUE)'=>array('label'=>'Still Due','class'=>'right'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>URL::link('user','invoice/view'),
)),
));
}
/**
* View an Invoice
*/
public function action_view() {
list($id,$output) = Table::page(__METHOD__);
$io = ORM::factory('Invoice',$id);
if (! $io->loaded() OR ! Auth::instance()->authorised($io->account)) {
$this->template->content = 'Unauthorised or doesnt exist?';
return FALSE;
}
$output .= View::factory($this->viewpath())
->set('mediapath',Route::get('default/media'))
->set('io',$io);
if ($io->due() AND ! $io->cart_exists()) {
$output .= View::factory($this->viewpath().'/pay')
->set('mid',$io->mid())
->set('o',$io);
}
if (! $io->status) {
// Add a gribber popup
// @todo Make a gribber popup a class on its own.
Style::add(array(
'type'=>'file',
'data'=>'css/jquery.gritter.css',
'media'=>'screen',
));
Script::add(array(
'type'=>'file',
'data'=>'js/jquery.gritter-1.5.js',
));
Script::add(array(
'type'=>'stdin',
'data'=>sprintf(
'$(document).ready(function() {
$.extend($.gritter.options, {
fade_in_speed: "medium",
fade_out_speed: 2000,
time: "3000",
sticky: false,
});
$.gritter.add({
title: "%s",
text: "%s",
image: "%s",
});});',
'Cancelled','Invoice CANCELLED',URL::site().SystemMessage::image('info',true)
)
));
Style::add(array(
'type'=>'stdin',
'data'=>'
#watermark {
color: #800000;
font-size: 4em;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
position: absolute;
width: 100%;
height: 100%;
margin: 0;
z-index: 1;
left:250px;
top:-20px;
}
'));
$output .= '<div id="watermark"><p>Invoice CANCELLED.</p></div>';
}
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Invoice'),$io->refnum(),$io->account->name()),
'body'=>$output,
));
}
/**
* Download an invoice
*/
public function action_download() {
$io = ORM::factory('Invoice',$this->request->param('id'));
$this->response->body(Invoice::instance($io)->pdf()->Output(sprintf('%s.pdf',$io->refnum()),'D'));
$this->response->headers(array('Content-Type' => 'application/pdf'));
$this->auto_render = FALSE;
}
}
?>

View File

@@ -0,0 +1,33 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Reseller Invoice viewing functions
*
* @package Invoice
* @category Controllers/Reseller
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Reseller_Invoice extends Controller_Invoice {
public function action_list() {
list($id,$output) = Table::page(__METHOD__);
$ao = ORM::factory('Account',$id);
if (! $ao->loaded() OR ! Auth::instance()->authorised($ao)) {
$this->template->content = 'Unauthorised or doesnt exist?';
return FALSE;
}
Block::add(array(
'body'=>$output,
));
$this->ao = $ao;
// @todo Our pagination is broken if we select multiple accounts, and those accounts have multiple invoices.
return parent::action_list();
}
}
?>

View File

@@ -9,130 +9,6 @@
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_User_Invoice extends Controller_TemplateDefault_User {
protected $secure_actions = array(
'download'=>TRUE,
'list'=>TRUE,
'view'=>TRUE,
);
/**
* Show a list of invoices
*/
public function action_list() {
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Invoices For'),$this->ao->accnum(),$this->ao->name(TRUE)),
'body'=>Table::display(
$this->ao->invoice->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','invoice/view/')),
'date_orig'=>array('label'=>'Date Issued'),
'due_date'=>array('label'=>'Date Due'),
'total(TRUE)'=>array('label'=>'Total','class'=>'right'),
'total_credits(TRUE)'=>array('label'=>'Credits','class'=>'right'),
'payments_total(TRUE)'=>array('label'=>'Payments','class'=>'right'),
'due(TRUE)'=>array('label'=>'Still Due','class'=>'right'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>URL::link('user','invoice/view'),
)),
));
}
/**
* View an Invoice
*/
public function action_view() {
list($id,$output) = Table::page(__METHOD__);
$io = ORM::factory('Invoice',$id);
if (! $io->loaded() AND ! in_array($this->ao->affiliate->id,$io->service_affiliates())) {
$this->template->content = 'Unauthorised or doesnt exist?';
return FALSE;
}
$output .= View::factory($this->viewpath())
->set('mediapath',Route::get('default/media'))
->set('io',$io);
if ($io->due() AND ! $io->cart_exists()) {
$output .= View::factory($this->viewpath().'/pay')
->set('mid',$io->mid())
->set('o',$io);
}
if (! $io->status) {
// Add a gribber popup
// @todo Make a gribber popup a class on its own.
Style::add(array(
'type'=>'file',
'data'=>'css/jquery.gritter.css',
'media'=>'screen',
));
Script::add(array(
'type'=>'file',
'data'=>'js/jquery.gritter-1.5.js',
));
Script::add(array(
'type'=>'stdin',
'data'=>sprintf(
'$(document).ready(function() {
$.extend($.gritter.options, {
fade_in_speed: "medium",
fade_out_speed: 2000,
time: "3000",
sticky: false,
});
$.gritter.add({
title: "%s",
text: "%s",
image: "%s",
});});',
'Cancelled','Invoice CANCELLED',URL::site().SystemMessage::image('info',true)
)
));
Style::add(array(
'type'=>'stdin',
'data'=>'
#watermark {
color: #800000;
font-size: 4em;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
position: absolute;
width: 100%;
height: 100%;
margin: 0;
z-index: 1;
left:250px;
top:-20px;
}
'));
$output .= '<div id="watermark"><p>Invoice CANCELLED.</p></div>';
}
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Invoice'),$io->refnum(),$io->account->name()),
'body'=>$output,
));
}
/**
* Download an invoice
*/
public function action_download() {
$io = ORM::factory('Invoice',$this->request->param('id'));
$this->response->body(Invoice::instance($io)->pdf()->Output(sprintf('%s.pdf',$io->refnum()),'D'));
$this->response->headers(array('Content-Type' => 'application/pdf'));
$this->auto_render = FALSE;
}
class Controller_User_Invoice extends Controller_Invoice {
}
?>

View File

@@ -436,18 +436,6 @@ class Model_Invoice extends ORM_OSB implements Cartable {
return $this->saved();
}
/**
* Return a list of affiliates associated with this invoice (via the service)
*/
public function service_affiliates() {
$return = array();
foreach ($this->items() as $io)
array_push($return,$io->service->affiliate_id);
return $return;
}
/**
* Return the subtotal of all items
*/

View File

@@ -30,6 +30,10 @@ abstract class lnApp_BreadCrumb extends HTMLRender {
throw new Kohana_Exception('Path is not a string, nor an array');
}
public static function dump() {
echo Debug::vars(static::$_data);
}
/**
* Enable a friendly name to be used for a path
*/
@@ -80,7 +84,7 @@ abstract class lnApp_BreadCrumb extends HTMLRender {
$output .= $i==$c ? '<li id="active">' : '<li>';
$output .= HTML::anchor(
(empty(static::$_data['url'][$p]) ? $p : static::$_data['url'][$p]),
(empty(static::$_data['name'][$p]) ? ucfirst($v) : static::$_data['name'][$p])
(empty(static::$_data['name'][$p]) ? ucfirst(URL::dir($v)) : static::$_data['name'][$p])
);
$output .= '</li>';
}

View File

@@ -15,7 +15,7 @@ class lnApp_Controller_Login extends Controller_TemplateDefault {
public function action_index() {
// If user already signed-in
if (Auth::instance()->logged_in()!= 0) {
if (Auth::instance()->logged_in() != 0) {
// Redirect to the user account
HTTP::redirect(URL::link('user','welcome/index'));
}

View File

@@ -37,16 +37,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
*
* @var array actions that require a valid user
*/
protected $secure_actions = array(
);
public function __construct(Request $request,Response $response) {
// Our Menu's can run without method authentication by default.
if (! isset($this->secure_actions['menu']))
$this->secure_actions['menu'] = FALSE;
return parent::__construct($request,$response);
}
protected $secure_actions = array();
/**
* Check and see if this controller needs authentication

View File

@@ -10,6 +10,8 @@
* @license http://dev.osbill.net/license.html
*/
class Controller_Product extends Controller_TemplateDefault {
protected $auth_required = FALSE;
/**
* Show a list of product categories
*/

View File

@@ -732,7 +732,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
$so = ORM::factory('Service',$id);
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account_id,$so->affiliate_id)) {
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account)) {
$this->template->content = 'Unauthorised or doesnt exist?';
return FALSE;
}

View File

@@ -26,7 +26,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
Block::add(array(
'title'=>_('Customer Services'),
'body'=>Table::display(
$this->filter(ORM::factory('Service')->list_active(),$this->ao->affiliate->id),
$this->filter(ORM::factory('Service')->list_active(),$this->ao->RTM->customers($this->ao->RTM),NULL,'account_id'),
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
@@ -55,7 +55,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
foreach (ORM::factory('Account')->list_active() as $ao)
if ($ao->has_any('group',array($go)))
foreach ($this->filter($ao->service->list_active(),$this->ao->affiliate->id,'name()') as $so)
foreach ($this->filter($ao->service->list_active(),$this->ao->RTM->customers($this->ao->RTM),NULL,'account_id') as $so)
if (! $so->service_billing->checkout_plugin_id)
array_push($svs,$so);
@@ -92,7 +92,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
$svs = array();
foreach ($co->account->find_all() as $ao)
foreach ($this->filter($ao->service->list_active(),$this->ao->affiliate->id,'name()') as $so)
foreach ($this->filter($ao->service->list_active(),$this->ao->RTM->customers($this->ao->RTM),NULL,'account_id') as $so)
if ($so->service_billing->checkout_plugin_id == $co->id)
array_push($svs,$so);
@@ -155,7 +155,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
}
public function action_listadslservices() {
$svs = $this->filter(ORM::factory('Service')->list_bylistgroup('ADSL'),$this->ao->affiliate->id,'name()');
$svs = $this->filter(ORM::factory('Service')->list_bylistgroup('ADSL'),$this->ao->RTM->customers($this->ao->RTM),'name()','account_id');
$data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('Legacy')
@@ -196,7 +196,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
}
public function action_listhspaservices() {
$svs = $this->filter(ORM::factory('Service')->list_bylistgroup('HSPA'),$this->ao->affiliate->id,'name()');
$svs = $this->filter(ORM::factory('Service')->list_bylistgroup('HSPA'),$this->ao->RTM->customers($this->ao->RTM),'name()','account_id');
$data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('Legacy')
@@ -240,7 +240,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
Block::add(array(
'title'=>_('Domain Names'),
'body'=>Table::display(
$this->filter(ORM::factory('Service')->list_bylistgroup('DOMAIN'),$this->ao->affiliate->id,'name()'),
$this->filter(ORM::factory('Service')->list_bylistgroup('DOMAIN'),$this->ao->RTM->customers($this->ao->RTM),'name()','account_id'),
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
@@ -264,7 +264,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
Block::add(array(
'title'=>_('Hosting Services'),
'body'=>Table::display(
$this->filter(ORM::factory('Service')->list_bylistgroup('HOST'),$this->ao->affiliate->id,'name()'),
$this->filter(ORM::factory('Service')->list_bylistgroup('HOST'),$this->ao->RTM->customers($this->ao->RTM),'name()','account_id'),
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),

View File

@@ -61,7 +61,7 @@ class Controller_User_Service extends Controller_TemplateDefault_User {
$so = ORM::factory('Service',$id);
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account_id,$so->affiliate_id)) {
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account)) {
$this->template->content = 'Unauthorised or doesnt exist?';
return FALSE;
}

View File

@@ -15,7 +15,6 @@
class Model_Service extends ORM_OSB {
// Relationships
protected $_has_one = array(
'affiliate'=>array('far_key'=>'affiliate_id','foreign_key'=>'id'),
'service_billing'=>array('far_key'=>'account_billing_id','foreign_key'=>'id'),
);
protected $_has_many = array(

View File

@@ -32,7 +32,7 @@ class Controller_User_SSL extends Controller_TemplateDefault_User {
HTTP::redirect(URL::link('user','service/view/'.$so->id));
}
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account_id,$so->affiliate_id)) {
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account)) {
$this->template->content = 'Unauthorised or doesnt exist?';
return FALSE;
}