Admin service updates for ssl, adsl
This commit is contained in:
@@ -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()),
|
||||
|
Reference in New Issue
Block a user