Removed redundant functions, some Standardisation work
This commit is contained in:
@@ -23,89 +23,13 @@ class Controller_Admin_Service extends Controller_Service {
|
||||
if ($this->request->post() AND $so=$this->add_edit() AND $so->loaded())
|
||||
HTTP::redirect(URL::link('admin','service/edit/'.$so->id));
|
||||
|
||||
Script::factory()
|
||||
->type('file')
|
||||
->data('media/theme/bootstrap/js/bootstrap.datepicker.js');
|
||||
$this->meta->title = 'New Service';
|
||||
|
||||
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()
|
||||
->type('form-horizontal')
|
||||
->title('Add/View Charge')
|
||||
->title_icon('fa fa-wrench')
|
||||
->body(View::factory('service/admin/add'));
|
||||
->title('Add New Service')
|
||||
->title_icon($this->icon)
|
||||
->body(View::factory('service/admin/add')->set('o',ORM::factory('Service')));
|
||||
}
|
||||
|
||||
public function action_ajaxaddplugin() {
|
||||
@@ -129,26 +53,10 @@ $(document).ready(function() {
|
||||
if (! $so->loaded())
|
||||
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()
|
||||
->type('stdin')
|
||||
->data('
|
||||
$(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({
|
||||
autoclose : true,
|
||||
format : "dd-M-yyyy",
|
||||
@@ -314,12 +222,12 @@ $(document).ready(function() {
|
||||
HTTP::redirect(URL::link('admin','service/view/'.$so->id));
|
||||
|
||||
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,
|
||||
));
|
||||
|
||||
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,
|
||||
));
|
||||
|
||||
@@ -327,7 +235,7 @@ $(document).ready(function() {
|
||||
->set('o',$so);
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s',$so->id(),$so->service_name()),
|
||||
'title'=>sprintf('%s: %s',$so->refnum(TRUE),$so->name()),
|
||||
'body'=>$output,
|
||||
));
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@
|
||||
* Fields:
|
||||
* + queue: PROVISION (to be provisioned)
|
||||
*/
|
||||
class Model_Service extends ORM_OSB {
|
||||
class Model_Service extends ORM {
|
||||
private $_plugin = NULL;
|
||||
|
||||
// Relationships
|
||||
@@ -88,24 +88,6 @@ class Model_Service extends ORM_OSB {
|
||||
|
||||
/** 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 **/
|
||||
|
||||
private function _plugin() {
|
||||
@@ -234,6 +216,20 @@ class Model_Service extends ORM_OSB {
|
||||
->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
|
||||
*/
|
||||
@@ -284,6 +280,10 @@ class Model_Service extends ORM_OSB {
|
||||
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) {
|
||||
$multiple = $annual ? Period::multiple($this->recur_schedule) : 1;
|
||||
|
||||
|
@@ -9,7 +9,7 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @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';
|
||||
|
||||
// Relationships
|
||||
|
@@ -9,7 +9,7 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @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';
|
||||
|
||||
// Relationships
|
||||
@@ -35,7 +35,7 @@ class Model_Service_Change extends ORM_OSB {
|
||||
$output = array();
|
||||
|
||||
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 {
|
||||
|
@@ -9,7 +9,7 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Service_Memo extends ORM_OSB {
|
||||
class Model_Service_Memo extends ORM {
|
||||
// Relationships
|
||||
protected $_belongs_to = array(
|
||||
'service'=>array(),
|
||||
|
@@ -9,7 +9,7 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @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
|
||||
protected $_sorting = array();
|
||||
|
||||
|
@@ -1,30 +1,50 @@
|
||||
<div class="col-md-11">
|
||||
<div class="col-md-12">
|
||||
<fieldset>
|
||||
<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>
|
||||
|
||||
<div id="plugin"></div>
|
||||
|
||||
<div class="row">
|
||||
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||
<button type="button" class="btn">Cancel</button>
|
||||
</div>
|
||||
</div> <!-- /col-md-11 -->
|
||||
<?php echo View::factory('field/submit'); ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
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);
|
||||
}
|
||||
});
|
||||
});
|
||||
});');
|
||||
?>
|
||||
|
@@ -1,29 +1,17 @@
|
||||
<div class="col-md-11">
|
||||
<div class="col-md-12">
|
||||
<fieldset>
|
||||
<legend>Update Service</legend>
|
||||
|
||||
<?php echo StaticList_YesNo::form('status',$o->status,FALSE,array('label'=>'Active')); ?>
|
||||
|
||||
<?php echo StaticList_RecurSchedule::form('recur_schedule',$o->recur_schedule,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="<?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')); ?>
|
||||
<?php
|
||||
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,'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']);
|
||||
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_override','value'=>$o->price_override,'text'=>'Override Price']);
|
||||
?>
|
||||
</fieldset>
|
||||
|
||||
<?php if ($plugin_form) { echo $plugin_form; } ?>
|
||||
|
||||
<div class="row">
|
||||
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||
<button type="button" class="btn">Cancel</button>
|
||||
</div>
|
||||
</div> <!-- /col-md-11 -->
|
||||
<?php echo View::factory('field/submit'); ?>
|
||||
</div>
|
||||
|
@@ -1,10 +1,10 @@
|
||||
<?php if ($o->pending_change()) : ?>
|
||||
<div class="span5">
|
||||
<div class="col-md-5">
|
||||
Pending change to: <?php echo $o->service_change->list_details(); ?>
|
||||
</div> <!-- /span -->
|
||||
<?php endif ?>
|
||||
|
||||
<div class="span6">
|
||||
<div class="col-md-12">
|
||||
<fieldset>
|
||||
<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; ?>
|
||||
<tr>
|
||||
<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>
|
||||
<?php endif ?>
|
||||
|
||||
|
@@ -20,10 +20,9 @@
|
||||
<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>
|
||||
|
||||
<!-- @todo -->
|
||||
<?php if (is_null($o->price) OR ($o->price<=$o->product->price($o->price_group,$o->recur_schedule,'base'))) : ?>
|
||||
<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 ?>
|
||||
|
||||
<dt>Invoiced To</dt>
|
||||
|
Reference in New Issue
Block a user