소스 검색

Points de vente partagés

feature/rotating_product
Guillaume Bourgeois 4 달 전
부모
커밋
9a6d6ea0d7
13개의 변경된 파일294개의 추가작업 그리고 44개의 파일을 삭제
  1. +20
    -5
      backend/controllers/SharedPointSaleController.php
  2. +15
    -1
      backend/views/layouts/content.php
  3. +1
    -1
      backend/views/layouts/left.php
  4. +86
    -4
      backend/views/shared-point-sale/index.php
  5. +2
    -2
      common/views/alert_message.php
  6. +1
    -1
      domain/Order/OrderStatus/OrderStatusDefinition.php
  7. +16
    -0
      domain/PointSale/PointSale/PointSale.php
  8. +41
    -28
      domain/PointSale/SharedPointSale/SharedPointSale.php
  9. +6
    -0
      domain/PointSale/SharedPointSale/SharedPointSaleModule.php
  10. +11
    -2
      domain/PointSale/SharedPointSale/SharedPointSaleRepository.php
  11. +28
    -0
      domain/PointSale/SharedPointSale/SharedPointSaleRepositoryQuery.php
  12. +62
    -0
      domain/PointSale/SharedPointSale/SharedPointSaleResolver.php
  13. +5
    -0
      domain/Producer/Producer/Producer.php

+ 20
- 5
backend/controllers/SharedPointSaleController.php 파일 보기

@@ -38,11 +38,8 @@

namespace backend\controllers;

use backend\controllers\BackendController;
use backend\forms\SharedPointSaleForm;
use backend\models\AccessUserProducerForm;
use domain\PointSale\SharedPointSale\SharedPointSale;
use domain\Feature\Feature\Feature;
use domain\User\User\UserSearch;
use yii\filters\AccessControl;
use yii\web\NotFoundHttpException;

@@ -79,7 +76,8 @@ class SharedPointSaleController extends BackendController

return $this->render('index', [
'sharedPointsSaleRequestOfMe' => $sharedPointSaleRepository->findSharedPointsSaleRequestsOfMe(),
'sharedPointsSaleRequestOthers' => $sharedPointSaleRepository->findSharedPointsSaleRequestsOthers()
'sharedPointsSaleRequestOthers' => $sharedPointSaleRepository->findSharedPointsSaleRequestsOthers(),
'pointsSaleArray' => $this->getPointSaleModule()->getRepository()->findPointSales()
]);
}

@@ -103,6 +101,23 @@ class SharedPointSaleController extends BackendController
]);
}

public function actionConfirm(int $id)
{
$sharedPointSale = $this->findSharedPointSale($id);
$sharedPointSale->scenario = SharedPointSale::SCENARIO_CONFIRM;
if($sharedPointSale->load(\Yii::$app->request->post()) && $sharedPointSale->validate()) {
$pointSaleWithSharing = $sharedPointSale->getPointSaleWithSharing();
if($this->getSharedPointSaleModule()->getManager()->confirmSharedPointSale($sharedPointSale, $pointSaleWithSharing, $this->getUserCurrent())) {
$this->addFlash('success', "La demande de partage de point de vente a bien été acceptée.");
}
else {
$this->addFlash('error', "Une erreur est survenue lors de l'annulation de la demande de partage.");
}
}

return $this->redirect(['index']);
}

