Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion AdminIncludes/order-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</div>
<div class="panel-body">

{form name="socolissimo.export.inet"}
{form name="socolissimo.export"}
<form action="{url path="/admin/module/socolissimo/export"}" method="post">
{form_hidden_fields form=$form}
{form_field form=$form field="new_status_id"}
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2.0.0
- Bugfixes
- Domicile delivery is now deprecated and will not be updated or taken care of anymore.
Use the ColissimoWs module instead for domicile delivery, and this one for relay point.
- Change version to 2.0.0 to follow the version number of ColissimoWs

# 1.4.7
- Changing a relay point Free Shipping for a specific area does not add the price for every other area anymore.

Expand Down
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<descriptive locale="fr_FR">
<title>So Colissimo</title>
</descriptive>
<version>1.4.11</version>
<version>2.0.0</version>
<author>
<name>Thelia</name>
<email>info@thelia.net</email>
Expand Down
9 changes: 7 additions & 2 deletions Config/schema.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<database defaultIdMethod="native" name="thelia" namespace="SoColissimo\Model">

<table name="address_socolissimo">
<column name="id" primaryKey="true" required="true" type="INTEGER" />
<column name="title_id" required="true" type="INTEGER" />
Expand All @@ -22,6 +23,7 @@
<reference foreign="id" local="country_id" />
</foreign-key>
</table>

<table name="order_address_socolissimo">
<column name="id" primaryKey="true" required="true" type="INTEGER" />
<column name="code" size="10" type="VARCHAR" required="true" />
Expand All @@ -30,13 +32,15 @@
<reference foreign="id" local="id" />
</foreign-key>
</table>

<table name="socolissimo_delivery_mode">
<column name="id" primaryKey="true" autoIncrement="true" required="true" type="INTEGER" />
<column name="title" size="255" type="VARCHAR"/>
<column name="code" size="55" type="VARCHAR" required="true"/>
<column name="freeshipping_active" type="BOOLEAN"/>
<column name="freeshipping_from" type="FLOAT"/>
</table>

<table name="socolissimo_price">
<column name="id" primaryKey="true" autoIncrement="true" required="true" type="INTEGER" />
<column name="area_id" required="true" type="INTEGER" />
Expand All @@ -53,11 +57,12 @@
</foreign-key>
</table>

