Source Code Opencart
Source Code Opencart
SOURCE CODE
Category.php
<?php
class ControllerCatalogCategory extends Controller {
private $error = array();
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('catalog/category');
$this->getList();
}
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('catalog/category');
$this->session->data['success'] = $this->language->get('text_success');
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->response->redirect($this->url->link('catalog/category', 'user_token='
. $this->session->data['user_token'] . $url, true));
}
$this->getForm();
}
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('catalog/category');
$this->session->data['success'] = $this->language->get('text_success');
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->response->redirect($this->url->link('catalog/category', 'user_token='
. $this->session->data['user_token'] . $url, true));
}
$this->getForm();
}
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('catalog/category');
if (isset($this->request->post['selected']) && $this->validateDelete()) {
foreach ($this->request->post['selected'] as $category_id) {
$this->model_catalog_category->deleteCategory($category_id);
}
$this->session->data['success'] = $this->language->get('text_success');
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->response->redirect($this->url->link('catalog/category', 'user_token='
. $this->session->data['user_token'] . $url, true));
}
$this->getList();
}
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('catalog/category');
if ($this->validateRepair()) {
$this->model_catalog_category->repairCategories();
$this->session->data['success'] = $this->language->get('text_success');
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->response->redirect($this->url->link('catalog/category', 'user_token='
. $this->session->data['user_token'] . $url, true));
}
$this->getList();
}
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
} else {
$order = 'ASC';
}
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/dashboard', 'user_token=' . $this-
>session->data['user_token'], true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('catalog/category', 'user_token=' . $this->session-
>data['user_token'] . $url, true)
);
$data['categories'] = array();
$filter_data = array(
'sort' => $sort,
'order' => $order,
'start' => ($page - 1) * $this->config->get('config_limit_admin'),
'limit' => $this->config->get('config_limit_admin')
);
$category_total = $this->model_catalog_category->getTotalCategories();
$results = $this->model_catalog_category->getCategories($filter_data);
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->session->data['success'])) {
$data['success'] = $this->session->data['success'];
unset($this->session->data['success']);
} else {
$data['success'] = '';
}
if (isset($this->request->post['selected'])) {
$data['selected'] = (array)$this->request->post['selected'];
} else {
$data['selected'] = array();
}
$url = '';
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
$data['pagination'] = $pagination->render();
$data['results'] = sprintf($this->language->get('text_pagination'),
($category_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 :
0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($category_total -
$this->config->get('config_limit_admin'))) ? $category_total : ((($page - 1) *
$this->config->get('config_limit_admin')) + $this->config-
>get('config_limit_admin')), $category_total, ceil($category_total / $this->config-
>get('config_limit_admin')));
$data['sort'] = $sort;
$data['order'] = $order;
$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
$this->response->setOutput($this->load->view('catalog/category_list',
$data));
}
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->error['name'])) {
$data['error_name'] = $this->error['name'];
} else {
$data['error_name'] = array();
}
if (isset($this->error['meta_title'])) {
$data['error_meta_title'] = $this->error['meta_title'];
} else {
$data['error_meta_title'] = array();
}
if (isset($this->error['keyword'])) {
$data['error_keyword'] = $this->error['keyword'];
} else {
$data['error_keyword'] = '';
}
if (isset($this->error['parent'])) {
$data['error_parent'] = $this->error['parent'];
} else {
$data['error_parent'] = '';
}
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/dashboard', 'user_token=' . $this-
>session->data['user_token'], true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('catalog/category', 'user_token=' . $this->session-
>data['user_token'] . $url, true)
);
if (!isset($this->request->get['category_id'])) {
$data['action'] = $this->url->link('catalog/category/add', 'user_token=' .
$this->session->data['user_token'] . $url, true);
} else {
$data['action'] = $this->url->link('catalog/category/edit', 'user_token=' .
$this->session->data['user_token'] . '&category_id=' . $this->request-
>get['category_id'] . $url, true);
}
$data['cancel'] = $this->url->link('catalog/category', 'user_token=' . $this-
>session->data['user_token'] . $url, true);
$data['user_token'] = $this->session->data['user_token'];
$this->load->model('localisation/language');
$data['languages'] = $this->model_localisation_language->getLanguages();
if (isset($this->request->post['category_description'])) {
$data['category_description'] = $this->request-
>post['category_description'];
} elseif (isset($this->request->get['category_id'])) {
$data['category_description'] = $this->model_catalog_category-
>getCategoryDescriptions($this->request->get['category_id']);
} else {
$data['category_description'] = array();
}
if (isset($this->request->post['path'])) {
$data['path'] = $this->request->post['path'];
} elseif (!empty($category_info)) {
$data['path'] = $category_info['path'];
} else {
$data['path'] = '';
}
if (isset($this->request->post['parent_id'])) {
$data['parent_id'] = $this->request->post['parent_id'];
} elseif (!empty($category_info)) {
$data['parent_id'] = $category_info['parent_id'];
} else {
$data['parent_id'] = 0;
}
$this->load->model('catalog/filter');
if (isset($this->request->post['category_filter'])) {
$filters = $this->request->post['category_filter'];
} elseif (isset($this->request->get['category_id'])) {
$filters = $this->model_catalog_category->getCategoryFilters($this-
>request->get['category_id']);
} else {
$filters = array();
}
$data['category_filters'] = array();
if ($filter_info) {
$data['category_filters'][] = array(
'filter_id' => $filter_info['filter_id'],
'name' => $filter_info['group'] . ' > ' . $filter_info['name']
);
}
}
$this->load->model('setting/store');
$data['stores'] = array();
$data['stores'][] = array(
'store_id' => 0,
'name' => $this->language->get('text_default')
);
$stores = $this->model_setting_store->getStores();
if (isset($this->request->post['category_store'])) {
$data['category_store'] = $this->request->post['category_store'];
} elseif (isset($this->request->get['category_id'])) {
$data['category_store'] = $this->model_catalog_category-
>getCategoryStores($this->request->get['category_id']);
} else {
$data['category_store'] = array(0);
}
if (isset($this->request->post['image'])) {
$data['image'] = $this->request->post['image'];
} elseif (!empty($category_info)) {
$data['image'] = $category_info['image'];
} else {
$data['image'] = '';
}
$this->load->model('tool/image');
if (isset($this->request->post['top'])) {
$data['top'] = $this->request->post['top'];
} elseif (!empty($category_info)) {
$data['top'] = $category_info['top'];
} else {
$data['top'] = 0;
}
if (isset($this->request->post['column'])) {
$data['column'] = $this->request->post['column'];
} elseif (!empty($category_info)) {
$data['column'] = $category_info['column'];
} else {
$data['column'] = 1;
}
if (isset($this->request->post['sort_order'])) {
$data['sort_order'] = $this->request->post['sort_order'];
} elseif (!empty($category_info)) {
$data['sort_order'] = $category_info['sort_order'];
} else {
$data['sort_order'] = 0;
}
if (isset($this->request->post['status'])) {
$data['status'] = $this->request->post['status'];
} elseif (!empty($category_info)) {
$data['status'] = $category_info['status'];
} else {
$data['status'] = true;
}
if (isset($this->request->post['category_seo_url'])) {
$data['category_seo_url'] = $this->request->post['category_seo_url'];
} elseif (isset($this->request->get['category_id'])) {
$data['category_seo_url'] = $this->model_catalog_category-
>getCategorySeoUrls($this->request->get['category_id']);
} else {
$data['category_seo_url'] = array();
}
if (isset($this->request->post['category_layout'])) {
$data['category_layout'] = $this->request->post['category_layout'];
} elseif (isset($this->request->get['category_id'])) {
$data['category_layout'] = $this->model_catalog_category-
>getCategoryLayouts($this->request->get['category_id']);
} else {
$data['category_layout'] = array();
}
$this->load->model('design/layout');
$data['layouts'] = $this->model_design_layout->getLayouts();
$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
$this->response->setOutput($this->load->view('catalog/category_form',
$data));
}
if ($this->request->post['category_seo_url']) {
$this->load->model('design/seo_url');
foreach ($this->request->post['category_seo_url'] as $store_id =>
$language) {
foreach ($language as $language_id => $keyword) {
if (!empty($keyword)) {
if (count(array_keys($language, $keyword)) > 1) {
$this->error['keyword'][$store_id][$language_id] = $this-
>language->get('error_unique');
}
$seo_urls = $this->model_design_seo_url-
>getSeoUrlsByKeyword($keyword);
foreach ($seo_urls as $seo_url) {
if (($seo_url['store_id'] == $store_id) && (!isset($this->request-
>get['category_id']) || ($seo_url['query'] != 'category_id=' . $this->request-
>get['category_id']))) {
$this->error['keyword'][$store_id][$language_id] = $this-
>language->get('error_keyword');
break;
}
}
}
}
}
}
if ($this->error && !isset($this->error['warning'])) {
$this->error['warning'] = $this->language->get('error_warning');
}
return !$this->error;
}
return !$this->error;
}
return !$this->error;
}
if (isset($this->request->get['filter_name'])) {
$this->load->model('catalog/category');
$filter_data = array(
'filter_name' => $this->request->get['filter_name'],
'sort' => 'name',
'order' => 'ASC',
'start' => 0,
'limit' => 5
);
$results = $this->model_catalog_category->getCategories($filter_data);
$sort_order = array();
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}
Product.php
<?php
class ControllerCatalogProduct extends Controller {
private $error = array();
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('catalog/product');
$this->getList();
}
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('catalog/product');
$this->session->data['success'] = $this->language->get('text_success');
$url = '';
if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request-
>get['filter_name'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request-
>get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_price'])) {
$url .= '&filter_price=' . $this->request->get['filter_price'];
}
if (isset($this->request->get['filter_quantity'])) {
$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}
if (isset($this->request->get['filter_status'])) {
$url .= '&filter_status=' . $this->request->get['filter_status'];
}
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->getForm();
}
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('catalog/product');
$this->session->data['success'] = $this->language->get('text_success');
$url = '';
if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request-
>get['filter_name'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request-
>get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_price'])) {
$url .= '&filter_price=' . $this->request->get['filter_price'];
}
if (isset($this->request->get['filter_quantity'])) {
$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}
if (isset($this->request->get['filter_status'])) {
$url .= '&filter_status=' . $this->request->get['filter_status'];
}
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->getForm();
}
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('catalog/product');
$this->session->data['success'] = $this->language->get('text_success');
$url = '';
if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request-
>get['filter_name'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request-
>get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_price'])) {
$url .= '&filter_price=' . $this->request->get['filter_price'];
}
if (isset($this->request->get['filter_quantity'])) {
$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}
if (isset($this->request->get['filter_status'])) {
$url .= '&filter_status=' . $this->request->get['filter_status'];
}
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->getList();
}
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('catalog/product');
$this->session->data['success'] = $this->language->get('text_success');
$url = '';
if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request-
>get['filter_name'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request-
>get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_price'])) {
$url .= '&filter_price=' . $this->request->get['filter_price'];
}
if (isset($this->request->get['filter_quantity'])) {
$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}
if (isset($this->request->get['filter_status'])) {
$url .= '&filter_status=' . $this->request->get['filter_status'];
}
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->getList();
}
if (isset($this->request->get['filter_model'])) {
$filter_model = $this->request->get['filter_model'];
} else {
$filter_model = '';
}
if (isset($this->request->get['filter_price'])) {
$filter_price = $this->request->get['filter_price'];
} else {
$filter_price = '';
}
if (isset($this->request->get['filter_quantity'])) {
$filter_quantity = $this->request->get['filter_quantity'];
} else {
$filter_quantity = '';
}
if (isset($this->request->get['filter_status'])) {
$filter_status = $this->request->get['filter_status'];
} else {
$filter_status = '';
}
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} else {
$sort = 'pd.name';
}
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
} else {
$order = 'ASC';
}
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
$url = '';
if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request-
>get['filter_name'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request-
>get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_price'])) {
$url .= '&filter_price=' . $this->request->get['filter_price'];
}
if (isset($this->request->get['filter_quantity'])) {
$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}
if (isset($this->request->get['filter_status'])) {
$url .= '&filter_status=' . $this->request->get['filter_status'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session-
>data['user_token'], true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('catalog/product', 'user_token=' . $this->session-
>data['user_token'] . $url, true)
);
$data['products'] = array();
$filter_data = array(
'filter_name' => $filter_name,
'filter_model' => $filter_model,
'filter_price' => $filter_price,
'filter_quantity' => $filter_quantity,
'filter_status' => $filter_status,
'sort' => $sort,
'order' => $order,
'start' => ($page - 1) * $this->config->get('config_limit_admin'),
'limit' => $this->config->get('config_limit_admin')
);
$this->load->model('tool/image');
$product_total = $this->model_catalog_product->getTotalProducts($filter_data);
$results = $this->model_catalog_product->getProducts($filter_data);
$special = false;
$product_specials = $this->model_catalog_product-
>getProductSpecials($result['product_id']);
break;
}
}
$data['products'][] = array(
'product_id' => $result['product_id'],
'image' => $image,
'name' => $result['name'],
'model' => $result['model'],
'price' => $this->currency->format($result['price'], $this->config-
>get('config_currency')),
'special' => $special,
'quantity' => $result['quantity'],
'status' => $result['status'] ? $this->language->get('text_enabled') : $this-
>language->get('text_disabled'),
'edit' => $this->url->link('catalog/product/edit', 'user_token=' . $this-
>session->data['user_token'] . '&product_id=' . $result['product_id'] . $url, true)
);
}
$data['user_token'] = $this->session->data['user_token'];
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->session->data['success'])) {
$data['success'] = $this->session->data['success'];
unset($this->session->data['success']);
} else {
$data['success'] = '';
}
if (isset($this->request->post['selected'])) {
$data['selected'] = (array)$this->request->post['selected'];
} else {
$data['selected'] = array();
}
$url = '';
if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request-
>get['filter_name'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request-
>get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_price'])) {
$url .= '&filter_price=' . $this->request->get['filter_price'];
}
if (isset($this->request->get['filter_quantity'])) {
$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}
if (isset($this->request->get['filter_status'])) {
$url .= '&filter_status=' . $this->request->get['filter_status'];
}
$url = '';
if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request-
>get['filter_name'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request-
>get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_price'])) {
$url .= '&filter_price=' . $this->request->get['filter_price'];
}
if (isset($this->request->get['filter_quantity'])) {
$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}
if (isset($this->request->get['filter_status'])) {
$url .= '&filter_status=' . $this->request->get['filter_status'];
}
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
$data['pagination'] = $pagination->render();
$data['filter_name'] = $filter_name;
$data['filter_model'] = $filter_model;
$data['filter_price'] = $filter_price;
$data['filter_quantity'] = $filter_quantity;
$data['filter_status'] = $filter_status;
$data['sort'] = $sort;
$data['order'] = $order;
$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
$this->response->setOutput($this->load->view('catalog/product_list', $data));
}
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->error['name'])) {
$data['error_name'] = $this->error['name'];
} else {
$data['error_name'] = array();
}
if (isset($this->error['meta_title'])) {
$data['error_meta_title'] = $this->error['meta_title'];
} else {
$data['error_meta_title'] = array();
}
if (isset($this->error['model'])) {
$data['error_model'] = $this->error['model'];
} else {
$data['error_model'] = '';
}
if (isset($this->error['keyword'])) {
$data['error_keyword'] = $this->error['keyword'];
} else {
$data['error_keyword'] = '';
}
$url = '';
if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request-
>get['filter_name'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request-
>get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_price'])) {
$url .= '&filter_price=' . $this->request->get['filter_price'];
}
if (isset($this->request->get['filter_quantity'])) {
$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}
if (isset($this->request->get['filter_status'])) {
$url .= '&filter_status=' . $this->request->get['filter_status'];
}
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session-
>data['user_token'], true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('catalog/product', 'user_token=' . $this->session-
>data['user_token'] . $url, true)
);
if (!isset($this->request->get['product_id'])) {
$data['action'] = $this->url->link('catalog/product/add', 'user_token=' . $this-
>session->data['user_token'] . $url, true);
} else {
$data['action'] = $this->url->link('catalog/product/edit', 'user_token=' . $this-
>session->data['user_token'] . '&product_id=' . $this->request->get['product_id'] . $url,
true);
}
$data['user_token'] = $this->session->data['user_token'];
$this->load->model('localisation/language');
$data['languages'] = $this->model_localisation_language->getLanguages();
if (isset($this->request->post['product_description'])) {
$data['product_description'] = $this->request->post['product_description'];
} elseif (isset($this->request->get['product_id'])) {
$data['product_description'] = $this->model_catalog_product-
>getProductDescriptions($this->request->get['product_id']);
} else {
$data['product_description'] = array();
}
if (isset($this->request->post['model'])) {
$data['model'] = $this->request->post['model'];
} elseif (!empty($product_info)) {
$data['model'] = $product_info['model'];
} else {
$data['model'] = '';
}
if (isset($this->request->post['sku'])) {
$data['sku'] = $this->request->post['sku'];
} elseif (!empty($product_info)) {
$data['sku'] = $product_info['sku'];
} else {
$data['sku'] = '';
}
if (isset($this->request->post['upc'])) {
$data['upc'] = $this->request->post['upc'];
} elseif (!empty($product_info)) {
$data['upc'] = $product_info['upc'];
} else {
$data['upc'] = '';
}
if (isset($this->request->post['ean'])) {
$data['ean'] = $this->request->post['ean'];
} elseif (!empty($product_info)) {
$data['ean'] = $product_info['ean'];
} else {
$data['ean'] = '';
}
if (isset($this->request->post['jan'])) {
$data['jan'] = $this->request->post['jan'];
} elseif (!empty($product_info)) {
$data['jan'] = $product_info['jan'];
} else {
$data['jan'] = '';
}
if (isset($this->request->post['isbn'])) {
$data['isbn'] = $this->request->post['isbn'];
} elseif (!empty($product_info)) {
$data['isbn'] = $product_info['isbn'];
} else {
$data['isbn'] = '';
}
if (isset($this->request->post['mpn'])) {
$data['mpn'] = $this->request->post['mpn'];
} elseif (!empty($product_info)) {
$data['mpn'] = $product_info['mpn'];
} else {
$data['mpn'] = '';
}
if (isset($this->request->post['location'])) {
$data['location'] = $this->request->post['location'];
} elseif (!empty($product_info)) {
$data['location'] = $product_info['location'];
} else {
$data['location'] = '';
}
$this->load->model('setting/store');
$data['stores'] = array();
$data['stores'][] = array(
'store_id' => 0,
'name' => $this->language->get('text_default')
);
$stores = $this->model_setting_store->getStores();
if (isset($this->request->post['product_store'])) {
$data['product_store'] = $this->request->post['product_store'];
} elseif (isset($this->request->get['product_id'])) {
$data['product_store'] = $this->model_catalog_product->getProductStores($this-
>request->get['product_id']);
} else {
$data['product_store'] = array(0);
}
if (isset($this->request->post['shipping'])) {
$data['shipping'] = $this->request->post['shipping'];
} elseif (!empty($product_info)) {
$data['shipping'] = $product_info['shipping'];
} else {
$data['shipping'] = 1;
}
if (isset($this->request->post['price'])) {
$data['price'] = $this->request->post['price'];
} elseif (!empty($product_info)) {
$data['price'] = $product_info['price'];
} else {
$data['price'] = '';
}
$this->load->model('catalog/recurring');
$data['recurrings'] = $this->model_catalog_recurring->getRecurrings();
if (isset($this->request->post['product_recurrings'])) {
$data['product_recurrings'] = $this->request->post['product_recurrings'];
} elseif (!empty($product_info)) {
$data['product_recurrings'] = $this->model_catalog_product-
>getRecurrings($product_info['product_id']);
} else {
$data['product_recurrings'] = array();
}
$this->load->model('localisation/tax_class');
$data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses();
if (isset($this->request->post['tax_class_id'])) {
$data['tax_class_id'] = $this->request->post['tax_class_id'];
} elseif (!empty($product_info)) {
$data['tax_class_id'] = $product_info['tax_class_id'];
} else {
$data['tax_class_id'] = 0;
}
if (isset($this->request->post['date_available'])) {
$data['date_available'] = $this->request->post['date_available'];
} elseif (!empty($product_info)) {
$data['date_available'] = ($product_info['date_available'] != '0000-00-00') ?
$product_info['date_available'] : '';
} else {
$data['date_available'] = date('Y-m-d');
}
if (isset($this->request->post['quantity'])) {
$data['quantity'] = $this->request->post['quantity'];
} elseif (!empty($product_info)) {
$data['quantity'] = $product_info['quantity'];
} else {
$data['quantity'] = 1;
}
if (isset($this->request->post['minimum'])) {
$data['minimum'] = $this->request->post['minimum'];
} elseif (!empty($product_info)) {
$data['minimum'] = $product_info['minimum'];
} else {
$data['minimum'] = 1;
}
if (isset($this->request->post['subtract'])) {
$data['subtract'] = $this->request->post['subtract'];
} elseif (!empty($product_info)) {
$data['subtract'] = $product_info['subtract'];
} else {
$data['subtract'] = 1;
}
if (isset($this->request->post['sort_order'])) {
$data['sort_order'] = $this->request->post['sort_order'];
} elseif (!empty($product_info)) {
$data['sort_order'] = $product_info['sort_order'];
} else {
$data['sort_order'] = 1;
}
$this->load->model('localisation/stock_status');
$data['stock_statuses'] = $this->model_localisation_stock_status-
>getStockStatuses();
if (isset($this->request->post['stock_status_id'])) {
$data['stock_status_id'] = $this->request->post['stock_status_id'];
} elseif (!empty($product_info)) {
$data['stock_status_id'] = $product_info['stock_status_id'];
} else {
$data['stock_status_id'] = 0;
}
if (isset($this->request->post['status'])) {
$data['status'] = $this->request->post['status'];
} elseif (!empty($product_info)) {
$data['status'] = $product_info['status'];
} else {
$data['status'] = true;
}
if (isset($this->request->post['weight'])) {
$data['weight'] = $this->request->post['weight'];
} elseif (!empty($product_info)) {
$data['weight'] = $product_info['weight'];
} else {
$data['weight'] = '';
}
$this->load->model('localisation/weight_class');
$data['weight_classes'] = $this->model_localisation_weight_class-
>getWeightClasses();
if (isset($this->request->post['weight_class_id'])) {
$data['weight_class_id'] = $this->request->post['weight_class_id'];
} elseif (!empty($product_info)) {
$data['weight_class_id'] = $product_info['weight_class_id'];
} else {
$data['weight_class_id'] = $this->config->get('config_weight_class_id');
}
if (isset($this->request->post['length'])) {
$data['length'] = $this->request->post['length'];
} elseif (!empty($product_info)) {
$data['length'] = $product_info['length'];
} else {
$data['length'] = '';
}
if (isset($this->request->post['width'])) {
$data['width'] = $this->request->post['width'];
} elseif (!empty($product_info)) {
$data['width'] = $product_info['width'];
} else {
$data['width'] = '';
}
if (isset($this->request->post['height'])) {
$data['height'] = $this->request->post['height'];
} elseif (!empty($product_info)) {
$data['height'] = $product_info['height'];
} else {
$data['height'] = '';
}
$this->load->model('localisation/length_class');
$data['length_classes'] = $this->model_localisation_length_class-
>getLengthClasses();
if (isset($this->request->post['length_class_id'])) {
$data['length_class_id'] = $this->request->post['length_class_id'];
} elseif (!empty($product_info)) {
$data['length_class_id'] = $product_info['length_class_id'];
} else {
$data['length_class_id'] = $this->config->get('config_length_class_id');
}
$this->load->model('catalog/manufacturer');
if (isset($this->request->post['manufacturer_id'])) {
$data['manufacturer_id'] = $this->request->post['manufacturer_id'];
} elseif (!empty($product_info)) {
$data['manufacturer_id'] = $product_info['manufacturer_id'];
} else {
$data['manufacturer_id'] = 0;
}
if (isset($this->request->post['manufacturer'])) {
$data['manufacturer'] = $this->request->post['manufacturer'];
} elseif (!empty($product_info)) {
$manufacturer_info = $this->model_catalog_manufacturer-
>getManufacturer($product_info['manufacturer_id']);
if ($manufacturer_info) {
$data['manufacturer'] = $manufacturer_info['name'];
} else {
$data['manufacturer'] = '';
}
} else {
$data['manufacturer'] = '';
}
// Categories
$this->load->model('catalog/category');
if (isset($this->request->post['product_category'])) {
$categories = $this->request->post['product_category'];
} elseif (isset($this->request->get['product_id'])) {
$categories = $this->model_catalog_product->getProductCategories($this-
>request->get['product_id']);
} else {
$categories = array();
}
$data['product_categories'] = array();
if ($category_info) {
$data['product_categories'][] = array(
'category_id' => $category_info['category_id'],
'name' => ($category_info['path']) ? $category_info['path'] . ' > ' .
$category_info['name'] : $category_info['name']
);
}
}
// Filters
$this->load->model('catalog/filter');
if (isset($this->request->post['product_filter'])) {
$filters = $this->request->post['product_filter'];
} elseif (isset($this->request->get['product_id'])) {
$filters = $this->model_catalog_product->getProductFilters($this->request-
>get['product_id']);
} else {
$filters = array();
}
$data['product_filters'] = array();
if ($filter_info) {
$data['product_filters'][] = array(
'filter_id' => $filter_info['filter_id'],
'name' => $filter_info['group'] . ' > ' . $filter_info['name']
);
}
}
// Attributes
$this->load->model('catalog/attribute');
if (isset($this->request->post['product_attribute'])) {
$product_attributes = $this->request->post['product_attribute'];
} elseif (isset($this->request->get['product_id'])) {
$product_attributes = $this->model_catalog_product->getProductAttributes($this-
>request->get['product_id']);
} else {
$product_attributes = array();
}
$data['product_attributes'] = array();
if ($attribute_info) {
$data['product_attributes'][] = array(
'attribute_id' => $product_attribute['attribute_id'],
'name' => $attribute_info['name'],
'product_attribute_description' =>
$product_attribute['product_attribute_description']
);
}
}
// Options
$this->load->model('catalog/option');
if (isset($this->request->post['product_option'])) {
$product_options = $this->request->post['product_option'];
} elseif (isset($this->request->get['product_id'])) {
$product_options = $this->model_catalog_product->getProductOptions($this-
>request->get['product_id']);
} else {
$product_options = array();
}
$data['product_options'] = array();
if (isset($product_option['product_option_value'])) {
foreach ($product_option['product_option_value'] as $product_option_value) {
$product_option_value_data[] = array(
'product_option_value_id' =>
$product_option_value['product_option_value_id'],
'option_value_id' => $product_option_value['option_value_id'],
'quantity' => $product_option_value['quantity'],
'subtract' => $product_option_value['subtract'],
'price' => $product_option_value['price'],
'price_prefix' => $product_option_value['price_prefix'],
'points' => $product_option_value['points'],
'points_prefix' => $product_option_value['points_prefix'],
'weight' => $product_option_value['weight'],
'weight_prefix' => $product_option_value['weight_prefix']
);
}
}
$data['product_options'][] = array(
'product_option_id' => $product_option['product_option_id'],
'product_option_value' => $product_option_value_data,
'option_id' => $product_option['option_id'],
'name' => $product_option['name'],
'type' => $product_option['type'],
'value' => isset($product_option['value']) ? $product_option['value'] : '',
'required' => $product_option['required']
);
}
$data['option_values'] = array();
$this->load->model('customer/customer_group');
$data['customer_groups'] = $this->model_customer_customer_group-
>getCustomerGroups();
if (isset($this->request->post['product_discount'])) {
$product_discounts = $this->request->post['product_discount'];
} elseif (isset($this->request->get['product_id'])) {
$product_discounts = $this->model_catalog_product->getProductDiscounts($this-
>request->get['product_id']);
} else {
$product_discounts = array();
}
$data['product_discounts'] = array();
if (isset($this->request->post['product_special'])) {
$product_specials = $this->request->post['product_special'];
} elseif (isset($this->request->get['product_id'])) {
$product_specials = $this->model_catalog_product->getProductSpecials($this-
>request->get['product_id']);
} else {
$product_specials = array();
}
$data['product_specials'] = array();
$this->load->model('tool/image');
// Images
if (isset($this->request->post['product_image'])) {
$product_images = $this->request->post['product_image'];
} elseif (isset($this->request->get['product_id'])) {
$product_images = $this->model_catalog_product->getProductImages($this-
>request->get['product_id']);
} else {
$product_images = array();
}
$data['product_images'] = array();
$data['product_images'][] = array(
'image' => $image,
'thumb' => $this->model_tool_image->resize($thumb, 100, 100),
'sort_order' => $product_image['sort_order']
);
}
// Downloads
$this->load->model('catalog/download');
if (isset($this->request->post['product_download'])) {
$product_downloads = $this->request->post['product_download'];
} elseif (isset($this->request->get['product_id'])) {
$product_downloads = $this->model_catalog_product-
>getProductDownloads($this->request->get['product_id']);
} else {
$product_downloads = array();
}
$data['product_downloads'] = array();
if ($download_info) {
$data['product_downloads'][] = array(
'download_id' => $download_info['download_id'],
'name' => $download_info['name']
);
}
}
if (isset($this->request->post['product_related'])) {
$products = $this->request->post['product_related'];
} elseif (isset($this->request->get['product_id'])) {
$products = $this->model_catalog_product->getProductRelated($this->request-
>get['product_id']);
} else {
$products = array();
}
$data['product_relateds'] = array();
if ($related_info) {
$data['product_relateds'][] = array(
'product_id' => $related_info['product_id'],
'name' => $related_info['name']
);
}
}
if (isset($this->request->post['points'])) {
$data['points'] = $this->request->post['points'];
} elseif (!empty($product_info)) {
$data['points'] = $product_info['points'];
} else {
$data['points'] = '';
}
if (isset($this->request->post['product_reward'])) {
$data['product_reward'] = $this->request->post['product_reward'];
} elseif (isset($this->request->get['product_id'])) {
$data['product_reward'] = $this->model_catalog_product-
>getProductRewards($this->request->get['product_id']);
} else {
$data['product_reward'] = array();
}
if (isset($this->request->post['product_seo_url'])) {
$data['product_seo_url'] = $this->request->post['product_seo_url'];
} elseif (isset($this->request->get['product_id'])) {
$data['product_seo_url'] = $this->model_catalog_product-
>getProductSeoUrls($this->request->get['product_id']);
} else {
$data['product_seo_url'] = array();
}
if (isset($this->request->post['product_layout'])) {
$data['product_layout'] = $this->request->post['product_layout'];
} elseif (isset($this->request->get['product_id'])) {
$data['product_layout'] = $this->model_catalog_product-
>getProductLayouts($this->request->get['product_id']);
} else {
$data['product_layout'] = array();
}
$this->load->model('design/layout');
$data['layouts'] = $this->model_design_layout->getLayouts();
$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
$this->response->setOutput($this->load->view('catalog/product_form', $data));
}
if ($this->request->post['product_seo_url']) {
$this->load->model('design/seo_url');
foreach ($this->request->post['product_seo_url'] as $store_id => $language) {
foreach ($language as $language_id => $keyword) {
if (!empty($keyword)) {
if (count(array_keys($language, $keyword)) > 1) {
$this->error['keyword'][$store_id][$language_id] = $this->language-
>get('error_unique');
}
$seo_urls = $this->model_design_seo_url-
>getSeoUrlsByKeyword($keyword);
foreach ($seo_urls as $seo_url) {
if (($seo_url['store_id'] == $store_id) && (!isset($this->request-
>get['product_id']) || (($seo_url['query'] != 'product_id=' . $this->request-
>get['product_id'])))) {
$this->error['keyword'][$store_id][$language_id] = $this->language-
>get('error_keyword');
break;
}
}
}
}
}
}
return !$this->error;
}
return !$this->error;
}
return !$this->error;
}
if (isset($this->request->get['filter_name'])) {
$filter_name = $this->request->get['filter_name'];
} else {
$filter_name = '';
}
if (isset($this->request->get['filter_model'])) {
$filter_model = $this->request->get['filter_model'];
} else {
$filter_model = '';
}
if (isset($this->request->get['limit'])) {
$limit = $this->request->get['limit'];
} else {
$limit = 5;
}
$filter_data = array(
'filter_name' => $filter_name,
'filter_model' => $filter_model,
'start' => 0,
'limit' => $limit
);
$results = $this->model_catalog_product->getProducts($filter_data);
$product_options = $this->model_catalog_product-
>getProductOptions($result['product_id']);
if ($option_info) {
$product_option_value_data = array();
foreach ($product_option['product_option_value'] as
$product_option_value) {
$option_value_info = $this->model_catalog_option-
>getOptionValue($product_option_value['option_value_id']);
if ($option_value_info) {
$product_option_value_data[] = array(
'product_option_value_id' =>
$product_option_value['product_option_value_id'],
'option_value_id' =>
$product_option_value['option_value_id'],
'name' => $option_value_info['name'],
'price' => (float)$product_option_value['price'] ? $this-
>currency->format($product_option_value['price'], $this->config->get('config_currency'))
: false,
'price_prefix' => $product_option_value['price_prefix']
);
}
}
$option_data[] = array(
'product_option_id' => $product_option['product_option_id'],
'product_option_value' => $product_option_value_data,
'option_id' => $product_option['option_id'],
'name' => $option_info['name'],
'type' => $option_info['type'],
'value' => $product_option['value'],
'required' => $product_option['required']
);
}
}
$json[] = array(
'product_id' => $result['product_id'],
'name' => strip_tags(html_entity_decode($result['name'], ENT_QUOTES,
'UTF-8')),
'model' => $result['model'],
'option' => $option_data,
'price' => $result['price']
);
}
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}
api.php (route)
<?php
use Illuminate\Http\Request;
/*
|----------------------------------------------------------------------
----
| API Routes
|----------------------------------------------------------------------
----
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::put('/update-profile/{id}', 'EstiquentApi@updateProfile');
Route::get('/users/{cc}', 'EstiquentApi@getUser');
Route::post('/insert-user', 'EstiquentApi@storeUser');
Route::post('/login', 'EstiquentApi@loginUser');
Route::get('/user/{id}', 'EstiquentApi@showUser');
Route::put('/update-user/{id}', 'EstiquentApi@updateUser');
Route::delete('/delete-user/{id}', 'EstiquentApi@destroyUser');
Route::get('/companies', 'EstiquentApi@getCompany');
Route::post('/insert-company', 'EstiquentApi@storeCompany');
Route::get('/company/{id}', 'EstiquentApi@showCompany');
Route::put('/update-company/{id}', 'EstiquentApi@updateCompany');
Route::delete('/delete-company/{id}', 'EstiquentApi@destroyCompany');
Route::get('/warehouses/{cc}', 'EstiquentApi@getWarehouse');
Route::post('/insert-warehouse', 'EstiquentApi@storeWarehouse');
Route::get('/warehouse/{id}', 'EstiquentApi@showWarehouse');
Route::put('/update-warehouse/{id}', 'EstiquentApi@updateWarehouse');
Route::delete('/delete-warehouse/{id}',
'EstiquentApi@destroyWarehouse');
Route::get('/destinations/{cc}', 'EstiquentApi@getDestination');
Route::post('/insert-destination', 'EstiquentApi@storeDestination');
Route::get('/destination/{id}', 'EstiquentApi@showDestination');
Route::put('/update-destination/{id}',
'EstiquentApi@updateDestination');
Route::delete('/delete-destination/{id}',
'EstiquentApi@destroyDestination');
Route::get('/transactions/{cc}', 'EstiquentApi@getTransaction');
Route::post('/insert-transaction', 'EstiquentApi@storeTransaction');
Route::get('/transaction/{id}', 'EstiquentApi@showTransaction');
Route::put('/update-transaction/{id}',
'EstiquentApi@updateTransaction');
Route::delete('/delete-transaction/{id}',
'EstiquentApi@destroyTransaction');
Route::get('/costs/{cc}', 'EstiquentApi@getCost');
Route::post('/insert-cost', 'EstiquentApi@storeCost');
Route::get('/cost/{id}', 'EstiquentApi@showCost');
Route::put('/update-cost/{id}', 'EstiquentApi@updateCost');
Route::delete('/delete-cost/{id}', 'EstiquentApi@destroyCost');
web.php (route)
<?php
/*
|----------------------------------------------------------------------
----
| Web Routes
|----------------------------------------------------------------------
----
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('login');
});
Route::group(['middleware' => 'StoreSession'],function(){
// Route::get('/', 'Profile@index');
Route::get('/admin', 'Admin@index');
Route::get('/profile', 'Profile@index');
Route::get('/warehouses', 'Warehouses@index');
Route::post('/warehouses/tes', 'Warehouses@tes');
Route::get('/destinations', 'Destinations@index');
Route::get('/transactions', 'Transactions@index');
Route::get('/costs', 'Costs@index');
Route::get('/company', 'Company@index');
Route::get('/logs', 'Logs@index');
Route::get('/users', 'Users@index');
Route::get('/nwc', 'NWC@index');
});
Route::get('/register', 'Register@index');
Route::get('/session/{id}/{pw}', 'Session@index');
Route::get('/logout', 'Session@logout');
LAMPIRAN B
DATABASE APLIKASI
Users
Warehouses
Destinations
Costs
Transactions