Open Source Billing
This commit is contained in:
20
modules/service/classes/Model/Service/Billing.php
Normal file
20
modules/service/classes/Model/Service/Billing.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class supports Service Billing.
|
||||
*
|
||||
* @package Service
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Service_Billing extends ORM_OSB {
|
||||
protected $_table_name = 'account_billing';
|
||||
|
||||
// Relationships
|
||||
protected $_has_one = array(
|
||||
'checkout'=>array('far_key'=>'checkout_plugin_id','foreign_key'=>'id'),
|
||||
);
|
||||
}
|
||||
?>
|
48
modules/service/classes/Model/Service/Change.php
Normal file
48
modules/service/classes/Model/Service/Change.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class supports Service Product Changes.
|
||||
*
|
||||
* @package Service
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Service_Change extends ORM_OSB {
|
||||
protected $_table_name = 'service_change';
|
||||
|
||||
// Relationships
|
||||
protected $_belongs_to = array(
|
||||
'product'=>array(),
|
||||
'service'=>array(),
|
||||
);
|
||||
|
||||
/**
|
||||
* Filters used to format the display of values into friendlier values
|
||||
*/
|
||||
protected $_display_filters = array(
|
||||
'date_ordered'=>array(
|
||||
array('Config::date',array(':value')),
|
||||
),
|
||||
'date_effective'=>array(
|
||||
array('Config::date',array(':value')),
|
||||
),
|
||||
);
|
||||
|
||||
public function list_details() {
|
||||
if ($this->_db_pending) {
|
||||
$output = array();
|
||||
|
||||
foreach ($this->find_all() as $sco) {
|
||||
array_push($output,sprintf('%s %s',$sco->product->name(),$sco->display('date_effective')));
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Kohana_Exception('Shouldnt be here!');
|
||||
}
|
||||
|
||||
return join('|',$output);
|
||||
}
|
||||
}
|
||||
?>
|
97
modules/service/classes/Model/Service/Plugin.php
Normal file
97
modules/service/classes/Model/Service/Plugin.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class supports Service Plugins.
|
||||
*
|
||||
* @package Service
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
abstract class Model_Service_Plugin extends ORM_OSB {
|
||||
// Reset any sorting that may be defined in our parent
|
||||
protected $_sorting = array();
|
||||
|
||||
/**
|
||||
* Form info for admins to update
|
||||
*/
|
||||
abstract public function admin_update();
|
||||
|
||||
/**
|
||||
* Our service name as defined in the DB
|
||||
*/
|
||||
abstract public function name();
|
||||
|
||||
/**
|
||||
* When does our service expire
|
||||
*/
|
||||
abstract public function expire();
|
||||
|
||||
/**
|
||||
* Show our service name as defined in the DB with product suffix.
|
||||
*/
|
||||
public function service_name() {
|
||||
return sprintf('%s - %s',$this->service->product->name(),$this->name());
|
||||
}
|
||||
|
||||
/**
|
||||
* View details of the service
|
||||
*/
|
||||
abstract public function service_view();
|
||||
|
||||
/**
|
||||
* The table attributes that provide username/password values
|
||||
*/
|
||||
abstract public function username_value();
|
||||
abstract public function password_value();
|
||||
|
||||
public function manage_button() {
|
||||
if (! $this->service->status)
|
||||
return FALSE;
|
||||
|
||||
static $k = '';
|
||||
|
||||
// If $k is already set, we've rendered this JS
|
||||
if ($k)
|
||||
return TRUE;
|
||||
|
||||
$k = Random::char();
|
||||
Session::instance()->set('manage_button',$k);
|
||||
|
||||
Script::add(array('type'=>'stdin','data'=>'
|
||||
$(document).ready(function() {
|
||||
var x=0;
|
||||
$("button[name=submit]").click(function() {
|
||||
var t=$(this).val().split(":");
|
||||
if (x++) { alert("Session expired, please refresh the page!"); return false; }
|
||||
$.getJSON("'.URL::link('user','service/ajaxmanage/'.$this->service_id,TRUE).'", { k: "'.$k.'",t: t[1] }, function(data) {
|
||||
$.each(data, function(key, val) { $("#"+key+"_"+t[0]+"_"+t[1]).val(val); });
|
||||
}).error(function() { alert("There was a problem with the request"); return false; }).success(
|
||||
function() { $("form[id=id_"+t[0]+"_"+t[1]+"]").submit(); });
|
||||
});
|
||||
});'
|
||||
));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specific service details for use in other modules
|
||||
* For Example: Invoice
|
||||
*
|
||||
* @todo Make the rendered items configurable
|
||||
* @todo Change this method name, now that it is public
|
||||
*/
|
||||
public function _details($type) {
|
||||
switch ($type) {
|
||||
// Nothing to add for invoices
|
||||
case 'invoice_detail_items':
|
||||
return array();
|
||||
|
||||
default:
|
||||
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user