Work on Email and other major consistency work

This commit is contained in:
Deon George
2013-11-22 15:36:50 +11:00
parent 89deb9c97b
commit c18d5a3881
55 changed files with 550 additions and 575 deletions

View File

@@ -127,46 +127,12 @@ class Controller_Admin_Service extends Controller_Service {
if (isset($_POST['plugin']) AND $_POST['plugin']) {
$p = $so->plugin();
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 ($p->values($_POST['plugin'])->changed() AND ! $this->save($p))
$p->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();
}
}
if ($so->values($_POST)->changed() AND ! $this->save($so))
$so->reload();
}
Script::factory()
@@ -211,10 +177,8 @@ $(document).ready(function() {
$so = ORM::factory('Service',$id);
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account)) {
$this->template->content = 'Unauthorised or doesnt exist?';
return FALSE;
}
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account))
throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it');
$doutput = $loutput = '';

View File

@@ -91,6 +91,12 @@ class Model_Service extends ORM_OSB {
return $format ? Currency::display($total) : $total;
}
public function email() {
return ORM::factory('Email_Log')
->where('module_id','=',$this->mid())
->where('module_data','=',$this);
}
/**
* When does this service expire
*/

View File

@@ -109,3 +109,24 @@
</fieldset>
</div> <!-- /row -->
<?php endif ?>
<?php $x=$o->email()->find_all(); if ($x->count()) : ?>
<div class="row">
<fieldset class="span5">
<legend>Emails about this service</legend>
<?php echo Table::factory()
->data($x)
->columns(array(
'id'=>'ID',
'date_orig'=>'Date',
'resolve("subject")'=>'Subject',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','email/view/')),
))
->postproc(array(
'resolve("subject")'=>array('trim'=>45),
)); ?>
</fieldset>
</div> <!-- /row -->
<?php endif ?>