Skip to content

Commit

Permalink
Merge pull request #25 from wuunder/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
TimD90 authored Jul 3, 2019
2 parents 3c33fcf + fce758c commit c38244b
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 75 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ Please file changes under `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed` o
The format is based on [Keep a Changelog](http://keepachangelog.com/).
## Unreleased


## Released

## [1.3.1](https://github.com/kabisa/wuunder-webshopplugin-prestashop/releases/tag/1.3.1)

### Changed
- Moved html from php to template [#24](https://github.com/wuunder/wuunder-webshopplugin-prestashop/pull/24)

## [1.3.0](https://github.com/kabisa/wuunder-webshopplugin-prestashop/releases/tag/1.3.0)

### Fixed
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ More info regarding the installation: https://wearewuunder.com/eenvoudig-prestas
* With this module you connect your Prestashop store to your Wuunder account.

## Install ##

* Download a release .zip from this repository. If you are not familiar with composer, download the -composer-installed.zip version.
* Use FTP to transfer the .zip to the module folder located inside the installation folder of your prestashop web install and unpack.

* Navigate to __Modules and Services__->__Modules and Services__ and scroll down until you find __Wuunder shipping module__.
* To enable and edit __Wuunder shipping module__ click on install to the right.
* Fill in the form.
Expand Down
105 changes: 34 additions & 71 deletions wuunderconnector/classes/WuunderCarrier.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
<?php
/**
* NOTICE OF LICENSE
*
* This file is licenced under the Software License Agreement.
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* You must not modify, adapt or create derivative works of this source code
*
* @author Wuunder Nederland BV
* @copyright 2015-2019 Wuunder Holding B.V.
* @license LICENSE.txt
* @author Wuunder Nederland BV
* @copyright 2015-2019 Wuunder Holding B.V.
* @license LICENSE.txt
*/

// Avoid direct access to the file
Expand Down Expand Up @@ -200,7 +188,7 @@ public static function installExternalCarrier($config)
} else {
foreach ($groups as $group) {
Db::getInstance()->insert('carrier_group', array('id_carrier' => (int)($carrier->id), 'id_group' => (int)($group['id_group'])));
}
}
}

$rangePrice = new RangePrice();
Expand All @@ -227,7 +215,7 @@ public static function installExternalCarrier($config)
Db::getInstance()->insert('carrier_zone', array('id_carrier' => (int)($carrier->id), 'id_zone' => (int)($zone['id_zone'])));
Db::getInstance()->update('delivery', array('id_carrier' => (int)($carrier->id), 'id_range_price' => (int)($rangePrice->id), 'id_range_weight' => null, 'id_zone' => (int)($zone['id_zone']), 'price' => pSQL('0')));
Db::getInstance()->update('delivery', array('id_carrier' => (int)($carrier->id), 'id_range_price' => pSQL(null), 'id_range_weight' => (int)($rangeWeight->id), 'id_zone' => (int)($zone['id_zone']), 'price' => pSQL('0')));
}
}
}

// Copy Logo
Expand All @@ -247,69 +235,43 @@ public static function installExternalCarrier($config)

public function getContent()
{
$this->_html .= '<h2>' . $this->l('My Carrier') . '</h2>';
$postResponse = "";
if (!empty($_POST) and Tools::isSubmit('submitSave')) {
$this->_postValidation();
if (!sizeof($this->_postErrors)) {
$this->_postProcess();
} else {
foreach ($this->_postErrors as $err) {
$this->_html .= '<div class="alert error"><img src="' . _PS_IMG_ . 'admin/forbbiden.gif" alt="nok" />&nbsp;' . $err . '</div>';
}
$postResponse = $this->_postProcess();
}
}
$this->_displayForm();
return $this->_html;
}

