Added User email viewing
Improved Table::
This commit is contained in:
@@ -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');
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -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');
|
||||
|
@@ -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,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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>
|
@@ -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"> </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>
|
Reference in New Issue
Block a user