浏览代码

Refactoring services #885

refactoring
Guillaume 1年前
父节点
当前提交
24ac35d0d1
共有 66 个文件被更改,包括 26489 次插入259 次删除
  1. +5
    -5
      common/components/BusinessLogic.php
  2. +1
    -1
      common/config/main.php
  3. +2
    -1
      common/controllers/CommonController.php
  4. +6
    -5
      common/forms/LoginForm.php
  5. +3
    -1
      common/helpers/CSV.php
  6. +2
    -1
      common/helpers/GlobalParam.php
  7. +4
    -3
      common/helpers/Tiller.php
  8. +6
    -5
      common/logic/BaseService.php
  9. +2
    -2
      common/logic/Producer/Producer/ProducerBuilder.php
  10. +1
    -2
      common/logic/Producer/Producer/ProducerContainer.php
  11. +1
    -1
      common/logic/Producer/Producer/ProducerFactory.php
  12. +6
    -6
      common/logic/Producer/Producer/ProducerModel.php
  13. +1
    -1
      common/logic/Producer/Producer/ProducerRepository.php
  14. +1
    -2
      common/logic/Producer/Producer/ProducerUtils.php
  15. +1
    -1
      common/logic/Producer/ProducerPriceRange/ProducerPriceRangeContainer.php
  16. +1
    -1
      common/logic/Producer/ProducerPriceRange/ProducerPriceRangeModel.php
  17. +1
    -1
      common/logic/Producer/ProducerPriceRange/ProducerPriceRangeRepository.php
  18. +2
    -2
      common/logic/User/CreditHistory/CreditHistoryBuilder.php
  19. +1
    -1
      common/logic/User/CreditHistory/CreditHistoryContainer.php
  20. +1
    -1
      common/logic/User/CreditHistory/CreditHistoryFactory.php
  21. +1
    -1
      common/logic/User/CreditHistory/CreditHistoryModel.php
  22. +1
    -1
      common/logic/User/CreditHistory/CreditHistoryRepository.php
  23. +4
    -4
      common/logic/User/CreditHistory/CreditHistorySolver.php
  24. +1
    -1
      common/logic/User/User/UserBuilder.php
  25. +1
    -3
      common/logic/User/User/UserContainer.php
  26. +1
    -1
      common/logic/User/User/UserFactory.php
  27. +22
    -15
      common/logic/User/User/UserModel.php
  28. +1
    -1
      common/logic/User/User/UserRepository.php
  29. +2
    -3
      common/logic/User/User/UserUtils.php
  30. +1
    -1
      common/logic/User/UserProducer/UserProducerBuilder.php
  31. +3
    -4
      common/logic/User/UserProducer/UserProducerContainer.php
  32. +3
    -3
      common/logic/User/UserProducer/UserProducerModel.php
  33. +1
    -1
      common/logic/User/UserProducer/UserProducerRepository.php
  34. +2
    -2
      common/mail/creditUser-html.php
  35. +1
    -1
      common/mail/creditUser-text.php
  36. +5
    -3
      common/mail/orderConfirm-html.php
  37. +4
    -3
      common/mail/orderConfirm-text.php
  38. +5
    -2
      common/mail/paymentError-html.php
  39. +1
    -1
      common/mail/signup-html.php
  40. +2
    -1
      common/mail/signup-text.php
  41. +5
    -4
      common/models/CreditHistorySearch.php
  42. +2
    -1
      common/models/DevelopmentPriority.php
  43. +2
    -1
      common/models/Distribution.php
  44. +8
    -7
      common/models/Document.php
  45. +21
    -18
      common/models/Order.php
  46. +2
    -1
      common/models/PointSale.php
  47. +2
    -1
      common/models/Product.php
  48. +15
    -17
      common/models/Subscription.php
  49. +3
    -1
      frontend/controllers/SiteController.php
  50. +14
    -15
      frontend/forms/SignupForm.php
  51. +2
    -2
      frontend/views/layouts/main.php
  52. +15
    -16
      producer/controllers/CreditController.php
  53. +21
    -21
      producer/controllers/OrderController.php
  54. +13
    -12
      producer/controllers/ProducerBaseController.php
  55. +5
    -3
      producer/controllers/SiteController.php
  56. +9
    -6
      producer/controllers/SubscriptionController.php
  57. +2
    -1
      producer/models/CreditForm.php
  58. +26203
    -0
      producer/runtime/logs/app.log
  59. +2
    -1
      producer/views/credit/add.php
  60. +15
    -15
      producer/views/credit/history.php
  61. +3
    -3
      producer/views/layouts/main.php
  62. +3
    -3
      producer/views/order/_form.php
  63. +5
    -5
      producer/views/order/order.php
  64. +3
    -3
      producer/views/site/index.php
  65. +2
    -6
      producer/views/subscription/_form.php
  66. +2
    -1
      producer/views/subscription/index.php

+ 5
- 5
common/components/BusinessLogic.php 查看文件

@@ -2,11 +2,11 @@

namespace common\components;

use common\containers\UserProducerContainer;
use common\logic\CreditHistory\CreditHistoryContainer;
use common\logic\Producer\ProducerContainer;
use common\logic\ProducerPriceRange\ProducerPriceRangeContainer;
use common\logic\User\UserContainer;
use common\logic\Producer\Producer\ProducerContainer;
use common\logic\Producer\ProducerPriceRange\ProducerPriceRangeContainer;
use common\logic\User\CreditHistory\CreditHistoryContainer;
use common\logic\User\User\UserContainer;
use common\logic\User\UserProducer\UserProducerContainer;
use yii\base\ErrorException;

class BusinessLogic

+ 1
- 1
common/config/main.php 查看文件