public function actionDecline(int $id)
{
$sharedPointSale = $this->findSharedPointSale($id);

+ 15
- 1
backend/views/layouts/content.php 파일 보기

@@ -43,6 +43,7 @@ use common\helpers\GlobalParam;

$producerModule = $this->getProducerModule();
$adminSettingBag = $this->getSettingModule()->getAdminSettingBag();
$sharedPointSaleModule = $this->getSharedPointSaleModule();

?>
<div class="content-wrapper">
@@ -92,11 +93,24 @@ $adminSettingBag = $this->getSettingModule()->getAdminSettingBag();
<?php $producer = GlobalParam::getCurrentProducer(); ?>
<?php if($producer && !$producerModule->isUpToDateWithOpendistribVersion($producer) && $producer->option_display_message_new_opendistrib_version): ?>
<div class="alert alert-success">
<p>Souke a été mis à jour vers la version <?= GlobalParam::getSoukeVersion() ?> ! <a class="alert-link" href="<?= Yii::$app->urlManager->createUrl(['development/index']) ?>">Découvrir les nouveautés</a></p>
<p>
<i class="icon fa fa-cogs"></i>
Souke a été mis à jour vers la version <?= GlobalParam::getSoukeVersion() ?> ! <a class="alert-link" href="<?= Yii::$app->urlManager->createUrl(['development/index']) ?>">Découvrir les nouveautés</a>
</p>
<a href="<?= Yii::$app->urlManager->createUrl(['producer/update-opendistrib-version']) ?>" class="close"><span aria-hidden="true">&times;</span></a>
</div>
<?php endif; ?>

<?php $countSharedPointsSaleRequestsOthers = $sharedPointSaleModule->getResolver()->countSharedPointsSaleRequestsOthers(); ?>
<?php if($countSharedPointsSaleRequestsOthers): ?>
<div class="alert alert-info">
<p>
<i class="icon fa fa-share-alt"></i>
Vous avez une demande de partage de point de vente en attente. <a class="alert-link" href="<?= Yii::$app->urlManager->createUrl(['shared-point-sale/index']) ?>">Voir</a>
</p>
</div>
<?php endif; ?>

<?php
$flashTypeArray = ['error' => 'ban', 'danger' => 'ban', 'warning' => 'warning', 'info' => 'info', 'success' => 'check'];
foreach($flashTypeArray as $flashType => $icon) {

+ 1
- 1
backend/views/layouts/left.php 파일 보기

@@ -210,7 +210,7 @@ $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGran
'active' => Yii::$app->controller->id == 'point-sale' || Yii::$app->controller->id == 'shared-point-sale',
'items' => [
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/point-sale/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Partagés', 'icon' => 'share-alt', 'url' => ['/shared-point-sale/index'], 'visible' => $isUserCurrentGrantedAsProducer && $featureChecker->isEnabled(Feature::ALIAS_SHARED_POINT_SALE)],
['label' => 'Partages', 'icon' => 'share-alt', 'url' => ['/shared-point-sale/index'], 'visible' => $isUserCurrentGrantedAsProducer && $featureChecker->isEnabled(Feature::ALIAS_SHARED_POINT_SALE)],
]
],
[

+ 86
- 4
backend/views/shared-point-sale/index.php 파일 보기

@@ -40,7 +40,9 @@ use domain\PointSale\UserPointSale\UserPointSale;
use domain\Producer\Producer\Producer;
use yii\grid\GridView;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

$sharedPointSaleModule = $this->getSharedPointSaleModule();
$pointSaleModule = $this->getPointSaleModule();

$this->setTitle('Points de vente partagés');
@@ -60,7 +62,7 @@ $this->addButton(
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Demandes de partage en attente
Mes demandes de partages en attente
</h3>
</div>
<div class="panel-body">
@@ -75,10 +77,10 @@ $this->addButton(
<tbody>
<?php foreach($sharedPointsSaleRequestOfMe as $sharedPointSale): ?>
<tr>
<td><?= Html::encode($sharedPointSale->getPointSale()->name); ?></td>
<td><?= Html::encode($sharedPointSale->getProducerWithSharing()->name); ?></td>
<td><?= Html::encode($sharedPointSale->getPointSale()->getName()); ?></td>
<td><?= Html::encode($sharedPointSale->getProducerWithSharing()->getName()); ?></td>
<td>
<a href="<?= Yii::$app->urlManager->createUrl(['shared-point-sale/decline', 'id' => $sharedPointSale->id]) ?>" class="btn btn-default">Annuler</a>
<a href="<?= Yii::$app->urlManager->createUrl(['shared-point-sale/decline', 'id' => $sharedPointSale->getId()]) ?>" class="btn btn-default">Annuler</a>
</td>
</tr>
<?php endforeach; ?>
@@ -88,4 +90,84 @@ $this->addButton(
</div>
<?php endif; ?>

<?php if(count($sharedPointsSaleRequestOthers)): ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Demandes de partage des autres producteurs
</h3>
</div>
<div class="panel-body">
<table class="table table-striped table-bordered">
<thead>
<tr>
<td>Producteur</td>
<td>Point de vente</td>
<td></td>
</tr>
</thead>
<tbody>
<?php foreach($sharedPointsSaleRequestOthers as $sharedPointSale): ?>
<tr>
<td><?= Html::encode($sharedPointSale->getPointSale()->getProducer()->getName()); ?></td>
<td><?= Html::encode($sharedPointSale->getPointSale()->getName()); ?></td>
<td>
<?php $form = ActiveForm::begin([
'enableClientValidation' => false,
'action' => Yii::$app->urlManager->createUrl(['shared-point-sale/confirm', 'id' => $sharedPointSale->getId()])
]); ?>
<?= $form->field($sharedPointSale, 'id_point_sale_with_sharing')
->dropDownList($pointSaleModule->getRepository()->populatePointSaleDropdownList())
->label('Votre point de vente'); ?>
<?= Html::submitButton('Confirmer', ['class' => 'btn btn-success', 'name' => 'save']) ?>
<?php ActiveForm::end(); ?>
</td>
<td>
<a href="<?= Yii::$app->urlManager->createUrl(['shared-point-sale/decline', 'id' => $sharedPointSale->getId()]) ?>" class="btn btn-danger">Décliner</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php endif; ?>

<?php if($sharedPointSaleModule->getResolver()->countPointsSaleShared()): ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Partages confirmés
</h3>
</div>
<div class="panel-body">
<table class="table table-striped table-bordered">
<thead>
<tr>
<td>Point de vente</td>
<td>Partagé avec</td>
</tr>
</thead>
<tbody>
<?php foreach($pointsSaleArray as $pointSale): ?>
<?php
$pointsSaleSharedWithPointSaleArray = $sharedPointSaleModule->getResolver()->getPointsSaleSharedWithPointSale($pointSale);
if(count($pointsSaleSharedWithPointSaleArray)):
?>
<tr>
<td><?= Html::encode($pointSale->getName()); ?></td>
<td>
<?php foreach($pointsSaleSharedWithPointSaleArray as $pointSaleSharedWithPointSale): ?>
<?= Html::encode($pointSaleSharedWithPointSale->getProducer()->getName()); ?>
<?php // Html::encode($pointSaleSharedWithPointSale->getName()); ?>
<?php endforeach; ?>
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php endif; ?>
</div>

+ 2
- 2
common/views/alert_message.php 파일 보기

@@ -6,7 +6,7 @@ use yii\helpers\Html;

<?php if($display && $message): ?>
<div class="alert alert-<?= $type ?>">
<?php if($title): ?>
<?php if(isset($title) && $title): ?>
<h4>
<?php if($icon): ?>
<i class="icon fa fa-<?= $icon ?>"></i>
@@ -15,7 +15,7 @@ use yii\helpers\Html;
</h4>
<?php endif; ?>
<p>
<?php if(!$title && $icon): ?>
<?php if((!isset($title) || !$title) && $icon): ?>
<i class="icon fa fa-<?= $icon ?>"></i>
<?php endif; ?>
<?php if(is_array($message)): ?>

+ 1
- 1
domain/Order/OrderStatus/OrderStatusDefinition.php 파일 보기

@@ -15,7 +15,7 @@ class OrderStatusDefinition extends AbstractDefinition
{
return [
OrderStatus::ALIAS_ORDERED => [
'label' => 'Créée'
'label' => 'Ajoutée'
],
OrderStatus::ALIAS_UPDATED => [
'label' => 'Modifiée'

+ 16
- 0
domain/PointSale/PointSale/PointSale.php 파일 보기

@@ -42,6 +42,7 @@ use common\components\ActiveRecordCommon;
use common\helpers\GlobalParam;
use domain\Distribution\PointSaleDistribution\PointSaleDistribution;
use domain\PointSale\UserPointSale\UserPointSale;
use domain\Producer\Producer\Producer;
use domain\User\User\User;

/**
@@ -136,10 +137,25 @@ class PointSale extends ActiveRecordCommon
];
}

public function getName(): string
{
return $this->name;
}

public function getProducer(): Producer
{
return $this->producerRelation;
}

/*
* Relations
*/

public function getProducerRelation()
{
return $this->hasOne(Producer::class, ['id' => 'id_producer']);
}

public function getUserPointSale()
{
return $this->hasMany(UserPointSale::class, ['id_point_sale' => 'id']);

+ 41
- 28
domain/PointSale/SharedPointSale/SharedPointSale.php 파일 보기

@@ -9,6 +9,46 @@ use domain\User\User\User;

class SharedPointSale extends ActiveRecordCommon
{
/* Yii */

public const SCENARIO_CONFIRM = 'confirm';

public static function tableName()
{
return 'shared_point_sale';
}

public function rules()
{
return [
[['id_point_sale', 'id_producer_with_sharing', 'created_at', 'created_by'], 'required'],
['id_point_sale_with_sharing', 'required', 'on' => self::SCENARIO_CONFIRM],
[['id_point_sale', 'id_producer_with_sharing', 'id_point_sale_with_sharing', 'status',
'created_by', 'confirmed_by', 'declined_by'], 'integer'],
[['created_at', 'confirmed_at', 'declined_at'], 'safe'],
['id_point_sale', 'exist', 'targetClass' => PointSale::class, 'targetAttribute' => 'id'],
['id_point_sale_with_sharing', 'exist', 'targetClass' => PointSale::class, 'targetAttribute' => 'id'],
['id_producer_with_sharing', 'exist', 'targetClass' => Producer::class, 'targetAttribute' => 'id'],
[['created_by', 'confirmed_by', 'declined_by'], 'exist', 'targetClass' => User::class, 'targetAttribute' => 'id'],
];
}

public function attributeLabels()
{
return [
'id_point_sale' => 'Point de vente que vous souhaitez partager',
'id_producer_with_sharing' => 'Producteur avec qui vous souhaitez partager un point de vente',
'id_point_sale_with_sharing' => 'Point de vente du producteur avec qui vous souhaitez partager ce point de vente',
];
}

/* Get / Set */

public function getId(): ?int
{
return $this->id;
}

public function getPointSale(): PointSale
{
return $this->pointSaleRelation;
@@ -34,7 +74,7 @@ class SharedPointSale extends ActiveRecordCommon

public function getPointSaleWithSharing(): ?PointSale
{
return $this->pointSaleWithSharing;
return $this->pointSaleWithSharingRelation;
}

public function setPointSaleWithSharing(PointSale $pointSaleWithSharing = null): self
@@ -123,33 +163,6 @@ class SharedPointSale extends ActiveRecordCommon
return $this;
}

public static function tableName()
{
return 'shared_point_sale';
}

public function rules()
{
return [
[['id_point_sale', 'id_producer_with_sharing', 'created_at', 'created_by'], 'required'],
[['id_point_sale', 'id_producer_with_sharing', 'id_point_sale_with_sharing', 'status',
'created_by', 'confirmed_by', 'declined_by'], 'integer'],
[['created_at', 'confirmed_at', 'declined_at'], 'safe'],
['id_point_sale', 'exist', 'targetClass' => PointSale::class, 'targetAttribute' => 'id'],
['id_producer_with_sharing', 'exist', 'targetClass' => Producer::class, 'targetAttribute' => 'id'],
[['created_by', 'confirmed_by', 'declined_by'], 'exist', 'targetClass' => User::class, 'targetAttribute' => 'id'],
];
}

public function attributeLabels()
{
return [
'id_point_sale' => 'Point de vente que vous souhaitez partager',
'id_producer_with_sharing' => 'Producteur avec qui vous souhaitez partager un point de vente',
'id_point_sale_with_sharing' => 'Point de vente du producteur avec qui vous souhaitez partager ce point de vente',
];
}

/* Relations */

public function getPointSaleRelation()

+ 6
- 0
domain/PointSale/SharedPointSale/SharedPointSaleModule.php 파일 보기

@@ -12,6 +12,7 @@ class SharedPointSaleModule extends AbstractModule
SharedPointSaleDefinition::class,
SharedPointSaleBuilder::class,
SharedPointSaleRepository::class,
SharedPointSaleResolver::class,
SharedPointSaleManager::class
];
}
@@ -31,6 +32,11 @@ class SharedPointSaleModule extends AbstractModule
return SharedPointSaleRepository::getInstance();
}

public function getResolver(): SharedPointSaleResolver
{
return SharedPointSaleResolver::getInstance();
}

public function getManager(): SharedPointSaleManager
{
return SharedPointSaleManager::getInstance();

+ 11
- 2
domain/PointSale/SharedPointSale/SharedPointSaleRepository.php 파일 보기

@@ -3,6 +3,7 @@
namespace domain\PointSale\SharedPointSale;

use domain\_\AbstractRepository;
use domain\PointSale\PointSale\PointSale;

class SharedPointSaleRepository extends AbstractRepository
{
@@ -34,7 +35,7 @@ class SharedPointSaleRepository extends AbstractRepository
{
return $this->createQuery()
->filterByProducerOfPointSale($this->getProducerContext())
->filterIsStatusOnline()
->filterIsRequest()
->find();
}

@@ -42,7 +43,15 @@ class SharedPointSaleRepository extends AbstractRepository
{
return $this->createQuery()
->filterByProducerWithSharing($this->getProducerContext())
->filterIsStatusOnline()
->filterIsRequest()
->find();
}

public function findSharedPointsSaleConfirmedByPointSale(PointSale $pointSale)
{
return $this->createQuery()
->filterByPointSale($pointSale)
->filterIsConfirmed()
->find();
}
}

+ 28
- 0
domain/PointSale/SharedPointSale/SharedPointSaleRepositoryQuery.php 파일 보기

@@ -4,6 +4,7 @@ namespace domain\PointSale\SharedPointSale;

use domain\_\AbstractRepositoryQuery;
use domain\_\StatusInterface;
use domain\PointSale\PointSale\PointSale;
use domain\Producer\Producer\Producer;

class SharedPointSaleRepositoryQuery extends AbstractRepositoryQuery
@@ -32,4 +33,31 @@ class SharedPointSaleRepositoryQuery extends AbstractRepositoryQuery
$this->andWhere(['id_producer_with_sharing' => $producer->id]);
return $this;
}

public function filterByPointSale(PointSale $pointSale)
{
$this->andWhere('id_point_sale = :id_point_sale OR id_point_sale_with_sharing = :id_point_sale')
->addParams(['id_point_sale' => $pointSale->id]);
return $this;
}

public function filterIsRequest()
{
$this->filterIsPointSaleWithSharingIsNull()
->filterIsStatusOnline();
return $this;
}

public function filterIsConfirmed()
{
$this->filterIsStatusOnline();
$this->andWhere('id_point_sale_with_sharing IS NOT NULL AND confirmed_at IS NOT NULL');
return $this;
}

public function filterIsPointSaleWithSharingIsNull(): self
{
$this->andWhere('id_point_sale_with_sharing IS NULL');
return $this;
}
}

+ 62
- 0
domain/PointSale/SharedPointSale/SharedPointSaleResolver.php 파일 보기

@@ -0,0 +1,62 @@
<?php

namespace domain\PointSale\SharedPointSale;

use domain\_\AbstractResolver;
use domain\PointSale\PointSale\PointSale;
use domain\PointSale\PointSale\PointSaleRepository;

class SharedPointSaleResolver extends AbstractResolver
{
protected PointSaleRepository $pointSaleRepository;
protected SharedPointSaleRepository $sharedPointSaleRepository;

public function loadDependencies(): void
{
$this->pointSaleRepository = $this->loadService(PointSaleRepository::class);
$this->sharedPointSaleRepository = $this->loadService(SharedPointSaleRepository::class);
}

public function getPointsSaleSharedWithPointSale(PointSale $pointSale): array
{
$pointsSaleSharedWithPointSaleArray = [];
$sharedPointsSaleConfirmedArray = $this->sharedPointSaleRepository->findSharedPointsSaleConfirmedByPointSale($pointSale);

foreach($sharedPointsSaleConfirmedArray as $sharedPointSaleConfirmed) {
if($sharedPointSaleConfirmed->getPointSale()->id != $pointSale->id
&& !in_array($sharedPointSaleConfirmed->getPointSale(), $pointsSaleSharedWithPointSaleArray)) {
$pointsSaleSharedWithPointSaleArray[] = $sharedPointSaleConfirmed->getPointSale();
}
if($sharedPointSaleConfirmed->getPointSaleWithSharing()->id != $pointSale->id
&& !in_array($sharedPointSaleConfirmed->getPointSaleWithSharing(), $pointsSaleSharedWithPointSaleArray)) {
$pointsSaleSharedWithPointSaleArray[] = $sharedPointSaleConfirmed->getPointSaleWithSharing();
}
}

return $pointsSaleSharedWithPointSaleArray;
}

public function hasPointSaleSharedWithPointSale(PointSale $pointSale): bool
{
return (bool) count($this->getPointsSaleSharedWithPointSale($pointSale));
}

public function countPointsSaleShared(): int
{
$count = 0;
$pointsSaleArray = $this->pointSaleRepository->findPointSales();

foreach($pointsSaleArray as $pointSale) {
if($this->hasPointSaleSharedWithPointSale($pointSale)) {
$count ++;
}
}

return $count;
}

public function countSharedPointsSaleRequestsOthers(): int
{
return count($this->sharedPointSaleRepository->findSharedPointsSaleRequestsOthers());
}
}

+ 5
- 0
domain/Producer/Producer/Producer.php 파일 보기

@@ -545,6 +545,11 @@ class Producer extends ActiveRecordCommon
];
}

public function getName(): string
{
return $this->name;
}

/*
* Relations
*/

Loading…
취소
저장