Kaynağa Gözat

Refactoring services #885

refactoring
Guillaume Bourgeois 1 yıl önce
ebeveyn
işleme
7f484b876a
25 değiştirilmiş dosya ile 138 ekleme ve 117 silme
  1. +1
    -1
      common/logic/Producer/Producer/Repository/ProducerRepository.php
  2. +3
    -1
      common/logic/ProducerContextTrait.php
  3. +1
    -1
      common/mail/orderConfirm-html.php
  4. +1
    -1
      common/mail/orderConfirm-text.php
  5. +3
    -3
      producer/controllers/CreditController.php
  6. +23
    -30
      producer/controllers/OrderController.php
  7. +4
    -2
      producer/controllers/ProducerBaseController.php
  8. +4
    -4
      producer/controllers/SiteController.php
  9. +4
    -4
      producer/controllers/SubscriptionController.php
  10. +4
    -2
      producer/models/CreditForm.php
  11. +4
    -4
      producer/views/credit/add.php
  12. +4
    -3
      producer/views/credit/history.php
  13. +4
    -4
      producer/views/layouts/main.php
  14. +9
    -3
      producer/views/order/_form.php
  15. +5
    -5
      producer/views/order/confirm.php
  16. +32
    -25
      producer/views/order/history.php
  17. +10
    -8
      producer/views/order/order.php
  18. +1
    -0
      producer/views/site-producer/error.php
  19. +1
    -1
      producer/views/site/contact.php
  20. +2
    -0
      producer/views/site/gcs.php
  21. +12
    -8
      producer/views/site/index.php
  22. +1
    -0
      producer/views/site/mentions.php
  23. +3
    -3
      producer/views/subscription/_form.php
  24. +0
    -2
      producer/views/subscription/form.php
  25. +2
    -2
      producer/views/subscription/index.php

+ 1
- 1
common/logic/Producer/Producer/Repository/ProducerRepository.php Dosyayı Görüntüle

@@ -199,7 +199,7 @@ class ProducerRepository extends AbstractRepository
return 0;
}