<!-- We need to keep this for compatibility reasons with older versions : the models are needed -->
<table name="socolissimo_area_freeshipping_dom">
<column name="id" primaryKey="true" autoIncrement="true" required="true" type="INTEGER" />
<column name="area_id" required="true" type="INTEGER" />
<column name="delivery_mode_id" required="true" type="INTEGER" />
<column name="cart_amount" defaultValue="0.000000" scale="6" size="16" type="DECIMAL" />
<column name="cart_amount" defaultValue="0.00" size="16" scale="2" type="DECIMAL" />
<foreign-key foreignTable="area" name="fk_socolissimo_area_freeshipping_dom_area_id" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference foreign="id" local="area_id" />
</foreign-key>
Expand All @@ -70,7 +75,7 @@
<column name="id" primaryKey="true" autoIncrement="true" required="true" type="INTEGER" />
<column name="area_id" required="true" type="INTEGER" />
<column name="delivery_mode_id" required="true" type="INTEGER" />
<column name="cart_amount" defaultValue="0.000000" scale="6" size="16" type="DECIMAL" />
<column name="cart_amount" defaultValue="0.00" size="16" scale="2" type="DECIMAL" />
<foreign-key foreignTable="area" name="fk_socolissimo_area_freeshipping_pr_area_id" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference foreign="id" local="area_id" />
</foreign-key>
Expand Down
2 changes: 2 additions & 0 deletions Config/sqldb.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Sqlfile -> Database map
thelia.sql=thelia
20 changes: 10 additions & 10 deletions Config/thelia.sql
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ CREATE TABLE `address_socolissimo`
`type` VARCHAR(10) NOT NULL,
`cellphone` VARCHAR(20),
PRIMARY KEY (`id`),
INDEX `FI_address_socolissimo_customer_title_id` (`title_id`),
INDEX `FI_address_socolissimo_country_id` (`country_id`),
INDEX `fi_address_socolissimo_customer_title_id` (`title_id`),
INDEX `fi_address_socolissimo_country_id` (`country_id`),
CONSTRAINT `fk_address_socolissimo_customer_title_id`
FOREIGN KEY (`title_id`)
REFERENCES `customer_title` (`id`)
Expand Down Expand Up @@ -91,8 +91,8 @@ CREATE TABLE `socolissimo_price`
`franco_min_price` FLOAT,
`price` FLOAT NOT NULL,
PRIMARY KEY (`id`),
INDEX `FI_socolissimo_price_area_id` (`area_id`),
INDEX `FI_socolissimo_price_delivery_mode_id` (`delivery_mode_id`),
INDEX `fi_socolissimo_price_area_id` (`area_id`),
INDEX `fi_socolissimo_price_delivery_mode_id` (`delivery_mode_id`),
CONSTRAINT `fk_socolissimo_price_area_id`
FOREIGN KEY (`area_id`)
REFERENCES `area` (`id`)
Expand All @@ -116,10 +116,10 @@ CREATE TABLE `socolissimo_area_freeshipping_dom`
`id` INTEGER NOT NULL AUTO_INCREMENT,
`area_id` INTEGER NOT NULL,
`delivery_mode_id` INTEGER NOT NULL,
`cart_amount` DECIMAL(16,6) DEFAULT 0.000000,
`cart_amount` DECIMAL(16,2) DEFAULT 0.00,
PRIMARY KEY (`id`),
INDEX `FI_socolissimo_area_freeshipping_dom_area_id` (`area_id`),
INDEX `FI_socolissimo_area_freeshipping_dom_delivery_mode_id` (`delivery_mode_id`),
INDEX `fi_socolissimo_area_freeshipping_dom_area_id` (`area_id`),
INDEX `fi_socolissimo_area_freeshipping_dom_delivery_mode_id` (`delivery_mode_id`),
CONSTRAINT `fk_socolissimo_area_freeshipping_dom_area_id`
FOREIGN KEY (`area_id`)
REFERENCES `area` (`id`)
Expand All @@ -143,10 +143,10 @@ CREATE TABLE `socolissimo_area_freeshipping_pr`
`id` INTEGER NOT NULL AUTO_INCREMENT,
`area_id` INTEGER NOT NULL,
`delivery_mode_id` INTEGER NOT NULL,
`cart_amount` DECIMAL(16,6) DEFAULT 0.000000,
`cart_amount` DECIMAL(16,2) DEFAULT 0.00,
PRIMARY KEY (`id`),
INDEX `FI_socolissimo_area_freeshipping_pr_area_id` (`area_id`),
INDEX `FI_socolissimo_area_freeshipping_pr_delivery_mode_id` (`delivery_mode_id`),
INDEX `fi_socolissimo_area_freeshipping_pr_area_id` (`area_id`),
INDEX `fi_socolissimo_area_freeshipping_pr_delivery_mode_id` (`delivery_mode_id`),
CONSTRAINT `fk_socolissimo_area_freeshipping_pr_area_id`
FOREIGN KEY (`area_id`)
REFERENCES `area` (`id`)
Expand Down
15 changes: 15 additions & 0 deletions Config/update/sql/2.0.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------------------------------------------------
-- socolissimo_area_freeshipping_dom
-- ---------------------------------------------------------------------

ALTER TABLE `socolissimo_area_freeshipping_dom` MODIFY `cart_amount` DECIMAL(18,2) DEFAULT 0.00 NULL;

-- ---------------------------------------------------------------------
-- socolissimo_area_freeshipping_pr
-- ---------------------------------------------------------------------

ALTER TABLE `socolissimo_area_freeshipping_pr` MODIFY `cart_amount` DECIMAL(18,2) DEFAULT 0.00 NULL;

# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;
5 changes: 3 additions & 2 deletions Controller/GetSpecificLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

namespace SoColissimo\Controller;

use SoColissimo\SoColissimo;
use SoColissimo\WebService\FindById;
use Symfony\Component\HttpFoundation\JsonResponse;
use Thelia\Controller\Front\BaseFrontController;
Expand Down Expand Up @@ -59,8 +60,8 @@ public function getPointInfo($point_id)
$req->setId($point_id)
->setLangue("FR")
->setDate(date("d/m/Y"))
->setAccountNumber(ConfigQuery::read('socolissimo_login'))
->setPassword(ConfigQuery::read('socolissimo_pwd'))
->setAccountNumber(SoColissimo::getConfigValue('socolissimo_username'))
->setPassword(SoColissimo::getConfigValue('socolissimo_password'))
;

