Updated Login to use lnapp, and minor update to Invoice

This commit is contained in:
Deon George
2016-08-17 22:30:12 +10:00
parent 07de13f678
commit c1cc6b6f69
10 changed files with 107 additions and 148 deletions

View File

@@ -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'));
}

View File

@@ -4,7 +4,7 @@
<?php
echo View::factory('field/date')->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']);

View File

@@ -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;
}

View File

@@ -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();

View File

@@ -1,61 +1,56 @@
<div class="span11">
<fieldset>
<legend>SSL CA Certificate Edit/Update</legend>
<fieldset class="col-md-12">
<legend>SSL CA Certificate Edit/Update</legend>
<div class="dl-horizontal">
<dt>Subject</dt>
<dd><?php echo $o->subject(); ?></dd>
<div class="dl-horizontal">
<dt>Subject</dt>
<dd><?php echo $o->subject(); ?></dd>
<dt>DN</dt>
<dd><?php echo $o->dn(); ?></dd>
<dt>DN</dt>
<dd><?php echo $o->dn(); ?></dd>
<dt>Serial</dt>
<dd><?php echo $o->serial(); ?></dd>
<dt>Serial</dt>
<dd><?php echo $o->serial(); ?></dd>
<dt>Subject Key Id</dt>
<dd><?php echo $o->ski(); ?></dd>
<dt>Subject Key Id</dt>
<dd><?php echo $o->ski(); ?></dd>
<?php if (! $o->isRoot()) : ?>
<dt>Issuer</dt>
<dd>
<?php if ($o->validParent()) : ?>
<?php echo HTML::anchor(URL::link('reseller','ssl/edit/').$o->parent_ssl_ca_id,$o->issuer()); ?>
<?php else : ?>
<?php echo $o->issuer(); ?>
<?php endif ?>
</dd>
<?php if (! $o->isRoot()) : ?>
<dt>Issuer</dt>
<dd>
<?php if ($o->validParent()) : ?>
<?php echo HTML::anchor(URL::link('reseller','ssl/edit/').$o->parent_ssl_ca_id,$o->issuer()); ?>
<?php else : ?>
<?php echo $o->issuer(); ?>
<?php endif ?>
</dd>
<dt>Issuer Serial</dt>
<dd><?php printf('%s (%s)',$o->aki_keyid(), $o->aki_serial()); ?></dd>
<dt>Issuer Serial</dt>
<dd><?php printf('%s (%s)',$o->aki_keyid(), $o->aki_serial()); ?></dd>
<dt>Issuer Valid</dt>
<dd><?php echo $o->validParent(TRUE); ?></dd>
<?php endif ?>
<dt>Issuer Valid</dt>
<dd><?php echo $o->validParent(TRUE); ?></dd>
<?php endif ?>
<dt>Valid From</dt>
<dd><?php echo $o->valid_from(TRUE); ?></dd>
<dt>Valid From</dt>
<dd><?php echo $o->valid_from(TRUE); ?></dd>
<dt>Valid To</dt>
<dd><?php echo $o->valid_to(TRUE); ?></dd>
<dt>Valid To</dt>
<dd><?php echo $o->valid_to(TRUE); ?></dd>
<dt>Hash</dt>
<dd><?php echo $o->hash(); ?></dd>
<dt>Hash</dt>
<dd><?php echo $o->hash(); ?></dd>
<dt>Version</dt>
<dd><?php echo $o->version(); ?></dd>
<dt>Version</dt>
<dd><?php echo $o->version(); ?></dd>
<dt>Key Algorithm<dt>
<dd><?php echo $o->algorithm(); ?></dd>
</div> <!-- /dl-horizontal -->
</fieldset>
<dt>Key Algorithm<dt>
<dd><?php echo $o->algorithm(); ?></dd>
</div> <!-- /dl-horizontal -->
<?php echo Form::textarea('sign_pk',$o->sign_pk,array('class'=>'span6','label'=>'Private Key','placeholder'=>'Private Key','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->sign_pk))); ?>
<?php echo Form::textarea('sign_cert',$o->sign_cert,array('class'=>'span6','label'=>'Public Certificate','placeholder'=>'Public Certificate','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->sign_cert))); ?>
<?php
echo View::factory('field/textarea')->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']);
<div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</div>
</div> <!-- /span -->
echo View::factory('field/submit');
?>
</fieldset>