public function getOnlinePaymentMinimumAmount(Producer $producer): float
public function getOnlinePaymentMinimumAmount(): float
{
$onlinePaymentMinimumAmount = $this->getConfig('option_online_payment_minimum_amount');
if (!$onlinePaymentMinimumAmount) {

+ 3
- 1
common/logic/ProducerContextTrait.php Dosyayı Görüntüle

@@ -9,9 +9,11 @@ trait ProducerContextTrait
{
protected ?Producer $producerContext = null;

public function setProducerContext(Producer $producer): void
public function setProducerContext(Producer $producer): self
{
$this->producerContext = $producer;

return $this;
}

public function getProducerContext(): Producer

+ 1
- 1
common/mail/orderConfirm-html.php Dosyayı Görüntüle

@@ -51,7 +51,7 @@ $orderManager = OrderManager::getInstance();
<p>Votre commande <?= ($order->reference && strlen($order->reference) > 0) ? 'N°'.$order->reference : '' ?> d'une valeur de <strong><?= $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true); ?></strong> a bien été prise en compte.</p>

<p>Récapitulatif des produits commandés :</p>
<p><?= $order->getCartSummary() ?></p>
<p><?= $orderManager->getCartSummary($order) ?></p>

<p>Elle sera à retirer le <strong><?= date('d/m/Y',strtotime($distribution->date)) ?></strong> au point de retrait
<strong><?= Html::encode($pointSale->name) ?></strong>

+ 1
- 1
common/mail/orderConfirm-text.php Dosyayı Görüntüle

@@ -53,7 +53,7 @@ Bonjour <?= $user->name; ?>,
Votre commande <?= ($order->reference && strlen($order->reference) > 0) ? '<strong>N°'.$order->reference.'</strong>' : '' ?> d'une valeur de <?= $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true); ?> a bien été prise en compte.

Récapitulatif des produits commandés :
<?= $order->getCartSummary(false) ?>
<?= $orderManager->getCartSummary($order, false) ?>

Elle sera à retirer le <?= date('d/m/Y',strtotime($distribution->date)) ?> au point de retrait <?= $pointSale->name ?> <?php if($order->pointSale->is_bread_box && $order->pointSale->bread_box_code): ?> (Code : <?= $order->pointSale->bread_box_code; ?>) <?php endif; ?> <?php if(strlen($pointSale->locality) > 0): ?> situé à <?= Html::encode($pointSale->locality) ?><?php endif ?>.


+ 3
- 3
producer/controllers/CreditController.php Dosyayı Görüntüle

@@ -84,7 +84,7 @@ class CreditController extends ProducerBaseController
*/
public function actionHistory(string $returnPayment = '')
{
$producer = $this->getProducer();
$producer = $this->getProducerCurrent();
if (\Yii::$app->user->isGuest) {
return $this->redirect($this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $producer->id]));
}
@@ -112,7 +112,7 @@ class CreditController extends ProducerBaseController

public function actionAdd()
{
$producer = $this->getProducer();
$producer = $this->getProducerCurrent();
if (\Yii::$app->user->isGuest) {
return $this->redirect($this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $producer->id]));
}
@@ -183,7 +183,7 @@ class CreditController extends ProducerBaseController
$creditHistoryManager = $this->getCreditHistoryManager();
$producerManager = $this->getProducerManager();
$userManager = $this->getUserManager();
$producer = $this->getProducer();
$producer = $this->getProducerCurrent();
$contactProducer = $producerManager->getMainContact($producer);

$payload = @file_get_contents('php://input');

+ 23
- 30
producer/controllers/OrderController.php Dosyayı Görüntüle

@@ -67,7 +67,7 @@ class OrderController extends ProducerBaseController
public function actionOrder(int $id = 0, $date = '')
{
$params = [];
$producer = $this->getProducer();
$producer = $this->getProducerCurrent();

if (\Yii::$app->user->isGuest && !$producer->option_allow_order_guest) {
return $this->redirect(
@@ -93,7 +93,7 @@ class OrderController extends ProducerBaseController
public function actionHistory($type = 'incoming')
{
$queryHistoryArray = $this->getOrderManager()
->queryOrdersHistory($this->getProducer(), $this->getUserCurrent(), $type);
->queryOrdersHistory($this->getProducerCurrent(), $this->getUserCurrent(), $type);
$queryHistoryIncoming = $queryHistoryArray['incoming'];
$queryHistoryPassed = $queryHistoryArray['passed'];

@@ -137,10 +137,10 @@ class OrderController extends ProducerBaseController

$orderManager = $this->getOrderManager();
$producerManager = $this->getProducerManager();
$producer = $this->getProducerCurrent();
$redirect = null;
$producer = $this->getProducer();
$idProducer = $producer->id;
$order = $orderManager->instanciateOrder();
$order = new Order;

if ($idProducer) {
$this->_verifyProducerActive($idProducer);
@@ -313,7 +313,7 @@ class OrderController extends ProducerBaseController
$posts = \Yii::$app->request->post();
$productsArray = [];
$totalQuantity = 0;
$producer = $this->getProducer();
$producer = $this->getProducerCurrent();

$isNewOrder = false;
if (!$order->id) {
@@ -332,7 +332,7 @@ class OrderController extends ProducerBaseController
$errorDate = false;
if (isset($order->id_distribution)) {
$distribution = $distributionManager->findOneDistributionById($order->id_distribution);
if ($order->getState() != Order::STATE_OPEN) {
if ($orderManager->getState($order) != Order::STATE_OPEN) {
$errorDate = true;
}
}
@@ -366,25 +366,16 @@ class OrderController extends ProducerBaseController
$userProducer = $userProducerManager->findOneUserProducer($user, $producer);
$pointSale = $pointSaleManager->findOnePointSaleById($order->id_point_sale);

// commentaire point de vente
$order->comment_point_sale = ($pointSale && strlen($pointSale->getComment())) ?
$pointSale->getComment() : '';

// la commande est automatiquement réactivée lors d'une modification
$order->date_delete = null;

// delivery
$order->comment_point_sale = ($pointSale && strlen($pointSaleManager->getComment($pointSale))) ?
$pointSaleManager->getComment($pointSale) : '';
$order->date_delete = null; // la commande est automatiquement réactivée lors d'une modification
$order->delivery_home = isset($posts['Order']['delivery_home']) ? $posts['Order']['delivery_home'] : false;
$order->delivery_address = (isset($posts['Order']['delivery_address']) && $order->delivery_home) ? $posts['Order']['delivery_address'] : null;

// comment
$order->comment = isset($posts['Order']['comment']) ? $posts['Order']['comment'] : null;

// sauvegarde de la commande
$order->save();

$orderManager->generateOrderReference($order);
$orderManager->changeOrderStatus($order, 'new-order', 'user');
$orderManager->updateOrderStatus($order, 'new-order', 'user');
$producerManager->addUser($user, $producer);

// suppression de tous les enregistrements ProductOrder
@@ -432,7 +423,7 @@ class OrderController extends ProducerBaseController
// credit
$credit = $producerManager->getConfig('credit');
$creditLimit = $producerManager->getConfig('credit_limit');
$creditFunctioning = $pointSaleManager->getPointSaleCreditFunctioning($pointSale);
$creditFunctioning = $producerManager->getPointSaleCreditFunctioning($pointSale);
$creditUser = $userManager->getCredit($user, $producer);
$order = $orderManager->findOneOrderById($order->id);
$amountRemaining = $orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING);
@@ -442,7 +433,7 @@ class OrderController extends ProducerBaseController
$creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY ||
($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER && $userProducer->credit_active)
)) {
$orderManager->changeOrderStatus($order, 'waiting-paiement-by-credit', 'user');
$orderManager->updateOrderStatus($order, 'waiting-paiement-by-credit', 'user');

// à payer
if ($orderManager->getPaymentStatus($order) == Order::PAYMENT_UNPAID) {
@@ -460,9 +451,9 @@ class OrderController extends ProducerBaseController
MeanPayment::CREDIT,
$order
);
$orderManager->changeOrderStatus($order, 'paid-by-credit', 'user');
$orderManager->updateOrderStatus($order, 'paid-by-credit', 'user');
} else {
$orderManager->changeOrderStatus($order, 'waiting-paiement-on-delivery', 'user');
$orderManager->updateOrderStatus($order, 'waiting-paiement-on-delivery', 'user');
}
} // surplus à rembourser
elseif ($orderManager->getPaymentStatus($order) == Order::PAYMENT_SURPLUS) {
@@ -478,7 +469,7 @@ class OrderController extends ProducerBaseController
);
}
} else {
$orderManager->changeOrderStatus($order, 'waiting-paiement-on-delivery', 'user');
$orderManager->updateOrderStatus($order, 'waiting-paiement-on-delivery', 'user');
}

$paramsEmail = [
@@ -520,7 +511,7 @@ class OrderController extends ProducerBaseController
}
}

$orderManager->setTillerSynchronization($order);
$orderManager->updateOrderTillerSynchronization($order);
}


