Le module MondialRelay n'était pas commité
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* Copyright (c) Franck Allimant, CQFDev */
|
||||
/* email : thelia@cqfdev.fr */
|
||||
/* web : http://www.cqfdev.fr */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace MondialRelay\Controller\BackOffice;
|
||||
|
||||
use MondialRelay\Model\MondialRelayZoneConfiguration;
|
||||
use MondialRelay\Model\MondialRelayZoneConfigurationQuery;
|
||||
use Thelia\Controller\Admin\BaseAdminController;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
/**
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class AreaAttributesController extends BaseAdminController
|
||||
{
|
||||
public function saveAction($areaId, $moduleId)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::UPDATE)) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$form = $this->createForm('mondialrelay.area_attributes_update_form');
|
||||
|
||||
$errorMessage = false;
|
||||
|
||||
try {
|
||||
$viewForm = $this->validateForm($form);
|
||||
|
||||
$data = $viewForm->getData();
|
||||
|
||||
if (null === $zoneConfig = MondialRelayZoneConfigurationQuery::create()->findOneByAreaId($areaId)) {
|
||||
$zoneConfig = new MondialRelayZoneConfiguration();
|
||||
}
|
||||
|
||||
$zoneConfig
|
||||
->setAreaId($areaId)
|
||||
->setDeliveryTime($data['delivery_time'])
|
||||
->setDeliveryType($data['delivery_type'])
|
||||
->save();
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
$errorMessage = $ex->getMessage();
|
||||
|
||||
Tlog::getInstance()->error("Failed to validate area attributes form: $errorMessage");
|
||||
}
|
||||
|
||||
return $this->render('mondialrelay/ajax/prices', [
|
||||
'module_id' => $moduleId,
|
||||
'error_message' => $errorMessage
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* Copyright (c) Franck Allimant, CQFDev */
|
||||
/* email : thelia@cqfdev.fr */
|
||||
/* web : http://www.cqfdev.fr */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace MondialRelay\Controller\BackOffice;
|
||||
|
||||
use MondialRelay\MondialRelay;
|
||||
use Thelia\Controller\Admin\BaseAdminController;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
/**
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class ConfigurationController extends BaseAdminController
|
||||
{
|
||||
public function saveAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::UPDATE)) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$form = $this->createForm('mondialrelay.settings_form');
|
||||
|
||||
$errorMessage = false;
|
||||
|
||||
try {
|
||||
$viewForm = $this->validateForm($form);
|
||||
|
||||
$data = $viewForm->getData();
|
||||
|
||||
foreach ($data as $name => $value) {
|
||||
MondialRelay::setConfigValue($name, $value);
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$errorMessage = $ex->getMessage();
|
||||
|
||||
Tlog::getInstance()->error("Failed to validate configuration form: $errorMessage");
|
||||
}
|
||||
|
||||
return $this->render('mondialrelay/ajax/general', [ 'error_message' => $errorMessage ]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* Copyright (c) Franck Allimant, CQFDev */
|
||||
/* email : thelia@cqfdev.fr */
|
||||
/* web : http://www.cqfdev.fr */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace MondialRelay\Controller\BackOffice;
|
||||
|
||||
use MondialRelay\Model\MondialRelayDeliveryInsurance;
|
||||
use MondialRelay\Model\MondialRelayDeliveryInsuranceQuery;
|
||||
use Thelia\Controller\Admin\BaseAdminController;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
/**
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class InsuranceController extends BaseAdminController
|
||||
{
|
||||
public function saveAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::UPDATE)) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$form = $this->createForm('mondialrelay.insurances_update_form');
|
||||
|
||||
$errorMessage = false;
|
||||
|
||||
try {
|
||||
$viewForm = $this->validateForm($form);
|
||||
|
||||
$data = $viewForm->getData();
|
||||
|
||||
foreach ($data['max_value'] as $key => $value) {
|
||||
if (null !== $insurance = MondialRelayDeliveryInsuranceQuery::create()->findPk($key)) {
|
||||
$insurance
|
||||
->setMaxValue($value)
|
||||
->setPriceWithTax($data['price_with_tax'][$key])
|
||||
->save();
|
||||
}
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$errorMessage = $ex->getMessage();
|
||||
|
||||
Tlog::getInstance()->error("Failed to validate insurances form: $errorMessage");
|
||||
}
|
||||
|
||||
return $this->render('mondialrelay/ajax/insurances', [ 'error_message' => $errorMessage ]);
|
||||
}
|
||||
|
||||
public function createAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::UPDATE)) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$form = $this->createForm('mondialrelay.insurance_create_form');
|
||||
|
||||
$errorMessage = false;
|
||||
|
||||
try {
|
||||
$viewForm = $this->validateForm($form);
|
||||
|
||||
$data = $viewForm->getData();
|
||||
|
||||
MondialRelayDeliveryInsuranceQuery::create()->filterByMaxValue($data['max_value'])->delete();
|
||||
|
||||
(new MondialRelayDeliveryInsurance())
|
||||
->setPriceWithTax($data['price_with_tax'])
|
||||
->setMaxValue($data['max_value'])
|
||||
->save();
|
||||
} catch (\Exception $ex) {
|
||||
$errorMessage = $ex->getMessage();
|
||||
|
||||
Tlog::getInstance()->error("Failed to validate insurances form: $errorMessage");
|
||||
}
|
||||
|
||||
return $this->render('mondialrelay/ajax/insurances', [ 'error_message' => $errorMessage ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $insuranceId
|
||||
* @return mixed|\Thelia\Core\HttpFoundation\Response
|
||||
* @throws \Propel\Runtime\Exception\PropelException
|
||||
*/
|
||||
public function deleteAction($insuranceId)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::DELETE)) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
MondialRelayDeliveryInsuranceQuery::create()->filterById($insuranceId)->delete();
|
||||
|
||||
return $this->render('mondialrelay/ajax/insurances');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* Copyright (c) Franck Allimant, CQFDev */
|
||||
/* email : thelia@cqfdev.fr */
|
||||
/* web : http://www.cqfdev.fr */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace MondialRelay\Controller\BackOffice;
|
||||
|
||||
use MondialRelay\Model\MondialRelayDeliveryPrice;
|
||||
use MondialRelay\Model\MondialRelayDeliveryPriceQuery;
|
||||
use Thelia\Controller\Admin\BaseAdminController;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
/**
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class PriceController extends BaseAdminController
|
||||
{
|
||||
public function saveAction($areaId, $moduleId)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::UPDATE)) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$form = $this->createForm('mondialrelay.prices_update_form');
|
||||
|
||||
$errorMessage = false;
|
||||
|
||||
try {
|
||||
$viewForm = $this->validateForm($form);
|
||||
|
||||
$data = $viewForm->getData();
|
||||
|
||||
MondialRelayDeliveryPriceQuery::create()->filterByAreaId($areaId)->delete();
|
||||
|
||||
foreach ($data['max_weight'] as $key => $value) {
|
||||
(new MondialRelayDeliveryPrice())
|
||||
->setAreaId($areaId)
|
||||
->setMaxWeight($value)
|
||||
->setPriceWithTax($data['price'][$key])
|
||||
->save();
|
||||
}
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
$errorMessage = $ex->getMessage();
|
||||
|
||||
Tlog::getInstance()->error("Failed to validate price form: $errorMessage");
|
||||
}
|
||||
|
||||
return $this->render('mondialrelay/ajax/prices', [
|
||||
'module_id' => $moduleId,
|
||||
'error_message' => $errorMessage
|
||||
]);
|
||||
}
|
||||
|
||||
public function createAction($areaId, $moduleId)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::UPDATE)) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$form = $this->createForm('mondialrelay.price_form');
|
||||
|
||||
$errorMessage = false;
|
||||
|
||||
try {
|
||||
$viewForm = $this->validateForm($form);
|
||||
|
||||
$data = $viewForm->getData();
|
||||
|
||||
MondialRelayDeliveryPriceQuery::create()->filterByMaxWeight($data['max_weight'])->delete();
|
||||
|
||||
(new MondialRelayDeliveryPrice())
|
||||
->setAreaId($areaId)
|
||||
->setPriceWithTax($data['price'])
|
||||
->setMaxWeight($data['max_weight'])
|
||||
->save();
|
||||
} catch (\Exception $ex) {
|
||||
$errorMessage = $ex->getMessage();
|
||||
|
||||
Tlog::getInstance()->error("Failed to validate price form: $errorMessage");
|
||||
}
|
||||
|
||||
return $this->render('mondialrelay/ajax/prices', [
|
||||
'module_id' => $moduleId,
|
||||
'error_message' => $errorMessage
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $insuranceId
|
||||
* @return mixed|\Thelia\Core\HttpFoundation\Response
|
||||
* @throws \Propel\Runtime\Exception\PropelException
|
||||
*/
|
||||
public function deleteAction($priceId, $moduleId)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::DELETE)) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
MondialRelayDeliveryPriceQuery::create()->filterById($priceId)->delete();
|
||||
|
||||
return $this->render('mondialrelay/ajax/prices', [ 'module_id' => $moduleId ]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user