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

@@ -10,5 +10,6 @@
* @license http://dev.osbill.net/license.html
*/
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() {
Block::factory()
->type('form-horizontal')
->title('Add/View Charge')
->title_icon('fa fa-wrench')
->title('New Charge')
->title_icon($this->icon)
->body($this->add_edit());
}
@@ -54,72 +54,11 @@ class Controller_Reseller_Charge extends Controller_Charge {
private function add_edit($id=NULL,$output='') {
$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)))
$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')
->set('o',$co);
}
@@ -130,7 +69,7 @@ $(document).ready(function() {
Block::factory()
->type('form-horizontal')
->title(sprintf('%s: %s',_('View Charges'),$id))
->title_icon('fa fa-wrench')
->title_icon($this->icon)
->body($this->add_edit($id,$output));
}

View File

@@ -9,7 +9,7 @@
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Charge extends ORM_OSB implements Invoicable {
class Model_Charge extends ORM {
protected $_belongs_to = array(
'account'=>array(),
'product'=>array(),
@@ -80,9 +80,6 @@ class Model_Charge extends ORM_OSB implements Invoicable {
}
/** 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 **/
@@ -100,26 +97,9 @@ class Model_Charge extends ORM_OSB implements Invoicable {
return $iio;
}
public function invoice_item($item_type) {
switch ($item_type) {
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 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'));
}
public function xtitle() {
return $this->invoice_item(5);
}
public function total($format=FALSE) {
$result = $this->quantity * $this->amount;