$response = $req->exec();
Expand Down
12 changes: 6 additions & 6 deletions Controller/SaveConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SoColissimo\Controller;

use SoColissimo\SoColissimo;
use Thelia\Controller\Admin\BaseAdminController;
use SoColissimo\Form\ConfigureSoColissimo;
use Thelia\Core\Translation\Translator;
Expand All @@ -22,12 +23,11 @@ public function save()
try {
$vform = $this->validateForm($form);

ConfigQuery::write('socolissimo_login', $vform->get('accountnumber')->getData(), 1, 1);
ConfigQuery::write('socolissimo_pwd', $vform->get('password')->getData(), 1, 1);
ConfigQuery::write('socolissimo_google_map_key', $vform->get('google_map_key')->getData(), 1, 1);
ConfigQuery::write('socolissimo_url_prod', $vform->get('url_prod')->getData(), 1, 1);
ConfigQuery::write('socolissimo_url_test', $vform->get('url_test')->getData(), 1, 1);
ConfigQuery::write('socolissimo_test_mode', $vform->get('test_mode')->getData(), 1, 1);
SoColissimo::setConfigValue('socolissimo_username', $vform->get('socolissimo_username')->getData());
SoColissimo::setConfigValue('socolissimo_password', $vform->get('socolissimo_password')->getData());
SoColissimo::setConfigValue('socolissimo_google_map_key', $vform->get('socolissimo_google_map_key')->getData());
SoColissimo::setConfigValue('socolissimo_endpoint_url', $vform->get('socolissimo_endpoint_url')->getData());
SoColissimo::setConfigValue('socolissimo_dom_delivery_authorized', $vform->get('socolissimo_dom_delivery_authorized')->getData());

return $this->generateRedirect(
URL::getInstance()->absoluteUrl('/admin/module/SoColissimo', ['current_tab' => 'configure'])
Expand Down
15 changes: 7 additions & 8 deletions Controller/SliceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
use SoColissimo\SoColissimo;
use Thelia\Controller\Admin\BaseAdminController;
use Thelia\Core\Security\AccessManager;
use Thelia\Core\Security\Resource\AdminResources;

class SliceController extends BaseAdminController
{
public function saveSliceAction()
{
$response = $this->checkAuth([], ['socolissimo'], AccessManager::UPDATE);

if (null !== $response) {
if (null !== $response = $this->checkAuth(array(AdminResources::MODULE), ['socolissimo'], AccessManager::UPDATE)) {
return $response;
}

Expand All @@ -33,14 +32,14 @@ public function saveSliceAction()
try {
$requestData = $this->getRequest()->request;

if (0 !== $id = intval($requestData->get('id', 0))) {
if (0 !== $id = (int)$requestData->get('id', 0)) {
$slice = SocolissimoPriceQuery::create()->findPk($id);
} else {
$slice = new SocolissimoPrice();
}


if (0 !== $areaId = intval($requestData->get('area', 0))) {
if (0 !== $areaId = (int)$requestData->get('area', 0)) {
$slice->setAreaId($areaId);
} else {
$messages[] = $this->getTranslator()->trans(
Expand All @@ -50,7 +49,7 @@ public function saveSliceAction()
);
}

if (0 !== $deliveryMode = intval($requestData->get('deliveryModeId', 0))) {
if (0 !== $deliveryMode = (int)$requestData->get('deliveryModeId', 0)) {
$slice->setDeliveryModeId($deliveryMode);
} else {
$messages[] = $this->getTranslator()->trans(
Expand Down Expand Up @@ -143,7 +142,7 @@ protected function getFloatVal($val, $default = -1)
$val = str_replace(".", "", $val);
$val = str_replace(",", ".", $val);
}
$val = floatval($val);
$val = (float)$val;

return $val;
}
Expand Down Expand Up @@ -172,7 +171,7 @@ public function deleteSliceAction()
try {
$requestData = $this->getRequest()->request;

if (0 !== $id = intval($requestData->get('id', 0))) {
if (0 !== $id = (int)$requestData->get('id', 0)) {
$slice = SocolissimoPriceQuery::create()->findPk($id);
$slice->delete();
$responseData['success'] = true;
Expand Down
65 changes: 27 additions & 38 deletions Form/ConfigureSoColissimo.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
namespace SoColissimo\Form;

use SoColissimo\SoColissimo;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Url;
use Thelia\Core\Translation\Translator;
Expand Down Expand Up @@ -62,73 +64,60 @@ protected function buildForm()
$translator = Translator::getInstance();
$this->formBuilder
->add(
'accountnumber',
'text',
'socolissimo_username',
TextType::class,
[
'constraints' => [new NotBlank()],
'data' => ConfigQuery::read('socolissimo_login'),
'data' => SoColissimo::getConfigValue('socolissimo_username'),
'label' => $translator->trans("Account number", [], SoColissimo::DOMAIN),
'label_attr' => ['for' => 'accountnumber']
'label_attr' => ['for' => 'socolissimo_username']
]
)
->add(
'password',
'text',
'socolissimo_password',
TextType::class,
[
'constraints' => [new NotBlank()],
'data' => ConfigQuery::read('socolissimo_pwd'),
'data' => SoColissimo::getConfigValue('socolissimo_password'),
'label' => $translator->trans("Password", [], SoColissimo::DOMAIN),
'label_attr' => ['for' => 'password']
'label_attr' => ['for' => 'socolissimo_password']
]
)
->add(
'url_prod',
'text',
'socolissimo_endpoint_url',
TextType::class,
[
'constraints' => [
new NotBlank(),
new Url([
'protocols' => ['https', 'http']
])
],
'data' => ConfigQuery::read('socolissimo_url_prod'),
'data' => SoColissimo::getConfigValue('socolissimo_endpoint_url'),
'label' => $translator->trans("Colissimo URL prod", [], SoColissimo::DOMAIN),
'label_attr' => ['for' => 'socolissimo_url_prod']
'label_attr' => ['for' => 'socolissimo_endpoint_url']
]
)
->add(
'url_test',
'text',
'socolissimo_google_map_key',
TextType::class,
[
'constraints' => [
new NotBlank(),
new Url([
'protocols' => ['https', 'http']
])
],
'data' => ConfigQuery::read('socolissimo_url_test'),
'label' => $translator->trans("Colissimo URL test", [], SoColissimo::DOMAIN),
'label_attr' => ['for' => 'socolissimo_url_test']
]
)
->add(
'test_mode',
'text',
[
'constraints' => [new NotBlank()],
'data' => ConfigQuery::read('socolissimo_test_mode'),
'label' => $translator->trans("Test mode", [], SoColissimo::DOMAIN),
'label_attr' => ['for' => 'test_mode']
'constraints' => [],
'data' => SoColissimo::getConfigValue('socolissimo_google_map_key'),
'label' => $translator->trans("Google map API key", [], SoColissimo::DOMAIN),
'label_attr' => ['for' => 'socolissimo_google_map_key']
]
)
->add(
'google_map_key',
'text',
'socolissimo_dom_delivery_authorized',
CheckboxType::class,
[
'constraints' => [],
'data' => ConfigQuery::read('socolissimo_google_map_key'),
'label' => $translator->trans("Google map API key", [], SoColissimo::DOMAIN),
'label_attr' => ['for' => 'google_map_key']
'required' => false,
'data' => (bool)SoColissimo::getConfigValue('socolissimo_dom_delivery_authorized'),
'value' => (bool)SoColissimo::getConfigValue('socolissimo_dom_delivery_authorized'),
'label' => $translator->trans("[DEPRECATED] Activate Dom delivery", [], SoColissimo::DOMAIN),
'label_attr' => ['for' => 'socolissimo_dom_delivery_authorized']
]
)
;
Expand Down
19 changes: 14 additions & 5 deletions Form/FreeShipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

namespace SoColissimo\Form;

use SoColissimo\Model\SocolissimoFreeshippingQuery;
use SoColissimo\SoColissimo;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;

Expand Down Expand Up @@ -52,10 +54,17 @@ class FreeShipping extends BaseForm
protected function buildForm()
{
$this->formBuilder
->add("delivery_mode", "integer")
->add("freeshipping", "checkbox", array(
'label'=>Translator::getInstance()->trans("Activate free shipping: ")
))
->add(
'delivery_mode',
IntegerType::class
)
->add(
'freeshipping',
CheckboxType::class,
[
'label' => Translator::getInstance()->trans("Activate free shipping: ", [], SoColissimo::DOMAIN)
]
)
;
}

Expand Down
Loading