Skip to content

Commit

Permalink
recurring
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkerr committed Feb 7, 2016
1 parent b020cd1 commit b5999b6
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 70 deletions.
59 changes: 40 additions & 19 deletions upload/catalog/controller/account/recurring.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,32 +150,53 @@ public function info() {

$data['heading_title'] = $this->language->get('text_recurring');

$data['text_recurring_id'] = $this->language->get('text_recurring_id');
$data['text_recurring_detail'] = $this->language->get('text_recurring_detail');
$data['text_order_recurring_id'] = $this->language->get('text_order_recurring_id');
$data['text_order_id'] = $this->language->get('text_order_id');
$data['text_date_added'] = $this->language->get('text_date_added');

$data['text_payment_method'] = $this->language->get('text_payment_method');
$data['text_recurring_detail'] = $this->language->get('text_recurring_detail');
$data['text_status'] = $this->language->get('text_status');
$data['text_ref'] = $this->language->get('text_ref');
$data['text_reference'] = $this->language->get('text_reference');
$data['text_product'] = $this->language->get('text_product');
$data['text_order'] = $this->language->get('text_order');

$data['text_quantity'] = $this->language->get('text_quantity');
$data['text_transactions'] = $this->language->get('text_transactions');
$data['text_transaction'] = $this->language->get('text_transaction');
$data['text_recurring_description'] = $this->language->get('text_recurring_description');

$data['text_no_results'] = $this->language->get('text_no_results');


$data['column_date_added'] = $this->language->get('column_date_added');
$data['column_type'] = $this->language->get('column_type');
$data['column_amount'] = $this->language->get('column_amount');

$data['order_recurring_id'] = $this->request->get['order_recurring_id'];
$data['order_id'] = $recurring_info['order_id'];
$data['recurring_description'] = $recurring_info['recurring_description'];
$data['recurring_status'] = $recurring_info['recurring_status'];
$data['payment_method'] = $recurring_info['payment_method'];
$data['product_name'] = $recurring_info['product_name'];
$data['quantity'] = $recurring_info['quantity'];
$data['date_added'] = date($this->language->get('date_format_short'), strtotime($recurring_info['date_added']));

$data['reference'] = $recurring_info['reference'];

$data['product'] = $this->url->link('product/product', 'product_id=' . $recurring['product_id'], true);
$data['order'] = $this->url->link('account/order/info', 'order_id=' . $recurring['order_id'], true);

// Transactions
$data['transactions'] = array();

$results = $this->model_account_recurring->getOrderRecurringTransactions($this->request->get['order_recurring_id']);

foreach ($results as $result) {
$data['transactions'][] = array(
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'type' => $result['type'],
'amount' => $this->currency->format($result['amount'], $recurring_info['currency'])
);
}


$recurring['date_added'] = date($this->language->get('date_format_short'), strtotime($recurring['date_added']));
$recurring['product'] = $this->url->link('product/product', 'product_id=' . $recurring['product_id'], true);
$recurring['order'] = $this->url->link('account/order/info', 'order_id=' . $recurring['order_id'], true);

$data['transactions'] = $this->model_account_recurring->getOrderRecurringTransactions($this->request->get['order_recurring_id']);

//$data['buttons'] = $this->load->controller('payment/' . $recurring['payment_code'] . '/recurringButtons');
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
Expand All @@ -186,9 +207,9 @@ public function info() {

$this->response->setOutput($this->load->view('account/recurring_info', $data));
} else {
$this->document->setTitle($this->language->get('text_order'));
$this->document->setTitle($this->language->get('text_recurring'));

$data['heading_title'] = $this->language->get('text_order');
$data['heading_title'] = $this->language->get('text_recurring');

$data['text_error'] = $this->language->get('text_error');

Expand All @@ -208,15 +229,15 @@ public function info() {

$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/order', '', true)
'href' => $this->url->link('account/recurring', '', true)
);

$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_order'),
'href' => $this->url->link('account/order/info', 'order_id=' . $order_id, true)
'text' => $this->language->get('text_recurring'),
'href' => $this->url->link('account/recurring/info', 'order_recurring_id=' . $order_recurring_id, true)
);

$data['continue'] = $this->url->link('account/order', '', true);
$data['continue'] = $this->url->link('account/recurring', '', true);

$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
Expand Down
50 changes: 26 additions & 24 deletions upload/catalog/language/en-gb/account/recurring.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
<?php
// Heading
$_['heading_title'] = 'Recurring Payments';
$_['heading_title'] = 'Recurring Payments';

// Text
$_['text_account'] = 'Account';
$_['text_recurring_detail'] = 'Recurring Payment Details';
$_['text_order_id'] = 'Order ID: ';
$_['text_product'] = 'Product: ';

$_['text_quantity'] = 'Quantity: ';

$_['text_recurring'] = 'Recurring Payment Information';

$_['text_recurring_detail'] = 'Recurring payment details'


$_['text_product'] = 'Product: ';
$_['text_order'] = 'Order: ';
$_['text_quantity'] = 'Quantity: ';

$_['text_recurring'] = 'Recurring payment';

$_['text_empty'] = 'No recurring payments found';

$_['text_transaction'] = 'Transactions';


$_['text_order_recurring_id'] = 'Recurring ID: ';
$_['text_payment_method'] = 'Payment method: ';
$_['text_date_added'] = 'Date Added';
$_['text_recurring_description'] = 'Description';
$_['text_status'] = 'Status:';
$_['text_reference'] = 'Reference:';


$_['text_empty'] = 'No recurring payments found!';
$_['text_error'] = 'The recurring order you requested could not be found!';


$_['text_transactions'] = 'Transactions';


;
$_['text_recurring_id'] = 'Profile ID: ';
$_['text_payment_method'] = 'Payment method: ';
$_['text_date_added'] = 'Date Added';
$_['text_recurring_description'] = 'Description: ';
$_['text_status'] = 'Status: ';
$_['text_ref'] = 'Reference: ';

$_['text_status_1'] = 'Active';
$_['text_status_2'] = 'Inactive';
Expand Down Expand Up @@ -80,17 +83,16 @@


// Column
$_['column_date_added'] = 'Date Added';
$_['column_type'] = 'Type';
$_['column_amount'] = 'Amount';
$_['column_status'] = 'Status';
$_['column_product'] = 'Product';
$_['column_action'] = 'Action';
$_['column_recurring_id'] = 'Profile ID';
$_['column_date_added'] = 'Date Added';
$_['column_type'] = 'Type';
$_['column_amount'] = 'Amount';
$_['column_status'] = 'Status';
$_['column_product'] = 'Product';
$_['column_recurring_id'] = 'Recurring ID';

// Error
$_['error_not_cancelled'] = 'Error: %s';
$_['error_not_found'] = 'Could not cancel recurring';
$_['error_not_found'] = 'Could not cancel recurring';

// Button
$_['button_return'] = 'Return';
$_['button_return'] = 'Return';
12 changes: 3 additions & 9 deletions upload/catalog/model/account/recurring.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,10 @@ class ModelAccountRecurring extends Model {
9 => 'Expired'
);

public function getOrderRecurring($recurring_id) {
$result = $this->db->query("SELECT `or`.*,`o`.`payment_method`,`o`.`payment_code`,`o`.`currency_code` FROM `" . DB_PREFIX . "order_recurring` `or` LEFT JOIN `" . DB_PREFIX . "order` `o` ON `or`.`order_id` = `o`.`order_id` WHERE `or`.`order_recurring_id` = '" . (int)$recurring_id . "' AND `o`.`customer_id` = '" . (int)$this->customer->getId() . "' LIMIT 1");
public function getOrderRecurring($order_recurring_id) {
$query = $this->db->query("SELECT `or`.*,`o`.`payment_method`,`o`.`payment_code`,`o`.`currency_code` FROM `" . DB_PREFIX . "order_recurring` `or` LEFT JOIN `" . DB_PREFIX . "order` `o` ON `or`.`order_id` = `o`.`order_id` WHERE `or`.`order_recurring_id` = '" . (int)$order_recurring_id . "' AND `o`.`customer_id` = '" . (int)$this->customer->getId() . "'");

if ($result->num_rows > 0) {
$recurring = $result->row;

return $recurring;
} else {
return false;
}
return $query->row;
}

public function getOrderRecurrings($start = 0, $limit = 20) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
</thead>
<tbody>
<tr>
<td class="text-left" style="width: 50%;"><?php if ($invoice_no) { ?>
<td class="text-left" style="width: 50%; vertical-align: top;"><?php if ($invoice_no) { ?>
<b><?php echo $text_invoice_no; ?></b> <?php echo $invoice_no; ?><br />
<?php } ?>
<b><?php echo $text_order_id; ?></b> #<?php echo $order_id; ?><br />
<b><?php echo $text_date_added; ?></b> <?php echo $date_added; ?></td>
<td class="text-left"><?php if ($payment_method) { ?>
<td class="text-left" style="width: 50%; vertical-align: top;"><?php if ($payment_method) { ?>
<b><?php echo $text_payment_method; ?></b> <?php echo $payment_method; ?><br />
<?php } ?>
<?php if ($shipping_method) { ?>
Expand All @@ -50,9 +50,9 @@
<table class="table table-bordered table-hover">
<thead>
<tr>
<td class="text-left" style="width: 50%;"><?php echo $text_payment_address; ?></td>
<td class="text-left" style="width: 50%; vertical-align: top;"><?php echo $text_payment_address; ?></td>
<?php if ($shipping_address) { ?>
<td class="text-left"><?php echo $text_shipping_address; ?></td>
<td class="text-left" style="width: 50%; vertical-align: top;"><?php echo $text_shipping_address; ?></td>
<?php } ?>
</tr>
</thead>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,31 @@
</thead>
<tbody>
<tr>
<td class="text-left" style="width: 50%;"><p><b><?php echo $text_recurring_id; ?></b> #<?php echo $order_recurring_id; ?></p>
<td class="text-left" style="width: 50%; vertical-align: top;"><p><b><?php echo $text_order_recurring_id; ?></b> #<?php echo $order_recurring_id; ?></p>
<p><b><?php echo $text_date_added; ?></b> <?php echo $date_added; ?></p>
<p><b><?php echo $text_status; ?></b> <?php echo $recurring_status; ?></p>
<p><b><?php echo $text_payment_method; ?></b> <?php echo $payment_method; ?></p></td>
<td class="left" style="width: 50%; vertical-align: top;"><p><b><?php echo $text_product; ?></b><a href="<?php echo $recurring['product_link']; ?>"><?php echo $recurring['product_name']; ?></a></p>
<p><b><?php echo $text_quantity; ?></b> <?php echo $recurring['product_quantity']; ?></p>
<p><b><?php echo $text_order; ?></b><a href="<?php echo $recurring['order_link']; ?>">#<?php echo $order_id; ?></a></p></td>
<td class="left" style="width: 50%; vertical-align: top;"><p><b><?php echo $text_product; ?></b><a href="<?php echo $recurring['product']; ?>"><?php echo $product_name; ?></a></p>
<p><b><?php echo $text_quantity; ?></b> <?php echo $quantity; ?></p>
<p><b><?php echo $text_order_id; ?></b> <a href="<?php echo $recurring['order']; ?>">#<?php echo $order_id; ?></a></p></td>
</tr>
</tbody>
</table>
<table class="table table-bordered table-hover">
<thead>
<tr>
<td class="text-left"><?php echo $text_recurring_description; ?></td>
<td class="text-left"><?php echo $text_ref; ?></td>
<td class="text-left"><?php echo $text_reference; ?></td>
</tr>
</thead>
<tbody>
<tr>
<td class="text-left" style="width: 50%;"><p style="margin: 5px;"><?php echo $recurring['recurring_description']; ?></p></td>
<td class="text-left" style="width: 50%;"><p style="margin: 5px;"><?php echo $recurring['reference']; ?></p></td>
<td class="text-left" style="width: 50%;"><p style="margin: 5px;"><?php echo $recurring_description; ?></p></td>
<td class="text-left" style="width: 50%;"><p style="margin: 5px;"><?php echo $reference; ?></p></td>
</tr>
</tbody>
</table>
<h2><?php echo $text_transactions; ?></h2>
<h3><?php echo $text_transaction; ?></h3>
<table class="table table-bordered table-hover">
<thead>
<tr>
Expand All @@ -57,22 +57,22 @@
</tr>
</thead>
<tbody>
<?php if (!empty($recurring['transactions'])) { ?>
<?php foreach ($recurring['transactions'] as $transaction) { ?>
<?php if ($transactions) { ?>
<?php foreach ($transactions as $transaction) { ?>
<tr>
<td class="text-left"><?php echo $transaction['date_added']; ?></td>
<td class="text-center"><?php echo $transaction_types[$transaction['type']]; ?></td>
<td class="text-center"><?php echo $transaction['type']; ?></td>
<td class="text-right"><?php echo $transaction['amount']; ?></td>
</tr>
<?php } ?>
<?php }else{ ?>
<?php } else { ?>
<tr>
<td colspan="3" class="text-center"><?php echo $text_no_results; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<?php echo $buttons; ?> <?php echo $content_bottom; ?> </div>
<?php echo $column_right; ?> </div>
<?php echo $buttons; ?><?php echo $content_bottom; ?></div>
<?php echo $column_right; ?></div>
</div>
<?php echo $footer; ?>

0 comments on commit b5999b6

Please sign in to comment.