@@ -78,43 +78,6 @@ class CronController extends BackendController | |||
]; | |||
} | |||
/** | |||
* Initialise le compte de démonstration. | |||
* | |||
* @param string $key | |||
*/ | |||
public function actionInitDemo($key = '') | |||
{ | |||
if ($key == '45432df6e842ac71aa0b5bb6b9f25d44') { | |||
$producerManager = $this->getProducerManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$producer = $producerManager->findOneProducerDemoAccount(); | |||
$producerManager->setProducerContext($producer); | |||
$distributionManager->setProducerContext($producer); | |||
if ($producer) { | |||
// initialisation de la distribution à J+7 | |||
$dateTime = strtotime("+7 day"); | |||
$dayStr = strtolower(date('l', $dateTime)); | |||
$fieldDeliveryDay = 'delivery_' . $dayStr; | |||
$pointsSaleArray = PointSale::searchAll(['point_sale.id_producer' => $producer->id]); | |||
$activeDistribution = false; | |||
foreach ($pointsSaleArray as $pointSale) { | |||
if ($pointSale->$fieldDeliveryDay) { | |||
$activeDistribution = true; | |||
} | |||
} | |||
if ($activeDistribution) { | |||
$distribution = $distributionManager->createDistributionIfNotExist(date('Y-m-d', $dateTime)); | |||
$distributionManager->activeDistribution($distribution); | |||
} | |||
} | |||
} | |||
} | |||
public function actionPayOrders($date) | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; |
@@ -185,9 +185,10 @@ class DistributionBuilder extends AbstractBuilder | |||
// active | |||
public function activeDistribution(Distribution $distribution, bool $active = true): void | |||
{ | |||
$this->pointSaleDistributionBuilder->createAllPointSaleDistributions($distribution, true); | |||
$distribution->active = (int) $active; | |||
$this->saveUpdate($distribution); | |||
$this->update($distribution); | |||
$this->pointSaleDistributionBuilder->createAllPointSaleDistributions($distribution, true); | |||
if ($active) { | |||
$distributionActiveEvent = new DistributionActiveEvent(); |
@@ -178,7 +178,7 @@ class Product extends ActiveRecordCommon | |||
public function afterFind() | |||
{ | |||
if ($this->taxRate == null) { | |||
$producer = Producer::searchOne(['id' => GlobalParam::getCurrentProducerId()]); | |||
$producer = Producer::searchOne(['id' => $this->id_producer]); | |||
if ($producer) { | |||
$this->populateRelation('taxRate', $producer->taxRate); | |||
} |
@@ -32,7 +32,8 @@ | |||
"yidas/yii2-bower-asset": "2.0.13.1", | |||
"stripe/stripe-php": "^7.95", | |||
"loveorigami/yii2-bootstrap-toggle": "*", | |||
"justcoded/yii2-event-listener": "*" | |||
"justcoded/yii2-event-listener": "*", | |||
"ext-pdo": "*" | |||
}, | |||
"require-dev": { | |||
"yiisoft/yii2-codeception": "*", |
@@ -4,7 +4,7 @@ | |||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | |||
"This file is @generated automatically" | |||
], | |||
"content-hash": "a48eac3c3b38a39f09914e9a706604ce", | |||
"content-hash": "7da17be4685def1e9635cc5ab5e5a7d9", | |||
"packages": [ | |||
{ | |||
"name": "2amigos/yii2-chartjs-widget", | |||
@@ -6482,7 +6482,8 @@ | |||
"prefer-stable": false, | |||
"prefer-lowest": false, | |||
"platform": { | |||
"php": ">=7.4" | |||
"php": ">=7.4", | |||
"ext-pdo": "*" | |||
}, | |||
"platform-dev": [], | |||
"plugin-api-version": "2.3.0" |
@@ -0,0 +1,27 @@ | |||
<?php | |||
namespace console\commands; | |||
use common\logic\Distribution\Distribution\Wrapper\DistributionManager; | |||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||
use yii\console\Controller; | |||
class DemoAccountController extends Controller | |||
{ | |||
public function actionIndex() | |||
{ | |||
$producerManager = ProducerManager::getInstance(); | |||
$distributionManager = DistributionManager::getInstance(); | |||
$producerDemo = $producerManager->findOneProducerDemoAccount(); | |||
\Yii::$app->logic->setProducerContext($producerDemo); | |||
if ($producerDemo) { | |||
$dateTime = strtotime("+7 day"); | |||
$distribution = $distributionManager->createDistributionIfNotExist(date('Y-m-d', $dateTime)); | |||
$distributionManager->activeDistribution($distribution); | |||
} | |||
} | |||
} | |||
?> |
@@ -47,7 +47,7 @@ return [ | |||
'id' => 'app-console', | |||
'basePath' => dirname(__DIR__), | |||
'bootstrap' => ['log'], | |||
'controllerNamespace' => 'console\controllers', | |||
'controllerNamespace' => 'console\commands', | |||
'components' => [ | |||
'log' => [ | |||
'targets' => [ |