diff --git a/application/classes/Company.php b/application/classes/Company.php index 33c29f1c..bf354b50 100644 --- a/application/classes/Company.php +++ b/application/classes/Company.php @@ -34,7 +34,7 @@ class Company { } public function admin() { - return $this->so->account->name(); + return $this->so->account; } public function address($ln='
') { diff --git a/application/classes/Controller/Login.php b/application/classes/Controller/Login.php index 9308cae9..90b446a5 100644 --- a/application/classes/Controller/Login.php +++ b/application/classes/Controller/Login.php @@ -11,6 +11,8 @@ * @also [logout] */ class Controller_Login extends lnApp_Controller_Login { + protected $login_attribute = 'username'; + /** * Enable site registration * @@ -23,70 +25,5 @@ class Controller_Login extends lnApp_Controller_Login { HTTP::redirect('login'); } - - /** - * Enable user password reset - */ - public function action_reset() { - // Minutes to keep our token - $token_expire = 15; - - // If user already signed-in - if (Auth::instance()->logged_in()) - HTTP::redirect('welcome/index'); - - // If the user posted their details to reset their password - if ($this->request->post()) { - // If the username is correct, create a method token - if ($this->request->post('username') AND ($ao=ORM::factory('Account',array('username'=>$this->request->post('username')))) AND $ao->loaded()) { - $mmto = ORM::factory('Module_Method_Token') - ->method(array('account','user:resetpassword')) - ->account($ao) - ->uses(2) - ->expire(time()+$token_expire*60); - - if ($mmto->generate()) { - // Send our email with the token - // @todo Need to provide an option if Email_Template is not installed/activited. - // @todo Need to provide an option if account_reset_password template doesnt exist. - $et = Email_Template::instance('account_reset_password'); - $et->to = array('account'=>array($mmto->account_id)); - $et->variables = array( - 'SITE'=>URL::base(TRUE,TRUE), - 'SITE_ADMIN'=>Company::instance()->admin(), - 'SITE_NAME'=>Company::instance()->name(), - 'TOKEN'=>$mmto->token, - 'TOKEN_EXPIRE_MIN'=>$token_expire, - 'USER_NAME'=>$mmto->account->namesub(), - ); - $et->send(); - - // Log the password reset - $ao->log('Password reset token sent'); - } - - // Redirect to our password reset, the Auth will validate the token. - } elseif ($this->request->query('token')) { - HTTP::redirect(URL::link('user','account/resetpassword?token='.$this->request->query('token'))); - } - - // Show our token screen even if the email was invalid. - if ($this->request->post('username')) - $output = View::factory('pages/login_reset_sent'); - - else - HTTP::redirect('login'); - - } else { - $output = View::factory('pages/login_reset'); - } - - Style::factory() - ->type('file') - ->data('media/theme/baseadmin/css/pages/login.css'); - - $this->template->content = $output; - $this->template->shownavbar = FALSE; - } } ?> diff --git a/application/classes/Model/Account.php b/application/classes/Model/Account.php index 3e3a252e..e8b7f8c2 100644 --- a/application/classes/Model/Account.php +++ b/application/classes/Model/Account.php @@ -127,6 +127,18 @@ class Model_Account extends lnApp_Model_Account { return $sk.sprintf('%s %s',$this->last_name,$this->first_name); } + /** + * Generate a token for non-login authorised functinos + */ + public function token($token_expire,$module,$method,$uses) { + return ORM::factory('Module_Method_Token') + ->method(array($module,$method)) + ->account($this) + ->uses($uses) + ->expire(time()+$token_expire*60) + ->generate(); + } + /** * Search for accounts matching a term */ diff --git a/application/views/pages/login_reset.php b/application/views/pages/login_reset.php deleted file mode 100644 index 5ae381d9..00000000 --- a/application/views/pages/login_reset.php +++ /dev/null @@ -1,21 +0,0 @@ -
-
-
-

Reset Password

- -

If you have forgotten your password, we can issue you a temporary access code via email that will allow you to change your password.

- - - - -
-
-
diff --git a/modules/charge/classes/Model/Charge.php b/modules/charge/classes/Model/Charge.php index 417baa75..2558c4e6 100644 --- a/modules/charge/classes/Model/Charge.php +++ b/modules/charge/classes/Model/Charge.php @@ -97,6 +97,10 @@ class Model_Charge extends ORM { return $iio; } + public function name($variable=NULL) { + return StaticList_ItemType::get($this->type); + } + public function namesub($variable=NULL) { return sprintf('%d@%2.2f - %s (%s)',$this->quantity,$this->amount,($this->description ? ' '.$this->description : '').($this->attributes ? ' ['.join('|',$this->attributes).']' : ''),$this->display('date_charge')); } diff --git a/modules/charge/views/charge/reseller/add_edit.php b/modules/charge/views/charge/reseller/add_edit.php index b406895a..45c473db 100644 --- a/modules/charge/views/charge/reseller/add_edit.php +++ b/modules/charge/views/charge/reseller/add_edit.php @@ -4,7 +4,7 @@ set('data',['field'=>'date_charge','value'=>$o->date_charge ? $o->date_charge : time(),'text'=>'Date Charge','enddate'=>'new Date()']); - echo View::factory('field/account')->set('data',['field'=>'account_id','value'=>$o->account_id,'text'=>'Account','name'=>sprintf('%s: %s',$o->account->refnum(),$o->account->name()),'ajaxurl'=>URL::link('reseller','charge/ajaxlist')]); + echo View::factory('field/account')->set('data',['field'=>'account_id','value'=>$o->account_id,'text'=>'Account','name'=>$o->account_id ? sprintf('%s: %s',$o->account->refnum(),$o->account->name()) : '','ajaxurl'=>URL::link('reseller','charge/ajaxlist')]); echo View::factory('field/select')->set('data',['field'=>'service_id','value'=>$o->account_id ? $o->account->service->list_select() : [],'text'=>'Service','default'=>$o->service_id,'class'=>'col-md-6']); echo View::factory('field/select')->set('data',['field'=>'sweep_type','value'=>Arr::merge([''=>''],StaticList_SweepType::table()),'text'=>'Sweep','default'=>is_null($o->sweep_type) ? 6 : $o->sweep_type,'class'=>'col-md-2']); echo View::factory('field/select')->set('data',['field'=>'type','value'=>Arr::merge([''=>''],StaticList_ItemType::table()),'text'=>'Item Type','default'=>$o->type,'class'=>'col-md-2']); diff --git a/modules/invoice/classes/Model/Invoice.php b/modules/invoice/classes/Model/Invoice.php index 4e015409..1cd2c404 100644 --- a/modules/invoice/classes/Model/Invoice.php +++ b/modules/invoice/classes/Model/Invoice.php @@ -185,24 +185,34 @@ class Model_Invoice extends ORM implements Cartable { $result = array(); $lo = $this->account->language; - foreach ($this->subitems() as $iio) { - // We only summarise item_type=0 - if (! $iio->item_type == 0) - continue; + $track['p'] = $track = array(); + foreach ($this->items_render() as $key => $items) { + switch ($key) { + case 's': + $last = ''; + foreach ($items as $iio) { - if ($iio->product) { - $p = $iio->product->name($lo); + if ($iio->product) { + $p = $iio->title($lo); + } - if (! isset($result[$p])) { - $result[$p]['quantity'] = 0; - $result[$p]['subtotal'] = 0; - } + if (! isset($result[$p])) { + $result[$p]['quantity'] = 0; + $result[$p]['subtotal'] = 0; + } - $result[$p]['quantity']++; - $result[$p]['subtotal'] += $iio->subtotal(); + $result[$p]['quantity']++; + $result[$p]['subtotal'] += $iio->subtotal(); + } + + break; + + case 'other': + break; } } + ksort($result); return $result; } diff --git a/modules/invoice/classes/Model/Invoice/Item.php b/modules/invoice/classes/Model/Invoice/Item.php index c84fd6db..55ea883f 100644 --- a/modules/invoice/classes/Model/Invoice/Item.php +++ b/modules/invoice/classes/Model/Invoice/Item.php @@ -170,6 +170,9 @@ class Model_Invoice_Item extends ORM { if (! $this->isValid()) return sprintf('Record Error [%s-%s]',$this->item_type,$this->id); + if (is_null($variable) OR ! $variable instanceof Model_Language) + $variable = Site::language(); + switch ($this->item_type) { case 0: case 2: @@ -278,6 +281,25 @@ class Model_Invoice_Item extends ORM { return $result; } + public function title(Model_Language $lo) { + if (! $this->isValid()) + return 'Record Error'; + + switch ($this->item_type) { + case 0: + case 2: + case 3: + case 4: + return $this->product->name($lo); + case 5: + return $this->_module()->name($lo); + case 124: + return StaticList_ItemType::get($this->item_type); + default: + return 'Unknown'; + } + } + public function total($format=FALSE) { $result = $this->void ? 0 : $this->subtotal()+$this->tax()-$this->discount(); diff --git a/modules/lnapp b/modules/lnapp index a7616960..2b48dde8 160000 --- a/modules/lnapp +++ b/modules/lnapp @@ -1 +1 @@ -Subproject commit a7616960f01f1019ecf2fe041a06af0d67a5e697 +Subproject commit 2b48dde8f7297e49914e742d85e14783d900902c diff --git a/modules/ssl/views/ssl/reseller/add_edit.php b/modules/ssl/views/ssl/reseller/add_edit.php index 6242ec8f..add6169b 100644 --- a/modules/ssl/views/ssl/reseller/add_edit.php +++ b/modules/ssl/views/ssl/reseller/add_edit.php @@ -1,61 +1,56 @@ -
-
- SSL CA Certificate Edit/Update +
+ SSL CA Certificate Edit/Update -
-
Subject
-
subject(); ?>
+
+
Subject
+
subject(); ?>
-
DN
-
dn(); ?>
+
DN
+
dn(); ?>
-
Serial
-
serial(); ?>
+
Serial
+
serial(); ?>
-
Subject Key Id
-
ski(); ?>
+
Subject Key Id
+
ski(); ?>
- isRoot()) : ?> -
Issuer
-
- validParent()) : ?> - parent_ssl_ca_id,$o->issuer()); ?> - - issuer(); ?> - -
+ isRoot()) : ?> +
Issuer
+
+ validParent()) : ?> + parent_ssl_ca_id,$o->issuer()); ?> + + issuer(); ?> + +
-
Issuer Serial
-
aki_keyid(), $o->aki_serial()); ?>
+
Issuer Serial
+
aki_keyid(), $o->aki_serial()); ?>
-
Issuer Valid
-
validParent(TRUE); ?>
- +
Issuer Valid
+
validParent(TRUE); ?>
+ -
Valid From
-
valid_from(TRUE); ?>
+
Valid From
+
valid_from(TRUE); ?>
-
Valid To
-
valid_to(TRUE); ?>
+
Valid To
+
valid_to(TRUE); ?>
-
Hash
-
hash(); ?>
+
Hash
+
hash(); ?>
-
Version
-
version(); ?>
+
Version
+
version(); ?>
-
Key Algorithm
-
algorithm(); ?>
-
-
+
Key Algorithm
+
algorithm(); ?>
+
- sign_pk,array('class'=>'span6','label'=>'Private Key','placeholder'=>'Private Key','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->sign_pk))); ?> - sign_cert,array('class'=>'span6','label'=>'Public Certificate','placeholder'=>'Public Certificate','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->sign_cert))); ?> +set('data',['field'=>'sign_pk','value'=>$o->sign_pk,'text'=>'Private Key']); + echo View::factory('field/textarea')->set('data',['field'=>'sign_cert','value'=>$o->sign_cert,'text'=>'Public Certificate']); -
-
- - -
-
- + echo View::factory('field/submit'); +?> +