Skip to content

Commit

Permalink
Restored attributes and customer approvals
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCartpenter committed Jan 20, 2024
1 parent a065499 commit e80c517
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 209 deletions.
30 changes: 21 additions & 9 deletions upload/admin/controller/catalog/attribute.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
<?php
/**
* Class Attribute
*
* @package Admin\Controller\Catalog
*/
class ControllerCatalogAttribute extends Controller {
/**
* @var array<string, string>
*/
private array $error = [];
private $error = [];

/**
* Index
Expand Down Expand Up @@ -138,6 +133,11 @@ public function delete(): void {
$this->getList();
}

/**
* Get List
*
* @return void
*/
protected function getList(): void {
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
Expand Down Expand Up @@ -255,13 +255,14 @@ protected function getList(): void {
$url .= '&order=' . $this->request->get['order'];
}

$pagination = new \Pagination();
$pagination = new Pagination();
$pagination->total = $attribute_total;
$pagination->page = $page;
$pagination->limit = $this->config->get('config_limit_admin');
$pagination->url = $this->url->link('catalog/attribute', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}', true);

$data['pagination'] = $pagination->render();

$data['results'] = sprintf($this->language->get('text_pagination'), ($attribute_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($attribute_total - $this->config->get('config_limit_admin'))) ? $attribute_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $attribute_total, ceil($attribute_total / $this->config->get('config_limit_admin')));

$data['sort'] = $sort;
Expand All @@ -274,6 +275,11 @@ protected function getList(): void {
$this->response->setOutput($this->load->view('catalog/attribute_list', $data));
}

/**
* Get Form
*
* @return void
*/
protected function getForm(): void {
$data['text_form'] = !isset($this->request->get['attribute_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');

Expand Down Expand Up @@ -340,7 +346,7 @@ protected function getForm(): void {
if (isset($this->request->post['attribute_description'])) {
$data['attribute_description'] = $this->request->post['attribute_description'];
} elseif (isset($this->request->get['attribute_id'])) {
$data['attribute_description'] = $this->model_catalog_attribute->getDescriptions($this->request->get['attribute_id']);
$data['attribute_description'] = $this->model_catalog_attribute->getAttributeDescriptions($this->request->get['attribute_id']);

Check failure on line 349 in upload/admin/controller/catalog/attribute.php

View workflow job for this annotation

GitHub Actions / tests (8.3)

Call to an undefined method Proxy<ModelCatalogAttribute>::getAttributeDescriptions().
} else {
$data['attribute_description'] = [];
}
Expand Down Expand Up @@ -372,6 +378,9 @@ protected function getForm(): void {
$this->response->setOutput($this->load->view('catalog/attribute_form', $data));
}

/**
* Validate Form
*/
protected function validateForm() {
if (!$this->user->hasPermission('modify', 'catalog/attribute')) {
$this->error['warning'] = $this->language->get('error_permission');
Expand All @@ -382,14 +391,17 @@ protected function validateForm() {
}

foreach ($this->request->post['attribute_description'] as $language_id => $value) {
if ((oc_strlen($value['name']) < 1) || (oc_strlen($value['name']) > 64)) {
if ((utf8_strlen($value['name']) < 1) || (utf8_strlen($value['name']) > 64)) {

Check failure on line 394 in upload/admin/controller/catalog/attribute.php

View workflow job for this annotation

GitHub Actions / tests (8.3)

Function utf8_strlen not found.

Check failure on line 394 in upload/admin/controller/catalog/attribute.php

View workflow job for this annotation

GitHub Actions / tests (8.3)

Function utf8_strlen not found.
$this->error['name'][$language_id] = $this->language->get('error_name');
}
}

return !$this->error;
}

/**
* Validate Delete
*/
protected function validateDelete() {
if (!$this->user->hasPermission('modify', 'catalog/attribute')) {
$this->error['warning'] = $this->language->get('error_permission');
Expand Down
18 changes: 3 additions & 15 deletions upload/admin/controller/customer/customer_approval.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<?php
/**
* Class Customer Approval
*
* @package Admin\Controller\Customer
*/
class ControllerCustomerCustomerApproval extends Controller {
/**
* @return void
Expand All @@ -26,7 +21,7 @@ public function index(): void {
}

if (isset($this->request->get['filter_customer_group_id'])) {
$filter_customer_group_id = (int)$this->request->get['filter_customer_group_id'];
$filter_customer_group_id = $this->request->get['filter_customer_group_id'];
} else {
$filter_customer_group_id = '';
}
Expand Down Expand Up @@ -78,12 +73,9 @@ public function index(): void {

$data['breadcrumbs'][] = [
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('customer/customer_approval', 'user_token=' . $this->session->data['user_token'] . $url, true)
'href' => $this->url->link('customer/customer_approval', 'user_token=' . $this->session->data['user_token'], true)
];

$data['approve'] = $this->url->link('customer/customer_approval/approve', 'user_token=' . $this->session->data['user_token'] . $url, true);
$data['deny'] = $this->url->link('customer/customer_approval/deny', 'user_token=' . $this->session->data['user_token'] . $url, true);

$data['filter_name'] = $filter_name;
$data['filter_email'] = $filter_email;
$data['filter_customer_group_id'] = $filter_customer_group_id;
Expand All @@ -92,7 +84,6 @@ public function index(): void {

$data['user_token'] = $this->session->data['user_token'];

// Customer Groups
$this->load->model('customer/customer_group');

$data['customer_groups'] = $this->model_customer_customer_group->getCustomerGroups();
Expand Down Expand Up @@ -125,7 +116,7 @@ public function customer_approval(): void {
}

if (isset($this->request->get['filter_customer_group_id'])) {
$filter_customer_group_id = (int)$this->request->get['filter_customer_group_id'];
$filter_customer_group_id = $this->request->get['filter_customer_group_id'];
} else {
$filter_customer_group_id = '';
}
Expand Down Expand Up @@ -160,7 +151,6 @@ public function customer_approval(): void {
'limit' => $this->config->get('config_limit_admin')
];

// Customer Approval
$this->load->model('customer/customer_approval');

$customer_approval_total = $this->model_customer_customer_approval->getTotalCustomerApprovals($filter_data);
Expand Down Expand Up @@ -229,7 +219,6 @@ public function approve(): void {
if (!$this->user->hasPermission('modify', 'customer/customer_approval')) {
$json['error'] = $this->language->get('error_permission');
} else {
// Customer Approval
$this->load->model('customer/customer_approval');

if ($this->request->get['type'] == 'customer') {
Expand Down Expand Up @@ -258,7 +247,6 @@ public function deny(): void {
if (!$this->user->hasPermission('modify', 'customer/customer_approval')) {
$json['error'] = $this->language->get('error_permission');
} else {
// Customer Approval
$this->load->model('customer/customer_approval');

if ($this->request->get['type'] == 'customer') {
Expand Down
78 changes: 0 additions & 78 deletions upload/admin/view/template/catalog/attribute.twig

This file was deleted.

12 changes: 6 additions & 6 deletions upload/admin/view/template/catalog/attribute_form.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
</div>
<div class="container-fluid">
{% if error_warning %}
<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}
<button type="button" class="close" data-dismiss="alert">&times;</button>
</div>
<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}
<button type="button" class="close" data-dismiss="alert">&times;</button>
</div>
{% endif %}
<div class="panel panel-default">
<div class="panel-heading">
Expand All @@ -29,8 +29,8 @@
<label class="col-sm-2 control-label">{{ entry_name }}</label>
<div class="col-sm-10">
{% for language in languages %}
<div class="input-group"><span class="input-group-addon"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}"/></span>
<input type="text" name="attribute_description[{{ language.language_id }}][name]" value="{{ attribute_description[language.language_id] ? attribute_description[language.language_id].name }}" placeholder="{{ entry_name }}" class="form-control"/>
<div class="input-group"><span class="input-group-addon"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /></span>
<input type="text" name="attribute_description[{{ language.language_id }}][name]" value="{{ attribute_description[language.language_id] ? attribute_description[language.language_id].name }}" placeholder="{{ entry_name }}" class="form-control" />
</div>
{% if error_name[language.language_id] %}
<div class="text-danger">{{ error_name[language.language_id] }}</div>
Expand Down Expand Up @@ -59,7 +59,7 @@
<div class="form-group">
<label class="col-sm-2 control-label" for="input-sort-order">{{ entry_sort_order }}</label>
<div class="col-sm-10">
<input type="text" name="sort_order" value="{{ sort_order }}" placeholder="{{ entry_sort_order }}" id="input-sort-order" class="form-control"/>
<input type="text" name="sort_order" value="{{ sort_order }}" placeholder="{{ entry_sort_order }}" id="input-sort-order" class="form-control" />
</div>
</div>
</form>
Expand Down
Loading

0 comments on commit e80c517

Please sign in to comment.