@@ -568,12 +559,14 @@ class OrderController extends ProducerBaseController
{
$orderManager = $this->getOrderManager();
$order = $orderManager->findOneOrderById($idOrder);
$producer = $this->getProducer();
$producer = $this->getProducerCurrent();

if (!$order || (!$orderManager->isOrderBelongsToUser($order, GlobalParam::getCurrentUser()) && !$producer->option_allow_order_guest)) {
throw new \yii\base\UserException('Commande introuvable.');
}

$orderManager->initOrder($order);

return $this->render('confirm', [
'order' => $order,
'returnPayment' => $returnPayment
@@ -600,7 +593,7 @@ class OrderController extends ProducerBaseController
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$user = GlobalParam::getCurrentUser();
$producer = $this->getProducer();
$producer = $this->getProducerCurrent();
$pointSale = $this->getPointSaleManager()->findOnePointSaleById($pointSaleId);
$order = $this->getOrderUser($date, $pointSale);

@@ -626,7 +619,7 @@ class OrderController extends ProducerBaseController
$json['points_sale'] = $this->ajaxInfosPointsSale($producer);

if ($dateObject && $dateObject->format($format) === $date) {
$distribution = $this->getDistributionManager()->createDistributionIfNotExist($producer, $date);
$distribution = $this->getDistributionManager()->createDistributionIfNotExist($date);
$json['distribution'] = $distribution;
$json['points_sale'] = $this->ajaxInfosPointsSale($producer, $distribution);
$json['categories'] = $this->ajaxInfosProductCategories($producer);
@@ -677,10 +670,10 @@ class OrderController extends ProducerBaseController
'id_distribution' => $distribution->id,
'id_point_sale' => $pointSaleCurrent->id
]);
$orderUserPointSale = $this->_getOrderUser($distribution->date, $pointSaleId);
$orderUserPointSale = $this->getOrderUser($distribution->date, $pointSaleCurrent);

if (!$pointSaleCurrent->maximum_number_orders
|| ($orderUserPointSale && $orderUserPointSale->id_point_sale == $pointSaleId)
|| ($orderUserPointSale && $orderUserPointSale->id_point_sale == $pointSaleCurrent->id)
|| ($pointSaleCurrent->maximum_number_orders &&
($countOrders < $pointSaleCurrent->maximum_number_orders))) {
$distributionsArrayFilterPointSale[] = $distribution;

+ 4
- 2
producer/controllers/ProducerBaseController.php Dosyayı Görüntüle

@@ -62,8 +62,10 @@ class ProducerBaseController extends CommonController
public function beforeAction($event)
{
$producer = $this->getProducer() ;
$producer = $this->getProducerCurrent() ;

$this->getLogic()->setProducerContext($producer);

$userProducer = UserProducer::find()
->where([
'id_user' => GlobalParam::getCurrentUserId(),

+ 4
- 4
producer/controllers/SiteController.php Dosyayı Görüntüle

@@ -90,7 +90,7 @@ class SiteController extends ProducerBaseController
public function actionIndex()
{
$dataProviderPointsSale = new ActiveDataProvider([
'query' => $this->getPointSaleManager()->queryPointSalesPublic($this->getProducer()),
'query' => $this->getPointSaleManager()->queryPointSalesPublic($this->getProducerCurrent()),
'pagination' => [
'pageSize' => 50,
],
@@ -111,7 +111,7 @@ class SiteController extends ProducerBaseController

$queryProducts = Product::find()
->andWhere([
'id_producer' => $this->getProducer()->id,
'id_producer' => $this->getProducerCurrent()->id,
'active' => true,
'id_product_category' => null,
])
@@ -161,7 +161,7 @@ class SiteController extends ProducerBaseController
public function actionContact()
{
$model = new ContactForm();
$producer = $this->getProducer();
$producer = $this->getProducerCurrent();

if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
$isSent = false;
@@ -192,7 +192,7 @@ class SiteController extends ProducerBaseController
*/
public function actionBookmarks(string $action)
{
$producer = $this->getProducer();
$producer = $this->getProducerCurrent();
$userProducer = $this->getUserProducerManager()
->createUserProducerIfNotExist(GlobalParam::getCurrentUser(), $producer);


+ 4
- 4
producer/controllers/SubscriptionController.php Dosyayı Görüntüle

@@ -72,7 +72,7 @@ class SubscriptionController extends ProducerBaseController
public function actionIndex()
{
if (\Yii::$app->user->isGuest) {
$producer = $this->getProducer();
$producer = $this->getProducerCurrent();
return $this->redirect($this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $producer->id]));
}

@@ -125,7 +125,7 @@ class SubscriptionController extends ProducerBaseController
public function actionForm(int $id = 0)
{
if (\Yii::$app->user->isGuest) {
$producer = $this->getProducer();
$producer = $this->getProducerCurrent();
return $this->redirect($this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $producer->id]));
}

@@ -140,7 +140,7 @@ class SubscriptionController extends ProducerBaseController
public function actionUpdate(int $id)
{
if (\Yii::$app->user->isGuest) {
$producer = $this->getProducer();
$producer = $this->getProducerCurrent();
return $this->redirect($this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $producer->id]));
}

@@ -219,7 +219,7 @@ class SubscriptionController extends ProducerBaseController
public function actionDelete($id)
{
if (\Yii::$app->user->isGuest) {
$producer = $this->getProducer();
$producer = $this->getProducerCurrent();
return $this->redirect($this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $producer->id]));
}


+ 4
- 2
producer/models/CreditForm.php Dosyayı Görüntüle

@@ -38,7 +38,7 @@ termes.

namespace producer\models;

use common\logic\Producer\Producer\Producer;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use Yii;
use yii\base\Model;

@@ -52,9 +52,11 @@ class CreditForm extends Model
*/
public function rules()
{
$producerManager = ProducerManager::getInstance();

return [
[['amount'], 'required'],
[['amount'], 'double', 'min' => Producer::getOnlinePaymentMinimumAmount()],
[['amount'], 'double', 'min' => $producerManager->getOnlinePaymentMinimumAmount()],
];
}


+ 4
- 4
producer/views/credit/add.php Dosyayı Görüntüle

@@ -36,12 +36,12 @@
* termes.
*/

use common\logic\Producer\Producer\Wrapper\ProducerManager;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\logic\Producer\Producer\Producer;

$producerManager = $this->getProducerManager();
$producer = $this->context->getProducer();
$producerManager = ProducerManager::getInstance();
$producer = $this->context->getProducerCurrent();

$this->setTitle('Créditer mon compte');
$this->setPageTitle('Crédit mon compte');
@@ -66,7 +66,7 @@ $this->addButton(
'template' => '{label}<div class="input-group input-group-lg">{input}<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span></div>{hint}',
])
->label('Quel montant souhaitez-vous créditer ?')
->hint('Montant minimum : '.$producerManager->getOnlinePaymentMinimumAmount($producer).' €'); ?>
->hint('Montant minimum : '.$producerManager->getOnlinePaymentMinimumAmount().' €'); ?>

<div class="form-group">
<?= Html::submitButton('<span class="glyphicon glyphicon-lock"></span> Payer', ['class' => 'btn btn-primary']

+ 4
- 3
producer/views/credit/history.php Dosyayı Görüntüle

@@ -36,14 +36,15 @@
* termes.
*/

use common\logic\User\CreditHistory\Wrapper\CreditHistoryManager;
use yii\grid\GridView;

$creditHistoryManager = $this->getCreditHistoryManager();
$producer = $this->context->getProducer();
$creditHistoryManager = CreditHistoryManager::getInstance();
$producer = $this->context->getProducerCurrent();
$this->setTitle('Crédit : <span id="credit-user">' . number_format($creditUser, 2) . ' €</span>');
$this->setPageTitle('Crédit');

if ($this->context->getProducer()->online_payment) {
if ($this->context->getProducerCurrent()->online_payment) {
$this->addButton(
[
'label' => '<span class="glyphicon glyphicon-credit-card"></span> Créditer mon compte',

+ 4
- 4
producer/views/layouts/main.php Dosyayı Görüntüle

@@ -36,16 +36,16 @@
* termes.
*/

use common\logic\Order\Order\Model\Order;
use common\logic\User\UserProducer\Model\UserProducer;
use yii\bootstrap\Nav;
use common\helpers\GlobalParam;
use common\logic\User\UserProducer\UserProducer;
use yii\helpers\Html;
use common\logic\Order\Order\Order;

\common\assets\CommonAsset::register($this);
\producer\assets\AppAsset::register($this);

$producer = $this->context->getProducer();
$producer = $this->context->getProducerCurrent();
if (!Yii::$app->user->isGuest) {
$userProducer = UserProducer::findOne(['id_user' => GlobalParam::getCurrentUserId(), 'id_producer' => $producer->id]);
}
@@ -183,7 +183,7 @@ if (!Yii::$app->user->isGuest) {
],
[
'label' => '<span class="glyphicon glyphicon-plus"></span> Commander',
'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $this->context->getProducer()->id, 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order', 'slug_producer' => $this->context->getProducer()->slug])]),
'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $this->context->getProducerCurrent()->id, 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order', 'slug_producer' => $this->context->getProducerCurrent()->slug])]),
'visible' => !$producer->option_allow_order_guest && \Yii::$app->user->isGuest,
'active' => $this->getControllerAction() == 'order/order',
],

+ 9
- 3
producer/views/order/_form.php Dosyayı Görüntüle

@@ -37,9 +37,15 @@ termes.
*/

use common\helpers\GlobalParam;
use common\helpers\Price;
use common\logic\Order\Order\Wrapper\OrderManager;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

$producerManager = $this->getProducerManager();
$producerManager = ProducerManager::getInstance();
$orderManager = OrderManager::getInstance();

?>
<div class="order-form">
@@ -65,7 +71,7 @@ $producerManager = $this->getProducerManager();
<?php if (isset($model->id)): ?>
<div class="date-order"><span><?php echo date('d/m/Y', strtotime($distribution->date)); ?></span></div>
<?= Html::hiddenInput('id_order', $model->id,['id'=>'id-order']); ?>
<?= Html::hiddenInput('paid_amount', $model->getAmount(Order::AMOUNT_PAID),['id'=>'paid-amount']); ?>
<?= Html::hiddenInput('paid_amount', $orderManager->getOrderAmount($model, Order::AMOUNT_PAID),['id'=>'paid-amount']); ?>
<?php endif; ?>

<div id="datepicker-distribution" <?php if (isset($model->id)): ?>style="display:none"<?php endif; ?>>
@@ -274,7 +280,7 @@ $producerManager = $this->getProducerManager();
$linkCredit = '<a class="info-credit" href="'.Yii::$app->urlManager->createUrl(['site/credit']) .'" data-toggle="tooltip" data-placement="bottom" title="En savoir plus sur le Crédit"><span class="glyphicon glyphicon-info-sign"></span></a>' ; ;
?>
<div id="checkbox-credit" >
<?php if($credit || $model->getAmount(Order::AMOUNT_PAID)): ?>
<?php if($credit || $orderManager->getAmount($order, Order::AMOUNT_PAID)): ?>
<?= Html::checkbox('credit', true, ['label' => 'Utiliser mon Crédit <span class="the-credit" data-toggle="tooltip" data-placement="top" data-original-title="Vous avez actuellement '.number_format($credit,2).' € sur votre compte Crédit">'.number_format($credit,2).'&nbsp;€</span><br /><span class="info"></span>']) ?>
<?= Html::hiddenInput('amount_credit', $credit, ['id' => 'amount-credit']) ?>
<?= Html::hiddenInput('str_amount_credit', number_format($credit,2).' €', ['id' => 'str-amount-credit']) ?>

+ 5
- 5
producer/views/order/confirm.php Dosyayı Görüntüle

@@ -39,11 +39,13 @@ termes.
use common\helpers\GlobalParam ;
use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Wrapper\OrderManager;
use common\logic\PointSale\PointSale\Wrapper\PointSaleManager;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use yii\helpers\Html;

$producerManager = ProducerManager::getInstance();
$orderManager = OrderManager::getInstance();
$pointSaleManager = PointSaleManager::getInstance();
$producer = GlobalParam::getCurrentProducer() ;

$this->setTitle('Confirmation de commande') ;
@@ -51,8 +53,6 @@ $this->setTitle('Confirmation de commande') ;
?>

<div id="order-success">


<?php if($producerManager->isOnlinePaymentActiveAndTypeOrder($producer) && $returnPayment != 'success'): ?>
<div class="alert alert-danger">
<h5>Le paiement en ligne a échoué.</h5>
@@ -98,7 +98,7 @@ $this->setTitle('Confirmation de commande') ;
<?php endif; ?>
</li>
<?php
$strInfos = $order->pointSale->getStrInfos(strtolower(date('l',strtotime($order->distribution->date))));
$strInfos = $pointSaleManager->getStrInfos($order->pointSale, strtolower(date('l',strtotime($order->distribution->date))));
?>
<?php if(strlen($strInfos) > 0): ?>
<li><span class="glyphicon glyphicon-info-sign"></span>
@@ -110,8 +110,8 @@ $this->setTitle('Confirmation de commande') ;
<div class="col-md-6">
<ul>
<li>
<p><strong>Produit<?php if($order->countProducts() > 1): ?>s<?php endif; ?></strong></p>
<p><?= $order->getCartSummary() ?></p>
<p><strong>Produit<?php if($orderManager->countProducts($order) > 1): ?>s<?php endif; ?></strong></p>
<p><?= $orderManager->getCartSummary($order) ?></p>
</li>
<li>Total : <strong><?= $orderManager->getOrderAmountWithTax($order,Order::AMOUNT_TOTAL, true); ?></strong></li>
</ul>

+ 32
- 25
producer/views/order/history.php Dosyayı Görüntüle

@@ -36,9 +36,15 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Wrapper\OrderManager;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use yii\bootstrap\ActiveForm;
use yii\grid\GridView;

$producer = $this->context->getProducer();
$orderManager = OrderManager::getInstance();
$producerManager = ProducerManager::getInstance();
$producer = $this->context->getProducerCurrent();
$this->setTitle('Mes commandes') ;
$this->addButton(['label' => '<span class="glyphicon glyphicon-plus"></span> Ajouter', 'url' => 'order/order', 'class' => 'btn btn-primary']) ;

@@ -77,56 +83,56 @@ $this->addButton(['label' => '<span class="glyphicon glyphicon-plus"></span> Ajo
GridView::widget([
'dataProvider' => $dataProviderOrders,
'summary' => '',
'beforeRow' => function($model) {
$model->init() ;
'beforeRow' => function($order) use ($orderManager) {
$orderManager->initOrder($order) ;
},
'columns' => [
[
'attribute' => 'distribution.date',
'label' => 'Date de livraison',
'format' => 'raw',
'value' => function($model) {
return $model->getBlockDate() ;
'value' => function($order) use ($orderManager) {
return $orderManager->getDateAsHtml($order) ;
}
],
[
'label' => 'Point de vente',
'format' => 'raw',
'value' => function($model) {
return $model->getPointSaleSummary();
'value' => function($order) use ($orderManager) {
return $orderManager->getPointSaleSummary($order);
}
],
[
'label' => 'Résumé',
'format' => 'raw',
'value' => function($model) {
return $model->getCartSummary();
'value' => function($order) use ($orderManager) {
return $orderManager->getCartSummary($order);
}
],
[
'label' => 'Montant',
'format' => 'raw',
'value' => function($model) {
return $model->getAmountSummary();
'value' => function($order) use ($orderManager) {
return $orderManager->getAmountSummary($order);
}
],
[
'label' => 'Statut',
'format' => 'raw',
'value' => function($c) {
'value' => function($order) use ($orderManager) {
$html = '' ;
if($c->date_delete) {
if($order->date_delete) {
$html .= '<span class="label label-danger">Annulée</span><br />' ;
}
else {
if($c->getState() == Order::STATE_DELIVERED) {
if($orderManager->getState($order) == Order::STATE_DELIVERED) {
$html .= '<span class="label label-success">Livrée</span>' ;
}
elseif($c->getState() == Order::STATE_PREPARATION) {
elseif($orderManager->getState($order) == Order::STATE_PREPARATION) {
$html .= '<span class="label label-warning">En préparation</span>' ;
}
elseif($c->getState() == Order::STATE_OPEN) {
elseif($orderManager->getState($order) == Order::STATE_OPEN) {
$html .= '<span class="label label-default">À venir</span>' ;
}
}
@@ -137,21 +143,22 @@ GridView::widget([
[
'label' => 'Actions',
'format' => 'raw',
'value' => function($c) use ($producer) {
'value' => function($order) use ($producer, $producerManager, $orderManager) {
$html = '' ;
if($c->getState() == Order::STATE_OPEN) {
if ($producer->isOnlinePaymentActiveAndTypeOrder()) {
$paymentStatus = $c->getPaymentStatus();
if($paymentStatus == Order::PAYMENT_UNPAID && $c->online_payment_url) {
$html .= '<a href="'.$c->online_payment_url.'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Payer en ligne</a>';
if($orderManager->getState($order) == Order::STATE_OPEN) {
if ($producerManager->isOnlinePaymentActiveAndTypeOrder($producer)) {
$paymentStatus = $orderManager->getPaymentStatus($order);
if($paymentStatus == Order::PAYMENT_UNPAID && $order->online_payment_url) {
$html .= '<a href="'.$order->online_payment_url.'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Payer en ligne</a>';
}
}
else {
$html .= '<a href="'.Yii::$app->urlManager->createUrl(['order/order','id'=>$c->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a> '.
'<a href="'.Yii::$app->urlManager->createUrl(['order/cancel','id'=>$c->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-trash"></span></a> '.
(($c->id_subscription) ? '<a href="'.Yii::$app->urlManagerProducer->createUrl(['subscription/form','id'=>$c->id_subscription]).'" class="btn btn-default"><span class="glyphicon glyphicon-repeat"></span></a>' : '') ;
$html .= '<a href="'.Yii::$app->urlManager->createUrl(['order/order','id'=>$order->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a> '.
'<a href="'.Yii::$app->urlManager->createUrl(['order/cancel','id'=>$order->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-trash"></span></a> '.
(($order->id_subscription) ? '<a href="'.Yii::$app->urlManagerProducer->createUrl(['subscription/form','id'=>$order->id_subscription]).'" class="btn btn-default"><span class="glyphicon glyphicon-repeat"></span></a>' : '') ;
}
}

return $html ;
}
]

+ 10
- 8
producer/views/order/order.php Dosyayı Görüntüle

@@ -37,19 +37,21 @@ termes.
*/

use common\helpers\GlobalParam ;
use common\logic\Producer\Producer\Producer;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\PointSaleDistribution\Model\PointSaleDistribution;
use common\logic\Producer\Producer\Model\Producer;

\producer\assets\VuejsOrderOrderAsset::register($this);

$this->setTitle('Commander') ;
$producer = $this->context->getProducer();
$producer = $this->context->getProducerCurrent();
$producerManager = $this->getProducerManager();

?>

<script>
var appInitValues = {
urlLogin: '<?= \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer', 'id' => $this->context->getProducer()->id, 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order', 'slug_producer' => $this->context->getProducer()->slug])]) ?>'
urlLogin: '<?= \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer', 'id' => $this->context->getProducerCurrent()->id, 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order', 'slug_producer' => $this->context->getProducerCurrent()->slug])]) ?>'
};
</script>

@@ -163,11 +165,11 @@ $producerManager = $this->getProducerManager();

<?php if($producer->behavior_order_select_distribution == Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST ): ?>
<div id="distributions-list">
<?php $incomingDistributions = DistributionModel::getIncoming(); ?>
<?php $incomingDistributions = Distribution::getIncoming(); ?>
<?php foreach($incomingDistributions as $distribution): ?>

<?php
$pointSaleDistributions = PointSaleDistributionModel::searchAll([
$pointSaleDistributions = PointSaleDistribution::searchAll([
'id_distribution' => $distribution->id,
'delivery' => 1
], [], [
@@ -237,7 +239,7 @@ $producerManager = $this->getProducerManager();
</template>
<template v-else>
<div :class="'form-group' + (pointSale.invalid_code ? ' has-error' : '')">
<div class="input-group" v-if="pointSale.code.length > 0">
<div class="input-group" v-if="pointSale.code && pointSale.code.length > 0">
<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
<input v-model="pointsSaleCodes[pointSale.id]" type="password" placeholder="Code" class="form-control input-code" />
</div>
@@ -250,7 +252,7 @@ $producerManager = $this->getProducerManager();
</a>
</div>
<div v-else>
<button class="btn btn-primary" @click="pointSaleClick" :data-code="pointSale.code.length > 0" :data-id-point-sale="pointSale.id">
<button class="btn btn-primary" @click="pointSaleClick" :data-code="pointSale.code && pointSale.code.length > 0" :data-id-point-sale="pointSale.id">
<span class="glyphicon glyphicon-map-marker"></span>
Choisir
</button>
@@ -523,7 +525,7 @@ $producerManager = $this->getProducerManager();
<th>Délai</th>
</tr>
</thead>
<?php foreach($producer->getSpecificDelays() as $day => $delay): ?>
<?php foreach($producerManager->getSpecificDelays($producer) as $day => $delay): ?>
<?php if($delay['order_delay'] && $delay['order_deadline']): ?>
<tr>
<td>

+ 1
- 0
producer/views/site-producer/error.php Dosyayı Görüntüle

@@ -44,6 +44,7 @@ use yii\helpers\Html;
/* @var $exception Exception */

$this->title = $name;

?>
<div class="site-error">


+ 1
- 1
producer/views/site/contact.php Dosyayı Görüntüle

@@ -46,7 +46,7 @@ $this->setTitle('Contact');
<div class="site-contact">
<div class="row">
<div class="col-lg-5">
<?php $form = yii\bootstrap\ActiveForm::begin(['id' => 'contact-form', 'enableClientValidation' => false,]); ?>
<?php $form = ActiveForm::begin(['id' => 'contact-form', 'enableClientValidation' => false,]); ?>
<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'email') ?>
<?= $form->field($model, 'subject') ?>

+ 2
- 0
producer/views/site/gcs.php Dosyayı Görüntüle

@@ -36,6 +36,8 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

use yii\helpers\Html;

$this->setTitle('Conditions générales de vente');

echo nl2br(Html::encode($producer->gcs)) ;

+ 12
- 8
producer/views/site/index.php Dosyayı Görüntüle

@@ -36,14 +36,19 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

use common\logic\Producer\Producer\Producer;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\PointSaleDistribution\Model\PointSaleDistribution;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use common\logic\Product\Product\Wrapper\ProductManager;
use yii\helpers\Html;
use yii\grid\GridView;
use common\helpers\Price;

$producer = $this->context->getProducer() ;
$productManager = $this->getProductManager();
$producerManager = $this->getProducerManager();
$productManager = ProductManager::getInstance();
$producerManager = ProducerManager::getInstance();
$producer = $this->context->getProducerCurrent() ;

$this->setTitle('Accueil');
$this->setPageTitle(Html::encode($producer->type.' à '.$producer->city)) ;

@@ -83,7 +88,7 @@ $this->setPageTitle(Html::encode($producer->type.' à '.$producer->city)) ;
'contentOptions' => ['class' => 'days'],
'value' => function($model) {

$producer = \Yii::$app->controller->getProducer() ;
$producer = \Yii::$app->controller->getProducerCurrent() ;

if($producer->behavior_home_point_sale_day_list == Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_WEEK) {
$arrayDays = [
@@ -114,10 +119,10 @@ $this->setPageTitle(Html::encode($producer->type.' à '.$producer->city)) ;
}
elseif($producer->behavior_home_point_sale_day_list == Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_INCOMING_DISTRIBUTIONS) {
$html = '' ;
$incomingDistributions = DistributionModel::getIncoming();
$incomingDistributions = Distribution::getIncoming();
$cpt = 0 ;
foreach($incomingDistributions as $distribution) {
$countPointSaleDistribution = PointSaleDistributionModel::searchCount([
$countPointSaleDistribution = PointSaleDistribution::searchCount([
'id_distribution' => $distribution->id,
'id_point_sale' => $model->id,
'delivery' => 1
@@ -141,7 +146,6 @@ $this->setPageTitle(Html::encode($producer->type.' à '.$producer->city)) ;
<h3><span>Produits</span></h3>

<?php

$columnsProducts = [] ;
if($hasProductPhoto) {
$columnsProducts [] = [

+ 1
- 0
producer/views/site/mentions.php Dosyayı Görüntüle

@@ -36,6 +36,7 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

use yii\helpers\Html;

$this->setTitle('Mentions légales');


+ 3
- 3
producer/views/subscription/_form.php Dosyayı Görüntüle

@@ -36,11 +36,11 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

use common\logic\Producer\Producer\Producer;
use common\logic\Producer\Producer\Wrapper\ProducerManager;

\producer\assets\VuejsSubscriptionFormAsset::register($this) ;
$producerManager = ProducerManager::getInstance();

$producerManager = $this->getProducerManager();
\producer\assets\VuejsSubscriptionFormAsset::register($this) ;

?>


+ 0
- 2
producer/views/subscription/form.php Dosyayı Görüntüle

@@ -36,8 +36,6 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

use yii\helpers\Html;

if($idSubscription > 0) {
$this->setTitle('Modifier un abonnement') ;
}

+ 2
- 2
producer/views/subscription/index.php Dosyayı Görüntüle

@@ -36,12 +36,12 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Product\Product\Model\Product;
use yii\helpers\Html;
use yii\grid\GridView;
use common\helpers\GlobalParam;
use common\logic\Producer\Producer\Producer;
use yii\helpers\ArrayHelper;
use common\logic\PointSale\PointSale\PointSale;

$producerManager = $this->getProducerManager();


Yükleniyor…
İptal
Kaydet