diff --git a/application/classes/controller/lnapp/login.php b/application/classes/controller/lnapp/login.php
index 4c8405d5..919d3801 100644
--- a/application/classes/controller/lnapp/login.php
+++ b/application/classes/controller/lnapp/login.php
@@ -18,7 +18,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
// If user already signed-in
if (Auth::instance()->logged_in()!= 0) {
// 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
@@ -35,7 +35,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
Request::current()->redirect($redir);
} else
- Request::current()->redirect('welcome/index');
+ Request::current()->redirect('user/welcome');
} else {
SystemMessage::add(array(
diff --git a/application/classes/controller/user/welcome.php b/application/classes/controller/user/welcome.php
new file mode 100644
index 00000000..4690c74a
--- /dev/null
+++ b/application/classes/controller/user/welcome.php
@@ -0,0 +1,25 @@
+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',
+ ));
+ }
+}
+?>
diff --git a/modules/account/classes/model/account.php b/modules/account/classes/model/account.php
index 69463b18..548c19ff 100644
--- a/modules/account/classes/model/account.php
+++ b/modules/account/classes/model/account.php
@@ -14,7 +14,7 @@ class Model_Account extends Model_Auth_UserDefault {
'user_tokens' => array('model' => 'user_token'),
'group' => array('through' => 'account_group'),
'invoice' => array('far_key'=>'id'),
- 'payment'=>array(),
+ 'payment'=>array('far_key'=>'id'),
'service' => array('far_key'=>'id'),
);
diff --git a/modules/invoice/classes/controller/user/invoice.php b/modules/invoice/classes/controller/user/invoice.php
index 1cce3806..5ea6ac49 100644
--- a/modules/invoice/classes/controller/user/invoice.php
+++ b/modules/invoice/classes/controller/user/invoice.php
@@ -12,8 +12,9 @@
*/
class Controller_User_Invoice extends Controller_TemplateDefault {
public $secure_actions = array(
+ 'download'=>TRUE,
'list'=>TRUE,
- 'view'=>FALSE,
+ 'view'=>TRUE,
);
/**
@@ -28,7 +29,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault {
Block::add(array(
'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()),
));
}
@@ -45,7 +46,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault {
}
// @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('invoice',$io);
}
diff --git a/modules/invoice/classes/model/invoice.php b/modules/invoice/classes/model/invoice.php
index 9a104eec..eb31222a 100644
--- a/modules/invoice/classes/model/invoice.php
+++ b/modules/invoice/classes/model/invoice.php
@@ -23,6 +23,10 @@ class Model_Invoice extends ORMOSB {
'payment'=>array('through'=>'payment_item'),
);
+ protected $_sorting = array(
+ 'id'=>'DESC',
+ );
+
/**
* @var array Filters to render values properly
*/
diff --git a/modules/invoice/views/invoice/html.php b/modules/invoice/views/invoice/user/html.php
similarity index 94%
rename from modules/invoice/views/invoice/html.php
rename to modules/invoice/views/invoice/user/html.php
index be3bb3f3..c8a17584 100644
--- a/modules/invoice/views/invoice/html.php
+++ b/modules/invoice/views/invoice/user/html.php
@@ -112,7 +112,7 @@
Sub Total: |
- subtotal(TRUE); ?> |
+ subtotal(TRUE); ?> |
Taxes Included: |
@@ -130,9 +130,12 @@
Total: |
- total(TRUE); ?> |
+ total(TRUE); ?> |
+
+ id,'Download detailed invoice'); ?> |
+
diff --git a/modules/invoice/views/invoice/list.php b/modules/invoice/views/invoice/user/list.php
similarity index 76%
rename from modules/invoice/views/invoice/list.php
rename to modules/invoice/views/invoice/user/list.php
index 22b46266..343811b4 100644
--- a/modules/invoice/views/invoice/list.php
+++ b/modules/invoice/views/invoice/user/list.php
@@ -2,6 +2,7 @@
ID |
+ Date |
Total |
Credits |
Payments |
@@ -11,8 +12,9 @@
id,$invoice->id()); ?> |
- display('total_amt'); ?> |
- display('credit_amt'); ?> |
+ display('date_orig'); ?> |
+ display('total_amt'); ?> |
+ display('credit_amt'); ?> |
display('billed_amt'); ?> |
due()); ?> |
display('status'); ?> |
diff --git a/modules/payment/classes/controller/user/payment.php b/modules/payment/classes/controller/user/payment.php
new file mode 100644
index 00000000..6ea2176f
--- /dev/null
+++ b/modules/payment/classes/controller/user/payment.php
@@ -0,0 +1,36 @@
+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()),
+ ));
+ }
+}
+?>
diff --git a/modules/payment/classes/model/payment.php b/modules/payment/classes/model/payment.php
index c39714ed..310ab2f0 100644
--- a/modules/payment/classes/model/payment.php
+++ b/modules/payment/classes/model/payment.php
@@ -21,7 +21,9 @@ class Model_Payment extends ORMOSB {
'checkout'=>array('foreign_key'=>'checkout_plugin_id'),
);
- protected $_sorting = array('date_payment'=>'DESC');
+ protected $_sorting = array(
+ 'date_payment'=>'DESC'
+ );
protected $_display_filters = array(
'date_payment'=>array(
@@ -42,4 +44,32 @@ class Model_Payment extends ORMOSB {
->where('date_payment','>=',time()-$start*86400)
->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());
+ }
}
diff --git a/modules/payment/views/payment/user/list.php b/modules/payment/views/payment/user/list.php
new file mode 100644
index 00000000..6c9d4d39
--- /dev/null
+++ b/modules/payment/views/payment/user/list.php
@@ -0,0 +1,21 @@
+
+
+
+ ID |
+ Date |
+ Method |
+ Total |
+ Unallocated |
+ Invoices |
+
+
+
+ id; ?> |
+ display('date_payment'); ?> |
+ checkout->display('name'); ?> |
+ display('total_amt'); ?> |
+ balance() ? ''.$po->balance(TRUE).'' : $po->balance(TRUE); ?> |
+ invoicelist(); ?> |
+
+
+
diff --git a/modules/service/classes/model/service/adsl.php b/modules/service/classes/model/service/adsl.php
index 9c7db348..31f1a00c 100644
--- a/modules/service/classes/model/service/adsl.php
+++ b/modules/service/classes/model/service/adsl.php
@@ -34,6 +34,10 @@ class Model_Service_ADSL extends Model_Service {
return $this->ipaddress ? $this->ipaddress : _('Dynamic');
}
+ public function contract_date_start() {
+ return Config::date($this->service_connect_date);
+ }
+
public function contract_date_end() {
return Config::date(strtotime(sprintf('+%s months',$this->contract_term),$this->service_connect_date));
}