Skip to content

Commit

Permalink
OpenCart 3 admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Quoc Dat Pham committed Aug 29, 2017
1 parent 6705afb commit 61653a9
Show file tree
Hide file tree
Showing 12 changed files with 541 additions and 248 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,74 +20,25 @@ public function index()
$this->load->model('setting/setting');

// Load language
$this->load->language('extension/payment/lemonway');
$this->variables = $this->load->language('extension/payment/lemonway');
$this->document->setTitle($this->language->get('heading_title'));

// If POST request => validate the data before saving
if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
// Edit settings
$this->model_setting_setting->editSetting('lemonway', $this->request->post);
}

// Load language variables
$this->variables['heading_title'] = $this->language->get('heading_title');
$this->variables['button_save'] = $this->language->get('button_save');
$this->variables['button_cancel'] = $this->language->get('button_cancel');

// Text
// ABOUT US
$this->variables['text_secured_solution'] = $this->language->get('text_secured_solution');
$this->variables['text_commission'] = $this->language->get('text_commission');
$this->variables['text_sign_in'] = $this->language->get('text_sign_in');
$this->variables['text_create_account_title'] = $this->language->get('text_create_account_title');
$this->variables['text_create_account_step_1'] = $this->language->get('text_create_account_step_1');
$this->variables['text_sign_up'] = $this->language->get('text_sign_up');
$this->variables['text_create_account_step_2'] = $this->language->get('text_create_account_step_2');
$this->variables['text_create_account_step_3'] = $this->language->get('text_create_account_step_3');
$this->variables['text_help_desk'] = $this->language->get('text_help_desk');
$this->variables['text_turnkey_solution'] = $this->language->get('text_turnkey_solution');
$this->variables['text_secured_payments_title'] = $this->language->get('text_secured_payments_title');
$this->variables['text_secured_payments_content'] = $this->language->get('text_secured_payments_content');
$this->variables['text_manage_transaction_title'] = $this->language->get('text_manage_transaction_title');
$this->variables['text_manage_transaction_content'] = $this->language->get('text_manage_transaction_content');
$this->variables['text_more_information'] = $this->language->get('text_more_information');
$this->variables['text_or'] = $this->language->get('text_or');
$this->variables['text_support_link'] = $this->language->get('text_support_link');

// CONFIGURATION
$this->variables['text_account_configuration'] = $this->language->get('text_account_configuration');
$this->variables['text_login'] = $this->language->get('text_login');
$this->variables['text_help_login'] = $this->language->get('text_help_login');
$this->variables['text_password'] = $this->language->get('text_password');
$this->variables['text_masked'] = $this->language->get('text_masked');
$this->variables['text_help_password'] = $this->language->get('text_help_password');
$this->variables['text_test_mode'] = $this->language->get('text_test_mode');
$this->variables['text_help_test_mode'] = $this->language->get('text_help_test_mode');
$this->variables['text_advanced_configuration'] = $this->language->get('text_advanced_configuration');
$this->variables['text_css'] = $this->language->get('text_css');
$this->variables['text_help_css'] = $this->language->get('text_help_css');
$this->variables['text_debug_mode'] = $this->language->get('text_debug_mode');
$this->variables['text_custom_environment'] = $this->language->get('text_custom_environment');
$this->variables['text_environment_name'] = $this->language->get('text_environment_name');
$this->variables['text_wallet'] = $this->language->get('text_wallet');

// CREDIT CARD
$this->variables['text_method_configuration'] = $this->language->get('text_method_configuration');
$this->variables['text_enabled'] = $this->language->get('text_enabled');
$this->variables['text_oneclick'] = $this->language->get('text_oneclick');
$this->variables['text_help_oneclick'] = $this->language->get('text_help_oneclick');

// Tab
$this->variables['tab_about_us'] = $this->language->get('tab_about_us');
$this->variables['tab_configuration'] = $this->language->get('tab_configuration');
$this->variables['tab_cc'] = $this->language->get('tab_cc');

