Internal overhaul of Cart/Checkout and other minor fixes

This commit is contained in:
Deon George 2013-12-02 15:16:28 +11:00
parent f8a5b153cf
commit 06b87c5135
26 changed files with 256 additions and 228 deletions

View File

@ -221,7 +221,7 @@ abstract class ORM extends Kohana_ORM {
public function save(Validation $validation=NULL) { public function save(Validation $validation=NULL) {
parent::save(); parent::save();
if ($this->saved() AND $this->_save_message) if ($this->saved() AND $this->_save_message AND (PHP_SAPI !== 'cli'))
SystemMessage::factory() SystemMessage::factory()
->title('Record Updated') ->title('Record Updated')
->type('success') ->type('success')

View File

@ -20,7 +20,7 @@ class Task_Adsl_Trafficalert extends Minion_Task {
// @todo Pick up services that are no longer active, but were inactive < 30 days ago. // @todo Pick up services that are no longer active, but were inactive < 30 days ago.
foreach (ORM::factory('Service')->list_byplugin('ADSL') as $so) { foreach (ORM::factory('Service')->list_byplugin('ADSL') as $so) {
if ($params['verbose']) if (Minion_CLI::options('verbose'))
echo $so->service_name()."\n"; echo $so->service_name()."\n";
if (! $data=$so->plugin()->traffic_report()) if (! $data=$so->plugin()->traffic_report())

View File

@ -20,7 +20,7 @@ class Task_Adsl_Trafficcharge extends Minion_Task {
// @todo Pick up services that are no longer active, but were inactive < 30 days ago. // @todo Pick up services that are no longer active, but were inactive < 30 days ago.
foreach (ORM::factory('Service')->list_byplugin('ADSL') as $so) { foreach (ORM::factory('Service')->list_byplugin('ADSL') as $so) {
if ($params['verbose']) if (Minion_CLI::options('verbose'))
echo $so->service_name()."\n"; echo $so->service_name()."\n";
if ($x=$so->plugin()->traffic_excess($date)) { if ($x=$so->plugin()->traffic_excess($date)) {

View File

@ -22,8 +22,8 @@ class Task_Adsl_Trafficget extends Minion_Task {
protected function _execute(array $params) { protected function _execute(array $params) {
foreach ($this->_traffic_suppliers(TRUE) as $aso) { foreach ($this->_traffic_suppliers(TRUE) as $aso) {
if ($params['verbose']) if (Minion_CLI::options('verbose'))
echo $aso->name."\n"; printf("%s: %s\n",$aso->id,$aso->name);
Service_Traffic_Adsl::instance($aso->name)->update_traffic(); Service_Traffic_Adsl::instance($aso->name)->update_traffic();
} }

View File

@ -6,5 +6,10 @@
<?php echo Form::file('csv',array('label'=>'Invoice File','required')); ?> <?php echo Form::file('csv',array('label'=>'Invoice File','required')); ?>
</fieldset> </fieldset>
<?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?> <div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="button" class="btn">Cancel</button>
</div>
</div>
</div> <!-- /span --> </div> <!-- /span -->

View File

@ -16,10 +16,6 @@ class Cart {
$this->id = is_null($id) ? Session::instance()->id() : $id; $this->id = is_null($id) ? Session::instance()->id() : $id;
} }
public static function instance($id=NULL) {
return new Cart($id);
}
/** /**
* Return a list of items in the cart * Return a list of items in the cart
*/ */
@ -29,6 +25,20 @@ class Cart {
->find_all(); ->find_all();
} }
public function checkout() {
$result = array();
$checkout = ORM::factory('Checkout')->where_active()->find_all()->as_array();
foreach ($this->contents() as $cio)
$checkout = array_intersect($checkout,$cio->checkout()->as_array());
foreach ($checkout as $cko)
$result[$cko->id] = $cko->name;
return $result;
}
public function delete() { public function delete() {
foreach (ORM::factory('Cart')->where('session_id','=',$this->id)->find_all() as $co) foreach (ORM::factory('Cart')->where('session_id','=',$this->id)->find_all() as $co)
$co->delete(); $co->delete();
@ -46,6 +56,10 @@ class Cart {
return $this->id; return $this->id;
} }
public static function instance($id=NULL) {
return new Cart($id);
}
public function total($format=FALSE) { public function total($format=FALSE) {
$total = 0; $total = 0;
@ -54,43 +68,5 @@ class Cart {
return $format ? Currency::display($total) : $total; return $format ? Currency::display($total) : $total;
} }
/**
* Print an HTML cart list
*
* @param bool $detail List a detailed cart or a summary cart
*/
public function cart_block() {
// @todo To implement.
return '';
// If the cart is empty, we'll return here.
if (! count($this->contents()))
return 'The cart is empty.';
Style::add(array(
'type'=>'file',
'data'=>'css/cart_blocklist.css',
));
$output = '<table class="cart_blocklist" border="0">';
foreach ($this->contents() as $item) {
$ppa = $item->product->get_price_array();
$pdata = Period::details($item->recurr_schedule,$item->product->price_recurr_weekday,time(),TRUE);
$output .= View::factory('cart/block_list')
->set('item',$item)
->set('price_setup',$item->quantity*$ppa[$item->recurr_schedule]['price_setup'])
->set('price_firstinvoice',$item->quantity*$ppa[$item->recurr_schedule]['price_base']*$pdata['prorata']);
}
$output .= '<tr class="submit">';
$output .= sprintf('<td colspan="3">%s&nbsp;%s</td>',
Form::button('checkout','Checkout',array('type' => 'submit')),
Form::button('empty','Empty',array('type' => 'submit')));
$output .= '</tr>';
$output .= '</table>';
return $output;
}
} }
?> ?>

View File

@ -16,52 +16,21 @@ class Controller_Cart extends Controller_TemplateDefault {
* List the cart contents * List the cart contents
*/ */
public function action_index() { public function action_index() {
$output = '';
$co = Cart::instance(); $co = Cart::instance();
// If the cart is empty, we'll return here. // If the cart is empty, we'll return here.
if (! count($co->contents())) if (! $co->contents()->count())
Block::add(array( $this->template->content = _('Cart is Empty');
'title'=>_('Empty Cart'),
'body'=>_('The cart is empty')
));
else { else {
Block::add(array( $output = View::factory('cart/view')->set('o',$co);
'title'=>_('Cart Items'),
'body'=>Table::display(
$co->contents(),
NULL,
array(
'item()->q'=>array('label'=>'Quantity'),
'item()->i'=>array('label'=>'Item'),
'item()->t'=>array('label'=>'Total','class'=>'right'),
),
array(
'type'=>'list',
)
),
));
$checkout = ORM::factory('Checkout')->where_active()->find_all()->as_array();
foreach ($co->contents() as $cio)
$checkout = array_intersect($checkout,$cio->checkout()->as_array());
$payopt = array();
foreach ($checkout as $cko)
$payopt[$cko->id] = $cko->name;
$output .= _('Total amount due for payment').' '.$co->total(TRUE);
$output .= Form::open('checkout/before'); $output .= Form::open('checkout/before');
$output .= Form::select('checkout_id',$payopt); $output .= View::factory('cart/payment')->set('o',$co);
$output .= Form::submit('submit',_('Checkout'));
$output .= Form::close(); $output .= Form::close();
Block::add(array( Block::factory()
'title'=>_('Payment'), ->body($output);
'body'=>$output,
));
} }
} }
@ -69,24 +38,19 @@ class Controller_Cart extends Controller_TemplateDefault {
* Add an item to the cart * Add an item to the cart
*/ */
public function action_add() { public function action_add() {
$cart = ORM::factory('Cart'); $co = ORM::factory('Cart');
$cart->session_id = Session::instance()->id(); $co->values(Request::current()->post());
$co->session_id = Session::instance()->id();
if ($cart->values(Request::current()->post())->check()) if (! $this->save($co))
$cart->save(); throw HTTP_Exception::factory(501,_('There was a problem adding the item to the cart.'));
else
throw new Kohana_Exception('Unable to add to cart');
if ($cart->saved())
HTTP::redirect('cart/index'); HTTP::redirect('cart/index');
else
throw new Kohana_Exception(_('There was a problem adding the item to the cart.'));
} }
public function action_empty() { public function action_empty() {
foreach (ORM::factory('Cart')->where('session_id','=',Session::instance()->id())->find_all() as $co) Cart::instance()->delete();
$co->delete();
$this->template->content = _('Cart Emptied'); $this->template->content = _('Cart Emptied');
} }

View File

@ -10,13 +10,14 @@
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Model_Cart extends ORM_OSB { class Model_Cart extends ORM_OSB {
protected $_belongs_to = array(
'product'=>array(),
);
// Cart doesnt use the update column // Cart doesnt use the update column
protected $_updated_column = FALSE; protected $_updated_column = FALSE;
protected $_belongs_to = array(
'product'=>array(),
'module'=>array(),
);
protected $_serialize_column = array( protected $_serialize_column = array(
'module_data', 'module_data',
); );
@ -30,46 +31,26 @@ class Model_Cart extends ORM_OSB {
), ),
); );
private $mo;
public function __construct($id = NULL) {
// Load our Model
parent::__construct($id);
// Autoload our Sub Items
if ($this->loaded())
$this->_load_sub_items();
return $this;
}
private function _load_sub_items() {
$this->mo = ORM::factory('Module',$this->module_id)->instance($this->module_item);
if (! $this->mo->loaded())
throw new Kohana_Exception('Item :item not loaded?',array(':item'=>$this->module_item));
}
public function checkout() { public function checkout() {
if (! method_exists($this->mo,'checkout')) if (! method_exists($this->mo(),'checkout'))
throw new Kohana_Exception('Module :module doesnt implement checkout?',array(':module'=>get_class($this->mo))); throw new Kohana_Exception('Module :module doesnt implement checkout?',array(':module'=>get_class($this->mo)));
return $this->mo->checkout(); return $this->mo()->checkout();
} }
public function item() { public function item() {
if (! method_exists($this->mo,'cart_item')) if (! method_exists($this->mo(),'cart_item'))
throw new Kohana_Exception('Module :module doesnt implement cart_item?',array(':module'=>get_class($this->mo))); throw new Kohana_Exception('Module :module doesnt implement cart_item?',array(':module'=>get_class($this->mo)));
return $this->mo->cart_item(); return $this->mo()->cart_item();
} }
public function mo() { public function mo() {
return $this->mo; return $this->module->instance($this->module_item);
} }
public function motype() { public function motype() {
return strtolower(preg_replace('/^Model_/','',get_class($this->mo))); return strtolower(preg_replace('/^Model_/','',get_class($this->mo())));
} }
} }
?> ?>

View File

@ -0,0 +1,24 @@
<div class="span4">
<fieldset>
<legend>Payment</legend>
<div class="dl-horizontal">
<dt>Payment By</dt>
<dd><?php echo Form::select('checkout_id',$o->checkout(),NULL,array('class'=>'small','nocg'=>TRUE)); ?></dd>
<dt>Total Due</dt>
<dd><?php echo $o->total(TRUE); ?></dd>
</div>
</fieldset>
<div class="row">&nbsp;</div>
<div class="row">
<div class="offset1">
<button type="submit" class="btn btn-primary">Checkout</button>
<a href="cart/empty" class="btn">Clear</a>
</div>
</div>
</div> <!-- /span -->
<div class="row">&nbsp;</div>

View File

@ -0,0 +1,13 @@
<div class="span4">
<fieldset>
<legend>Cart Contents</legend>
<?php echo Table::factory()
->data($o->contents())
->columns(array(
'item()->q'=>'Quantity',
'item()->i'=>'Item',
'item()->t'=>'Total',
)); ?>
</fieldset>
</div> <!-- /span -->

View File

@ -24,5 +24,10 @@
endfor ?> endfor ?>
</fieldset> </fieldset>
<?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?> <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 --> </div> <!-- /span -->

View File

@ -18,11 +18,12 @@ class Checkout_Plugin_Paypal_Cart extends Checkout_Plugin_Paypal {
public function before(Cart $co) { public function before(Cart $co) {
$output = ''; $output = '';
$output .= Form::open(sprintf('https://%s/cgi-bin/webscr',$this->test_mode ? $this->url_test : $this->url_prod),array('method'=>'POST'));
$output .= View::factory('checkout/plugin/paypal/before') $output .= View::factory('checkout/plugin/paypal/before')
->set('checkout',$this->co) ->set('checkout',$this->co)
->set('cart',$co); ->set('cart',$co);
$output .= Form::open(sprintf('https://%s/cgi-bin/webscr',$this->test_mode ? $this->url_test : $this->url_prod),array('method'=>'POST'));
$output .= Form::hidden('cmd','_cart'); $output .= Form::hidden('cmd','_cart');
$output .= Form::hidden('business',$this->test_mode ? 'deon_1260578114_biz@graytech.net.au' : 'deon@graytech.net.au'); $output .= Form::hidden('business',$this->test_mode ? 'deon_1260578114_biz@graytech.net.au' : 'deon@graytech.net.au');
$output .= Form::hidden('bn','Graytech_BuyNow_WPS_AU'); $output .= Form::hidden('bn','Graytech_BuyNow_WPS_AU');
@ -46,7 +47,6 @@ class Checkout_Plugin_Paypal_Cart extends Checkout_Plugin_Paypal {
$output .= Form::hidden('item_name_'.$c,'Paypal Fee'); $output .= Form::hidden('item_name_'.$c,'Paypal Fee');
$output .= Form::hidden('amount_'.$c,$this->co->fee($co->total())); $output .= Form::hidden('amount_'.$c,$this->co->fee($co->total()));
$output .= Form::submit('submit','Pay Now');
$output .= Form::close(); $output .= Form::close();
return $output; return $output;

View File

@ -0,0 +1,16 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Admin for Checkout management
*
* @package Checkout
* @category Controllers/Admin
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Admin_Checkout extends Controller_Checkout {
protected $secure_actions = array(
);
}
?>

View File

@ -28,13 +28,8 @@ class Controller_Checkout extends Controller_TemplateDefault {
$co = ORM::factory('Checkout',$cid); $co = ORM::factory('Checkout',$cid);
Block::add(array( Block::factory()
'title'=>'Checkout', ->body($co->plugin()->before(Cart::instance()));
'body'=>$co->plugin()->before(Cart::instance()),
));
// Suppress our right hand tab
$this->template->right = ' ';
} }
public function action_after() { public function action_after() {
@ -71,6 +66,7 @@ class Controller_Checkout extends Controller_TemplateDefault {
$cno->status = 1; $cno->status = 1;
$cno->data = Request::current()->post(); $cno->data = Request::current()->post();
$cno->save(); $cno->save();
} else { } else {
$cno->where('id','=',$test_id)->find(); $cno->where('id','=',$test_id)->find();
} }

View File

@ -1,3 +0,0 @@
<tr>
<td class="icon"><label for="payment_<?php echo $payment->id; ?>"><?php echo FORM::radio('payment',$payment->id,0,array('id'=>'payment_'.$payment->id)); ?> <?php echo HTML::image($payment->graphic_url,array('alt'=>'')); ?> <?php echo $payment->name; ?></label></td>
</tr>

View File

@ -1,32 +1,30 @@
<p>Paypal will be used to pay for the following items:</p> <?php echo View::factory('cart/view')->set('o',$cart); ?>
</br>
<?php <div class="span4">
echo Table::display( <fieldset>
$cart->contents(), <legend>Payment by Paypal</legend>
NULL,
array(
'item()->q'=>array('label'=>'Quantity'),
'item()->i'=>array('label'=>'Item'),
'item()->t'=>array('label'=>'Total','class'=>'right'),
),
array(
'type'=>'list',
)
);
?>
</br>
<p>Please Note: Paypal charges a fee to receive payments, and that fee will be added to your payment.</p> <p>Please Note: Paypal charges a fee to receive payments, and that fee will be added to your payment.</p>
<table class="list-box-left"> <div class="dl-horizontal">
<tr class="list-data"> <dt>Cart Total</dt>
<th>Cart Total</th> <dd><?php echo $t=$cart->total(TRUE); ?></dd>
<td class="right"><?php echo $t=$cart->total(TRUE); ?></td>
</tr> <dt>Payment Fee</dt>
<tr class="list-data"> <dd><?php echo Currency::display($f=$checkout->fee($t)); ?></dd>
<th>Payment Fee</th>
<td class="right"><?php echo Currency::display($f=$checkout->fee($t)); ?></td> <dt>Total</dt>
</tr> <dd><?php echo Currency::display($t+$f); ?></dd>
<tr class="list-data"> </div>
<th>Total</th> </fieldset>
<td class="right"><?php echo Currency::display($t+$f); ?></td>
</tr> <div class="row">&nbsp;</div>
</table>
<div class="row">
<div class="offset1">
<button type="submit" class="btn btn-primary">Pay Now</button>
<a href="cart/empty" class="btn">Clear</a>
</div>
</div>
</div> <!-- /span -->
<div class="row">&nbsp;</div>

View File

@ -95,7 +95,9 @@ class Controller_Admin_Payment extends Controller_Payment {
private function add_edit($id=NULL,$output='') { private function add_edit($id=NULL,$output='') {
$po = ORM::factory('Payment',$id); $po = ORM::factory('Payment',$id);
if ($_POST) { if ($this->request->post()) {
$po->values($this->request->post());
// Update our invoice payment items // Update our invoice payment items
if (isset($_POST['payment_item']) AND count($_POST['payment_item'])) if (isset($_POST['payment_item']) AND count($_POST['payment_item']))
foreach ($_POST['payment_item'] as $k=>$v) { foreach ($_POST['payment_item'] as $k=>$v) {

View File

@ -15,7 +15,14 @@
<?php echo Form::input('notes',$o->notes,array('class'=>'span5','label'=>'Notes','placeholder'=>'Any notes about this payment?')); ?> <?php echo Form::input('notes',$o->notes,array('class'=>'span5','label'=>'Notes','placeholder'=>'Any notes about this payment?')); ?>
</fieldset> </fieldset>
<div class="span8" id="items"</div> <div class="span11">
<div class="span8" id="items"></div>
</div>
<?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?> <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 --> </div> <!-- /span -->

View File

@ -7,5 +7,10 @@
<?php echo Form::file('payment',array('label'=>'Payment File','required','help-block'=>'BillDetails')); ?> <?php echo Form::file('payment',array('label'=>'Payment File','required','help-block'=>'BillDetails')); ?>
</fieldset> </fieldset>
<?php echo Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?> <div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="button" class="btn">Cancel</button>
</div>
</div>
</div> <!-- /span --> </div> <!-- /span -->

View File

@ -127,8 +127,18 @@ class Controller_Reseller_SSL extends Controller_SSL {
private function add_edit($id=NULL,$output='') { private function add_edit($id=NULL,$output='') {
$sco = ORM::factory('SSL_CA',$id); $sco = ORM::factory('SSL_CA',$id);
if ($_POST AND $sco->values($_POST)->changed() AND ! ($this->save($sco))) if ($this->request->post()) {
if (! $sco->account_id)
$sco->account_id = (string)Auth::instance()->get_user();
// Set our values, so that our filters have data
$sco->values($this->request->post());
// To trigger our filter to get the correct parent
$sco->parent_ssl_ca_id = -1;
if ($sco->changed() AND ! $this->save($sco))
$sco->reload(); $sco->reload();
}
return View::factory('ssl/reseller/add_edit') return View::factory('ssl/reseller/add_edit')
->set('o',$sco); ->set('o',$sco);

View File

@ -36,15 +36,16 @@ class Model_SSL_CA extends ORM_OSB {
} }
public function rules() { public function rules() {
return array( return Arr::merge(parent::rules(),array(
'sign_cert'=>array( 'sign_cert'=>array(
array('not_empty'),
array(array($this,'isCert')), array(array($this,'isCert')),
array(array($this,'isCA')), array(array($this,'isCA')),
), ),
'parent_ssl_ca_id'=>array( 'parent_ssl_ca_id'=>array(
array(array($this,'rule_parentExist')), array(array($this,'rule_parentExist')),
), ),
); ));
} }
private $_so = NULL; private $_so = NULL;
@ -120,12 +121,32 @@ class Model_SSL_CA extends ORM_OSB {
return $this; return $this;
} }
/**
* Filter to find the parent SSL_CA
*
* @notes This filter only runs when the value passed is -1
*/
public function filter_getParent() { public function filter_getParent() {
foreach (ORM::factory($this->_object_name)->find_all() as $sco) // This cannot be an array
if ($sco->aki_keyid() == $this->aki_keyid()) if (count(func_get_args()) != 1)
return NULL;
$x = func_get_args();
$x = array_pop($x);
// This filter only runs when our value is -1
if ($x != -1)
return $x;
foreach (ORM::factory($this->_object_name)->find_all() as $sco) {
if ($sco->ski() == $this->aki_keyid())
return $sco->id; return $sco->id;
} }
// If we got here, we couldnt find it
return $this->isRoot() ? NULL : $x;
}
public function list_childca() { public function list_childca() {
return $this->children->find_all(); return $this->children->find_all();
} }
@ -136,7 +157,7 @@ class Model_SSL_CA extends ORM_OSB {
public function rule_parentExist() { public function rule_parentExist() {
// Our parent_ssl_ca_id should have been populated by filter_GetParent(). // Our parent_ssl_ca_id should have been populated by filter_GetParent().
return $this->parent_ssl_ca_id OR $this->isRoot(); return ($this->parent_ssl_ca_id > 0) OR $this->isRoot();
} }
} }
?> ?>

View File

@ -72,36 +72,20 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
return $this; return $this;
} }
public function validCA() {
return $this->ca->validParent();
}
// If we change the SSL certificate, we need to reload our SSL object
public function values(array $values, array $expected = NULL) {
parent::values($values,$expected);
if (array_key_exists('cert',$values))
$this->_so = SSL::instance($this->cert);
return $this;
}
/** /**
* Get specific service details for use in other modules * Return all our CA Certs for this certificate
* For Example: Invoice
*
* @todo Make the rendered items configurable
* @todo Change this method name, now that it is public
*/ */
// @todo This needs to be validated for this model public function cacerts() {
public function _details($type) { $result = array();
switch ($type) {
case 'invoice_detail_items': $x = $this->ssl_ca_id;
return array(); while ($x) {
break; $sco = ORM::factory('SSL_CA',$x);
default: array_push($result,$sco->sign_cert);
return parent::$_details($type); $x = $sco->parent_ssl_ca_id;
} }
return $result;
} }
public function download_button() { public function download_button() {
@ -119,19 +103,6 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
return $output; return $output;
} }
public function cacerts() {
$result = array();
$x = $this->ssl_ca_id;
while ($x) {
$sco = ORM::factory('SSL_CA',$x);
array_push($result,$sco->sign_cert);
$x = $sco->parent_ssl_ca_id;
}
return $result;
}
/** /**
* Renew an SSL Certificate * Renew an SSL Certificate
*/ */
@ -171,5 +142,37 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
throw new Kohana_Exception('Error Creating SSL Certificate :error',array(':error'=>openssl_error_string())); throw new Kohana_Exception('Error Creating SSL Certificate :error',array(':error'=>openssl_error_string()));
} }
} }
public function validCA() {
return $this->ca->validParent();
}
// If we change the SSL certificate, we need to reload our SSL object
public function values(array $values, array $expected = NULL) {
parent::values($values,$expected);
if (array_key_exists('cert',$values))
$this->_so = SSL::instance($this->cert);
return $this;
}
/**
* Get specific service details for use in other modules
* For Example: Invoice
*
* @todo Make the rendered items configurable
* @todo Change this method name, now that it is public
*/
// @todo This needs to be validated for this model
public function _details($type) {
switch ($type) {
case 'invoice_detail_items':
return array();
break;
default:
return parent::$_details($type);
}
}
} }
?> ?>

View File

@ -150,11 +150,11 @@ class SSL {
} }
public function get_isCA() { public function get_isCA() {
return preg_match('/CA:TRUE/',$this->_bc()); return preg_match('/CA:TRUE/',$this->_bc()) ? TRUE : FALSE;
} }
public function get_isCert() { public function get_isCert() {
return is_array($this->_details()); return is_array($this->_details()) ? TRUE : FALSE;
} }
public function get_isRoot() { public function get_isRoot() {

View File

@ -16,7 +16,7 @@ return array(
'isCA'=>'This is certificate is not a Certificate Authority certificate', 'isCA'=>'This is certificate is not a Certificate Authority certificate',
), ),
'parent_ssl_ca_id'=>array( 'parent_ssl_ca_id'=>array(
'Rule_ParentExists'=>'The parent certificate doesnt exist, please define it first', 'rule_parentExist'=>'The parent certificate doesnt exist, please define it first',
), ),
); );
?> ?>

View File

@ -46,6 +46,7 @@
<div class="span6"> <div class="span6">
<fieldset> <fieldset>
<legend>Certificate</legend> <legend>Certificate</legend>
<pre><?php echo $o->cert; ?></pre> <pre><?php echo $o->cert; ?></pre>
<?php <?php
@ -55,6 +56,5 @@
echo Form::button('submit','Renew',array('class'=>'btn btn-primary')); echo Form::button('submit','Renew',array('class'=>'btn btn-primary'));
endif endif
?> ?>
</fieldset> </fieldset>
</div> <!-- /span --> </div> <!-- /span -->

View File

@ -52,5 +52,10 @@
<?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_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 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 Form::button('submit','Submit',array('class'=>'btn btn-primary')); ?> <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 --> </div> <!-- /span -->