Added User email viewing

Improved Table::
This commit is contained in:
Deon George
2011-08-27 16:33:46 +10:00
parent 495da41e0d
commit 6d44e7d5b2
51 changed files with 701 additions and 273 deletions

View File

@@ -93,7 +93,7 @@ class Controller_User_Account extends Controller_TemplateDefault_User {
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Account Edit'),$this->ao->accnum(),$this->ao->name(TRUE)),
'body'=>View::factory('account/edit')
'body'=>View::factory('account/user/edit')
->set('record',$this->ao),
));
}

View File

@@ -12,6 +12,7 @@ class Model_Account extends Model_Auth_UserDefault {
// Relationships
protected $_has_many = array(
'user_tokens' => array('model' => 'user_token'),
'email_log' => array('far_key'=>'id'),
'group' => array('through' => 'account_group'),
'invoice' => array('far_key'=>'id'),
'payment'=>array('far_key'=>'id'),

View File

@@ -12,11 +12,38 @@
*/
class Controller_Admin_Email extends Controller_TemplateDefault_Admin {
protected $secure_actions = array(
'list'=>TRUE,
'templateadd'=>TRUE,
'templateedit'=>TRUE,
'templatelist'=>TRUE,
);
/**
* Show a list of emails
*/
public function action_list() {
$elo = ORM::factory('email_log');
Block::add(array(
'title'=>_('System Emails Sent'),
'body'=>Table::display(
$elo->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/email/view/'),
'date_orig'=>array('label'=>'Date'),
'translate_resolve("subject")'=>array('label'=>'Subject'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/email/view',
)),
));
}
/**
* List our defined email templates
*/

View File

@@ -0,0 +1,70 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides User Email View functions
*
* @package OSB
* @subpackage Email
* @category Controllers/User
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Controller_User_Email extends Controller_TemplateDefault_User {
protected $secure_actions = array(
'list'=>TRUE,
'view'=>TRUE,
);
/**
* Show a list of emails
*/
public function action_list() {
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Email For'),$this->ao->accnum(),$this->ao->name(TRUE)),
'body'=>Table::display(
$this->ao->email_log->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/email/view/'),
'date_orig'=>array('label'=>'Date'),
'translate_resolve("subject")'=>array('label'=>'Subject'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/email/view',
)),
));
}
public function action_view() {
$output = '';
if (! $id = $this->request->param('id')) {
if (isset($_POST['id']) AND is_array($_POST['id']))
Table::post('email_view','id');
list($id,$output) = Table::page('email_view');
} else {
$id = $this->request->param('id');
}
$elo = ORM::factory('email_log',$id);
if (! $elo->loaded() OR ! Auth::instance()->authorised($elo->account_id)) {
$this->template->content = 'Unauthorised or doesnt exist?';
return FALSE;
}
$output .= View::factory('email/user/view')
->set('elo',$elo);
Block::add(array(
'title'=>sprintf('%s: %s',_('Email'),$elo->translate_resolve('subject')),
'body'=>$output,
));
}
}
?>

View File

@@ -13,7 +13,7 @@
class Email_Template {
// We'll store the template here
private $template;
private $template_mail;
private $etto;
private $email_data = array();
private $default_lang = 'en';
private $components = array('subject','message_text','message_html');
@@ -27,9 +27,9 @@ class Email_Template {
if (is_null($language_id))
$language_id=$this->default_lang;
$this->template_mail = $this->template->email_template_translate->where('language_id','=',$language_id)->find();
if (! $this->template_mail->loaded() AND
($this->template_mail = $this->template->email_template_translate->where('language_id','=',$this->default_lang)->find()) AND ! $this->template_mail->loaded())
$this->etto = $this->template->email_template_translate->where('language_id','=',$language_id)->find();
if (! $this->etto->loaded() AND
($this->etto = $this->template->email_template_translate->where('language_id','=',$this->default_lang)->find()) AND ! $this->etto->loaded())
// @todo Change this to log/email the admin
throw new Kohana_Exception('No template (:template) found for user language (:language_id) or default language (:default_lang)',
@@ -97,23 +97,20 @@ class Email_Template {
$return = array();
foreach ($this->components as $v)
foreach ($this->template_mail->variables($v) as $x=>$y)
foreach ($this->etto->variables($v) as $x => $y)
if (! in_array($y,$return))
array_push($return,$y);
return $return;
}
public function send($admin=FALSE) {
public function send(array $admin=array()) {
$e = Email::connect();
$sm = Swift_Message::newInstance()
->setFrom(Kohana::config('config.email_from'));
foreach ($this->components as $component) {
$s = $this->template_mail->$component;
foreach ($this->template_mail->variables($component) as $k => $v)
$s = str_replace('%'.$v.'%',$this->email_data['variables'][$v],$s);
$s = $this->etto->resolve($this->email_data['variables'],$component);
switch ($component) {
case 'message_html':
@@ -131,7 +128,6 @@ class Email_Template {
}
}
// @todo This should go to the admin defined in email_setup
if ($admin OR ($admin = Config::testmail($this->template->name))) {
$sm->setTo($admin);
$sa = array(1);
@@ -153,7 +149,7 @@ class Email_Template {
$elo->clear();
$elo->account_id = $id;
$elo->email_template_id = $this->template_mail->id;
$elo->email_template_translate_id = $this->etto->id;
$elo->data = $data;
$elo->save();
}

View File

@@ -11,10 +11,26 @@
* @license http://dev.osbill.net/license.html
*/
class Model_Email_Log extends ORMOSB {
protected $_belongs_to = array(
'account'=>array('far_key'=>'id'),
'email_template_translate'=>array('far_key'=>'id'),
);
protected $_sorting = array(
'id'=>'DESC',
);
protected $_display_filters = array(
'date_orig'=>array(
array('Config::datetime',array(':value')),
),
);
public function translate_resolve($column) {
if (! $this->data OR ! ($r = $this->email_template_translate->variables($column)))
return $this->email_template_translate->display($column);
else
return $this->email_template_translate->resolve(unserialize(gzuncompress($this->data)),$column);
}
}
?>

View File

@@ -28,5 +28,14 @@ class Model_Email_Template_Translate extends ORMOSB {
return $results;
}
public function resolve($data,$column) {
$output = $this->display($column);
foreach ($this->variables($column) as $k => $v)
$output = str_replace('%'.$v.'%',$data[$v],$output);
return $output;
}
}
?>

View File

@@ -0,0 +1,20 @@
<table width="100%">
<tr>
<td>To:</td><td class="data"><?php printf('%s (%s)',$elo->account->name(),$elo->account->display('email')); ?></td>
</tr>
<tr>
<td>Date:</td><td class="data"><?php echo $elo->display('date_orig'); ?></td>
</tr>
<tr>
<td>Subject:</td><td class="data"><?php echo $elo->translate_resolve('subject'); ?></td>
</tr>
<tr>
<td style="width: 100%;" colspan="2">
<table class="box-full">
<tr>
<td><?php echo $elo->translate_resolve('message_html'); ?></td>
</tr>
</table>
</td>
</tr>
</table>

View File

@@ -1,28 +0,0 @@
<?php
echo '<b>'.__FILE__.'</b><br/>';
echo Form::open();
echo Form::select('plugin',$plugins);
echo '<table>';
echo '<tr>';
printf('<td class="heading">%s</td>','Date');
printf('<td class="heading">%s</td>','Invoice');
printf('<td class="heading">%s</td>','Customer');
printf('<td class="heading">%s</td>','Method');
printf('<td class="heading">%s</td>','Export');
echo '</tr>';
$c = 0;
foreach ($invoices as $invoice) {
printf('<tr class="%s">',(++$c%2==0?'even':'odd'));
printf('<td>%s</td><td>%s</td><td>%s %s (%s)</td><td>%s [%s/%s]</td><td><input type="checkbox" name="invoiceid[]" value="%s" /></td>',
$invoice->date_orig,$invoice->id,
$invoice->account->first_name,$invoice->account->last_name,$invoice->account->company,'paymentmethod',$invoice->total_amt,$invoice->due_date,
$invoice->id);
echo '</tr>';
}
echo '</table>';
echo Form::close();
echo '<PRE>';print_r($invoice);
?>

View File

@@ -11,6 +11,39 @@
* @license http://dev.osbill.net/license.html
*/
class Controller_Admin_Invoice extends Controller_TemplateDefault_Admin {
protected $secure_actions = array(
'list'=>TRUE,
);
/**
* Show a list of invoices
*/
public function action_list() {
$io = ORM::factory('invoice');
Block::add(array(
'title'=>_('System Customer Invoices'),
'body'=>Table::display(
$io->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/invoice/view/'),
'date_orig'=>array('label'=>'Date'),
'total_amt'=>array('label'=>'Total','class'=>'right'),
'credit_amt'=>array('label'=>'Credits','class'=>'right'),
'billed_amt'=>array('label'=>'Payments','class'=>'right'),
'due(TRUE)'=>array('label'=>'Still Due','class'=>'right'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/invoice/view',
)),
));
}
public function action_convert() {
if (Config::sitemode() != KOHANA::DEVELOPMENT)
throw new Kohana_Exception(__METHOD__.' can only be run in development');

View File

@@ -11,11 +11,5 @@
* @license http://dev.osbill.net/license.html
*/
class Controller_Invoice extends Controller_TemplateDefault {
public function action_display() {
// @todo - this should be a global config item
$mediapath = Route::get('default/media');
$this->template->content = Kohana::debug(func_get_args());
}
}
?>

View File

@@ -19,7 +19,7 @@ class Controller_Task_Invoice extends Controller_Task {
throw new Kohana_Exception('Unknown Task List command :command',array(':command'=>$mode));
$total = $numinv = 0;
$duelist = View::factory('invoice/task/'.$tm.'_header');
$duelist = View::factory('invoice/task/'.$tm.'_head');
foreach ($io->$tm() as $t) {
$duelist .= View::factory('invoice/task/'.$tm.'_body')
->set('io',$t);
@@ -27,7 +27,7 @@ class Controller_Task_Invoice extends Controller_Task {
$numinv++;
$total += $t->due();
}
$duelist .= View::factory('invoice/task/'.$tm.'_footer');
$duelist .= View::factory('invoice/task/'.$tm.'_foot');
// Send our email
$et = Email_Template::instance('task_invoice_overdue');

View File

@@ -18,20 +18,46 @@ class Controller_User_Invoice extends Controller_TemplateDefault_User {
);
/**
* Show a product
* Show a list of invoices
*/
public function action_list() {
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Invoices For'),$this->ao->accnum(),$this->ao->name(TRUE)),
'body'=>View::factory('invoice/user/list')
->set('invoices',$this->ao->invoice->find_all()),
'body'=>Table::display(
$this->ao->invoice->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/invoice/view/'),
'date_orig'=>array('label'=>'Date'),
'total_amt'=>array('label'=>'Total','class'=>'right'),
'credit_amt'=>array('label'=>'Credits','class'=>'right'),
'billed_amt'=>array('label'=>'Payments','class'=>'right'),
'due(TRUE)'=>array('label'=>'Still Due','class'=>'right'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/invoice/view',
)),
));
}
/**
* View an Invoice
*/
public function action_view($id) {
public function action_view() {
$output = '';
if (! $id = $this->request->param('id')) {
if (isset($_POST['id']) AND is_array($_POST['id']))
Table::post('invoice_view','id');
list($id,$output) = Table::page('invoice_view');
} else {
$id = $this->request->param('id');
}
$io = ORM::factory('invoice',$id);
if (! $io->loaded() OR ! Auth::instance()->authorised($io->account_id)) {
@@ -39,10 +65,14 @@ class Controller_User_Invoice extends Controller_TemplateDefault_User {
return FALSE;
}
// @todo media path probably should be a config item
$this->template->content = View::factory('invoice/user/html')
$output .= View::factory('invoice/user/view')
->set('mediapath',Route::get('default/media'))
->set('invoice',$io);
->set('io',$io);
Block::add(array(
'title'=>sprintf('%s: %s',_('Invoice'),$io->refnum()),
'body'=>$output,
));
}
/**

View File

@@ -1,23 +0,0 @@
<!-- @todo NEEDS TO BE TRANSLATED -->
<table class="box-left">
<tr>
<td class="head">ID</td>
<td class="head">Date</td>
<td class="head">Total</td>
<td class="head">Credits</td>
<td class="head">Payments</td>
<td class="head">Due</td>
<td class="head">Active</td>
</tr>
<?php $i = 0; foreach ($invoices as $invoice) { ?>
<tr class="<?php echo ++$i%2 ? 'odd' : 'even'; ?>">
<td><?php echo HTML::anchor('/user/invoice/view/'.$invoice->id,$invoice->id()); ?></td>
<td><?php echo $invoice->display('date_orig'); ?></td>
<td class="number"><?php echo $invoice->display('total_amt'); ?></td>
<td class="number"><?php echo $invoice->display('credit_amt'); ?></td>
<td class="number"><?php echo $invoice->display('billed_amt'); ?></td>
<td style="font-weight: <?php echo $invoice->due() ? 'bold' : 'normal'; ?>"><?php echo Currency::display($invoice->due()); ?></td>
<td><?php echo $invoice->display('status'); ?></td>
</tr>
<?php } ?>
</table>

View File

@@ -14,27 +14,27 @@
<table class="invoice_summary" border="0">
<tr>
<td>TAX INVOICE</td>
<td class="bold-right"><?php echo $invoice->id(); ?></td>
<td class="bold-right"><?php echo $io->id(); ?></td>
</tr>
<tr>
<td>Issue Date</td>
<td class="bold-right"><?php echo $invoice->display('date_orig'); ?></td>
<td class="bold-right"><?php echo $io->display('date_orig'); ?></td>
</tr>
<tr>
<td>Due Date</td>
<td class="bold-right"><?php echo $invoice->display('due_date'); ?></td>
<td class="bold-right"><?php echo $io->display('due_date'); ?></td>
</tr>
<tr>
<td>Current Charges Due</td>
<td class="bold-right"><?php echo $invoice->display('total_amt'); ?></td>
<td class="bold-right"><?php echo $io->display('total_amt'); ?></td>
</tr>
<tr>
<td>Payments Received to Date</td>
<td class="bold-right"><?php echo $invoice->display('billed_amt'); ?></td>
<td class="bold-right"><?php echo $io->display('billed_amt'); ?></td>
</tr>
<tr>
<td>Total Charges Due</td>
<td class="bold-right"><?php echo $invoice->due(TRUE); ?></td>
<td class="bold-right"><?php echo $io->due(TRUE); ?></td>
</tr>
</table>
</td>
@@ -46,7 +46,7 @@
<tr>
<td class="head" colspan="4">Charges Detail:</td>
</tr>
<?php foreach ($invoice->sorted_service_items('recur_schedule') as $cat => $catitems) { ?>
<?php foreach ($io->sorted_service_items('recur_schedule') as $cat => $catitems) { ?>
<?php if ($cat) { ?>
<tr>
<td><div id="toggle_<?php echo $cat; ?>"><?php echo HTML::image($mediapath->uri(array('file'=>'img/toggle-closed.png')),array('alt'=>'+')); ?></div><script type="text/javascript">$("#toggle_<?php echo $cat; ?>").click(function() {$('#detail_toggle_<?php echo $cat; ?>').toggle();});</script></td>
@@ -71,7 +71,7 @@
<tr class="head">
<td><?php echo HTML::anchor('/user/service/view/'.$item->service->id,$item->service->id()); ?></td>
<td colspan="3"><?php echo $item->product->product_translate->find()->name; ?> (<?php echo $item->product_id; ?>)</td>
<td class="right"><?php echo Currency::display($invoice->items_service_total($item->service_id));?></td>
<td class="right"><?php echo Currency::display($io->items_service_total($item->service_id));?></td>
</tr>
<!-- End Product Information -->
@@ -86,7 +86,7 @@
<!-- Product Sub Items -->
<?php
foreach ($invoice->items_sub($item->service_id) as $subitem) {
foreach ($io->items_sub($item->service_id) as $subitem) {
if (! is_null($subitem->module_id)) {
$m = StaticList_Module::record('module','name','id',$subitem->module_id);
// @todo Need to remove the explicit test for 'charge' and be more dynamic
@@ -109,14 +109,14 @@
<tr>
<td colspan="2">&nbsp;</td>
<td><?php echo _('Taxes'); ?></td>
<td class="right"><?php echo Currency::display($invoice->items_service_tax($item->service_id));?></td>
<td class="right"><?php echo Currency::display($io->items_service_tax($item->service_id));?></td>
</tr>
<!-- Product End Sub Items Tax -->
<?php } ?>
<?php } else { ?>
<!-- Product Sub Items -->
<?php
foreach ($invoice->items_sub(NULL) as $subitem) {
foreach ($io->items_sub(NULL) as $subitem) {
if (! is_null($subitem->module_id)) {
$m = StaticList_Module::record('module','name','id',$subitem->module_id);
// @todo Need to remove the explicit test for 'charge' and be more dynamic
@@ -142,13 +142,13 @@
<?php } ?>
<tr>
<td class="head" colspan="2">Sub Total:</td>
<td class="bold-right"><?php echo $invoice->subtotal(TRUE); ?></td>
<td class="bold-right"><?php echo $io->subtotal(TRUE); ?></td>
</tr>
<tr>
<td class="head" colspan="4">Taxes Included:</td>
</tr>
<?php
foreach ($invoice->tax_summary() as $tid => $amount) {
foreach ($io->tax_summary() as $tid => $amount) {
$m = ORM::factory('tax',$tid);
?>
<tr>
@@ -160,12 +160,12 @@
<!-- @todo Add discounts -->
<tr>
<td class="head" colspan="3">Total:</td>
<td class="bold-right"><?php echo $invoice->total(TRUE); ?></td>
<td class="bold-right"><?php echo $io->total(TRUE); ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><?php echo HTML::anchor('user/invoice/download/'.$invoice->id,'Download detailed invoice'); ?></td>
<td><?php echo HTML::anchor('user/invoice/download/'.$io->id,'Download detailed invoice'); ?></td>
</tr>
</table>

View File

@@ -12,6 +12,7 @@
*/
class Controller_Admin_Module extends Controller_TemplateDefault_Admin {
protected $secure_actions = array(
'add'=>TRUE,
'edit'=>TRUE,
'list'=>TRUE,
);
@@ -47,30 +48,32 @@ class Controller_Admin_Module extends Controller_TemplateDefault_Admin {
* List our installed modules
*/
public function action_list() {
$modules = ORM::factory('module');
$output = '';
$output .= View::factory('module/admin/list_header');
foreach ($modules->find_all() as $mo) {
$output .= View::factory('module/admin/list_body')
->set('module',$mo);
}
$output .= View::factory('module/admin/list_footer');
$mo = ORM::factory('module');
Block::add(array(
'title'=>_('Currently installed modules'),
'body'=>$output,
));
'title'=>sprintf('%s: %s - %s',_('Email For'),$this->ao->accnum(),$this->ao->name(TRUE)),
'body'=>Table::display(
$mo->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'admin/module/edit/'),
'name'=>array('label'=>'Name'),
'status'=>array('label'=>'Active'),
),
array(
'page'=>TRUE,
'type'=>'list',
)),
));
}
/**
* Edit a Module Configuration
*
* @param int $mid Module ID
* @todo Highlight those methods that have security, but the class does not have auth_required set to YES or the method isnt defined in secure_actions
*/
public function action_edit($mid) {
public function action_edit() {
$mid = $this->request->param('id');
$mo = ORM::factory('module',$mid);
if (! $mo->loaded()) {
@@ -87,35 +90,42 @@ class Controller_Admin_Module extends Controller_TemplateDefault_Admin {
$methods = $this->_methods($mo->name);
// Show methods defined in the DB already.
$output .= View::factory('module/admin/method_list_header');
foreach ($mo->module_method->find_all() as $meo) {
Block::add(array(
'title'=>sprintf('%s: %s ',_('Defined Module Methods For'),$mo->display('name')),
'body'=>Table::display(
$mo->module_method->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'admin/module_method/edit/'),
'name'=>array('label'=>'Name'),
'notes'=>array('label'=>'Notes'),
'menu_display'=>array('label'=>'Menu'),
),
array(
'page'=>TRUE,
'type'=>'list',
)),
));
// Show new methods NOT defined in the DB already.
foreach ($mo->module_method->find_all() as $meo)
if (($method = array_search($meo->name,$methods)) !== false)
unset($methods[$method]);
$output .= View::factory('module/admin/method_list_body')
->set('method',$meo)
->set('module',$mo)
->set('defined',$method !== false);
}
$output .= View::factory('module/admin/method_list_spacer');
// Show new methods NOT defined in the DB already.
foreach ($methods as $method) {
$meo = ORM::factory('module_method')
->values(array('name'=>$method,'notes'=>_('Not defined in DB')));
$output .= View::factory('module/admin/method_list_body')
->set('method',$meo)
->set('module',$mo)
->set('defined',$method === false);
}
$output .= View::factory('module/admin/method_list_footer');
Block::add(array(
'title'=>sprintf(_('%s Methods'),strtoupper($mo->name)),
'body'=>$output,
));
if (count($methods))
Block::add(array(
'title'=>sprintf('%s: %s ',_('Undefined Module Methods For'),$mo->display('name')),
'body'=>Table::display(
$methods,
25,
array(
'__VALUE__'=>array('label'=>'Name','url'=>sprintf('admin/module_method/add/%s/',$mo->id)),
),
array(
'page'=>TRUE,
'type'=>'list',
)),
));
}
}
?>

View File

@@ -10,7 +10,7 @@
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Controller_Admin_Module_Method extends Controller_Module {
class Controller_Admin_Module_Method extends Controller_Admin_Module {
/**
* Add a method to the database
*/
@@ -63,7 +63,8 @@ class Controller_Admin_Module_Method extends Controller_Module {
*
* @param int $mid Module ID
*/
public function action_edit($mid) {
public function action_edit() {
$mid = $this->request->param('id');
$mmo = ORM::factory('module_method',$mid);
if (! $mmo->loaded()) {
@@ -114,13 +115,13 @@ class Controller_Admin_Module_Method extends Controller_Module {
$output .= Form::open();
$output .= View::factory('module/admin/method_detail_header');
$output .= View::factory('module/admin/method_detail_head');
foreach ($groups->find_all() as $go) {
$output .= View::factory('module/admin/method_detail_body')
->set('group',$go)
->set('defined',$mmo->has('group',$go));
}
$output .= View::factory('module/admin/method_detail_footer');
$output .= View::factory('module/admin/method_detail_foot');
$output .= '<div>'.Form::submit('submit',_('Update')).'</div>';
$output .= Form::close();

View File

@@ -1,4 +0,0 @@
<tr>
<td><a href="<?php echo URL::site(sprintf('/admin/module/edit/%s',$module->id)); ?>" alt=""><?php echo $module->name; ?></a></td>
<td><?php echo $module->display('status'); ?></td>
</tr>

View File

@@ -1,6 +0,0 @@
<!-- //@todo Translation required -->
<table class="box-left">
<tr class="head">
<td>Module</td>
<td>Active</td>
</tr>

View File

@@ -1,11 +0,0 @@
<tr>
<td>
<?php if ($defined) { ?>
<a href="<?php echo URL::site(sprintf('/admin/module_method/edit/%s',$method->id)); ?>" alt=""><?php echo $method->name; ?></a>
<?php } else { ?>
<a href="<?php echo URL::site(sprintf('/admin/module_method/add/%s/%s',$module->id,$method->name)); ?>" alt=""><?php echo $method->name; ?></a>
<?php } ?>
</td>
<td><?php echo $method->display('notes'); ?></td>
<td><?php echo $method->display('menu_display'); ?></td>
</tr>

View File

@@ -1 +0,0 @@
</table>

View File

@@ -1,7 +0,0 @@
<!-- //@todo Translation required -->
<table class="box-left">
<tr class="head">
<td>Method</td>
<td>Notes</td>
<td>Menu</td>
</tr>

View File

@@ -1,3 +0,0 @@
<tr class="spacer">
<td>&nbsp;</td>
</tr>

View File

@@ -20,9 +20,22 @@ class Controller_User_Payment extends Controller_TemplateDefault_User {
*/
public function action_list() {
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Payments For'),$this->ao->accnum(),$this->ao->name(TRUE)),
'body'=>View::factory('payment/user/list')
->set('payments',$this->ao->payment->find_all()),
'title'=>sprintf('%s: %s - %s',_('Payments Received For'),$this->ao->accnum(),$this->ao->name(TRUE)),
'body'=>Table::display(
$this->ao->payment->find_all(),
25,
array(
'id'=>array('label'=>'ID'),
'date_payment'=>array('label'=>'Date'),
'checkout->display("name")'=>array('label'=>'Method'),
'total_amt'=>array('label'=>'Total','class'=>'right'),
'balance(TRUE)'=>array('label'=>'Balance','class'=>'right'),
'invoicelist()'=>array('label'=>'Invoices'),
),
array(
'page'=>TRUE,
'type'=>'list',
)),
));
}
}

View File

@@ -1,21 +0,0 @@
<!-- @todo NEEDS TO BE TRANSLATED -->
<table class="box-left">
<tr>
<td class="head">ID</td>
<td class="head">Date</td>
<td class="head">Method</td>
<td class="head">Total</td>
<td class="head">Unallocated</td>
<td class="head">Invoices</td>
</tr>
<?php $i = 0; foreach ($payments as $po) { ?>
<tr class="<?php echo ++$i%2 ? 'odd' : 'even'; ?>">
<td><?php echo $po->id; ?></td>
<td><?php echo $po->display('date_payment'); ?></td>
<td><?php echo $po->checkout->display('name'); ?></td>
<td class="number"><?php echo $po->display('total_amt'); ?></td>
<td class="number"><?php echo $po->balance() ? '<b>'.$po->balance(TRUE).'</b>' : $po->balance(TRUE); ?></td>
<td class="number"><?php echo $po->invoicelist(); ?></td>
</tr>
<?php } ?>
</table>

View File

@@ -14,12 +14,43 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
protected $control = array('Services'=>'services');
protected $secure_actions = array(
'list'=>TRUE,
'listbycheckout'=>TRUE,
'listadslbilling'=>TRUE,
'listadslservices'=>TRUE,
'listhspaservices'=>TRUE,
'update'=>TRUE,
);
/**
* Show a list of services
*/
public function action_list() {
$so = ORM::factory('service');
Block::add(array(
'title'=>_('System Customer Services'),
'body'=>Table::display(
$so->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
'type'=>array('label'=>'Type'),
'name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price'=>array('label'=>'Price','class'=>'right'),
'active'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/email/view',
)),
));
}
/**
* List all services by their default checkout method
*/

View File

@@ -17,17 +17,43 @@ class Controller_User_Service extends Controller_TemplateDefault_User {
);
/**
* Show a product
* Show a list of services
*/
public function action_list() {
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Services For'),$this->ao->accnum(),$this->ao->name(TRUE)),
'body'=>View::factory('service/user/list')
->set('services',$this->ao->service->find_all()),
'body'=>Table::display(
$this->ao->service->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
'type'=>array('label'=>'Type'),
'name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price'=>array('label'=>'Price','class'=>'right'),
'active'=>array('label'=>'Active'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/service/view',
)),
));
}
public function action_view($id) {
public function action_view() {
$output = '';
if (! $id = $this->request->param('id')) {
if (isset($_POST['id']) AND is_array($_POST['id']))
Table::post('service_view','id');
list($id,$output) = Table::page('service_view');
} else {
$id = $this->request->param('id');
}
$so = ORM::factory('service',$id);
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account_id)) {
@@ -35,10 +61,12 @@ class Controller_User_Service extends Controller_TemplateDefault_User {
return FALSE;
}
$output .= View::factory('service/user/view')
->set('so',$so);
Block::add(array(
'title'=>sprintf('%s: %s',$so->id(),$so->product->name()),
'body'=>View::factory('service/user/view')
->set('so',$so),
'body'=>$output,
));
}
}

View File

@@ -1,21 +0,0 @@
<!-- @todo NEEDS TO BE TRANSLATED -->
<table class="box-left">
<tr>
<td class="head">ID</td>
<td class="head">Type</td>
<td class="head">Details</td>
<td class="head">Billing</td>
<td class="head">Price</td>
<td class="head">Active</td>
</tr>
<?php $i = 0; foreach ($services as $service) { ?>
<tr class="<?php echo ++$i%2 ? 'odd' : 'even'; ?>">
<td><?php echo HTML::anchor('user/service/view/'.$service->id,$service->id); ?></td>
<td><?php echo $service->display('type'); ?></td>
<td><?php echo $service->name(); ?></td>
<td><?php echo $service->display('recur_schedule');?></td>
<td><?php echo $service->display('price'); ?></td>
<td><?php echo $service->display('active'); ?></td>
</tr>
<?php } ?>
</table>