Removed redundant functions, some Standardisation work

This commit is contained in:
Deon George 2016-08-15 21:23:18 +10:00
parent 24bb4a701b
commit 07de13f678
82 changed files with 367 additions and 590 deletions

View File

@ -69,7 +69,7 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module {
foreach (ORM::factory('Group')->find_all() as $go) { foreach (ORM::factory('Group')->find_all() as $go) {
// If the group was defined and no longer // If the group was defined and no longer
if ($mmo->has('group',$go) AND (! $this->request->post('groups')) OR ! in_array($go->id,$this->request->post('groups'))) { if ($mmo->has('group',$go) AND (! $this->request->post('groups') OR ! in_array($go->id,$this->request->post('groups')))) {
$gmo = ORM::factory('Group_Method',array('method_id'=>$mmo->id,'group_id'=>$go->id)); $gmo = ORM::factory('Group_Method',array('method_id'=>$mmo->id,'group_id'=>$go->id));
if (! $gmo->delete()) if (! $gmo->delete())

View File

@ -12,17 +12,6 @@
abstract class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault { abstract class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault {
protected $auth_required = TRUE; protected $auth_required = TRUE;
// @todo To rework
public function after() {
$dc = URL::link('user','welcome/index');
$m = sprintf('%s/%s',Request::current()->directory(),Request::current()->controller());
BreadCrumb::URL(Request::current()->directory(),sprintf('%s/%s',Request::current()->directory(),$dc),FALSE);
BreadCrumb::URL($m,method_exists($this,'action_menu') ? $m.'/menu' : sprintf('%s/%s',Request::current()->directory(),$dc),FALSE);
parent::after();
}
protected function save(Model $o) { protected function save(Model $o) {
try { try {
return $o->save(); return $o->save();
@ -48,7 +37,7 @@ abstract class Controller_TemplateDefault extends lnApp_Controller_TemplateDefau
if ($config_items) { if ($config_items) {
Block::factory() Block::factory()
->title('Update Module Configuration') ->title('Update Module Configuration')
->title_icon('icon-wrench') ->title_icon('fa fa-wrench')
->type('form-horizontal') ->type('form-horizontal')
->body(View::factory('setup/admin/module')->set('o',Company::instance()->so())->set('mid',$mo->id)); ->body(View::factory('setup/admin/module')->set('o',Company::instance()->so())->set('mid',$mo->id));
} }

View File

@ -44,21 +44,7 @@ class Model_Account extends lnApp_Model_Account {
/** REQUIRED ABSTRACT METHODS **/ /** REQUIRED ABSTRACT METHODS **/
/** /** LOCAL METHODS **/
* Returns the company name if it exists, otherwise the persons name
*/
public function name($variable=NULL) {
return $this->isCompany() ? $this->company : $this->namesub();
}
/*
* Returns the persons name
*/
public function namesub($variable=NULL) {
return trim(sprintf('%s %s',$this->first_name,$this->last_name));
}
/** OTHER METHODS **/
public function activated() { public function activated() {
return $this->has('group'); return $this->has('group');
@ -115,6 +101,20 @@ class Model_Account extends lnApp_Model_Account {
return $this->RTM->loaded(); return $this->RTM->loaded();
} }
/**
* Returns the company name if it exists, otherwise the persons name
*/
public function name($variable=NULL) {
return $this->isCompany() ? $this->company : $this->namesub();
}
/*
* Returns the persons name
*/
public function namesub($variable=NULL) {
return trim(sprintf('%s %s',$this->first_name,$this->last_name));
}
/** /**
* The key we use to sort entries of this model type * The key we use to sort entries of this model type
*/ */

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Account_Log extends ORM_OSB { class Model_Account_Log extends ORM {
protected $_belongs_to = array( protected $_belongs_to = array(
'account'=>array(), 'account'=>array(),
); );

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Country extends ORM_OSB { class Model_Country extends ORM {
protected $_has_one = array( protected $_has_one = array(
'currency'=>array('far_key'=>'id'), 'currency'=>array('far_key'=>'id'),
); );

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Currency extends ORM_OSB { class Model_Currency extends ORM {
protected $_sorting = array( protected $_sorting = array(
'name'=>'ASC', 'name'=>'ASC',
); );

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Group_Method extends ORM_OSB { class Model_Group_Method extends ORM {
// Relationships // Relationships
protected $_has_one = array( protected $_has_one = array(
'record_id'=>array(), 'record_id'=>array(),

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Language extends ORM_OSB { class Model_Language extends ORM {
protected $_sorting = array( protected $_sorting = array(
'name'=>'ASC', 'name'=>'ASC',
); );

View File

@ -9,6 +9,6 @@
* @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
*/ */
class Model_Log_Error extends ORM_OSB { class Model_Log_Error extends ORM {
} }
?> ?>

View File

@ -12,7 +12,7 @@
* @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
*/ */
class Model_Module extends ORM_OSB { class Model_Module extends ORM {
// Relationships // Relationships
protected $_has_one = array( protected $_has_one = array(
'record_id'=>array('model'=>'Record_ID','far_key'=>'id'), 'record_id'=>array('model'=>'Record_ID','far_key'=>'id'),

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Module_Method extends ORM_OSB { class Model_Module_Method extends ORM {
// This module doesnt keep track of column updates automatically // This module doesnt keep track of column updates automatically
protected $_created_column = FALSE; protected $_created_column = FALSE;
protected $_updated_column = FALSE; protected $_updated_column = FALSE;

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Module_Method_Token extends ORM_OSB { class Model_Module_Method_Token extends ORM {
// This module doesnt keep track of column updates automatically // This module doesnt keep track of column updates automatically
protected $_updated_column = FALSE; protected $_updated_column = FALSE;

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_RTM extends ORM_OSB { class Model_RTM extends ORM {
protected $_belongs_to = array( protected $_belongs_to = array(
'account' => array(), 'account' => array(),
); );

View File

@ -8,7 +8,7 @@
* @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
*/ */
class Model_Record_ID extends ORM_OSB { class Model_Record_ID extends ORM {
protected $_primary_key = 'module_id'; protected $_primary_key = 'module_id';
// This module doesnt keep track of column updates automatically // This module doesnt keep track of column updates automatically

View File

@ -12,7 +12,7 @@
* @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
*/ */
class Model_Setup extends ORM_OSB { class Model_Setup extends ORM {
// Setup doesnt use the update column // Setup doesnt use the update column
protected $_updated_column = FALSE; protected $_updated_column = FALSE;

View File

@ -1,14 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class extends Kohana's [ORM] class to create defaults for OSB.
*
* @package OSB
* @category Helpers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
* @deprecate
*/
abstract class ORM_OSB extends ORM {
}

View File

@ -101,7 +101,7 @@ class Controller_Admin_Adsl extends Controller_Adsl {
->data($apo->products()) ->data($apo->products())
->columns(array( ->columns(array(
'id'=>'ID', 'id'=>'ID',
'title()'=>'Name', 'name(Site::language())'=>'Name',
'status'=>'Active', 'status'=>'Active',
)) ))
->prepend(array( ->prepend(array(

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_ADSL_Supplier extends ORM_OSB { class Model_ADSL_Supplier extends ORM {
protected $_updated_column = FALSE; protected $_updated_column = FALSE;
// Relationships // Relationships

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_ADSL_Supplier_Plan extends ORM_OSB { class Model_ADSL_Supplier_Plan extends ORM {
// Relationships // Relationships
protected $_belongs_to = array( protected $_belongs_to = array(
'supplier'=>array('model'=>'ADSL_Supplier'), 'supplier'=>array('model'=>'ADSL_Supplier'),

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Service_Plugin_Adsl_Traffic extends ORM_OSB { class Model_Service_Plugin_Adsl_Traffic extends ORM {
protected $_table_name = 'service__adsl_traffic'; protected $_table_name = 'service__adsl_traffic';
protected $_primary_key = 'service'; protected $_primary_key = 'service';
protected $_disable_wild_select = TRUE; protected $_disable_wild_select = TRUE;

View File

@ -1,5 +1,5 @@
<div id="page-title"> <div id="page-title">
<h1><?php echo $o->title(); ?></h1> <h1><?php echo $o->name(Site::language()); ?></h1>
<?php echo $o->description(); ?> <?php echo $o->description(); ?>
</div> <!-- /page-title --> </div> <!-- /page-title -->
@ -10,12 +10,12 @@
<th class="plan-title">Plan Name</th> <th class="plan-title">Plan Name</th>
<?php foreach ($o->products() as $po) : ?> <?php foreach ($o->products() as $po) : ?>
<td class="plan-title"><?php echo $po->title(); ?> <small>(<?php echo $po->id; ?>)</small></td> <td class="plan-title"><?php echo $po->name(Site::language()); ?> <small>(<?php echo $po->id; ?>)</small></td>
<?php endforeach ?> <?php endforeach ?>
</tr> </tr>
<tr class="plan-header"> <tr class="plan-header">
<th class="plan-price" >Price</th> <th class="plan-title" >Price</th>
<?php foreach ($o->products() as $po) : ?> <?php foreach ($o->products() as $po) : ?>
<?php $go = $po->price_best($o->recur_schedule,TRUE); ?> <?php $go = $po->price_best($o->recur_schedule,TRUE); ?>

View File

@ -1,5 +1,5 @@
<div id="page-title"> <div id="page-title">
<h1><?php echo $o->title(); ?></h1> <h1><?php echo $o->name(Site::language()); ?></h1>
<?php echo $o->description(); ?> <?php echo $o->description(); ?>
</div> <!-- /page-title --> </div> <!-- /page-title -->
@ -23,9 +23,7 @@
<div class="plan-header"> <div class="plan-header">
<div class="plan-title"> <div class="plan-title"><?php echo $po->name(Site::language()); ?> <small>(<?php echo $po->id; ?>)</small></div>
<?php echo $po->title(); ?> <small>(<?php echo $po->id; ?>)</small>
</div> <!-- /plan-title -->
<div class="plan-price"> <div class="plan-price">
<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> <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>

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Cart extends ORM_OSB { class Model_Cart extends ORM {
// Cart doesnt use the update column // Cart doesnt use the update column
protected $_updated_column = FALSE; protected $_updated_column = FALSE;

View File

@ -10,5 +10,6 @@
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Controller_Charge extends Controller_TemplateDefault { class Controller_Charge extends Controller_TemplateDefault {
protected $icon = 'fa fa-dollar';
} }
?> ?>

View File

@ -21,8 +21,8 @@ class Controller_Reseller_Charge extends Controller_Charge {
public function action_add() { public function action_add() {
Block::factory() Block::factory()
->type('form-horizontal') ->type('form-horizontal')
->title('Add/View Charge') ->title('New Charge')
->title_icon('fa fa-wrench') ->title_icon($this->icon)
->body($this->add_edit()); ->body($this->add_edit());
} }
@ -54,72 +54,11 @@ class Controller_Reseller_Charge extends Controller_Charge {
private function add_edit($id=NULL,$output='') { private function add_edit($id=NULL,$output='') {
$co = ORM::factory('Charge',$id); $co = ORM::factory('Charge',$id);
$this->meta->title = sprintf('Charge: %s (%s)',$co->name(),$co->account->name()); $this->meta->title = $co->loaded() ? sprintf('Charge: %s (%s)',$co->name(),$co->account->name()) : 'New Charge';
if ($this->request->post() AND $co->values($this->request->post())->changed() AND (! $this->save($co))) if ($this->request->post() AND $co->values($this->request->post())->changed() AND (! $this->save($co)))
$co->reload(); $co->reload();
Script::factory()
->type('file')
->data('media/theme/bootstrap/js/bootstrap.datepicker.js');
Style::factory()
->type('file')
->data('media/theme/bootstrap/css/bootstrap.datepicker.css');
Script::factory()
->type('stdin')
->data('
$(document).ready(function() {
$("#date_charge_label").datepicker({
autoclose : true,
endDate : new Date(),
todayHighlight: true,
format : "dd-M-yyyy",
todayBtn : true,
}).on("hide",function(ev) {
$("input[name=date_charge]").val(ev.date.valueOf()/1000);
});
$("input[name=account_id_label]").typeahead({
minLength: 2,
source: function (query,process) {
search("'.URL::link('reseller','charge/ajaxlist').'",query,process);
},
matcher: function () { return true; },
updater: function (item) {
$("input[name=account_id]").val(users[item]);
// Send the request and update sub category dropdown
$.ajax({
type: "GET",
data: "key="+users[item],
dataType: "json",
cache: false,
url: "'.URL::link('reseller','charge/ajaxlistservice',TRUE).'",
timeout: 2000,
error: function(x) {
alert("Failed to submit");
},
success: function(data) {
$("select[name=service_id]").empty();
$.each(data, function(i, j){
var row = "<option value=\"" + j.value + "\">" + j.label + "</option>";
$(row).appendTo("select[name=service_id]");
});
}
});
return item;
},
});
});
');
return View::factory('charge/reseller/add_edit') return View::factory('charge/reseller/add_edit')
->set('o',$co); ->set('o',$co);
} }
@ -130,7 +69,7 @@ $(document).ready(function() {
Block::factory() Block::factory()
->type('form-horizontal') ->type('form-horizontal')
->title(sprintf('%s: %s',_('View Charges'),$id)) ->title(sprintf('%s: %s',_('View Charges'),$id))
->title_icon('fa fa-wrench') ->title_icon($this->icon)
->body($this->add_edit($id,$output)); ->body($this->add_edit($id,$output));
} }

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Charge extends ORM_OSB implements Invoicable { class Model_Charge extends ORM {
protected $_belongs_to = array( protected $_belongs_to = array(
'account'=>array(), 'account'=>array(),
'product'=>array(), 'product'=>array(),
@ -80,9 +80,6 @@ class Model_Charge extends ORM_OSB implements Invoicable {
} }
/** REQUIRED ABSTRACT METHODS **/ /** REQUIRED ABSTRACT METHODS **/
public function namesub($variable=NULL) {
return sprintf('%d@%2.2f - %s (%s)',$this->quantity,$this->amount,($this->description ? ' '.$this->description : '').($this->attributes ? ' ['.join('|',$this->attributes).']' : ''),$this->display('date_charge'));
}
/** LOCAL METHODS **/ /** LOCAL METHODS **/
@ -100,26 +97,9 @@ class Model_Charge extends ORM_OSB implements Invoicable {
return $iio; return $iio;
} }
public function invoice_item($item_type) { public function namesub($variable=NULL) {
switch ($item_type) { return sprintf('%d@%2.2f - %s (%s)',$this->quantity,$this->amount,($this->description ? ' '.$this->description : '').($this->attributes ? ' ['.join('|',$this->attributes).']' : ''),$this->display('date_charge'));
case 5:
return sprintf('%s (%s x %s%s%s) %s',
StaticList_ItemType::get($item_type),
$this->quantity,
$this->display('amount'),
($this->description ? ' '.$this->description : ''),
($this->attributes ? ' ['.join('|',$this->attributes).']' : ''),
$this->display('date_charge'));
default:
return sprintf('%s %s',StaticList_ItemType::get($item_type),$this->display('date_charge')).($this->description ? ' ('.$this->description.')' : '');
}
} }
public function xtitle() {
return $this->invoice_item(5);
}
public function total($format=FALSE) { public function total($format=FALSE) {
$result = $this->quantity * $this->amount; $result = $this->quantity * $this->amount;

View File

@ -1,39 +1,56 @@
<div class="col-md-11"> <div class="col-md-12">
<fieldset> <fieldset>
<legend>Charge Details</legend> <legend>Charge Details</legend>
<label for="date_charge_label">Date Charge</label> <?php
<div class="input-group col-md-3"> echo View::factory('field/date')->set('data',['field'=>'date_charge','value'=>$o->date_charge ? $o->date_charge : time(),'text'=>'Date Charge','enddate'=>'new Date()']);
<input type="text" id="date_charge_label" value="<?php echo $o->display('date_charge'); ?>" class="form-control" placeholder="Date Charge"> echo View::factory('field/account')->set('data',['field'=>'account_id','value'=>$o->account_id,'text'=>'Account','name'=>sprintf('%s: %s',$o->account->refnum(),$o->account->name()),'ajaxurl'=>URL::link('reseller','charge/ajaxlist')]);
<span class="input-group-addon" id="basic-addon1"><i class="fa fa-calendar"></i></span> echo View::factory('field/select')->set('data',['field'=>'service_id','value'=>$o->account_id ? $o->account->service->list_select() : [],'text'=>'Service','default'=>$o->service_id,'class'=>'col-md-6']);
</div> echo View::factory('field/select')->set('data',['field'=>'sweep_type','value'=>Arr::merge([''=>''],StaticList_SweepType::table()),'text'=>'Sweep','default'=>is_null($o->sweep_type) ? 6 : $o->sweep_type,'class'=>'col-md-2']);
<?php echo Form::hidden('date_charge',$o->date_charge); ?> echo View::factory('field/select')->set('data',['field'=>'type','value'=>Arr::merge([''=>''],StaticList_ItemType::table()),'text'=>'Item Type','default'=>$o->type,'class'=>'col-md-2']);
echo View::factory('field/number')->set('data',['field'=>'quantity','value'=>$o->quantity,'text'=>'Quantity','class'=>'col-md-2']);
<?php echo Form::input('account_id_label',$o->account->name(),array('label'=>'Account','placeholder'=>'Account','data-provide'=>'typeahead')); ?> echo View::factory('field/money')->set('data',['field'=>'amount','value'=>$o->amount,'text'=>'Amount','class'=>'col-md-2']);
<?php echo Form::hidden('account_id',$o->account_id); ?> echo View::factory('field/select')->set('data',['field'=>'taxable','value'=>StaticList_YesNo::table(),'text'=>'Taxable','default'=>$o->taxable,'class'=>'col-md-1']);
echo View::factory('field/text')->set('data',['field'=>'description','value'=>$o->description,'text'=>'Description','class'=>'col-md-5']);
<?php echo Form::select('service_id',$o->account_id ? $o->account->service->list_select() : array(),$o->service_id,array('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::input('quantity',$o->quantity,array('label'=>'Quantity','placeholder'=>'Quantity')); ?>
<?php echo Form::input('amount',$o->amount,array('label'=>'Amount','placeholder'=>'Total',)); ?>
<?php echo StaticList_YesNo::form('taxable',is_null($o->taxable) ? TRUE : $o->taxable,FALSE,array('label'=>'Taxable')); ?>
<?php echo Form::input('description',$o->description,array('label'=>'Description','placeholder'=>'Any notes about this charge?')); ?>
<!-- @todo Use JS to dynamically add more lines as required --> <!-- @todo Use JS to dynamically add more lines as required -->
<?php $i=0; if ($o->attributes) foreach ($o->attributes as $key => $value) : <?php $i=0; if ($o->attributes) foreach ($o->attributes as $key => $value) :
echo Form::input("attributes[$key]",$value,array('label'=>$key)); echo Form::input("attributes[$key]",$value,array('label'=>$key));
$i++; $i++;
endforeach ?> endforeach ?>
<?php for ($i=$i;$i<10;$i++) : <?php for ($i=$i;$i<10;$i++) :
echo Form::input("attributes[$i]",isset($o->attributes[$i]) ? $o->attributes[$i] : '',array('label'=>'Attributes')); echo Form::input("attributes[$i]",isset($o->attributes[$i]) ? $o->attributes[$i] : '',array('label'=>'Attributes'));
endfor ?> endfor ?>
</fieldset> </fieldset>
<div class="row"> <?php echo View::factory('field/submit'); ?>
<button type="submit" class="btn btn-primary">Save changes</button> </div>
<button type="button" class="btn">Cancel</button>
</div> <?php
</div> <!-- /col-md-11 --> Script::factory()
->type('stdin')
->data('
$(document).ready(function() {
$("input[name=account_id]").change(function(){
// Send the request and update sub category dropdown
$.ajax({
type: "GET",
data: "key="+$(this).val(),
dataType: "json",
cache: false,
url: "'.URL::link('reseller','charge/ajaxlistservice',TRUE).'",
timeout: 2000,
error: function(x) {
alert("Failed to submit");
},
success: function(data) {
$("select[name=service_id]").empty();
$.each(data, function(i, j){
var row = "<option value=\"" + j.value + "\">" + j.label + "</option>";
$(row).appendTo("select[name=service_id]");
});
}
});
});
});');
?>

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Checkout extends ORM_OSB { class Model_Checkout extends ORM {
protected $_has_many = array( protected $_has_many = array(
'payment'=>array(), 'payment'=>array(),
'service'=>array('through'=>'account_billing','foreign_key'=>'checkout_id'), 'service'=>array('through'=>'account_billing','foreign_key'=>'checkout_id'),
@ -20,10 +20,6 @@ class Model_Checkout extends ORM_OSB {
/** REQUIRED ABSTRACT METHODS **/ /** REQUIRED ABSTRACT METHODS **/
public function name($variable=NULL) {
return $this->name;
}
/** LOCAL METHODS **/ /** LOCAL METHODS **/
/** /**
@ -46,6 +42,10 @@ class Model_Checkout extends ORM_OSB {
return Currency::round($net-$amt); return Currency::round($net-$amt);
} }
public function name($variable=NULL) {
return $this->name;
}
/** /**
* Return the object of the checkout plugin * Return the object of the checkout plugin
*/ */

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Checkout_Notify extends ORM_OSB implements Invoicable { class Model_Checkout_Notify extends ORM {
// Relationships // Relationships
protected $_has_one = array( protected $_has_one = array(
'checkout'=>array('far_key'=>'checkout_id','foreign_key'=>'id'), 'checkout'=>array('far_key'=>'checkout_id','foreign_key'=>'id'),
@ -25,10 +25,6 @@ class Model_Checkout_Notify extends ORM_OSB implements Invoicable {
'data', 'data',
); );
public function invoice_item($item_type) {
return sprintf('Payment Fee: %s',$this->checkout->name);
}
public function process() { public function process() {
return $this->checkout->plugin()->notify($this); return $this->checkout->plugin()->notify($this);
} }

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Domain_Registrar extends ORM_OSB { class Model_Domain_Registrar extends ORM {
/** /**
* The button that provides a login to the Registrar to manage the domain license * The button that provides a login to the Registrar to manage the domain license
*/ */

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Domain_Tld extends ORM_OSB { class Model_Domain_Tld extends ORM {
protected $_display_filters = array( protected $_display_filters = array(
'name'=>array( 'name'=>array(
array('strtoupper',array(':value')), array('strtoupper',array(':value')),

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Email_Log extends ORM_OSB { class Model_Email_Log extends ORM {
// Email Log doesnt use the update column // Email Log doesnt use the update column
protected $_updated_column = FALSE; protected $_updated_column = FALSE;

View File

@ -8,7 +8,7 @@
* @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
*/ */
class Model_Email_Template extends ORM_OSB { class Model_Email_Template extends ORM {
protected $_has_many = array( protected $_has_many = array(
'translate'=>array('model'=>'Email_Template_Translate','foreign_key'=>'email_template_id','far_key'=>'id'), 'translate'=>array('model'=>'Email_Template_Translate','foreign_key'=>'email_template_id','far_key'=>'id'),
); );

View File

@ -8,7 +8,7 @@
* @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
*/ */
class Model_Email_Template_Translate extends ORM_OSB { class Model_Email_Template_Translate extends ORM {
// This module doesnt keep track of column updates automatically // This module doesnt keep track of column updates automatically
protected $_created_column = FALSE; protected $_created_column = FALSE;
protected $_updated_column = FALSE; protected $_updated_column = FALSE;

View File

@ -100,10 +100,10 @@ class Export_Plugin_Quicken extends Export_Plugin {
$items[$c]['INVITEM'] = $edo->map_data['item']; $items[$c]['INVITEM'] = $edo->map_data['item'];
} else { } else {
throw HTTP_Exception::factory(501,'Missing product map data for :product (:id)',array(':product'=>$iio->module()->title(),':id'=>$iio->module_ref)); throw HTTP_Exception::factory(501,'Missing product map data for :product (:id)',array(':product'=>$iio->product->name(Site::language()),':id'=>$iio->module_ref));
} }
$items[$c]['MEMO'] = sprintf('%s (%s)',$iio->module()->title(),$iio->period()); $items[$c]['MEMO'] = $iio->name();
// Non product item // Non product item
} else { } else {

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Export extends ORM_OSB { class Model_Export extends ORM {
// Relationships // Relationships
protected $_has_many = array( protected $_has_many = array(
'export_module' => array('far_key'=>'id','xforeign_key'=>'x'), 'export_module' => array('far_key'=>'id','xforeign_key'=>'x'),

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Export_DataMap extends ORM_OSB { class Model_Export_DataMap extends ORM {
// Relationships // Relationships
protected $_belongs_to = array( protected $_belongs_to = array(
'export_module' => array(), 'export_module' => array(),
@ -20,12 +20,11 @@ class Model_Export_DataMap extends ORM_OSB {
'map_data', 'map_data',
); );
public function list_itemsnoexport(Model $o,$emoid,$desc='title()') { public function list_itemsnoexport(Model $o,$emoid,$desc='name(Site::language())') {
$result = array(); $result = array();
$o->select(array($this->table_name().'.id','edm')) $o->select(array($this->table_name().'.id','edm'))
->join($this->table_name(),'LEFT OUTER') ->join($this->table_name(),'LEFT OUTER')
->on($this->table_name().'.site_id','=',$o->table_name().'.site_id') // @todo This should be automatic
->on($this->table_name().'.item_id','=',$o->table_name().'.id') ->on($this->table_name().'.item_id','=',$o->table_name().'.id')
->on('export_module_id','=',$emoid) ->on('export_module_id','=',$emoid)
->where($o->table_name().'.status','=',TRUE) ->where($o->table_name().'.status','=',TRUE)

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Export_Item extends ORM_OSB { class Model_Export_Item extends ORM {
// Relationships // Relationships
protected $_belongs_to = array( protected $_belongs_to = array(
'export_module' => array(), 'export_module' => array(),

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Export_Module extends ORM_OSB { class Model_Export_Module extends ORM {
protected $_created_column = FALSE; protected $_created_column = FALSE;
protected $_updated_column = FALSE; protected $_updated_column = FALSE;

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Host_Server extends ORM_OSB { class Model_Host_Server extends ORM {
// Host Server doesnt use the update column // Host Server doesnt use the update column
protected $_updated_column = FALSE; protected $_updated_column = FALSE;

View File

@ -9,6 +9,6 @@
* @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
*/ */
class Model_Host_Server_Affiliate extends ORM_OSB { class Model_Host_Server_Affiliate extends ORM {
} }
?> ?>

View File

@ -1,5 +1,5 @@
<div id="page-title"> <div id="page-title">
<h1><?php echo $o->title(); ?></h1> <h1><?php echo $o->name(Site::language()); ?></h1>
<?php echo $o->description(); ?> <?php echo $o->description(); ?>
</div> <!-- /page-title --> </div> <!-- /page-title -->
@ -23,9 +23,7 @@
<div class="plan-header"> <div class="plan-header">
<div class="plan-title"> <div class="plan-title"><?php echo $po->name(Site::language()); ?></div>
<?php echo $po->title(); ?>
</div> <!-- /plan-title -->
<div class="plan-price"> <div class="plan-price">
<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> <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>

View File

@ -17,11 +17,11 @@ class Controller_Task_Invoice extends Controller_Task {
foreach (ORM::factory('Invoice_Item')->find_all() as $iio) { foreach (ORM::factory('Invoice_Item')->find_all() as $iio) {
if ($iio->product_name AND $iio->product_id) { if ($iio->product_name AND $iio->product_id) {
if (md5(strtoupper($iio->product_name)) == md5(strtoupper($iio->product->title()))) { if (md5(strtoupper($iio->product_name)) == md5(strtoupper($iio->product->name(Site::language())))) {
$iio->product_name = NULL; $iio->product_name = NULL;
$iio->save(); $iio->save();
} else { } else {
print_r(array("DIFF",'id'=>$iio->id,'pn'=>serialize($iio->product_name),'ppn'=>serialize($iio->product->title()),'pid'=>$iio->product_id,'test'=>strcasecmp($iio->product_name,$iio->product->title()))); print_r(array("DIFF",'id'=>$iio->id,'pn'=>serialize($iio->product_name),'ppn'=>serialize($iio->product->name(Site::language())),'pid'=>$iio->product_id,'test'=>strcasecmp($iio->product_name,$iio->product->name(Site::language()))));
} }
} }
} }

View File

@ -1,16 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This interface ensures that all items have the required invoice methods
*
* @package Invoice
* @category Interface
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
interface Invoicable {
// Render an invoice line item.
public function invoice_item($item_type);
}
?>

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Invoice extends ORM_OSB implements Cartable { class Model_Invoice extends ORM implements Cartable {
protected $_belongs_to = array( protected $_belongs_to = array(
'account'=>array() 'account'=>array()
); );
@ -54,14 +54,6 @@ class Model_Invoice extends ORM_OSB implements Cartable {
/** REQUIRED ABSTRACT METHODS **/ /** REQUIRED ABSTRACT METHODS **/
/**
* Display the Invoice Reference Number
*/
public function refnum($short=FALSE) {
return ($short ? '' : $this->account->refnum(FALSE).'-').sprintf('%06s',$this->id);
}
/** REQUIRED INTERFACE METHODS **/ /** REQUIRED INTERFACE METHODS **/
public function cart_item() { public function cart_item() {
@ -127,7 +119,7 @@ class Model_Invoice extends ORM_OSB implements Cartable {
$c = 0; $c = 0;
if (! $this->_loaded) if (! $this->_loaded)
foreach ($this->_sub_items as $iio) foreach ($this->_sub_items as $iio)
$iio->id = 'FAKE:'.$c++; $iio->id = '****:'.$c++;
// First work through our recurring schedule items // First work through our recurring schedule items
$result['s'] = array(); $result['s'] = array();
@ -191,14 +183,15 @@ class Model_Invoice extends ORM_OSB implements Cartable {
*/ */
public function items_summary() { public function items_summary() {
$result = array(); $result = array();
$lo = $this->account->language;
foreach ($this->subitems() as $iio) { foreach ($this->subitems() as $iio) {
// We only summarise item_type=0 // We only summarise item_type=0
if (! $iio->item_type == 0) if (! $iio->item_type == 0)
continue; continue;
if ($iio->module() instanceof Model_Product) { if ($iio->product) {
$p = $iio->module()->title(); $p = $iio->product->name($lo);
if (! isset($result[$p])) { if (! isset($result[$p])) {
$result[$p]['quantity'] = 0; $result[$p]['quantity'] = 0;
@ -258,6 +251,13 @@ class Model_Invoice extends ORM_OSB implements Cartable {
return $result; return $result;
} }
/**
* Display the Invoice Reference Number
*/
public function refnum($short=FALSE) {
return ($short ? '' : $this->account->refnum(FALSE).'-').sprintf('%06s',$this->id);
}
/** /**
* Check the reminder value * Check the reminder value
*/ */

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Invoice_Item extends ORM_OSB { class Model_Invoice_Item extends ORM {
// Relationships // Relationships
protected $_belongs_to = array( protected $_belongs_to = array(
'invoice'=>array(), 'invoice'=>array(),
@ -66,51 +66,6 @@ class Model_Invoice_Item extends ORM_OSB {
/** REQUIRED ABSTRACT METHODS **/ /** REQUIRED ABSTRACT METHODS **/
public function name($variable=NULL) {
if (! $this->isValid())
return sprintf('Record Error [%s-%s]',$this->item_type,$this->id);
switch ($this->item_type) {
case 0:
case 2:
case 3:
case 4:
case 5:
return sprintf('%s: %s',$this->product->name($variable),$this->service->namesub($variable));
case 124:
return StaticList_ItemType::get($this->item_type);
default:
return sprintf('Unknown [%s-%s]',$this->item_type,$this->id);
}
}
public function namesub($variable=NULL) {
if (! $this->isValid())
return sprintf('Record Error [%s-%s]',$this->item_type,$this->id);
switch ($this->item_type) {
case 0:
return sprintf('%s: %s',StaticList_ItemType::get($this->item_type),$this->period());
case 2:
return sprintf('%s: %s',StaticList_ItemType::get($this->item_type),$this->_module() ? $this->_module()->display('date_charge') : $this->period());
case 3:
case 4:
case 6:
return sprintf('%s: %s',StaticList_ItemType::get($this->item_type),($this->_module()->attributes ? $this->_module()->namesub($variable) : $this->_module()->display('date_charge')));
case 5:
return $this->_module()->namesub($variable);
default:
return sprintf('Unknown [%s-%s]',$this->item_type,$this->id);
}
}
/**
* Display the Invoice Item Reference Number
*/
public function refnum($short=FALSE) {
return $short ? '' : sprintf('%03s-',$this->item_type).sprintf('%06s',$this->id);
}
/** LOCAL METHODS **/ /** LOCAL METHODS **/
/** /**
@ -185,6 +140,7 @@ class Model_Invoice_Item extends ORM_OSB {
break; break;
case 3: case 3:
case 4: case 4:
case 7:
if (! $this->service_id OR ! $this->product_id OR ! $this->module_id OR ! $this->module_ref OR $this->product_name OR ! is_null($this->recurring_schedule)) if (! $this->service_id OR ! $this->product_id OR ! $this->module_id OR ! $this->module_ref OR $this->product_name OR ! is_null($this->recurring_schedule))
return FALSE; return FALSE;
break; break;
@ -210,11 +166,57 @@ class Model_Invoice_Item extends ORM_OSB {
return $this->_module(); return $this->_module();
} }
public function name($variable=NULL) {
if (! $this->isValid())
return sprintf('Record Error [%s-%s]',$this->item_type,$this->id);
switch ($this->item_type) {
case 0:
case 2:
case 3:
case 4:
case 5:
return sprintf('%s: %s',$this->product->name($variable),$this->service->namesub($variable));
case 124:
return StaticList_ItemType::get($this->item_type);
default:
return sprintf('Unknown [%s-%s]',$this->item_type,$this->id);
}
}
public function namesub($variable=NULL) {
if (! $this->isValid())
return sprintf('Record Error [%s-%s]',$this->item_type,$this->id);
switch ($this->item_type) {
case 0:
return sprintf('%s: %s',StaticList_ItemType::get($this->item_type),$this->period());
case 2:
return sprintf('%s: %s',StaticList_ItemType::get($this->item_type),$this->_module() ? $this->_module()->display('date_charge') : $this->period());
case 3:
case 4:
case 6:
return sprintf('%s: %s',StaticList_ItemType::get($this->item_type),($this->_module()->attributes ? $this->_module()->namesub($variable) : $this->_module()->display('date_charge')));
case 5:
case 7:
return $this->_module()->namesub($variable);
default:
return sprintf('Unknown [%s-%s]',$this->item_type,$this->id);
}
}
// Display the period that a transaction applies // Display the period that a transaction applies
public function period() { public function period() {
return ($this->date_start == $this->date_stop) ? Site::Date($this->date_start) : sprintf('%s -> %s',Site::Date($this->date_start),Site::Date($this->date_stop)); return ($this->date_start == $this->date_stop) ? Site::Date($this->date_start) : sprintf('%s -> %s',Site::Date($this->date_start),Site::Date($this->date_stop));
} }
/**
* Display the Invoice Item Reference Number
*/
public function refnum($short=FALSE) {
return $short ? '' : sprintf('%03s-',$this->item_type).sprintf('%06s',$this->id);
}
public function save(Validation $validation = NULL) { public function save(Validation $validation = NULL) {
// Our items will be clobbered once we save the object, so we need to save it here. // Our items will be clobbered once we save the object, so we need to save it here.
$subitems = $this->subitems(); $subitems = $this->subitems();
@ -276,20 +278,6 @@ class Model_Invoice_Item extends ORM_OSB {
return $result; return $result;
} }
/**
* The title for invoice items
*/
public function title() {
if ($this->service_id AND $this->module_id AND method_exists($this->module(),'invoice_title'))
return $this->service->name(); #$this->module_ref ? sprintf('%s: %s',$this->module()->invoice_title(),$this->service->name()) : $this->service->name();
elseif ($x=$this->module() AND ($x instanceof Model_Charge) AND $x->product_id)
return $x->product->title().' '.$this->service->name();
elseif ($this->product_id)
return sprintf('* %s: %s',$this->product->invoice_title(),$this->service->name());
else
return 'Unknown Item';
}
public function total($format=FALSE) { public function total($format=FALSE) {
$result = $this->void ? 0 : $this->subtotal()+$this->tax()-$this->discount(); $result = $this->void ? 0 : $this->subtotal()+$this->tax()-$this->discount();

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Invoice_Memo extends ORM_OSB { class Model_Invoice_Memo extends ORM {
// Relationships // Relationships
protected $_belongs_to = array( protected $_belongs_to = array(
'invoice'=>array(), 'invoice'=>array(),

View File

@ -9,7 +9,11 @@
* @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
*/ */
class Model_Account_Oauth extends ORM_OSB { class Model_Account_Oauth extends ORM {
protected $_serialize_column = array(
'oauth_data',
);
protected $_compress_column = array( protected $_compress_column = array(
'oauth_data', 'oauth_data',
); );

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Oauth extends ORM_OSB { class Model_Oauth extends ORM {
// Relationships // Relationships
protected $_has_many = array( protected $_has_many = array(
'account_oauth' => array('far_key'=>'id'), 'account_oauth' => array('far_key'=>'id'),

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Payment extends ORM_OSB { class Model_Payment extends ORM {
// Relationships // Relationships
protected $_belongs_to = array( protected $_belongs_to = array(
'account'=>array(), 'account'=>array(),

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Payment_Item extends ORM_OSB { class Model_Payment_Item extends ORM {
// Relationships // Relationships
protected $_belongs_to = array( protected $_belongs_to = array(
'payment'=>array(), 'payment'=>array(),

View File

@ -246,7 +246,7 @@ $.ajax({
throw HTTP_Exception::factory(403,'Product either doesnt exist, or you are not authorised to see it'); throw HTTP_Exception::factory(403,'Product either doesnt exist, or you are not authorised to see it');
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->name(Site::language())))
->title_icon('icon-th-list') ->title_icon('icon-th-list')
->body(View::factory('service/reseller/list')->set('o',$po->service->where_active()->find_all())); ->body(View::factory('service/reseller/list')->set('o',$po->service->where_active()->find_all()));
} }

View File

@ -12,9 +12,7 @@
* Column Definitions: * Column Definitions:
* + price_type: 0=One Time, 1=Recurring, 2=Trial * + price_type: 0=One Time, 1=Recurring, 2=Trial
*/ */
class Model_Product extends ORM_OSB implements Invoicable { class Model_Product extends ORM {
private $_pto = NULL;
protected $_has_many = array( protected $_has_many = array(
'invoice'=>array('through'=>'invoice_item'), 'invoice'=>array('through'=>'invoice_item'),
'service'=>array('far_key'=>'id'), 'service'=>array('far_key'=>'id'),
@ -50,6 +48,8 @@ class Model_Product extends ORM_OSB implements Invoicable {
'price_group', 'price_group',
); );
private $_pto = NULL;
// Our attributes that are arrays, we'll convert/unconvert them // Our attributes that are arrays, we'll convert/unconvert them
protected $_serialize_column = array( protected $_serialize_column = array(
'price_group', 'price_group',
@ -59,46 +59,6 @@ class Model_Product extends ORM_OSB implements Invoicable {
/** REQUIRED ABSTRACT METHODS **/ /** REQUIRED ABSTRACT METHODS **/
public function name($variable=NULL) {
if (! $variable instanceof Model_Language)
throw HTTP_Exception::factory(500,'Call to :method incorrect',array(':method'=>__METHOD__));
$pto = $this->_pto($variable);
return (! $pto->loaded() OR ! $pto->name) ? sprintf('Unknown: [%s]',$this->id) : $pto->name;
}
public function namesub($variable=NULL) {
if (! $variable instanceof Model_Language)
throw HTTP::Exception(500,'Call to :method incorrect',array(':method'=>__METHOD__));
$pto = $this->_pto($variable);
return (! $pto->loaded() OR ! $pto->description_short) ? sprintf('Unknown: [%s]',$this->id) : $pto->description_short;
}
public function refnum($short=FALSE) {
return ($short ? '' : sprintf('%02s-',Site::id())).sprintf('%04s',$this->id);
}
/** REQUIRED INTERFACE METHODS **/
public function invoice_item($item_type) {
switch ($item_type) {
case 0:
case 7:
return 'Service';
case 6:
return 'Service Cancellation';
default:
return 'Product Charge';
}
}
public function invoice_title() {
return $this->title();
}
/** LOCAL METHODS **/ /** LOCAL METHODS **/
// Our database index for pricing values // Our database index for pricing values
@ -134,9 +94,9 @@ class Model_Product extends ORM_OSB implements Invoicable {
* Return the translated description for a category. * Return the translated description for a category.
*/ */
public function description($full=FALSE) { public function description($full=FALSE) {
$x = $this->translate(); $pto = $this->_pto(Site::language());
return $x->loaded() ? $x->display($full ? 'description_full' : 'description_short') : 'No Description'; return $pto->loaded() ? $pto->display($full ? 'description_full' : 'description_short') : 'No Description';
} }
/** /**
@ -167,6 +127,24 @@ class Model_Product extends ORM_OSB implements Invoicable {
return ($this->price_type == 2) ? TRUE : FALSE; return ($this->price_type == 2) ? TRUE : FALSE;
} }
public function name($variable=NULL) {
if (! $variable instanceof Model_Language)
throw HTTP_Exception::factory(500,'Call to :method incorrect',array(':method'=>__METHOD__));
$pto = $this->_pto($variable);
return (! $pto->loaded() OR ! $pto->name) ? sprintf('Unknown: [%s]',$this->id) : $pto->name;
}
public function namesub($variable=NULL) {
if (! $variable instanceof Model_Language)
throw HTTP::Exception(500,'Call to :method incorrect',array(':method'=>__METHOD__));
$pto = $this->_pto($variable);
return (! $pto->loaded() OR ! $pto->description_short) ? sprintf('Unknown: [%s]',$this->id) : $pto->description_short;
}
/** /**
* Return the object of the product plugin * Return the object of the product plugin
*/ */
@ -235,6 +213,10 @@ class Model_Product extends ORM_OSB implements Invoicable {
return $this->_price_options; return $this->_price_options;
} }
public function refnum($short=FALSE) {
return ($short ? '' : sprintf('%02s-',Site::id())).sprintf('%04s',$this->id);
}
public function save(Validation $validation=NULL) { public function save(Validation $validation=NULL) {
parent::save($validation); parent::save($validation);
@ -257,18 +239,5 @@ class Model_Product extends ORM_OSB implements Invoicable {
public function supplier() { public function supplier() {
return $this->plugin() ? $this->plugin()->supplier() : 'other'; return $this->plugin() ? $this->plugin()->supplier() : 'other';
} }
private function translate() {
return $this->translate->where('language_id','=',Company::instance()->language())->find();
}
/**
* Return the translated title for a category
*/
public function title() {
$x = $this->translate();
return $x->loaded() ? $x->display('name') : 'No Title';
}
} }
?> ?>

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Product_Category extends ORM_OSB { class Model_Product_Category extends ORM {
protected $_table_name = 'product_cat'; protected $_table_name = 'product_cat';
protected $_created_column = FALSE; protected $_created_column = FALSE;
protected $_updated_column = FALSE; protected $_updated_column = FALSE;
@ -28,21 +28,46 @@ class Model_Product_Category extends ORM_OSB {
'position'=>'ASC', 'position'=>'ASC',
); );
private $_pto = NULL;
protected $_save_message = TRUE; protected $_save_message = TRUE;
/** REQUIRED ABSTRACT METHODS **/
/** LOCAL METHODS **/
/**
* Return the translated langauge object
*/
private function _pto(Model_Language $lo) {
if (! $this->_pto) {
// First try the called langauge.
$pto = $this->translate->where('language_id','=',$lo->id)->find();
// Second try the called langauge.
if (! $pto->loaded())
$pto = $this->translate->where('language_id','=',Company::instance()->language()->id)->find();
$this->_pto = $pto;
}
return $this->_pto;
}
/** /**
* Return the translated description for a category. * Return the translated description for a category.
*/ */
public function description() { public function description() {
$x = $this->translate(); $pto = $this->_pto(Site::language());
return $x->loaded() ? $x->display('description') : 'No Description'; return $pto->loaded() ? $pto->display('description') : 'No Description';
} }
public function name($variable=NULL) { public function name($variable=NULL) {
$x = $this->translate(); $pto = $this->_pto(Site::language());
return $x->loaded() ? $x->display('name') : 'No Name'; return $pto->loaded() ? $pto->display('name') : 'No Name';
} }
/** /**
@ -100,19 +125,5 @@ class Model_Product_Category extends ORM_OSB {
return $result; return $result;
} }
/**
* Return the translated title for a category
*/
public function title() {
$x = $this->translate();
return $x->loaded() ? $x->display('name') : 'No Title';
}
private function translate() {
return $this->translate->where('language_id','=',Company::instance()->language())->find();
}
} }
?> ?>

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Product_Category_Translate extends ORM_OSB { class Model_Product_Category_Translate extends ORM {
protected $_table_name = 'product_cat_translate'; protected $_table_name = 'product_cat_translate';
protected $_created_column = FALSE; protected $_created_column = FALSE;
protected $_updated_column = FALSE; protected $_updated_column = FALSE;

View File

@ -9,7 +9,7 @@
* @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
*/ */
abstract class Model_Product_Plugin extends ORM_OSB { abstract class Model_Product_Plugin extends ORM {
// 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();

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Product_Translate extends ORM_OSB { class Model_Product_Translate extends ORM {
protected $_created_column = FALSE; protected $_created_column = FALSE;
protected $_updated_column = FALSE; protected $_updated_column = FALSE;

View File

@ -122,8 +122,6 @@
padding: 1em 0; padding: 1em 0;
margin: 0 2em; margin: 0 2em;
text-align: center;
border-bottom: 1px dotted #CCC; border-bottom: 1px dotted #CCC;
} }
@ -379,6 +377,7 @@
font-weight: 500; font-weight: 500;
font-size: 11px; font-size: 11px;
margin: 0 0; margin: 0 0;
width: 100%;
} }
.plan.plain td:first-of-type { .plan.plain td:first-of-type {
border-left: 1px solid #D8D7D7; border-left: 1px solid #D8D7D7;
@ -421,7 +420,6 @@
border-top: 1px dotted #D8D7D7; border-top: 1px dotted #D8D7D7;
} }
.plan.plain .plan-features th { .plan.plain .plan-features th {
text-align: center;
padding: 5px; padding: 5px;
font-size: 110%; font-size: 110%;
font-weight: normal; font-weight: normal;

View File

@ -1,6 +1,6 @@
<div class="col-md-12"> <div class="col-md-12">
<fieldset> <fieldset>
<legend><?php echo $o->title();?></legend> <legend><?php echo $o->name(Site::language());?></legend>
<div class="form-group"> <div class="form-group">
<label for="status" class="col-sm-2 control-label">Product Active</label> <label for="status" class="col-sm-2 control-label">Product Active</label>

View File

@ -1,7 +1,7 @@
<div id="container"> <div id="container">
<div class="row divider service-container"> <div class="row divider service-container">
<div class="grid-3"> <div class="grid-3">
<h2><span class="slash">//</span> <?php echo $o->title(); ?></h2> <h2><span class="slash">//</span> <?php echo $o->name(Site::language()); ?></h2>
</div> </div>
<?php $c=0;foreach ($o->subcategories->find_all() as $pco) : ?> <?php $c=0;foreach ($o->subcategories->find_all() as $pco) : ?>
@ -14,7 +14,7 @@
<div class="grid-3"> <div class="grid-3">
<div class="service-item"> <div class="service-item">
<h3><i class="icon-tint"></i><?php echo $pco->title(); ?></h3> <h3><i class="icon-tint"></i><?php echo $pco->name(Site::language()); ?></h3>
<?php $x=350;echo strlen($pco->description())<$x ? $pco->description() : substr($pco->description(),0,$x).'...'; ?> <?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> <p><a href="<?php echo URL::site('product/category/'.$pco->id); ?>" class="">More Details »</a></p>

View File

@ -4,7 +4,7 @@
->page_items(25) ->page_items(25)
->columns(array( ->columns(array(
'id'=>'ID', 'id'=>'ID',
'title()'=>'Details', 'name(Site::language())'=>'Name',
'status'=>'Active', 'status'=>'Active',
'prod_plugin_file'=>'Plugin Name', 'prod_plugin_file'=>'Plugin Name',
'prod_plugin_data'=>'Plugin Data', 'prod_plugin_data'=>'Plugin Data',

View File

@ -1,11 +1,11 @@
<div id="page-title"> <div id="page-title">
<h1><?php echo $o->title(); ?></h1> <h1><?php echo $o->name(Site::language()); ?></h1>
<?php echo $o->description(); ?> <?php echo $o->description(); ?>
</div> <!-- /page-title --> </div> <!-- /page-title -->
<div id="container"> <div id="container">
<div class="span9"> <div class="col-md-9">
<?php echo $o->description(TRUE); ?> <?php echo $o->description(TRUE); ?>
</div> <!-- /row --> </div>
</div> <!-- /container --> </div> <!-- /container -->

View File

@ -23,89 +23,13 @@ class Controller_Admin_Service extends Controller_Service {
if ($this->request->post() AND $so=$this->add_edit() AND $so->loaded()) if ($this->request->post() AND $so=$this->add_edit() AND $so->loaded())
HTTP::redirect(URL::link('admin','service/edit/'.$so->id)); HTTP::redirect(URL::link('admin','service/edit/'.$so->id));
Script::factory() $this->meta->title = 'New Service';
->type('file')
->data('media/theme/bootstrap/js/bootstrap.datepicker.js');
Style::factory()
->type('file')
->data('media/theme/bootstrap/css/bootstrap.datepicker.css');
// @todo This AJAX URL should be a service one
Script::factory()
->type('stdin')
->data('
$(document).ready(function() {
$("#date_next_invoice_label").datepicker({
autoclose : true,
todayHighlight: true,
format : "dd-mm-yyyy",
todayBtn : true,
}).on("hide",function(ev) {
$("input[name=date_next_invoice]").val(ev.date.valueOf()/1000);
});
$("input[name=account_id_label]").typeahead({
minLength: 2,
source: function (query,process) {
search("'.URL::link('admin','payment/ajaxlist').'",query,process);
},
matcher: function () { return true; },
updater: function (item) {
$("input[name=account_id]").val(users[item]);
// Send the request and update sub category dropdown
$.ajax({
type: "GET",
data: "key="+users[item],
dataType: "html",
cache: false,
url: "'.URL::link('admin','payment/ajaxitemlist',TRUE).'",
timeout: 2000,
error: function(x) {
alert("Failed to submit");
},
success: function(data) {
$("div[id=items]").empty().append(data);
}
});
return item;
},
});
$("select[name=product_id]").change(function() {
// If we select a blank, then dont continue
if (this.value == 0)
return false;
// Send the request and update sub category dropdown
$.ajax({
type: "GET",
data: "key="+$(this).val(),
dataType: "html",
cache: false,
url: "'.URL::link('admin','service/ajaxaddplugin/',TRUE).'",
timeout: 2000,
error: function(x) {
alert("Failed to submit");
},
success: function(data) {
$("div[id=plugin]").empty().append(data);
}
});
});
});
');
// @todo Move this to automatically add this if a date format is used
Block::factory() Block::factory()
->type('form-horizontal') ->type('form-horizontal')
->title('Add/View Charge') ->title('Add New Service')
->title_icon('fa fa-wrench') ->title_icon($this->icon)
->body(View::factory('service/admin/add')); ->body(View::factory('service/admin/add')->set('o',ORM::factory('Service')));
} }
public function action_ajaxaddplugin() { public function action_ajaxaddplugin() {
@ -129,26 +53,10 @@ $(document).ready(function() {
if (! $so->loaded()) if (! $so->loaded())
HTTP::redirect('welcome/index'); HTTP::redirect('welcome/index');
Script::factory()
->type('file')
->data('media/theme/bootstrap/vendor/datepicker/js/bootstrap-datepicker.js');
Style::factory()
->type('file')
->data('media/theme/bootstrap/vendor/datepicker/css/datepicker.css');
Script::factory() Script::factory()
->type('stdin') ->type('stdin')
->data(' ->data('
$(document).ready(function() { $(document).ready(function() {
$("#date_next_invoice_label").datepicker({
autoclose : true,
format : "dd-M-yyyy",
todayBtn : true,
}).on("hide",function(ev) {
$("input[name=date_next_invoice]").val(ev.date.valueOf()/1000);
});
$("#service_connect_date_label").datepicker({ $("#service_connect_date_label").datepicker({
autoclose : true, autoclose : true,
format : "dd-M-yyyy", format : "dd-M-yyyy",
@ -314,12 +222,12 @@ $(document).ready(function() {
HTTP::redirect(URL::link('admin','service/view/'.$so->id)); HTTP::redirect(URL::link('admin','service/view/'.$so->id));
Block::add(array( Block::add(array(
'title'=>sprintf('Transaction History for %s: %s',$so->id(),$so->name()), 'title'=>sprintf('Transaction History for %s: %s',$so->refnum(TRUE),$so->name()),
'body'=>$loutput, 'body'=>$loutput,
)); ));
Block::add(array( Block::add(array(
'title'=>sprintf('Transaction Debug for %s: %s',$so->id(),$so->name()), 'title'=>sprintf('Transaction Debug for %s: %s',$so->refnum(TRUE),$so->name()),
'body'=>$doutput, 'body'=>$doutput,
)); ));
@ -327,7 +235,7 @@ $(document).ready(function() {
->set('o',$so); ->set('o',$so);
Block::add(array( Block::add(array(
'title'=>sprintf('%s: %s',$so->id(),$so->service_name()), 'title'=>sprintf('%s: %s',$so->refnum(TRUE),$so->name()),
'body'=>$output, 'body'=>$output,
)); ));
} }

View File

@ -12,7 +12,7 @@
* Fields: * Fields:
* + queue: PROVISION (to be provisioned) * + queue: PROVISION (to be provisioned)
*/ */
class Model_Service extends ORM_OSB { class Model_Service extends ORM {
private $_plugin = NULL; private $_plugin = NULL;
// Relationships // Relationships
@ -88,24 +88,6 @@ class Model_Service extends ORM_OSB {
/** REQUIRED ABSTRACT METHODS **/ /** REQUIRED ABSTRACT METHODS **/
/**
* Display the service product name
*/
public function name($variable=NULL) {
if (! $variable instanceOf Model_Language)
$variable = Company::instance()->language();
return $this->product->name($variable).(($x=$this->namesub($variable)) ? ': '.$x : '');
}
public function namesub($variable=NULL) {
return is_null($plugin=$this->_plugin()) ? '' : $plugin->name($variable);
}
public function refnum($short=FALSE) {
return ($short ? '' : sprintf('%02s-',Site::id())).sprintf('%05s',$this->id);
}
/** LOCAL METHODS **/ /** LOCAL METHODS **/
private function _plugin() { private function _plugin() {
@ -234,6 +216,20 @@ class Model_Service extends ORM_OSB {
->order_by('date_stop','DESC'); ->order_by('date_stop','DESC');
} }
/**
* Display the service product name
*/
public function name($variable=NULL) {
if (! $variable instanceOf Model_Language)
$variable = Company::instance()->language();
return $this->product->name($variable).(($x=$this->namesub($variable)) ? ': '.$x : '');
}
public function namesub($variable=NULL) {
return is_null($plugin=$this->_plugin()) ? '' : $plugin->name($variable);
}
/** /**
* Returns the date that an item has been paid to * Returns the date that an item has been paid to
*/ */
@ -284,6 +280,10 @@ class Model_Service extends ORM_OSB {
return (is_null($x = $this->plugin())) ? NULL : $x->render_edit(); return (is_null($x = $this->plugin())) ? NULL : $x->render_edit();
} }
public function refnum($short=FALSE) {
return ($short ? '' : sprintf('%02s-',Site::id())).sprintf('%05s',$this->id);
}
public function revenue($annual=FALSE) { public function revenue($annual=FALSE) {
$multiple = $annual ? Period::multiple($this->recur_schedule) : 1; $multiple = $annual ? Period::multiple($this->recur_schedule) : 1;

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Service_Billing extends ORM_OSB { class Model_Service_Billing extends ORM {
protected $_table_name = 'account_billing'; protected $_table_name = 'account_billing';
// Relationships // Relationships

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Service_Change extends ORM_OSB { class Model_Service_Change extends ORM {
protected $_table_name = 'service_change'; protected $_table_name = 'service_change';
// Relationships // Relationships
@ -35,7 +35,7 @@ class Model_Service_Change extends ORM_OSB {
$output = array(); $output = array();
foreach ($this->find_all() as $sco) { foreach ($this->find_all() as $sco) {
array_push($output,sprintf('%s %s',$sco->product->title(),$sco->display('date_effective'))); array_push($output,sprintf('%s %s',$sco->product->name($sco->service->account->language),$sco->display('date_effective')));
} }
} else { } else {

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Service_Memo extends ORM_OSB { class Model_Service_Memo extends ORM {
// Relationships // Relationships
protected $_belongs_to = array( protected $_belongs_to = array(
'service'=>array(), 'service'=>array(),

View File

@ -9,7 +9,7 @@
* @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
*/ */
abstract class Model_Service_Plugin extends ORM_OSB { abstract class Model_Service_Plugin extends ORM {
// 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();

View File

@ -1,30 +1,50 @@
<div class="col-md-11"> <div class="col-md-12">
<fieldset> <fieldset>
<legend>Service Information</legend> <legend>Service Information</legend>
<?php
echo View::factory('field/account')->set('data',['field'=>'account_id','value'=>$o->account_id,'text'=>'Account','name'=>'','ajaxurl'=>URL::link('admin','payment/ajaxlist')]);
echo View::factory('field/select')->set('data',['field'=>'status','value'=>StaticList_YesNo::table(),'text'=>'Active','default'=>$o->status,'class'=>'col-md-1']);
echo View::factory('field/select')->set('data',['field'=>'recur_schedule','value'=>StaticList_RecurSchedule::table(),'text'=>'Billing Period','default'=>$o->recur_schedule,'class'=>'col-md-2']);
echo View::factory('field/date')->set('data',['field'=>'data_next_invoice','value'=>$o->date_next_invoice ? $o->date_next_invoice : time(),'text'=>'Date Next Invoice','enddate'=>NULL]);
echo View::factory('field/select')->set('data',['field'=>'taxable','value'=>StaticList_YesNo::table(),'text'=>'Taxable','default'=>is_null($o->taxable) ? TRUE : $o->taxable,'class'=>'col-md-1']);
echo View::factory('field/select')->set('data',['field'=>'suspend_billing','value'=>StaticList_YesNo::table(),'text'=>'Suspend Billing','default'=>$o->suspend_billing,'class'=>'col-md-1']);
echo View::factory('field/money')->set('data',['field'=>'price','value'=>$o->price,'text'=>'Price']);
echo View::factory('field/money')->set('data',['field'=>'price_override','value'=>$o->price_override,'text'=>'Override Price']);
echo View::factory('field/select')->set('data',['field'=>'product_id','value'=>ORM::factory('Product')->where_active()->list_select(TRUE),'text'=>'Product','default'=>NULL,'class'=>'col-md-5']);
?>
<?php echo Form::input('account_id_label','',array('label'=>'Account','placeholder'=>'Account','autocomplete'=>'no','data-provide'=>'typeahead')); ?>
<?php echo Form::hidden('account_id',''); ?>
<?php echo StaticList_YesNo::form('status',NULL,FALSE,array('label'=>'Active')); ?>
<?php echo StaticList_RecurSchedule::form('recur_schedule',NULL,FALSE,array('label'=>'Billing Period','required'));?>
<label for="date_next_invoice_label">Date Next Invoice</label>
<div class="input-group col-md-3">
<input type="text" id="date_next_invoice_label" value="" xisabled="disabled" class="form-control" placeholder="Date Next Invoice">
<span class="input-group-addon" id="basic-addon1"><i class="fa fa-calendar"></i></span>
</div>
<?php echo Form::hidden('date_next_invoice',time()); ?>
<?php echo StaticList_YesNo::form('taxable',NULL,FALSE,array('label'=>'Taxable')); ?>
<?php echo StaticList_YesNo::form('suspend_billing',NULL,FALSE,array('label'=>'Suspend Billing')); ?>
<?php echo Form::input('price_override',NULL,array('label'=>'Override Price')); ?>
<?php echo Form::select('product_id',ORM::factory('Product')->list_select(TRUE),NULL,array('label'=>'Product','sort'=>TRUE)); ?>
</fieldset> </fieldset>
<div id="plugin"></div> <div id="plugin"></div>
<div class="row"> <?php echo View::factory('field/submit'); ?>
<button type="submit" class="btn btn-primary">Save changes</button> </div>
<button type="button" class="btn">Cancel</button>
</div> <?php
</div> <!-- /col-md-11 --> Script::factory()
->type('stdin')
->data('
$(document).ready(function() {
$("select[name=product_id]").change(function() {
// If we select a blank, then dont continue
if (this.value == 0)
return false;
// Send the request and update sub category dropdown
$.ajax({
type: "GET",
data: "key="+$(this).val(),
dataType: "html",
cache: false,
url: "'.URL::link('admin','service/ajaxaddplugin/',TRUE).'",
timeout: 2000,
error: function(x) {
alert("Failed to submit");
},
success: function(data) {
$("div[id=plugin]").empty().append(data);
}
});
});
});');
?>

View File

@ -1,29 +1,17 @@
<div class="col-md-11"> <div class="col-md-12">
<fieldset> <fieldset>
<legend>Update Service</legend> <legend>Update Service</legend>
<?php
<?php echo StaticList_YesNo::form('status',$o->status,FALSE,array('label'=>'Active')); ?> echo View::factory('field/select')->set('data',['field'=>'status','value'=>StaticList_YesNo::table(),'text'=>'Active','default'=>$o->status,'class'=>'col-md-1']);
echo View::factory('field/select')->set('data',['field'=>'recur_schedule','value'=>StaticList_RecurSchedule::table(),'text'=>'Billing Period','default'=>$o->recur_schedule,'class'=>'col-md-2']);
<?php echo StaticList_RecurSchedule::form('recur_schedule',$o->recur_schedule,FALSE,array('label'=>'Billing Period','required'));?> echo View::factory('field/date')->set('data',['field'=>'data_next_invoice','value'=>$o->date_next_invoice,'text'=>'Date Next Invoice','enddate'=>NULL]);
echo View::factory('field/select')->set('data',['field'=>'taxable','value'=>StaticList_YesNo::table(),'text'=>'Taxable','default'=>$o->taxable,'class'=>'col-md-1']);
<label for="date_next_invoice_label">Date Next Invoice</label> echo View::factory('field/select')->set('data',['field'=>'suspend_billing','value'=>StaticList_YesNo::table(),'text'=>'Suspend Billing','default'=>$o->suspend_billing,'class'=>'col-md-1']);
<div class="input-group col-md-3"> echo View::factory('field/money')->set('data',['field'=>'price_override','value'=>$o->price_override,'text'=>'Override Price']);
<input type="text" id="date_next_invoice_label" value="<?php echo $o->display('date_next_invoice'); ?>" class="form-control" placeholder="Date Next Invoice"> ?>
<span class="input-group-addon" id="basic-addon1"><i class="fa fa-calendar"></i></span>
</div>
<?php echo Form::hidden('date_next_invoice',$o->date_next_invoice); ?>
<?php echo StaticList_YesNo::form('taxable',$o->taxable,FALSE,array('label'=>'Taxable')); ?>
<?php echo StaticList_YesNo::form('suspend_billing',$o->suspend_billing,FALSE,array('label'=>'Suspend Billing')); ?>
<?php echo Form::input('price_override',$o->price_override,array('label'=>'Override Price')); ?>
</fieldset> </fieldset>
<?php if ($plugin_form) { echo $plugin_form; } ?> <?php if ($plugin_form) { echo $plugin_form; } ?>
<div class="row"> <?php echo View::factory('field/submit'); ?>
<button type="submit" class="btn btn-primary">Save changes</button> </div>
<button type="button" class="btn">Cancel</button>
</div>
</div> <!-- /col-md-11 -->

View File

@ -1,10 +1,10 @@
<?php if ($o->pending_change()) : ?> <?php if ($o->pending_change()) : ?>
<div class="span5"> <div class="col-md-5">
Pending change to: <?php echo $o->service_change->list_details(); ?> Pending change to: <?php echo $o->service_change->list_details(); ?>
</div> <!-- /span --> </div> <!-- /span -->
<?php endif ?> <?php endif ?>
<div class="span6"> <div class="col-md-12">
<fieldset> <fieldset>
<legend>Service Transaction Details</legend> <legend>Service Transaction Details</legend>
@ -28,7 +28,7 @@
<?php if (! is_null($iio->product_id) AND $lp != $iio->product_id) : $lp = $iio->product_id; ?> <?php if (! is_null($iio->product_id) AND $lp != $iio->product_id) : $lp = $iio->product_id; ?>
<tr> <tr>
<th><?php echo $iio->product_id; ?></th> <th><?php echo $iio->product_id; ?></th>
<th colspan="9"><?php echo $iio->product->title(); ?></th> <th colspan="9"><?php echo $iio->product->name($o->account->language); ?></th>
</tr> </tr>
<?php endif ?> <?php endif ?>

View File

@ -20,10 +20,9 @@
<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>
<!-- @todo -->
<?php if (is_null($o->price) OR ($o->price<=$o->product->price($o->price_group,$o->recur_schedule,'base'))) : ?> <?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->name($o->account->language)); ?></dd>
<?php endif ?> <?php endif ?>
<dt>Invoiced To</dt> <dt>Invoiced To</dt>

View File

@ -122,12 +122,12 @@ class Controller_Reseller_Ssl extends Controller_Ssl {
} }
public function action_renew() { public function action_renew() {
$so = ORM::factory('Service',Request::current()->param('id')); $so = ORM::factory('Service',$this->request->param('id'));
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account)) if (! $so->loaded() OR ! Auth::instance()->authorised($so->account))
throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it'); throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it');
$so->plugin()->renew(); $so->plugin()->renew($this->request->query('force'));
HTTP::redirect(URL::link('user','service/view/'.$so->id)); HTTP::redirect(URL::link('user','service/view/'.$so->id));
} }

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_SSL extends ORM_OSB { class Model_SSL extends ORM {
protected $_updated_column = FALSE; protected $_updated_column = FALSE;
} }
?> ?>

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_SSL_CA extends ORM_OSB { class Model_SSL_CA extends ORM {
protected $_updated_column = FALSE; protected $_updated_column = FALSE;
// Relationships // Relationships

View File

@ -47,14 +47,6 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
return (! $this->_so) ? ($format ? 'Not Issued' : 0) : $this->_so->get_valid_to($format); return (! $this->_so) ? ($format ? 'Not Issued' : 0) : $this->_so->get_valid_to($format);
} }
public function name($variable=NULL) {
return ($this->cert AND $this->ca->loaded()) ? sprintf('%s:%s',$this->ca->subject(),$this->display('cert')) : $this->display('csr');
}
public function namesub($variable=NULL) {
return $this->ca->dn();
}
public function password() {} // Not used public function password() {} // Not used
public function username() {} // Not used public function username() {} // Not used
@ -156,6 +148,14 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
return 'Unknown'; return 'Unknown';
} }
public function name($variable=NULL) {
return ($this->cert AND $this->ca->loaded()) ? sprintf('%s:%s',$this->ca->subject(),$this->display('cert')) : $this->display('csr');
}
public function namesub($variable=NULL) {
return $this->ca->dn();
}
/** /**
* Renew an SSL Certificate * Renew an SSL Certificate
*/ */
@ -180,7 +180,7 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
$res = openssl_csr_sign($this->csr,$this->ca->sign_cert,$this->ca->sign_pk,$days,array( $res = openssl_csr_sign($this->csr,$this->ca->sign_cert,$this->ca->sign_pk,$days,array(
'config'=>$ssl_conf['config'], 'config'=>$ssl_conf['config'],
'x509_extensions'=>$this->service->product->plugin()->extensions, 'x509_extensions'=>$this->service->product->plugin()->extensions,
'digest_alg'=>'sha1', 'digest_alg'=>$ssl_conf['digest'],
),time()); ),time());
if ($res AND openssl_x509_export($res,$cert)) { if ($res AND openssl_x509_export($res,$cert)) {

View File

@ -18,5 +18,8 @@ return array(
// Location to openssl config // Location to openssl config
'config' => 'application/config/openssl.cnf', 'config' => 'application/config/openssl.cnf',
// Algorithm to use for signing certs
'digest' => 'sha256',
); );
?> ?>

View File

@ -1,7 +1,9 @@
<fieldset> <fieldset>
<legend>SSL Certificate Service Details</legend> <legend>SSL Certificate Service Details</legend>
<?php echo Form::textarea('plugin[csr]',$o->service->plugin()->csr,array('label'=>'CSR','placeholder'=>'CSR','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->csr),'cols'=>Form::textarea_width($o->service->plugin()->csr))); ?> <?php
<?php echo Form::textarea('plugin[pk]',$o->service->plugin()->pk,array('label'=>'Private Key','placeholder'=>'Private Key','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->pk),'cols'=>Form::textarea_width($o->service->plugin()->pk))); ?> echo View::factory('field/textarea')->set('data',['field'=>'plugin[csr]','value'=>$o->service->plugin()->csr,'text'=>'CSR']);
<?php echo Form::textarea('plugin[cert]',$o->service->plugin()->cert,array('label'=>'Public Certificate','placeholder'=>'Public Certificate','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->cert),'cols'=>Form::textarea_width($o->service->plugin()->cert))); ?> echo View::factory('field/textarea')->set('data',['field'=>'plugin[pk]','value'=>$o->service->plugin()->pk,'text'=>'Private Key']);
echo View::factory('field/textarea')->set('data',['field'=>'plugin[cert]','value'=>$o->service->plugin()->cert,'text'=>'Public Certificate']);
?>
</fieldset> </fieldset>

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Task extends ORM_OSB { class Model_Task extends ORM {
protected $_display_filters = array( protected $_display_filters = array(
'date_run'=>array( 'date_run'=>array(
array('Site::Datetime',array(':value')), array('Site::Datetime',array(':value')),

View File

@ -9,7 +9,7 @@
* @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
*/ */
class Model_Task_Log extends ORM_OSB { class Model_Task_Log extends ORM {
protected $_sorting = array( protected $_sorting = array(
'id'=>'DESC', 'id'=>'DESC',
); );

View File

@ -9,6 +9,6 @@
* @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
*/ */
class Model_Invoice_Item_Tax extends ORM_OSB { class Model_Invoice_Item_Tax extends ORM {
} }
?> ?>

View File

@ -9,6 +9,6 @@
* @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
*/ */
class Model_Tax extends ORM_OSB { class Model_Tax extends ORM {
} }
?> ?>