D'autres fichiers en conf
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace PaymentCondition\Controller;
|
||||
|
||||
use PaymentCondition\Model\PaymentDeliveryCondition;
|
||||
use PaymentCondition\Model\PaymentDeliveryConditionQuery;
|
||||
use Thelia\Controller\Admin\BaseAdminController;
|
||||
use Thelia\Core\HttpFoundation\JsonResponse;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
class AdminController extends BaseAdminController
|
||||
{
|
||||
public function viewAction()
|
||||
{
|
||||
return $this->render('payment-condition/configuration');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace PaymentCondition\Controller;
|
||||
|
||||
use PaymentCondition\Model\PaymentAreaCondition;
|
||||
use PaymentCondition\Model\PaymentAreaConditionQuery;
|
||||
use Thelia\Controller\Admin\BaseAdminController;
|
||||
use Thelia\Core\HttpFoundation\JsonResponse;
|
||||
use Thelia\Model\AreaQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
class AreaConditionController extends BaseAdminController
|
||||
{
|
||||
public function viewAction()
|
||||
{
|
||||
$areaPaymentConditionArray = [];
|
||||
|
||||
$paymentModules = ModuleQuery::create()
|
||||
->findByCategory('payment');
|
||||
|
||||
$shippingAreas = AreaQuery::create()->find();
|
||||
|
||||
$paymentAreaConditions = PaymentAreaConditionQuery::create()
|
||||
->find();
|
||||
|
||||
if (null !== $paymentAreaConditions) {
|
||||
/** @var PaymentAreaCondition $paymentAreaCondition */
|
||||
foreach ($paymentAreaConditions as $paymentAreaCondition) {
|
||||
$areaPaymentConditionArray[$paymentAreaCondition->getPaymentModuleId()][$paymentAreaCondition->getAreaId()] = $paymentAreaCondition->getIsValid();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('payment-condition/shipping_area', [
|
||||
'paymentModules' => $paymentModules,
|
||||
'shippingAreas' => $shippingAreas,
|
||||
"areaPaymentCondition" => $areaPaymentConditionArray
|
||||
]);
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
try {
|
||||
$paymentId = $request->request->get("paymentId");
|
||||
$areaId = $request->request->get("areaId");
|
||||
$isValid = $request->request->get("isValid") == "true" ? 1 : 0;
|
||||
|
||||
$paymentArea = PaymentAreaConditionQuery::create()
|
||||
->filterByPaymentModuleId($paymentId)
|
||||
->filterByAreaId($areaId)
|
||||
->findOneOrCreate();
|
||||
|
||||
$paymentArea->setIsValid($isValid)
|
||||
->save();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return JsonResponse::create($e->getMessage(), 500);
|
||||
}
|
||||
return JsonResponse::create("Success");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace PaymentCondition\Controller;
|
||||
|
||||
use CustomerFamily\Model\CustomerFamily;
|
||||
use CustomerFamily\Model\CustomerFamilyQuery;
|
||||
use PaymentCondition\Model\PaymentCustomerFamilyCondition;
|
||||
use PaymentCondition\Model\PaymentCustomerFamilyConditionQuery;
|
||||
use Thelia\Controller\Admin\BaseAdminController;
|
||||
use Thelia\Core\HttpFoundation\JsonResponse;
|
||||
use Thelia\Model\Module;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
class CustomerFamilyConditionController extends BaseAdminController
|
||||
{
|
||||
public function viewAction()
|
||||
{
|
||||
$customerFamilyPaymentsModules = [];
|
||||
$moduleCodes = [];
|
||||
$familyCodes = [];
|
||||
|
||||
$paymentModules = ModuleQuery::create()
|
||||
->findByCategory('payment');
|
||||
|
||||
$customerFamilies = CustomerFamilyQuery::create()
|
||||
->find();
|
||||
|
||||
/** @var Module $paymentModule */
|
||||
foreach ($paymentModules as $paymentModule) {
|
||||
$moduleCodes[$paymentModule->getId()] = $paymentModule->getCode();
|
||||
|
||||
/** @var CustomerFamily $customerFamily */
|
||||
foreach ($customerFamilies as $customerFamily) {
|
||||
$customerFamilyPaymentsModules[$customerFamily->getId()][$paymentModule->getId()] = 0;
|
||||
$familyCodes[$customerFamily->getId()] = $customerFamily->getCode();
|
||||
}
|
||||
}
|
||||
|
||||
$customerFamilyPayments = PaymentCustomerFamilyConditionQuery::create()
|
||||
->find();
|
||||
|
||||
if (null !== $customerFamilyPayments) {
|
||||
/** @var PaymentCustomerFamilyCondition $customerFamilyPayment */
|
||||
foreach ($customerFamilyPayments as $customerFamilyPayment) {
|
||||
$customerFamilyPaymentsModules[$customerFamilyPayment->getCustomerFamilyId()][$customerFamilyPayment->getPaymentModuleId()] = $customerFamilyPayment->getIsValid();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('payment-condition/customer_family', [
|
||||
"module_codes" => $moduleCodes,
|
||||
"family_codes" => $familyCodes,
|
||||
"paymentFamilyCondition" =>$customerFamilyPaymentsModules
|
||||
]);
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
try {
|
||||
$moduleId = $request->request->get("moduleId");
|
||||
$customerFamilyId = $request->request->get("customerFamilyId");
|
||||
$isValid = $request->request->get("isValid") == "true" ? 1 : 0;
|
||||
|
||||
$paymentCustomerFamily = PaymentCustomerFamilyConditionQuery::create()
|
||||
->filterByPaymentModuleId($moduleId)
|
||||
->filterByCustomerFamilyId($customerFamilyId)
|
||||
->findOneOrCreate();
|
||||
|
||||
$paymentCustomerFamily->setIsValid($isValid)
|
||||
->save();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return JsonResponse::create($e->getMessage(), 500);
|
||||
}
|
||||
return JsonResponse::create("Success");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace PaymentCondition\Controller;
|
||||
|
||||
use PaymentCondition\Model\PaymentDeliveryCondition;
|
||||
use PaymentCondition\Model\PaymentDeliveryConditionQuery;
|
||||
use Thelia\Controller\Admin\BaseAdminController;
|
||||
use Thelia\Core\HttpFoundation\JsonResponse;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
class DeliveryConditionController extends BaseAdminController
|
||||
{
|
||||
public function viewAction()
|
||||
{
|
||||
$paymentDeliveryConditionArray = [];
|
||||
|
||||
$paymentModules = ModuleQuery::create()
|
||||
->findByCategory('payment');
|
||||
|
||||
$deliveryModules = ModuleQuery::create()
|
||||
->findByCategory('delivery');
|
||||
|
||||
$paymentDeliveryConditions = PaymentDeliveryConditionQuery::create()
|
||||
->find();
|
||||
|
||||
if (null !== $paymentDeliveryConditions) {
|
||||
/** @var PaymentDeliveryCondition $paymentDeliveryCondition */
|
||||
foreach ($paymentDeliveryConditions as $paymentDeliveryCondition) {
|
||||
$paymentDeliveryConditionArray[$paymentDeliveryCondition->getPaymentModuleId()][$paymentDeliveryCondition->getDeliveryModuleId()] = $paymentDeliveryCondition->getIsValid();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('payment-condition/delivery', [
|
||||
'paymentModules' => $paymentModules,
|
||||
'deliveryModules' => $deliveryModules,
|
||||
"paymentDeliveryCondition" => $paymentDeliveryConditionArray
|
||||
]);
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
try {
|
||||
$paymentId = $request->request->get("paymentId");
|
||||
$deliveryId = $request->request->get("deliveryId");
|
||||
$isValid = $request->request->get("isValid") == "true" ? 1 : 0;
|
||||
|
||||
$paymentDelivery = PaymentDeliveryConditionQuery::create()
|
||||
->filterByPaymentModuleId($paymentId)
|
||||
->filterByDeliveryModuleId($deliveryId)
|
||||
->findOneOrCreate();
|
||||
|
||||
$paymentDelivery->setIsValid($isValid)
|
||||
->save();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return JsonResponse::create($e->getMessage(), 500);
|
||||
}
|
||||
return JsonResponse::create("Success");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user