// Load default layout
$this->variables['header'] = $this->load->controller('common/header');
$this->variables['column_left'] = $this->load->controller('common/column_left');
$this->variables['footer'] = $this->load->controller('common/footer');
$this->variables['cancel_link'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'], true);

$this->document->setTitle($this->language->get('heading_title'));

if (isset($this->session->data['user_token'])) { // OpenCart 3
$this->variables['cancel_link'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true);
} else { // OpenCart 2
$this->variables['cancel_link'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true);
}

// Load setting values
$this->variables['lemonway_api_login'] = $this->model_setting_setting->getSettingValue('lemonway_api_login');
Expand All @@ -101,39 +52,41 @@ public function index()
$this->variables['lemonway_oneclick_enabled'] = $this->model_setting_setting->getSettingValue('lemonway_oneclick_enabled');

// Alerts
$this->variables['no_permission'] = false;
$this->variables['no_method'] = false;
$this->variables['success'] = false;
$this->variables['api_error'] = false;

if ($this->variables['lemonway_status']) { // If enabled
// If Test mode
if ($this->variables['lemonway_is_test_mode']) {
$this->variables['error_test_mode'] = $this->language->get('error_test_mode');
}

// Test the configuration
// Test the config
if ($this->testConfig()) {
$this->variables['error_success'] = $this->language->get('error_success');
$this->variables['success'] = true;
}
} else { // If no method enabled
$this->variables['error_no_method'] = $this->language->get('error_no_method');
$this->variables['no_method'] = true;
}

$this->variables['error_custom_env'] = $this->language->get('error_custom_env');

// Load tabs
// About us
$this->variables['about_us'] = $this->load->view('extension/payment/lemonway_aboutus.tpl', $this->variables);
$this->variables['about_us'] = $this->load->view('extension/payment/lemonway_aboutus', $this->variables);
// Configuration
$this->variables['configure'] = $this->load->view('extension/payment/lemonway_configure.tpl', $this->variables);
$this->variables['config'] = $this->load->view('extension/payment/lemonway_config', $this->variables);
// Credit Card
$this->variables['cc'] = $this->load->view('extension/payment/lemonway_cc.tpl', $this->variables);
$this->variables['cc'] = $this->load->view('extension/payment/lemonway_cc', $this->variables);

$this->response->setOutput($this->load->view('extension/payment/lemonway.tpl', $this->variables));
$this->response->setOutput($this->load->view('extension/payment/lemonway', $this->variables));
}

private function validate()
{
$error = false;

if (!$this->user->hasPermission('modify', 'extension/payment/lemonway')) {
$this->variables['error_permission'] = $this->language->get('error_permission');
$this->variables['no_permission'] = true;
$error = true;
}

Expand Down Expand Up @@ -180,7 +133,7 @@ private function validate()
return !$error; // If no error => validated
}

