2011-09-28 06:46:22 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class supports Service Plugins.
|
|
|
|
*
|
|
|
|
* @package OSB
|
|
|
|
* @subpackage Product/Service
|
|
|
|
* @category Models
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2010 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
2012-12-10 21:48:30 +00:00
|
|
|
abstract class Model_Service_Plugin extends ORM_OSB {
|
2011-09-28 06:46:22 +00:00
|
|
|
// Reset any sorting that may be defined in our parent
|
|
|
|
protected $_sorting = array();
|
|
|
|
|
|
|
|
/**
|
2011-12-29 02:52:24 +00:00
|
|
|
* Form info for admins to update
|
2011-09-28 06:46:22 +00:00
|
|
|
*/
|
2011-12-29 02:52:24 +00:00
|
|
|
abstract public function admin_update();
|
2011-09-28 06:46:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Our service name as defined in the DB
|
|
|
|
*/
|
|
|
|
abstract public function name();
|
|
|
|
|
2012-10-08 12:52:21 +00:00
|
|
|
/**
|
|
|
|
* When does our service expire
|
|
|
|
*/
|
|
|
|
abstract public function expire();
|
|
|
|
|
2011-09-28 06:46:22 +00:00
|
|
|
/**
|
|
|
|
* 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());
|
|
|
|
}
|
|
|
|
|
2011-12-29 02:52:24 +00:00
|
|
|
/**
|
|
|
|
* View details of the service
|
|
|
|
*/
|
|
|
|
abstract public function service_view();
|
|
|
|
|
2012-06-22 05:12:59 +00:00
|
|
|
/**
|
|
|
|
* The table attributes that provide username/password values
|
|
|
|
*/
|
|
|
|
abstract public function username_value();
|
|
|
|
abstract public function password_value();
|
|
|
|
|
|
|
|
public function manage_button() {
|
2012-10-22 12:24:28 +00:00
|
|
|
if (! $this->service->status)
|
|
|
|
return FALSE;
|
|
|
|
|
2012-06-22 05:12:59 +00:00
|
|
|
static $k = '';
|
|
|
|
|
|
|
|
// If $k is already set, we've rendered this JS
|
|
|
|
if ($k)
|
2012-10-22 12:24:28 +00:00
|
|
|
return TRUE;
|
2012-06-22 05:12:59 +00:00
|
|
|
|
|
|
|
$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(":");
|
2012-06-26 14:28:18 +00:00
|
|
|
if (x++) { alert("Session expired, please refresh the page!"); return false; }
|
2013-02-12 11:14:59 +00:00
|
|
|
$.getJSON("'.URL::link('user','service/ajaxmanage/'.$this->service_id,TRUE).'", { k: "'.$k.'",t: t[1] }, function(data) {
|
2012-06-22 05:12:59 +00:00
|
|
|
$.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(); });
|
|
|
|
});
|
|
|
|
});'
|
|
|
|
));
|
2012-10-22 12:24:28 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2012-06-22 05:12:59 +00:00
|
|
|
}
|
|
|
|
|
2011-09-28 06:46:22 +00:00
|
|
|
/**
|
|
|
|
* 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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|