Skip to content

Commit

Permalink
Bug fixes and dysplay of order status in invoce page
Browse files Browse the repository at this point in the history
  • Loading branch information
abantecart committed Jan 3, 2014
1 parent 65204df commit 3c76278
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 19 deletions.
12 changes: 7 additions & 5 deletions public_html/storefront/controller/pages/account/invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ public function main() {
$order_info = $this->model_account_order->getOrder($order_id);

if ($order_info) {
$this->data['order_id'] = $this->request->get['order_id'];
$this->data['order_id'] = $order_id;
$this->data['invoice_id'] = $order_info['invoice_id'] ? $order_info['invoice_prefix'] . $order_info['invoice_id']:'';

$this->data['email'] = $order_info['email'];
$this->data['telephone'] = $order_info['telephone'];
$this->data['fax'] = $order_info['fax'];

$this->data['status'] = $this->model_account_order->getOrderStatus($order_id);

$shipping_data = array(
'firstname' => $order_info['shipping_firstname'],
'lastname' => $order_info['shipping_lastname'],
Expand Down Expand Up @@ -119,10 +121,10 @@ public function main() {

$products = array();

$order_products = $this->model_account_order->getOrderProducts($this->request->get['order_id']);
$order_products = $this->model_account_order->getOrderProducts($order_id);

foreach ($order_products as $product) {
$options = $this->model_account_order->getOrderOptions($this->request->get['order_id'], $product['order_product_id']);
$options = $this->model_account_order->getOrderOptions($order_id, $product['order_product_id']);

$option_data = array();

Expand All @@ -144,13 +146,13 @@ public function main() {
);
}
$this->data['products'] = $products;
$this->data['totals'] = $this->model_account_order->getOrderTotals($this->request->get['order_id']);
$this->data['totals'] = $this->model_account_order->getOrderTotals($order_id);
$this->data['comment'] = $order_info['comment'];
$this->data['product_link'] = $this->html->getSecureURL('product/product', '&product_id=%ID%');

$historys = array();

$results = $this->model_account_order->getOrderHistories($this->request->get['order_id']);
$results = $this->model_account_order->getOrderHistories($order_id);

foreach ($results as $result) {
$historys[] = array(
Expand Down
44 changes: 42 additions & 2 deletions public_html/storefront/model/account/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,27 @@ public function getOrder($order_id, $order_status_id = '') {
}

public function getOrders($start = 0, $limit = 20) {

$language_id = (int)$this->config->get('storefront_language_id');

if ($start < 0) {
$start = 0;
}

$query = $this->db->query("SELECT o.order_id, o.firstname, o.lastname, os.name as status, o.date_added, o.total, o.currency, o.value FROM `" . $this->db->table("orders") . "` o LEFT JOIN " . $this->db->table("order_statuses") . " os ON (o.order_status_id = os.order_status_id) WHERE customer_id = '" . (int)$this->customer->getId() . "' AND o.order_status_id > '0' ORDER BY o.order_id DESC LIMIT " . (int)$start . "," . (int)$limit);
$query = $this->db->query("SELECT o.order_id,
o.firstname,
o.lastname,
os.name as status,
o.date_added,
o.total,
o.currency,
o.value
FROM `" . $this->db->table("orders") . "` o
LEFT JOIN " . $this->db->table("order_statuses") . " os
ON (o.order_status_id = os.order_status_id AND os.language_id = '" . (int)$language_id . "')
WHERE customer_id = '" . (int)$this->customer->getId() . "'
AND o.order_status_id > '0'
ORDER BY o.order_id DESC LIMIT " . (int)$start . "," . (int)$limit);

return $query->rows;
}
Expand All @@ -162,8 +178,32 @@ public function getOrderTotals($order_id) {
return $query->rows;
}

public function getOrderStatus($order_id) {
$language_id = (int)$this->config->get('storefront_language_id');

$query = $this->db->query("SELECT os.name AS status
FROM " . $this->db->table("orders") . " o,
" . $this->db->table("order_statuses") . " os
WHERE o.order_id = '" . (int)$order_id . "'
AND o.order_status_id = os.order_status_id
AND os.language_id = '" . (int)$language_id . "'"
);

return $query->row['status'];
}

public function getOrderHistories($order_id) {
$query = $this->db->query("SELECT date_added, os.name AS status, oh.comment, oh.notify FROM " . $this->db->table("order_history") . " oh LEFT JOIN " . $this->db->table("order_statuses") . " os ON oh.order_status_id = os.order_status_id WHERE oh.order_id = '" . (int)$order_id . "' AND oh.notify = '1' AND os.language_id = '" . (int)$this->config->get('storefront_language_id') . "' ORDER BY oh.date_added");
$language_id = (int)$this->config->get('storefront_language_id');

$query = $this->db->query("SELECT date_added,
os.name AS status,
oh.comment,
oh.notify
FROM " . $this->db->table("order_history") . " oh
LEFT JOIN " . $this->db->table("order_statuses") . " os ON oh.order_status_id = os.order_status_id
WHERE oh.order_id = '" . (int)$order_id . "' AND oh.notify = '1'
AND os.language_id = '" . (int)$language_id . "'
ORDER BY oh.date_added");

return $query->rows;
}
Expand Down
18 changes: 10 additions & 8 deletions public_html/storefront/model/catalog/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ class ModelCatalogCategory extends Model {
* @return array
*/
public function getCategory($category_id) {
$language_id = (int)$this->config->get('storefront_language_id');
$query = $this->db->query("SELECT DISTINCT *
FROM " . DB_PREFIX . "categories c
LEFT JOIN " . DB_PREFIX . "category_descriptions cd ON (c.category_id = cd.category_id AND cd.language_id = '" . (int)$this->config->get('storefront_language_id') . "')
LEFT JOIN " . DB_PREFIX . "category_descriptions cd ON (c.category_id = cd.category_id AND cd.language_id = '" . $language_id . "')
LEFT JOIN " . DB_PREFIX . "categories_to_stores c2s ON (c.category_id = c2s.category_id)
WHERE c.category_id = '" . (int)$category_id . "'
AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "'
Expand All @@ -48,19 +49,20 @@ public function getCategory($category_id) {
* @return array
*/
public function getCategories($parent_id = 0, $limit=0) {
$language_id = (int)$this->config->get('storefront_language_id');
$cache_name = 'category.list.'. $parent_id.'.'.$limit;
$cache = $this->cache->get($cache_name, (int)$this->config->get('storefront_language_id'), (int)$this->config->get('config_store_id'));
$cache = $this->cache->get($cache_name, $language_id, (int)$this->config->get('config_store_id'));
if(is_null($cache)){
$query = $this->db->query("SELECT *
FROM " . DB_PREFIX . "categories c
LEFT JOIN " . DB_PREFIX . "category_descriptions cd ON (c.category_id = cd.category_id AND cd.language_id = '" . (int)$this->config->get('storefront_language_id') . "')
LEFT JOIN " . DB_PREFIX . "category_descriptions cd ON (c.category_id = cd.category_id AND cd.language_id = '" . $language_id . "')
LEFT JOIN " . DB_PREFIX . "categories_to_stores c2s ON (c.category_id = c2s.category_id)
WHERE ".($parent_id<0 ? "" : "c.parent_id = '" . (int)$parent_id . "' AND ")."
c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND c.status = '1'
ORDER BY c.sort_order, LCASE(cd.name)
".((int)$limit ? "LIMIT ".(int)$limit : '')." ");
$cache = $query->rows;
$this->cache->set($cache_name, $cache, (int)$this->config->get('storefront_language_id'), (int)$this->config->get('config_store_id'));
$this->cache->set($cache_name, $cache, $language_id, (int)$this->config->get('config_store_id'));
}
return $cache;
}
Expand Down Expand Up @@ -95,13 +97,13 @@ public function getTotalCategoriesByCategoryId($parent_id = 0) {
* @return array
*/
public function getCategoriesDetails($parent_id = 0, $path = '') {
$language_id = (int)$this->config->get('storefront_language_id');
$store_id = (int)$this->config->get('config_store_id');
$this->load->model('catalog/product');
$this->load->model('catalog/manufacturer');
$resource = new AResource('image');
$cash_name = 'category.details.'.$parent_id;
$categories = $this->cache->get( $cash_name,
(int)$this->config->get('storefront_language_id'),
(int)$this->config->get('config_store_id') );
$categories = $this->cache->get( $cash_name, $language_id, $store_id );
if ( count($categories) ) {
return $categories;
}
Expand Down Expand Up @@ -152,7 +154,7 @@ public function getCategoriesDetails($parent_id = 0, $path = '') {
'thumb' => $thumbnail['thumb_url'],
);
}
$this->cache->set( $cash_name, $categories, (int)$this->config->get('storefront_language_id'), (int)$this->config->get('config_store_id') );
$this->cache->set( $cash_name, $categories, $language_id, $store_id );
return $categories;
}

Expand Down
6 changes: 2 additions & 4 deletions public_html/storefront/model/checkout/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,9 @@ public function _confirm($order_id, $order_status_id, $comment = '') {
WHERE order_id = '" . (int)$order_id . "'");

foreach ($order_product_query->rows as $product) {
if ($product['subtract']) {
$this->db->query("UPDATE " . $this->db->table("products") . "
$this->db->query("UPDATE " . $this->db->table("products") . "
SET quantity = (quantity - " . (int)$product['quantity'] . ")
WHERE product_id = '" . (int)$product['product_id'] . "'");
}
WHERE product_id = '" . (int)$product['product_id'] . "' AND subtract = 1");

$order_option_query = $this->db->query("SELECT *
FROM " . $this->db->table("order_options") . "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<b><?php echo $text_order_id; ?></b><br />
#<?php echo $order_id; ?><br />
<br />
<b><?php echo $column_status; ?></b><br />
<?php echo $status; ?><br />
<br />
<b><?php echo $text_email; ?></b><br />
<?php echo $email; ?><br />
<br />
Expand Down

0 comments on commit 3c76278

Please sign in to comment.