// Test if the configuration is OK
// Test if the config is OK
private function testConfig()
{
// Load settings
Expand Down Expand Up @@ -225,6 +178,7 @@ private function testConfig()

if (isset($res->E)) {
$this->variables['error_api'] = $this->language->get('error_api') . " - " . $lemonwayService->printError($res->E);
$this->variables['api_error'] = true;
return false;
} else {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
$_['text_support_link'] = 'https://lemonway.zendesk.com/hc/en-gb/';

// CONFIGURATION
$_['text_account_configuration'] = 'ACCOUNT CONFIGURATION';
$_['text_account_config'] = 'ACCOUNT CONFIGURATION';
$_['text_login'] = 'Login Lemon Way for E-commerce';
$_['text_help_login'] = '<a href="https://www.lemonway.com/ecommerce/" target="_blank">Create an account</a>';
$_['text_password'] = 'Password Lemon Way for E-commerce';
$_['text_masked'] = 'Masked';
$_['text_help_password'] = '<a href="https://ecommerce.lemonway.com/en/seller/lost-password" target="_blank">Forgotten password?</a>';
$_['text_test_mode'] = 'Test mode';
$_['text_help_test_mode'] = '<a href="https://lemonway.zendesk.com/hc/en-gb/articles/115004064525-2-How-do-I-test-with-the-OpenCart-module-" target="_blank">Click here to see how to use Test mode</a>';
$_['text_advanced_configuration'] = 'ADVANCED CONFIGURATION';
$_['text_advanced_config'] = 'ADVANCED CONFIGURATION';
$_['text_css'] = 'CSS URL';
$_['text_help_css'] = 'Customise the stylesheet of the payment page (Notice: If your website is in https, the CSS URL has to be in https too)';
$_['text_debug_mode'] = 'Debug Mode';
Expand All @@ -41,13 +41,13 @@
$_['text_wallet'] = 'Technical wallet name';

// CREDIT CARD
$_['text_method_configuration'] = 'METHOD CONFIGURATION ';
$_['text_method_config'] = 'METHOD CONFIGURATION ';
$_['text_oneclick'] = 'One-click';
$_['text_help_oneclick'] = 'Display One-click form when check out';

// Tab
$_['tab_about_us'] = 'ABOUT US';
$_['tab_configuration'] = 'CONFIGURATION';
$_['tab_config'] = 'CONFIGURATION';
$_['tab_cc'] = 'CREDIT CARD';

// Error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@

<div class="container-fluid">
<!-- Alerts -->
<?php if (isset($error_permission)) { ?>
<?php if ($no_permission) { ?>
<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?= $error_permission ?></div>
<?php } ?>

<?php if (isset($error_no_method)) { ?>
<?php if ($no_method) { ?>
<div class="alert alert-warning"><i class="fa fa-exclamation-triangle"></i> <?= $error_no_method ?>
<button type="button" class="close" data-dismiss="alert">&times;</button>
</div>
<?php } ?>

<?php if (isset($error_test_mode)) { ?>
<?php if ($lemonway_is_test_mode) { ?>
<div class="alert alert-warning"><i class="fa fa-exclamation-triangle"></i> <?= $error_test_mode ?>
<button type="button" class="close" data-dismiss="alert">&times;</button>
</div>
<?php } ?>

<?php if (isset($error_success)) { ?>
<?php if ($success) { ?>
<div class="alert alert-success"><i class="fa fa-check-circle"></i> <?= $error_success ?>
<button type="button" class="close" data-dismiss="alert">&times;</button>
</div>
<?php } ?>

<?php if (isset($error_api)) { ?>
<?php if ($api_error) { ?>
<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?= $error_api ?></div>
<?php } ?>
<!-- End alerts -->
Expand All @@ -47,14 +47,14 @@
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist" data-tabs="tabs">
<li class="active"><a id="aboutus_tab" href="#aboutus" role="tab" data-toggle="tab"><i class="fa fa-info-circle"></i> <?= $tab_about_us ?></a></li>
<li><a id="config_tab" href="#config" role="tab" data-toggle="tab"><i class="fa fa-cog"></i> <?= $tab_configuration ?></a></li>
<li><a id="config_tab" href="#config" role="tab" data-toggle="tab"><i class="fa fa-cog"></i> <?= $tab_config ?></a></li>
<li><a id="cc_tab" href="#cc" role="tab" data-toggle="tab"><i class="fa fa-credit-card"></i> <?= $tab_cc ?></a></li>
</ul>

<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane fade in active" id="aboutus"><?= $about_us ?></div>
<div class="tab-pane fade" id="config"><?= $configure ?></div>
<div class="tab-pane fade" id="config"><?= $config ?></div>
<div class="tab-pane fade" id="cc"><?= $cc ?></div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{{ header }}
{{ column_left }}
<div id="content">
<div class="page-header">
<div class="container-fluid">
<div class="pull-right">
<button type="submit" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button>
<a href="{{ cancel_link }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a>
</div>
<h1>{{ heading_title }}</h1>
</div>
</div>

<div class="container-fluid">
<!-- Alerts -->
{% if no_permission %}
<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> {{ error_permission }}</div>
{% endif %}

{% if no_method %}
<div class="alert alert-warning"><i class="fa fa-exclamation-triangle"></i> {{ error_no_method }}
<button type="button" class="close" data-dismiss="alert">&times;</button>
</div>
{% endif %}

{% if lemonway_is_test_mode %}
<div class="alert alert-warning"><i class="fa fa-exclamation-triangle"></i> {{ error_test_mode }}
<button type="button" class="close" data-dismiss="alert">&times;</button>
</div>
{% endif %}

{% if success %}
<div class="alert alert-success"><i class="fa fa-check-circle"></i> {{ error_success }}
<button type="button" class="close" data-dismiss="alert">&times;</button>
</div>
{% endif %}

{% if api_error %}
<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> {{ error_api }}</div>
{% endif %}
<!-- End alerts -->

<div class="panel panel-default">
<div class="panel-body">
<form id="form-lemonway" class="form-horizontal" method="post" enctype="multipart/form-data">
<div role="tabpanel">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist" data-tabs="tabs">
<li class="active"><a id="aboutus_tab" href="#aboutus" role="tab" data-toggle="tab"><i class="fa fa-info-circle"></i> {{ tab_about_us }}</a></li>
<li><a id="config_tab" href="#config" role="tab" data-toggle="tab"><i class="fa fa-cog"></i> {{ tab_config }}</a></li>
<li><a id="cc_tab" href="#cc" role="tab" data-toggle="tab"><i class="fa fa-credit-card"></i> {{ tab_cc }}</a></li>
</ul>

<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane fade in active" id="aboutus">{{ about_us }}</div>
<div class="tab-pane fade" id="config">{{ config }}</div>
<div class="tab-pane fade" id="cc">{{ cc }}</div>
</div>
</div>
</form>
<div class="text-right">
<small>v{{ constant('LEMONWAY_VERSION') }}</small>
</div>
</div>
</div>
</div>
</div>
<!-- </div> -->
{{ footer }}

<script>
$(function()
{
// Show config tab
$("#config_link").click(function(e)
{
e.preventDefault();
$("#config_tab").tab('show');
});
// Show cc tab
$("#cc_link").click(function(e)
{
e.preventDefault();
$("#cc_tab").tab('show');
});
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<?= $text_manage_transaction_content ?>
</dd>
</dl>
<img src="view/image/payment/bo-screenshot.png" alt="Back office screenshot" class="col-xs-10" id="bo-screenshot" />
<img src="view/image/payment/bo-screenshot.png" alt="Back office screenshot" class="img-responsive" id="bo-screenshot" />
</div>
</div>

Expand Down
Loading

0 comments on commit 61653a9

Please sign in to comment.