private function _displayForm()
{
$this->_html .= '<fieldset>
<legend><img src="' . $this->_path . 'logo.gif" alt="" /> ' . $this->l('My Carrier Module Status') . '</legend>';

$alert = array();
$alert = false;
if (!Configuration::get('MYCARRIER1_OVERCOST') || Configuration::get('MYCARRIER1_OVERCOST') == '') {
$alert['carrier1'] = 1;
$alert = true;
}


if (!count($alert)) {
$this->_html .= '<img src="' . _PS_IMG_ . 'admin/module_install.png" /><strong>' . $this->l('My Carrier is configured and online!') . '</strong>';
} else {
$this->_html .= '<img src="' . _PS_IMG_ . 'admin/warn2.png" /><strong>' . $this->l('My Carrier is not configured yet, please:') . '</strong>';
$this->_html .= '<br />' . (isset($alert['carrier1']) ? '<img src="' . _PS_IMG_ . 'admin/warn2.png" />' : '<img src="' . _PS_IMG_ . 'admin/module_install.png" />') . ' 1) ' . $this->l('Configure the carrier 1 overcost');
}

$this->_html .= '</fieldset><div class="clear">&nbsp;</div>
<style>
#tabList { clear: left; }
.tabItem { display: block;
background: #FFFFF0; border: 1px solid #CCCCCC;
padding: 10px; padding-top: 20px; }
</style>
<div id="tabList">
<div class="tabItem">
<form action="index.php?tab=' . Tools::getValue('tab') . '&configure=' . Tools::getValue('configure') . '&token=' . Tools::getValue('token') . '&tab_module=' . Tools::getValue('tab_module') . '&module_name=' . Tools::getValue('module_name') . '&id_tab=1&section=general" method="post" class="form" id="configForm">
<fieldset style="border: 0px;">
<h4>' . $this->l('General configuration') . ' :</h4>
<label>' . $this->l('My Carrier1 overcost') . ' : </label>
<div class="margin-form">
<input type="text" size="20" name="mycarrier1_overcost" value="' . Tools::getValue('mycarrier1_overcost', Configuration::get('MYCARRIER1_OVERCOST')) . '" /></div>
<label>' . $this->l('My Carrier2 overcost') . ' : </label>
<div class="margin-form">
<input type="text" size="20" name="mycarrier2_overcost" value="' . Tools::getValue('mycarrier2_overcost', Configuration::get('MYCARRIER2_OVERCOST')) . '" />
</div>
</div>
<br /><br />
</fieldset>
<div class="margin-form">
<input class="button" name="submitSave" type="submit">
</div>
</form>
</div></div>';
Context::getContext()->smarty->assign(
array(
'title' => $this->l('My Carrier'),
'errors' => $this->_postErrors,
'postResponse' => $postResponse,
'psimg' => _PS_IMG_,
'path' => self . _path,
'carrierStatus' => $this->l('My Carrier Module Status'),
'alert' => $alert,
'isConfigured' => $this->l('My Carrier is configured and online!'),
'isNotConfigured' => $this->l('My Carrier is not configured yet, please:'),
'pleaseConfigure' => $this->l('Configure the carrier 1 overcost'),
'formAction' => "index.php?tab=" . Tools::getValue('tab') . '&configure=' . Tools::getValue('configure') . '&token=' . Tools::getValue('token') . '&tab_module=' . Tools::getValue('tab_module') . '&module_name=' . Tools::getValue('module_name') . "&id_tab=1&section=general",
'generalConf' => $this->l('General configuration'),
'mycarrier1' => $this->l('My Carrier1 overcost'),
'mycarrier2' => $this->l('My Carrier2 overcost'),
'mycarrier1value' => Tools::getValue('mycarrier1_overcost', Configuration::get('MYCARRIER1_OVERCOST')),
'mycarrier2value' => Tools::getValue('mycarrier2_overcost', Configuration::get('MYCARRIER2_OVERCOST')),
)
);
// Context::getContext()->smarty->display('WuunderCarrierContent.tpl');
}


