@@ -40,8 +40,8 @@ namespace backend\controllers; | |||
use common\helpers\GlobalParam; | |||
use common\models\Producer ; | |||
use common\models\UserModel ; | |||
use common\models\UserModelSearch ; | |||
use common\models\ User ; | |||
use common\models\ UserSearch ; | |||
use backend\models\AccessUserProducerForm ; | |||
/** | |||
@@ -64,7 +64,7 @@ class AccessController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend(); | |||
return User::hasAccessBackend(); | |||
} | |||
] | |||
], | |||
@@ -80,7 +80,7 @@ class AccessController extends BackendController | |||
*/ | |||
public function actionIndex() | |||
{ | |||
$userSearch = new UserModelSearch ; | |||
$userSearch = new UserSearch ; | |||
$usersArray = $userSearch->search()->query->all() ; | |||
$modelAccessUserProducerForm = new AccessUserProducerForm ; | |||
@@ -88,14 +88,14 @@ class AccessController extends BackendController | |||
Yii::$app->getSession()->setFlash('success', 'Droits ajoutés à l\'utilisateur'); | |||
} | |||
$usersAccessArray = UserModel::find() | |||
$usersAccessArray = User::find() | |||
->where([ | |||
'id_producer' => GlobalParam::getCurrentProducerId(), | |||
'status' => UserModel::STATUS_PRODUCER | |||
'status' => User::STATUS_PRODUCER | |||
]) | |||
->all() ; | |||
$producer = ProducerModel::searchOne() ; | |||
$producer = Producer::searchOne() ; | |||
return $this->render('index', [ | |||
'usersArray' => $usersArray, | |||
@@ -110,13 +110,13 @@ class AccessController extends BackendController | |||
*/ | |||
public function actionDelete($idUser) | |||
{ | |||
$user = UserModel::searchOne([ | |||
$user = User::searchOne([ | |||
'id' => $idUser | |||
]) ; | |||
if($user) { | |||
$user->id_producer = 0 ; | |||
$user->status = UserModel::STATUS_ACTIVE ; | |||
$user->status = User::STATUS_ACTIVE ; | |||
$user->save() ; | |||
Yii::$app->getSession()->setFlash('success', 'Droits de l\'utilisateur supprimé.'); | |||
} |
@@ -40,7 +40,7 @@ namespace backend\controllers; | |||
use backend\models\MailForm ; | |||
use yii\web\NotFoundHttpException ; | |||
use common\models\UserModel ; | |||
use common\models\ User ; | |||
/** | |||
* UserController implements the CRUD actions for User model. | |||
@@ -64,7 +64,7 @@ class CommunicateAdminController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::getCurrentStatus() == UserModel::STATUS_ADMIN; | |||
return User::getCurrentStatus() == User::STATUS_ADMIN; | |||
} | |||
] | |||
], | |||
@@ -80,7 +80,7 @@ class CommunicateAdminController extends BackendController | |||
public function actionIndex($section = 'producers') | |||
{ | |||
if($section == 'producers') { | |||
$producers = ProducerModel::find()->where(['producer.active' => 1])->with(['contact'])->all() ; | |||
$producers = Producer::find()->where(['producer.active' => 1])->with(['contact'])->all() ; | |||
$usersArray = []; | |||
$users = [] ; | |||
foreach ($producers as $producer) { | |||
@@ -97,9 +97,9 @@ class CommunicateAdminController extends BackendController | |||
} | |||
} | |||
elseif($section == 'users') { | |||
$users = UserModel::find() | |||
$users = User::find() | |||
->where([ | |||
'user.status' => UserModel::STATUS_ACTIVE | |||
'user.status' => User::STATUS_ACTIVE | |||
]) | |||
->all() ; | |||
$usersArray = []; |
@@ -59,7 +59,7 @@ class CommunicateController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend(); | |||
return User::hasAccessBackend(); | |||
} | |||
] | |||
], | |||
@@ -75,8 +75,8 @@ class CommunicateController extends BackendController | |||
*/ | |||
public function actionIndex() | |||
{ | |||
$producer = ProducerModel::searchOne() ; | |||
$pointsSaleArray = PointSaleModel::searchAll() ; | |||
$producer = Producer::searchOne() ; | |||
$pointsSaleArray = PointSale::searchAll() ; | |||
return $this->render('index', [ | |||
'producer' => $producer, | |||
@@ -92,7 +92,7 @@ class CommunicateController extends BackendController | |||
*/ | |||
public function actionInstructions() | |||
{ | |||
$producer = ProducerModel::searchOne() ; | |||
$producer = Producer::searchOne() ; | |||
// get your HTML raw content without any layouts or scripts | |||
$content = $this->renderPartial('instructions_multi', [ |
@@ -89,7 +89,7 @@ class CronController extends BackendController | |||
$dateTime = strtotime("+7 day"); | |||
$dayStr = strtolower(date('l', $dateTime)); | |||
$fieldDeliveryDay = 'delivery_' . $dayStr; | |||
$pointsSaleArray = PointSaleModel::searchAll(['point_sale.id_producer' => $producer->id]); | |||
$pointsSaleArray = PointSale::searchAll(['point_sale.id_producer' => $producer->id]); | |||
$activeDistribution = false; | |||
foreach ($pointsSaleArray as $pointSale) { | |||
if ($pointSale->$fieldDeliveryDay) { | |||
@@ -158,7 +158,7 @@ class CronController extends BackendController | |||
} | |||
} | |||
$arrayProducers = ProducerModel::searchAll(); | |||
$arrayProducers = Producer::searchAll(); | |||
foreach ($arrayProducers as $producer) { | |||
$countOrders = 0; | |||
@@ -176,25 +176,25 @@ class CronController extends BackendController | |||
* Paiement des commandes (paiement automatique) | |||
*/ | |||
$arrayOrders = OrderModel::searchAll([ | |||
$arrayOrders = Order::searchAll([ | |||
'distribution.date' => $date, | |||
'distribution.id_producer' => $producer->id | |||
], [ | |||
'conditions' => 'date_delete IS NULL' | |||
]); | |||
$configCredit = ProducerModel::getConfig('credit', $producer->id); | |||
$configCredit = Producer::getConfig('credit', $producer->id); | |||
if ($arrayOrders && is_array($arrayOrders)) { | |||
foreach ($arrayOrders as $order) { | |||
if ($order->auto_payment && $configCredit) { | |||
if ($order->getAmount(OrderModel::AMOUNT_REMAINING) > 0) { | |||
if ($order->getAmount(Order::AMOUNT_REMAINING) > 0) { | |||
$order->saveCreditHistory( | |||
CreditHistoryModel::TYPE_PAYMENT, | |||
$order->getAmount(OrderModel::AMOUNT_REMAINING), | |||
CreditHistory::TYPE_PAYMENT, | |||
$order->getAmount(Order::AMOUNT_REMAINING), | |||
$order->distribution->id_producer, | |||
$order->id_user, | |||
UserModel::ID_USER_SYSTEM | |||
User::ID_USER_SYSTEM | |||
); | |||
$countOrders++; | |||
} | |||
@@ -206,8 +206,8 @@ class CronController extends BackendController | |||
* Envoi des commandes par email au producteur | |||
*/ | |||
if (!strlen($forceDate) && ProducerModel::getConfig('option_notify_producer_order_summary', $producer->id)) { | |||
$arrayOrders = OrderModel::searchAll([ | |||
if (!strlen($forceDate) && Producer::getConfig('option_notify_producer_order_summary', $producer->id)) { | |||
$arrayOrders = Order::searchAll([ | |||
'distribution.date' => $date, | |||
'distribution.id_producer' => $producer->id | |||
], [ | |||
@@ -245,9 +245,9 @@ class CronController extends BackendController | |||
$mail->setSubject($subject); | |||
// envoi des emails à tous les comptes users (statut producer) associés à ce producteur | |||
$userArray = UserModel::searchAll([ | |||
$userArray = User::searchAll([ | |||
'id_producer' => $producer->id, | |||
'status' => UserModel::STATUS_PRODUCER | |||
'status' => User::STATUS_PRODUCER | |||
]); | |||
foreach ($userArray as $user) { |
@@ -58,7 +58,7 @@ class DeliveryNoteController extends DocumentController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend(); | |||
return User::hasAccessBackend(); | |||
} | |||
] | |||
], |
@@ -63,7 +63,7 @@ class DevelopmentController extends Controller | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend() ; | |||
return User::hasAccessBackend() ; | |||
} | |||
] | |||
], |
@@ -48,11 +48,11 @@ use common\models\Product; | |||
use common\models\Producer; | |||
use common\models\Order; | |||
use common\models\ProductCategory; | |||
use common\models\UserModel; | |||
use common\models\ User; | |||
use common\models\Subscription; | |||
use common\helpers\Price; | |||
use common\models\PointSaleDistribution; | |||
use common\logic\UserProducer\UserProducerModel; | |||
use common\logic\UserProducer\ UserProducer; | |||
use DateTime; | |||
class DistributionController extends BackendController | |||
@@ -73,8 +73,8 @@ class DistributionController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::getCurrentStatus() == UserModel::STATUS_ADMIN | |||
|| UserModel::getCurrentStatus() == UserModel::STATUS_PRODUCER; | |||
return User::getCurrentStatus() == User::STATUS_ADMIN | |||
|| User::getCurrentStatus() == User::STATUS_PRODUCER; | |||
} | |||
] | |||
], | |||
@@ -96,7 +96,7 @@ class DistributionController extends BackendController | |||
$orderUpdate = null; | |||
if ($idOrderUpdate) { | |||
$orderUpdate = OrderModel::searchOne(['id' => $idOrderUpdate]); | |||
$orderUpdate = Order::searchOne(['id' => $idOrderUpdate]); | |||
} | |||
return $this->render('index', [ | |||
@@ -172,7 +172,7 @@ class DistributionController extends BackendController | |||
]; | |||
// commandes | |||
$ordersArray = OrderModel::searchAll([ | |||
$ordersArray = Order::searchAll([ | |||
'distribution.id' => $distribution->id, | |||
], [ | |||
'orderby' => 'user.lastname ASC, user.name ASC' | |||
@@ -193,7 +193,7 @@ class DistributionController extends BackendController | |||
$json['distribution']['weight'] = number_format($weight, 2); | |||
// products | |||
$productsQuery = ProductModel::find() | |||
$productsQuery = Product::find() | |||
->orWhere(['id_producer' => GlobalParam::getCurrentProducerId(),]) | |||
->joinWith([ | |||
'taxRate', | |||
@@ -210,7 +210,7 @@ class DistributionController extends BackendController | |||
$potentialWeight = 0; | |||
foreach ($productsArray as &$theProduct) { | |||
$quantityOrder = OrderModel::getProductQuantity($theProduct['id'], $ordersArray); | |||
$quantityOrder = Order::getProductQuantity($theProduct['id'], $ordersArray); | |||
$theProduct['quantity_ordered'] = $quantityOrder; | |||
if (!isset($theProduct['productDistribution'][0])) { | |||
@@ -249,7 +249,7 @@ class DistributionController extends BackendController | |||
$productOrderArray = []; | |||
foreach ($order->productOrder as $productOrder) { | |||
$productOrderArray[$productOrder->id_product] = [ | |||
'quantity' => $productOrder->quantity * ProductModel::$unitsArray[$productOrder->unit]['coefficient'], | |||
'quantity' => $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'], | |||
'unit' => $productOrder->unit, | |||
'price' => number_format($productOrder->price, 3), | |||
'invoice_price' => number_format($productOrder->invoice_price, 2), | |||
@@ -278,12 +278,12 @@ class DistributionController extends BackendController | |||
'wording' => $creditHistoryService->getStrWording($creditHistory), | |||
'debit' => ($creditHistoryService->isTypeDebit($creditHistory) ? '- ' . $creditHistoryService->getAmount( | |||
$creditHistory, | |||
OrderModel::AMOUNT_TOTAL, | |||
Order::AMOUNT_TOTAL, | |||
true | |||
) : ''), | |||
'credit' => ($creditHistoryService->isTypeCredit($creditHistory) ? '+ ' . $creditHistoryService->getAmount( | |||
$creditHistory, | |||
OrderModel::AMOUNT_TOTAL, | |||
Order::AMOUNT_TOTAL, | |||
true | |||
) : '') | |||
]; | |||
@@ -306,10 +306,10 @@ class DistributionController extends BackendController | |||
$order = array_merge($order->getAttributes(), [ | |||
'selected' => false, | |||
'weight' => $order->weight, | |||
'amount' => Price::numberTwoDecimals($order->getAmountWithTax(OrderModel::AMOUNT_TOTAL)), | |||
'amount_paid' => Price::numberTwoDecimals($order->getAmount(OrderModel::AMOUNT_PAID)), | |||
'amount_remaining' => Price::numberTwoDecimals($order->getAmount(OrderModel::AMOUNT_REMAINING)), | |||
'amount_surplus' => Price::numberTwoDecimals($order->getAmount(OrderModel::AMOUNT_SURPLUS)), | |||
'amount' => Price::numberTwoDecimals($order->getAmountWithTax(Order::AMOUNT_TOTAL)), | |||
'amount_paid' => Price::numberTwoDecimals($order->getAmount(Order::AMOUNT_PAID)), | |||
'amount_remaining' => Price::numberTwoDecimals($order->getAmount(Order::AMOUNT_REMAINING)), | |||
'amount_surplus' => Price::numberTwoDecimals($order->getAmount(Order::AMOUNT_SURPLUS)), | |||
'user' => (isset($order->user)) ? array_merge( | |||
$order->user->getAttributes(), | |||
$arrayCreditUser | |||
@@ -326,7 +326,7 @@ class DistributionController extends BackendController | |||
$json['orders'] = $ordersArray; | |||
// points de vente | |||
$pointsSaleArray = PointSaleModel::find() | |||
$pointsSaleArray = PointSale::find() | |||
->joinWith([ | |||
'pointSaleDistribution' => function ($q) use ($distribution) { | |||
$q->where(['id_distribution' => $distribution->id]); | |||
@@ -347,7 +347,7 @@ class DistributionController extends BackendController | |||
$json['points_sale'] = $pointsSaleArray; | |||
// bons de livraison | |||
$deliveryNotesArray = DeliveryNoteModel::searchAll([ | |||
$deliveryNotesArray = DeliveryNote::searchAll([ | |||
'distribution.date' => $date, | |||
], [ | |||
'join_with' => ['user AS user_delivery_note', 'orders', 'producer'] | |||
@@ -379,7 +379,7 @@ class DistributionController extends BackendController | |||
]; | |||
// utilisateurs | |||
$usersArray = UserModel::findBy()->all(); | |||
$usersArray = User::findBy()->all(); | |||
$json['users'] = $usersArray; | |||
@@ -424,7 +424,7 @@ class DistributionController extends BackendController | |||
} | |||
// abonnements manquants | |||
$arraySubscriptions = SubscriptionModel::searchByDate($date); | |||
$arraySubscriptions = Subscription::searchByDate($date); | |||
$json['missing_subscriptions'] = []; | |||
if ($distribution->active) { | |||
foreach ($arraySubscriptions as $subscription) { | |||
@@ -446,7 +446,7 @@ class DistributionController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$user = UserModel::findOne(['id' => $idUser]); | |||
$user = User::findOne(['id' => $idUser]); | |||
$favoritePointSale = $user->getFavoritePointSale(); | |||
$idFavoritePointSale = 0; | |||
if ($favoritePointSale) { | |||
@@ -467,12 +467,12 @@ class DistributionController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$order = OrderModel::searchOne(['id' => $idOrder]); | |||
$order = Order::searchOne(['id' => $idOrder]); | |||
$distribution = DistributionModel::findOne($idDistribution); | |||
$user = UserModel::findOne($idUser); | |||
$pointSale = PointSaleModel::findOne($idPointSale); | |||
$user = User::findOne($idUser); | |||
$pointSale = PointSale::findOne($idPointSale); | |||
$productsArray = ProductModel::find() | |||
$productsArray = Product::find() | |||
->where([ | |||
'id_producer' => GlobalParam::getCurrentProducerId(), | |||
])->joinWith([ | |||
@@ -505,7 +505,7 @@ class DistributionController extends BackendController | |||
$productOrderArray[$product['id']] = [ | |||
'quantity' => $quantity, | |||
'unit' => $product->unit, | |||
'unit_coefficient' => ProductModel::$unitsArray[$product->unit]['coefficient'], | |||
'unit_coefficient' => Product::$unitsArray[$product->unit]['coefficient'], | |||
'prices' => $priceArray, | |||
'active' => $product->productDistribution[0]->active | |||
&& (!$pointSale || $product->isAvailableOnPointSale($pointSale)), | |||
@@ -518,14 +518,14 @@ class DistributionController extends BackendController | |||
public function actionAjaxUpdateInvoicePrices($idOrder) | |||
{ | |||
$order = OrderModel::searchOne([ | |||
$order = Order::searchOne([ | |||
'id' => (int)$idOrder | |||
]); | |||
if ($order && $order->distribution->id_producer == GlobalParam::getCurrentProducerId()) { | |||
$userProducer = null; | |||
if ($order->id_user) { | |||
$userProducer = UserProducerModel::searchOne([ | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $order->id_user, | |||
'id_producer' => GlobalParam::getCurrentProducerId() | |||
]); | |||
@@ -581,7 +581,7 @@ class DistributionController extends BackendController | |||
$idProducer = GlobalParam::getCurrentProducerId(); | |||
} | |||
$ordersArray = OrderModel::searchAll( | |||
$ordersArray = Order::searchAll( | |||
[ | |||
'distribution.date' => $date, | |||
'distribution.id_producer' => $idProducer | |||
@@ -601,7 +601,7 @@ class DistributionController extends BackendController | |||
if ($distribution) { | |||
$selectedProductsArray = ProductDistributionModel::searchByDistribution($distribution->id); | |||
$pointsSaleArray = PointSaleModel::searchAll([ | |||
$pointsSaleArray = PointSale::searchAll([ | |||
'point_sale.id_producer' => $idProducer | |||
]); | |||
@@ -610,7 +610,7 @@ class DistributionController extends BackendController | |||
} | |||
// produits | |||
$productsArray = ProductModel::find() | |||
$productsArray = Product::find() | |||
->joinWith([ | |||
'productDistribution' => function ($q) use ($distribution) { | |||
$q->where(['id_distribution' => $distribution->id]); | |||
@@ -639,7 +639,7 @@ class DistributionController extends BackendController | |||
'pointsSaleArray' => $pointsSaleArray, | |||
'productsArray' => $productsArray, | |||
'ordersArray' => $ordersArray, | |||
'producer' => ProducerModel::searchOne(['id' => $idProducer]) | |||
'producer' => Producer::searchOne(['id' => $idProducer]) | |||
]); | |||
$dateStr = date('d/m/Y', strtotime($date)); | |||
@@ -708,8 +708,8 @@ class DistributionController extends BackendController | |||
} elseif ($type == 'csv') { | |||
$datas = []; | |||
$optionCsvExportAllProducts = ProducerModel::getConfig('option_csv_export_all_products'); | |||
$optionCsvExportByPiece = ProducerModel::getConfig('option_csv_export_by_piece'); | |||
$optionCsvExportAllProducts = Producer::getConfig('option_csv_export_all_products'); | |||
$optionCsvExportByPiece = Producer::getConfig('option_csv_export_by_piece'); | |||
// produits en colonne | |||
$productsNameArray = ['', 'Commentaire']; | |||
@@ -718,8 +718,8 @@ class DistributionController extends BackendController | |||
$cpt = 2; | |||
foreach ($productsArray as $product) { | |||
$productsHasQuantity[$product->id] = 0; | |||
foreach (ProductModel::$unitsArray as $unit => $dataUnit) { | |||
$quantity = OrderModel::getProductQuantity($product->id, $ordersArray, true, $unit); | |||
foreach ( Product::$unitsArray as $unit => $dataUnit) { | |||
$quantity = Order::getProductQuantity($product->id, $ordersArray, true, $unit); | |||
if ($quantity) { | |||
$productsHasQuantity[$product->id] += $quantity; | |||
} | |||
@@ -733,7 +733,7 @@ class DistributionController extends BackendController | |||
$productUnit = $product->unit; | |||
} | |||
$productName .= ' (' . ProductModel::strUnit($productUnit, 'wording_short', true) . ')'; | |||
$productName .= ' (' . Product::strUnit($productUnit, 'wording_short', true) . ')'; | |||
$productsNameArray[] = $productName; | |||
$productsIndexArray[$product->id] = $cpt++; | |||
@@ -751,7 +751,7 @@ class DistributionController extends BackendController | |||
if ($optionCsvExportByPiece) { | |||
foreach ($order->productOrder as $productOrder) { | |||
$orderLine[$productsIndexArray[$productOrder->id_product]] = OrderModel::getProductQuantityPieces( | |||
$orderLine[$productsIndexArray[$productOrder->id_product]] = Order::getProductQuantityPieces( | |||
$productOrder->id_product, | |||
[$order] | |||
); | |||
@@ -767,7 +767,7 @@ class DistributionController extends BackendController | |||
} | |||
$orderLine[$productsIndexArray[$productOrder->id_product]] .= $productOrder->quantity; | |||
if ($productOrder->product->unit != $productOrder->unit) { | |||
$orderLine[$productsIndexArray[$productOrder->id_product]] .= ProductModel::strUnit( | |||
$orderLine[$productsIndexArray[$productOrder->id_product]] .= Product::strUnit( | |||
$productOrder->unit, | |||
'wording_short', | |||
true | |||
@@ -844,7 +844,7 @@ class DistributionController extends BackendController | |||
]); | |||
if ($distribution) { | |||
$ordersArray = OrderModel::searchAll( | |||
$ordersArray = Order::searchAll( | |||
[ | |||
'distribution.date' => $date, | |||
'distribution.id_producer' => $idProducer | |||
@@ -856,7 +856,7 @@ class DistributionController extends BackendController | |||
); | |||
$selectedProductsArray = ProductDistributionModel::searchByDistribution($distribution->id); | |||
$pointsSaleArray = PointSaleModel::searchAll([ | |||
$pointsSaleArray = PointSale::searchAll([ | |||
'point_sale.id_producer' => $idProducer | |||
]); | |||
@@ -891,14 +891,14 @@ class DistributionController extends BackendController | |||
} | |||
// catégories | |||
$categoriesArray = ProductCategoryModel::searchAll( | |||
$categoriesArray = ProductCategory::searchAll( | |||
['id_producer' => $idProducer], | |||
['orderby' => 'product_category.position ASC'] | |||
); | |||
array_unshift($categoriesArray, null); | |||
// produits | |||
$productsArray = ProductModel::find() | |||
$productsArray = Product::find() | |||
->joinWith([ | |||
'productDistribution' => function ($q) use ($distribution) { | |||
$q->where(['id_distribution' => $distribution->id]); | |||
@@ -928,7 +928,7 @@ class DistributionController extends BackendController | |||
'categoriesArray' => $categoriesArray, | |||
'productsArray' => $productsArray, | |||
'ordersArray' => $ordersArrayPaged, | |||
'producer' => ProducerModel::searchOne(['id' => $idProducer]) | |||
'producer' => Producer::searchOne(['id' => $idProducer]) | |||
]); | |||
$dateStr = date('d/m/Y', strtotime($date)); | |||
@@ -1027,13 +1027,13 @@ class DistributionController extends BackendController | |||
public function actionReportTerredepains($date, $key) | |||
{ | |||
if ($key == 'ef572cc148c001f0180c4a624189ed30') { | |||
$producer = ProducerModel::searchOne([ | |||
$producer = Producer::searchOne([ | |||
'producer.slug' => 'terredepains' | |||
]); | |||
$idProducer = $producer->id; | |||
$ordersArray = OrderModel::searchAll( | |||
$ordersArray = Order::searchAll( | |||
[ | |||
'distribution.date' => $date, | |||
'distribution.id_producer' => $idProducer | |||
@@ -1055,7 +1055,7 @@ class DistributionController extends BackendController | |||
if ($distribution) { | |||
$selectedProductsArray = ProductDistributionModel::searchByDistribution($distribution->id); | |||
$pointsSaleArray = PointSaleModel::searchAll([ | |||
$pointsSaleArray = PointSale::searchAll([ | |||
'point_sale.id_producer' => $idProducer | |||
]); | |||
@@ -1064,7 +1064,7 @@ class DistributionController extends BackendController | |||
} | |||
// produits | |||
$productsArray = ProductModel::find() | |||
$productsArray = Product::find() | |||
->joinWith([ | |||
'productDistribution' => function ($q) use ($distribution) { | |||
$q->where(['id_distribution' => $distribution->id]); | |||
@@ -1084,7 +1084,7 @@ class DistributionController extends BackendController | |||
$productsHasQuantity = []; | |||
$cpt = 1; | |||
foreach ($productsArray as $product) { | |||
$theUnit = ProductModel::strUnit($product->unit, 'wording_short', true); | |||
$theUnit = Product::strUnit($product->unit, 'wording_short', true); | |||
$theUnit = ($theUnit == 'p.') ? '' : ' (' . $theUnit . ')'; | |||
$productsNameArray[] = $product->name . $theUnit; | |||
$productsIndexArray[$product->id] = $cpt++; | |||
@@ -1121,7 +1121,7 @@ class DistributionController extends BackendController | |||
} | |||
$orderLine[$productsIndexArray[$productOrder->id_product]] .= $productOrder->quantity; | |||
if ($productOrder->product->unit != $productOrder->unit) { | |||
$orderLine[$productsIndexArray[$productOrder->id_product]] .= ProductModel::strUnit($productOrder->unit, 'wording_short', true); | |||
$orderLine[$productsIndexArray[$productOrder->id_product]] .= Product::strUnit($productOrder->unit, 'wording_short', true); | |||
} | |||
} | |||
$datas[] = $this->_lineOrderReportCSV($orderLine, $cpt - 1, true); | |||
@@ -1151,8 +1151,8 @@ class DistributionController extends BackendController | |||
{ | |||
$totalsPointSaleArray = [$label]; | |||
foreach ($productsArray as $product) { | |||
foreach (ProductModel::$unitsArray as $unit => $dataUnit) { | |||
$quantity = OrderModel::getProductQuantity($product->id, $ordersArray, false, $unit); | |||
foreach ( Product::$unitsArray as $unit => $dataUnit) { | |||
$quantity = Order::getProductQuantity($product->id, $ordersArray, false, $unit); | |||
if ($quantity) { | |||
$index = $productsIndexArray[$product->id]; | |||
if (!isset($totalsPointSaleArray[$index])) { | |||
@@ -1166,7 +1166,7 @@ class DistributionController extends BackendController | |||
$totalsPointSaleArray[$index] .= $quantity; | |||
if ($product->unit != $unit) { | |||
$totalsPointSaleArray[$index] .= '' . ProductModel::strUnit($unit, 'wording_short', true); | |||
$totalsPointSaleArray[$index] .= '' . Product::strUnit($unit, 'wording_short', true); | |||
} | |||
} | |||
} | |||
@@ -1180,8 +1180,8 @@ class DistributionController extends BackendController | |||
foreach ($productsArray as $product) { | |||
$quantity = 0; | |||
foreach (ProductModel::$unitsArray as $unit => $dataUnit) { | |||
$quantityProduct = OrderModel::getProductQuantity($product->id, $ordersArray, false, $unit); | |||
foreach ( Product::$unitsArray as $unit => $dataUnit) { | |||
$quantityProduct = Order::getProductQuantity($product->id, $ordersArray, false, $unit); | |||
if ($unit == 'piece') { | |||
$quantity += $quantityProduct; | |||
@@ -1320,7 +1320,7 @@ class DistributionController extends BackendController | |||
$dateSaturday = date('Y-m-d', strtotime('Saturday', $start)); | |||
$dateSunday = date('Y-m-d', strtotime('Sunday', $start)); | |||
$pointsSaleArray = PointSaleModel::searchAll(); | |||
$pointsSaleArray = PointSale::searchAll(); | |||
$activeMonday = false; | |||
$activeTuesday = false; | |||
@@ -1387,7 +1387,7 @@ class DistributionController extends BackendController | |||
public function actionAjaxProcessAddSubscriptions($date) | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
SubscriptionModel::addAll($date, true); | |||
Subscription::addAll($date, true); | |||
return ['success']; | |||
} | |||
@@ -1400,14 +1400,14 @@ class DistributionController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$return = []; | |||
$producerTiller = ProducerModel::getConfig('tiller'); | |||
$producerTiller = Producer::getConfig('tiller'); | |||
if ($producerTiller) { | |||
$tiller = new Tiller(); | |||
$isSynchro = $tiller->isSynchro($date); | |||
if (!$isSynchro) { | |||
$orders = OrderModel::searchAll([ | |||
$orders = Order::searchAll([ | |||
'distribution.date' => $date, | |||
'order.tiller_synchronization' => 1 | |||
], [ | |||
@@ -1457,7 +1457,7 @@ class DistributionController extends BackendController | |||
[ | |||
'type' => $typePaymentTiller, | |||
'amount' => $order->getAmountWithTax( | |||
OrderModel::AMOUNT_TOTAL | |||
Order::AMOUNT_TOTAL | |||
) * 100, | |||
'status' => 'ACCEPTED', | |||
'date' => $strDate | |||
@@ -1487,12 +1487,12 @@ class DistributionController extends BackendController | |||
if (is_array($idOrders) && count($idOrders) > 0) { | |||
foreach ($idOrders as $idOrder) { | |||
$order = OrderModel::searchOne([ | |||
$order = Order::searchOne([ | |||
'id' => (int)$idOrder | |||
]); | |||
if ($order && $order->distribution->id_producer == GlobalParam::getCurrentProducerId()) { | |||
$deliveryNote = DeliveryNoteModel::searchOne([ | |||
$deliveryNote = DeliveryNote::searchOne([ | |||
'id' => (int)$order->id_delivery_note | |||
]); | |||
@@ -1531,7 +1531,7 @@ class DistributionController extends BackendController | |||
if (is_array($idOrders) && count($idOrders) > 0) { | |||
foreach ($idOrders as $idOrder) { | |||
$order = OrderModel::searchOne([ | |||
$order = Order::searchOne([ | |||
'id' => (int)$idOrder | |||
]); | |||
@@ -1540,7 +1540,7 @@ class DistributionController extends BackendController | |||
$deliveryNote = null; | |||
$idDeliveryNote = $order->id_delivery_note; | |||
if ($idDeliveryNote) { | |||
$deliveryNote = DeliveryNoteModel::searchOne([ | |||
$deliveryNote = DeliveryNote::searchOne([ | |||
'id' => (int)$idDeliveryNote | |||
]); | |||
} | |||
@@ -1571,10 +1571,10 @@ class DistributionController extends BackendController | |||
$order->save(); | |||
// init invoice prices | |||
$user = UserModel::searchOne([ | |||
$user = User::searchOne([ | |||
'id' => $deliveryNote->id_user | |||
]); | |||
$userProducer = UserProducerModel::searchOne([ | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $deliveryNote->id_user, | |||
'id_producer' => GlobalParam::getCurrentProducerId() | |||
]); | |||
@@ -1616,7 +1616,7 @@ class DistributionController extends BackendController | |||
if (is_array($idOrders) && count($idOrders) > 0) { | |||
// récupération première commande pour obtenir des infos | |||
reset($idOrders); | |||
$firstOrder = OrderModel::searchOne([ | |||
$firstOrder = Order::searchOne([ | |||
'id' => (int)$idOrders[key($idOrders)] | |||
]); | |||
@@ -1624,13 +1624,13 @@ class DistributionController extends BackendController | |||
$deliveryNote = null; | |||
$isUpdate = false; | |||
$i = 0; | |||
$ordersArray = OrderModel::searchAll([ | |||
$ordersArray = Order::searchAll([ | |||
'id' => $idOrders, | |||
]); | |||
do { | |||
$order = $ordersArray[$i]; | |||
if ($order->distribution->id_producer == GlobalParam::getCurrentProducerId() && $order->id_delivery_note > 0) { | |||
$deliveryNote = DeliveryNoteModel::searchOne([ | |||
$deliveryNote = DeliveryNote::searchOne([ | |||
'id' => $order->id_delivery_note | |||
]); | |||
$isUpdate = true; | |||
@@ -1638,7 +1638,7 @@ class DistributionController extends BackendController | |||
$i++; | |||
} while ($deliveryNote == null && isset($ordersArray[$i])); | |||
if ($deliveryNote && $deliveryNote->status == DocumentModel::STATUS_VALID) { | |||
if ($deliveryNote && $deliveryNote->status == Document::STATUS_VALID) { | |||
return [ | |||
'return' => 'error', | |||
'alert' => [ | |||
@@ -1663,16 +1663,16 @@ class DistributionController extends BackendController | |||
if ($firstOrder->pointSale->id_user) { | |||
$deliveryNote->id_user = $firstOrder->pointSale->id_user; | |||
$user = UserModel::searchOne([ | |||
$user = User::searchOne([ | |||
'id' => $deliveryNote->id_user | |||
]); | |||
$userProducer = UserProducerModel::searchOne([ | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $deliveryNote->id_user, | |||
'id_producer' => GlobalParam::getCurrentProducerId() | |||
]); | |||
} else { | |||
$user = new UserModel; | |||
$user->type = UserModel::TYPE_LEGAL_PERSON; | |||
$user = new User; | |||
$user->type = User::TYPE_LEGAL_PERSON; | |||
$user->name_legal_person = $firstOrder->pointSale->name; | |||
$user->address = $firstOrder->pointSale->address; | |||
$user->id_producer = 0; | |||
@@ -1684,7 +1684,7 @@ class DistributionController extends BackendController | |||
} | |||
$user->save(); | |||
$userProducer = new UserProducerModel; | |||
$userProducer = new UserProducer; | |||
$userProducer->id_user = $user->id; | |||
$userProducer->id_producer = GlobalParam::getCurrentProducerId(); | |||
$userProducer->credit = 0; | |||
@@ -1701,7 +1701,7 @@ class DistributionController extends BackendController | |||
$deliveryNote->save(); | |||
} else { | |||
// réinitialisation des order.id_delivery_note | |||
OrderModel::updateAll([ | |||
Order::updateAll([ | |||
'id_delivery_note' => null | |||
], [ | |||
'id_delivery_note' => $deliveryNote->id | |||
@@ -1709,10 +1709,10 @@ class DistributionController extends BackendController | |||
} | |||
if (!isset($user) || !$user) { | |||
$user = UserModel::searchOne([ | |||
$user = User::searchOne([ | |||
'id' => $deliveryNote->id_user | |||
]); | |||
$userProducer = UserProducerModel::searchOne([ | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $deliveryNote->id_user, | |||
'id_producer' => GlobalParam::getCurrentProducerId() | |||
]); | |||
@@ -1720,7 +1720,7 @@ class DistributionController extends BackendController | |||
// affectation du BL aux commandes | |||
foreach ($idOrders as $idOrder) { | |||
$order = OrderModel::searchOne([ | |||
$order = Order::searchOne([ | |||
'id' => (int)$idOrder | |||
]); | |||
if ($order && $order->distribution->id_producer == GlobalParam::getCurrentProducerId()) { | |||
@@ -1729,7 +1729,7 @@ class DistributionController extends BackendController | |||
} | |||
// init invoice price | |||
$order = OrderModel::searchOne(['id' => $idOrder]); | |||
$order = Order::searchOne(['id' => $idOrder]); | |||
if ($order) { | |||
$order->initInvoicePrices([ | |||
'user' => $user, |
@@ -43,11 +43,11 @@ use common\models\Invoice; | |||
use common\models\PointSale; | |||
use common\models\Product; | |||
use common\models\Quotation; | |||
use common\models\UserModel; | |||
use common\models\ User; | |||
use common\models\Document; | |||
use common\helpers\GlobalParam; | |||
use common\models\Order; | |||
use common\logic\UserProducer\UserProducerModel; | |||
use common\logic\UserProducer\ UserProducer; | |||
use kartik\mpdf\Pdf; | |||
use yii\base\UserException; | |||
use yii; | |||
@@ -69,7 +69,7 @@ class DocumentController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend(); | |||
return User::hasAccessBackend(); | |||
} | |||
] | |||
], | |||
@@ -82,9 +82,9 @@ class DocumentController extends BackendController | |||
set_time_limit(0); | |||
$validatedDocumentsArray = array_merge( | |||
QuotationModel::find()->where(['status' => DocumentModel::STATUS_VALID])->all(), | |||
DeliveryNoteModel::find()->where(['status' => DocumentModel::STATUS_VALID])->all(), | |||
InvoiceModel::find()->where(['status' => DocumentModel::STATUS_VALID])->all() | |||
Quotation::find()->where(['status' => Document::STATUS_VALID])->all(), | |||
DeliveryNote::find()->where(['status' => Document::STATUS_VALID])->all(), | |||
Invoice::find()->where(['status' => Document::STATUS_VALID])->all() | |||
); | |||
foreach($validatedDocumentsArray as $document) { | |||
@@ -125,7 +125,7 @@ class DocumentController extends BackendController | |||
if ($model->getClass() == 'Invoice') { | |||
if ($model->deliveryNotes && is_array($model->deliveryNotes) && count($model->deliveryNotes)) { | |||
foreach ($model->deliveryNotes as $key => $idDeliveryNote) { | |||
OrderModel::updateAll([ | |||
Order::updateAll([ | |||
'id_invoice' => $model->id | |||
], [ | |||
'id_delivery_note' => $idDeliveryNote | |||
@@ -172,7 +172,7 @@ class DocumentController extends BackendController | |||
$model->delete(); | |||
if ($this->getClass() == 'DeliveryNote') { | |||
OrderModel::updateAll([ | |||
Order::updateAll([ | |||
'order.id_delivery_note' => null | |||
], [ | |||
'order.id_delivery_note' => $id | |||
@@ -180,7 +180,7 @@ class DocumentController extends BackendController | |||
} | |||
if ($this->getClass() == 'Quotation') { | |||
OrderModel::updateAll([ | |||
Order::updateAll([ | |||
'order.id_quotation' => null | |||
], [ | |||
'order.id_quotation' => $id | |||
@@ -188,7 +188,7 @@ class DocumentController extends BackendController | |||
} | |||
if ($this->getClass() == 'Invoice') { | |||
OrderModel::updateAll([ | |||
Order::updateAll([ | |||
'order.id_invoice' => null | |||
], [ | |||
'order.id_invoice' => $id | |||
@@ -282,7 +282,7 @@ class DocumentController extends BackendController | |||
'', // Réf. | |||
$productOrder->product->name, // Désignation * | |||
$productOrder->quantity, // Qté * | |||
'', // ProductModel::strUnit($productOrder->unit, 'wording'), // Unité | |||
'', // Product::strUnit($productOrder->unit, 'wording'), // Unité | |||
$price, // PU HT * | |||
'', // Remise | |||
$productOrder->taxRate->value * 100, // TVA | |||
@@ -349,7 +349,7 @@ class DocumentController extends BackendController | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
if ($idUser > 0) { | |||
$user = UserModel::searchOne([ | |||
$user = User::searchOne([ | |||
'id' => $idUser | |||
]); | |||
@@ -378,13 +378,13 @@ class DocumentController extends BackendController | |||
'orderby' => 'distribution.date ASC', | |||
'join_with' => ['user AS user_delivery_note', 'orders', 'producer'] | |||
]; | |||
$deliveryNotesCreateArray = DeliveryNoteModel::searchAll([ | |||
$deliveryNotesCreateArray = DeliveryNote::searchAll([ | |||
'id_user' => $user->id, | |||
'status' => DocumentModel::STATUS_VALID | |||
'status' => Document::STATUS_VALID | |||
], $options); | |||
$deliveryNotesUpdateArray = DeliveryNoteModel::searchAll([ | |||
$deliveryNotesUpdateArray = DeliveryNote::searchAll([ | |||
'id_user' => $user->id, | |||
'status' => DocumentModel::STATUS_VALID, | |||
'status' => Document::STATUS_VALID, | |||
'order.id_invoice' => $idDocument | |||
], $options); | |||
$json['delivery_note_create_array'] = $this->initDeliveryNoteArray('create', $deliveryNotesCreateArray); | |||
@@ -424,7 +424,7 @@ class DocumentController extends BackendController | |||
$deliveryNote->getAttributes(), | |||
[ | |||
'url' => Yii::$app->urlManager->createUrl(['delivery-note/update', 'id' => $deliveryNote->id]), | |||
'total' => $deliveryNote->getAmountWithTax(OrderModel::INVOICE_AMOUNT_TOTAL) | |||
'total' => $deliveryNote->getAmountWithTax(Order::INVOICE_AMOUNT_TOTAL) | |||
] | |||
); | |||
@@ -439,7 +439,7 @@ class DocumentController extends BackendController | |||
{ | |||
$classDocument = $this->getClass(); | |||
if ($id > 0 && DocumentModel::isValidClass($classDocument)) { | |||
if ($id > 0 && Document::isValidClass($classDocument)) { | |||
$document = $classDocument::searchOne([ | |||
'id' => $id | |||
]); | |||
@@ -470,7 +470,7 @@ class DocumentController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
if ($idDocument > 0 && DocumentModel::isValidClass($classDocument)) { | |||
if ($idDocument > 0 && Document::isValidClass($classDocument)) { | |||
$document = $classDocument::searchOne([ | |||
'id' => $idDocument | |||
]); | |||
@@ -501,13 +501,13 @@ class DocumentController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
if ($idDocument > 0 && DocumentModel::isValidClass($classDocument)) { | |||
if ($idDocument > 0 && Document::isValidClass($classDocument)) { | |||
$document = $classDocument::searchOne([ | |||
'id' => $idDocument | |||
]); | |||
if ($document) { | |||
$productsArray = ProductModel::searchAll([], [ | |||
$productsArray = Product::searchAll([], [ | |||
'orderby' => 'product.order ASC' | |||
]); | |||
@@ -536,11 +536,11 @@ class DocumentController extends BackendController | |||
); | |||
} | |||
$userProducer = UserProducerModel::searchOne([ | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $document->user->id, | |||
'id_producer' => GlobalParam::getCurrentProducerId() | |||
]); | |||
$pointSale = PointSaleModel::searchOne([ | |||
$pointSale = PointSale::searchOne([ | |||
'id_user' => $document->user->id | |||
]); | |||
@@ -549,7 +549,7 @@ class DocumentController extends BackendController | |||
'order', | |||
function ($product) use ($document, $userProducer, $pointSale) { | |||
return array_merge($product->getAttributes(), [ | |||
'unit_coefficient' => ProductModel::$unitsArray[$product->unit]['coefficient'], | |||
'unit_coefficient' => Product::$unitsArray[$product->unit]['coefficient'], | |||
'prices' => $product->getPriceArray($userProducer->user, $pointSale), | |||
'wording_unit' => $product->wording_unit, | |||
'tax_rate' => $product->taxRate->value | |||
@@ -569,12 +569,12 @@ class DocumentController extends BackendController | |||
'orders' => $ordersArray, | |||
'total' => ($document->getClass() == 'Invoice' || $document->getClass( | |||
) == 'DeliveryNote') ? $document->getAmount( | |||
OrderModel::INVOICE_AMOUNT_TOTAL | |||
) : $document->getAmount(OrderModel::AMOUNT_TOTAL), | |||
Order::INVOICE_AMOUNT_TOTAL | |||
) : $document->getAmount(Order::AMOUNT_TOTAL), | |||
'total_with_tax' => ($document->getClass() == 'Invoice' || $document->getClass( | |||
) == 'DeliveryNote') ? $document->getAmountWithTax( | |||
OrderModel::INVOICE_AMOUNT_TOTAL | |||
) : $document->getAmountWithTax(OrderModel::AMOUNT_TOTAL), | |||
Order::INVOICE_AMOUNT_TOTAL | |||
) : $document->getAmountWithTax(Order::AMOUNT_TOTAL), | |||
'invoice_url' => ($document->getClass() == 'DeliveryNote' && $document->getInvoice()) ? Yii::$app->urlManager->createUrl(['invoice/update', 'id' => $document->getInvoice()->id]) : null | |||
]; | |||
} | |||
@@ -591,7 +591,7 @@ class DocumentController extends BackendController | |||
$document = $classDocument::searchOne([ | |||
'id' => $idDocument | |||
]); | |||
$product = ProductModel::searchOne([ | |||
$product = Product::searchOne([ | |||
'id' => $idProduct | |||
]); | |||
@@ -602,7 +602,7 @@ class DocumentController extends BackendController | |||
$order->id_point_sale = null; | |||
$order->id_distribution = null; | |||
$order->status = 'tmp-order'; | |||
$order->origin = OrderModel::ORIGIN_ADMIN; | |||
$order->origin = Order::ORIGIN_ADMIN; | |||
$order->date = date('Y-m-d H:i:s'); | |||
$fieldIdDocument = 'id_' . $classDocument::tableName(); | |||
$order->$fieldIdDocument = $document->id; | |||
@@ -615,7 +615,7 @@ class DocumentController extends BackendController | |||
$productOrder = new ProductOrder; | |||
$productOrder->id_order = $order->id; | |||
$productOrder->id_product = $idProduct; | |||
$quantity = $quantity / ProductModel::$unitsArray[$product->unit]['coefficient']; | |||
$quantity = $quantity / Product::$unitsArray[$product->unit]['coefficient']; | |||
$productOrder->quantity = $quantity; | |||
$productOrder->price = (float)$price; | |||
$productOrder->unit = $product->unit; | |||
@@ -647,7 +647,7 @@ class DocumentController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$productOrder = ProductOrderModel::searchOne([ | |||
$productOrder = ProductOrder::searchOne([ | |||
'id' => $idProductOrder | |||
]); | |||
@@ -62,10 +62,10 @@ class InvoiceController extends DocumentController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$invoice = InvoiceModel::searchOne(['id' => $idInvoice]); | |||
$invoice = Invoice::searchOne(['id' => $idInvoice]); | |||
if($invoice && $invoice->isStatusDraft()) { | |||
OrderModel::updateAll([ | |||
Order::updateAll([ | |||
'id_invoice' => null | |||
], [ | |||
'id_delivery_note' => $idDeliveryNote | |||
@@ -92,11 +92,11 @@ class InvoiceController extends DocumentController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$invoice = InvoiceModel::searchOne(['id' => $idInvoice]); | |||
$deliveryNote = DeliveryNoteModel::searchOne(['id' => $idDeliveryNote]); | |||
$invoice = Invoice::searchOne(['id' => $idInvoice]); | |||
$deliveryNote = DeliveryNote::searchOne(['id' => $idDeliveryNote]); | |||
if($invoice && $invoice->isStatusDraft() && $deliveryNote) { | |||
OrderModel::updateAll([ | |||
Order::updateAll([ | |||
'id_invoice' => $idInvoice | |||
], [ | |||
'id_delivery_note' => $idDeliveryNote |
@@ -43,11 +43,11 @@ use common\models\CreditHistory; | |||
use common\models\Order; | |||
use common\models\ProductOrder; | |||
use common\models\Product; | |||
use common\models\UserModel; | |||
use common\models\ User; | |||
use common\models\ProductDistribution; | |||
use common\models\Distribution; | |||
use common\models\Producer; | |||
use common\logic\UserProducer\UserProducerModel; | |||
use common\logic\UserProducer\ UserProducer; | |||
class OrderController extends BackendController | |||
{ | |||
@@ -63,8 +63,8 @@ class OrderController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::getCurrentStatus() == UserModel::STATUS_ADMIN | |||
|| UserModel::getCurrentStatus() == UserModel::STATUS_PRODUCER; | |||
return User::getCurrentStatus() == User::STATUS_ADMIN | |||
|| User::getCurrentStatus() == User::STATUS_PRODUCER; | |||
} | |||
] | |||
], | |||
@@ -86,7 +86,7 @@ class OrderController extends BackendController | |||
{ | |||
if ($date != '') { | |||
// commandes | |||
$orders = OrderModel::searchAll([ | |||
$orders = Order::searchAll([ | |||
'distribution.date' => $date | |||
]); | |||
@@ -98,7 +98,7 @@ class OrderController extends BackendController | |||
foreach ($point->orders as $order) { | |||
// suppression des product_order | |||
ProductOrderModel::deleteAll(['id_order' => $order->id]); | |||
ProductOrder::deleteAll(['id_order' => $order->id]); | |||
// création des commande_produit modifiés | |||
foreach ($products as $product) { | |||
@@ -168,7 +168,7 @@ class OrderController extends BackendController | |||
*/ | |||
public function actionIndex($date = '', $returnData = false) | |||
{ | |||
if (!ProductModel::searchCount() || !PointSaleModel::searchCount()) { | |||
if (! Product::searchCount() || !PointSale::searchCount()) { | |||
$this->redirect(['site/index', 'error_products_points_sale' => 1]); | |||
} | |||
@@ -176,7 +176,7 @@ class OrderController extends BackendController | |||
// users | |||
$arrayUsers = [0 => '--']; | |||
$users = UserModel::searchAll([], ['orderby' => 'lastname, name ASC']); | |||
$users = User::searchAll([], ['orderby' => 'lastname, name ASC']); | |||
foreach ($users as $user) { | |||
$arrayUsers[$user->id] = $user->name . ' ' . $user->lastname; | |||
@@ -187,7 +187,7 @@ class OrderController extends BackendController | |||
// points de vente | |||
if ($distribution) { | |||
$arrayPointsSale = PointSaleModel::find() | |||
$arrayPointsSale = PointSale::find() | |||
->joinWith(['pointSaleDistribution' => function ($q) use ($distribution) { | |||
$q->where(['id_distribution' => $distribution->id]); | |||
}]) | |||
@@ -196,17 +196,17 @@ class OrderController extends BackendController | |||
]) | |||
->all(); | |||
} else { | |||
$arrayPointsSale = PointSaleModel::searchAll(); | |||
$arrayPointsSale = PointSale::searchAll(); | |||
} | |||
// produits | |||
$arrayProducts = ProductModel::searchAll(); | |||
$arrayProducts = Product::searchAll(); | |||
// gestion des commandes | |||
$this->processOrderForm($distribution, $date, $arrayPointsSale, $arrayProducts, $users); | |||
// commandes | |||
$arrayOrders = OrderModel::searchAll([ | |||
$arrayOrders = Order::searchAll([ | |||
'distribution.date' => $date, | |||
]); | |||
@@ -311,7 +311,7 @@ class OrderController extends BackendController | |||
// produits | |||
if ($distribution) { | |||
$arrayProducts = ProductModel::searchByDistribution($distribution->id); | |||
$arrayProducts = Product::searchByDistribution($distribution->id); | |||
} | |||
// poids total de la production et CA potentiel | |||
@@ -429,18 +429,18 @@ class OrderController extends BackendController | |||
public function actionDownload($date = '', $idPointSale = 0, $global = 0) | |||
{ | |||
// commandes | |||
$ordersArray = OrderModel::searchAll([ | |||
$ordersArray = Order::searchAll([ | |||
'distribution.date' => $date | |||
]); | |||
// points de vente | |||
$pointsSaleArray = PointSaleModel::searchAll(); | |||
$pointsSaleArray = PointSale::searchAll(); | |||
foreach ($pointsSaleArray as $pointSale) { | |||
$pv->initOrders($ordersArray); | |||
} | |||
// produits | |||
$productsArray = ProductModel::find()->orderBy('order ASC')->all(); | |||
$productsArray = Product::find()->orderBy('order ASC')->all(); | |||
$distribution = DistributionModel::find() | |||
->where('date LIKE \':date\'') | |||
@@ -481,7 +481,7 @@ class OrderController extends BackendController | |||
$strProducts = ''; | |||
foreach ($productsArray as $product) { | |||
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | |||
$quantity = OrderModel::getProductQuantity($product->id, $pointSale->orders); | |||
$quantity = Order::getProductQuantity($product->id, $pointSale->orders); | |||
$strQuantity = ''; | |||
if ($quantity) { | |||
$strQuantity = $quantity; | |||
@@ -501,7 +501,7 @@ class OrderController extends BackendController | |||
$strProducts = ''; | |||
foreach ($productsArray as $product) { | |||
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | |||
$quantity = OrderModel::getProductQuantity($product->id, $ordersArray); | |||
$quantity = Order::getProductQuantity($product->id, $ordersArray); | |||
$strQuantity = ''; | |||
if ($quantity) { | |||
$strQuantity = $quantity; | |||
@@ -587,7 +587,7 @@ class OrderController extends BackendController | |||
$dataAdd = [$pointSale->name]; | |||
foreach ($products as $product) { | |||
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | |||
$dataAdd[] = OrderModel::getProductQuantity($product->id, $pointSale->orders); | |||
$dataAdd[] = Order::getProductQuantity($product->id, $pointSale->orders); | |||
} | |||
} | |||
$data[] = $dataAdd; | |||
@@ -597,7 +597,7 @@ class OrderController extends BackendController | |||
$dataAdd = ['Total']; | |||
foreach ($products as $product) { | |||
if (isset($selectedProductsArray[$product->id]['active']) && $selectedProductsArray[$product->id]['active']) { | |||
$dataAdd[] = OrderModel::getProductQuantity($product->id, $orders); | |||
$dataAdd[] = Order::getProductQuantity($product->id, $orders); | |||
} | |||
} | |||
$data[] = $dataAdd; | |||
@@ -692,7 +692,7 @@ class OrderController extends BackendController | |||
if ($active) { | |||
// add commandes automatiques | |||
SubscriptionModel::addAll($date); | |||
Subscription::addAll($date); | |||
} | |||
if ($redirect) { | |||
@@ -718,7 +718,7 @@ class OrderController extends BackendController | |||
$dateSaturday = date('Y-m-d', strtotime('Saturday', $start)); | |||
$dateSunday = date('Y-m-d', strtotime('Sunday', $start)); | |||
$pointsSaleArray = PointSaleModel::searchAll(); | |||
$pointsSaleArray = PointSale::searchAll(); | |||
$activeMonday = false; | |||
$activeTuesday = false; | |||
@@ -759,7 +759,7 @@ class OrderController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$order = OrderModel::searchOne([ | |||
$order = Order::searchOne([ | |||
'id' => $idOrder | |||
]); | |||
@@ -780,23 +780,23 @@ class OrderController extends BackendController | |||
*/ | |||
public function actionDelete($date, $idOrder) | |||
{ | |||
$order = OrderModel::searchOne(['id' => $idOrder]); | |||
$order = Order::searchOne(['id' => $idOrder]); | |||
if ($order) { | |||
// remboursement de la commande | |||
if ($order->id_user && $order->getAmount(OrderModel::AMOUNT_PAID) && ProducerModel::getConfig('credit')) { | |||
if ($order->id_user && $order->getAmount(Order::AMOUNT_PAID) && Producer::getConfig('credit')) { | |||
$order->saveCreditHistory( | |||
CreditHistoryModel::TYPE_REFUND, | |||
$order->getAmount(OrderModel::AMOUNT_PAID), | |||
CreditHistory::TYPE_REFUND, | |||
$order->getAmount(Order::AMOUNT_PAID), | |||
$order->distribution->id_producer, | |||
$order->id_user, | |||
UserModel::getCurrentId() | |||
User::getCurrentId() | |||
); | |||
} | |||
$order->delete(); | |||
ProductOrderModel::deleteAll(['id_order' => $idOrder]); | |||
ProductOrder::deleteAll(['id_order' => $idOrder]); | |||
} | |||
$this->redirect(['index', 'date' => $date]); | |||
@@ -819,7 +819,7 @@ class OrderController extends BackendController | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$products = json_decode($products); | |||
$pointSale = PointSaleModel::findOne($idPointSale); | |||
$pointSale = PointSale::findOne($idPointSale); | |||
$distribution = DistributionModel::searchOne([ | |||
'date' => $date | |||
]); | |||
@@ -835,7 +835,7 @@ class OrderController extends BackendController | |||
$order->id_point_sale = $idPointSale; | |||
$order->mean_payment = $meanPayment; | |||
$order->id_distribution = $distribution->id; | |||
$order->origin = OrderModel::ORIGIN_ADMIN; | |||
$order->origin = Order::ORIGIN_ADMIN; | |||
$order->comment = $comment; | |||
$order->status = 'tmp-order'; | |||
@@ -843,7 +843,7 @@ class OrderController extends BackendController | |||
$order->id_user = $idUser; | |||
// commentaire du point de vente | |||
$userPointSale = UserPointSaleModel::searchOne([ | |||
$userPointSale = UserPointSale::searchOne([ | |||
'id_point_sale' => $idPointSale, | |||
'id_user' => $idUser | |||
]); | |||
@@ -862,15 +862,15 @@ class OrderController extends BackendController | |||
$userProducer = false; | |||
if (isset($order->user) && $order->user) { | |||
$user = $order->user; | |||
$userProducer = UserProducerModel::searchOne([ | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $user->id, | |||
'id_producer' => $order->distribution->id_producer | |||
]); | |||
} | |||
foreach ($products as $key => $dataProductOrder) { | |||
$product = ProductModel::findOne($key); | |||
$quantity = $dataProductOrder->quantity / ProductModel::$unitsArray[$dataProductOrder->unit]['coefficient']; | |||
$product = Product::findOne($key); | |||
$quantity = $dataProductOrder->quantity / Product::$unitsArray[$dataProductOrder->unit]['coefficient']; | |||
if ($product && $quantity) { | |||
$productOrder = new ProductOrder; | |||
$productOrder->id_order = $order->id; | |||
@@ -893,7 +893,7 @@ class OrderController extends BackendController | |||
} | |||
} | |||
$order = OrderModel::searchOne(['id' => $order->id]); | |||
$order = Order::searchOne(['id' => $order->id]); | |||
if ($order && $processCredit) { | |||
$order->processCredit(); | |||
} | |||
@@ -936,7 +936,7 @@ class OrderController extends BackendController | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$order = OrderModel::searchOne(['id' => $idOrder]); | |||
$order = Order::searchOne(['id' => $idOrder]); | |||
if ($order && | |||
$order->distribution->id_producer == GlobalParam::getCurrentProducerId()) { | |||
@@ -947,7 +947,7 @@ class OrderController extends BackendController | |||
$order->id_user = $idUser; | |||
// commentaire du point de vente | |||
$userPointSale = UserPointSaleModel::searchOne([ | |||
$userPointSale = UserPointSale::searchOne([ | |||
'id_point_sale' => $order->id_point_sale, | |||
'id_user' => $idUser | |||
]); | |||
@@ -960,10 +960,10 @@ class OrderController extends BackendController | |||
$order->id_user = 0; | |||
} | |||
$user = UserModel::searchOne(['id' => $order->id_user]); | |||
$user = User::searchOne(['id' => $order->id_user]); | |||
$userProducer = false; | |||
if ($user) { | |||
$userProducer = UserProducerModel::searchOne([ | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $user->id, | |||
'id_producer' => $order->distribution->id_producer | |||
]); | |||
@@ -971,20 +971,20 @@ class OrderController extends BackendController | |||
$products = json_decode($products); | |||
foreach ($products as $key => $dataProductOrder) { | |||
$productOrder = ProductOrderModel::findOne([ | |||
$productOrder = ProductOrder::findOne([ | |||
'id_order' => $idOrder, | |||
'id_product' => $key | |||
]); | |||
$quantity = $dataProductOrder->quantity | |||
/ ProductModel::$unitsArray[$dataProductOrder->unit]['coefficient']; | |||
/ Product::$unitsArray[$dataProductOrder->unit]['coefficient']; | |||
if ($quantity) { | |||
if ($productOrder) { | |||
$productOrder->quantity = $quantity; | |||
$productOrder->price = $dataProductOrder->price; | |||
} else { | |||
$product = ProductModel::findOne($key); | |||
$product = Product::findOne($key); | |||
if ($product) { | |||
$productOrder = new ProductOrder; | |||
@@ -1023,19 +1023,19 @@ class OrderController extends BackendController | |||
$order->save(); | |||
$order = OrderModel::searchOne(['id' => $order->id]); | |||
$order = Order::searchOne(['id' => $order->id]); | |||
if ($order && $processCredit) { | |||
// Si changement d'user : on rembourse l'ancien user | |||
$amountPaid = $order->getAmount(OrderModel::AMOUNT_PAID); | |||
$amountPaid = $order->getAmount(Order::AMOUNT_PAID); | |||
if($oldIdUser != $idUser && $amountPaid > 0) { | |||
$order->saveCreditHistory( | |||
CreditHistoryModel::TYPE_REFUND, | |||
CreditHistory::TYPE_REFUND, | |||
$amountPaid, | |||
GlobalParam::getCurrentProducerId(), | |||
$oldIdUser, | |||
UserModel::getCurrentId() | |||
User::getCurrentId() | |||
); | |||
$order = OrderModel::searchOne(['id' => $order->id]); | |||
$order = Order::searchOne(['id' => $order->id]); | |||
} | |||
$order->processCredit(); | |||
@@ -1052,24 +1052,24 @@ class OrderController extends BackendController | |||
public function actionPaymentStatus($idOrder) | |||
{ | |||
$creditHistoryService = \Yii::$app->logic->getCreditHistoryContainer()->getService(); | |||
$order = OrderModel::searchOne(['id' => $idOrder]); | |||
$order = Order::searchOne(['id' => $idOrder]); | |||
if ($order) { | |||
$html = ''; | |||
if ($order->id_user) { | |||
$userProducer = UserProducerModel::find() | |||
$userProducer = UserProducer::find() | |||
->where([ | |||
'id_user' => $order->id_user, | |||
'id_producer' => $order->distribution->id_producer | |||
]) | |||
->one(); | |||
$amountPaid = $order->getAmount(OrderModel::AMOUNT_PAID); | |||
$amountPaid = $order->getAmount(Order::AMOUNT_PAID); | |||
if (abs($order->amount - $amountPaid) < 0.0001) { | |||
$html .= '<span class="label label-success">Payé</span>'; | |||
$buttonsCredit = Html::a('Rembourser ' . $order->getAmountWithTax(OrderModel::AMOUNT_TOTAL, true), 'javascript:void(0);', ['class' => 'btn btn-default btn-xs rembourser', 'data-montant' => $order->amount, 'data-type' => 'refund']); | |||
$buttonsCredit = Html::a('Rembourser ' . $order->getAmountWithTax(Order::AMOUNT_TOTAL, true), 'javascript:void(0);', ['class' => 'btn btn-default btn-xs rembourser', 'data-montant' => $order->amount, 'data-type' => 'refund']); | |||
} elseif ($order->amount > $amountPaid) { | |||
$amountToPay = $order->amount - $amountPaid; | |||
$html .= '<span class="label label-danger">Non payé</span> reste <strong>' . number_format($amountToPay, 2) . ' €</strong> à payer'; | |||
@@ -1086,7 +1086,7 @@ class OrderController extends BackendController | |||
. '</span>'; | |||
// historique | |||
$history = CreditHistoryModel::find() | |||
$history = CreditHistory::find() | |||
->with('userAction') | |||
->where(['id_order' => $idOrder]) | |||
->all(); | |||
@@ -1101,8 +1101,8 @@ class OrderController extends BackendController | |||
. '<td>' . date('d/m/Y H:i:s', strtotime($creditHistoryService->getDate($creditHistory))) . '</td>' | |||
. '<td>' . Html::encode($creditHistoryService->getStrUserAction($creditHistory)) . '</td>' | |||
. '<td>' . $creditHistoryService->getStrWording($creditHistory) . '</td>' | |||
. '<td>' . ($creditHistoryService->isTypeDebit($creditHistory) ? '- ' . $creditHistoryService->getAmountWithTax($creditHistory, OrderModel::AMOUNT_TOTAL, true) : '') . '</td>' | |||
. '<td>' . ($creditHistoryService->isTypeCredit($creditHistory) ? '+ ' . $creditHistoryService->getAmountWithTax($creditHistory, OrderModel::AMOUNT_TOTAL, true) : '') . '</td>' | |||
. '<td>' . ($creditHistoryService->isTypeDebit($creditHistory) ? '- ' . $creditHistoryService->getAmountWithTax($creditHistory, Order::AMOUNT_TOTAL, true) : '') . '</td>' | |||
. '<td>' . ($creditHistoryService->isTypeCredit($creditHistory) ? '+ ' . $creditHistoryService->getAmountWithTax($creditHistory, Order::AMOUNT_TOTAL, true) : '') . '</td>' | |||
. '</tr>'; | |||
} | |||
} else { | |||
@@ -1135,7 +1135,7 @@ class OrderController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$order = OrderModel::searchOne([ | |||
$order = Order::searchOne([ | |||
'id' => $idOrder | |||
]); | |||
@@ -1145,7 +1145,7 @@ class OrderController extends BackendController | |||
$amount, | |||
GlobalParam::getCurrentProducerId(), | |||
$order->id_user, | |||
UserModel::getCurrentId() | |||
User::getCurrentId() | |||
); | |||
} | |||
@@ -1163,7 +1163,7 @@ class OrderController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$order = OrderModel::searchOne([ | |||
$order = Order::searchOne([ | |||
'id' => (int)$idOrder | |||
]); | |||
@@ -65,7 +65,7 @@ class PointSaleController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend(); | |||
return User::hasAccessBackend(); | |||
} | |||
], | |||
], | |||
@@ -118,7 +118,7 @@ class PointSaleController extends BackendController | |||
*/ | |||
public function actionUpdate($id) | |||
{ | |||
$model = PointSaleModel::find() | |||
$model = PointSale::find() | |||
->with('userPointSale') | |||
->where(['id' => $id]) | |||
->one(); | |||
@@ -149,7 +149,7 @@ class PointSaleController extends BackendController | |||
*/ | |||
public function initForm($id = 0) | |||
{ | |||
$users = UserModel::findBy() | |||
$users = User::findBy() | |||
->leftJoin('user_point_sale', 'user_point_sale.id_user = user.id AND user_point_sale.id_point_sale = :id_point_sale',[':id_point_sale' => $id]) | |||
->orderBy('user_point_sale.id_point_sale DESC, lastname ASC, name ASC') | |||
->all(); | |||
@@ -174,16 +174,16 @@ class PointSaleController extends BackendController | |||
$pointSale->save(); | |||
// Suppression du lien entre les utilisateurs et le point de vente | |||
UserPointSaleModel::deleteAll(['id_point_sale' => $id]); | |||
UserPointSale::deleteAll(['id_point_sale' => $id]); | |||
// Suppression du lien PointSaleDistribution pour toutes les distributions à venir | |||
$incomingDistributions = DistributionModel::getIncomingDistributions(); | |||
$incomingDistributions = DistributionModel::getIncoming(); | |||
foreach ($incomingDistributions as $distribution) { | |||
PointSaleDistributionModel::deleteAll(['id_point_sale' => $id, 'id_distribution' => $distribution->id]); | |||
} | |||
// Suppression de toutes les commandes à venir de ce point de vente | |||
$ordersArray = OrderModel::searchAll( | |||
$ordersArray = Order::searchAll( | |||
[ | |||
'id_point_sale' => $id, | |||
], | |||
@@ -218,7 +218,7 @@ class PointSaleController extends BackendController | |||
{ | |||
$pointSale = $this->findModel($id) ; | |||
if($pointSale) { | |||
PointSaleModel::updateAll(['default' => 0], 'id_producer = :id_producer', [':id_producer' => GlobalParam::getCurrentProducerId()]) ; | |||
PointSale::updateAll(['default' => 0], 'id_producer = :id_producer', [':id_producer' => GlobalParam::getCurrentProducerId()]) ; | |||
if(!$pointSale->default) { | |||
$pointSale->default = 1 ; | |||
$pointSale->save() ; | |||
@@ -241,7 +241,7 @@ class PointSaleController extends BackendController | |||
*/ | |||
protected function findModel($id) | |||
{ | |||
if (($model = PointSaleModel::findOne($id)) !== null) { | |||
if (($model = PointSale::findOne($id)) !== null) { | |||
return $model; | |||
} | |||
else { |
@@ -40,7 +40,7 @@ namespace backend\controllers; | |||
use common\helpers\GlobalParam; | |||
use Yii; | |||
use common\models\UserModel; | |||
use common\models\ User; | |||
use yii\web\NotFoundHttpException; | |||
use yii\filters\VerbFilter; | |||
use yii\filters\AccessControl; | |||
@@ -74,7 +74,7 @@ class ProducerAdminController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::getCurrentStatus() == UserModel::STATUS_ADMIN; | |||
return User::getCurrentStatus() == User::STATUS_ADMIN; | |||
} | |||
] | |||
], | |||
@@ -90,7 +90,7 @@ class ProducerAdminController extends BackendController | |||
public function actionIndex() | |||
{ | |||
$dataProviderProducer = new ActiveDataProvider([ | |||
'query' => ProducerModel::find() | |||
'query' => Producer::find() | |||
->with('userProducer', 'user') | |||
->orderBy('active DESC, free_price DESC'), | |||
'pagination' => [ | |||
@@ -98,7 +98,7 @@ class ProducerAdminController extends BackendController | |||
], | |||
]); | |||
$producersArray = ProducerModel::find()->where('active = 1')->all(); | |||
$producersArray = Producer::find()->where('active = 1')->all(); | |||
$sumPrices = 0; | |||
foreach($producersArray as $producer) { | |||
@@ -154,21 +154,21 @@ class ProducerAdminController extends BackendController | |||
$fromProducerId = (int) $fromProducerId; | |||
$toProducerId = (int) $toProducerId; | |||
$count = 0; | |||
$usersArray = UserModel::findBy(['id_producer' => $fromProducerId])->all(); | |||
$usersArray = User::findBy(['id_producer' => $fromProducerId])->all(); | |||
foreach($usersArray as $user) { | |||
$idUser = $user['user_id']; | |||
$countOrders = 0; | |||
if($withOrders) { | |||
$countOrders = OrderModel::searchCount([ | |||
$countOrders = Order::searchCount([ | |||
'id_user' => $idUser, | |||
'distribution.id_producer' => $fromProducerId | |||
], ['conditions' => 'date_delete IS NULL']); | |||
} | |||
if(($withOrders && $countOrders) || !$withOrders) { | |||
ProducerModel::addUser($idUser, $toProducerId); | |||
Producer::addUser($idUser, $toProducerId); | |||
$count ++; | |||
} | |||
} | |||
@@ -190,12 +190,12 @@ class ProducerAdminController extends BackendController | |||
*/ | |||
public function actionBill($idProducer) | |||
{ | |||
$producer = ProducerModel::findOne($idProducer); | |||
$producer = Producer::findOne($idProducer); | |||
if ($producer) { | |||
$period = date('Y-m', strtotime('-1 month')); | |||
$last_invoice = InvoiceModel::getLastInvoice() ; | |||
$last_invoice = Invoice::getLastInvoice() ; | |||
if (!$last_invoice) { | |||
$reference = 'BAP000001'; | |||
} else { | |||
@@ -229,7 +229,7 @@ class ProducerAdminController extends BackendController | |||
public function actionBilling() | |||
{ | |||
$dataProviderInvoice = new ActiveDataProvider([ | |||
'query' => InvoiceModel::find() | |||
'query' => Invoice::find() | |||
->with('producer') | |||
->orderBy('reference DESC'), | |||
'pagination' => [ | |||
@@ -245,7 +245,7 @@ class ProducerAdminController extends BackendController | |||
public function actionProducerInstallTaxUpdatePrices($idProducer) | |||
{ | |||
// product | |||
$productsArray = ProductModel::searchAll([ | |||
$productsArray = Product::searchAll([ | |||
'id_producer' => $idProducer | |||
]) ; | |||
@@ -280,7 +280,7 @@ class ProducerAdminController extends BackendController | |||
* @throws NotFoundHttpException | |||
*/ | |||
protected function findModel($id) { | |||
if (($model = ProducerModel::findOne($id)) !== null) { | |||
if (($model = Producer::findOne($id)) !== null) { | |||
return $model; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); |
@@ -70,7 +70,7 @@ class ProducerController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend(); | |||
return User::hasAccessBackend(); | |||
} | |||
] | |||
], | |||
@@ -157,7 +157,7 @@ class ProducerController extends BackendController | |||
public function actionBilling() | |||
{ | |||
$datasInvoices = new ActiveDataProvider([ | |||
'query' => InvoiceModel::find() | |||
'query' => Invoice::find() | |||
->where(['id_producer' => GlobalParam::getCurrentProducerId()]) | |||
->orderBy('reference DESC'), | |||
'pagination' => [ | |||
@@ -165,7 +165,7 @@ class ProducerController extends BackendController | |||
], | |||
]); | |||
$producer = ProducerModel::findOne(GlobalParam::getCurrentProducerId()); | |||
$producer = Producer::findOne(GlobalParam::getCurrentProducerId()); | |||
if ($producer->load(Yii::$app->request->post())) { | |||
$producer->save(); | |||
@@ -176,7 +176,7 @@ class ProducerController extends BackendController | |||
} | |||
$dataProviderPrices = new ActiveDataProvider([ | |||
'query' => ProducerPriceRangeModel::find() | |||
'query' => ProducerPriceRange::find() | |||
->orderBy('id ASC'), | |||
'pagination' => [ | |||
'pageSize' => 100, | |||
@@ -200,7 +200,7 @@ class ProducerController extends BackendController | |||
*/ | |||
protected function findModel($id) | |||
{ | |||
if (($model = ProducerModel::findOne($id)) !== null) { | |||
if (($model = Producer::findOne($id)) !== null) { | |||
return $model; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); |
@@ -65,7 +65,7 @@ class ProducerPriceRangeAdminController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::getCurrentStatus() == UserModel::STATUS_ADMIN; | |||
return User::getCurrentStatus() == User::STATUS_ADMIN; | |||
} | |||
] | |||
], | |||
@@ -81,7 +81,7 @@ class ProducerPriceRangeAdminController extends BackendController | |||
public function actionIndex() | |||
{ | |||
$dataProvider = new ActiveDataProvider([ | |||
'query' => ProducerPriceRangeModel::find()->orderBy('range_begin ASC') | |||
'query' => ProducerPriceRange::find()->orderBy('range_begin ASC') | |||
]); | |||
return $this->render('index', [ | |||
@@ -134,7 +134,7 @@ class ProducerPriceRangeAdminController extends BackendController | |||
*/ | |||
public function actionDelete($id) | |||
{ | |||
$producerPriceRange = ProducerPriceRangeModel::searchOne([ | |||
$producerPriceRange = ProducerPriceRange::searchOne([ | |||
'id' => $id | |||
]) ; | |||
$producerPriceRange->delete(); | |||
@@ -152,7 +152,7 @@ class ProducerPriceRangeAdminController extends BackendController | |||
*/ | |||
protected function findModel($id) | |||
{ | |||
if (($model = ProducerPriceRangeModel::findOne($id)) !== null) { | |||
if (($model = ProducerPriceRange::findOne($id)) !== null) { | |||
return $model; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); |
@@ -65,7 +65,7 @@ class ProductCategoryController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend(); | |||
return User::hasAccessBackend(); | |||
} | |||
], | |||
], | |||
@@ -143,7 +143,7 @@ class ProductCategoryController extends BackendController | |||
$productCategory = $this->findModel($id); | |||
$productCategory->delete(); | |||
ProductModel::updateAll(['id_product_category' => null], ['id_product_category' => $id]); | |||
Product::updateAll(['id_product_category' => null], ['id_product_category' => $id]); | |||
Yii::$app->getSession()->setFlash('success', 'Catégorie <strong>' . Html::encode($productCategory->name) . '</strong> supprimée.'); | |||
return $this->redirect(['index']); | |||
@@ -175,7 +175,7 @@ class ProductCategoryController extends BackendController | |||
*/ | |||
protected function findModel($id) | |||
{ | |||
if (($model = ProductCategoryModel::findOne($id)) !== null) { | |||
if (($model = ProductCategory::findOne($id)) !== null) { | |||
return $model; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); |
@@ -43,13 +43,13 @@ use common\models\ProductDistribution; | |||
use common\models\ProductPrice; | |||
use common\models\ProductPriceSearch; | |||
use common\models\ProductSearch; | |||
use common\models\UserModelSearch; | |||
use common\models\ UserSearch; | |||
use Yii; | |||
use yii\filters\AccessControl; | |||
use common\models\Product; | |||
use common\models\Distribution; | |||
use common\models\UserModel; | |||
use common\logic\UserProducer\UserProducerModel; | |||
use common\models\ User; | |||
use common\logic\UserProducer\ UserProducer; | |||
use yii\data\ActiveDataProvider; | |||
use yii\web\Controller; | |||
use yii\web\NotFoundHttpException; | |||
@@ -79,7 +79,7 @@ class ProductController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend(); | |||
return User::hasAccessBackend(); | |||
} | |||
] | |||
], | |||
@@ -126,7 +126,7 @@ class ProductController extends BackendController | |||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | |||
$lastProductOrder = ProductModel::find()->where('id_producer = :id_producer')->params([':id_producer' => GlobalParam::getCurrentProducerId()])->orderBy('order DESC')->one(); | |||
$lastProductOrder = Product::find()->where('id_producer = :id_producer')->params([':id_producer' => GlobalParam::getCurrentProducerId()])->orderBy('order DESC')->one(); | |||
if ($lastProductOrder) { | |||
$model->order = ++$lastProductOrder->order; | |||
} | |||
@@ -202,11 +202,11 @@ class ProductController extends BackendController | |||
*/ | |||
public function processAvailabilityPointsSale($model) | |||
{ | |||
ProductPointSaleModel::deleteAll(['id_product' => $model->id]); | |||
ProductPointSale::deleteAll(['id_product' => $model->id]); | |||
if (is_array($model->pointsSale) && count($model->pointsSale)) { | |||
foreach ($model->pointsSale as $key => $val) { | |||
$pointSale = PointSaleModel::findOne($val); | |||
$pointSale = PointSale::findOne($val); | |||
if ($pointSale) { | |||
$productPointSale = new ProductPointSale; | |||
$productPointSale->id_product = $model->id; | |||
@@ -230,12 +230,12 @@ class ProductController extends BackendController | |||
'id_product' => $id | |||
])); | |||
$userProducerWithProductPercent = UserProducerModel::searchAll([], [ | |||
$userProducerWithProductPercent = UserProducer::searchAll([], [ | |||
'join_with' => ['user'], | |||
'conditions' => 'user_producer.product_price_percent != 0', | |||
]); | |||
$pointSaleWithProductPercent = PointSaleModel::searchAll([], [ | |||
$pointSaleWithProductPercent = PointSale::searchAll([], [ | |||
'conditions' => 'point_sale.product_price_percent != 0' | |||
]); | |||
@@ -265,7 +265,7 @@ class ProductController extends BackendController | |||
'from_quantity' => $model->from_quantity ? $model->from_quantity : null, | |||
]; | |||
$productPriceExist = ProductPriceModel::findOne($conditionsProductPriceExist); | |||
$productPriceExist = ProductPrice::findOne($conditionsProductPriceExist); | |||
if ($productPriceExist) { | |||
$productPriceExist->delete(); | |||
@@ -373,7 +373,7 @@ class ProductController extends BackendController | |||
*/ | |||
protected function findModel($id) | |||
{ | |||
if (($model = ProductModel::findOne($id)) !== null) { | |||
if (($model = Product::findOne($id)) !== null) { | |||
return $model; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); | |||
@@ -382,7 +382,7 @@ class ProductController extends BackendController | |||
protected function findModelProductPrice($id) | |||
{ | |||
if (($model = ProductPriceModel::findOne($id)) !== null) { | |||
if (($model = ProductPrice::findOne($id)) !== null) { | |||
return $model; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); |
@@ -60,7 +60,7 @@ class QuotationController extends DocumentController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend(); | |||
return User::hasAccessBackend(); | |||
} | |||
] | |||
], | |||
@@ -98,7 +98,7 @@ class QuotationController extends DocumentController | |||
$invoice->name = str_replace(['Devis', 'devis'], 'Facture', $quotation->name); | |||
$invoice->save() ; | |||
OrderModel::updateAll([ | |||
Order::updateAll([ | |||
'order.id_invoice' => $invoice->id | |||
], [ | |||
'order.id_quotation' => $id |
@@ -56,7 +56,7 @@ class ReportController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend() ; | |||
return User::hasAccessBackend() ; | |||
} | |||
] | |||
], | |||
@@ -74,8 +74,8 @@ class ReportController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$usersArray = UserModel::findBy()->all() ; | |||
$pointsSaleArray = PointSaleModel::searchAll() ; | |||
$usersArray = User::findBy()->all() ; | |||
$pointsSaleArray = PointSale::searchAll() ; | |||
// distributions | |||
$firstDistribution = DistributionModel::searchOne([], [ |
@@ -68,7 +68,7 @@ class SiteController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend() ; | |||
return User::hasAccessBackend() ; | |||
} | |||
], | |||
[ | |||
@@ -76,7 +76,7 @@ class SiteController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::getCurrentStatus() == UserModel::STATUS_ADMIN ; | |||
return User::getCurrentStatus() == User::STATUS_ADMIN ; | |||
} | |||
], | |||
], | |||
@@ -112,11 +112,11 @@ class SiteController extends BackendController | |||
{ | |||
// commandes | |||
$optionDashboardNumberDistributions = ProducerModel::getConfig('option_dashboard_number_distributions') ; | |||
$optionDashboardNumberDistributions = Producer::getConfig('option_dashboard_number_distributions') ; | |||
$dashboardNumberDistributions = $optionDashboardNumberDistributions ? $optionDashboardNumberDistributions : 3 ; | |||
$optionDashboardDateStart = ProducerModel::getConfig('option_dashboard_date_start') ; | |||
$optionDashboardDateEnd = ProducerModel::getConfig('option_dashboard_date_end') ; | |||
$optionDashboardDateStart = Producer::getConfig('option_dashboard_date_start') ; | |||
$optionDashboardDateEnd = Producer::getConfig('option_dashboard_date_end') ; | |||
$queryDistributions = DistributionModel::find()->with('order') ; | |||
@@ -162,27 +162,27 @@ class SiteController extends BackendController | |||
$paramsOrders[':date_start'] = date('Y-m-d 00:00:00') ; | |||
} | |||
$ordersArray = OrderModel::searchAll([],[ | |||
$ordersArray = Order::searchAll([],[ | |||
'orderby' => 'date DESC', | |||
'conditions' => $conditionsOrders.' AND (origin = \'' . OrderModel::ORIGIN_USER . '\' OR origin = \'' . OrderModel::ORIGIN_ADMIN . '\' OR (origin = \'' . OrderModel::ORIGIN_AUTO . '\' AND (date_update IS NOT NULL OR date_delete IS NOT NULL)))', | |||
'conditions' => $conditionsOrders.' AND (origin = \'' . Order::ORIGIN_USER . '\' OR origin = \'' . Order::ORIGIN_ADMIN . '\' OR (origin = \'' . Order::ORIGIN_AUTO . '\' AND (date_update IS NOT NULL OR date_delete IS NOT NULL)))', | |||
'params' => $paramsOrders, | |||
]); | |||
// clients | |||
$usersArray = UserModel::findBy() | |||
$usersArray = User::findBy() | |||
->orderBy('created_at DESC') | |||
->limit(5) | |||
->all(); | |||
$usersNegativeCredit = UserModel::findBy(['id_producer' => GlobalParam::getCurrentProducerId()]) | |||
$usersNegativeCredit = User::findBy(['id_producer' => GlobalParam::getCurrentProducerId()]) | |||
->andWhere('user_producer.credit < 0') | |||
->all(); | |||
// paramètres | |||
$producer = GlobalParam::getCurrentProducer(); | |||
$productsCount = ProductModel::searchCount() ; | |||
$pointsSaleCount = PointSaleModel::searchCount() ; | |||
$productsCount = Product::searchCount() ; | |||
$pointsSaleCount = PointSale::searchCount() ; | |||
return $this->render('index', [ | |||
'distributionsArray' => $distributionsArray, |
@@ -58,7 +58,7 @@ class StatsController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend() ; | |||
return User::hasAccessBackend() ; | |||
} | |||
] | |||
], | |||
@@ -142,7 +142,7 @@ class StatsController extends BackendController | |||
{ | |||
if(!$year) $year = date('Y') ; | |||
$productsArray = ProductModel::searchAll() ; | |||
$productsArray = Product::searchAll() ; | |||
$dataProducts = [] ; | |||
@@ -53,7 +53,7 @@ class SubscriptionController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend() ; | |||
return User::hasAccessBackend() ; | |||
} | |||
] | |||
], | |||
@@ -92,7 +92,7 @@ class SubscriptionController extends BackendController | |||
$model->id_producer = GlobalParam::getCurrentProducerId(); | |||
if($idOrder) { | |||
$order = OrderModel::searchOne(['id' => $idOrder]); | |||
$order = Order::searchOne(['id' => $idOrder]); | |||
if ($order) { | |||
$model->id_user = $order->id_user; | |||
$model->username = $order->username; | |||
@@ -101,7 +101,7 @@ class SubscriptionController extends BackendController | |||
$dateDay = strtolower(date('l',strtotime($order->distribution->date))) ; | |||
$model->$dateDay = 1 ; | |||
$model->week_frequency = 1 ; | |||
if($model->id_user && ProducerModel::getConfig('credit')) { | |||
if($model->id_user && Producer::getConfig('credit')) { | |||
$model->auto_payment = 1 ; | |||
} | |||
@@ -115,7 +115,7 @@ class SubscriptionController extends BackendController | |||
} | |||
// produits | |||
$productsArray = ProductModel::searchAll([], [ | |||
$productsArray = Product::searchAll([], [ | |||
'orderby' => 'product.order ASC' | |||
]) ; | |||
@@ -124,7 +124,7 @@ class SubscriptionController extends BackendController | |||
{ | |||
Yii::$app->getSession()->setFlash('success', 'Abonnement ajouté'); | |||
$subscription = SubscriptionModel::findOne($model->id) ; | |||
$subscription = Subscription::findOne($model->id) ; | |||
$matchedDistributionsArray = $subscription->searchMatchedIncomingDistributions() ; | |||
if(count($matchedDistributionsArray)) { | |||
return $this->redirect(['subscription/update-distributions', 'idSubscription' => $subscription->id]); | |||
@@ -152,7 +152,7 @@ class SubscriptionController extends BackendController | |||
// form | |||
$model = new SubscriptionForm; | |||
$model->isAdmin = true ; | |||
$subscription = SubscriptionModel::findOne($id); | |||
$subscription = Subscription::findOne($id); | |||
if ($subscription) { | |||
$model->id = $id; | |||
@@ -180,7 +180,7 @@ class SubscriptionController extends BackendController | |||
} | |||
// produits | |||
$arrayProductsSubscription = ProductSubscriptionModel::searchAll([ | |||
$arrayProductsSubscription = ProductSubscription::searchAll([ | |||
'id_subscription' => $model->id | |||
]) ; | |||
@@ -192,7 +192,7 @@ class SubscriptionController extends BackendController | |||
} | |||
// produits | |||
$productsArray = ProductModel::searchAll([], [ | |||
$productsArray = Product::searchAll([], [ | |||
'orderby' => 'product.order ASC' | |||
]) ; | |||
@@ -204,7 +204,7 @@ class SubscriptionController extends BackendController | |||
if ($model->save()) { | |||
$subscription = SubscriptionModel::findOne($model->id) ; | |||
$subscription = Subscription::findOne($model->id) ; | |||
$messageOrdersDeleted = ''; | |||
if($model->date_end) { | |||
@@ -240,19 +240,19 @@ class SubscriptionController extends BackendController | |||
*/ | |||
public function actionDelete($id) | |||
{ | |||
$subscription = SubscriptionModel::searchOne([ | |||
$subscription = Subscription::searchOne([ | |||
'subscription.id' => $id | |||
]) ; | |||
$subscription->deleteOrdersIncomingDistributions() ; | |||
$subscription->delete(); | |||
ProductSubscriptionModel::deleteAll(['id_subscription' => $id]); | |||
ProductSubscription::deleteAll(['id_subscription' => $id]); | |||
Yii::$app->getSession()->setFlash('success', 'Abonnement supprimé'); | |||
return $this->redirect(['subscription/index']); | |||
} | |||
public function actionUpdateDistributions($idSubscription, $generate = false, $update = false) | |||
{ | |||
$subscription = SubscriptionModel::findOne($idSubscription) ; | |||
$subscription = Subscription::findOne($idSubscription) ; | |||
$matchedDistributionsArray = $subscription->searchMatchedIncomingDistributions() ; | |||
if($generate) { | |||
@@ -277,7 +277,7 @@ class SubscriptionController extends BackendController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$productsQuery = ProductModel::find() | |||
$productsQuery = Product::find() | |||
->where(['id_producer' => GlobalParam::getCurrentProducerId(),]) ; | |||
if($idSubscription) { | |||
@@ -298,13 +298,13 @@ class SubscriptionController extends BackendController | |||
'price' => $theProduct['price'] | |||
] ;*/ | |||
$theProduct['wording_unit'] = ProductModel::strUnit($theProduct['unit'], 'wording_short'); | |||
$theProduct['wording_unit'] = Product::strUnit($theProduct['unit'], 'wording_short'); | |||
if(isset($theProduct['productSubscription'][0])) { | |||
/*if($theProduct['productSubscription'][0]['unit'] != $theProduct['unit']) { | |||
$theProduct['units'][] = [ | |||
'unit' => $theProduct['productSubscription'][0]['unit'], | |||
'wording_unit' => ProductModel::strUnit($theProduct['productSubscription'][0]['unit'], 'wording_short'), | |||
'wording_unit' => Product::strUnit($theProduct['productSubscription'][0]['unit'], 'wording_short'), | |||
'step' => $theProduct['productSubscription'][0]['step'], | |||
'price' => $theProduct['productSubscription'][0]['price'], | |||
] ; | |||
@@ -312,7 +312,7 @@ class SubscriptionController extends BackendController | |||
$theProduct['step'] = $theProduct['productSubscription'][0]['step'] ; | |||
$theProduct['price'] = $theProduct['productSubscription'][0]['price'] ; | |||
}*/ | |||
$theProduct['quantity'] = $theProduct['productSubscription'][0]['quantity'] * ProductModel::$unitsArray[$theProduct['unit']]['coefficient'] ; | |||
$theProduct['quantity'] = $theProduct['productSubscription'][0]['quantity'] * Product::$unitsArray[$theProduct['unit']]['coefficient'] ; | |||
} | |||
else { | |||
$theProduct['quantity'] = '' ; |
@@ -41,15 +41,24 @@ namespace backend\controllers; | |||
use backend\models\CreditForm; | |||
use common\helpers\GlobalParam; | |||
use common\helpers\Mailjet; | |||
use common\models\UserModel; | |||
use common\models\Producer; | |||
use common\models\Distribution; | |||
use backend\models\MailForm; | |||
use common\models\UserGroup; | |||
use common\logic\UserProducer\UserProducerModel; | |||
use common\models\UserPointSale; | |||
use common\models\PointSale; | |||
use common\models\UserUserGroup; | |||
use common\helpers\Password; | |||
use common\logic\Distribution\Distribution\Distribution; | |||
use common\logic\Order\Order\OrderSearch; | |||
use common\logic\PointSale\PointSale\PointSale; | |||
use common\logic\PointSale\UserPointSale\UserPointSale; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\logic\User\CreditHistory\CreditHistory; | |||
use common\logic\User\User\UserSearch; | |||
use common\logic\User\UserGroup\UserGroup; | |||
use common\logic\User\UserGroup\UserUserGroup; | |||
use common\logic\User\UserProducer\UserProducer; | |||
use yii\base\UserException; | |||
use yii\debug\models\search\User; | |||
use yii\filters\AccessControl; | |||
use yii\filters\VerbFilter; | |||
use \Yii; | |||
use yii\web\NotFoundHttpException; | |||
/** | |||
* UserController implements the CRUD actions for User model. | |||
@@ -61,18 +70,18 @@ class UserController extends BackendController | |||
{ | |||
return [ | |||
'verbs' => [ | |||
'class' => VerbFilter::className(), | |||
'class' => VerbFilter::class, | |||
'actions' => [ | |||
], | |||
], | |||
'access' => [ | |||
'class' => AccessControl::className(), | |||
'class' => AccessControl::class, | |||
'rules' => [ | |||
[ | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend(); | |||
return $this->isUserCurrentAdmin(); | |||
} | |||
] | |||
], | |||
@@ -88,7 +97,7 @@ class UserController extends BackendController | |||
public function actionIndex( | |||
$idPointSale = 0, $sectionSubscribers = false, $sectionInactiveUsers = false) | |||
{ | |||
$searchModel = new UserSearch; | |||
$searchModel = new UserSearch(); | |||
$dataProvider = $searchModel->search([ | |||
'UserSearch' => array_merge( | |||
[ | |||
@@ -102,11 +111,11 @@ class UserController extends BackendController | |||
) | |||
]); | |||
$producer = ProducerModel::searchOne([ | |||
$producer = Producer::searchOne([ | |||
'id' => GlobalParam::getCurrentProducerId() | |||
]); | |||
$pointsSaleArray = PointSaleModel::searchAll(); | |||
$pointsSaleArray = PointSale::searchAll(); | |||
return $this->render('index', [ | |||
'searchModel' => $searchModel, | |||
@@ -124,7 +133,7 @@ class UserController extends BackendController | |||
if ($model->id) { | |||
// init points de vente sélectionnés | |||
$userPointSaleArray = UserPointSaleModel::searchAll([ | |||
$userPointSaleArray = UserPointSale::searchAll([ | |||
'id_user' => $model->id | |||
]); | |||
if ($userPointSaleArray && count($userPointSaleArray) > 0) { | |||
@@ -134,7 +143,7 @@ class UserController extends BackendController | |||
} | |||
// init groupes d'utilisateurs sélectionnés | |||
$userUserGroupsArray = UserUserGroupModel::searchAll([ | |||
$userUserGroupsArray = UserUserGroup::searchAll([ | |||
'id_user' => $model->id | |||
]); | |||
if ($userUserGroupsArray && count($userUserGroupsArray) > 0) { | |||
@@ -144,7 +153,7 @@ class UserController extends BackendController | |||
} | |||
// product price percent | |||
$userProducer = UserProducerModel::searchOne([ | |||
$userProducer = UserProducer::searchOne([ | |||
'id_producer' => GlobalParam::getCurrentProducerId(), | |||
'id_user' => $model->id | |||
]); | |||
@@ -152,7 +161,7 @@ class UserController extends BackendController | |||
} | |||
// points de vente | |||
$pointsSaleArray = PointSaleModel::find() | |||
$pointsSaleArray = PointSale::find() | |||
->where([ | |||
'id_producer' => GlobalParam::getCurrentProducerId(), | |||
'status' => 1 | |||
@@ -165,7 +174,7 @@ class UserController extends BackendController | |||
->all(); | |||
// groupes d'utilisateurs | |||
$userGroupsArray = UserGroupModel::find() | |||
$userGroupsArray = UserGroup::find() | |||
->where([ | |||
'id_producer' => GlobalParam::getCurrentProducerId(), | |||
]) | |||
@@ -184,19 +193,19 @@ class UserController extends BackendController | |||
*/ | |||
public function actionCreate() | |||
{ | |||
$model = new UserModel(); | |||
$model = new User(); | |||
$userExist = false; | |||
$posts = Yii::$app->request->post(); | |||
if ($posts && isset($posts['User']['email']) && strlen($posts['User']['email']) > 0) { | |||
$userExist = UserModel::searchOne([ | |||
$userExist = User::searchOne([ | |||
'email' => $posts['User']['email'] | |||
]); | |||
} | |||
if ($userExist) { | |||
ProducerModel::addUser($userExist->id, GlobalParam::getCurrentProducerId()); | |||
Producer::addUser($userExist->id, GlobalParam::getCurrentProducerId()); | |||
$this->processLinkPointSale($userExist); | |||
$this->processLinkUserGroup($userExist); | |||
Yii::$app->getSession()->setFlash('success', "L'utilisateur que vous souhaitez créer possède déjà un compte sur la plateforme. Il vient d'être lié à votre établissement."); | |||
@@ -215,7 +224,7 @@ class UserController extends BackendController | |||
$model->save(); | |||
// liaison etablissement / user | |||
$useProducer = new UserProducerModel(); | |||
$useProducer = new UserProducer(); | |||
$useProducer->id_user = $model->id; | |||
$useProducer->id_producer = GlobalParam::getCurrentProducerId(); | |||
$useProducer->credit = 0; | |||
@@ -228,7 +237,7 @@ class UserController extends BackendController | |||
$this->processProductPricePercent($model); | |||
Yii::$app->getSession()->setFlash('success', 'Utilisateur créé.'); | |||
$model = new UserModel(); | |||
$model = new User(); | |||
} | |||
} | |||
@@ -250,8 +259,8 @@ class UserController extends BackendController | |||
// Moodification du profil | |||
$previousMail = $model->email; | |||
$user = UserModel::find()->with('userProducer')->where(['id' => $model['id']])->one(); | |||
$userBelongToProducer = UserProducerModel::findOne(['id_user' => $id, 'id_producer' => GlobalParam::getCurrentProducerId()]); | |||
$user = User::find()->with('userProducer')->where(['id' => $model['id']])->one(); | |||
$userBelongToProducer = UserProducer::findOne(['id_user' => $id, 'id_producer' => GlobalParam::getCurrentProducerId()]); | |||
if ($userBelongToProducer) { | |||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | |||
@@ -306,17 +315,17 @@ class UserController extends BackendController | |||
/** | |||
* Lie un utilisateur aux points de vente sélectionnés. | |||
* | |||
* @param UserModel $modelUser | |||
* @param User $modelUser | |||
*/ | |||
public function processLinkPointSale($modelUser) | |||
{ | |||
$posts = Yii::$app->request->post(); | |||
UserPointSaleModel::deleteAll([ | |||
UserPointSale::deleteAll([ | |||
'id_user' => $modelUser->id | |||
]); | |||
if (is_array($modelUser->points_sale) && count($modelUser->points_sale) > 0) { | |||
foreach ($modelUser->points_sale as $pointSaleId) { | |||
$userPointSale = UserPointSaleModel::searchOne([ | |||
$userPointSale = UserPointSale::searchOne([ | |||
'id_user' => $modelUser->id, | |||
'id_point_sale' => $pointSaleId | |||
]); | |||
@@ -334,19 +343,19 @@ class UserController extends BackendController | |||
/** | |||
* Lie un utilisateur aux groupes d'utilisateurs sélectionnés. | |||
* | |||
* @param UserModel $modelUser | |||
* @param User $modelUser | |||
*/ | |||
public function processLinkUserGroup($modelUser) | |||
{ | |||
$posts = Yii::$app->request->post(); | |||
UserUserGroupModel::deleteAll([ | |||
UserUserGroup::deleteAll([ | |||
'id_user' => $modelUser->id | |||
]); | |||
if (is_array($modelUser->user_groups) && count($modelUser->user_groups) > 0) { | |||
foreach ($modelUser->user_groups as $userGroupId) { | |||
$userUserGroup = UserUserGroupModel::searchOne([ | |||
$userUserGroup = UserUserGroup::searchOne([ | |||
'id_user' => $modelUser->id, | |||
'id_user_group' => $userGroupId | |||
]); | |||
@@ -363,7 +372,7 @@ class UserController extends BackendController | |||
public function processProductPricePercent($model) | |||
{ | |||
$userProducer = UserProducerModel::searchOne([ | |||
$userProducer = UserProducer::searchOne([ | |||
'id_producer' => GlobalParam::getCurrentProducerId(), | |||
'id_user' => $model->id | |||
]); | |||
@@ -379,7 +388,7 @@ class UserController extends BackendController | |||
*/ | |||
public function actionDelete($id) | |||
{ | |||
$userProducer = UserProducerModel::findOne([ | |||
$userProducer = UserProducer::findOne([ | |||
'id_user' => $id, | |||
'id_producer' => GlobalParam::getCurrentProducerId() | |||
]); | |||
@@ -416,7 +425,7 @@ class UserController extends BackendController | |||
$usersPointSaleLink = 1; | |||
} | |||
$users = UserModel::findBy([ | |||
$users = User::findBy([ | |||
'id_producer' => GlobalParam::getCurrentProducerId(), | |||
'id_point_sale' => $idPointSale, | |||
'users_point_sale_link' => $usersPointSaleLink, | |||
@@ -431,11 +440,11 @@ class UserController extends BackendController | |||
$usersArray[] = $user['email']; | |||
} | |||
$pointsSaleArray = PointSaleModel::find()->where(['id_producer' => GlobalParam::getCurrentProducerId()])->all(); | |||
$pointsSaleArray = PointSale::find()->where(['id_producer' => GlobalParam::getCurrentProducerId()])->all(); | |||
$pointSale = null; | |||
if ($idPointSale) { | |||
$pointSale = PointSaleModel::findOne(['id' => $idPointSale]); | |||
$pointSale = PointSale::findOne(['id' => $idPointSale]); | |||
} | |||
$mailForm = new MailForm(); | |||
@@ -465,7 +474,7 @@ class UserController extends BackendController | |||
return $this->redirect(['mail', 'idPointSale' => $idPointSale]); | |||
} | |||
$incomingDistributions = DistributionModel::getIncomingDistributions(); | |||
$incomingDistributions = Distribution::getIncoming(); | |||
$incomingDistributionsArray = ['0' => '--']; | |||
foreach ($incomingDistributions as $distribution) { | |||
$incomingDistributionsArray[$distribution->id] = strftime('%A %d %B %Y', strtotime($distribution->date)); | |||
@@ -495,10 +504,10 @@ class UserController extends BackendController | |||
*/ | |||
public function actionCredit($id) | |||
{ | |||
$user = UserModel::find()->with('userProducer')->where(['id' => $id])->one(); | |||
$userProducer = UserProducerModel::findOne(['id_user' => $id, 'id_producer' => GlobalParam::getCurrentProducerId()]); | |||
$user = User::find()->with('userProducer')->where(['id' => $id])->one(); | |||
$userProducer = UserProducer::findOne(['id_user' => $id, 'id_producer' => GlobalParam::getCurrentProducerId()]); | |||
if (($userProducer) || UserModel::getCurrentStatus() == UserModel::STATUS_ADMIN) { | |||
if (($userProducer) || User::getCurrentStatus() == User::STATUS_ADMIN) { | |||
$creditForm = new CreditForm(); | |||
if ($creditForm->load(Yii::$app->request->post()) && $creditForm->validate()) { | |||
@@ -508,7 +517,7 @@ class UserController extends BackendController | |||
$creditForm = new CreditForm; | |||
} | |||
$history = CreditHistoryModel::find() | |||
$history = CreditHistory::find() | |||
->with(['order', 'userAction']) | |||
->where([ | |||
'id_user' => $user->id, | |||
@@ -536,8 +545,8 @@ class UserController extends BackendController | |||
*/ | |||
public function actionOrders($id) | |||
{ | |||
$user = UserModel::findOne($id); | |||
$searchModel = new OrderSearch; | |||
$user = User::findOne($id); | |||
$searchModel = new OrderSearch(); | |||
$dataProvider = $searchModel->search(array_merge(Yii::$app->request->queryParams, ['id_user' => $id])); | |||
return $this->render('orders', [ | |||
@@ -556,7 +565,7 @@ class UserController extends BackendController | |||
*/ | |||
public function actionStateCredit($idUser, $state) | |||
{ | |||
$userProducer = UserProducerModel::searchOne([ | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $idUser | |||
]); | |||
@@ -571,13 +580,10 @@ class UserController extends BackendController | |||
/** | |||
* Finds the User model based on its primary key value. | |||
* If the model is not found, a 404 HTTP exception will be thrown. | |||
* @param integer $id | |||
* @return UserModel the loaded model | |||
* @throws NotFoundHttpException if the model cannot be found | |||
*/ | |||
protected function findModel($id) | |||
{ | |||
if (($model = UserModel::findOne($id)) !== null) { | |||
if (($model = User::findOne($id)) !== null) { | |||
return $model; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); |
@@ -66,7 +66,7 @@ class UserGroupController extends BackendController | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return UserModel::hasAccessBackend(); | |||
return User::hasAccessBackend(); | |||
} | |||
], | |||
], | |||
@@ -144,7 +144,7 @@ class UserGroupController extends BackendController | |||
$userGroup = $this->findModel($id); | |||
$userGroup->delete(); | |||
UserUserGroupModel::deleteAll(['id_user_group' => $id]); | |||
User UserGroup::deleteAll(['id_user_group' => $id]); | |||
Yii::$app->getSession()->setFlash('success', 'Groupe d\'utilisateur <strong>' . Html::encode($userGroup->name) . '</strong> supprimé.'); | |||
return $this->redirect(['index']); | |||
@@ -159,7 +159,7 @@ class UserGroupController extends BackendController | |||
*/ | |||
protected function findModel($id) | |||
{ | |||
if (($model = UserGroupModel::findOne($id)) !== null) { | |||
if (($model = UserGroup::findOne($id)) !== null) { | |||
return $model; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); |
@@ -41,9 +41,9 @@ namespace backend\models; | |||
use common\helpers\GlobalParam; | |||
use Yii; | |||
use yii\base\Model; | |||
use common\models\UserModel ; | |||
use common\models\ User ; | |||
use common\models\Producer ; | |||
use common\logic\UserProducer\UserProducerModel ; | |||
use common\logic\UserProducer\ UserProducer ; | |||
/** | |||
* ContactForm is the model behind the contact form. | |||
@@ -76,14 +76,14 @@ class AccessUserProducerForm extends Model | |||
public function save() | |||
{ | |||
$user = UserModel::searchOne([ | |||
$user = User::searchOne([ | |||
'id' => $this->id_user | |||
]) ; | |||
if($user) { | |||
$user->id_producer = GlobalParam::getCurrentProducerId() ; | |||
if($user->status != UserModel::STATUS_PRODUCER && $user->status != UserModel::STATUS_ADMIN) { | |||
$user->status = UserModel::STATUS_PRODUCER ; | |||
if($user->status != User::STATUS_PRODUCER && $user->status != User::STATUS_ADMIN) { | |||
$user->status = User::STATUS_PRODUCER ; | |||
} | |||
return $user->save(); | |||
} |
@@ -43,9 +43,9 @@ use common\helpers\Mailjet; | |||
use Yii; | |||
use yii\base\Model; | |||
use common\models\CreditHistory ; | |||
use common\models\UserModel ; | |||
use common\models\ User ; | |||
use common\models\Producer ; | |||
use common\logic\UserProducer\UserProducerModel ; | |||
use common\logic\UserProducer\ UserProducer ; | |||
use common\helpers\Mail ; | |||
/** | |||
@@ -117,9 +117,9 @@ class CreditForm extends Model | |||
// on prévient l'utilisateur que son compte vient d'être crédité | |||
if($this->send_mail) { | |||
$user = UserModel::findOne($this->id_user) ; | |||
$user = User::findOne($this->id_user) ; | |||
$producer = GlobalParam::getCurrentProducer() ; | |||
$userProducer = UserProducerModel::searchOne([ | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $this->id_user | |||
]); | |||
@@ -116,7 +116,7 @@ class MailForm extends Model | |||
'.$linkOrder ; | |||
if($this->integrate_product_list) { | |||
$productsArray = ProductModel::find() | |||
$productsArray = Product::find() | |||
->where([ | |||
'id_producer' => GlobalParam::getCurrentProducerId(), | |||
]) | |||
@@ -143,7 +143,7 @@ Produits disponibles : | |||
} | |||
if($product->price) { | |||
$productDescription .= ' / '.Price::format($product->getPriceWithTax()) ; | |||
$productDescription .= ' ('.ProductModel::strUnit($product->unit, 'wording_unit').')' ; | |||
$productDescription .= ' ('. Product::strUnit($product->unit, 'wording_unit').')' ; | |||
} | |||
$messageAutoText .= '- '.$productDescription.' |
@@ -53,7 +53,7 @@ $this->setTitle('Accès') ; | |||
</div> | |||
<div class="panel-body"> | |||
<?php $form = ActiveForm::begin(); ?> | |||
<?= $form->field($modelAccessUserProducerForm, 'id_user')->dropDownList(UserModel::populateDropdownList(), ['class' => 'select2'])->label(''); ?> | |||
<?= $form->field($modelAccessUserProducerForm, 'id_user')->dropDownList( User::populateDropdownList(), ['class' => 'select2'])->label(''); ?> | |||
<?= Html::submitButton('Ajouter', ['class' => 'btn btn-success']) ?> | |||
<?php ActiveForm::end(); ?> | |||
</div> |
@@ -43,7 +43,7 @@ $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon gl | |||
?> | |||
<div class="delivery-note-index"> | |||
<?php if(DeliveryNoteModel::searchCount()): ?> | |||
<?php if(DeliveryNote::searchCount()): ?> | |||
<?= GridView::widget([ | |||
'filterModel' => $searchModel, | |||
'dataProvider' => $dataProvider, | |||
@@ -91,7 +91,7 @@ $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon gl | |||
[ | |||
'attribute' => 'id_point_sale', | |||
'header' => 'Point de vente', | |||
'filter' => ArrayHelper::map(PointSaleModel::searchAll([], ['as_array'=>true]), 'id', 'name'), | |||
'filter' => ArrayHelper::map(PointSale::searchAll([], ['as_array'=>true]), 'id', 'name'), | |||
'format' => 'html', | |||
'value' => function($model) { | |||
$pointSale = $model->getPointSale() ; | |||
@@ -105,7 +105,7 @@ $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon gl | |||
'attribute' => 'amount', | |||
'header' => 'Montant', | |||
'value' => function($deliveryNote) { | |||
return $deliveryNote->getAmountWithTax(OrderModel::INVOICE_AMOUNT_TOTAL, true) ; | |||
return $deliveryNote->getAmountWithTax(Order::INVOICE_AMOUNT_TOTAL, true) ; | |||
} | |||
], | |||
[ |
@@ -40,7 +40,7 @@ use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\models\Development; | |||
use common\models\DevelopmentPriority; | |||
use common\models\UserModel; | |||
use common\models\ User; | |||
use common\helpers\Url; | |||
use common\helpers\GlobalParam; | |||
@@ -126,7 +126,7 @@ $this->addBreadcrumb($this->getTitle()); | |||
]; | |||
if (UserModel::hasAccessBackend()) { | |||
if ( User::hasAccessBackend()) { | |||
$columns[] = [ | |||
'header' => 'Priorité', | |||
@@ -160,7 +160,7 @@ $this->addBreadcrumb($this->getTitle()); | |||
]; | |||
} | |||
if (UserModel::getCurrentStatus() == UserModel::STATUS_ADMIN) { | |||
if ( User::getCurrentStatus() == User::STATUS_ADMIN) { | |||
$columns[] = [ | |||
'class' => 'yii\grid\ActionColumn', | |||
'template' => '{update}', |
@@ -40,7 +40,7 @@ use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\models\Development; | |||
use common\models\DevelopmentPriority; | |||
use common\models\UserModel; | |||
use common\models\ User; | |||
use common\helpers\Url; | |||
use common\helpers\GlobalParam; | |||
@@ -104,7 +104,7 @@ foreach ($pointsSaleArray as $pointSale) { | |||
$add = false; | |||
foreach ($order->productOrder as $productOrder) { | |||
if($product->id == $productOrder->id_product) { | |||
$unit = (ProductModel::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '.ProductModel::strUnit($productOrder->unit, 'wording_short', true) ; | |||
$unit = ( Product::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($productOrder->unit, 'wording_short', true) ; | |||
$strProducts .= $product->name . ' (' .$productOrder->quantity .$unit.')<br />'; | |||
$add = true; | |||
} | |||
@@ -156,7 +156,7 @@ foreach ($pointsSaleArray as $pointSale) { | |||
$credit = '' ; | |||
if(isset($order->user) && $order->user->id) { | |||
$userProducer = UserProducerModel::searchOne([ | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $order->user->id | |||
]); | |||
@@ -181,10 +181,10 @@ foreach ($pointsSaleArray as $pointSale) { | |||
$strProducts = ''; | |||
$cpt = 0 ; | |||
foreach ($productsArray as $product) { | |||
foreach(ProductModel::$unitsArray as $unit => $dataUnit) { | |||
$quantity = OrderModel::getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||
foreach( Product::$unitsArray as $unit => $dataUnit) { | |||
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||
if ($quantity) { | |||
$theUnit = (ProductModel::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '.ProductModel::strUnit($unit, 'wording_short', true) ; | |||
$theUnit = ( Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($unit, 'wording_short', true) ; | |||
$strProducts .= $product->name . ' (' .$quantity .$theUnit.')<br />'; | |||
} | |||
} | |||
@@ -230,10 +230,10 @@ foreach ($pointsSaleArray as $pointSale) | |||
$cpt = 0 ; | |||
foreach ($productsArray as $product) { | |||
foreach(ProductModel::$unitsArray as $unit => $dataUnit) { | |||
$quantity = OrderModel::getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||
foreach( Product::$unitsArray as $unit => $dataUnit) { | |||
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||
if ($quantity) { | |||
$theUnit = (ProductModel::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '.ProductModel::strUnit($unit, 'wording_short', true) ; | |||
$theUnit = ( Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($unit, 'wording_short', true) ; | |||
$html .= $product->name . ' (' .$quantity .$theUnit.')<br />'; | |||
} | |||
} | |||
@@ -257,10 +257,10 @@ $html .= '<tr><td><strong>Total</strong></td><td>' ; | |||
$cpt = 0 ; | |||
foreach ($productsArray as $product) { | |||
foreach(ProductModel::$unitsArray as $unit => $dataUnit) { | |||
$quantity = OrderModel::getProductQuantity($product->id, $ordersArray, false, $unit); | |||
foreach( Product::$unitsArray as $unit => $dataUnit) { | |||
$quantity = Order::getProductQuantity($product->id, $ordersArray, false, $unit); | |||
if ($quantity) { | |||
$theUnit = (ProductModel::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '.ProductModel::strUnit($unit, 'wording_short', true) ; | |||
$theUnit = ( Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($unit, 'wording_short', true) ; | |||
$html .= $product->name . ' (' .$quantity .$theUnit.')<br />'; | |||
} | |||
} |
@@ -56,7 +56,7 @@ foreach($pointsSaleArray as $keyPointSale => $pointSale) { | |||
foreach ($orders as $order) { | |||
$html .= '<tr>'; | |||
$strUser = $order->getStrUser(); | |||
if ($producer->option_order_reference_type == ProducerModel::ORDER_REFERENCE_TYPE_YEARLY && $order->reference && strlen($order->reference) > 0) { | |||
if ($producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY && $order->reference && strlen($order->reference) > 0) { | |||
$strUser .= '<br />' . $order->reference; | |||
} | |||
@@ -93,7 +93,7 @@ function line_product($product, $orders) { | |||
$quantity = '' ; | |||
foreach($order->productOrder as $productOrder) { | |||
if($product->id == $productOrder->id_product) { | |||
$unit = (ProductModel::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '.ProductModel::strUnit($productOrder->unit, 'wording_short', true) ; | |||
$unit = ( Product::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($productOrder->unit, 'wording_short', true) ; | |||
$quantity .= $productOrder->quantity .$unit ; | |||
if($productOrder->quantity > 1) { |
@@ -86,7 +86,7 @@ foreach ($pointsSaleArray as $pointSale) { | |||
} | |||
// référence | |||
if($producer->option_order_reference_type == ProducerModel::ORDER_REFERENCE_TYPE_YEARLY && $order->reference && strlen($order->reference) > 0) { | |||
if($producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY && $order->reference && strlen($order->reference) > 0) { | |||
$strUser .= '<br />'.$order->reference ; | |||
} | |||
@@ -98,7 +98,7 @@ foreach ($pointsSaleArray as $pointSale) { | |||
$add = false; | |||
foreach ($order->productOrder as $productOrder) { | |||
if($product->id == $productOrder->id_product) { | |||
$unit = (ProductModel::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '.ProductModel::strUnit($productOrder->unit, 'wording_short', true) ; | |||
$unit = ( Product::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($productOrder->unit, 'wording_short', true) ; | |||
$strProducts .= '('.$productOrder->quantity .$unit.') '.$product->getNameExport() . '<br />'; | |||
$add = true; | |||
} | |||
@@ -115,7 +115,7 @@ foreach ($pointsSaleArray as $pointSale) { | |||
$credit = '' ; | |||
if(isset($order->user) && $order->user->id) { | |||
$userProducer = UserProducerModel::searchOne([ | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $order->user->id | |||
]); | |||
@@ -129,17 +129,17 @@ foreach ($pointsSaleArray as $pointSale) { | |||
$html .= '<td><strong>'.number_format($order->amount_with_tax, 2) . ' € '; | |||
if($order->getPaymentStatus() == OrderModel::PAYMENT_PAID) | |||
if($order->getPaymentStatus() == Order::PAYMENT_PAID) | |||
{ | |||
$html .= '(payé)' ; | |||
} | |||
elseif($order->getPaymentStatus() == OrderModel::PAYMENT_UNPAID && $order->getAmount(OrderModel::AMOUNT_PAID)) | |||
elseif($order->getPaymentStatus() == Order::PAYMENT_UNPAID && $order->getAmount(Order::AMOUNT_PAID)) | |||
{ | |||
$html .= '(reste '.$order->getAmount(OrderModel::AMOUNT_REMAINING, true).' à payer)' ; | |||
$html .= '(reste '.$order->getAmount(Order::AMOUNT_REMAINING, true).' à payer)' ; | |||
} | |||
elseif($order->getPaymentStatus() == OrderModel::PAYMENT_SURPLUS) | |||
elseif($order->getPaymentStatus() == Order::PAYMENT_SURPLUS) | |||
{ | |||
$html .= '(surplus : '.$order->getAmount(OrderModel::PAYMENT_SURPLUS, true).' à rembourser)' ; | |||
$html .= '(surplus : '.$order->getAmount(Order::PAYMENT_SURPLUS, true).' à rembourser)' ; | |||
} | |||
$html .= '</strong></td>' ; | |||
@@ -153,10 +153,10 @@ foreach ($pointsSaleArray as $pointSale) { | |||
$strProducts = ''; | |||
$cpt = 0 ; | |||
foreach ($productsArray as $product) { | |||
foreach(ProductModel::$unitsArray as $unit => $dataUnit) { | |||
$quantity = OrderModel::getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||
foreach( Product::$unitsArray as $unit => $dataUnit) { | |||
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||
if ($quantity) { | |||
$theUnit = (ProductModel::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '.ProductModel::strUnit($unit, 'wording_short', true) ; | |||
$theUnit = ( Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($unit, 'wording_short', true) ; | |||
$strProducts .= '(' .$quantity .$theUnit.') '.$product->getNameExport() . '<br />'; | |||
} | |||
} | |||
@@ -202,10 +202,10 @@ foreach ($pointsSaleArray as $pointSale) | |||
$cpt = 0 ; | |||
foreach ($productsArray as $product) { | |||
foreach(ProductModel::$unitsArray as $unit => $dataUnit) { | |||
$quantity = OrderModel::getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||
foreach( Product::$unitsArray as $unit => $dataUnit) { | |||
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||
if ($quantity) { | |||
$theUnit = (ProductModel::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '.ProductModel::strUnit($unit, 'wording_short', true) ; | |||
$theUnit = ( Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($unit, 'wording_short', true) ; | |||
$html .= '(' .$quantity .$theUnit.') '.$product->getNameExport() . '<br />'; | |||
} | |||
} | |||
@@ -229,10 +229,10 @@ $html .= '<tr><td><strong>Total</strong></td><td>' ; | |||
$cpt = 0 ; | |||
foreach ($productsArray as $product) { | |||
foreach(ProductModel::$unitsArray as $unit => $dataUnit) { | |||
$quantity = OrderModel::getProductQuantity($product->id, $ordersArray, false, $unit); | |||
foreach( Product::$unitsArray as $unit => $dataUnit) { | |||
$quantity = Order::getProductQuantity($product->id, $ordersArray, false, $unit); | |||
if ($quantity) { | |||
$theUnit = (ProductModel::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '.ProductModel::strUnit($unit, 'wording_short', true) ; | |||
$theUnit = ( Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($unit, 'wording_short', true) ; | |||
$html .= '(' .$quantity .$theUnit.') '.$product->name . '<br />'; | |||
} | |||
} |
@@ -24,9 +24,9 @@ | |||
</td> | |||
<?php endif; ?> | |||
<td class="align-center"> | |||
<?= $productOrder->quantity * ProductModel::$unitsArray[$productOrder->unit]['coefficient'] ?> | |||
<?= $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'] ?> | |||
</td> | |||
<td class="align-center"><?= ProductModel::strUnit($productOrder->unit, 'wording') ?></td> | |||
<td class="align-center"><?= Product::strUnit($productOrder->unit, 'wording') ?></td> | |||
<?php if($displayPrices): ?> | |||
<?php if($producer->taxRate->value != 0): ?> | |||
<td class="align-center"><?= $productOrder->taxRate->value * 100 ?> %</td> |
@@ -73,7 +73,7 @@ use common\models\Producer; | |||
'template' => '{label} <a href="' . Yii::$app->urlManager->createUrl(['user/create']) . '" class="btn btn-xs btn-default">Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span></a><div>{input}</div>{hint}', | |||
]) | |||
->dropDownList( | |||
UserModel::populateDropdownList(), | |||
User::populateDropdownList(), | |||
[ | |||
'@change' => 'changeUser', | |||
'v-model' => 'idUser', | |||
@@ -215,7 +215,7 @@ use common\models\Producer; | |||
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-repeat"></span> Regénérer (PDF)</a> | |||
<?php endif; ?> | |||
<?php if ($model->getClass() == 'Invoice' && ProducerModel::getConfig('option_export_evoliz')): ?> | |||
<?php if ($model->getClass() == 'Invoice' && Producer::getConfig('option_export_evoliz')): ?> | |||
<a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/export-csv-evoliz', 'id' => $model->id]) ?>" | |||
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-save-file"></span> Export Evoliz | |||
(CSV)</a> |
@@ -1,8 +1,8 @@ | |||
<?php | |||
$displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && ProducerModel::getConfig('document_display_prices_delivery_note')); | |||
$displayProductDescription = ProducerModel::getConfig('document_display_product_description'); | |||
$documentPriceDecimals = (int) ProducerModel::getConfig('option_document_price_decimals'); | |||
$displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && Producer::getConfig('document_display_prices_delivery_note')); | |||
$displayProductDescription = Producer::getConfig('document_display_product_description'); | |||
$documentPriceDecimals = (int) Producer::getConfig('option_document_price_decimals'); | |||
?> | |||
@@ -126,7 +126,7 @@ $documentPriceDecimals = (int) ProducerModel::getConfig('option_document_price_d | |||
<?php endforeach; ?> | |||
<?php endif; ?> | |||
<?php if ($displayPrices): ?> | |||
<?php $typeAmount = $document->isInvoicePrice() ? OrderModel::INVOICE_AMOUNT_TOTAL : OrderModel::AMOUNT_TOTAL; ?> | |||
<?php $typeAmount = $document->isInvoicePrice() ? Order::INVOICE_AMOUNT_TOTAL : Order::AMOUNT_TOTAL; ?> | |||
<?php if ($producer->taxRate->value != 0): ?> | |||
@@ -51,7 +51,7 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon- | |||
<div class="invoice-index"> | |||
<?php if(InvoiceModel::searchCount()): ?> | |||
<?php if(Invoice::searchCount()): ?> | |||
<?= GridView::widget([ | |||
'filterModel' => $searchModel, | |||
'dataProvider' => $dataProvider, | |||
@@ -96,7 +96,7 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon- | |||
'attribute' => 'amount', | |||
'header' => 'Montant', | |||
'value' => function($invoice) { | |||
return $invoice->getAmountWithTax(OrderModel::INVOICE_AMOUNT_TOTAL, true) ; | |||
return $invoice->getAmountWithTax(Order::INVOICE_AMOUNT_TOTAL, true) ; | |||
} | |||
], | |||
[ |
@@ -38,7 +38,7 @@ | |||
use yii\helpers\Html; | |||
use common\models\Producer; | |||
use common\models\UserModel; | |||
use common\models\ User; | |||
use yii\widgets\ActiveForm; | |||
use yii\helpers\ArrayHelper; | |||
use common\helpers\GlobalParam; | |||
@@ -63,7 +63,7 @@ $producer = GlobalParam::getCurrentProducer(); | |||
<div class="navbar-custom-menu"> | |||
<?php | |||
$usersArray = UserModel::findBy(['id_producer' => GlobalParam::getCurrentProducerId()]) | |||
$usersArray = User::findBy(['id_producer' => GlobalParam::getCurrentProducerId()]) | |||
->andWhere('CAST(FROM_UNIXTIME(user.created_at) AS date) > \'' . date("Y-m-d", strtotime("-7 days")) . '\'') | |||
->orderBy('created_at DESC') | |||
->all(); | |||
@@ -175,7 +175,7 @@ $producer = GlobalParam::getCurrentProducer(); | |||
<?php | |||
$usersNegativeCreditArray = UserModel::findBy(['id_producer' => GlobalParam::getCurrentProducerId()]) | |||
$usersNegativeCreditArray = User::findBy(['id_producer' => GlobalParam::getCurrentProducerId()]) | |||
->andWhere('user_producer.credit < 0') | |||
->orderBy('lastname, name ASC') | |||
->all(); | |||
@@ -198,7 +198,7 @@ $producer = GlobalParam::getCurrentProducer(); | |||
<?php foreach ($usersNegativeCreditArray as $user): ?> | |||
<li> | |||
<a href="<?= Yii::$app->urlManagerBackend->createUrl(['user/credit', 'id' => $user['user_id']]); ?>"> | |||
<h5><?= UserModel::getUsernameFromArray($user); ?> | |||
<h5><?= User::getUsernameFromArray($user); ?> | |||
<small> | |||
<i class="fa fa-euro"></i> <?= Price::format($user['credit']); ?> | |||
</small> | |||
@@ -215,7 +215,7 @@ $producer = GlobalParam::getCurrentProducer(); | |||
</li> | |||
<?php if (UserModel::isCurrentProducer() || UserModel::isCurrentAdmin()): ?> | |||
<?php if ( User::isCurrentProducer() || User::isCurrentAdmin()): ?> | |||
<li class="dropdown producer-menu"> | |||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> | |||
@@ -229,7 +229,7 @@ $producer = GlobalParam::getCurrentProducer(); | |||
</a> | |||
<ul class="dropdown-menu"> | |||
<?php if (UserModel::isCurrentAdmin()): ?> | |||
<?php if ( User::isCurrentAdmin()): ?> | |||
<li> | |||
<a href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => GlobalParam::getCurrentProducer()->slug]); ?>"> | |||
<i class="fa fa-th-large"></i> | |||
@@ -237,7 +237,7 @@ $producer = GlobalParam::getCurrentProducer(); | |||
</a> | |||
</li> | |||
<li class="header"> <strong>Autres producteurs</strong></li> | |||
<?php $producersArray = ProducerModel::find()->orderBy('name ASC')->all(); ?> | |||
<?php $producersArray = Producer::find()->orderBy('name ASC')->all(); ?> | |||
<?php foreach ($producersArray as $producer): ?> | |||
<li> | |||
<a href="<?= Yii::$app->urlManagerBackend->createUrl(['site/change-producer', 'id' => $producer->id]); ?>"><?= Html::encode($producer->name) ?></a> | |||
@@ -258,7 +258,7 @@ $producer = GlobalParam::getCurrentProducer(); | |||
<li class="dropdown user user-menu"> | |||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> | |||
<i class="fa fa-user"></i> | |||
<span class="hidden-xs"><?= Html::encode(UserModel::getCurrent()->name . ' ' . UserModel::getCurrent()->lastname); ?></span> | |||
<span class="hidden-xs"><?= Html::encode( User::getCurrent()->name . ' ' . User::getCurrent()->lastname); ?></span> | |||
<i class="fa fa-caret-down"></i> | |||
</a> | |||
<ul class="dropdown-menu"> |
@@ -54,39 +54,39 @@ | |||
[ | |||
'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'], | |||
'items' => [ | |||
['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/site/index'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/site/index'], 'visible' => User::isCurrentProducer()], | |||
['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => User::isCurrentProducer()], | |||
[ | |||
'label' => 'Produits', | |||
'icon' => 'clone', | |||
'url' => ['/product/index'], | |||
'visible' => UserModel::isCurrentProducer(), | |||
'visible' => User::isCurrentProducer(), | |||
'active' => Yii::$app->controller->id == 'product', | |||
'items' => [ | |||
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/product/index'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Catégories', 'icon' => 'book', 'url' => ['/product-category/index'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/product/index'], 'visible' => User::isCurrentProducer()], | |||
['label' => 'Catégories', 'icon' => 'book', 'url' => ['/product-category/index'], 'visible' => User::isCurrentProducer()], | |||
] | |||
], | |||
['label' => 'Points de vente', 'icon' => 'map-marker', 'url' => ['/point-sale/index'], 'visible' => UserModel::isCurrentProducer(), 'active' => Yii::$app->controller->id == 'point-sale'], | |||
['label' => 'Points de vente', 'icon' => 'map-marker', 'url' => ['/point-sale/index'], 'visible' => User::isCurrentProducer(), 'active' => Yii::$app->controller->id == 'point-sale'], | |||
[ | |||
'label' => 'Utilisateurs', | |||
'icon' => 'users', | |||
'url' => ['/user/index'], | |||
'items' => [ | |||
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/user/index'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/user/index'], 'visible' => User::isCurrentProducer()], | |||
['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => User::isCurrentProducer()], | |||
], | |||
], | |||
['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => UserModel::isCurrentProducer(), 'active' => Yii::$app->controller->id == 'subscription'], | |||
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate/index'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => User::isCurrentProducer(), 'active' => Yii::$app->controller->id == 'subscription'], | |||
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate/index'], 'visible' => User::isCurrentProducer()], | |||
[ | |||
'label' => 'Documents', | |||
'icon' => 'clone', | |||
'url' => ['/delivery-note/index'], | |||
'items' => [ | |||
['label' => 'Bons de livraison', 'icon' => 'sticky-note-o', 'url' => ['/delivery-note/index'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Factures', 'icon' => 'sticky-note-o', 'url' => ['/invoice/index'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Devis', 'icon' => 'sticky-note-o', 'url' => ['/quotation/index'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Bons de livraison', 'icon' => 'sticky-note-o', 'url' => ['/delivery-note/index'], 'visible' => User::isCurrentProducer()], | |||
['label' => 'Factures', 'icon' => 'sticky-note-o', 'url' => ['/invoice/index'], 'visible' => User::isCurrentProducer()], | |||
['label' => 'Devis', 'icon' => 'sticky-note-o', 'url' => ['/quotation/index'], 'visible' => User::isCurrentProducer()], | |||
], | |||
], | |||
[ | |||
@@ -94,33 +94,33 @@ | |||
'icon' => 'line-chart', | |||
'url' => ['/stats/index'], | |||
'items' => [ | |||
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats/index'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Rapports', 'icon' => 'pencil-square-o', 'url' => ['/report/index'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Produits', 'icon' => 'table', 'url' => ['/stats/products'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats/index'], 'visible' => User::isCurrentProducer()], | |||
['label' => 'Rapports', 'icon' => 'pencil-square-o', 'url' => ['/report/index'], 'visible' => User::isCurrentProducer()], | |||
['label' => 'Produits', 'icon' => 'table', 'url' => ['/stats/products'], 'visible' => User::isCurrentProducer()], | |||
], | |||
], | |||
['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/producer/update'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Accès', 'icon' => 'lock', 'url' => ['/access/index'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/producer/update'], 'visible' => User::isCurrentProducer()], | |||
['label' => 'Accès', 'icon' => 'lock', 'url' => ['/access/index'], 'visible' => User::isCurrentProducer()], | |||
[ | |||
'label' => 'Développement', | |||
'icon' => 'code', | |||
'url' => ['/development/index'], | |||
'visible' => UserModel::isCurrentProducer(), | |||
'visible' => User::isCurrentProducer(), | |||
'active' => Yii::$app->controller->id == 'development', | |||
'template'=>'<a href="{url}">{icon} {label}'.$newVersionOpendistribTemplate.'</a>' | |||
], | |||
['label' => 'Tarifs', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => UserModel::isCurrentProducer()], | |||
['label' => 'Tarifs', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => User::isCurrentProducer()], | |||
['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => UserModel::isCurrentAdmin()], | |||
['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => UserModel::isCurrentAdmin()], | |||
['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => UserModel::isCurrentAdmin()], | |||
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => UserModel::isCurrentAdmin()], | |||
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => UserModel::isCurrentAdmin()], | |||
['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => User::isCurrentAdmin()], | |||
['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => User::isCurrentAdmin()], | |||
['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => User::isCurrentAdmin()], | |||
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => User::isCurrentAdmin()], | |||
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => User::isCurrentAdmin()], | |||
['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => UserModel::isCurrentAdmin()], | |||
['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => UserModel::isCurrentAdmin()], | |||
['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => UserModel::isCurrentAdmin()], | |||
['label' => 'Login', 'url' => ['site/login'], 'visible' => !UserModel::isCurrentConnected()], | |||
['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => User::isCurrentAdmin()], | |||
['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => User::isCurrentAdmin()], | |||
['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => User::isCurrentAdmin()], | |||
['label' => 'Login', 'url' => ['site/login'], 'visible' => ! User::isCurrentConnected()], | |||
], | |||
] | |||
) ?> |
@@ -41,7 +41,7 @@ use yii\bootstrap\Nav; | |||
use yii\bootstrap\NavBar; | |||
use yii\widgets\Breadcrumbs; | |||
use common\models\Producer; | |||
use common\models\UserModel; | |||
use common\models\ User; | |||
use yii\widgets\ActiveForm; | |||
use yii\helpers\ArrayHelper; | |||
use common\helpers\Url; | |||
@@ -55,7 +55,7 @@ use common\helpers\GlobalParam; | |||
$producer = null; | |||
if (!Yii::$app->user->isGuest) { | |||
$producer = ProducerModel::findOne(GlobalParam::getCurrentProducerId()); | |||
$producer = Producer::findOne(GlobalParam::getCurrentProducerId()); | |||
} | |||
?> | |||
@@ -167,7 +167,7 @@ if (!Yii::$app->user->isGuest) { | |||
$menuItems[] = ['label' => 'Connexion', 'url' => ['/site/login']]; | |||
} else { | |||
if (Yii::$app->user->identity->status == UserModel::STATUS_ADMIN) { | |||
if (Yii::$app->user->identity->status == User::STATUS_ADMIN) { | |||
$menuItems[] = [ | |||
'label' => '<span class="glyphicon glyphicon-asterisk"></span>', | |||
'url' => '#', | |||
@@ -211,9 +211,9 @@ if (!Yii::$app->user->isGuest) { | |||
<?php endif; ?> | |||
<?php if (!Yii::$app->user->isGuest): ?> | |||
<div class="name-producer"> | |||
<?php if (UserModel::getCurrentStatus() == UserModel::STATUS_PRODUCER): ?> | |||
<?php if ( User::getCurrentStatus() == User::STATUS_PRODUCER): ?> | |||
<span><?= Html::encode(Yii::$app->user->identity->getNameProducer()); ?></span> | |||
<?php elseif (UserModel::getCurrentStatus() == UserModel::STATUS_ADMIN): ?> | |||
<?php elseif ( User::getCurrentStatus() == User::STATUS_ADMIN): ?> | |||
<?php $form = ActiveForm::begin(['id' => 'select-producer']); ?> | |||
<?= | |||
Html::dropDownList('select_producer', GlobalParam::getCurrentProducerId(), ArrayHelper::map(ProducerModel::find()->orderBy('name ASC')->all(), 'id', function ($model, $defaultValue) { | |||
@@ -224,7 +224,7 @@ if (!Yii::$app->user->isGuest) { | |||
<?php endif; ?> | |||
<?php | |||
$producer = ProducerModel::findOne(GlobalParam::getCurrentProducerId()); | |||
$producer = Producer::findOne(GlobalParam::getCurrentProducerId()); | |||
if (!$producer->active): | |||
?> | |||
<span class="label label-danger" data-toggle="tooltip" data-placement="bottom" |
@@ -110,17 +110,17 @@ foreach ($pointsSaleArray as $pointSale) { | |||
$html .= '<td><strong>'.number_format($order->amount, 2) . ' € '; | |||
if($order->getPaymentStatus() == OrderModel::PAYMENT_PAID) | |||
if($order->getPaymentStatus() == Order::PAYMENT_PAID) | |||
{ | |||
$html .= '(payé)' ; | |||
} | |||
elseif($order->getPaymentStatus() == OrderModel::PAYMENT_UNPAID && $order->getAmount(OrderModel::AMOUNT_PAID)) | |||
elseif($order->getPaymentStatus() == Order::PAYMENT_UNPAID && $order->getAmount(Order::AMOUNT_PAID)) | |||
{ | |||
$html .= '(reste '.$order->getAmount(OrderModel::AMOUNT_REMAINING, true).' à payer)' ; | |||
$html .= '(reste '.$order->getAmount(Order::AMOUNT_REMAINING, true).' à payer)' ; | |||
} | |||
elseif($order->getPaymentStatus() == OrderModel::PAYMENT_SURPLUS) | |||
elseif($order->getPaymentStatus() == Order::PAYMENT_SURPLUS) | |||
{ | |||
$html .= '(surplus : '.$order->getAmount(OrderModel::PAYMENT_SURPLUS, true).' à rembourser)' ; | |||
$html .= '(surplus : '.$order->getAmount(Order::PAYMENT_SURPLUS, true).' à rembourser)' ; | |||
} | |||
$html .= '</strong></td>' ; | |||
@@ -133,7 +133,7 @@ foreach ($pointsSaleArray as $pointSale) { | |||
$strProducts = ''; | |||
foreach ($productsArray as $product) { | |||
$quantity = OrderModel::getProductQuantity($product->id, $pointSale->orders); | |||
$quantity = Order::getProductQuantity($product->id, $pointSale->orders); | |||
$strQuantity = ''; | |||
if ($quantity) { | |||
$strQuantity = $quantity; | |||
@@ -171,7 +171,7 @@ foreach ($pointsSaleArray as $pointSale) | |||
{ | |||
$html .= '<tr><td>'.$pointSale->name.'</td><td>' ; | |||
foreach ($productsArray as $product) { | |||
$quantity = OrderModel::getProductQuantity($product->id, $pointSale->orders); | |||
$quantity = Order::getProductQuantity($product->id, $pointSale->orders); | |||
$strQuantity = ($quantity) ? $quantity : '' ; | |||
if(strlen($strQuantity)) { | |||
@@ -190,7 +190,7 @@ foreach ($pointsSaleArray as $pointSale) | |||
// total | |||
$html .= '<tr><td><strong>Total</strong></td><td>' ; | |||
foreach ($productsArray as $product) { | |||
$quantity = OrderModel::getProductQuantity($product->id, $ordersArray); | |||
$quantity = Order::getProductQuantity($product->id, $ordersArray); | |||
if($quantity) { | |||
$html .= $quantity . ' '.$product->name.', ' ; | |||
} |
@@ -59,7 +59,7 @@ use common\models\ProductPrice ; | |||
<?= $form->field($model, 'id_user', [ | |||
'template' => '{label} <a href="' . Yii::$app->urlManager->createUrl(['user/create']) . '" class="btn btn-xs btn-default">Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span></a><div>{input}</div>{hint}', | |||
]) | |||
->dropDownList(UserModel::populateDropdownList(), ['class' => 'select2']) | |||
->dropDownList( User::populateDropdownList(), ['class' => 'select2']) | |||
->hint('Utilisé lors de la facturation'); ?> | |||
<?php | |||
@@ -76,14 +76,14 @@ use common\models\ProductPrice ; | |||
<?= $form->field($model, 'credit_functioning') | |||
->dropDownList([ | |||
'' => 'Paramètres globaux (' . ProducerModel::$creditFunctioningArray[ProducerModel::getConfig('credit_functioning')] . ')', | |||
ProducerModel::CREDIT_FUNCTIONING_OPTIONAL => ProducerModel::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_OPTIONAL], | |||
ProducerModel::CREDIT_FUNCTIONING_MANDATORY => ProducerModel::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_MANDATORY], | |||
ProducerModel::CREDIT_FUNCTIONING_USER => ProducerModel::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_USER], | |||
'' => 'Paramètres globaux (' . Producer::$creditFunctioningArray[ProducerModel::getConfig('credit_functioning')] . ')', | |||
Producer::CREDIT_FUNCTIONING_OPTIONAL => Producer::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_OPTIONAL], | |||
Producer::CREDIT_FUNCTIONING_MANDATORY => Producer::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_MANDATORY], | |||
Producer::CREDIT_FUNCTIONING_USER => Producer::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_USER], | |||
], [])->hint(ProducerModel::HINT_CREDIT_FUNCTIONING); ?> | |||
<?php /*$form->field($model, 'product_price_percent') | |||
->dropDownList(ProductPriceModel::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit dans ce point de vente.');*/ ?> | |||
->dropDownList( ProductPrice::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit dans ce point de vente.');*/ ?> | |||
<?= $form->field($model, 'maximum_number_orders')->textInput() ?> | |||
@@ -128,7 +128,7 @@ use common\models\ProductPrice ; | |||
<?= Html::activeCheckboxList($model, 'users', ArrayHelper::map($users, 'user_id', function ($model_user, $defaultValue) use ($model) { | |||
return Html::encode(UserModel::getUsernameFromArray($model_user)) . '<br />' | |||
return Html::encode( User::getUsernameFromArray($model_user)) . '<br />' | |||
. Html::activeTextInput( | |||
$model, | |||
'users_comment[' . $model_user['user_id'] . ']', |
@@ -98,7 +98,7 @@ $this->addButton( | |||
], | |||
'format' => 'raw', | |||
'value' => function ($model) { | |||
$count = UserPointSaleModel::find()->where( | |||
$count = UserPointSale::find()->where( | |||
['id_point_sale' => $model->id] | |||
)->count(); | |||
$html = ''; | |||
@@ -129,7 +129,7 @@ $this->addButton( | |||
'format' => 'raw', | |||
'value' => function ($model) { | |||
if ($model->credit && isset(ProducerModel::$creditFunctioningArray[$model->credit_functioning])) { | |||
return '<span class="glyphicon glyphicon-euro"></span> ' . ProducerModel::$creditFunctioningArray[$model->credit_functioning]; | |||
return '<span class="glyphicon glyphicon-euro"></span> ' . Producer::$creditFunctioningArray[$model->credit_functioning]; | |||
} | |||
return ''; |
@@ -38,7 +38,7 @@ termes. | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\models\UserModel ; | |||
use common\models\ User ; | |||
use common\models\Etablissement ; | |||
$this->title = 'Facturation'; |
@@ -38,7 +38,7 @@ termes. | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\models\UserModel ; | |||
use common\models\ User ; | |||
use common\models\Producer ; | |||
use common\models\Distribution ; | |||
@@ -119,7 +119,7 @@ $this->addButton(['label' => 'Nouveau producteur <span class="glyphicon glyphico | |||
else { | |||
foreach($model->user as $u) | |||
{ | |||
if($u->status == UserModel::STATUS_PRODUCER) | |||
if($u->status == User::STATUS_PRODUCER) | |||
{ | |||
return Html::encode($u->lastname.' '.$u->name) | |||
.'<br />'.Html::encode($u->email) |
@@ -38,7 +38,7 @@ | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\models\UserModel; | |||
use common\models\ User; | |||
use common\models\Producer; | |||
use common\models\Distribution; | |||
@@ -38,7 +38,7 @@ termes. | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\models\UserModel ; | |||
use common\models\ User ; | |||
use common\models\Producer ; | |||
use yii\bootstrap\ActiveForm; | |||
@@ -50,7 +50,7 @@ $this->addBreadcrumb($this->getTitle()); | |||
<script> | |||
var appInitValues = { | |||
isAdmin: <?= (int)UserModel::isCurrentAdmin() ?> | |||
isAdmin: <?= (int) User::isCurrentAdmin() ?> | |||
}; | |||
</script> | |||
@@ -120,8 +120,8 @@ $this->addBreadcrumb($this->getTitle()); | |||
?> | |||
<?= $form->field($model, 'behavior_home_point_sale_day_list') | |||
->dropDownList([ | |||
ProducerModel::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_WEEK => 'Jours de la semaine', | |||
ProducerModel::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_INCOMING_DISTRIBUTIONS => 'Distributions à venir', | |||
Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_WEEK => 'Jours de la semaine', | |||
Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_INCOMING_DISTRIBUTIONS => 'Distributions à venir', | |||
]); ?> | |||
</div> | |||
</div> | |||
@@ -245,13 +245,13 @@ $this->addBreadcrumb($this->getTitle()); | |||
<h4>Tunnel de commande</h4> | |||
<?= $form->field($model, 'option_order_entry_point') | |||
->dropDownList([ | |||
ProducerModel::ORDER_ENTRY_POINT_DATE => 'Date', | |||
ProducerModel::ORDER_ENTRY_POINT_POINT_SALE => 'Point de vente', | |||
Producer::ORDER_ENTRY_POINT_DATE => 'Date', | |||
Producer::ORDER_ENTRY_POINT_POINT_SALE => 'Point de vente', | |||
], []); ?> | |||
<?= $form->field($model, 'behavior_order_select_distribution') | |||
->dropDownList([ | |||
ProducerModel::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_CALENDAR => 'Calendrier', | |||
ProducerModel::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST => 'Liste', | |||
Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_CALENDAR => 'Calendrier', | |||
Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST => 'Liste', | |||
]); ?> | |||
<?= $form->field($model, 'option_delivery') | |||
->dropDownList([ | |||
@@ -313,13 +313,13 @@ $this->addBreadcrumb($this->getTitle()); | |||
<h4>Divers</h4> | |||
<?= $form->field($model, 'option_order_reference_type') | |||
->dropDownList([ | |||
ProducerModel::ORDER_REFERENCE_TYPE_NONE => '--', | |||
ProducerModel::ORDER_REFERENCE_TYPE_YEARLY => 'Annuelle', | |||
Producer::ORDER_REFERENCE_TYPE_NONE => '--', | |||
Producer::ORDER_REFERENCE_TYPE_YEARLY => 'Annuelle', | |||
], []); ?> | |||
<?= $form->field($model, 'option_behavior_cancel_order') | |||
->dropDownList([ | |||
ProducerModel::BEHAVIOR_DELETE_ORDER_DELETE => 'Suppression de la commande', | |||
ProducerModel::BEHAVIOR_DELETE_ORDER_STATUS => 'Passage de la commande en statut "supprimé"', | |||
Producer::BEHAVIOR_DELETE_ORDER_DELETE => 'Suppression de la commande', | |||
Producer::BEHAVIOR_DELETE_ORDER_STATUS => 'Passage de la commande en statut "supprimé"', | |||
], []); ?> | |||
</div> | |||
</div> | |||
@@ -351,9 +351,9 @@ $this->addBreadcrumb($this->getTitle()); | |||
<?= $form->field($model, 'credit_functioning') | |||
->dropDownList([ | |||
ProducerModel::CREDIT_FUNCTIONING_OPTIONAL => ProducerModel::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_OPTIONAL], | |||
ProducerModel::CREDIT_FUNCTIONING_MANDATORY => ProducerModel::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_MANDATORY], | |||
ProducerModel::CREDIT_FUNCTIONING_USER => ProducerModel::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_USER], | |||
Producer::CREDIT_FUNCTIONING_OPTIONAL => Producer::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_OPTIONAL], | |||
Producer::CREDIT_FUNCTIONING_MANDATORY => Producer::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_MANDATORY], | |||
Producer::CREDIT_FUNCTIONING_USER => Producer::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_USER], | |||
], [])->hint(ProducerModel::HINT_CREDIT_FUNCTIONING); ?> | |||
<?= $form->field($model, 'use_credit_checked_default') |
@@ -22,12 +22,12 @@ use common\helpers\GlobalParam; | |||
<?= $form->field($model, 'active')->radioList([1 => 'Oui', 0 => 'Non']) ?> | |||
<?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?> | |||
<?= $form->field($model, 'reference')->textInput(['maxlength' => 255]) ?> | |||
<?= $form->field($model, 'id_product_category')->dropDownList(ProductCategoryModel::populateDropdownList()); ?> | |||
<?= $form->field($model, 'id_product_category')->dropDownList( ProductCategory::populateDropdownList()); ?> | |||
<?= $form->field($model, 'description')->textInput(['maxlength' => 255]) ?> | |||
<?= $form->field($model, 'recipe')->textarea()->label('Description longue') ?> | |||
<?= $form->field($model, 'unit') | |||
->dropDownList(ArrayHelper::map(ProductModel::$unitsArray, 'unit', 'wording')) | |||
->dropDownList(ArrayHelper::map( Product::$unitsArray, 'unit', 'wording')) | |||
->label('Unité (pièce, poids ou volume)'); ?> | |||
@@ -139,7 +139,7 @@ use common\helpers\GlobalParam; | |||
<?= $form->field($model, 'available_on_points_sale')->radioList([1 => 'Disponible', 0 => 'Indisponible']) ?> | |||
<strong id="label-availability-points-sale">Et <span><?php if($model->available_on_points_sale): ?>indisponible<?php else: ?>disponible<?php endif; ?></span> sur les points de vente</strong> | |||
<?php $pointSaleArray = PointSaleModel::find() | |||
<?php $pointSaleArray = PointSale::find() | |||
->where(['id_producer' => GlobalParam::getCurrentProducerId()]) | |||
->orderBy('is_bread_box ASC, name ASC') | |||
->all(); ?> |
@@ -116,7 +116,7 @@ $this->addButton(['label' => 'Nouveau produit <span class="glyphicon glyphicon-p | |||
'value' => function ($model) { | |||
$return = ''; | |||
if ($model->price) { | |||
$return = Price::format($model->getPriceWithTax()) . ' (' . ProductModel::strUnit($model->unit, 'wording_unit', true) . ')'; | |||
$return = Price::format($model->getPriceWithTax()) . ' (' . Product::strUnit($model->unit, 'wording_unit', true) . ')'; | |||
} | |||
return $return; |
@@ -7,7 +7,7 @@ use yii\helpers\ArrayHelper; | |||
use common\models\TaxRate; | |||
use common\models\Producer; | |||
use common\helpers\GlobalParam; | |||
use common\models\UserModel ; | |||
use common\models\ User ; | |||
?> | |||
@@ -27,10 +27,10 @@ use common\models\UserModel ; | |||
'options' => ['enctype' => 'multipart/form-data'] | |||
]); ?> | |||
<?= $form->field($model, 'id_user')->dropDownList(UserModel::populateDropdownList()); ?> | |||
<?= $form->field($model, 'id_user_group')->dropDownList(UserGroupModel::populateDropdownList()); ?> | |||
<?= $form->field($model, 'id_point_sale')->dropDownList(PointSaleModel::populateDropdownList()); ?> | |||
<?= $form->field($model, 'from_quantity')->label('À partir de la quantité ('.ProductModel::strUnit(ProductModel::getRefUnit($modelProduct->unit), 'wording').')'); ?> | |||
<?= $form->field($model, 'id_user')->dropDownList( User::populateDropdownList()); ?> | |||
<?= $form->field($model, 'id_user_group')->dropDownList( UserGroup::populateDropdownList()); ?> | |||
<?= $form->field($model, 'id_point_sale')->dropDownList(PointSale::populateDropdownList()); ?> | |||
<?= $form->field($model, 'from_quantity')->label('À partir de la quantité ('. Product::strUnit( Product::getRefUnit($modelProduct->unit), 'wording').')'); ?> | |||
<?php | |||
$producer = GlobalParam::getCurrentProducer(); | |||
@@ -44,13 +44,13 @@ use common\models\UserModel ; | |||
'template' => ' | |||
<div class="row"> | |||
<div class="col-xs-6"> | |||
<label for="product-price" class="control-label without-tax">Prix ('.ProductModel::strUnit(ProductModel::getRefUnit($modelProduct->unit), 'wording_unit').') HT</label> | |||
<label for="product-price" class="control-label without-tax">Prix ('. Product::strUnit( Product::getRefUnit($modelProduct->unit), 'wording_unit').') HT</label> | |||
<div class="input-group"> | |||
{input} <span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span> | |||
</div> | |||
</div> | |||
<div class="col-xs-6"> | |||
<label for="productprice-price-with-tax" class="control-label with-tax">Prix ('.ProductModel::strUnit(ProductModel::getRefUnit($modelProduct->unit), 'wording_unit').') TTC</label> | |||
<label for="productprice-price-with-tax" class="control-label with-tax">Prix ('. Product::strUnit( Product::getRefUnit($modelProduct->unit), 'wording_unit').') TTC</label> | |||
<div class="input-group"> | |||
<input type="text" id="productprice-price-with-tax" class="form-control" name="" value="" data-tax-rate-value="'.$taxRateValue.'"> | |||
<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span> |
@@ -106,7 +106,7 @@ $this->addBreadcrumb('Modifier'); | |||
'attribute' => 'from_quantity', | |||
'value' => function ($productPrice) { | |||
if($productPrice->from_quantity) { | |||
return $productPrice->from_quantity.' '.ProductModel::strUnit(ProductModel::getRefUnit($productPrice->product->unit), 'wording'); | |||
return $productPrice->from_quantity.' '. Product::strUnit( Product::getRefUnit($productPrice->product->unit), 'wording'); | |||
} | |||
return '' ; |
@@ -43,7 +43,7 @@ $this->addButton(['label' => 'Nouveau devis <span class="glyphicon glyphicon-plu | |||
?> | |||
<div class="quotation-index"> | |||
<?php if(QuotationModel::searchCount()): ?> | |||
<?php if(Quotation::searchCount()): ?> | |||
<?= GridView::widget([ | |||
'filterModel' => $searchModel, | |||
'dataProvider' => $dataProvider, | |||
@@ -88,7 +88,7 @@ $this->addButton(['label' => 'Nouveau devis <span class="glyphicon glyphicon-plu | |||
'attribute' => 'amount', | |||
'header' => 'Montant', | |||
'value' => function($invoice) { | |||
return $invoice->getAmountWithTax(OrderModel::AMOUNT_TOTAL, true) ; | |||
return $invoice->getAmountWithTax(Order::AMOUNT_TOTAL, true) ; | |||
} | |||
], | |||
[ |
@@ -162,7 +162,7 @@ $this->setTitle('Tableau de bord'); | |||
</td> | |||
<td><?= $order->getCartSummary() ; ?></td> | |||
<td><?= $order->getPointSaleSummary() ; ?></td> | |||
<td><?= $order->getAmountWithTax(OrderModel::AMOUNT_TOTAL, true) ; ?></td> | |||
<td><?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true) ; ?></td> | |||
<td class="history"><?= $order->getStrHistory() ; ?></td> | |||
</tr> | |||
<?php endforeach; ?> |
@@ -39,7 +39,7 @@ termes. | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use yii\helpers\ArrayHelper ; | |||
use common\models\UserModel ; | |||
use common\models\ User ; | |||
use common\models\PointSale ; | |||
use common\helpers\GlobalParam ; | |||
@@ -53,7 +53,7 @@ use common\helpers\GlobalParam ; | |||
<?= $form->field($model, 'id')->hiddenInput() ?> | |||
<?php endif; ?> | |||
<div class="col-md-5" id="bloc-select-user"> | |||
<?= $form->field($model, 'id_user')->dropDownList(UserModel::populateDropdownList(), ['class' => 'select2']); ?> | |||
<?= $form->field($model, 'id_user')->dropDownList( User::populateDropdownList(), ['class' => 'select2']); ?> | |||
</div> | |||
<div class="col-md-1" id="or-user"> | |||
<span>OU</span> | |||
@@ -64,7 +64,7 @@ use common\helpers\GlobalParam ; | |||
<div class="clr"></div> | |||
<?= $form->field($model, 'id_producer')->hiddenInput() ?> | |||
<?= $form->field($model, 'id_point_sale')->dropDownList(ArrayHelper::map(PointSaleModel::searchAll(), 'id', function($model, $defaultValue) { | |||
<?= $form->field($model, 'id_point_sale')->dropDownList(ArrayHelper::map(PointSale::searchAll(), 'id', function($model, $defaultValue) { | |||
return $model['name']; | |||
}), ['prompt' => '--','class' => 'form-control user-id']) ?> | |||
<?= $form->field($model, 'date_begin') ?> | |||
@@ -84,9 +84,9 @@ use common\helpers\GlobalParam ; | |||
<?= $form->field($model, 'auto_payment') | |||
->dropDownList([ | |||
SubscriptionModel::AUTO_PAYMENT_DEDUCTED => 'Déduit', | |||
SubscriptionModel::AUTO_PAYMENT_YES => 'Oui', | |||
SubscriptionModel::AUTO_PAYMENT_NO => 'Non' | |||
Subscription::AUTO_PAYMENT_DEDUCTED => 'Déduit', | |||
Subscription::AUTO_PAYMENT_YES => 'Oui', | |||
Subscription::AUTO_PAYMENT_NO => 'Non' | |||
]) | |||
->hint('Attention, un compte client existant doit être spécifié en haut de ce formulaire.') ?> | |||
@@ -46,7 +46,7 @@ $this->setTitle('Abonnements') ; | |||
$this->addBreadcrumb($this->getTitle()) ; | |||
$this->addButton(['label' => 'Nouvel abonnement <span class="glyphicon glyphicon-plus"></span>', 'url' => 'subscription/create', 'class' => 'btn btn-primary']) ; | |||
$subscriptionsArray = SubscriptionModel::searchAll() ; | |||
$subscriptionsArray = Subscription::searchAll() ; | |||
@@ -82,7 +82,7 @@ $subscriptionsArray = SubscriptionModel::searchAll() ; | |||
foreach($model->productSubscription as $productSubscription) | |||
{ | |||
if(isset($productSubscription->product)) { | |||
$html .= Html::encode($productSubscription->product->name).' ('.($productSubscription->quantity * ProductModel::$unitsArray[$productSubscription->product->unit]['coefficient']).' '.ProductModel::strUnit($productSubscription->product->unit, 'wording_short').')<br />' ; | |||
$html .= Html::encode($productSubscription->product->name).' ('.($productSubscription->quantity * Product::$unitsArray[$productSubscription->product->unit]['coefficient']).' '. Product::strUnit($productSubscription->product->unit, 'wording_short').')<br />' ; | |||
} | |||
else { | |||
$html .= 'Produit non défini<br />' ; | |||
@@ -102,7 +102,7 @@ $subscriptionsArray = SubscriptionModel::searchAll() ; | |||
'attribute' => 'id_point_sale', | |||
'label' => 'Point de vente', | |||
'format' => 'raw', | |||
'filter' => ArrayHelper::map(PointSaleModel::find()->where(['id_producer' => GlobalParam::getCurrentProducerId()])->asArray()->all(), 'id', 'name'), | |||
'filter' => ArrayHelper::map(PointSale::find()->where(['id_producer' => GlobalParam::getCurrentProducerId()])->asArray()->all(), 'id', 'name'), | |||
'value' => function($model) { | |||
return Html::encode($model->pointSale->name) ; | |||
} |
@@ -38,7 +38,7 @@ | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\models\UserModel; | |||
use common\models\ User; | |||
use common\models\Producer; | |||
use common\models\Distribution; | |||
@@ -52,7 +52,7 @@ use common\models\ProductPrice ; | |||
]); ?> | |||
<?= $form->field($model, 'type') | |||
->dropDownList(UserModel::getTypeChoicesArray(), [ | |||
->dropDownList( User::getTypeChoicesArray(), [ | |||
'v-model' => 'type' | |||
]) ; ?> | |||
<?= $form->field($model, 'name_legal_person', ['options' => ['v-show' => "type == 'legal-person'"]])->textInput() ?> | |||
@@ -88,7 +88,7 @@ use common\models\ProductPrice ; | |||
?> | |||
<?php /* $form->field($model, 'product_price_percent') | |||
->dropDownList(ProductPriceModel::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit pour cet utilisateur.');*/ ?> | |||
->dropDownList( ProductPrice::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit pour cet utilisateur.');*/ ?> | |||
<div class="form-group"> | |||
<?= Html::submitButton($model->isNewRecord ? 'Ajouter' : 'Modifier', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> |
@@ -54,7 +54,7 @@ $this->addBreadcrumb('Créditer') ; | |||
<div class="user-credit"> | |||
<?php | |||
$producer = ProducerModel::searchOne([ | |||
$producer = Producer::searchOne([ | |||
'id' => GlobalParam::getCurrentProducerId() | |||
]); | |||
@@ -89,8 +89,8 @@ $this->addBreadcrumb('Créditer') ; | |||
<div class="panel-body"> | |||
<?php $form = ActiveForm::begin(); ?> | |||
<?= $form->field($creditForm, 'type')->dropDownList([ | |||
CreditHistoryModel::TYPE_CREDIT => 'Crédit', | |||
CreditHistoryModel::TYPE_DEBIT => 'Débit', | |||
CreditHistory::TYPE_CREDIT => 'Crédit', | |||
CreditHistory::TYPE_DEBIT => 'Débit', | |||
]) ?> | |||
<?= $form->field($creditForm, 'amount')->textInput() ?> | |||
<?= $form->field($creditForm, 'mean_payment')->dropDownList([ |
@@ -38,7 +38,7 @@ | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\models\UserModel; | |||
use common\models\ User; | |||
use common\models\Order; | |||
$this->setTitle('Utilisateurs'); | |||
@@ -67,14 +67,14 @@ $this->render('_menu', [ | |||
'attribute' => 'username', | |||
'label' => 'Nom', | |||
'value' => function ($model) { | |||
return UserModel::getUsernameFromArray($model); | |||
return User::getUsernameFromArray($model); | |||
} | |||
], | |||
[ | |||
'attribute' => 'type', | |||
'label' => 'Type', | |||
'value' => function ($model) { | |||
$typeArray = UserModel::getTypeChoicesArray(); | |||
$typeArray = User::getTypeChoicesArray(); | |||
if(isset($typeArray[$model['type']])) { | |||
return $typeArray[$model['type']]; | |||
} | |||
@@ -107,7 +107,7 @@ $this->render('_menu', [ | |||
'buttons' => [ | |||
'orders' => function ($url, $model) { | |||
$url = Yii::$app->urlManager->createUrl(['user/orders', 'id' => $model['id']]); | |||
$countOrders = OrderModel::searchCount([ | |||
$countOrders = Order::searchCount([ | |||
'id_user' => $model['id'], | |||
], ['conditions' => 'date_delete IS NULL']); | |||
@@ -129,7 +129,7 @@ $this->render('_menu', [ | |||
'format' => 'raw', | |||
'value' => function ($model) use ($producer) { | |||
$userProducer = UserProducerModel::searchOne([ | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $model->id | |||
]); | |||
$credit = $userProducer ? $userProducer->credit : 0; | |||
@@ -159,7 +159,7 @@ $this->render('_menu', [ | |||
'buttons' => [ | |||
'update' => function ($url, $model) { | |||
$url = Yii::$app->urlManager->createUrl(['user/update', 'id' => $model->id]); | |||
$user = UserModel::find()->with('userProducer')->where(['id' => $model->id])->one(); | |||
$user = User::find()->with('userProducer')->where(['id' => $model->id])->one(); | |||
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | |||
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default' | |||
]); |
@@ -61,7 +61,7 @@ return [ | |||
], | |||
'user' => [ | |||
'class' => 'yii\web\User', | |||
'identityClass' => 'common\logic\User\User\UserModel', | |||
'identityClass' => 'common\logic\User\User\User', | |||
'enableAutoLogin' => true, | |||
'identityCookie' => [ | |||
'name' => 'distrib', |
@@ -39,7 +39,7 @@ termes. | |||
namespace common\controllers; | |||
use common\components\BusinessLogic; | |||
use common\logic\User\User\UserModel; | |||
use common\logic\User\User\User; | |||
use yii; | |||
class CommonController extends \yii\web\Controller |
@@ -39,7 +39,7 @@ termes. | |||
namespace common\forms; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\logic\User\User\UserModel; | |||
use common\logic\User\User\User; | |||
use Yii; | |||
use yii\base\Model; | |||
@@ -119,14 +119,14 @@ class LoginForm extends Model | |||
* Finds user by [[username]] | |||
* | |||
*/ | |||
public function getUser(): UserModel | |||
public function getUser(): User | |||
{ | |||
if ($this->_user === false) { | |||
$this->_user = UserModel::searchOne( | |||
$this->_user = User::searchOne( | |||
['email' => $this->email], | |||
[ | |||
'conditions' => 'type LIKE :type_individual OR type LIKE :type_legal_person', | |||
'params' => [':type_individual' => UserModel::TYPE_INDIVIDUAL, ':type_legal_person' => UserModel::TYPE_LEGAL_PERSON] | |||
'params' => [':type_individual' => User::TYPE_INDIVIDUAL, ':type_legal_person' => User::TYPE_LEGAL_PERSON] | |||
] | |||
); | |||
} |
@@ -118,7 +118,7 @@ class SubscriptionForm extends Model | |||
public function save() | |||
{ | |||
if ($this->id) { | |||
$subscription = SubscriptionModel::searchOne(['id' => $this->id]) ; | |||
$subscription = Subscription::searchOne(['id' => $this->id]) ; | |||
} | |||
else { | |||
$subscription = new Subscription ; | |||
@@ -156,19 +156,19 @@ class SubscriptionForm extends Model | |||
// produits | |||
if ($this->id) { | |||
$productsSubscriptionsArray = ProductSubscriptionModel::findAll(['id_subscription' => $this->id]) ; | |||
ProductSubscriptionModel::deleteAll(['id_subscription' => $this->id]); | |||
$productsSubscriptionsArray = ProductSubscription::findAll(['id_subscription' => $this->id]) ; | |||
ProductSubscription::deleteAll(['id_subscription' => $this->id]); | |||
} | |||
foreach ($this->products as $nameInput => $quantity) { | |||
if ($quantity) { | |||
$idProduct = (int) str_replace('product_', '', $nameInput); | |||
$product = ProductModel::findOne($idProduct) ; | |||
$product = Product::findOne($idProduct) ; | |||
$newProductSubscription = new ProductSubscription; | |||
$newProductSubscription->id_subscription = $subscription->id; | |||
$newProductSubscription->id_product = $idProduct; | |||
$newProductSubscription->quantity = $quantity / ProductModel::$unitsArray[$product->unit]['coefficient']; | |||
$newProductSubscription->quantity = $quantity / Product::$unitsArray[$product->unit]['coefficient']; | |||
$newProductSubscription->save(); | |||
} |
@@ -56,18 +56,18 @@ class Price | |||
return floatval($priceWithTax) / ($taxRate + 1); | |||
} | |||
public static function getPriceWithTax($priceWithoutTax, $taxRate, $taxCalculationMethod = DocumentModel::TAX_CALCULATION_METHOD_DEFAULT) | |||
public static function getPriceWithTax($priceWithoutTax, $taxRate, $taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT) | |||
{ | |||
$vat = self::getVat($priceWithoutTax, $taxRate, $taxCalculationMethod); | |||
return self::numberTwoDecimals(self::round($priceWithoutTax + $vat)); | |||
} | |||
public static function getVat($priceTotalWithoutTax, $taxRate, $taxCalculationMethod = DocumentModel::TAX_CALCULATION_METHOD_DEFAULT) | |||
public static function getVat($priceTotalWithoutTax, $taxRate, $taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT) | |||
{ | |||
$vat = $priceTotalWithoutTax * $taxRate; | |||
if($taxCalculationMethod == DocumentModel::TAX_CALCULATION_METHOD_SUM_OF_ROUNDINGS) { | |||
if($taxCalculationMethod == Document::TAX_CALCULATION_METHOD_SUM_OF_ROUNDINGS) { | |||
$vat = self::round($vat); | |||
} | |||
@@ -80,7 +80,7 @@ class Tiller | |||
{ | |||
if ($this->producer_tiller) { | |||
$ordersTiller = $this->getOrders($date); | |||
$ordersOpendistrib = OrderModel::searchAll([ | |||
$ordersOpendistrib = Order::searchAll([ | |||
'distribution.date' => $date, | |||
'order.tiller_synchronization' => 1 | |||
], [ | |||
@@ -96,7 +96,7 @@ class Tiller | |||
foreach ($ordersTiller->orders as $orderTiller) { | |||
if ($orderOpendistrib->tiller_external_id == $orderTiller->id) { | |||
$amountTotalOrderOpendistrib = (int)round( | |||
$orderOpendistrib->getAmountWithTax(OrderModel::AMOUNT_TOTAL) * 100 | |||
$orderOpendistrib->getAmountWithTax(Order::AMOUNT_TOTAL) * 100 | |||
); | |||
if ($amountTotalOrderOpendistrib == (int)$orderTiller->currentPayedAmount | |||
|| $amountTotalOrderOpendistrib == (int)$orderTiller->currentBill) { |
@@ -40,7 +40,7 @@ namespace common\logic\Distribution\Distribution; | |||
use common\logic\Distribution\PointSaleDistribution\PointSaleDistribution; | |||
use common\logic\Distribution\ProductDistribution\ProductDistribution; | |||
use common\logic\Order\Order\OrderModel; | |||
use common\logic\Order\Order\Order; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\helpers\GlobalParam; | |||
use common\components\ActiveRecordCommon; | |||
@@ -67,8 +67,8 @@ class Distribution extends ActiveRecordCommon | |||
{ | |||
return [ | |||
[['date'], 'required'], | |||
[['active'], 'integer'], | |||
[['date'], 'safe'], | |||
[['active'], 'integer'] | |||
]; | |||
} | |||
@@ -95,7 +95,7 @@ class Distribution extends ActiveRecordCommon | |||
public function getOrder() | |||
{ | |||
return $this->hasMany(OrderModel::class, ['id_distribution' => 'id']); | |||
return $this->hasMany(Order::class, ['id_distribution' => 'id']); | |||
} | |||
public function getProductDistribution() | |||
@@ -115,7 +115,7 @@ class Distribution extends ActiveRecordCommon | |||
*/ | |||
public static function linkProductIncomingDistributions($product) | |||
{ | |||
$distributionsArray = self::getIncomingDistributions(); | |||
$distributionsArray = self::getIncoming(); | |||
foreach ($distributionsArray as $distribution) { | |||
$distribution->linkProduct($product); | |||
} | |||
@@ -128,7 +128,7 @@ class Distribution extends ActiveRecordCommon | |||
*/ | |||
public static function linkPointSaleIncomingDistributions($pointSale) | |||
{ | |||
$distributionsArray = self::getIncomingDistributions(); | |||
$distributionsArray = self::getIncoming(); | |||
foreach ($distributionsArray as $distribution) { | |||
$distribution->linkPointSale($pointSale); | |||
} | |||
@@ -197,7 +197,7 @@ class Distribution extends ActiveRecordCommon | |||
if ($active) { | |||
// ajout des abonnements | |||
SubscriptionModel::addAll($this->date); | |||
Subscription::addAll($this->date); | |||
} | |||
} | |||
@@ -2,28 +2,38 @@ | |||
namespace common\logic\Distribution\Distribution; | |||
use common\helpers\GlobalParam; | |||
use common\logic\BaseService; | |||
use common\logic\BuilderInterface; | |||
use common\logic\Distribution\PointSaleDistribution\PointSaleDistribution; | |||
use common\logic\Distribution\PointSaleDistribution\PointSaleDistributionBuilder; | |||
use common\logic\Distribution\PointSaleDistribution\PointSaleDistributionRepository; | |||
use common\logic\Distribution\ProductDistribution\ProductDistribution; | |||
use common\logic\Order\Order\OrderModel; | |||
use common\logic\Distribution\ProductDistribution\ProductDistributionBuilder; | |||
use common\logic\Distribution\ProductDistribution\ProductDistributionRepository; | |||
use common\logic\Order\Order\Order; | |||
use common\logic\Order\Order\OrderRepository; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\logic\Product\Product\Product; | |||
use common\logic\Product\Product\ProductRepository; | |||
use common\logic\User\UserProducer\UserProducer; | |||
class DistributionBuilder extends BaseService implements BuilderInterface | |||
{ | |||
protected DistributionRepository $distributionRepository; | |||
protected PointSaleDistributionRepository $pointSaleDistributionRepository; | |||
protected PointSaleDistributionBuilder $pointSaleDistributionBuilder; | |||
protected ProductRepository $productRepository; | |||
protected ProductDistributionRepository $productDistributionRepository; | |||
protected ProductDistributionBuilder $productDistributionBuilder; | |||
protected OrderRepository $orderRepository; | |||
public function __construct() | |||
{ | |||
$this->distributionRepository = $this->loadService(DistributionRepository::class); | |||
$this->pointSaleDistributionRepository = $this->loadService(PointSaleDistributionRepository::class); | |||
$this->pointSaleDistributionBuilder = $this->loadService(PointSaleDistributionBuilder::class); | |||
$this->productRepository = $this->loadService(ProductRepository::class); | |||
$this->productDistributionRepository = $this->loadService(ProductDistributionRepository::class); | |||
$this->orderRepository = $this->loadService(OrderRepository::class); | |||
} | |||
public function instanciate(Producer $producer, string $date, bool $delivery = true): Distribution | |||
@@ -37,11 +47,15 @@ class DistributionBuilder extends BaseService implements BuilderInterface | |||
return $distribution; | |||
} | |||
public function create(Producer $producer, string $date, int $delivery = 1): Distribution | |||
// initDistribution | |||
public function create(Producer $producer, string $date, bool $delivery = true): Distribution | |||
{ | |||
$distribution = $this->instanciate($producer, $date, 1); | |||
$distribution = $this->instanciate($producer, $date, $delivery); | |||
$distribution->save(); | |||
$this->initPointSaleDistribution($distribution); | |||
$this->initProductDistribution($distribution); | |||
return $distribution; | |||
} | |||
@@ -56,45 +70,21 @@ class DistributionBuilder extends BaseService implements BuilderInterface | |||
return $distribution; | |||
} | |||
/** | |||
* Initialise un jour de production. | |||
*/ | |||
// initDistribution | |||
public function init(string $date, Producer $producer = null): Distribution | |||
{ | |||
$distribution = null; | |||
if ($date != '') { | |||
if (!$producer) { | |||
$producer = GlobalParam::getCurrentProducer(); | |||
} | |||
$distribution = $this->createIfNotExist($producer, $date, 1); | |||
} | |||
if ($distribution) { | |||
$this->initPointSaleDistribution($distribution); | |||
$this->initProductDistribution($distribution); | |||
} | |||
return $distribution; | |||
} | |||
public function initPointSaleDistribution(Distribution $distribution): void | |||
{ | |||
$countPointSaleDistribution = $this->pointSaleDistributionRepository->countByDistribution($distribution); | |||
if (!$countPointSaleDistribution) { | |||
$this->pointSaleDistributionBuilder->initAll($distribution, true); | |||
$this->pointSaleDistributionBuilder->createAll($distribution, true); | |||
} | |||
} | |||
public function initProductDistribution(Distribution $distribution) | |||
public function initProductDistribution(Distribution $distribution): void | |||
{ | |||
$products = Product::searchAll(); | |||
$productArray = $this->productRepository->get(); | |||
$countProductDistribution = $this->productDistributionRepository->countByDistribution($distribution); | |||
$productsDistribution = ProductDistribution::searchAll([ | |||
'id_distribution' => $distribution->id | |||
]); | |||
if (!count($productsDistribution)) { | |||
foreach ($products as $product) { | |||
if (!$countProductDistribution) { | |||
foreach ($productArray as $product) { | |||
$this->linkProduct($distribution, $product); | |||
} | |||
} | |||
@@ -105,49 +95,16 @@ class DistributionBuilder extends BaseService implements BuilderInterface | |||
*/ | |||
public function linkProduct(Distribution $distribution, Product $product): ProductDistribution | |||
{ | |||
$productDistribution = ProductDistribution::searchOne([ | |||
'id_distribution' => $this->id, | |||
'id_product' => $product->id | |||
]); | |||
if (!$productDistribution) { | |||
$productDistribution = new ProductDistribution(); | |||
$productDistribution->id_distribution = $this->id; | |||
$productDistribution->id_product = $product->id; | |||
} | |||
$productDistribution = $this->productDistributionBuilder->createIfNotExist($distribution, $product); | |||
$this->updateOrderProductPrices($distribution, $product); | |||
$dayDistribution = date('N', strtotime($this->date)); | |||
$daysArray = [ | |||
1 => 'monday', | |||
2 => 'tuesday', | |||
3 => 'wednesday', | |||
4 => 'thursday', | |||
5 => 'friday', | |||
6 => 'saturday', | |||
7 => 'sunday', | |||
]; | |||
$productDistribution->active = 0; | |||
$day = $daysArray[$dayDistribution]; | |||
if ($product->active && $product->$day) { | |||
$productDistribution->active = 1; | |||
} | |||
return $productDistribution; | |||
} | |||
public function updateOrderProductPrices(Distribution $distribution, Product $product): void | |||
{ | |||
$ordersArray = $this->orderRepository->getByDistribution($distribution, 'AND origin != "user"'); | |||
$productDistribution->quantity_max = $product->quantity_max; | |||
$fieldQuantityMax = 'quantity_max_' . $day; | |||
if (isset($product->$fieldQuantityMax) && $product->$fieldQuantityMax > 0) { | |||
$productDistribution->quantity_max = $product->$fieldQuantityMax; | |||
} | |||
$productDistribution->save(); | |||
// update prices product order | |||
$ordersArray = OrderModel::searchAll([ | |||
'distribution.date' => $this->date, | |||
'distribution.id_producer' => $this->id_producer | |||
], | |||
[ | |||
'conditions' => 'date_delete IS NULL AND origin != "user"' | |||
]); | |||
if ($ordersArray) { | |||
foreach ($ordersArray as $order) { | |||
foreach ($order->productOrder as $productOrder) { | |||
@@ -158,7 +115,7 @@ class DistributionBuilder extends BaseService implements BuilderInterface | |||
$userProducer = false; | |||
if (isset($order->user) && $order->user) { | |||
$user = $order->user; | |||
$userProducer = UserProducerModel::searchOne([ | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $user->id, | |||
'id_producer' => $order->distribution->id_producer | |||
]); | |||
@@ -176,7 +133,5 @@ class DistributionBuilder extends BaseService implements BuilderInterface | |||
} | |||
} | |||
} | |||
return $productDistribution; | |||
} | |||
} |
@@ -35,7 +35,7 @@ class DistributionRepository extends BaseService implements RepositoryInterface | |||
/** | |||
* Récupère les distributions futures. | |||
*/ | |||
public function getIncomingDistributions(): array | |||
public function getIncoming(): array | |||
{ | |||
$distributionsArray = Distribution::find() | |||
->where('date > \'' . date('Y-m-d') . '\'') |
@@ -9,6 +9,23 @@ use common\logic\SolverInterface; | |||
class DistributionSolver extends BaseService implements SolverInterface | |||
{ | |||
public function getDayAsString(Distribution $distribution): string | |||
{ | |||
$dayDistribution = date('N', strtotime($distribution->date)); | |||
$daysArray = [ | |||
1 => 'monday', | |||
2 => 'tuesday', | |||
3 => 'wednesday', | |||
4 => 'thursday', | |||
5 => 'friday', | |||
6 => 'saturday', | |||
7 => 'sunday', | |||
]; | |||
return $daysArray[$dayDistribution]; | |||
} | |||
/** | |||
* Déduit si un produit est actif ou non | |||
*/ |
@@ -92,7 +92,7 @@ class PointSaleDistribution extends ActiveRecordCommon | |||
public function getPointSale() | |||
{ | |||
return $this->hasOne(PointSaleModel::className(), ['id' => 'id_point_sale']); | |||
return $this->hasOne(PointSale::className(), ['id' => 'id_point_sale']); | |||
} | |||
/** |
@@ -38,7 +38,7 @@ class PointSaleDistributionBuilder extends BaseService implements BuilderInterfa | |||
* Initialise les PointSaleDistribution pour une distribution donnée. | |||
*/ | |||
// setAll | |||
public function initAll(Distribution $distribution, bool $delivery): void | |||
public function createAll(Distribution $distribution, bool $delivery): void | |||
{ | |||
$arrPointsSale = PointSale::find() | |||
->with(['pointSaleDistribution' => function($q) use ($distribution) { |
@@ -76,7 +76,7 @@ class ProductDistribution extends ActiveRecordCommon | |||
public function getProduct() | |||
{ | |||
return $this->hasOne(ProductModel::className(), ['id' => 'id_product']); | |||
return $this->hasOne( Product::className(), ['id' => 'id_product']); | |||
} | |||
public function getDistribution() | |||
@@ -124,7 +124,7 @@ class ProductDistribution extends ActiveRecordCommon | |||
'id_distribution' => $idDistribution | |||
]) ; | |||
$orders = OrderModel::searchAll([ | |||
$orders = Order::searchAll([ | |||
'distribution.id' => $idDistribution | |||
]) ; | |||
@@ -134,8 +134,8 @@ class ProductDistribution extends ActiveRecordCommon | |||
'active' => (int) $productDistribution->active, | |||
'unavailable' => (int) $productDistribution->product->unavailable, | |||
'quantity_max' => $productDistribution->quantity_max, | |||
'quantity_order' => OrderModel::getProductQuantity($productDistribution->id_product, $orders), | |||
'quantity_remaining' => $productDistribution->quantity_max - OrderModel::getProductQuantity($productDistribution->id_product, $orders) | |||
'quantity_order' => Order::getProductQuantity($productDistribution->id_product, $orders), | |||
'quantity_remaining' => $productDistribution->quantity_max - Order::getProductQuantity($productDistribution->id_product, $orders) | |||
]; | |||
} | |||
} |
@@ -3,14 +3,80 @@ | |||
namespace common\logic\Distribution\ProductDistribution; | |||
use common\logic\BaseService; | |||
use common\logic\Distribution\Distribution\Distribution; | |||
use common\logic\Distribution\Distribution\DistributionSolver; | |||
use common\logic\FactoryInterface; | |||
use common\logic\Product\Product\Product; | |||
class ProductDistributionBuilder extends BaseService implements FactoryInterface | |||
{ | |||
public function create(): ProductDistribution | |||
protected ProductDistributionRepository $productDistributionRepository; | |||
protected DistributionSolver $distributionSolver; | |||
public function __construct() | |||
{ | |||
$this->productDistributionRepository = $this->loadService(ProductDistributionRepository::class); | |||
$this->distributionSolver = $this->loadService(DistributionSolver::class); | |||
} | |||
public function instanciate(Distribution $distribution, Product $product): ProductDistribution | |||
{ | |||
$productDistribution = new ProductDistribution(); | |||
$productDistribution->populateRelation('distribution', $distribution); | |||
$productDistribution->id_distribution = $distribution->id; | |||
$productDistribution->populateRelation('product', $product); | |||
$productDistribution->id_product = $product->id; | |||
return $productDistribution; | |||
} | |||
public function create(Distribution $distribution, Product $product): ProductDistribution | |||
{ | |||
$productDistribution = $this->instanciate($distribution, $product); | |||
$this | |||
->initActive($productDistribution) | |||
->initQuantityMax($productDistribution); | |||
$productDistribution->save(); | |||
} | |||
public function createIfNotExist(Distribution $distribution, Product $product): ProductDistribution | |||
{ | |||
$productDistribution = $this->productDistributionRepository->getOne($distribution, $product); | |||
if(!$productDistribution) { | |||
$productDistribution = $this->create($distribution, $product); | |||
} | |||
return $productDistribution; | |||
} | |||
public function initActive(ProductDistribution $productDistribution): ProductDistribution | |||
{ | |||
$day = $this->distributionSolver->getDayAsString($productDistribution->distribution); | |||
$productDistribution->active = 0; | |||
if ($productDistribution->product->active && $productDistribution->product->$day) { | |||
$productDistribution->active = 1; | |||
} | |||
return $productDistribution; | |||
} | |||
public function initQuantityMax(ProductDistribution $productDistribution): ProductDistribution | |||
{ | |||
$product = $productDistribution->product; | |||
$day = $this->distributionSolver->getDayAsString($productDistribution->distribution); | |||
$productDistribution->quantity_max = $product->quantity_max; | |||
$fieldQuantityMax = 'quantity_max_' . $day; | |||
if (isset($product->$fieldQuantityMax) && $product->$fieldQuantityMax > 0) { | |||
$productDistribution->quantity_max = $product->$fieldQuantityMax; | |||
} | |||
return $productDistribution; | |||
} | |||
} |
@@ -3,9 +3,24 @@ | |||
namespace common\logic\Distribution\ProductDistribution; | |||
use common\logic\BaseService; | |||
use common\logic\Distribution\Distribution\Distribution; | |||
use common\logic\Product\Product\Product; | |||
use common\logic\RepositoryInterface; | |||
class ProductDistributionRepository extends BaseService implements RepositoryInterface | |||
{ | |||
public function countByDistribution(Distribution $distribution): int | |||
{ | |||
return ProductDistribution::searchCount([ | |||
'id_distribution' => $distribution->id | |||
]); | |||
} | |||
public function getOne(Distribution $distribution, Product $product): ?ProductDistribution | |||
{ | |||
return ProductDistribution::searchOne([ | |||
'id_distribution' => $distribution->id, | |||
'id_product' => $product->id | |||
]); | |||
} | |||
} |
@@ -55,7 +55,7 @@ use Yii; | |||
* @property string $city | |||
* @property string $postcode | |||
*/ | |||
class DeliveryNoteModel extends Document | |||
class DeliveryNote extends Document | |||
{ | |||
/** | |||
@@ -114,7 +114,7 @@ class DeliveryNoteModel extends Document | |||
$idInvoice = $this->getInvoiceId(); | |||
if($idInvoice) { | |||
$invoice = InvoiceModel::searchOne([ | |||
$invoice = Invoice::searchOne([ | |||
'id' => $idInvoice | |||
]); | |||
} |
@@ -8,7 +8,7 @@ class DeliveryNoteContainer implements ContainerInterface | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
return DeliveryNoteModel::class; | |||
return DeliveryNote::class; | |||
} | |||
public function getServices(): array |
@@ -7,9 +7,9 @@ use common\logic\FactoryInterface; | |||
class DeliveryNoteFactory extends BaseService implements FactoryInterface | |||
{ | |||
public function create(): DeliveryNoteModel | |||
public function create(): DeliveryNote | |||
{ | |||
$deliveryNote = new DeliveryNoteModel(); | |||
$deliveryNote = new DeliveryNote(); | |||
return $deliveryNote; | |||
} |
@@ -41,7 +41,7 @@ namespace common\logic\Document\DeliveryNote; | |||
use common\helpers\GlobalParam; | |||
use yii\data\ActiveDataProvider; | |||
class DeliveryNoteSearch extends DeliveryNoteModel | |||
class DeliveryNoteSearch extends DeliveryNote | |||
{ | |||
public $id_point_sale ; | |||
public $date_distribution ; | |||
@@ -60,7 +60,7 @@ class DeliveryNoteSearch extends DeliveryNoteModel | |||
{ | |||
$optionsSearch = self::defaultOptionsSearch(); | |||
$query = DeliveryNoteModel::find() | |||
$query = DeliveryNote::find() | |||
->with($optionsSearch['with']) | |||
->joinWith($optionsSearch['join_with']) | |||
->where(['delivery_note.id_producer' => GlobalParam::getCurrentProducerId()]) |
@@ -44,7 +44,7 @@ use common\logic\Producer\Producer\Producer; | |||
use kartik\mpdf\Pdf; | |||
use yii\base\ErrorException; | |||
class DocumentModel extends ActiveRecordCommon | |||
class Document extends ActiveRecordCommon | |||
{ | |||
const STATUS_DRAFT = 'draft'; | |||
const STATUS_VALID = 'valid'; | |||
@@ -100,7 +100,7 @@ class DocumentModel extends ActiveRecordCommon | |||
public function getUser() | |||
{ | |||
return $this->hasOne(UserModel::className(), ['id' => 'id_user']); | |||
return $this->hasOne( User::className(), ['id' => 'id_user']); | |||
} | |||
public function getProducer() | |||
@@ -110,9 +110,9 @@ class DocumentModel extends ActiveRecordCommon | |||
public function relationOrders($fieldIdDocument) | |||
{ | |||
$defaultOptionsSearch = OrderModel::defaultOptionsSearch(); | |||
$defaultOptionsSearch = Order::defaultOptionsSearch(); | |||
return $this->hasMany(OrderModel::className(), [$fieldIdDocument => 'id']) | |||
return $this->hasMany(Order::className(), [$fieldIdDocument => 'id']) | |||
->with($defaultOptionsSearch['with']) | |||
->joinWith($defaultOptionsSearch['join_with']) | |||
->orderBy('distribution.date ASC'); | |||
@@ -122,17 +122,17 @@ class DocumentModel extends ActiveRecordCommon | |||
* Méthodes | |||
*/ | |||
public function getAmount($type = OrderModel::AMOUNT_TOTAL, $format = false) | |||
public function getAmount($type = Order::AMOUNT_TOTAL, $format = false) | |||
{ | |||
return $this->_getAmountGeneric($type, false, $format); | |||
} | |||
public function getAmountWithTax($type = OrderModel::AMOUNT_TOTAL, $format = false) | |||
public function getAmountWithTax($type = Order::AMOUNT_TOTAL, $format = false) | |||
{ | |||
return $this->_getAmountGeneric($type, true, $format); | |||
} | |||
protected function _getAmountGeneric($type = OrderModel::AMOUNT_TOTAL, $withTax = true, $format = false) | |||
protected function _getAmountGeneric($type = Order::AMOUNT_TOTAL, $withTax = true, $format = false) | |||
{ | |||
$amount = 0; | |||
$totalVat = 0; | |||
@@ -262,7 +262,7 @@ class DocumentModel extends ActiveRecordCommon | |||
} | |||
$prefix = Producer::getConfig('document_' . $classLower . '_prefix'); | |||
$oneDocumentExist = $class::searchOne(['status' => DocumentModel::STATUS_VALID], ['orderby' => 'reference DESC']); | |||
$oneDocumentExist = $class::searchOne(['status' => Document::STATUS_VALID], ['orderby' => 'reference DESC']); | |||
if ($oneDocumentExist) { | |||
$reference = $oneDocumentExist->reference; | |||
@@ -380,7 +380,7 @@ class DocumentModel extends ActiveRecordCommon | |||
public function changeStatus($status) | |||
{ | |||
if ($status == DocumentModel::STATUS_VALID) { | |||
if ($status == Document::STATUS_VALID) { | |||
$this->status = $status; | |||
$this->reference = $this->generateReference(); | |||
} |
@@ -8,7 +8,7 @@ class DocumentContainer implements ContainerInterface | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
return DocumentModel::class; | |||
return Document::class; | |||
} | |||
public function getServices(): array |
@@ -38,7 +38,7 @@ termes. | |||
namespace common\logic\Document\Invoice; | |||
use common\logic\Document\Document\DocumentModel; | |||
use common\logic\Document\Document\Document; | |||
/** | |||
* This is the model class for table "invoice". | |||
@@ -53,7 +53,7 @@ use common\logic\Document\Document\DocumentModel; | |||
* @property string $city | |||
* @property string $postcode | |||
*/ | |||
class InvoiceModel extends DocumentModel | |||
class Invoice extends Document | |||
{ | |||
public $deliveryNotes ; |
@@ -10,7 +10,7 @@ class InvoiceContainer implements ContainerInterface | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
return InvoiceModel::class; | |||
return Invoice::class; | |||
} | |||
public function getServices(): array |
@@ -7,9 +7,9 @@ use common\logic\FactoryInterface; | |||
class InvoiceFactory extends BaseService implements FactoryInterface | |||
{ | |||
public function create(): InvoiceModel | |||
public function create(): Invoice | |||
{ | |||
$invoice = new InvoiceModel(); | |||
$invoice = new Invoice(); | |||
return $invoice; | |||
} |
@@ -40,7 +40,7 @@ namespace common\logic\Document\Invoice; | |||
use common\helpers\GlobalParam; | |||
class InvoiceSearch extends InvoiceModel | |||
class InvoiceSearch extends Invoice | |||
{ | |||
var $username; | |||
@@ -57,7 +57,7 @@ class InvoiceSearch extends InvoiceModel | |||
{ | |||
$optionsSearch = self::defaultOptionsSearch(); | |||
$query = InvoiceModel::find() | |||
$query = Invoice::find() | |||
->with($optionsSearch['with']) | |||
->joinWith($optionsSearch['join_with']) | |||
->where(['invoice.id_producer' => GlobalParam::getCurrentProducerId()]) |
@@ -38,7 +38,7 @@ | |||
namespace common\logic\Document\Quotation; | |||
use common\logic\Document\Document\DocumentModel; | |||
use common\logic\Document\Document\Document; | |||
/** | |||
* This is the model class for table "quotation". | |||
@@ -53,7 +53,7 @@ use common\logic\Document\Document\DocumentModel; | |||
* @property string $city | |||
* @property string $postcode | |||
*/ | |||
class QuotationModel extends DocumentModel | |||
class Quotation extends Document | |||
{ | |||
/** |
@@ -6,13 +6,13 @@ use common\logic\ContainerInterface; | |||
use common\logic\Document\Document\DocumentBuilder; | |||
use common\logic\Document\Document\DocumentSolver; | |||
use common\logic\Document\Quotation\QuotationFactory; | |||
use common\logic\Document\Quotation\QuotationModel; | |||
use common\logic\Document\Quotation\Quotation; | |||
class QuotationContainer implements ContainerInterface | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
return QuotationModel::class; | |||
return Quotation::class; | |||
} | |||
public function getServices(): array |
@@ -7,9 +7,9 @@ use common\logic\FactoryInterface; | |||
class QuotationFactory extends BaseService implements FactoryInterface | |||
{ | |||
public function create(): QuotationModel | |||
public function create(): Quotation | |||
{ | |||
$quotation = new QuotationModel(); | |||
$quotation = new Quotation(); | |||
return $quotation; | |||
} |
@@ -41,7 +41,7 @@ namespace common\logic\Document\Quotation; | |||
use common\helpers\GlobalParam; | |||
use yii\data\ActiveDataProvider; | |||
class QuotationSearch extends QuotationModel | |||
class QuotationSearch extends Quotation | |||
{ | |||
public function rules() | |||
@@ -58,7 +58,7 @@ class QuotationSearch extends QuotationModel | |||
{ | |||
$optionsSearch = self::defaultOptionsSearch(); | |||
$query = QuotationModel::find() | |||
$query = Quotation::find() | |||
->with($optionsSearch['with']) | |||
->joinWith($optionsSearch['join_with']) | |||
->where(['quotation.id_producer' => GlobalParam::getCurrentProducerId()]) |
@@ -41,8 +41,8 @@ namespace common\logic\Order\Order; | |||
use common\helpers\GlobalParam; | |||
use common\helpers\Price; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\logic\User\CreditHistory\CreditHistoryModel; | |||
use common\logic\User\User\UserModel; | |||
use common\logic\User\CreditHistory\CreditHistory; | |||
use common\logic\User\User\User; | |||
use Yii; | |||
use yii\helpers\Html; | |||
use common\components\ActiveRecordCommon; | |||
@@ -52,7 +52,7 @@ use yii\web\NotFoundHttpException; | |||
* This is the model class for table "order". | |||
* | |||
*/ | |||
class OrderModel extends ActiveRecordCommon | |||
class Order extends ActiveRecordCommon | |||
{ | |||
var $amount = 0; | |||
var $amount_with_tax = 0; | |||
@@ -145,12 +145,12 @@ class OrderModel extends ActiveRecordCommon | |||
public function getUser() | |||
{ | |||
return $this->hasOne(UserModel::className(), ['id' => 'id_user']); | |||
return $this->hasOne(User::className(), ['id' => 'id_user']); | |||
} | |||
public function getProductOrder() | |||
{ | |||
return $this->hasMany(ProductOrderModel::className(), ['id_order' => 'id']) | |||
return $this->hasMany(ProductOrder::className(), ['id_order' => 'id']) | |||
->orderBy(['product.order' => SORT_ASC]) | |||
->joinWith('product'); | |||
} | |||
@@ -168,34 +168,34 @@ class OrderModel extends ActiveRecordCommon | |||
public function getPointSale() | |||
{ | |||
return $this->hasOne(PointSaleModel::className(), ['id' => 'id_point_sale']) | |||
return $this->hasOne(PointSale::className(), ['id' => 'id_point_sale']) | |||
->with('userPointSale'); | |||
} | |||
public function getCreditHistory() | |||
{ | |||
return $this->hasMany(CreditHistoryModel::class, ['id_order' => 'id']); | |||
return $this->hasMany(CreditHistory::class, ['id_order' => 'id']); | |||
} | |||
public function getSubscription() | |||
{ | |||
return $this->hasOne(SubscriptionModel::className(), ['id' => 'id_subscription']) | |||
return $this->hasOne( Subscription::className(), ['id' => 'id_subscription']) | |||
->with('productSubscription'); | |||
} | |||
public function getInvoice() | |||
{ | |||
return $this->hasOne(InvoiceModel::className(), ['id' => 'id_invoice']); | |||
return $this->hasOne(Invoice::className(), ['id' => 'id_invoice']); | |||
} | |||
public function getQuotation() | |||
{ | |||
return $this->hasOne(QuotationModel::className(), ['id' => 'id_quotation']); | |||
return $this->hasOne(Quotation::className(), ['id' => 'id_quotation']); | |||
} | |||
public function getDeliveryNote() | |||
{ | |||
return $this->hasOne(DeliveryNoteModel::className(), ['id' => 'id_delivery_note']); | |||
return $this->hasOne(DeliveryNote::className(), ['id' => 'id_delivery_note']); | |||
} | |||
/** | |||
@@ -223,7 +223,7 @@ class OrderModel extends ActiveRecordCommon | |||
* Initialise le montant total, le montant déjà payé et le poids de la | |||
* commande. | |||
*/ | |||
public function init($taxCalculationMethod = DocumentModel::TAX_CALCULATION_METHOD_DEFAULT) | |||
public function init($taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT) | |||
{ | |||
$this->initAmount($taxCalculationMethod); | |||
$this->initPaidAmount(); | |||
@@ -235,7 +235,7 @@ class OrderModel extends ActiveRecordCommon | |||
* Initialise le montant de la commande. | |||
* | |||
*/ | |||
public function initAmount($taxCalculationMethod = DocumentModel::TAX_CALCULATION_METHOD_DEFAULT) | |||
public function initAmount($taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT) | |||
{ | |||
$this->amount = 0; | |||
$this->amount_with_tax = 0; | |||
@@ -329,7 +329,7 @@ class OrderModel extends ActiveRecordCommon | |||
if (isset($this->creditHistory)) { | |||
$history = $this->creditHistory; | |||
} else { | |||
$history = CreditHistoryModel::find() | |||
$history = CreditHistory::find() | |||
->where(['id_order' => $this->id]) | |||
->all(); | |||
} | |||
@@ -338,9 +338,9 @@ class OrderModel extends ActiveRecordCommon | |||
if (count($history)) { | |||
foreach ($history as $ch) { | |||
if ($ch->type == CreditHistoryModel::TYPE_PAYMENT) { | |||
if ($ch->type == CreditHistory::TYPE_PAYMENT) { | |||
$this->paid_amount += $ch->amount; | |||
} elseif ($ch->type == CreditHistoryModel::TYPE_REFUND) { | |||
} elseif ($ch->type == CreditHistory::TYPE_REFUND) { | |||
$this->paid_amount -= $ch->amount; | |||
} | |||
} | |||
@@ -350,14 +350,14 @@ class OrderModel extends ActiveRecordCommon | |||
public function delete($force = false) | |||
{ | |||
// remboursement si l'utilisateur a payé pour cette commande | |||
$amountPaid = $this->getAmount(OrderModel::AMOUNT_PAID); | |||
$amountPaid = $this->getAmount(Order::AMOUNT_PAID); | |||
if ($amountPaid > 0.01) { | |||
$this->saveCreditHistory( | |||
CreditHistoryModel::TYPE_REFUND, | |||
CreditHistory::TYPE_REFUND, | |||
$amountPaid, | |||
GlobalParam::getCurrentProducerId(), | |||
$this->id_user, | |||
UserModel::getCurrentId() | |||
User::getCurrentId() | |||
); | |||
} | |||
@@ -367,7 +367,7 @@ class OrderModel extends ActiveRecordCommon | |||
'option_behavior_cancel_order' | |||
) == Producer::BEHAVIOR_DELETE_ORDER_STATUS && strlen($this->date_delete)) || | |||
$force) { | |||
ProductOrderModel::deleteAll(['id_order' => $this->id]); | |||
ProductOrder::deleteAll(['id_order' => $this->id]); | |||
return parent::delete(); | |||
} // status 'delete' | |||
elseif (Producer::getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS) { | |||
@@ -449,7 +449,7 @@ class OrderModel extends ActiveRecordCommon | |||
public function addOrderStatusHistory($newStatus, $origin) | |||
{ | |||
$orderStatusHistory = new OrderStatusHistory(); | |||
$orderStatusHistory->id_user = UserModel::getCurrentId(); | |||
$orderStatusHistory->id_user = User::getCurrentId(); | |||
$orderStatusHistory->id_order = $this->id; | |||
$orderStatusHistory->status = $newStatus; | |||
$orderStatusHistory->origin = $origin; | |||
@@ -519,7 +519,7 @@ class OrderModel extends ActiveRecordCommon | |||
*/ | |||
public function getDataJson() | |||
{ | |||
$order = OrderModel::searchOne(['order.id' => $this->id]); | |||
$order = Order::searchOne(['order.id' => $this->id]); | |||
$jsonOrder = []; | |||
if ($order) { | |||
@@ -560,7 +560,7 @@ class OrderModel extends ActiveRecordCommon | |||
$creditHistory->id_producer = $idProducer; | |||
$creditHistory->id_user_action = $idUserAction; | |||
$creditHistory->populateRelation('order', $this); | |||
$creditHistory->populateRelation('user', UserModel::find()->where(['id' => $this->id_user])->one()); | |||
$creditHistory->populateRelation('user', User::find()->where(['id' => $this->id_user])->one()); | |||
$creditHistoryService->save($creditHistory); | |||
} | |||
@@ -580,10 +580,10 @@ class OrderModel extends ActiveRecordCommon | |||
if ($paymentStatus == self::PAYMENT_PAID) { | |||
return true; | |||
} elseif ($paymentStatus == self::PAYMENT_SURPLUS) { | |||
$type = CreditHistoryModel::TYPE_REFUND; | |||
$type = CreditHistory::TYPE_REFUND; | |||
$amount = $this->getAmount(self::AMOUNT_SURPLUS); | |||
} elseif ($paymentStatus == self::PAYMENT_UNPAID) { | |||
$type = CreditHistoryModel::TYPE_PAYMENT; | |||
$type = CreditHistory::TYPE_PAYMENT; | |||
$amount = $this->getAmount(self::AMOUNT_REMAINING); | |||
} | |||
@@ -592,14 +592,14 @@ class OrderModel extends ActiveRecordCommon | |||
$amount, | |||
GlobalParam::getCurrentProducerId(), | |||
$this->id_user, | |||
UserModel::getCurrentId() | |||
User::getCurrentId() | |||
); | |||
} | |||
} | |||
public function setTillerSynchronization() | |||
{ | |||
$order = OrderModel::searchOne(['id' => $this->id]); | |||
$order = Order::searchOne(['id' => $this->id]); | |||
$paymentStatus = $order->getPaymentStatus(); | |||
@@ -642,7 +642,7 @@ class OrderModel extends ActiveRecordCommon | |||
public function getCartSummary($htmlFormat = true) | |||
{ | |||
if (!isset($this->productOrder)) { | |||
$this->productOrder = ProductOrderModel::find()->where(['id_order' => $this->id])->all(); | |||
$this->productOrder = ProductOrder::find()->where(['id_order' => $this->id])->all(); | |||
} | |||
$html = ''; | |||
@@ -650,7 +650,7 @@ class OrderModel extends ActiveRecordCommon | |||
$i = 0; | |||
foreach ($this->productOrder as $p) { | |||
if (isset($p->product)) { | |||
$html .= Html::encode($p->product->name) . ' (' . $p->quantity . ' ' . ProductModel::strUnit( | |||
$html .= Html::encode($p->product->name) . ' (' . $p->quantity . ' ' . Product::strUnit( | |||
$p->unit, | |||
'wording_short', | |||
true | |||
@@ -712,15 +712,15 @@ class OrderModel extends ActiveRecordCommon | |||
if ($creditActive) { | |||
$html .= '<br />'; | |||
if ($this->paid_amount) { | |||
if ($this->getPaymentStatus() == OrderModel::PAYMENT_PAID) { | |||
if ($this->getPaymentStatus() == Order::PAYMENT_PAID) { | |||
$html .= '<span class="label label-success">Payée</span>'; | |||
} elseif ($this->getPaymentStatus() == OrderModel::PAYMENT_UNPAID) { | |||
} elseif ($this->getPaymentStatus() == Order::PAYMENT_UNPAID) { | |||
$html .= '<span class="label label-danger">Non payée</span><br /> | |||
Reste <strong>' . $this->getAmount( | |||
OrderModel::AMOUNT_REMAINING, | |||
Order::AMOUNT_REMAINING, | |||
true | |||
) . '</strong> à payer'; | |||
} elseif ($this->getPaymentStatus() == OrderModel::PAYMENT_SURPLUS) { | |||
} elseif ($this->getPaymentStatus() == Order::PAYMENT_SURPLUS) { | |||
$html .= '<span class="label label-success">Payée</span>'; | |||
} | |||
} else { | |||
@@ -937,7 +937,7 @@ class OrderModel extends ActiveRecordCommon | |||
$quantity += $po->quantity; | |||
} else { | |||
if (isset($po->product) && $po->product->weight > 0) { | |||
$quantity += ($po->quantity * ProductModel::$unitsArray[$po->unit]['coefficient']) / $po->product->weight; | |||
$quantity += ($po->quantity * Product::$unitsArray[$po->unit]['coefficient']) / $po->product->weight; | |||
} | |||
} | |||
} | |||
@@ -969,7 +969,7 @@ class OrderModel extends ActiveRecordCommon | |||
if (is_array($orders)) { | |||
if (count($orders)) { | |||
foreach ($orders as $order) { | |||
if (is_a($order, 'common\logic\Order\Order\OrderModel')) { | |||
if (is_a($order, 'common\logic\Order\Order\Order')) { | |||
$order->init(); | |||
} | |||
} | |||
@@ -977,7 +977,7 @@ class OrderModel extends ActiveRecordCommon | |||
} | |||
} else { | |||
$order = $orders; | |||
if (is_a($order, 'common\logic\Order\Order\OrderModel')) { | |||
if (is_a($order, 'common\logic\Order\Order\Order')) { | |||
return $order->init(); | |||
} // count | |||
else { | |||
@@ -1049,7 +1049,7 @@ class OrderModel extends ActiveRecordCommon | |||
$producer = Producer::findOne($idProducer); | |||
if (!$this->reference && $producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY) { | |||
$lastOrder = OrderModel::find()->innerJoinWith('distribution', true) | |||
$lastOrder = Order::find()->innerJoinWith('distribution', true) | |||
->where(['>=', 'distribution.date', date('Y') . '-01-01']) | |||
->andWhere([ | |||
'distribution.id_producer' => $producer->id |
@@ -8,7 +8,7 @@ class OrderContainer implements ContainerInterface | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
return OrderModel::class; | |||
return Order::class; | |||
} | |||
public function getServices(): array |
@@ -7,9 +7,9 @@ use common\logic\FactoryInterface; | |||
class OrderFactory extends BaseService implements FactoryInterface | |||
{ | |||
public function create(): OrderModel | |||
public function create(): Order | |||
{ | |||
$order = new OrderModel(); | |||
$order = new Order(); | |||
return $order; | |||
} |
@@ -3,9 +3,19 @@ | |||
namespace common\logic\Order\Order; | |||
use common\logic\BaseService; | |||
use common\logic\Distribution\Distribution\Distribution; | |||
use common\logic\RepositoryInterface; | |||
class OrderRepository extends BaseService implements RepositoryInterface | |||
{ | |||
public function getByDistribution(Distribution $distribution, string $conditionAppend = '') | |||
{ | |||
return Order::searchAll([ | |||
'distribution.date' => $distribution->date, | |||
'distribution.id_producer' => $distribution->id_producer | |||
], | |||
[ | |||
'conditions' => 'date_delete IS NULL ' . $conditionAppend | |||
]); | |||
} | |||
} |
@@ -38,7 +38,7 @@ termes. | |||
namespace common\logic\Order\Order ; | |||
class OrderSearch extends OrderModel | |||
class OrderSearch extends Order | |||
{ | |||
public function search($params) | |||
{ | |||
@@ -49,7 +49,7 @@ class OrderSearch extends OrderModel | |||
$paramsSearch['id_user'] = $params['id_user']; | |||
} | |||
$query = OrderModel::searchQuery($paramsSearch, [ | |||
$query = Order::searchQuery($paramsSearch, [ | |||
'orderby' => 'distribution.date DESC' | |||
]); | |||
@@ -12,7 +12,7 @@ use common\components\ActiveRecordCommon; | |||
* @property integer $id_order_status | |||
* @property string $date | |||
*/ | |||
class OrderStatusHistoryModel extends ActiveRecordCommon | |||
class OrderStatusHistory extends ActiveRecordCommon | |||
{ | |||
/** | |||
* @inheritdoc | |||
@@ -55,12 +55,12 @@ class OrderStatusHistoryModel extends ActiveRecordCommon | |||
public function getOrder() | |||
{ | |||
return $this->hasOne(UserModel::className(), ['id' => 'id_order']); | |||
return $this->hasOne( User::className(), ['id' => 'id_order']); | |||
} | |||
public function getUser() | |||
{ | |||
return $this->hasOne(UserModel::className(), ['id' => 'id_user']); | |||
return $this->hasOne( User::className(), ['id' => 'id_user']); | |||
} | |||
/** |
@@ -8,7 +8,7 @@ class OrderStatusHistoryContainer implements ContainerInterface | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
return OrderStatusHistoryModel::class; | |||
return OrderStatusHistory::class; | |||
} | |||
public function getServices(): array |
@@ -7,9 +7,9 @@ use common\logic\FactoryInterface; | |||
class OrderStatusHistoryFactory extends BaseService implements FactoryInterface | |||
{ | |||
public function create(): OrderStatusHistoryModel | |||
public function create(): OrderStatusHistory | |||
{ | |||
$orderStatusHistory = new OrderStatusHistoryModel(); | |||
$orderStatusHistory = new OrderStatusHistory(); | |||
return $orderStatusHistory; | |||
} |
@@ -51,7 +51,7 @@ use common\components\ActiveRecordCommon; | |||
* @property double $quantity | |||
* @property string $unit | |||
*/ | |||
class ProductOrderModel extends ActiveRecordCommon | |||
class ProductOrder extends ActiveRecordCommon | |||
{ | |||
/** | |||
@@ -68,7 +68,7 @@ class ProductOrderModel extends ActiveRecordCommon | |||
public function getProduct() | |||
{ | |||
return $this->hasOne(ProductModel::className(), ['id' => 'id_product']); | |||
return $this->hasOne( Product::className(), ['id' => 'id_product']); | |||
} | |||
public function getTaxRate() | |||
@@ -148,9 +148,9 @@ class ProductOrderModel extends ActiveRecordCommon | |||
return Price::getPriceWithTax($this->price, $this->taxRate->value); | |||
} | |||
public function getPriceByTypeTotal($typeTotal = OrderModel::AMOUNT_TOTAL) | |||
public function getPriceByTypeTotal($typeTotal = Order::AMOUNT_TOTAL) | |||
{ | |||
if($typeTotal == OrderModel::INVOICE_AMOUNT_TOTAL && $this->invoice_price) { | |||
if($typeTotal == Order::INVOICE_AMOUNT_TOTAL && $this->invoice_price) { | |||
return $this->invoice_price; | |||
} | |||
@@ -8,7 +8,7 @@ class ProductOrderContainer implements ContainerInterface | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
return ProductOrderModel::class; | |||
return ProductOrder::class; | |||
} | |||
public function getServices(): array |
@@ -7,9 +7,9 @@ use common\logic\FactoryInterface; | |||
class ProductOrderFactory extends BaseService implements FactoryInterface | |||
{ | |||
public function create(): ProductOrderModel | |||
public function create(): ProductOrder | |||
{ | |||
$productOrder = new ProductOrderModel(); | |||
$productOrder = new ProductOrder(); | |||
return $productOrder; | |||
} |