Internal overhaul
This commit is contained in:
@@ -14,7 +14,7 @@ class Model_ADSL_Supplier extends ORM_OSB {
|
||||
|
||||
// Relationships
|
||||
protected $_has_many = array(
|
||||
'adsl_supplier_plan'=>array('model'=>'ADSL_Supplier_Plan','foreign_key'=>'supplier_id','far_key'=>'id'),
|
||||
'plan'=>array('model'=>'ADSL_Supplier_Plan','foreign_key'=>'supplier_id','far_key'=>'id'),
|
||||
'traffic'=>array('model'=>'Service_Plugin_Adsl_Traffic','foreign_key'=>'supplier_id','far_key'=>'id'),
|
||||
);
|
||||
|
||||
@@ -50,7 +50,7 @@ class Model_ADSL_Supplier extends ORM_OSB {
|
||||
* Return a list of plans that this supplier makes available
|
||||
*/
|
||||
public function find_plans($active=TRUE) {
|
||||
return $active ? $this->adsl_supplier_plan->where_active() : $this->adsl_supplier_plan;
|
||||
return $active ? $this->plan->where_active() : $this->plan;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,8 +63,8 @@ class Model_ADSL_Supplier extends ORM_OSB {
|
||||
|
||||
foreach ($this->find_plans(FALSE)->find_all() as $aspo) {
|
||||
foreach ($aspo->plan->find_all() as $apo) {
|
||||
foreach ($apo->products(FALSE)->find_all() as $po) {
|
||||
foreach ($po->services($active)->find_all() as $so) {
|
||||
foreach ($apo->products(FALSE) as $po) {
|
||||
foreach ($po->service->list_active() as $so) {
|
||||
array_push($result,$so);
|
||||
}
|
||||
}
|
||||
|
@@ -19,9 +19,6 @@ class Model_Product_Plugin_Adsl extends Model_Product_Plugin {
|
||||
protected $_belongs_to = array(
|
||||
'supplier_plan'=>array('model'=>'ADSL_Supplier_Plan','foreign_key'=>'adsl_supplier_plan_id'),
|
||||
);
|
||||
protected $_has_many = array(
|
||||
'product'=>array('far_key'=>'id','foreign_key'=>'prod_plugin_data'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Filters used to format the display of values into friendlier values
|
||||
@@ -59,14 +56,6 @@ class Model_Product_Plugin_Adsl extends Model_Product_Plugin {
|
||||
'extra_up_offpeak',
|
||||
);
|
||||
|
||||
// Map the table fields
|
||||
private $_map = array(
|
||||
'base_up_offpeak'=>'extra_up_offpeak',
|
||||
'base_down_offpeak'=>'extra_down_offpeak',
|
||||
'base_up_peak'=>'extra_up_peak',
|
||||
'base_down_peak'=>'extra_down_peak',
|
||||
);
|
||||
|
||||
// Our required abstract methods
|
||||
|
||||
public function cost($annual=FALSE) {
|
||||
@@ -75,25 +64,24 @@ class Model_Product_Plugin_Adsl extends Model_Product_Plugin {
|
||||
return $annual ? $x*12 : $x;
|
||||
}
|
||||
|
||||
public function feature_summary() {
|
||||
return View::factory(sprintf('product/plugin/%s/feature_summary',$this->plugin()))
|
||||
->set('o',$this);
|
||||
}
|
||||
|
||||
// @todo Select the ADSL Plan for this product.
|
||||
public function render_edit() {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function render_order() {
|
||||
return View::factory(sprintf('product/plugin/%s/order',$this->plugin()));
|
||||
}
|
||||
|
||||
public function supplier() {
|
||||
return $this->supplier_plan->supplier_id;
|
||||
}
|
||||
|
||||
/** LOCAL FUNCTIONS **/
|
||||
// Local functions
|
||||
|
||||
// Map the table fields
|
||||
private $_map = array(
|
||||
'base_up_offpeak'=>'extra_up_offpeak',
|
||||
'base_down_offpeak'=>'extra_down_offpeak',
|
||||
'base_up_peak'=>'extra_up_peak',
|
||||
'base_down_peak'=>'extra_down_peak',
|
||||
);
|
||||
|
||||
/**
|
||||
* Calculate the allowance array or traffic used array
|
||||
@@ -204,19 +192,5 @@ class Model_Product_Plugin_Adsl extends Model_Product_Plugin {
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the products using this plan
|
||||
*/
|
||||
public function products($active=FALSE) {
|
||||
$x = ORM::factory('Product')
|
||||
->where('prod_plugin_file','=','ADSL')
|
||||
->and_where('prod_plugin_data','=',$this);
|
||||
|
||||
if ($active)
|
||||
$x->where_active();
|
||||
|
||||
return $x;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -15,10 +15,6 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
|
||||
protected $_updated_column = FALSE;
|
||||
|
||||
// Relationships
|
||||
protected $_belongs_to = array(
|
||||
'service'=>array(),
|
||||
);
|
||||
|
||||
protected $_has_one = array(
|
||||
'provided_plan'=>array('model'=>'Product_Plugin_Adsl','far_key'=>'provided_adsl_plan_id','foreign_key'=>'id'),
|
||||
);
|
||||
@@ -36,7 +32,10 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
|
||||
),
|
||||
);
|
||||
|
||||
protected $_save_message = TRUE;
|
||||
|
||||
// Required abstract functions
|
||||
|
||||
public function expire() {
|
||||
// We'll leave it to the Service record to determine when this service expires
|
||||
return NULL;
|
||||
@@ -46,43 +45,15 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
|
||||
return $this->service_number;
|
||||
}
|
||||
|
||||
public function username_value() {
|
||||
return $this->service_username;
|
||||
}
|
||||
|
||||
public function password_value() {
|
||||
public function password() {
|
||||
return $this->service_password;
|
||||
}
|
||||
|
||||
// Override our parent function to include some JS.
|
||||
public function admin_update() {
|
||||
Script::factory()
|
||||
->type('stdin')
|
||||
->data('
|
||||
$(document).ready(function() {
|
||||
$("#service_connect_date_label").datepicker({
|
||||
autoclose : true,
|
||||
startDate : now,
|
||||
format : "dd-M-yyyy",
|
||||
todayBtn : true,
|
||||
}).on("hide",function(ev) {
|
||||
$("input[id=service_connect_date]").val(ev.date.valueOf()/1000);
|
||||
});
|
||||
$("#service_contract_date_label").datepicker({
|
||||
autoclose : true,
|
||||
startDate : now,
|
||||
format : "dd-M-yyyy",
|
||||
todayBtn : true,
|
||||
}).on("hide",function(ev) {
|
||||
$("input[id=service_contract_date]").val(ev.date.valueOf()/1000);
|
||||
});
|
||||
});
|
||||
');
|
||||
|
||||
return parent::admin_update();
|
||||
public function username() {
|
||||
return $this->service_username;
|
||||
}
|
||||
|
||||
/** LOCAL FUNCTIONS **/
|
||||
// Local functions
|
||||
|
||||
/**
|
||||
* If we override the plan that the customers gets (from what the supplier provides).
|
||||
@@ -99,7 +70,8 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
public function contract_date_end($format=FALSE) {
|
||||
$x = strtotime(sprintf('+%s months',$this->contract_term),$this->service_contract_date);
|
||||
// ADSL Contract Terms are held in the ADSL Plan
|
||||
$x = strtotime(sprintf('+%s months',$this->service->plugin()->contract_term),$this->service_contract_date);
|
||||
|
||||
return $format ? Config::date($x) : $x;
|
||||
}
|
||||
@@ -475,6 +447,7 @@ $(document).ready(function() {
|
||||
->where_open()
|
||||
->and_where($this->_table_name.'.service_number','like','%'.$term.'%')
|
||||
->or_where($this->_table_name.'.service_address','like','%'.$term.'%')
|
||||
->or_where($this->_table_name.'.ipaddress','like','%'.$term.'%')
|
||||
->where_close();
|
||||
|
||||
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
|
||||
|
Reference in New Issue
Block a user