Updates to invoice display
This commit is contained in:
parent
c8c4c5176d
commit
41eec89afa
@ -18,7 +18,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
|||||||
// If user already signed-in
|
// If user already signed-in
|
||||||
if (Auth::instance()->logged_in()!= 0) {
|
if (Auth::instance()->logged_in()!= 0) {
|
||||||
// Redirect to the user account
|
// Redirect to the user account
|
||||||
Request::current()->redirect('welcome/index');
|
Request::current()->redirect('user/welcome');
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a post and $_POST is not empty
|
// If there is a post and $_POST is not empty
|
||||||
@ -35,7 +35,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
|||||||
Request::current()->redirect($redir);
|
Request::current()->redirect($redir);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
Request::current()->redirect('welcome/index');
|
Request::current()->redirect('user/welcome');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
||||||
|
25
application/classes/controller/user/welcome.php
Normal file
25
application/classes/controller/user/welcome.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lnApp Main home page
|
||||||
|
*
|
||||||
|
* @package lnApp
|
||||||
|
* @subpackage Page/Home
|
||||||
|
* @category Controllers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
class Controller_User_Welcome extends Controller_TemplateDefault {
|
||||||
|
protected $auth_required = TRUE;
|
||||||
|
|
||||||
|
public function action_index() {
|
||||||
|
$ao = ORM::factory('account',Auth::instance()->get_user()->id);
|
||||||
|
|
||||||
|
Block::add(array(
|
||||||
|
'title'=>sprintf('%s: %s %s',$ao->accnum(),$ao->first_name,$ao->last_name),
|
||||||
|
'body'=>'Please select from the tree on the left',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -14,7 +14,7 @@ class Model_Account extends Model_Auth_UserDefault {
|
|||||||
'user_tokens' => array('model' => 'user_token'),
|
'user_tokens' => array('model' => 'user_token'),
|
||||||
'group' => array('through' => 'account_group'),
|
'group' => array('through' => 'account_group'),
|
||||||
'invoice' => array('far_key'=>'id'),
|
'invoice' => array('far_key'=>'id'),
|
||||||
'payment'=>array(),
|
'payment'=>array('far_key'=>'id'),
|
||||||
'service' => array('far_key'=>'id'),
|
'service' => array('far_key'=>'id'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -12,8 +12,9 @@
|
|||||||
*/
|
*/
|
||||||
class Controller_User_Invoice extends Controller_TemplateDefault {
|
class Controller_User_Invoice extends Controller_TemplateDefault {
|
||||||
public $secure_actions = array(
|
public $secure_actions = array(
|
||||||
|
'download'=>TRUE,
|
||||||
'list'=>TRUE,
|
'list'=>TRUE,
|
||||||
'view'=>FALSE,
|
'view'=>TRUE,
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,7 +29,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault {
|
|||||||
|
|
||||||
Block::add(array(
|
Block::add(array(
|
||||||
'title'=>sprintf('%s: %s - %s',_('Invoices For'),$ao->accnum(),$ao->name(TRUE)),
|
'title'=>sprintf('%s: %s - %s',_('Invoices For'),$ao->accnum(),$ao->name(TRUE)),
|
||||||
'body'=>View::factory('invoice/list')
|
'body'=>View::factory('invoice/user/list')
|
||||||
->set('invoices',$ao->invoice->find_all()),
|
->set('invoices',$ao->invoice->find_all()),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -45,7 +46,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @todo media path probably should be a config item
|
// @todo media path probably should be a config item
|
||||||
$this->template->content = View::factory('invoice/html')
|
$this->template->content = View::factory('invoice/user/html')
|
||||||
->set('mediapath',Route::get('default/media'))
|
->set('mediapath',Route::get('default/media'))
|
||||||
->set('invoice',$io);
|
->set('invoice',$io);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,10 @@ class Model_Invoice extends ORMOSB {
|
|||||||
'payment'=>array('through'=>'payment_item'),
|
'payment'=>array('through'=>'payment_item'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
protected $_sorting = array(
|
||||||
|
'id'=>'DESC',
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array Filters to render values properly
|
* @var array Filters to render values properly
|
||||||
*/
|
*/
|
||||||
|
@ -112,7 +112,7 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="head" colspan="2">Sub Total:</td>
|
<td class="head" colspan="2">Sub Total:</td>
|
||||||
<td class="bold-right"><?echo $invoice->subtotal(TRUE); ?></td>
|
<td class="bold-right"><?php echo $invoice->subtotal(TRUE); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="head" colspan="4">Taxes Included:</td>
|
<td class="head" colspan="4">Taxes Included:</td>
|
||||||
@ -130,9 +130,12 @@
|
|||||||
<!-- @todo Add discounts -->
|
<!-- @todo Add discounts -->
|
||||||
<tr>
|
<tr>
|
||||||
<td class="head" colspan="3">Total:</td>
|
<td class="head" colspan="3">Total:</td>
|
||||||
<td class="bold-right"><?echo $invoice->total(TRUE); ?></td>
|
<td class="bold-right"><?php echo $invoice->total(TRUE); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo HTML::anchor('user/invoice/download/'.$invoice->id,'Download detailed invoice'); ?></td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
@ -2,6 +2,7 @@
|
|||||||
<table class="box-left">
|
<table class="box-left">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="head">ID</td>
|
<td class="head">ID</td>
|
||||||
|
<td class="head">Date</td>
|
||||||
<td class="head">Total</td>
|
<td class="head">Total</td>
|
||||||
<td class="head">Credits</td>
|
<td class="head">Credits</td>
|
||||||
<td class="head">Payments</td>
|
<td class="head">Payments</td>
|
||||||
@ -11,8 +12,9 @@
|
|||||||
<?php $i = 0; foreach ($invoices as $invoice) { ?>
|
<?php $i = 0; foreach ($invoices as $invoice) { ?>
|
||||||
<tr class="<?php echo ++$i%2 ? 'odd' : 'even'; ?>">
|
<tr class="<?php echo ++$i%2 ? 'odd' : 'even'; ?>">
|
||||||
<td><?php echo HTML::anchor('/user/invoice/view/'.$invoice->id,$invoice->id()); ?></td>
|
<td><?php echo HTML::anchor('/user/invoice/view/'.$invoice->id,$invoice->id()); ?></td>
|
||||||
<td><?php echo $invoice->display('total_amt'); ?></td>
|
<td><?php echo $invoice->display('date_orig'); ?></td>
|
||||||
<td><?php echo $invoice->display('credit_amt'); ?></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 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 style="font-weight: <?php echo $invoice->due() ? 'bold' : 'normal'; ?>"><?php echo Currency::display($invoice->due()); ?></td>
|
||||||
<td><?php echo $invoice->display('status'); ?></td>
|
<td><?php echo $invoice->display('status'); ?></td>
|
36
modules/payment/classes/controller/user/payment.php
Normal file
36
modules/payment/classes/controller/user/payment.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides User Payment functions
|
||||||
|
*
|
||||||
|
* @package OSB
|
||||||
|
* @subpackage Payment
|
||||||
|
* @category Controllers/User
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
class Controller_User_Payment extends Controller_TemplateDefault {
|
||||||
|
public $secure_actions = array(
|
||||||
|
'list'=>TRUE,
|
||||||
|
'view'=>TRUE,
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a payments received
|
||||||
|
*/
|
||||||
|
public function action_list() {
|
||||||
|
$id = Auth::instance()->get_user()->id;
|
||||||
|
$ao = ORM::factory('account',$id);
|
||||||
|
|
||||||
|
if (! $ao->loaded())
|
||||||
|
throw new Kohana_Exception('Account doesnt exist :account ?',array(':account'=>$id));
|
||||||
|
|
||||||
|
Block::add(array(
|
||||||
|
'title'=>sprintf('%s: %s - %s',_('Payments For'),$ao->accnum(),$ao->name(TRUE)),
|
||||||
|
'body'=>View::factory('payment/user/list')
|
||||||
|
->set('payments',$ao->payment->find_all()),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -21,7 +21,9 @@ class Model_Payment extends ORMOSB {
|
|||||||
'checkout'=>array('foreign_key'=>'checkout_plugin_id'),
|
'checkout'=>array('foreign_key'=>'checkout_plugin_id'),
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $_sorting = array('date_payment'=>'DESC');
|
protected $_sorting = array(
|
||||||
|
'date_payment'=>'DESC'
|
||||||
|
);
|
||||||
|
|
||||||
protected $_display_filters = array(
|
protected $_display_filters = array(
|
||||||
'date_payment'=>array(
|
'date_payment'=>array(
|
||||||
@ -42,4 +44,32 @@ class Model_Payment extends ORMOSB {
|
|||||||
->where('date_payment','>=',time()-$start*86400)
|
->where('date_payment','>=',time()-$start*86400)
|
||||||
->find_all();
|
->find_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the remaining balance available for this payment
|
||||||
|
*/
|
||||||
|
public function balance($format=FALSE) {
|
||||||
|
$t = 0;
|
||||||
|
|
||||||
|
foreach ($this->payment_item->find_all() as $pio)
|
||||||
|
$t += $pio->alloc_amt;
|
||||||
|
|
||||||
|
return $format ? Currency::display($this->total_amt-$t) : $this->total_amt-$t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of invoices that this payment is applied to
|
||||||
|
*/
|
||||||
|
public function invoices() {
|
||||||
|
$invoices = array();
|
||||||
|
|
||||||
|
foreach ($this->payment_item->find_all() as $pio)
|
||||||
|
array_push($invoices,$pio->invoice);
|
||||||
|
|
||||||
|
return $invoices;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function invoicelist() {
|
||||||
|
return join(',',$this->invoices());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
21
modules/payment/views/payment/user/list.php
Normal file
21
modules/payment/views/payment/user/list.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<!-- @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>
|
@ -34,6 +34,10 @@ class Model_Service_ADSL extends Model_Service {
|
|||||||
return $this->ipaddress ? $this->ipaddress : _('Dynamic');
|
return $this->ipaddress ? $this->ipaddress : _('Dynamic');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function contract_date_start() {
|
||||||
|
return Config::date($this->service_connect_date);
|
||||||
|
}
|
||||||
|
|
||||||
public function contract_date_end() {
|
public function contract_date_end() {
|
||||||
return Config::date(strtotime(sprintf('+%s months',$this->contract_term),$this->service_connect_date));
|
return Config::date(strtotime(sprintf('+%s months',$this->contract_term),$this->service_connect_date));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user