Parcourir la source

Adaptations refactoring/traduction backend/controllers/IndexController > OrderController

dev
Guillaume Bourgeois il y a 6 ans
Parent
révision
7e78215528
11 fichiers modifiés avec 461 ajouts et 536 suppressions
  1. +420
    -509
      backend/controllers/OrderController.php
  2. +2
    -2
      backend/models/CreditForm.php
  3. +1
    -1
      common/components/ActiveRecordCommon.php
  4. +1
    -1
      common/models/Development.php
  5. +3
    -4
      common/models/Distribution.php
  6. +2
    -2
      common/models/PointSale.php
  7. +1
    -1
      common/models/PointSaleDistribution.php
  8. +5
    -5
      common/models/Producer.php
  9. +5
    -4
      common/models/Product.php
  10. +19
    -5
      common/models/User.php
  11. +2
    -2
      frontend/models/AddProducerForm.php

backend/controllers/OrderController.php
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


+ 2
- 2
backend/models/CreditForm.php Voir le fichier

@@ -102,7 +102,7 @@ class CreditForm extends Model
$creditHistory = new CreditHistory;
$creditHistory->id_user = $this->id_user;
$creditHistory->id_user_action = Yii::$app->user->identity->id;
$creditHistory->id_producer = Producer::getCurrentId() ;
$creditHistory->id_producer = Producer::getId() ;
$creditHistory->type = $this->type ;
$creditHistory->comment = $this->comment ;
$creditHistory->amount = $this->amount ;
@@ -112,7 +112,7 @@ class CreditForm extends Model
// on prévient l'utilisateur que son compte vient d'être crédité
if($this->send_mail) {
$user = User::findOne($this->id_user) ;
$producer = Producer::getCurrent() ;
$producer = Producer::get() ;
$userProducer = UserProducer::searchOne([
'id_user' => $this->id_user
]);

+ 1
- 1
common/components/ActiveRecordCommon.php Voir le fichier

@@ -71,7 +71,7 @@ class ActiveRecordCommon extends \yii\db\ActiveRecord
$pk = $class::tableName().'.'.$pk[0] ;
if (!isset($params[$options['attribute_id_producer']]) && !Yii::$app->user->isGuest) {
$params[$options['attribute_id_producer']] = Producer::getCurrentId();
$params[$options['attribute_id_producer']] = Producer::getId();
}
if(!isset($options['type_search'])) {

+ 1
- 1
common/models/Development.php Voir le fichier

@@ -100,7 +100,7 @@ class Development extends \yii\db\ActiveRecord
return $this->hasOne(
DevelopmentPriority::className(),
['id_development' => 'id'])
->where(['id_producer' => Producer::getCurrentId()])
->where(['id_producer' => Producer::getId()])
->with('producer');
}


+ 3
- 4
common/models/Distribution.php Voir le fichier

@@ -51,7 +51,6 @@ use common\models\Distribution;
*/
class Distribution extends \yii\db\ActiveRecord
{

/**
* @inheritdoc
*/
@@ -120,7 +119,7 @@ class Distribution extends \yii\db\ActiveRecord
/**
* Retourne si un produit est actif ou non.
*
* @param integer $id_produit
* @param integer $idProduit
* @return boolean
*/
public function isActiveProduct($idProduit)
@@ -157,7 +156,7 @@ class Distribution extends \yii\db\ActiveRecord
$distribution = new Distribution;
$distribution->date = $date;
$distribution->delivery = 1;
$distribution->id_producer = Producer::getCurrentId();
$distribution->id_producer = Producer::getId();
$distribution->save();
}
}
@@ -219,7 +218,7 @@ class Distribution extends \yii\db\ActiveRecord
}
}
return $production ;
return $distribution ;
}

}

+ 2
- 2
common/models/PointSale.php Voir le fichier

@@ -183,7 +183,7 @@ class PointSale extends \yii\db\ActiveRecord
*/
public function save($runValidation = true, $attributeNames = NULL)
{
$this->id_producer = Producer::getCurrentId();
$this->id_producer = Producer::getId();
return parent::save($runValidation, $attributeNames);
}

@@ -249,7 +249,7 @@ class PointSale extends \yii\db\ActiveRecord
*/
public static function count()
{
return self::searchCount(['id_producer' => Producer::getCurrentId()]) ;
return self::searchCount(['id_producer' => Producer::getId()]) ;
}