private function _postValidation()
{
// Check configuration values
Expand All @@ -324,11 +286,12 @@ private function _postProcess()
{
// Saving new configurations
if (Configuration::updateValue('MYCARRIER1_OVERCOST', Tools::getValue('mycarrier1_overcost'))) {
$this->_html .= $this->displayConfirmation($this->l('Settings updated'));
return $this->displayConfirmation($this->l('Settings updated'));
} else {
$this->_html .= $this->displayErrors($this->l('Settings failed'));
return $this->displayErrors($this->l('Settings failed'));
}
}

/*
** Front Methods
**
Expand Down
2 changes: 1 addition & 1 deletion wuunderconnector/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>wuunderconnector</name>
<displayName><![CDATA[Wuunder shipping module]]></displayName>
<version><![CDATA[1.2.7]]></version>
<version><![CDATA[1.3.1]]></version>
<description><![CDATA[Send and receive your shipments easily, personally and efficiently. You can ship via more then 23 carriers. Wuunder takes care of all your transport and warehouse solutions you need.]]></description>
<author><![CDATA[Wuunder]]></author>
<tab><![CDATA[shipping_logistics]]></tab>
Expand Down
3 changes: 2 additions & 1 deletion wuunderconnector/controllers/admin/AdminWuunderConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* @license LICENSE.txt
*/

if (!defined('_PS_VERSION_')) {
exit;
}
Expand Down Expand Up @@ -367,7 +368,7 @@ public function initContent()
Context::getContext()->smarty->registerPlugin("function", "order_state", array($this, 'getOrderState'));
Context::getContext()->smarty->assign(
array(
'version' => floatval(_PS_VERSION_),
'version' => (float)_PS_VERSION_,
'order_info' => $order_info,
'admin_url' => ((_PS_VERSION_ < '1.7') ? _PS_BASE_URL_ . __PS_BASE_URI__ . end($path) . "/" : "") . $link->getAdminLink('AdminWuunderConnector', true),)
);
Expand Down
1 change: 1 addition & 0 deletions wuunderconnector/controllers/front/wuunderwebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @license LICENSE.txt
*/

if (!defined('_PS_VERSION_')) {
exit;
}
Expand Down
55 changes: 55 additions & 0 deletions wuunderconnector/views/templates/admin/WuunderCarrierContent.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<h2>{$title}</h2>
{foreach from=$errors item=error}
<div class="alert error"><img src="{$psimg}admin/forbbiden.gif" alt="nok"/>&nbsp;{$error}</div>
{/foreach}
{$postResponse}
<fieldset>
<legend><img src="{$path}logo.gif" alt=""/> {$carrierStatus}</legend>

{if $alert}
<img src="{$psimg}admin/module_install.png"/>
<strong>{$isConfigured}</strong>
{else}
<img src="{$psimg}admin/warn2.png"/>
<strong>{$isNotConfigured}</strong>
<br/>
<img src="{$psimg}admin/warn2.png"/>
{$pleaseConfigure}
{/if}

</fieldset>
<div class="clear">&nbsp;</div>
<style>
#tabList {
clear: left;
}
.tabItem {
display: block;
background: #FFFFF0;
border: 1px solid #CCCCCC;
padding: 10px;
padding-top: 20px;
}
</style>
<div id="tabList">
<div class="tabItem">
<form action="{$formAction}" method="post" class="form" id="configForm">

<fieldset style="border: 0px;">
<h4>{$generalConf} :</h4>
<label>{$mycarrier1} : </label>
<div class="margin-form">
<input type="text" size="20" name="mycarrier1_overcost" value="{$mycarrier1value}"/></div>
<label>{$mycarrier2}' : </label>
<div class="margin-form">
<input type="text" size="20" name="mycarrier2_overcost" value="{$mycarrier2value}"/>
</div>
</div>
<br/><br/>
</fieldset>
<div class="margin-form">
<input class="button" name="submitSave" type="submit">
</div>
</form>
</div>
7 changes: 5 additions & 2 deletions wuunderconnector/wuunderconnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
if (_PS_VERSION_ < '1.7') {
require_once 'vendor/autoload.php';
}
require_once 'classes/WuunderCarrier.php';
$modulePath = _PS_MODULE_DIR_ . '/wuunderconnector/';
require_once $modulePath . 'classes/WuunderCarrier.php';

class WuunderConnector extends Module
{
Expand All @@ -49,7 +50,9 @@ public function __construct()
{
$this->name = 'wuunderconnector';
$this->tab = 'shipping_logistics';
$this->version = '1.3.0';

$this->version = '1.3.1';

$this->author = 'Wuunder';
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
Expand Down

0 comments on commit c38244b

Please sign in to comment.