@@ -61,7 +61,7 @@ return [
],
'user' => [
'class' => 'yii\web\User',
'identityClass' => 'common\logic\User\UserModel',
'identityClass' => 'common\logic\User\User\UserModel',
'enableAutoLogin' => true,
'identityCookie' => [
'name' => 'distrib',

+ 2
- 1
common/controllers/CommonController.php 查看文件

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

namespace common\controllers;

use common\components\BusinessLogic;
use yii;

class CommonController extends \yii\web\Controller
@@ -51,7 +52,7 @@ class CommonController extends \yii\web\Controller
return parent::beforeAction($event);
}

public function getLogic()
public function getLogic(): BusinessLogic
{
return Yii::$app->logic;
}

+ 6
- 5
common/forms/LoginForm.php 查看文件

@@ -38,6 +38,8 @@ termes.

namespace common\forms;

use common\logic\Producer\Producer\ProducerModel;
use common\logic\User\User\UserModel;
use Yii;
use yii\base\Model;

@@ -72,7 +74,7 @@ class LoginForm extends Model
['id_producer', 'integer'],
['id_producer', function($attribute, $params) {
if ($this->id_producer) {
$producer = Producer::findOne($this->id_producer);
$producer = ProducerModel::findOne($this->id_producer);
if (!$producer) {
$this->addError($attribute, 'Ce producteur n\'existe pas.');
}
@@ -116,16 +118,15 @@ class LoginForm extends Model
/**
* Finds user by [[username]]
*
* @return User|null
*/
public function getUser()
public function getUser(): UserModel
{
if ($this->_user === false) {
$this->_user = User::searchOne(
$this->_user = UserModel::searchOne(
['email' => $this->email],
[
'conditions' => 'type LIKE :type_individual OR type LIKE :type_legal_person',
'params' => [':type_individual' => User::TYPE_INDIVIDUAL, ':type_legal_person' => User::TYPE_LEGAL_PERSON]
'params' => [':type_individual' => UserModel::TYPE_INDIVIDUAL, ':type_legal_person' => UserModel::TYPE_LEGAL_PERSON]
]
);
}

+ 3
- 1
common/helpers/CSV.php 查看文件

@@ -39,12 +39,14 @@

namespace common\helpers;

use common\logic\Producer\Producer\ProducerModel;

class CSV
{

public static function array2csv(array &$array)
{
$separator = Producer::getConfig('option_csv_separator') ?: ';';
$separator = ProducerModel::getConfig('option_csv_separator') ?: ';';

if (count($array) == 0) {
return null;

+ 2
- 1
common/helpers/GlobalParam.php 查看文件

@@ -38,6 +38,7 @@

namespace common\helpers;

use common\logic\Producer\Producer\ProducerModel;
use common\models\Producer;

class GlobalParam
@@ -60,7 +61,7 @@ class GlobalParam
public static function getCurrentProducer()
{
if (\Yii::$app->params['producer'] == false) {
\Yii::$app->params['producer'] = Producer::searchOne();
\Yii::$app->params['producer'] = ProducerModel::searchOne();
}
return \Yii::$app->params['producer'];
}

+ 4
- 3
common/helpers/Tiller.php 查看文件

@@ -38,6 +38,7 @@

namespace common\helpers;

use common\logic\Producer\Producer\ProducerModel;
use linslin\yii2\curl;

class Tiller
@@ -52,9 +53,9 @@ class Tiller
public function __construct()
{
$this->curl = new curl\Curl();
$this->producer_tiller = Producer::getConfig('tiller');
$this->provider_token = Producer::getConfig('tiller_provider_token');
$this->restaurant_token = Producer::getConfig('tiller_restaurant_token');
$this->producer_tiller = ProducerModel::getConfig('tiller');
$this->provider_token = ProducerModel::getConfig('tiller_provider_token');
$this->restaurant_token = ProducerModel::getConfig('tiller_restaurant_token');
}

public function getOrders($date)

+ 6
- 5
common/logic/BaseService.php 查看文件

@@ -11,8 +11,9 @@ class BaseService
return [
FactoryInterface::class,
SolverInterface::class,
RepositoryInterface::class,
BuilderInterface::class,
ServiceInterface::class,
UtilsInterface::class,
];
}

@@ -74,17 +75,17 @@ class BaseService
return $this->classImplementsInterface(BuilderInterface::class);
}

public function isService(): bool
public function isUtils(): bool
{
return $this->classImplementsInterface(ServiceInterface::class);
return $this->classImplementsInterface(UtilsInterface::class);
}

protected function classImplementsInterface(string $interface, $object = null): bool
protected function classImplementsInterface(string $interface, $object = null)
{
if(is_null($object)) {
$object = $this;
}

return class_implements($object, $interface);
return in_array($interface, class_implements($object));
}
}

common/logic/Producer/ProducerBuilder.php → common/logic/Producer/Producer/ProducerBuilder.php 查看文件

@@ -1,11 +1,11 @@
<?php

namespace common\logic\Producer;
namespace common\logic\Producer\Producer;

use common\helpers\Password;
use common\logic\BaseService;
use common\logic\BuilderInterface;
use common\logic\UserProducer\UserProducerModel;
use common\logic\User\UserProducer\UserProducerModel;

class ProducerBuilder extends BaseService implements BuilderInterface
{

common/logic/Producer/ProducerContainer.php → common/logic/Producer/Producer/ProducerContainer.php 查看文件

@@ -1,9 +1,8 @@
<?php

namespace common\logic\Producer;
namespace common\logic\Producer\Producer;

use common\logic\ContainerInterface;
use common\services\Producer\ProducerUtils;

class ProducerContainer implements ContainerInterface
{

common/logic/Producer/ProducerFactory.php → common/logic/Producer/Producer/ProducerFactory.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace common\logic\Producer;
namespace common\logic\Producer\Producer;

use common\logic\BaseService;
use common\logic\FactoryInterface;

common/logic/Producer/ProducerModel.php → common/logic/Producer/Producer/ProducerModel.php 查看文件

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

namespace common\logic\Producer;
namespace common\logic\Producer\Producer;

use common\logic\User\UserModel;
use common\logic\User\User\UserModel;
use common\models\TaxRate;
use common\logic\UserProducer\UserProducerModel;
use common\logic\User\UserProducer\UserProducerModel;
use Yii;
use common\components\ActiveRecordCommon;
use common\helpers\Departments;
@@ -436,7 +436,7 @@ class ProducerModel extends ActiveRecordCommon
public function getContact()
{
return $this->hasMany(UserModel::className(), ['id_producer' => 'id'])
->where(['status' => User::STATUS_PRODUCER]);
->where(['status' => UserModel::STATUS_PRODUCER]);
}

public function getTaxRate()
@@ -839,7 +839,7 @@ class ProducerModel extends ActiveRecordCommon

public function getUrlLogo()
{
return Yii::$app->urlManagerProducer->getHostInfo() . '/' . Yii::$app->urlManagerProducer->baseUrl . '/uploads/' . $this->logo;
return Yii::$app->urlManagerProducer->getHostInfo() . 'ProducerModel.php/' . Yii::$app->urlManagerProducer->baseUrl . '/uploads/' . $this->logo;
}

public function getEmailOpendistrib()
@@ -917,7 +917,7 @@ class ProducerModel extends ActiveRecordCommon
$this->save();
}

public function getOnlinePaymentMinimumAmount()
public static function getOnlinePaymentMinimumAmount()
{
$onlinePaymentMinimumAmount = self::getConfig('option_online_payment_minimum_amount');
if (!$onlinePaymentMinimumAmount) {

common/logic/Producer/ProducerRepository.php → common/logic/Producer/Producer/ProducerRepository.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace common\logic\Producer;
namespace common\logic\Producer\Producer;

use common\helpers\Departments;
use common\logic\BaseService;

common/logic/Producer/ProducerUtils.php → common/logic/Producer/Producer/ProducerUtils.php 查看文件

@@ -1,9 +1,8 @@
<?php

namespace common\services\Producer;
namespace common\logic\Producer\Producer;

use common\logic\BaseService;
use common\logic\Producer\ProducerModel;
use common\logic\UtilsInterface;

class ProducerUtils extends BaseService implements UtilsInterface

common/logic/ProducerPriceRange/ProducerPriceRangeContainer.php → common/logic/Producer/ProducerPriceRange/ProducerPriceRangeContainer.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace common\logic\ProducerPriceRange;
namespace common\logic\Producer\ProducerPriceRange;

use common\logic\ContainerInterface;


common/logic/ProducerPriceRange/ProducerPriceRangeModel.php → common/logic/Producer/ProducerPriceRange/ProducerPriceRangeModel.php 查看文件

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

namespace common\logic\ProducerPriceRange;
namespace common\logic\Producer\ProducerPriceRange;

use common\components\ActiveRecordCommon;


common/logic/ProducerPriceRange/ProducerPriceRangeRepository.php → common/logic/Producer/ProducerPriceRange/ProducerPriceRangeRepository.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace common\logic\ProducerPriceRange;
namespace common\logic\Producer\ProducerPriceRange;

use common\logic\BaseService;
use common\logic\RepositoryInterface;

common/logic/CreditHistory/CreditHistoryBuilder.php → common/logic/User/CreditHistory/CreditHistoryBuilder.php 查看文件

@@ -1,10 +1,10 @@
<?php

namespace common\logic\CreditHistory;
namespace common\logic\User\CreditHistory;

use common\logic\BaseService;
use common\logic\BuilderInterface;
use common\services\UserProducer\UserProducerBuilder;
use common\logic\User\UserProducer\UserProducerBuilder;

class CreditHistoryBuilder extends BaseService implements BuilderInterface
{

common/logic/CreditHistory/CreditHistoryContainer.php → common/logic/User/CreditHistory/CreditHistoryContainer.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace common\logic\CreditHistory;
namespace common\logic\User\CreditHistory;

use common\logic\ContainerInterface;


common/logic/CreditHistory/CreditHistoryFactory.php → common/logic/User/CreditHistory/CreditHistoryFactory.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace common\logic\CreditHistory;
namespace common\logic\User\CreditHistory;

use common\logic\FactoryInterface;


common/logic/CreditHistory/CreditHistoryModel.php → common/logic/User/CreditHistory/CreditHistoryModel.php 查看文件

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

namespace common\logic\CreditHistory;
namespace common\logic\User\CreditHistory;

use common\components\ActiveRecordCommon;
use yii\db\ActiveQuery;

common/logic/CreditHistory/CreditHistoryRepository.php → common/logic/User/CreditHistory/CreditHistoryRepository.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace common\logic\CreditHistory;
namespace common\logic\User\CreditHistory;

use common\logic\BaseService;
use common\logic\RepositoryInterface;

common/logic/CreditHistory/CreditHistorySolver.php → common/logic/User/CreditHistory/CreditHistorySolver.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace common\logic\CreditHistory;
namespace common\logic\User\CreditHistory;

use common\helpers\MeanPayment;
use common\logic\SolverInterface;
@@ -91,12 +91,12 @@ class CreditHistorySolver implements SolverInterface

$user = $creditHistory->getUserObject();
if ($user) {
$str .= '<br />Client : ' . Html::encode($user->getName() . ' ' . $user->getLastname());
$str .= '<br />Client : ' . Html::encode($user->getName() . ' CreditHistorySolver.php' . $user->getLastname());
}

$userAction = $creditHistory->getUserActionObject();
if ($userAction) {
$str .= '<br />Action : ' . Html::encode($userAction->getName() . ' ' . $userAction->getLastname());
$str .= '<br />Action : ' . Html::encode($userAction->getName() . ' CreditHistorySolver.php' . $userAction->getLastname());
}

return $str;
@@ -124,7 +124,7 @@ class CreditHistorySolver implements SolverInterface
$userAction = $creditHistory->getUserActionObject();

if ($userAction) {
return $userAction->getName() . ' ' . $userAction->getlastname();
return $userAction->getName() . ' CreditHistorySolver.php' . $userAction->getlastname();
} else {
return 'Système';
}

common/logic/User/UserBuilder.php → common/logic/User/User/UserBuilder.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace common\logic\User;
namespace common\logic\User\User;

use common\logic\BaseService;
use common\logic\BuilderInterface;

common/logic/User/UserContainer.php → common/logic/User/User/UserContainer.php 查看文件

@@ -1,10 +1,8 @@
<?php

namespace common\logic\User;
namespace common\logic\User\User;

use common\logic\ContainerInterface;
use common\services\User\UserFactory;
use common\services\User\UserUtils;

class UserContainer implements ContainerInterface
{

common/logic/User/UserFactory.php → common/logic/User/User/UserFactory.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace common\logic\User;
namespace common\logic\User\User;

use common\logic\BaseService;
use common\logic\FactoryInterface;

common/logic/User/UserModel.php → common/logic/User/User/UserModel.php 查看文件

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

namespace common\logic\User;
namespace common\logic\User\User;

use common\helpers\GlobalParam;
use common\logic\Producer\ProducerModel;
use common\logic\Producer\Producer\ProducerModel;
use common\logic\User\UserProducer\UserProducerModel;
use common\models\Order;
use common\models\PointSale;
use common\models\UserPointSale;
use common\models\UserUserGroup;
use yii\base\NotSupportedException;
use yii\behaviors\TimestampBehavior;
use yii\web\IdentityInterface;
use yii\db\Query;
@@ -434,7 +440,7 @@ class UserModel extends ActiveRecordCommon implements IdentityInterface
if (empty($token)) {
return false;
}
$expire = Yii::$app->params['user.passwordResetTokenExpire'];
$expire = \Yii::$app->params['user.passwordResetTokenExpire'];
$parts = explode('_', $token);
$timestamp = (int)end($parts);
return $timestamp + $expire >= time();
@@ -472,7 +478,7 @@ class UserModel extends ActiveRecordCommon implements IdentityInterface
*/
public function validatePassword($password)
{
return Yii::$app->security->validatePassword($password, $this->password_hash);
return \Yii::$app->security->validatePassword($password, $this->password_hash);
}

/**
@@ -482,7 +488,7 @@ class UserModel extends ActiveRecordCommon implements IdentityInterface
*/
public function setPassword($password)
{
$this->password_hash = Yii::$app->security->generatePasswordHash($password);
$this->password_hash = \Yii::$app->security->generatePasswordHash($password);
}

/**
@@ -490,7 +496,7 @@ class UserModel extends ActiveRecordCommon implements IdentityInterface
*/
public function generateAuthKey()
{
$this->auth_key = Yii::$app->security->generateRandomString();
$this->auth_key = \Yii::$app->security->generateRandomString();
}

/**
@@ -498,7 +504,7 @@ class UserModel extends ActiveRecordCommon implements IdentityInterface
*/
public function generatePasswordResetToken()
{
$this->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time();
$this->password_reset_token = \Yii::$app->security->generateRandomString() . '_' . time();
}

/**
@@ -516,8 +522,8 @@ class UserModel extends ActiveRecordCommon implements IdentityInterface
*/
public static function getCurrent()
{
if (!Yii::$app->user->isGuest) {
return Yii::$app->user->identity;
if (!\Yii::$app->user->isGuest) {
return \Yii::$app->user->identity;
}

return false;
@@ -530,7 +536,7 @@ class UserModel extends ActiveRecordCommon implements IdentityInterface
*/
public static function isCurrentConnected()
{
return !Yii::$app->user->isGuest;
return !\Yii::$app->user->isGuest;
}

/**
@@ -540,7 +546,8 @@ class UserModel extends ActiveRecordCommon implements IdentityInterface
*/
public function isProducer()
{
return ($this->status == UserModel::STATUS_ADMIN || $this->status == UserModel::STATUS_PRODUCER) && $this->id_producer;
return ($this->status == UserModel::STATUS_ADMIN
|| $this->status == UserModel::STATUS_PRODUCER) && $this->id_producer;
}

/**
@@ -687,8 +694,8 @@ class UserModel extends ActiveRecordCommon implements IdentityInterface
{
if (strlen($this->email)) {
$producer = ProducerModel::findOne(GlobalParam::getCurrentProducerId());
Yii::$app->mailer->compose();
$mail = Yii::$app->mailer->compose(
\Yii::$app->mailer->compose();
$mail = \Yii::$app->mailer->compose(
['html' => 'createUserAdmin-html', 'text' => 'createUserAdmin-text'], ['user' => $this, 'producer' => $producer, 'password' => $password]
)
->setTo($this->email)
@@ -782,8 +789,8 @@ class UserModel extends ActiveRecordCommon implements IdentityInterface
*/
public static function getCurrentStatus()
{
if (!Yii::$app->user->isGuest) {
return Yii::$app->user->identity->status;
if (!\Yii::$app->user->isGuest) {
return \Yii::$app->user->identity->status;
}

return false;

common/logic/User/UserRepository.php → common/logic/User/User/UserRepository.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace common\logic\User;
namespace common\logic\User\User;

use common\logic\BaseService;
use common\logic\RepositoryInterface;

common/logic/User/UserUtils.php → common/logic/User/User/UserUtils.php 查看文件

@@ -1,10 +1,9 @@
<?php

namespace common\services\User;
namespace common\logic\User\User;

use common\logic\BaseService;
use common\logic\Producer\ProducerModel;
use common\logic\User\UserModel;
use common\logic\Producer\Producer\ProducerModel;
use common\logic\UtilsInterface;

class UserUtils extends BaseService implements UtilsInterface

common/logic/UserProducer/UserProducerBuilder.php → common/logic/User/UserProducer/UserProducerBuilder.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace common\services\UserProducer;
namespace common\logic\User\UserProducer;

use common\helpers\MeanPayment;
use common\logic\BaseService;

common/logic/UserProducer/UserProducerContainer.php → common/logic/User/UserProducer/UserProducerContainer.php 查看文件

@@ -1,10 +1,10 @@
<?php

namespace common\containers;
namespace common\logic\User\UserProducer;

use common\logic\ContainerInterface;
use common\logic\UserProducer\UserProducerModel;
use common\logic\UserProducer\UserProducerRepository;
use common\logic\User\UserProducer\UserProducerModel;
use common\logic\User\UserProducer\UserProducerRepository;

class UserProducerContainer implements ContainerInterface
{
@@ -20,7 +20,6 @@ class UserProducerContainer implements ContainerInterface
];
}


public function getRepository(): UserProducerRepository
{
return new UserProducerRepository();

common/logic/UserProducer/UserProducerModel.php → common/logic/User/UserProducer/UserProducerModel.php 查看文件

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

namespace common\logic\UserProducer;
namespace common\logic\User\UserProducer;

use common\logic\Producer\ProducerModel;
use common\logic\User\UserModel;
use common\logic\Producer\Producer\ProducerModel;
use common\logic\User\User\UserModel;
use Yii;
use common\components\ActiveRecordCommon;


common/logic/UserProducer/UserProducerRepository.php → common/logic/User/UserProducer/UserProducerRepository.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace common\logic\UserProducer;
namespace common\logic\User\UserProducer;

use common\logic\BaseService;
use common\logic\RepositoryInterface;

+ 2
- 2
common/mail/creditUser-html.php 查看文件

@@ -38,14 +38,14 @@ termes.

use yii\helpers\Html;
use common\helpers\Price;
use common\models\CreditHistorique;
use common\logic\User\CreditHistory\CreditHistoryModel;

?>

<p>Bonjour <?= Html::encode($user->name); ?>,</p>

<p>Votre producteur <strong><?= Html::encode($producer->name); ?></strong> vient
de <?php if($creditForm->type == CreditHistory::TYPE_CREDIT): ?>créditer<?php else: ?>débiter<?php endif; ?> votre compte de <strong><?= Price::format($creditForm->amount); ?></strong> sur le site <a href="http://www.opendistrib.net/">Opendistrib</a>.</p>
de <?php if($creditForm->type == CreditHistoryModel::TYPE_CREDIT): ?>créditer<?php else: ?>débiter<?php endif; ?> votre compte de <strong><?= Price::format($creditForm->amount); ?></strong> sur le site <a href="http://www.opendistrib.net/">Opendistrib</a>.</p>

<p>Votre compte est désormais à <strong><?= Price::format($userProducer->credit); ?></strong><br />
<a href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['credit/history','slug_producer' => $producer->slug]) ?>">Cliquez ici</a> pour voir l'historique de votre crédit.</p>

+ 1
- 1
common/mail/creditUser-text.php 查看文件

@@ -42,7 +42,7 @@ use common\models\CreditHistorique;
?>
Bonjour <?= $user->name; ?>,</p>

Votre producteur <?= $producer->name; ?> vient de <?php if($creditForm->type == CreditHistory::TYPE_CREDIT): ?>créditer<?php else: ?>débiter<?php endif; ?> votre compte de <?= Price::format($creditForm->amount); ?> sur le site http://www.laboiteapain.net/
Votre producteur <?= $producer->name; ?> vient de <?php if($creditForm->type == CreditHistoryModel::TYPE_CREDIT): ?>créditer<?php else: ?>débiter<?php endif; ?> votre compte de <?= Price::format($creditForm->amount); ?> sur le site http://www.opendistrib.net/

Votre compte est désormais à : <?= Price::format($userProducer->credit); ?>.
Suivez ce lien pour voir l'historique de votre crédit : <?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['credit/history','slug_producer' => $producer->slug]) ?>">

+ 5
- 3
common/mail/orderConfirm-html.php 查看文件

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

use common\models\Producer ;
use common\helpers\GlobalParam ;
use yii\helpers\Html;
use common\logic\Producer\Producer\ProducerModel;
use common\models\Order;

?>

@@ -55,13 +57,13 @@ use common\helpers\GlobalParam ;
<?php endif; ?>
<?php if(strlen($pointSale->locality) > 0): ?> situé à <?= Html::encode($pointSale->locality) ?><?php endif ?>.</p>

<?php $payment_infos = Producer::getConfig('option_payment_info') ; ?>
<?php $payment_infos = ProducerModel::getConfig('option_payment_info') ; ?>
<?php if($payment_infos && strlen($payment_infos) > 0): ?>
<p><strong>Informations de paiement :</strong><br />
<?= nl2br(Html::encode($payment_infos)); ?></p>
<?php endif; ?>

<?php $order_infos = Producer::getConfig('order_infos') ; ?>
<?php $order_infos = ProducerModel::getConfig('order_infos') ; ?>
<?php if($order_infos && strlen($order_infos) > 0): ?>
<p><strong>Informations générales :</strong><br />
<?= nl2br(Html::encode($order_infos)); ?></p>

+ 4
- 3
common/mail/orderConfirm-text.php 查看文件

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

use common\models\Producer ;
use common\helpers\GlobalParam ;
use common\logic\Producer\Producer\ProducerModel;

$producer = GlobalParam::getCurrentProducer() ;

?>
@@ -51,13 +52,13 @@ Récapitulatif des produits commandés :

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 ?>.

<?php $payment_infos = Producer::getConfig('option_payment_info') ; ?>
<?php $payment_infos = ProducerModel::getConfig('option_payment_info') ; ?>
<?php if($payment_infos && strlen($payment_infos) > 0): ?>
Informations de paiement :
<?= $payment_infos ?>
<?php endif; ?>

<?php $order_infos = Producer::getConfig('order_infos') ; ?>
<?php $order_infos = ProducerModel::getConfig('order_infos') ; ?>
<?php if($order_infos && strlen($order_infos) > 0): ?>
Informations générales :
<?= $order_infos ?>

+ 5
- 2
common/mail/paymentError-html.php 查看文件

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

use yii\helpers\Html;
use common\logic\Producer\Producer\ProducerModel;

?>

<p>Bonjour <?= Html::encode($user->name); ?>,</p>
@@ -46,13 +49,13 @@ termes.

<p>Vous pouvez retrouver le lien de paiement dans votre <a href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['credit/history','slug_producer' => $producer->slug]) ?>">historique de commandes</a>.</p>

<?php $payment_infos = Producer::getConfig('option_payment_info') ; ?>
<?php $payment_infos = ProducerModel::getConfig('option_payment_info') ; ?>
<?php if($payment_infos && strlen($payment_infos) > 0): ?>
<p><strong>Informations de paiement :</strong><br />
<?= nl2br(Html::encode($payment_infos)); ?></p>
<?php endif; ?>

<?php $order_infos = Producer::getConfig('order_infos') ; ?>
<?php $order_infos = ProducerModel::getConfig('order_infos') ; ?>
<?php if($order_infos && strlen($order_infos) > 0): ?>
<p><strong>Informations générales :</strong><br />
<?= nl2br(Html::encode($order_infos)); ?></p>

+ 1
- 1
common/mail/signup-html.php 查看文件

@@ -37,8 +37,8 @@ termes.
*/

use yii\helpers\Html;
use common\models\UserModel ;
use common\helpers\Url ;
use common\logic\User\User\UserModel;

?>


+ 2
- 1
common/mail/signup-text.php 查看文件

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

use common\models\UserModel ;
use common\helpers\Url ;

use common\logic\User\User\UserModel;

?>

Bonjour <?= $user->name ?>,

+ 5
- 4
common/models/CreditHistorySearch.php 查看文件

@@ -39,10 +39,11 @@ termes.
namespace common\models ;

use common\helpers\GlobalParam;
use common\models\CreditHistory ;
use common\repositories\CreditHistoryRepository;
use common\logic\User\CreditHistory\CreditHistoryModel;
use common\logic\User\CreditHistory\CreditHistoryRepository;
use yii\data\ActiveDataProvider;

class CreditHistorySearch extends CreditHistory
class CreditHistorySearch extends CreditHistoryModel
{
public function rules(): array
@@ -59,7 +60,7 @@ class CreditHistorySearch extends CreditHistory
{
$optionsSearch = CreditHistoryRepository::defaultOptionsSearch() ;
$query = CreditHistory::find()
$query = CreditHistoryModel::find()
->with($optionsSearch['with'])
->innerJoinWith($optionsSearch['join_with'], true)
->where(['credit_history.id_producer' => GlobalParam::getCurrentProducerId()])

+ 2
- 1
common/models/DevelopmentPriority.php 查看文件

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

namespace common\models;

use common\logic\Producer\Producer\ProducerModel;
use Yii;
use common\components\ActiveRecordCommon ;
use common\models\Producer;
@@ -81,7 +82,7 @@ class DevelopmentPriority extends ActiveRecordCommon

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

/**

+ 2
- 1
common/models/Distribution.php 查看文件

@@ -38,6 +38,7 @@

namespace common\models;

use common\logic\Producer\Producer\ProducerModel;
use Yii;
use common\helpers\GlobalParam;
use common\models\Order;
@@ -62,7 +63,7 @@ class Distribution extends ActiveRecordCommon

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

/**

+ 8
- 7
common/models/Document.php 查看文件

@@ -39,6 +39,7 @@
namespace common\models;

use common\helpers\GlobalParam;
use common\logic\Producer\Producer\ProducerModel;
use kartik\mpdf\Pdf;
use Symfony\Component\Finder\Exception\DirectoryNotFoundException;
use yii\base\ErrorException;
@@ -104,7 +105,7 @@ class Document extends ActiveRecordCommon

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

public function relationOrders($fieldIdDocument)
@@ -260,7 +261,7 @@ class Document extends ActiveRecordCommon
$classLower = 'delivery_note';
}

$prefix = Producer::getConfig('document_' . $classLower . '_prefix');
$prefix = ProducerModel::getConfig('document_' . $classLower . '_prefix');
$oneDocumentExist = $class::searchOne(['status' => Document::STATUS_VALID], ['orderby' => 'reference DESC']);

if ($oneDocumentExist) {
@@ -273,7 +274,7 @@ class Document extends ActiveRecordCommon

return $prefix . $numReference;
} else {
$firstReference = Producer::getConfig('document_' . $classLower . '_first_reference');
$firstReference = ProducerModel::getConfig('document_' . $classLower . '_first_reference');

if (strlen($firstReference) > 0) {
return $firstReference;
@@ -324,7 +325,7 @@ class Document extends ActiveRecordCommon
$contentFooter .= '</div>';

$marginBottom = 10;
if (strlen(Producer::getConfig('document_infos_bottom')) > 0) {
if (strlen(ProducerModel::getConfig('document_infos_bottom')) > 0) {
$marginBottom = 40;
}

@@ -459,8 +460,8 @@ class Document extends ActiveRecordCommon
public function isDisplayOrders()
{
$displayOrders = ($this->getClass() == 'Invoice') ?
Producer::getConfig('document_display_orders_invoice') :
Producer::getConfig('document_display_orders_delivery_note');
ProducerModel::getConfig('document_display_orders_invoice') :
ProducerModel::getConfig('document_display_orders_delivery_note');

return $displayOrders;
}
@@ -517,7 +518,7 @@ class Document extends ActiveRecordCommon

public function initTaxCalculationMethod()
{
$producerTaxCalculationMethod = Producer::getConfig('option_tax_calculation_method');
$producerTaxCalculationMethod = ProducerModel::getConfig('option_tax_calculation_method');

if ($producerTaxCalculationMethod) {
$this->tax_calculation_method = $producerTaxCalculationMethod;

+ 21
- 18
common/models/Order.php 查看文件

@@ -41,6 +41,9 @@ namespace common\models;
use common\helpers\Debug;
use common\helpers\GlobalParam;
use common\helpers\Price;
use common\logic\Producer\Producer\ProducerModel;
use common\logic\User\CreditHistory\CreditHistoryModel;
use common\logic\User\User\UserModel;
use common\models\Producer;
use Yii;
use yii\helpers\Html;
@@ -181,7 +184,7 @@ class Order extends ActiveRecordCommon

public function getCreditHistory()
{
return $this->hasMany(CreditHistory::className(), ['id_order' => 'id']);
return $this->hasMany(CreditHistoryModel::class, ['id_order' => 'id']);
}

public function getSubscription()
@@ -336,7 +339,7 @@ class Order extends ActiveRecordCommon
if (isset($this->creditHistory)) {
$history = $this->creditHistory;
} else {
$history = CreditHistory::find()
$history = CreditHistoryModel::find()
->where(['id_order' => $this->id])
->all();
}
@@ -345,9 +348,9 @@ class Order extends ActiveRecordCommon

if (count($history)) {
foreach ($history as $ch) {
if ($ch->type == CreditHistory::TYPE_PAYMENT) {
if ($ch->type == CreditHistoryModel::TYPE_PAYMENT) {
$this->paid_amount += $ch->amount;
} elseif ($ch->type == CreditHistory::TYPE_REFUND) {
} elseif ($ch->type == CreditHistoryModel::TYPE_REFUND) {
$this->paid_amount -= $ch->amount;
}
}
@@ -360,7 +363,7 @@ class Order extends ActiveRecordCommon
$amountPaid = $this->getAmount(Order::AMOUNT_PAID);
if ($amountPaid > 0.01) {
$this->saveCreditHistory(
CreditHistory::TYPE_REFUND,
CreditHistoryModel::TYPE_REFUND,
$amountPaid,
GlobalParam::getCurrentProducerId(),
$this->id_user,
@@ -369,15 +372,15 @@ class Order extends ActiveRecordCommon
}

// delete
if (Producer::getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_DELETE ||
(Producer::getConfig(
if (ProducerModel::getConfig('option_behavior_cancel_order') == ProducerModel::BEHAVIOR_DELETE_ORDER_DELETE ||
(ProducerModel::getConfig(
'option_behavior_cancel_order'
) == Producer::BEHAVIOR_DELETE_ORDER_STATUS && strlen($this->date_delete)) ||
) == ProducerModel::BEHAVIOR_DELETE_ORDER_STATUS && strlen($this->date_delete)) ||
$force) {
ProductOrder::deleteAll(['id_order' => $this->id]);
return parent::delete();
} // status 'delete'
elseif (Producer::getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS) {
elseif (ProducerModel::getConfig('option_behavior_cancel_order') == ProducerModel::BEHAVIOR_DELETE_ORDER_STATUS) {
$this->date_delete = date('Y-m-d H:i:s');
return $this->save();
}
@@ -587,10 +590,10 @@ class Order extends ActiveRecordCommon
if ($paymentStatus == self::PAYMENT_PAID) {
return true;
} elseif ($paymentStatus == self::PAYMENT_SURPLUS) {
$type = CreditHistory::TYPE_REFUND;
$type = CreditHistoryModel::TYPE_REFUND;
$amount = $this->getAmount(self::AMOUNT_SURPLUS);
} elseif ($paymentStatus == self::PAYMENT_UNPAID) {
$type = CreditHistory::TYPE_PAYMENT;
$type = CreditHistoryModel::TYPE_PAYMENT;
$amount = $this->getAmount(self::AMOUNT_REMAINING);
}

@@ -713,7 +716,7 @@ class Order extends ActiveRecordCommon
{
$html = '';

$creditActive = Producer::getConfig('credit');
$creditActive = ProducerModel::getConfig('credit');
$html .= $this->getAmountWithTax(self::AMOUNT_TOTAL, true);

if ($creditActive) {
@@ -775,11 +778,11 @@ class Order extends ActiveRecordCommon
$todayHour = date('G');
$dayDistribution = strtolower(date('l', strtotime($this->distribution->date)));

$orderDelay = Producer::getConfig(
$orderDelay = ProducerModel::getConfig(
'order_delay',
$this->distribution->id_producer
);
$orderDelaySpecific = Producer::getConfig(
$orderDelaySpecific = ProducerModel::getConfig(
'order_delay_' . $dayDistribution,
$this->distribution->id_producer
);
@@ -787,11 +790,11 @@ class Order extends ActiveRecordCommon
$orderDelay = $orderDelaySpecific;
}

$orderDeadline = Producer::getConfig(
$orderDeadline = ProducerModel::getConfig(
'order_deadline',
$this->distribution->id_producer
);
$orderDeadlineSpecific = Producer::getConfig(
$orderDeadlineSpecific = ProducerModel::getConfig(
'order_deadline_' . $dayDistribution,
$this->distribution->id_producer
);
@@ -1053,9 +1056,9 @@ class Order extends ActiveRecordCommon
public function initReference()
{
$idProducer = GlobalParam::getCurrentProducerId();
$producer = Producer::findOne($idProducer);
$producer = ProducerModel::findOne($idProducer);

if (!$this->reference && $producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY) {
if (!$this->reference && $producer->option_order_reference_type == ProducerModel::ORDER_REFERENCE_TYPE_YEARLY) {
$lastOrder = Order::find()->innerJoinWith('distribution', true)
->where(['>=', 'distribution.date', date('Y') . '-01-01'])
->andWhere([

+ 2
- 1
common/models/PointSale.php 查看文件

@@ -39,6 +39,7 @@
namespace common\models;

use common\helpers\GlobalParam;
use common\logic\Producer\Producer\ProducerModel;
use Yii;
use yii\helpers\Html;
use common\models\UserPointSale;
@@ -362,7 +363,7 @@ class PointSale extends ActiveRecordCommon
{
return strlen($this->credit_functioning) > 0 ?
$this->credit_functioning :
Producer::getConfig('credit_functioning');
ProducerModel::getConfig('credit_functioning');
}

/**

+ 2
- 1
common/models/Product.php 查看文件

@@ -41,6 +41,7 @@ namespace common\models;
use common\helpers\Debug;
use common\helpers\GlobalParam;
use common\helpers\Price;
use common\logic\Producer\Producer\ProducerModel;
use Yii;
use common\components\ActiveRecordCommon;

@@ -183,7 +184,7 @@ class Product extends ActiveRecordCommon
public function afterFind()
{
if ($this->taxRate == null) {
$producer = Producer::searchOne(['id' => GlobalParam::getCurrentProducerId()]);
$producer = ProducerModel::searchOne(['id' => GlobalParam::getCurrentProducerId()]);
if ($producer) {
$this->populateRelation('taxRate', $producer->taxRate);
}

+ 15
- 17
common/models/Subscription.php 查看文件

@@ -39,14 +39,12 @@
namespace common\models;

use common\helpers\GlobalParam;
use common\models\PointSale;
use common\models\UserModel;
use common\logic\Producer\Producer\ProducerModel;
use common\logic\User\CreditHistory\CreditHistoryModel;
use common\logic\User\UserProducer\UserProducerModel;
use Yii;
use common\components\ActiveRecordCommon;
use common\models\Producer;
use common\models\UserPointSale;
use common\models\Order;
use common\models\ProductOrder;
use common\logic\User\User\UserModel;

/**
* This is the model class for table "commande_auto".
@@ -128,13 +126,13 @@ class Subscription extends ActiveRecordCommon

public function getUser()
{
return $this->hasOne(UserModel::className(), ['id' => 'id_user']);
return $this->hasOne(UserModel::class, ['id' => 'id_user']);
}

public function getProducer()
{
return $this->hasOne(
Producer::className(),
ProducerModel::class,
['id' => 'id_producer']
);
}
@@ -142,7 +140,7 @@ class Subscription extends ActiveRecordCommon
public function getPointSale()
{
return $this->hasOne(
PointSale::className(),
PointSale::class,
['id' => 'id_point_sale']
);
}
@@ -150,7 +148,7 @@ class Subscription extends ActiveRecordCommon
public function getProductSubscription()
{
return $this->hasMany(
ProductSubscription::className(),
ProductSubscription::class,
['id_subscription' => 'id']
)->with('product');
}
@@ -221,12 +219,12 @@ class Subscription extends ActiveRecordCommon

$order->auto_payment = 0;
if($this->auto_payment == self::AUTO_PAYMENT_DEDUCTED) {
if ($order->id_user && Producer::getConfig('credit') && $pointSale->credit) {
if ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) {
if ($order->id_user && ProducerModel::getConfig('credit') && $pointSale->credit) {
if ($creditFunctioning == ProducerModel::CREDIT_FUNCTIONING_OPTIONAL) {
$order->auto_payment = 0;
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) {
} elseif ($creditFunctioning == ProducerModel::CREDIT_FUNCTIONING_MANDATORY) {
$order->auto_payment = 1;
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER) {
} elseif ($creditFunctioning == ProducerModel::CREDIT_FUNCTIONING_USER) {
$user = UserModel::findOne($order->id_user);
$userProducer = UserProducerModel::searchOne([
'id_user' => $order->id_user,
@@ -450,7 +448,7 @@ class Subscription extends ActiveRecordCommon
':id_subscription' => $this->id
];

$orderDeadline = Producer::getConfig('order_deadline');
$orderDeadline = ProducerModel::getConfig('order_deadline');
$hour = date('G');

if ($hour >= $orderDeadline) {
@@ -469,7 +467,7 @@ class Subscription extends ActiveRecordCommon
$orders->params($params);

$ordersArray = $orders->all();
$configCredit = Producer::getConfig('credit');
$configCredit = ProducerModel::getConfig('credit');

$countOrdersDeleted = 0;
if ($ordersArray && count($ordersArray)) {
@@ -480,7 +478,7 @@ class Subscription extends ActiveRecordCommon
// remboursement de la commande
if ($theOrder->id_user && $theOrder->getAmount(Order::AMOUNT_PAID) && $configCredit) {
$theOrder->saveCreditHistory(
CreditHistory::TYPE_REFUND,
CreditHistoryModel::TYPE_REFUND,
$theOrder->getAmount(Order::AMOUNT_PAID),
$theOrder->distribution->id_producer,
$theOrder->id_user,

+ 3
- 1
frontend/controllers/SiteController.php 查看文件

@@ -38,7 +38,7 @@

namespace frontend\controllers;

use common\models\UserModel;
use common\logic\User\User\UserModel;
use frontend\forms\ProducerCodeForm;
use Yii;
use frontend\forms\PasswordResetRequestForm;
@@ -127,6 +127,8 @@ class SiteController extends FrontendController
*/
public function actionIndex()
{
$this->getLogic()->getProducerContainer()->getBuilder();

$producerRepository = $this->getLogic()->getProducerContainer()->getRepository();

return $this->render('index', [

+ 14
- 15
frontend/forms/SignupForm.php 查看文件

@@ -38,12 +38,11 @@

namespace frontend\forms;

use common\logic\Producer\Producer\ProducerModel;
use common\logic\User\User\UserModel;
use common\models\TaxRate;
use Yii;
use common\models\UserModel;
use common\models\Producer;
use yii\base\Model;
use common\models\UserProducerModel;
use common\helpers\Password;

/**
* Signup form
@@ -171,7 +170,7 @@ class SignupForm extends Model
['id_producer', 'integer'],
['id_producer', function ($attribute, $params) {
if ($this->id_producer) {
$producer = Producer::findOne($this->id_producer);
$producer = ProducerModel::findOne($this->id_producer);
if (!$producer) {
$this->addError($attribute, 'Ce producteur n\'existe pas.');
}
@@ -181,7 +180,7 @@ class SignupForm extends Model
return $this->option_user_producer == 'user';
}],
['code', 'required', 'message' => 'Champs obligatoire', 'when' => function ($model) {
$producer = Producer::findOne($this->id_producer);
$producer = ProducerModel::findOne($this->id_producer);
if ($producer) {
return strlen($producer->code);
} else {
@@ -190,7 +189,7 @@ class SignupForm extends Model
}],
['code', function ($attribute, $params) {
$code = $this->$attribute;
$producer = Producer::findOne($this->id_producer);
$producer = ProducerModel::findOne($this->id_producer);

if ($producer && strtolower(trim($code)) != strtolower(trim($producer->code))) {
$this->addError($attribute, 'Code incorrect');
@@ -239,7 +238,7 @@ class SignupForm extends Model

if ($this->validate()) {

$user = $userContainer->getService()->createInstance();
$user = $userContainer->getFactory()->create();
$this->populateUser($user);

if ($this->isProducer()) {
@@ -253,11 +252,11 @@ class SignupForm extends Model

if ($user->save() && $producer) {
// Liaison User / Producer
$producerContainer->getService()->addUser($user->id, $idProducer);
$producerContainer->getBuilder()->addUser($user->id, $idProducer);

// Envoi d'un email de bienvenue à l'utilisateur
if ($this->isCustomer()) {
$userContainer->getService()->sendEmailSignup($user, $producer);
$userContainer->getUtils()->sendEmailSignup($user, $producer);
}

return $user;
@@ -283,19 +282,19 @@ class SignupForm extends Model
$producerContainer = \Yii::$app->logic->getProducerContainer();

// Création du producteur
$producer = $producerContainer->getService()->createInstance();
$producer = $producerContainer->getFactory()->createInstance();
$this->populateProducer($producer);
$producerContainer->getService()->init($producer);
$producerContainer->getBuilder()->init($producer);
$producer->save();

/*
* Envoi d'un email à l'administrateur pour le prévenir
* qu'un nouveau producteur s'est inscrit
*/
$producerContainer->getService()->sendEmailNewProducer($producer);
$producerContainer->getUtils()->sendEmailNewProducer($producer);

// Initialisation de l'utilisateur (statut et liaison au producteur)
$userContainer->getService()->initProducer($user, $producer);
$userContainer->getBuilder()->initProducer($user, $producer);

return $producer;
}
@@ -310,7 +309,7 @@ class SignupForm extends Model
$user->lastname = $this->lastname;
$user->phone = $this->phone;

$userContainer->getService()->initPassword($user, $this->password);
$userContainer->getBuilder()->initPassword($user, $this->password);
}

public function populateProducer($producer)

+ 2
- 2
frontend/views/layouts/main.php 查看文件

@@ -42,8 +42,8 @@ use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use common\widgets\Alert;
use common\helpers\Url;
use common\logic\Producer\ProducerModel;
use common\logic\User\UserModel;
use common\logic\Producer\Producer\ProducerModel;
use common\logic\User\User\UserModel;

/* @var $this \yii\web\View */
/* @var $content string */

+ 15
- 16
producer/controllers/CreditController.php 查看文件

@@ -38,17 +38,16 @@

namespace producer\controllers;

use common\helpers\GlobalParam;
use common\helpers\Mailjet;
use common\helpers\MeanPayment;
use common\models\CreditHistory;
use common\logic\User\CreditHistory\CreditHistoryModel;
use common\logic\User\User\UserModel;
use common\logic\User\UserProducer\UserProducerModel;
use common\models\CreditHistorySearch;
use common\models\Distribution;
use common\models\Order;
use common\models\PointSale;
use common\models\UserProducerModel;
use producer\models\CreditForm;
use common\models\UserModel;
use Stripe\PaymentIntent;
use yii\filters\VerbFilter;

class CreditController extends ProducerBaseController
@@ -99,7 +98,7 @@ class CreditController extends ProducerBaseController

$searchModel = new CreditHistorySearch();
$searchModel->id_user = UserModel::getCurrentId();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$dataProvider = $searchModel->search(\Yii::$app->request->queryParams);

$userProducer = UserProducerModel::searchOne([
'id_producer' => $producer->id,
@@ -108,10 +107,10 @@ class CreditController extends ProducerBaseController

if (strlen($returnPayment)) {
if ($returnPayment == 'success') {
Yii::$app->getSession()->setFlash('success', "Paiement accepté : votre compte vient d'être crédité.");
\Yii::$app->getSession()->setFlash('success', "Paiement accepté : votre compte vient d'être crédité.");
}
if ($returnPayment == 'cancel') {
Yii::$app->getSession()->setFlash('error', 'Paiement annulé.');
\Yii::$app->getSession()->setFlash('error', 'Paiement annulé.');
}
}

@@ -127,14 +126,14 @@ class CreditController extends ProducerBaseController
$producer = $this->getProducer();

if(\Yii::$app->user->isGuest) {
return $this->redirect(Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer','id' => $producer->id])) ;
return $this->redirect(\Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer','id' => $producer->id])) ;
}

if ($producer->online_payment || $producer->option_stripe_mode_test) {

$creditForm = new CreditForm;

if ($creditForm->load(Yii::$app->request->post()) && $creditForm->validate()) {
if ($creditForm->load(\Yii::$app->request->post()) && $creditForm->validate()) {
$user = UserModel::getCurrent();

\Stripe\Stripe::setApiKey(
@@ -193,7 +192,7 @@ class CreditController extends ProducerBaseController

public function actionStripeVerification()
{
$creditHistoryService = $this->getLogic()->getCreditHistoryContainer()->getService();
$creditHistoryBuilder = $this->getLogic()->getCreditHistoryContainer()->getBuilder();
$producer = $this->getProducer();
$contactProducer = $producer->getMainContact();

@@ -236,7 +235,7 @@ class CreditController extends ProducerBaseController
switch ($event->type) {
case 'charge.succeeded':

$creditHistoryExist = CreditHistory::searchOne([
$creditHistoryExist = CreditHistoryModel::searchOne([
'id_user' => $idUser,
'amount' => $amount,
], [
@@ -248,21 +247,21 @@ class CreditController extends ProducerBaseController
if(!$creditHistoryExist) {

// on crédite le crédit du client
$creditHistory = new CreditHistory;
$creditHistory = new CreditHistoryModel();
$creditHistory->id_user = $idUser;
$creditHistory->id_user_action = $idUser;
$creditHistory->id_producer = $idProducer;
$creditHistory->type = CreditHistory::TYPE_CREDIT;
$creditHistory->type = CreditHistoryModel::TYPE_CREDIT;
$creditHistory->comment = null;
$creditHistory->amount = $amount;
$creditHistory->mean_payment = MeanPayment::CREDIT_CARD;

$creditHistoryService->save($creditHistory);
$creditHistoryBuilder->save($creditHistory);

if (isset($order) && $order) {
// paiement de la commande
$order->saveCreditHistory(
CreditHistory::TYPE_PAYMENT,
CreditHistoryModel::TYPE_PAYMENT,
$amount,
$idProducer,
$order->id_user,

+ 21
- 21
producer/controllers/OrderController.php 查看文件

@@ -38,18 +38,18 @@

namespace producer\controllers;

use common\helpers\Debug;
use common\helpers\GlobalParam;
use common\helpers\Mailjet;
use common\logic\Producer\Producer\ProducerModel;
use common\logic\User\CreditHistory\CreditHistoryModel;
use common\models\ProductCategory;
use common\models\ProductDistribution;
use common\models\UserModel;
use common\models\Producer;
use common\logic\User\User\UserModel;
use common\models\Order;
use common\models\UserPointSale;
use common\models\Product;
use common\models\UserProducerModel;
use common\logic\User\UserProducer\UserProducerModel;
use DateTime;
use yii\web\NotFoundHttpException;

class OrderController extends ProducerBaseController
{
@@ -334,7 +334,7 @@ class OrderController extends ProducerBaseController
*/
public function _verifyProducerActive($idProducer)
{
$producer = Producer::findOne($idProducer);
$producer = ProducerModel::findOne($idProducer);
if ($producer && !$producer->active) {
throw new NotFoundHttpException('Ce producteur est actuellement hors ligne.');
}
@@ -443,7 +443,7 @@ class OrderController extends ProducerBaseController
$order->changeOrderStatus('new-order', 'user');

// ajout de l'utilisateur à l'établissement
Producer::addUser($user->id, $distribution->id_producer);
ProducerModel::addUser($user->id, $distribution->id_producer);

// suppression de tous les enregistrements ProductOrder
if (!is_null($order)) {
@@ -492,8 +492,8 @@ class OrderController extends ProducerBaseController
$pointSale->linkUser($user->id);

// credit
$credit = Producer::getConfig('credit');
$creditLimit = Producer::getConfig('credit_limit');
$credit = ProducerModel::getConfig('credit');
$creditLimit = ProducerModel::getConfig('credit_limit');
$creditFunctioning = $pointSale->getCreditFunctioning();
$creditUser = $user->getCredit($distribution->id_producer);
$order = Order::searchOne([
@@ -503,9 +503,9 @@ class OrderController extends ProducerBaseController
$amountRemaining = $order->getAmount(Order::AMOUNT_REMAINING);

if ($credit && $pointSale->credit &&
(($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL && $posts['use_credit']) ||
$creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY ||
($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER && $userProducer->credit_active)
(($creditFunctioning == ProducerModel::CREDIT_FUNCTIONING_OPTIONAL && $posts['use_credit']) ||
$creditFunctioning == ProducerModel::CREDIT_FUNCTIONING_MANDATORY ||
($creditFunctioning == ProducerModel::CREDIT_FUNCTIONING_USER && $userProducer->credit_active)
)) {
$order->changeOrderStatus('waiting-paiement-by-credit', 'user');

@@ -517,7 +517,7 @@ class OrderController extends ProducerBaseController

if ($amountRemaining > 0) {
$order->saveCreditHistory(
CreditHistory::TYPE_PAYMENT,
CreditHistoryModel::TYPE_PAYMENT,
$amountRemaining,
$distribution->id_producer,
UserModel::getCurrentId(),
@@ -531,7 +531,7 @@ class OrderController extends ProducerBaseController
elseif ($order->getPaymentStatus() == Order::PAYMENT_SURPLUS) {
$amountSurplus = $order->getAmount(Order::AMOUNT_SURPLUS);
$order->saveCreditHistory(
CreditHistory::TYPE_REFUND,
CreditHistoryModel::TYPE_REFUND,
$amountSurplus,
$distribution->id_producer,
UserModel::getCurrentId(),
@@ -564,13 +564,13 @@ class OrderController extends ProducerBaseController
*/
if ($isNewOrder) {
// au client
if (Producer::getConfig('option_email_confirm')) {
if (ProducerModel::getConfig('option_email_confirm')) {
Mailjet::sendMail($paramsEmail);
}

// au producteur
$contactProducer = $producer->getMainContact();
if (Producer::getConfig('option_email_confirm_producer') && $contactProducer && strlen(
if (ProducerModel::getConfig('option_email_confirm_producer') && $contactProducer && strlen(
$contactProducer->email
)) {
$paramsEmail['to_email'] = $contactProducer->email;
@@ -665,7 +665,7 @@ class OrderController extends ProducerBaseController
$orderUser = $this->_getOrderUser($date, $pointSaleId);

// Producteur
$producer = Producer::searchOne([
$producer = ProducerModel::searchOne([
'id' => $this->getProducer()->id
]);
$json['producer'] = [
@@ -695,7 +695,7 @@ class OrderController extends ProducerBaseController
$distributionsArray = Distribution::filterDistributionsByDateDelay($distributionsArray);

// Filtre par point de vente
if ($pointSaleId && $producer->option_order_entry_point == Producer::ORDER_ENTRY_POINT_POINT_SALE) {
if ($pointSaleId && $producer->option_order_entry_point == ProducerModel::ORDER_ENTRY_POINT_POINT_SALE) {
$distributionsArrayFilterPointSale = [];
for ($i = 0; $i < count($distributionsArray); $i++) {
$distribution = $distributionsArray[$i];
@@ -730,7 +730,7 @@ class OrderController extends ProducerBaseController
':date' => $dateMini
];

if ($pointSaleId && $producer->option_order_entry_point == Producer::ORDER_ENTRY_POINT_POINT_SALE) {
if ($pointSaleId && $producer->option_order_entry_point == ProducerModel::ORDER_ENTRY_POINT_POINT_SALE) {
$conditionsOrdersUser[] = 'order.id_point_sale = :id_point_sale';
$paramsOrdersUser[':id_point_sale'] = $pointSaleId;
}
@@ -761,7 +761,7 @@ class OrderController extends ProducerBaseController
]);

if($user && !$userProducer) {
$userProducer = Producer::addUser($user->id, $producer->id);
$userProducer = ProducerModel::addUser($user->id, $producer->id);
}

$json['user'] = false;
@@ -961,7 +961,7 @@ class OrderController extends ProducerBaseController
->orderBy('code ASC, restricted_access ASC, is_bread_box ASC, `default` DESC, name ASC')
->all();

$creditFunctioningProducer = Producer::getConfig('credit_functioning');
$creditFunctioningProducer = ProducerModel::getConfig('credit_functioning');
$position = 0;

foreach ($pointsSaleArray as &$pointSale) {

+ 13
- 12
producer/controllers/ProducerBaseController.php 查看文件

@@ -39,6 +39,9 @@ termes.
namespace producer\controllers;

use common\controllers\CommonController;
use common\logic\Producer\Producer\ProducerModel;
use common\logic\User\User\UserModel;
use common\logic\User\UserProducer\UserProducerModel;

class ProducerBaseController extends CommonController
{
@@ -62,9 +65,9 @@ class ProducerBaseController extends CommonController
{
$producer = $this->getProducer() ;
$userProducer = UserProducer::find()
$userProducer = UserProducerModel::find()
->where([
'id_user' => User::getCurrentId(),
'id_user' => UserModel::getCurrentId(),
'id_producer' => $producer->id
])
->one() ;
@@ -76,13 +79,13 @@ class ProducerBaseController extends CommonController
// Si l'utilisateur n'est pas connecté, on le redirige vers une page qui lui permet
// de se connecter ou de s'inscrire en saisissant le code du producteur
if(Yii::$app->user->isGuest) {
$this->redirect(Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer','id' => $producer->id])) ;
if(\Yii::$app->user->isGuest) {
$this->redirect(\Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer','id' => $producer->id])) ;
}
// si l'utilisateur est connecté et qu'il n'a pas encore saisi de code
else {
if(!$userProducer || ($userProducer && !$userProducer->active)) {
$this->redirect(Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer-code','id' => $producer->id])) ;
$this->redirect(\Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer-code','id' => $producer->id])) ;
}
}
}
@@ -90,8 +93,8 @@ class ProducerBaseController extends CommonController
/*
* Producteur hors ligne
*/
if(!$producer->active && (Yii::$app->user->isGuest || Yii::$app->user->identity->id_producer != $producer->id)) {
$this->redirect(Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer-offline','id' => $producer->id])) ;
if(!$producer->active && (\Yii::$app->user->isGuest || \Yii::$app->user->identity->id_producer != $producer->id)) {
$this->redirect(\Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer-offline','id' => $producer->id])) ;
}
return parent::beforeAction($event);
@@ -99,9 +102,7 @@ class ProducerBaseController extends CommonController
/**
* Retourne le producteur courant.
*
* @return Etablissement
* @throws \yii\web\HttpException
*
*/
public function getProducer()
{
@@ -109,9 +110,9 @@ class ProducerBaseController extends CommonController
return $this->producer ;
}
else {
$producer = Producer::find()
$producer = ProducerModel::find()
->with('contact')
->where(['slug' => Yii::$app->getRequest()->getQueryParam('slug_producer')])
->where(['slug' => \Yii::$app->getRequest()->getQueryParam('slug_producer')])
->one() ;
if($producer) {

+ 5
- 3
producer/controllers/SiteController.php 查看文件

@@ -40,6 +40,8 @@ namespace producer\controllers;

use common\forms\ContactForm;
use common\helpers\GlobalParam;
use common\logic\User\User\UserModel;
use common\logic\User\UserProducer\UserProducerModel;
use common\models\ProductCategory;

class SiteController extends ProducerBaseController
@@ -229,15 +231,15 @@ class SiteController extends ProducerBaseController
public function actionBookmarks($action)
{
$producer = $this->getProducer();
$userProducer = UserProducer::find()
$userProducer = UserProducerModel::find()
->where([
'id_user' => User::getCurrentId(),
'id_user' => UserModel::getCurrentId(),
'id_producer' => $producer->id
])
->one();

if (!$userProducer) {
$userProducer = Producer::addUser(User::getCurrentId(), $producer->id);
$userProducer = $this->getLogic()->getProducerContainer()->getBuilder()->addUser(UserModel::getCurrentId(), $producer->id);
}

if ($userProducer) {

+ 9
- 6
producer/controllers/SubscriptionController.php 查看文件

@@ -40,9 +40,12 @@ namespace producer\controllers;

use common\helpers\Debug;
use common\helpers\GlobalParam;
use common\logic\User\User\UserModel;
use common\logic\User\UserProducer\UserProducerModel;
use common\models\SubscriptionForm;
use common\models\SubscriptionSearch;
use common\models\Product;
use yii\base\UserException;

class SubscriptionController extends ProducerBaseController
{
@@ -76,7 +79,7 @@ class SubscriptionController extends ProducerBaseController
}

$searchModel = new SubscriptionSearch;
$searchModel->id_user = User::getCurrentId();
$searchModel->id_user = UserModel::getCurrentId();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);

return $this->render('index', [
@@ -90,7 +93,7 @@ class SubscriptionController extends ProducerBaseController
// form
$model = new SubscriptionForm;
$model->id_producer = GlobalParam::getCurrentProducerId();
$model->id_user = User::getCurrentId();
$model->id_user = UserModel::getCurrentId();

$posts = Yii::$app->request->post();

@@ -245,9 +248,9 @@ class SubscriptionController extends ProducerBaseController
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$params = [];

$user = User::getCurrent();
$userProducer = UserProducer::searchOne([
'id_user' => User::getCurrentId()
$user = UserModel::getCurrent();
$userProducer = UserProducerModel::searchOne([
'id_user' => UserModel::getCurrentId()
]);
$pointSale = false;

@@ -316,7 +319,7 @@ class SubscriptionController extends ProducerBaseController
'id' => $idSubscription
]);

if (!$subscription || $subscription->id_user != User::getCurrentId()) {
if (!$subscription || $subscription->id_user != UserModel::getCurrentId()) {
throw new UserException('Abonnement introuvable');
} else {
$params = array_merge($params, $subscription->getAttributes());

+ 2
- 1
producer/models/CreditForm.php 查看文件

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

namespace producer\models;

use common\logic\Producer\Producer\ProducerModel;
use Yii;
use yii\base\Model;

@@ -53,7 +54,7 @@ class CreditForm extends Model
{
return [
[['amount'], 'required'],
[['amount'], 'double', 'min' => Producer::getOnlinePaymentMinimumAmount()],
[['amount'], 'double', 'min' => ProducerModel::getOnlinePaymentMinimumAmount()],
];
}


+ 26203
- 0
producer/runtime/logs/app.log
文件差异内容过多而无法显示
查看文件


+ 2
- 1
producer/views/credit/add.php 查看文件

@@ -38,6 +38,7 @@

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\logic\Producer\Producer\ProducerModel;

$this->setTitle('Créditer mon compte');
$this->setPageTitle('Crédit mon compte');
@@ -62,7 +63,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 : '.Producer::getOnlinePaymentMinimumAmount().' €'); ?>
->hint('Montant minimum : '.ProducerModel::getOnlinePaymentMinimumAmount().' €'); ?>

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

+ 15
- 15
producer/views/credit/history.php 查看文件

@@ -39,7 +39,7 @@
use yii\grid\GridView;
use ruskid\stripe\StripeCheckoutCustom;

$creditHistoryService = \Yii::$app->logic->getCreditHistoryContainer()->getService();
$creditHistorySolver = \Yii::$app->logic->getCreditHistoryContainer()->getSolver();
$producer = $this->context->getProducer();
$this->setTitle('Crédit : <span id="credit-user">' . number_format($creditUser, 2) . ' €</span>');
$this->setPageTitle('Crédit');
@@ -61,35 +61,35 @@ if ($this->context->getProducer()->online_payment) {
'columns' => [
[
'attribute' => 'date',
'value' => function ($model) use ($creditHistoryService) {
return $creditHistoryService->getDate($model, true);
'value' => function ($model) use ($creditHistorySolver) {
return $creditHistorySolver->getDate($model, true);
}
],
[
'attribute' => 'id_user_action',
'value' => function ($model) use ($creditHistoryService) {
return $creditHistoryService->getStrUserAction($model);
'value' => function ($model) use ($creditHistorySolver) {
return $creditHistorySolver->getStrUserAction($model);
}
],
[
'label' => 'Type',
'format' => 'raw',
'value' => function ($model) use ($creditHistoryService) {
return $creditHistoryService->getStrWording($model);
'value' => function ($model) use ($creditHistorySolver) {
return $creditHistorySolver->getStrWording($model);
}
],
[
'attribute' => 'mean_payment',
'value' => function ($model) use ($creditHistoryService) {
return $creditHistoryService->getStrMeanPayment($model);
'value' => function ($model) use ($creditHistorySolver) {
return $creditHistorySolver->getStrMeanPayment($model);
}
],
[
'label' => '- Débit',
'format' => 'raw',
'value' => function ($model) use ($creditHistoryService) {
if ($creditHistoryService->isTypeDebit($model)) {
return '-&nbsp;' . $creditHistoryService->getAmount($model, true);
'value' => function ($model) use ($creditHistorySolver) {
if ($creditHistorySolver->isTypeDebit($model)) {
return '-&nbsp;' . $creditHistorySolver->getAmount($model, true);
}
return '';
}
@@ -97,9 +97,9 @@ if ($this->context->getProducer()->online_payment) {
[
'label' => '+ Crédit',
'format' => 'raw',
'value' => function ($model) use ($creditHistoryService) {
if ($creditHistoryService->isTypeCredit($model)) {
return '+&nbsp;' . $creditHistoryService->getAmount($model, true);
'value' => function ($model) use ($creditHistorySolver) {
if ($creditHistorySolver->isTypeCredit($model)) {
return '+&nbsp;' . $creditHistorySolver->getAmount($model, true);
}
return '';
}

+ 3
- 3
producer/views/layouts/main.php 查看文件

@@ -41,16 +41,16 @@ use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use common\widgets\Alert;
use common\helpers\Url;
use common\models\Producer;
use common\models\UserModel;
use common\helpers\GlobalParam;
use common\logic\User\UserProducer\UserProducerModel;
use common\logic\User\User\UserModel;

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

$producer = $this->context->getProducer();
if (!Yii::$app->user->isGuest) {
$userProducer = UserProducer::findOne(['id_user' => UserModel::getCurrentId(), 'id_producer' => $producer->id]);
$userProducer = UserProducerModel::findOne(['id_user' => UserModel::getCurrentId(), 'id_producer' => $producer->id]);
}

?>

+ 3
- 3
producer/views/order/_form.php 查看文件

@@ -37,7 +37,7 @@ termes.
*/

use yii\widgets\ActiveForm;
use common\models\Product;
use common\logic\Producer\Producer\ProducerModel;

?>
<div class="order-form">
@@ -123,7 +123,7 @@ use common\models\Product;
{
foreach($pointSale->userPointSale as $userPointSale)
{
if($userPointSale->id_user == User::getCurrentId() && strlen($userPointSale->comment))
if($userPointSale->id_user == UserModel::getCurrentId() && strlen($userPointSale->comment))
{
$comment = '<div class="comment"><span>'.Html::encode($userPointSale->comment).'</span></div>' ;
}
@@ -257,7 +257,7 @@ use common\models\Product;

<?php if($idProducer): ?>
<?php
$producer = Producer::findOne($idProducer);
$producer = ProducerModel::findOne($idProducer);
?>
<div id="bar-fixed" class="<?php if($producer->credit): ?>credit<?php else: ?>no-credit<?php endif; ?>">
<div class="container">

+ 5
- 5
producer/views/order/order.php 查看文件

@@ -37,8 +37,8 @@ termes.
*/

use common\helpers\GlobalParam ;
use common\models\Producer ;
use common\models\Distribution ;
use common\logic\Producer\Producer\ProducerModel;

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

@@ -69,7 +69,7 @@ $producer = $this->context->getProducer();
<div>
<div id="steps">
<ul>
<?php if($producer->option_order_entry_point == Producer::ORDER_ENTRY_POINT_DATE): ?>
<?php if($producer->option_order_entry_point == ProducerModel::ORDER_ENTRY_POINT_DATE): ?>
<step-date
first="true"
:step="step"
@@ -134,7 +134,7 @@ $producer = $this->context->getProducer();
Chargement ...
</div>
<div v-else>
<?php if($producer->behavior_order_select_distribution == Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST ): ?>
<?php if($producer->behavior_order_select_distribution == ProducerModel::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST ): ?>
<div style="display:none ;">
<?php endif; ?>
<div id="legend">
@@ -158,11 +158,11 @@ $producer = $this->context->getProducer();
@dayclick='dayClick'
></v-calendar>
</div>
<?php if($producer->behavior_order_select_distribution == Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST ): ?>
<?php if($producer->behavior_order_select_distribution == ProducerModel::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST ): ?>
</div>
<?php endif; ?>

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

+ 3
- 3
producer/views/site/index.php 查看文件

@@ -39,7 +39,7 @@ termes.
use common\helpers\GlobalParam ;
use common\models\Distribution;
use common\models\PointSaleDistribution;
use common\models\Producer ;
use common\logic\Producer\Producer\ProducerModel;

$producer = $this->context->getProducer() ;
$this->setTitle('Accueil');
@@ -82,7 +82,7 @@ $this->setPageTitle(Html::encode($producer->type.' à '.$producer->city)) ;

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

if($producer->behavior_home_point_sale_day_list == Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_WEEK) {
if($producer->behavior_home_point_sale_day_list == ProducerModel::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_WEEK) {
$arrayDays = [
'monday' => 'Lundi',
'tuesday' => 'Mardi',
@@ -109,7 +109,7 @@ $this->setPageTitle(Html::encode($producer->type.' à '.$producer->city)) ;

return $html ;
}
elseif($producer->behavior_home_point_sale_day_list == Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_INCOMING_DISTRIBUTIONS) {
elseif($producer->behavior_home_point_sale_day_list == ProducerModel::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_INCOMING_DISTRIBUTIONS) {
$html = '' ;
$incomingDistributions = Distribution::getIncomingDistributions();
$cpt = 0 ;

+ 2
- 6
producer/views/subscription/_form.php 查看文件

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

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper ;
use common\models\UserModel ;
use common\models\PointSale ;
use common\logic\Producer\Producer\ProducerModel;

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

@@ -134,7 +130,7 @@ use common\models\PointSale ;
<h3><span>Paiement</span></h3>

<?php if(Producer::getConfig('credit')): ?>
<?php if(ProducerModel::getConfig('credit')): ?>
<div class="form-group field-subscriptionform-auto_payment">
<label><input type="checkbox" id="subscriptionform-auto_payment" name="SubscriptionForm[auto_payment]" v-model="autoPayment"> Paiement automatique</label>
<div class="hint-block">Cochez cette case si vous souhaitez que votre Crédit soit automatiquement débité.</div>

+ 2
- 1
producer/views/subscription/index.php 查看文件

@@ -40,6 +40,7 @@ use yii\helpers\Html;
use yii\grid\GridView;
use common\models\Product ;
use common\helpers\GlobalParam;
use common\logic\Producer\Producer\ProducerModel;

$this->setTitle('Abonnements') ;
$this->addButton(['label' => '<span class="glyphicon glyphicon-plus"></span> Ajouter', 'url' => 'subscription/form', 'class' => 'btn btn-primary']) ;
@@ -152,7 +153,7 @@ $columns = [
],
] ;
if(Producer::getConfig('credit')) {
if(ProducerModel::getConfig('credit')) {
$columns[] = [
'format' => 'raw',
'label' => 'Paiement automatique',

正在加载...
取消
保存