/**

+ 1
- 1
common/models/PointSaleDistribution.php Voir le fichier

@@ -52,7 +52,7 @@ use common\models\Production;
class PointSaleDistribution extends \yii\db\ActiveRecord
{

var $point_sale_distribution;
var $points_sale_distribution;

/**
* @inheritdoc

+ 5
- 5
common/models/Producer.php Voir le fichier

@@ -282,7 +282,7 @@ class Producer extends \yii\db\ActiveRecord
{
if (strlen($config)) {
if (!$idProducer) {
$idProducer = Producer::getCurrentId() ;
$idProducer = Producer::getId() ;
}
$producer = self::findOne($idProducer);
@@ -349,9 +349,9 @@ class Producer extends \yii\db\ActiveRecord
* Retourne le producteur courant (le producteur auquel l'utilisateur
* connecté est rattaché).
*
* @return boolean
* @return integer|boolean
*/
public static function getCurrentId()
public static function getId()
{
if(!Yii::$app->user->isGuest) {
return Yii::$app->user->identity->id_producer ;
@@ -365,9 +365,9 @@ class Producer extends \yii\db\ActiveRecord
*
* @return Producer|boolean
*/
public static function getCurrent()
public static function get()
{
if(self::getCurrentId()) {
if(self::getId()) {
return self::searchOne() ;
}

+ 5
- 4
common/models/Product.php Voir le fichier

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

use Yii;
use common\components\ActiveRecordCommon ;

/**
* This is the model class for table "produit".
@@ -54,7 +55,7 @@ use Yii;
* @property double $poids
* @property string $recette
*/
class Product extends \yii\db\ActiveRecord
class Product extends ActiveRecordCommon
{
var $total = 0;

@@ -162,7 +163,7 @@ class Product extends \yii\db\ActiveRecord
*/
public function save($runValidation = true, $attributeNames = NULL)
{
$this->id_producer = Producer::getCurrentId();
$this->id_producer = Producer::getId();
return parent::save($runValidation, $attributeNames);
}

@@ -172,12 +173,12 @@ class Product extends \yii\db\ActiveRecord
* @param integer $idDistribution
* @return array
*/
public function searchByDistribution($idDistribution)
public static function searchByDistribution($idDistribution)
{
return Product::find()
->leftJoin('product_distribution', 'product.id = product_distribution.id_product')
->where([
'id_producer' => Producer::getCurrentId(),
'id_producer' => Producer::getId(),
'product_distribution.id_distribution' => $idDistribution
])
->orderBy('product_distribution.active DESC, product.order ASC')

+ 19
- 5
common/models/User.php Voir le fichier

@@ -40,7 +40,7 @@ namespace common\models;

use yii\web\IdentityInterface;
use yii\db\Query ;
use common\components\ActiveRecordCommon ;
/**
* User model
*
@@ -56,7 +56,7 @@ use yii\db\Query ;
* @property string $password write-only password
* @property boolean $confiance
*/
class User extends ActiveRecord implements IdentityInterface
class User extends ActiveRecordCommon implements IdentityInterface
{

const STATUS_DELETED = 0;
@@ -288,7 +288,7 @@ class User extends ActiveRecord implements IdentityInterface
public static function findBy($params = [])
{
if (!isset($params['id_producer'])) {
$params['id_producer'] = Producer::getCurrentId() ;
$params['id_producer'] = Producer::getId() ;
}
$query = (new Query())
@@ -501,7 +501,7 @@ class User extends ActiveRecord implements IdentityInterface
public function sendMailWelcome($password)
{
if (strlen($this->email)) {
$producer = Producer::findOne(Producer::getCurrentId());
$producer = Producer::findOne(Producer::getId());
Yii::$app->mailer->compose();
$mail = Yii::$app->mailer->compose(
['html' => 'createUserAdmin-html', 'text' => 'createUserAdmin-text'], ['user' => $this, 'producer' => $producer, 'password' => $password]
@@ -518,12 +518,26 @@ class User extends ActiveRecord implements IdentityInterface
*
* @return mixed
*/
public static function getCurrentId() {
public static function getId() {
if(!Yii::$app->user->isGuest) {
return Yii::$app->user->identity->id ;
}
return false ;
}
/**
* Retourne le status de l'utilisateur courant connecté.
*
* @return integer|boolean
*/
public static function getStatus()
{
if(!Yii::$app->user->isGuest) {
return Yii::$app->user->identity->status ;
}
return false ;
}

}

+ 2
- 2
frontend/models/AddProducerForm.php Voir le fichier

@@ -118,7 +118,7 @@ class AddProducerForm extends Model
$producer = Producer::findOne($this->id_producer);

$userProducerExist = UserProducer::searchOne([
'id_user' => User::getCurrentId(),
'id_user' => User::getId(),
'active' => 0
]) ;

@@ -127,7 +127,7 @@ class AddProducerForm extends Model
$userProducerExist->save();
} else {
$userProducer = new UserProducer();
$userProducer->id_user = User::getCurrentId();
$userProducer->id_user = User::getId();
$userProducer->id_producer = $this->id_producr;
$userProducer->credit = 0;
$userProducer->actif = 1;

Chargement…
Annuler
Enregistrer