Admin service updates for ssl, adsl

This commit is contained in:
Deon George 2013-11-09 15:51:08 +11:00
parent 2d9d7f383c
commit 158a4f9e47
13 changed files with 235 additions and 170 deletions

View File

@ -94,7 +94,7 @@ class Controller_Reseller_Welcome extends Controller_Welcome {
'date_payment'=>'Pay Date',
'account->accnum()'=>'Num',
'account->name()'=>'Account',
'account->status'=>'Active',
'account->display("status")'=>'Active',
'total(TRUE)'=>'Total',
'balance(TRUE)'=>'Balance',
))

View File

@ -32,15 +32,6 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
);
// Required abstract functions
public function admin_update() {
return View::factory('service/admin/adsl/update')
->set('mediapath',Route::get('default/media'))
->set('so',$this);
}
/**
* When does this service expire
*/
public function expire() {
// @todo This should work out if the invoices are currently due, then the expire is the invoice date, otherwise the next invoice date.
return NULL;
@ -50,6 +41,33 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
return $this->service_number;
}
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 product() {
if ($this->provided_adsl_plan_id)
return $this->adsl_plan;

View File

@ -1,46 +0,0 @@
<!-- @todo NEEDS TO BE TRANSLATED -->
<table width="100%">
<tr>
<td class="head" colspan="2">Plugin Details</td>
</tr>
<tr>
<td style="width: 40%;">Service Number</td>
<td style="width: 60%;" class="data"><?php echo Form::input('plugin[service_number]',$so->service_number); ?></td>
</tr>
<tr>
<td>Service Address</td>
<td class="data"><?php echo Form::input('plugin[service_address]',$so->service_address); ?></td>
</tr>
<tr>
<td>Service Connect Date</td>
<td class="data">
<?php echo Form::input('plugin[service_connect_date]',$so->service_connect_date,array('id'=>'service_connect_date')); ?>
<?php echo HTML::anchor('#',
HTML::image($mediapath->uri(array('file'=>'img/calendar.png')),array('alt'=>_('Calendar'),'style'=>'cursor: pointer;')),
array('title'=>'Click to popup a dialog to select a date graphically','onclick'=>"dateSelector('service_connect_date')")); ?>
<script type="text/javascript">defaults['service_connect_date'] = '%s';</script>
</td>
</tr>
<tr>
<td>Service Contract Date</td>
<td class="data">
<?php echo Form::input('plugin[service_contract]',$so->service_contract_date,array('id'=>'service_contract_date')); ?>
<?php echo HTML::anchor('#',
HTML::image($mediapath->uri(array('file'=>'img/calendar.png')),array('alt'=>_('Calendar'),'style'=>'cursor: pointer;')),
array('title'=>'Click to popup a dialog to select a date graphically','onclick'=>"dateSelector('service_contract_date')")); ?>
<script type="text/javascript">defaults['service_contract_date'] = '%s';</script>
</td>
</tr>
<tr>
<td>Service Username</td>
<td class="data"><?php echo Form::input('plugin[service_username]',$so->service_username); ?></td>
</tr>
<tr>
<td>Service Password</td>
<td class="data"><?php echo Form::input('plugin[service_password]',$so->service_password); ?></td>
</tr>
<tr>
<td>Service IP Address</td>
<td class="data"><?php echo Form::input('plugin[ipaddress]',$so->ipaddress); ?></td>
</tr>
</table>

View File

@ -0,0 +1,45 @@
<div class="row">
<div class="span6">
<?php echo Form::input('plugin[service_number]',$o->service_number,array('class'=>'span2','label'=>'Service Number','placeholder'=>'Service Number')); ?>
</div>
</div> <!-- /row -->
<div class="row">
<div class="span6">
<?php echo Form::input('plugin[service_address]',$o->service_address,array('class'=>'span6','label'=>'Service Address','placeholder'=>'Service Address')); ?>
</div>
</div> <!-- /row -->
<div class="row">
<div class="span5 input-append date" id="service_connect_date_label">
<?php echo Form::input('service_connect_date_label',$o->display('service_connect_date'),array('class'=>'span2','label'=>'Service Connected','add-on'=>'<i class="icon-calendar"></i>','disabled')); ?>
</div>
<?php echo Form::hidden('plugin[service_connect_date]',$o->service_connect_date,array('id'=>'service_connect_date')); ?>
</div> <!-- /row -->
<div class="row">
<div class="span5 input-append date" id="service_contract_date_label">
<?php echo Form::input('service_contract_date_label',$o->display('service_contract_date'),array('class'=>'span2','label'=>'Contract Start Date','add-on'=>'<i class="icon-calendar"></i>','disabled')); ?>
</div>
<?php echo Form::hidden('plugin[service_contract_date]',$o->service_contract_date,array('id'=>'service_contract_date')); ?>
</div> <!-- /row -->
<div class="row">
<div class="span6">
<?php echo Form::input('plugin[service_username]',$o->service_username,array('class'=>'span6','label'=>'Service Username','placeholder'=>'Service Username')); ?>
</div>
</div> <!-- /row -->
<div class="row">
<div class="span6">
<?php echo Form::input('plugin[service_password]',$o->service_password,array('class'=>'span6','label'=>'Service Password','placeholder'=>'Service Password')); ?>
</div>
</div> <!-- /row -->
<div class="row">
<div class="span6">
<?php echo Form::input('plugin[ipaddress]',$o->ipaddress,array('class'=>'span6','label'=>'Service IP Address','placeholder'=>'Service IP Address')); ?>
</div>
</div> <!-- /row -->

View File

@ -81,7 +81,7 @@ $(document).ready(function() {
$("#date_charge_label").datepicker({
autoclose : true,
endDate : now,
format : "dd-mm-yyyy",
format : "dd-M-yyyy",
todayBtn : true,
}).on("hide",function(ev) {
$("input[name=date_charge]").val(ev.date.valueOf()/1000);
@ -152,7 +152,7 @@ $(document).ready(function() {
->columns(array(
'id'=>'ID',
'date_charge'=>'Date',
'processed(TRUE)'=>'Processed',
'processed'=>'Processed',
'invoice_item->invoice_id'=>'Invoice',
'sweep_type'=>'Sweep',
'quantity'=>'Quantity',

@ -1 +1 @@
Subproject commit 45cadf09454eede07c4c75238231bed8967a6848
Subproject commit c014a4cec843a37c14cb77b2d453909b8ca6494e

View File

@ -115,50 +115,95 @@ class Controller_Admin_Service extends Controller_Service {
}
public function action_update() {
$id = $this->request->param('id');
list($id,$output) = Table::page(__METHOD__);
$so = ORM::factory('Service',$id);
if (! $so->loaded())
HTTP::redirect('welcome/index');
if ($_POST) {
if (isset($_POST['plugin']) AND $_POST['plugin'])
if (! $so->plugin()->values($_POST['plugin'])->update()->saved())
throw new Kohana_Exception('Failed to save updates to plugin data for record :record',array(':record'=>$so->id()));
// Entry updated
if (isset($_POST['plugin']) AND $_POST['plugin']) {
$p = $so->plugin();
if (! $so->values($_POST)->update()->saved())
throw new Kohana_Exception('Failed to save updates to service data for record :record',array(':record'=>$so->id()));
if ($p->values($_POST['plugin'])->changed() AND $p->check()) {
try {
$p->values($_POST['plugin'])->save();
SystemMessage::factory()
->title('Record PLUGIN updated')
->type('success')
->body(_('Your Charge record has been recorded/updated.'));
} catch (ORM_Validation_Exception $e) {
$errors = $e->errors('models');
SystemMessage::factory()
->title('Record PLUGIN NOT updated')
->type('error')
->body(join('<br/>',array_values($errors)));
$so->reload();
}
}
}
if ($so->values($_POST)->changed() AND $so->check()) {
try {
$so->values($_POST)->save();
SystemMessage::factory()
->title('Record updated')
->type('success')
->body(_('Your Charge record has been recorded/updated.'));
} catch (ORM_Validation_Exception $e) {
$errors = $e->errors('models');
SystemMessage::factory()
->title('Record NOT updated')
->type('error')
->body(join('<br/>',array_values($errors)));
$so->reload();
}
}
}
Block::add(array(
'title'=>sprintf('%s %s:%s',_('Update Service'),$so->id(),$so->name()),
'body'=>View::factory($this->viewpath())
->set('so',$so)
->set('mediapath',Route::get('default/media'))
->set('plugin_form',$so->admin_update()),
));
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('
var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
$(document).ready(function() {
$("#date_next_invoice_label").datepicker({
autoclose : true,
startDate : now,
format : "dd-M-yyyy",
todayBtn : true,
}).on("hide",function(ev) {
$("input[name=date_next_invoicel]").val(ev.date.valueOf()/1000);
});
});
');
Block::factory()
->type('form-horizontal')
->title(sprintf('%s: %s %s',_('Update Service'),$id,$so->name()))
->title_icon('icon-wrench')
->body(View::factory('service/admin/edit')
->set('o',$so)
->set('plugin_form',$so->admin_update())
);
// @todo Investigate a better way of preparing for jscalendar
Script::add(array(
'type'=>'file',
'data'=>'js/dhtml.calendar.js',
));
Script::add(array(
'type'=>'file',
'data'=>'js/dhtml.calendar-setup.js',
));
Script::add(array(
'type'=>'file',
'data'=>'js/dhtml.calendar-en.js',
));
Script::add(array(
'type'=>'file',
'data'=>'js/dhtml.date_selector.js',
));
Style::add(array(
'type'=>'file',
'data'=>'css/dhtml.calendar.css',
));
}
public function action_view() {
@ -173,8 +218,8 @@ class Controller_Admin_Service extends Controller_Service {
$doutput = $loutput = '';
$loutput .= View::factory($this->viewpath())
->set('so',$so);
$loutput .= View::factory('service/admin/view')
->set('o',$so);
// Validate the transactions
$bt = NULL;
@ -241,7 +286,7 @@ class Controller_Admin_Service extends Controller_Service {
));
$output .= View::factory('service/user/view')
->set('so',$so);
->set('o',$so);
Block::add(array(
'title'=>sprintf('%s: %s',$so->id(),$so->service_name()),

View File

@ -13,11 +13,6 @@ 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
*/
@ -46,6 +41,14 @@ abstract class Model_Service_Plugin extends ORM_OSB {
abstract public function username_value();
abstract public function password_value();
/**
* Form info for admins to update
*/
public function admin_update() {
return View::factory(sprintf('service/admin/plugin/%s/edit',$this->plugin()))
->set('o',$this);
}
public function manage_button() {
if (! $this->service->status OR $this->service->expiring())
return FALSE;
@ -76,6 +79,10 @@ function() { $("form[id=id_"+t[0]+"_"+t[1]+"]").submit(); });
return TRUE;
}
protected function plugin() {
return strtolower(preg_replace('/(.*)_([a-zA-Z]+)$/',"$2",get_class($this)));
}
/**
* Get specific service details for use in other modules
* For Example: Invoice

View File

@ -0,0 +1,48 @@
<div class="row">
<div class="span9 offset1">
<fieldset>
<legend>Update Service</legend>
<div class="row">
<div class="span3">
<?php echo StaticList_YesNo::form('status',$o->status,FALSE,array('label'=>'Active','class'=>'span1')); ?>
</div>
</div> <!-- /row -->
<div class="row">
<div class="span5">
<?php echo StaticList_RecurSchedule::form('recure_schedule',$o->recur_schedule,FALSE,array('label'=>'Billing Period','required'));?>
</div>
</div> <!-- /row -->
<div class="row">
<div class="span5 input-append date" id="date_next_invoice_label">
<?php echo Form::input('date_next_invoice_label',$o->display('date_next_invoice'),array('class'=>'span2','label'=>'Date Last Invoice','add-on'=>'<i class="icon-calendar"></i>','disabled')); ?>
</div>
<?php echo Form::hidden('date_next_invoice',$o->date_next_invoice); ?>
</div> <!-- /row -->
<div class="row">
<div class="span3">
<?php echo StaticList_YesNo::form('taxable',$o->taxable,FALSE,array('label'=>'Taxable','class'=>'span1')); ?>
</div>
</div> <!-- /row -->
<div class="row">
<div class="span3">
<?php echo StaticList_YesNo::form('suspend_billing',$o->suspend_billing,FALSE,array('label'=>'Suspend Billing','class'=>'span1')); ?>
</div>
</div> <!-- /row -->
<?php if ($plugin_form) { echo $plugin_form; } ?>
<div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</div>
</fieldset>
</div> <!-- /span -->
</div> <!-- /row -->

View File

@ -1,48 +0,0 @@
<!-- @todo NEEDS TO BE TRANSLATED -->
<?php echo Form::open(); ?>
<table width="100%">
<tr>
<td style="width: 50%; vertical-align: top;">
<table width="100%">
<tr>
<td style="width: 40%;">Service Active</td>
<td style="width: 60%;" class="data"><?php echo StaticList_YesNo::form('status',$so->status); ?></td>
</tr>
<tr>
<td>Queue</td>
<td class="data"><?php echo $so->display('queue'); ?></td>
</tr>
<tr>
<td>Billing Period</td>
<td class="data"><?php echo StaticList_RecurSchedule::form('recure_schedule',$so->product,$so->recur_schedule);?></td>
</tr>
<tr>
<td>Date Last Invoice</td>
<td class="data"><?php echo $so->display('date_last_invoice'); ?></td>
</tr>
<tr>
<td>Date Next Invoice</td>
<td class="data">
<?php echo Form::input('date_next_invoice',$so->date_next_invoice,array('id'=>'date_next_invoice')); ?>
<?php echo HTML::anchor('#',
HTML::image($mediapath->uri(array('file'=>'img/calendar.png')),array('alt'=>_('Calendar'),'style'=>'cursor: pointer;')),
array('title'=>'Click to popup a dialog to select a date graphically','onclick'=>"dateSelector('date_next_invoice')")); ?>
<script type="text/javascript">defaults['date_next_invoice'] = '%s';</script>
</td>
</tr>
<tr>
<td>Taxable</td>
<td class="data"><?php echo StaticList_YesNo::form('taxable',$so->taxable); ?></td>
</tr>
<tr>
<td>Suspend Billing</td>
<td class="data"><?php echo StaticList_YesNo::form('suspend_billing',$so->suspend_billing); ?></td>
</tr>
</table>
<?php if ($plugin_form) { echo '<br/>'.$plugin_form; } ?>
<!-- END Service Information -->
</td>
</tr>
</table>
<?php echo Form::submit('submit',_('Update'),array('class'=>'form_button')); ?>
<?php echo Form::close(); ?>

View File

@ -104,13 +104,6 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
}
}
// @todo This needs to be validated for this model
public function admin_update() {
return View::factory('service/admin/plugin/ssl/update')
->set('mediapath',Route::get('default/media'))
->set('o',$this);
}
public function download_button() {
if (! $this->service->status OR ! preg_match('/client/',$this->service->product->plugin()->extensions) OR $this->valid_to() < time())
return '';

View File

@ -0,0 +1,17 @@
<div class="row">
<div class="span6">
<?php echo Form::textarea('plugin[csr]',$o->service->plugin()->csr,array('class'=>'span6','label'=>'CSR','placeholder'=>'CSR','nowysihtml'=>TRUE,'style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->csr))); ?>
</div>
</div> <!-- /row -->
<div class="row">
<div class="span6">
<?php echo Form::textarea('plugin[pk]',$o->service->plugin()->pk,array('class'=>'span6','label'=>'Private Key','placeholder'=>'Private Key','nowysihtml'=>TRUE,'style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->pk))); ?>
</div>
</div> <!-- /row -->
<div class="row">
<div class="span6">
<?php echo Form::textarea('plugin[cert]',$o->service->plugin()->cert,array('class'=>'span6','label'=>'Public Certificate','placeholder'=>'Public Certificate','nowysihtml'=>TRUE,'style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->cert))); ?>
</div>
</div> <!-- /row -->

View File

@ -1,14 +0,0 @@
<table border="0">
<tr>
<td style="width: 40%;">CSR</td>
<td style="width: 60%;"><?php echo FORM::textarea('plugin[csr]',$so->service->plugin()->csr,array('cols'=>64,'rows'=>13,'nowysihtml'=>TRUE)); ?></td>
</td>
<tr>
<td>PK</td>
<td><?php echo FORM::textarea('plugin[pk]',$so->service->plugin()->pk,array('cols'=>64,'rows'=>13,'nowysihtml'=>TRUE)); ?></td>
</td>
<tr>
<td>Cert</td>
<td><?php echo FORM::textarea('plugin[cert]',$so->service->plugin()->cert,array('cols'=>64,'rows'=>13,'nowysihtml'=>TRUE)); ?></td>
</td>
</table>