'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], | ||||
*/ | */ | ||||
public function actionIndex() | public function actionIndex() | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$producer = $this->getProducerCurrent(); | $producer = $this->getProducerCurrent(); | ||||
$userSearch = new UserSearch(); | $userSearch = new UserSearch(); | ||||
$usersArray = $userSearch->search()->query->all(); | $usersArray = $userSearch->search()->query->all(); | ||||
$modelAccessUserProducerForm = new AccessUserProducerForm; | $modelAccessUserProducerForm = new AccessUserProducerForm; | ||||
if ($modelAccessUserProducerForm->load(\Yii::$app->request->post()) && $modelAccessUserProducerForm->validate()) { | if ($modelAccessUserProducerForm->load(\Yii::$app->request->post()) && $modelAccessUserProducerForm->validate()) { | ||||
$user = $userManager->findOneUserById($modelAccessUserProducerForm->id_user); | |||||
if($user && $userManager->grantAccess($user)) { | |||||
$user = $userModule->findOneUserById($modelAccessUserProducerForm->id_user); | |||||
if($user && $userModule->grantAccess($user)) { | |||||
$this->setFlash('success', 'Droits ajoutés à l\'utilisateur'); | $this->setFlash('success', 'Droits ajoutés à l\'utilisateur'); | ||||
} | } | ||||
else { | else { | ||||
return $this->render('index', [ | return $this->render('index', [ | ||||
'usersArray' => $usersArray, | 'usersArray' => $usersArray, | ||||
'usersAccessArray' => $userManager->findUsersByProducer($producer), | |||||
'usersAccessArray' => $userModule->findUsersByProducer($producer), | |||||
'producer' => $producer, | 'producer' => $producer, | ||||
'modelAccessUserProducerForm' => $modelAccessUserProducerForm, | 'modelAccessUserProducerForm' => $modelAccessUserProducerForm, | ||||
]); | ]); | ||||
public function actionDelete($idUser) | public function actionDelete($idUser) | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$user = $userManager->findOneUserById($idUser); | |||||
$userModule = $this->getUserModule(); | |||||
$user = $userModule->findOneUserById($idUser); | |||||
if ($user && $userManager->deleteAccess($user)) { | |||||
if ($user && $userModule->deleteAccess($user)) { | |||||
$this->addFlash('success', 'Droits de l\'utilisateur supprimé.'); | $this->addFlash('success', 'Droits de l\'utilisateur supprimé.'); | ||||
} | } | ||||
else { | else { |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->isCurrentAdmin(); | |||||
return $this->getUserModule()->isCurrentAdmin(); | |||||
} | } | ||||
] | ] | ||||
], | ], | ||||
public function actionIndex($section = 'producers') | public function actionIndex($section = 'producers') | ||||
{ | { | ||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
if ($section == 'producers') { | if ($section == 'producers') { | ||||
$producers = $producerManager->findProducersActive(); | $producers = $producerManager->findProducersActive(); | ||||
} | } | ||||
} | } | ||||
} elseif ($section == 'users') { | } elseif ($section == 'users') { | ||||
$users = $userManager->findUsersByStatus(User::STATUS_ACTIVE); | |||||
$users = $userModule->findUsersByStatus(User::STATUS_ACTIVE); | |||||
$usersArray = []; | $usersArray = []; | ||||
foreach ($users as $user) { | foreach ($users as $user) { | ||||
if (isset($user['email']) && strlen($user['email'])) { | if (isset($user['email']) && strlen($user['email'])) { |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], | ||||
public function actionIndex() | public function actionIndex() | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$userProducerManager = $this->getUserProducerManager(); | $userProducerManager = $this->getUserProducerManager(); | ||||
$dataProviderUsersWithNegativeCredit = new ActiveDataProvider([ | $dataProviderUsersWithNegativeCredit = new ActiveDataProvider([ | ||||
'query' => $userManager->queryUsersWithNegativeCredit(), | |||||
'query' => $userModule->queryUsersWithNegativeCredit(), | |||||
'sort' => false, | 'sort' => false, | ||||
'pagination' => [ | 'pagination' => [ | ||||
'pageSize' => 30, | 'pageSize' => 30, | ||||
public function actionExportUsers(string $type) | public function actionExportUsers(string $type) | ||||
{ | { | ||||
$this->getUserManager()->exportUsersCreditAsCsv($type); | |||||
$this->getUserModule()->exportUsersCreditAsCsv($type); | |||||
} | } | ||||
} | } |
$distributionManager = $this->getDistributionManager(); | $distributionManager = $this->getDistributionManager(); | ||||
$orderManager = $this->getOrderManager(); | $orderManager = $this->getOrderManager(); | ||||
$paymentManager = $this->getPaymentManager(); | $paymentManager = $this->getPaymentManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
if ($key == '64ac0bdab7e9f5e48c4d991ec5201d57') { | if ($key == '64ac0bdab7e9f5e48c4d991ec5201d57') { | ||||
ini_set('memory_limit', '-1'); | ini_set('memory_limit', '-1'); | ||||
$orderManager->initOrder($order); | $orderManager->initOrder($order); | ||||
if ($order->auto_payment && $configCredit) { | if ($order->auto_payment && $configCredit) { | ||||
if ($orderManager->isCreditAutoPayment($order) && $orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING) > 0) { | if ($orderManager->isCreditAutoPayment($order) && $orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING) > 0) { | ||||
$paymentManager->payOrder($order, MeanPayment::CREDIT, $userManager->findOneUserById(User::ID_USER_SYSTEM), false); | |||||
$paymentManager->payOrder($order, MeanPayment::CREDIT, $userModule->findOneUserById(User::ID_USER_SYSTEM), false); | |||||
$countOrders++; | $countOrders++; | ||||
} | } | ||||
} | } |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
], | ], | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
$userManager = $this->getUserManager(); | |||||
return $userManager->isCurrentAdmin() || $userManager->isCurrentProducer(); | |||||
$userModule = $this->getUserModule(); | |||||
return $userModule->isCurrentAdmin() || $userModule->isCurrentProducer(); | |||||
} | } | ||||
] | ] | ||||
], | ], | ||||
$distributionManager = $this->getDistributionManager(); | $distributionManager = $this->getDistributionManager(); | ||||
$orderManager = $this->getOrderManager(); | $orderManager = $this->getOrderManager(); | ||||
$productManager = $this->getProductManager(); | $productManager = $this->getProductManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$producer = $this->getProducerCurrent(); | $producer = $this->getProducerCurrent(); | ||||
$format = 'Y-m-d'; | $format = 'Y-m-d'; | ||||
$json['points_sale'] = $this->buildAjaxInfosResponsePointsSale($distribution); | $json['points_sale'] = $this->buildAjaxInfosResponsePointsSale($distribution); | ||||
$json['delivery_notes'] = $this->buildAjaxInfosResponseDeliveryNotes($date); | $json['delivery_notes'] = $this->buildAjaxInfosResponseDeliveryNotes($date); | ||||
$json['order_create'] = $this->buildAjaxInfosResponseOrderCreate($distribution, $productsArray); | $json['order_create'] = $this->buildAjaxInfosResponseOrderCreate($distribution, $productsArray); | ||||
$json['users'] = $userManager->findUsers(); | |||||
$json['users'] = $userModule->findUsers(); | |||||
$json['one_distribution_week_active'] = $distributionManager->isOneDistributionWeekActive($date); | $json['one_distribution_week_active'] = $distributionManager->isOneDistributionWeekActive($date); | ||||
$json['tiller_is_synchro'] = $this->buildAjaxInfosResponseTiller($producer, $date); | $json['tiller_is_synchro'] = $this->buildAjaxInfosResponseTiller($producer, $date); | ||||
$json['missing_subscriptions'] = $this->buildAjaxInfosResponseMissingSubscriptions($date, $distribution, $ordersArrayObject); | $json['missing_subscriptions'] = $this->buildAjaxInfosResponseMissingSubscriptions($date, $distribution, $ordersArrayObject); | ||||
public function buildAjaxInfosResponseOrders(array $ordersArray, array $productsArray) | public function buildAjaxInfosResponseOrders(array $ordersArray, array $productsArray) | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$orderManager = $this->getOrderManager(); | $orderManager = $this->getOrderManager(); | ||||
$paymentManager = $this->getPaymentManager(); | $paymentManager = $this->getPaymentManager(); | ||||
'mean_payment' => $payment->mean_payment, | 'mean_payment' => $payment->mean_payment, | ||||
'wording_mean_payment' => $paymentManager->getStrMeanPayment($payment), | 'wording_mean_payment' => $paymentManager->getStrMeanPayment($payment), | ||||
'date' => date('d/m/Y H:i:s', strtotime($payment->date)), | 'date' => date('d/m/Y H:i:s', strtotime($payment->date)), | ||||
'user' => $payment->getUserObject() ? $userManager->getUsername($payment->getUserObject()) : '', | |||||
'user' => $payment->getUserObject() ? $userModule->getUsername($payment->getUserObject()) : '', | |||||
'user_action' => $paymentManager->getStrUserAction($payment), | 'user_action' => $paymentManager->getStrUserAction($payment), | ||||
'wording' => $paymentManager->getStrWording($payment, $order), | 'wording' => $paymentManager->getStrWording($payment, $order), | ||||
'amount' => $paymentManager->getAmount($payment, Order::AMOUNT_TOTAL, true), | 'amount' => $paymentManager->getAmount($payment, Order::AMOUNT_TOTAL, true), | ||||
$arrayCreditUser = []; | $arrayCreditUser = []; | ||||
if(isset($order->user)) { | if(isset($order->user)) { | ||||
$arrayCreditUser['credit'] = $userManager->getCredit($order->user); | |||||
$arrayCreditUser['credit_active'] = $userManager->getCreditActive($order->user); | |||||
$arrayCreditUser['credit'] = $userModule->getCredit($order->user); | |||||
$arrayCreditUser['credit_active'] = $userModule->getCreditActive($order->user); | |||||
} | } | ||||
$oneProductUnactivated = false; | $oneProductUnactivated = false; | ||||
public function actionAjaxPointSaleFavorite($idUser) | public function actionAjaxPointSaleFavorite($idUser) | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$orderManager = $this->getOrderManager(); | $orderManager = $this->getOrderManager(); | ||||
$user = $userManager->findOneUserById($idUser); | |||||
$user = $userModule->findOneUserById($idUser); | |||||
$idFavoritePointSale = 0; | $idFavoritePointSale = 0; | ||||
if($user) { | if($user) { | ||||
$distributionManager = $this->getDistributionManager(); | $distributionManager = $this->getDistributionManager(); | ||||
$orderManager = $this->getOrderManager(); | $orderManager = $this->getOrderManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$pointSaleManager = $this->getPointSaleManager(); | $pointSaleManager = $this->getPointSaleManager(); | ||||
$productManager = $this->getProductManager(); | $productManager = $this->getProductManager(); | ||||
$order = $orderManager->findOneOrderById($idOrder); | $order = $orderManager->findOneOrderById($idOrder); | ||||
$distribution = $distributionManager->findOneDistributionById($idDistribution); | $distribution = $distributionManager->findOneDistributionById($idDistribution); | ||||
$user = $userManager->findOneUserById($idUser); | |||||
$user = $userModule->findOneUserById($idUser); | |||||
$pointSale = $pointSaleManager->findOnePointSaleById($idPointSale); | $pointSale = $pointSaleManager->findOnePointSaleById($idPointSale); | ||||
$productsArray = Product::find() | $productsArray = Product::find() |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], | ||||
public function actionAjaxUserInfos($typeAction, $idUser, $classDocument, $idDocument = false) | public function actionAjaxUserInfos($typeAction, $idUser, $classDocument, $idDocument = false) | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$documentManager = $this->getDocumentManager(); | $documentManager = $this->getDocumentManager(); | ||||
$orderManager = $this->getOrderManager(); | $orderManager = $this->getOrderManager(); | ||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
if ($idUser > 0) { | if ($idUser > 0) { | ||||
$user = $userManager->findOneUserById($idUser); | |||||
$user = $userModule->findOneUserById($idUser); | |||||
if ($user) { | if ($user) { | ||||
$document = null; | $document = null; | ||||
if ($document && $document->id_user == $user->id) { | if ($document && $document->id_user == $user->id) { | ||||
$address = $document->address; | $address = $document->address; | ||||
} else { | } else { | ||||
$address = $userManager->getFullAddress($user); | |||||
$address = $userModule->getFullAddress($user); | |||||
} | } | ||||
$json = [ | $json = [ |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->isCurrentProducer() | |||||
|| $this->getUserManager()->isCurrentAdmin(); | |||||
return $this->getUserModule()->isCurrentProducer() | |||||
|| $this->getUserModule()->isCurrentAdmin(); | |||||
} | } | ||||
] | ] | ||||
], | ], | ||||
$distributionManager = $this->getDistributionManager(); | $distributionManager = $this->getDistributionManager(); | ||||
$pointSaleManager = $this->getPointSaleManager(); | $pointSaleManager = $this->getPointSaleManager(); | ||||
$userPointSaleManager = $this->getUserPointSaleManager(); | $userPointSaleManager = $this->getUserPointSaleManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$userProducerManager = $this->getUserProducerManager(); | $userProducerManager = $this->getUserProducerManager(); | ||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$productManager = $this->getProductManager(); | $productManager = $this->getProductManager(); | ||||
$order->id_user = $idUser; | $order->id_user = $idUser; | ||||
// commentaire du point de vente | // commentaire du point de vente | ||||
$userPointSale = $userPointSaleManager->findOneUserPointSale($userManager->findOneUserById($idUser), $pointSale); | |||||
$userPointSale = $userPointSaleManager->findOneUserPointSale($userModule->findOneUserById($idUser), $pointSale); | |||||
if ($userPointSale && strlen($userPointSale->comment)) { | if ($userPointSale && strlen($userPointSale->comment)) { | ||||
$order->comment_point_sale = $userPointSale->comment; | $order->comment_point_sale = $userPointSale->comment; | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$orderManager = $this->getOrderManager(); | $orderManager = $this->getOrderManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$pointSaleManager = $this->getPointSaleManager(); | $pointSaleManager = $this->getPointSaleManager(); | ||||
$userPointSaleManager = $this->getUserPointSaleManager(); | $userPointSaleManager = $this->getUserPointSaleManager(); | ||||
$paymentManager = $this->getPaymentManager(); | $paymentManager = $this->getPaymentManager(); | ||||
$order = $orderManager->findOneOrderById($idOrder); | $order = $orderManager->findOneOrderById($idOrder); | ||||
$orderManager->initOrder($order); | $orderManager->initOrder($order); | ||||
$user = $userManager->findOneUserById($idUser); | |||||
$user = $userModule->findOneUserById($idUser); | |||||
$pointSale = $pointSaleManager->findOnePointSaleById($idPointSale); | $pointSale = $pointSaleManager->findOnePointSaleById($idPointSale); | ||||
if ($order | if ($order |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
], | ], | ||||
], | ], | ||||
*/ | */ | ||||
public function initForm(int $id = 0) | public function initForm(int $id = 0) | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$users = $userManager->queryUsersBy() | |||||
$users = $userModule->queryUsersBy() | |||||
->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]) | ->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') | ->orderBy('user_point_sale.id_point_sale DESC, lastname ASC, name ASC') | ||||
->all(); | ->all(); |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->isCurrentAdmin(); | |||||
return $this->getUserModule()->isCurrentAdmin(); | |||||
} | } | ||||
] | ] | ||||
], | ], | ||||
public function actionUserTransfer($fromProducerId, $toProducerId, $withOrders = 1) | public function actionUserTransfer($fromProducerId, $toProducerId, $withOrders = 1) | ||||
{ | { | ||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$fromProducerId = (int)$fromProducerId; | $fromProducerId = (int)$fromProducerId; | ||||
$toProducerId = (int)$toProducerId; | $toProducerId = (int)$toProducerId; | ||||
$count = 0; | $count = 0; | ||||
$usersArray = $userManager->queryUsersBy(['id_producer' => $fromProducerId])->all(); | |||||
$usersArray = $userModule->queryUsersBy(['id_producer' => $fromProducerId])->all(); | |||||
foreach ($usersArray as $user) { | foreach ($usersArray as $user) { | ||||
$idUser = $user['user_id']; | $idUser = $user['user_id']; | ||||
if (($withOrders && $countOrders) || !$withOrders) { | if (($withOrders && $countOrders) || !$withOrders) { | ||||
$producerManager->addUser( | $producerManager->addUser( | ||||
$userManager->findOneUserById($idUser), | |||||
$userModule->findOneUserById($idUser), | |||||
$producerManager->findOneProducerById($toProducerId) | $producerManager->findOneProducerById($toProducerId) | ||||
); | ); | ||||
$count++; | $count++; |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->isCurrentAdmin(); | |||||
return $this->getUserModule()->isCurrentAdmin(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
], | ], | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], | ||||
$productPriceManager = $this->getProductPriceManager(); | $productPriceManager = $this->getProductPriceManager(); | ||||
$userGroupManager = $this->getUserGroupManager(); | $userGroupManager = $this->getUserGroupManager(); | ||||
$pointSaleManager = $this->getPointSaleManager(); | $pointSaleManager = $this->getPointSaleManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$model = new ProductPriceUploadForm(); | $model = new ProductPriceUploadForm(); | ||||
$price = (float) str_replace(',', '.', $productPriceCsv[5]); | $price = (float) str_replace(',', '.', $productPriceCsv[5]); | ||||
$product = $productName ? $productManager->findOneProductByName($productName) : null; | $product = $productName ? $productManager->findOneProductByName($productName) : null; | ||||
$user = (count($userArray) > 1) ? $userManager->findOneUserById((int)$userArray[1]) : null; | |||||
$user = (count($userArray) > 1) ? $userModule->findOneUserById((int)$userArray[1]) : null; | |||||
$userGroup = $userGroupName ? $userGroupManager->findOneUserGroupByName($userGroupName) : null; | $userGroup = $userGroupName ? $userGroupManager->findOneUserGroupByName($userGroupName) : null; | ||||
$pointSale = $pointSaleName ? $pointSaleManager->findOnePointSaleByName($pointSaleName) : null; | $pointSale = $pointSaleName ? $pointSaleManager->findOnePointSaleByName($pointSaleName) : null; | ||||
{ | { | ||||
$productManager = $this->getProductManager(); | $productManager = $this->getProductManager(); | ||||
$productPriceManager = $this->getProductPriceManager(); | $productPriceManager = $this->getProductPriceManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$data = []; | $data = []; | ||||
if($productPrice->user || $productPrice->userGroup || $productPrice->pointSale || $productPrice->from_quantity) { | if($productPrice->user || $productPrice->userGroup || $productPrice->pointSale || $productPrice->from_quantity) { | ||||
$data[] = [ | $data[] = [ | ||||
$product->name, | $product->name, | ||||
$productPrice->user ? str_replace('#', '', $userManager->getUsername($productPrice->user)).' #'.$productPrice->user->id : '', | |||||
$productPrice->user ? str_replace('#', '', $userModule->getUsername($productPrice->user)).' #'.$productPrice->user->id : '', | |||||
$productPrice->userGroup ? $productPrice->userGroup->name : '', | $productPrice->userGroup ? $productPrice->userGroup->name : '', | ||||
$productPrice->pointSale ? $productPrice->pointSale->name : '', | $productPrice->pointSale ? $productPrice->pointSale->name : '', | ||||
$productPrice->from_quantity ?? '', | $productPrice->from_quantity ?? '', |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$pointSaleManager = $this->getPointSaleManager(); | $pointSaleManager = $this->getPointSaleManager(); | ||||
$distributionManager = $this->getDistributionManager(); | $distributionManager = $this->getDistributionManager(); | ||||
$usersArray = $userManager->findUsers(); | |||||
$usersArray = $userModule->findUsers(); | |||||
$pointsSaleArray = $pointSaleManager->findPointSales(); | $pointsSaleArray = $pointSaleManager->findPointSales(); | ||||
$firstDistribution = $distributionManager->findOneFirstDistribution(); | $firstDistribution = $distributionManager->findOneFirstDistribution(); | ||||
$lastDistribution = $distributionManager->findOneLastDistribution(); | $lastDistribution = $distributionManager->findOneLastDistribution(); |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->getCurrentStatus() == User::STATUS_ADMIN; | |||||
return $this->getUserModule()->getCurrentStatus() == User::STATUS_ADMIN; | |||||
} | } | ||||
], | ], | ||||
], | ], | ||||
$producer = $this->getProducerContainer()->getRepository()->findOneProducerById($id); | $producer = $this->getProducerContainer()->getRepository()->findOneProducerById($id); | ||||
if($producer) { | if($producer) { | ||||
$this->getUserContainer()->getBuilder()->switchProducer($user, $producer); | |||||
$this->getUserModule()->getServices()->getBuilder()->switchProducer($user, $producer); | |||||
} | } | ||||
else { | else { | ||||
$this->addFlash('error', 'Producteur introuvable.'); | $this->addFlash('error', 'Producteur introuvable.'); |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->isCurrentAdmin(); | |||||
return $this->getUserModule()->isCurrentAdmin(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], |
use common\logic\Payment\Model\Payment; | use common\logic\Payment\Model\Payment; | ||||
use common\logic\User\User\Model\User; | use common\logic\User\User\Model\User; | ||||
use common\logic\User\User\Model\UserSearch; | use common\logic\User\User\Model\UserSearch; | ||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use common\logic\User\UserProducer\Model\UserProducer; | use common\logic\User\UserProducer\Model\UserProducer; | ||||
use common\logic\User\UserUserGroup\Model\UserUserGroup; | use common\logic\User\UserUserGroup\Model\UserUserGroup; | ||||
use yii\base\UserException; | use yii\base\UserException; | ||||
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
] | ] | ||||
], | ], | ||||
public function actionCreate() | public function actionCreate() | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$producerCurrent = $this->getProducerCurrent(); | $producerCurrent = $this->getProducerCurrent(); | ||||
$model = $userManager->instanciateUser(); | |||||
$model = $userModule->instanciateUser(); | |||||
$posts = Yii::$app->request->post(); | $posts = Yii::$app->request->post(); | ||||
$userExist = false; | $userExist = false; | ||||
if ($posts && isset($posts['User']['email']) && strlen($posts['User']['email']) > 0) { | if ($posts && isset($posts['User']['email']) && strlen($posts['User']['email']) > 0) { | ||||
$userExist = $userManager->findOneUserByEmail($posts['User']['email']); | |||||
$userExist = $userModule->findOneUserByEmail($posts['User']['email']); | |||||
} | } | ||||
if ($userExist) { | if ($userExist) { | ||||
if ($model->load(\Yii::$app->request->post()) && $model->validate() && YII_ENV != 'demo') { | if ($model->load(\Yii::$app->request->post()) && $model->validate() && YII_ENV != 'demo') { | ||||
$model->id_producer = 0; | $model->id_producer = 0; | ||||
$password = Password::generate(); | $password = Password::generate(); | ||||
$userManager->setPassword($model, $password); | |||||
$userManager->generateAuthKey($model); | |||||
$userModule->setPassword($model, $password); | |||||
$userModule->generateAuthKey($model); | |||||
$model->username = $model->email; | $model->username = $model->email; | ||||
if (!strlen($model->email)) { | if (!strlen($model->email)) { | ||||
$model->username = 'inconnu@opendistrib.net'; | $model->username = 'inconnu@opendistrib.net'; | ||||
$useProducer->newsletter = $model->newsletter; | $useProducer->newsletter = $model->newsletter; | ||||
$useProducer->save(); | $useProducer->save(); | ||||
$userManager->sendMailWelcome($model, $password); | |||||
$userModule->sendMailWelcome($model, $password); | |||||
$this->processLinkPointSale($model); | $this->processLinkPointSale($model); | ||||
$this->processLinkUserGroup($model); | $this->processLinkUserGroup($model); | ||||
$this->processProductPricePercent($model); | $this->processProductPricePercent($model); | ||||
$this->setFlash('success', 'Utilisateur créé.'); | $this->setFlash('success', 'Utilisateur créé.'); | ||||
$model = $userManager->instanciateUser(); | |||||
$model = $userModule->instanciateUser(); | |||||
} | } | ||||
} | } | ||||
public function actionUpdate($id) | public function actionUpdate($id) | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$pointSaleManager = $this->getPointSaleManager(); | $pointSaleManager = $this->getPointSaleManager(); | ||||
$model = $this->findModel($id); | $model = $this->findModel($id); | ||||
// on envoie le mail de bienvenue si le mail vient d'être défini | // on envoie le mail de bienvenue si le mail vient d'être défini | ||||
if (!strlen($previousMail) && strlen($model->email)) { | if (!strlen($previousMail) && strlen($model->email)) { | ||||
$password = Password::generate(); | $password = Password::generate(); | ||||
$userManager->setPassword($model, $password); | |||||
$userModule->setPassword($model, $password); | |||||
$model->username = $model->email; | $model->username = $model->email; | ||||
$userManager->sendMailWelcome($model, $password); | |||||
$userModule->sendMailWelcome($model, $password); | |||||
} | } | ||||
$this->processLinkPointSale($model); | $this->processLinkPointSale($model); | ||||
$this->processLinkUserGroup($model); | $this->processLinkUserGroup($model); | ||||
$this->processProductPricePercent($model); | $this->processProductPricePercent($model); | ||||
if($model->newsletter) { | if($model->newsletter) { | ||||
$userManager->subscribeUserNewsletter($model); | |||||
$userModule->subscribeUserNewsletter($model); | |||||
} | } | ||||
else { | else { | ||||
$userManager->unsubscribeUserNewsletter($model); | |||||
$userModule->unsubscribeUserNewsletter($model); | |||||
} | } | ||||
$this->setFlash('success', 'Utilisateur <strong>'.Html::encode($userManager->getUsername($model)).'</strong> modifié.'); | |||||
$this->setFlash('success', 'Utilisateur <strong>'.Html::encode($userModule->getUsername($model)).'</strong> modifié.'); | |||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
} | } | ||||
$newPassword = Yii::$app->request->post('submit_new_password'); | $newPassword = Yii::$app->request->post('submit_new_password'); | ||||
if ($newPassword) { | if ($newPassword) { | ||||
$password = Password::generate(); | $password = Password::generate(); | ||||
$userManager->setPassword($model, $password); | |||||
$userModule->setPassword($model, $password); | |||||
$model->save(); | $model->save(); | ||||
$producer = $this->getProducerCurrent(); | $producer = $this->getProducerCurrent(); | ||||
$producer | $producer | ||||
); | ); | ||||
$this->setFlash('success', 'Nouveau mot de passe envoyé à <strong>'.Html::encode($userManager->getUsername($model)).'</strong>.'); | |||||
$this->setFlash('success', 'Nouveau mot de passe envoyé à <strong>'.Html::encode($userModule->getUsername($model)).'</strong>.'); | |||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
} | } | ||||
*/ | */ | ||||
public function actionDelete(int $id) | public function actionDelete(int $id) | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$userProducerManager = $this->getUserProducerManager(); | $userProducerManager = $this->getUserProducerManager(); | ||||
$user = $userManager->findOneUserById($id); | |||||
$user = $userModule->findOneUserById($id); | |||||
$userProducer = $userProducerManager->findOneUserProducer($user); | $userProducer = $userProducerManager->findOneUserProducer($user); | ||||
if ($userProducer) { | if ($userProducer) { | ||||
*/ | */ | ||||
public function actionCredit(int $id) | public function actionCredit(int $id) | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$paymentContainer = $this->getPaymentContainer(); | $paymentContainer = $this->getPaymentContainer(); | ||||
$userProducerContainer = $this->getUserProducerContainer(); | $userProducerContainer = $this->getUserProducerContainer(); | ||||
$user = $userManager->findOneUserById($id); | |||||
$user = $userModule->findOneUserById($id); | |||||
$userProducer = $userProducerContainer->getRepository()->findOneUserProducer($user); | $userProducer = $userProducerContainer->getRepository()->findOneUserProducer($user); | ||||
if ($userProducer) { | if ($userProducer) { | ||||
*/ | */ | ||||
public function actionStateCredit($idUser, $state) | public function actionStateCredit($idUser, $state) | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$userProducerManager = $this->getUserProducerManager(); | $userProducerManager = $this->getUserProducerManager(); | ||||
$user = $userManager->findOneUserById($idUser); | |||||
$user = $userModule->findOneUserById($idUser); | |||||
$userProducer = $userProducerManager->findOneUserProducer($user); | $userProducer = $userProducerManager->findOneUserProducer($user); | ||||
if ($userProducer) { | if ($userProducer) { | ||||
*/ | */ | ||||
public function actionOrders($id) | public function actionOrders($id) | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$user = $userManager->findOneUserById($id); | |||||
$user = $userModule->findOneUserById($id); | |||||
$searchModel = new OrderSearch(); | $searchModel = new OrderSearch(); | ||||
$dataProvider = $searchModel->search(array_merge(\Yii::$app->request->queryParams, ['id_user' => $id])); | $dataProvider = $searchModel->search(array_merge(\Yii::$app->request->queryParams, ['id_user' => $id])); | ||||
*/ | */ | ||||
protected function findModel($id) | protected function findModel($id) | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
if (($user = $userManager->findOneUserById($id)) !== null) { | |||||
if (($user = $userModule->findOneUserById($id)) !== null) { | |||||
return $user; | return $user; | ||||
} else { | } else { | ||||
throw new NotFoundHttpException("Utilisateur introuvable"); | throw new NotFoundHttpException("Utilisateur introuvable"); | ||||
$usersPointSaleLink = 0, | $usersPointSaleLink = 0, | ||||
$usersPointSaleHasOrder = 0) | $usersPointSaleHasOrder = 0) | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$distributionManager = $this->getDistributionManager(); | $distributionManager = $this->getDistributionManager(); | ||||
if ($idPointSale && !$usersPointSaleLink && !$usersPointSaleHasOrder) { | if ($idPointSale && !$usersPointSaleLink && !$usersPointSaleHasOrder) { | ||||
$usersPointSaleLink = 1; | $usersPointSaleLink = 1; | ||||
} | } | ||||
$users = $userManager->queryUsersBy([ | |||||
$users = $userModule->queryUsersBy([ | |||||
'id_producer' => GlobalParam::getCurrentProducerId(), | 'id_producer' => GlobalParam::getCurrentProducerId(), | ||||
'id_point_sale' => $idPointSale, | 'id_point_sale' => $idPointSale, | ||||
'users_point_sale_link' => $usersPointSaleLink, | 'users_point_sale_link' => $usersPointSaleLink, | ||||
public function actionSwitchIdentity(int $id) | public function actionSwitchIdentity(int $id) | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
if($this->isUserCurrentAdmin()) { | if($this->isUserCurrentAdmin()) { | ||||
$initialId = Yii::$app->user->getId(); | $initialId = Yii::$app->user->getId(); | ||||
if($initialId != $id) { | if($initialId != $id) { | ||||
$user = $userManager->findOneUserById($id); | |||||
$user = $userModule->findOneUserById($id); | |||||
$duration = 0; | $duration = 0; | ||||
Yii::$app->user->switchIdentity($user, $duration); | Yii::$app->user->switchIdentity($user, $duration); | ||||
Yii::$app->session->set('user.idbeforeswitch',$initialId); | Yii::$app->session->set('user.idbeforeswitch',$initialId); |
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], | ||||
'matchCallback' => function ($rule, $action) { | 'matchCallback' => function ($rule, $action) { | ||||
return $this->getUserManager()->hasAccessBackend(); | |||||
return $this->getUserModule()->hasAccessBackend(); | |||||
} | } | ||||
], | ], | ||||
], | ], |
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\logic\Payment\Wrapper\PaymentManager; | use common\logic\Payment\Wrapper\PaymentManager; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use common\logic\User\UserProducer\Wrapper\UserProducerManager; | use common\logic\User\UserProducer\Wrapper\UserProducerManager; | ||||
use yii\base\Model; | use yii\base\Model; | ||||
*/ | */ | ||||
public function save() | public function save() | ||||
{ | { | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$userProducerManager = UserProducerManager::getInstance(); | $userProducerManager = UserProducerManager::getInstance(); | ||||
$paymentManager = PaymentManager::getInstance(); | $paymentManager = PaymentManager::getInstance(); | ||||
if ($this->validate()) { | if ($this->validate()) { | ||||
$user = $userManager->findOneUserById($this->id_user); | |||||
$paymentManager->creditOrDebitUser($this->type, $user, $this->amount, $this->mean_payment, $userManager->getCurrent(), $this->comment); | |||||
$user = $userModule->findOneUserById($this->id_user); | |||||
$paymentManager->creditOrDebitUser($this->type, $user, $this->amount, $this->mean_payment, $userModule->getCurrent(), $this->comment); | |||||
// on prévient l'utilisateur que son compte vient d'être crédité | // on prévient l'utilisateur que son compte vient d'être crédité | ||||
if($this->send_mail) { | if($this->send_mail) { |
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use yii\helpers\ArrayHelper ; | use yii\helpers\ArrayHelper ; | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$this->setTitle('Accès') ; | $this->setTitle('Accès') ; | ||||
</div> | </div> | ||||
<div class="panel-body"> | <div class="panel-body"> | ||||
<?php $form = ActiveForm::begin(); ?> | <?php $form = ActiveForm::begin(); ?> | ||||
<?= $form->field($modelAccessUserProducerForm, 'id_user')->dropDownList( $userManager->populateUserDropdownList(), ['class' => 'select2'])->label(''); ?> | |||||
<?= $form->field($modelAccessUserProducerForm, 'id_user')->dropDownList( $userModule->populateUserDropdownList(), ['class' => 'select2'])->label(''); ?> | |||||
<?= Html::submitButton('Ajouter', ['class' => 'btn btn-success']) ?> | <?= Html::submitButton('Ajouter', ['class' => 'btn btn-success']) ?> | ||||
<?php ActiveForm::end(); ?> | <?php ActiveForm::end(); ?> | ||||
</div> | </div> |
use common\helpers\Price; | use common\helpers\Price; | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$this->setTitle('Crédit'); | $this->setTitle('Crédit'); | ||||
'columns' => [ | 'columns' => [ | ||||
[ | [ | ||||
'label' => 'Client', | 'label' => 'Client', | ||||
'value' => function ($user) use ($userManager) { | |||||
return $userManager->getUsernameFromArray($user, true); | |||||
'value' => function ($user) use ($userModule) { | |||||
return $userModule->getUsernameFromArray($user, true); | |||||
} | } | ||||
], | ], | ||||
[ | [ |
use common\logic\Order\Order\Wrapper\OrderManager; | use common\logic\Order\Order\Wrapper\OrderManager; | ||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | use common\logic\Producer\Producer\Wrapper\ProducerManager; | ||||
use common\logic\Subscription\Subscription\Wrapper\SubscriptionManager; | use common\logic\Subscription\Subscription\Wrapper\SubscriptionManager; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use yii\helpers\Html ; | use yii\helpers\Html ; | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$orderManager = OrderManager::getInstance(); | $orderManager = OrderManager::getInstance(); | ||||
$subscriptionManager = SubscriptionManager::getInstance(); | $subscriptionManager = SubscriptionManager::getInstance(); | ||||
$producerManager = ProducerManager::getInstance(); | $producerManager = ProducerManager::getInstance(); | ||||
<?php foreach($subscriptionsLatestAddedArray as $subscription): ?> | <?php foreach($subscriptionsLatestAddedArray as $subscription): ?> | ||||
<tr> | <tr> | ||||
<td><?= date('d/m/Y à H:i', strtotime($subscription->created_at)); ?></td> | <td><?= date('d/m/Y à H:i', strtotime($subscription->created_at)); ?></td> | ||||
<td><?= $userManager->getUsername($subscription->user); ?></td> | |||||
<td><?= $userModule->getUsername($subscription->user); ?></td> | |||||
<td><?= Html::encode($subscription->pointSale->name); ?></td> | <td><?= Html::encode($subscription->pointSale->name); ?></td> | ||||
<td><?= $subscriptionManager->getProductsListAsHtml($subscription); ?></td> | <td><?= $subscriptionManager->getProductsListAsHtml($subscription); ?></td> | ||||
<td><?= $subscriptionManager->getDaysAsHtml($subscription); ?></td> | <td><?= $subscriptionManager->getDaysAsHtml($subscription); ?></td> |
]; | ]; | ||||
if ($this->getUserManager()->hasAccessBackend()) { | |||||
if ($this->getUserModule()->hasAccessBackend()) { | |||||
$columns[] = [ | $columns[] = [ | ||||
'header' => 'Priorité', | 'header' => 'Priorité', |
use common\helpers\MeanPayment;use common\helpers\Price;use common\logic\Document\Document\Wrapper\DocumentManager; | use common\helpers\MeanPayment;use common\helpers\Price;use common\logic\Document\Document\Wrapper\DocumentManager; | ||||
use common\logic\Document\Invoice\Wrapper\InvoiceManager;use common\logic\Payment\Wrapper\PaymentManager;use common\logic\Producer\Producer\Wrapper\ProducerManager; | use common\logic\Document\Invoice\Wrapper\InvoiceManager;use common\logic\Payment\Wrapper\PaymentManager;use common\logic\Producer\Producer\Wrapper\ProducerManager; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
$producerManager = ProducerManager::getInstance(); | $producerManager = ProducerManager::getInstance(); | ||||
$documentManager = DocumentManager::getInstance(); | $documentManager = DocumentManager::getInstance(); | ||||
$invoiceManager = InvoiceManager::getInstance(); | $invoiceManager = InvoiceManager::getInstance(); | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$paymentManager = PaymentManager::getInstance(); | $paymentManager = PaymentManager::getInstance(); | ||||
$documentClass = $documentManager->getClass($model); | $documentClass = $documentManager->getClass($model); | ||||
<?php if ($action == 'update'): ?> | <?php if ($action == 'update'): ?> | ||||
<?= $form->field($model, 'id_user', [ | <?= $form->field($model, 'id_user', [ | ||||
'template' => '{label} <div>{input}</div>' . $userManager->getUsername($model->user), | |||||
'template' => '{label} <div>{input}</div>' . $userModule->getUsername($model->user), | |||||
])->hiddenInput(); ?> | ])->hiddenInput(); ?> | ||||
<?php else: ?> | <?php else: ?> | ||||
<?= $form->field($model, 'id_user', [ | <?= $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}', | '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( | ->dropDownList( | ||||
$userManager->populateUserDropdownList(), | |||||
$userModule->populateUserDropdownList(), | |||||
[ | [ | ||||
'@change' => 'changeUser', | '@change' => 'changeUser', | ||||
'v-model' => 'idUser', | 'v-model' => 'idUser', |
use common\helpers\Price; | use common\helpers\Price; | ||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$documentManager = $this->getDocumentManager(); | $documentManager = $this->getDocumentManager(); | ||||
$orderManager = $this->getOrderManager(); | $orderManager = $this->getOrderManager(); | ||||
<?php if ($document->address && strlen($document->address) > 0): ?> | <?php if ($document->address && strlen($document->address) > 0): ?> | ||||
<?= nl2br($document->address) ?> | <?= nl2br($document->address) ?> | ||||
<?php else: ?> | <?php else: ?> | ||||
<?= $userManager->getFullAddress($document->user, true); ?> | |||||
<?= $userModule->getFullAddress($document->user, true); ?> | |||||
<?php endif; ?> | <?php endif; ?> | ||||
</div> | </div> | ||||
</div> | </div> |
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$invoiceManager = $this->getInvoiceManager(); | $invoiceManager = $this->getInvoiceManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$this->setTitle('Factures'); | $this->setTitle('Factures'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | 'headerOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | 'filterOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | 'contentOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'value' => function ($invoice) use ($userManager) { | |||||
return $userManager->getUsername($invoice->user); | |||||
'value' => function ($invoice) use ($userModule) { | |||||
return $userModule->getUsername($invoice->user); | |||||
} | } | ||||
], | ], | ||||
[ | [ |
use common\helpers\Price; | use common\helpers\Price; | ||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | use common\logic\Producer\Producer\Wrapper\ProducerManager; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\logic\Distribution\Distribution\Model\Distribution; | use common\logic\Distribution\Distribution\Model\Distribution; | ||||
use common\logic\Producer\Producer\Model\Producer; | use common\logic\Producer\Producer\Model\Producer; | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$producerManager = ProducerManager::getInstance(); | $producerManager = ProducerManager::getInstance(); | ||||
$producer = GlobalParam::getCurrentProducer(); | $producer = GlobalParam::getCurrentProducer(); | ||||
<div class="navbar-custom-menu"> | <div class="navbar-custom-menu"> | ||||
<?php | <?php | ||||
$usersArray = $userManager->queryUsersBy(['id_producer' => GlobalParam::getCurrentProducerId()]) | |||||
$usersArray = $userModule->queryUsersBy(['id_producer' => GlobalParam::getCurrentProducerId()]) | |||||
->andWhere('CAST(FROM_UNIXTIME(user.created_at) AS date) > \'' . date("Y-m-d", strtotime("-7 days")) . '\'') | ->andWhere('CAST(FROM_UNIXTIME(user.created_at) AS date) > \'' . date("Y-m-d", strtotime("-7 days")) . '\'') | ||||
->orderBy('created_at DESC') | ->orderBy('created_at DESC') | ||||
->all(); | ->all(); | ||||
<ul class="nav navbar-nav"> | <ul class="nav navbar-nav"> | ||||
<?php if ($userManager->isCurrentAdmin()): ?> | |||||
<?php if ($userModule->isCurrentAdmin()): ?> | |||||
<li class="dropdown producer-menu"> | <li class="dropdown producer-menu"> | ||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> | <a href="#" class="dropdown-toggle" data-toggle="dropdown"> | ||||
<span class="glyphicon glyphicon-grain"></span> | <span class="glyphicon glyphicon-grain"></span> | ||||
<?php | <?php | ||||
$usersNegativeCreditArray = $userManager->findUsersWithNegativeCredit(); | |||||
$usersNegativeCreditArray = $userModule->findUsersWithNegativeCredit(); | |||||
?> | ?> | ||||
<?php foreach ($usersNegativeCreditArray as $user): ?> | <?php foreach ($usersNegativeCreditArray as $user): ?> | ||||
<li> | <li> | ||||
<a href="<?= Yii::$app->urlManagerBackend->createUrl(['user/credit', 'id' => $user['user_id']]); ?>"> | <a href="<?= Yii::$app->urlManagerBackend->createUrl(['user/credit', 'id' => $user['user_id']]); ?>"> | ||||
<h5><?= $userManager->getUsernameFromArray($user); ?> | |||||
<h5><?= $userModule->getUsernameFromArray($user); ?> | |||||
<small> | <small> | ||||
<i class="fa fa-euro"></i> <?= Price::format($user['credit']); ?> | <i class="fa fa-euro"></i> <?= Price::format($user['credit']); ?> | ||||
</small> | </small> | ||||
</ul> | </ul> | ||||
</li> | </li> | ||||
<?php if ($userManager->isCurrentProducer() || $userManager->isCurrentAdmin()): ?> | |||||
<?php if ($userModule->isCurrentProducer() || $userModule->isCurrentAdmin()): ?> | |||||
<li> | <li> | ||||
<a href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => GlobalParam::getCurrentProducer()->slug]); ?>"> | <a href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => GlobalParam::getCurrentProducer()->slug]); ?>"> | ||||
<span class="glyphicon glyphicon-eye-open"></span> | <span class="glyphicon glyphicon-eye-open"></span> |
use common\logic\Ticket\Ticket\Wrapper\TicketManager; | use common\logic\Ticket\Ticket\Wrapper\TicketManager; | ||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$userProducerManager = $this->getUserProducerManager(); | $userProducerManager = $this->getUserProducerManager(); | ||||
$ticketManager = $this->getTicketManager(); | $ticketManager = $this->getTicketManager(); | ||||
$producer = GlobalParam::getCurrentProducer(); | $producer = GlobalParam::getCurrentProducer(); | ||||
$countTicketsProducerUnreadLabel = ''; | $countTicketsProducerUnreadLabel = ''; | ||||
$countTicketsProducerUnread = $ticketManager->countTicketsUnreadByUser($this->getUserCurrent()); | $countTicketsProducerUnread = $ticketManager->countTicketsUnreadByUser($this->getUserCurrent()); | ||||
if($countTicketsProducerUnread && !$userManager->isCurrentAdmin()) { | |||||
if($countTicketsProducerUnread && !$userModule->isCurrentAdmin()) { | |||||
$countTicketsProducerUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsProducerUnread.'</small></span>'; | $countTicketsProducerUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsProducerUnread.'</small></span>'; | ||||
} | } | ||||
$countTicketsAdminUnreadLabel = ''; | $countTicketsAdminUnreadLabel = ''; | ||||
$countTicketsAdminUnread = $ticketManager->countTicketsAdminUnreadByUser($this->getUserCurrent()); | $countTicketsAdminUnread = $ticketManager->countTicketsAdminUnreadByUser($this->getUserCurrent()); | ||||
if($countTicketsAdminUnread && $userManager->isCurrentAdmin()) { | |||||
if($countTicketsAdminUnread && $userModule->isCurrentAdmin()) { | |||||
$countTicketsAdminUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsAdminUnread.'</small></span>'; | $countTicketsAdminUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsAdminUnread.'</small></span>'; | ||||
} | } | ||||
[ | [ | ||||
'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'], | 'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'], | ||||
'items' => [ | 'items' => [ | ||||
['label' => "Besoin d'aide ?", 'options' => ['class' => 'header'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => "Besoin d'aide ?", 'options' => ['class' => 'header'], 'visible' => $userModule->isCurrentProducer()], | |||||
[ | [ | ||||
'label' => 'Support', | 'label' => 'Support', | ||||
'icon' => 'comments', | 'icon' => 'comments', | ||||
'url' => ['support/index'], | 'url' => ['support/index'], | ||||
'visible' => $userManager->isCurrentProducer(), | |||||
'visible' => $userModule->isCurrentProducer(), | |||||
'template' => '<a href="{url}">{icon} {label}' . $countTicketsProducerUnreadLabel . '</a>' | 'template' => '<a href="{url}">{icon} {label}' . $countTicketsProducerUnreadLabel . '</a>' | ||||
], | ], | ||||
['label' => $producer->name, 'options' => ['class' => 'header'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/dashboard/index'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => $producer->name, 'options' => ['class' => 'header'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/dashboard/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
[ | [ | ||||
'label' => 'Produits', | 'label' => 'Produits', | ||||
'icon' => 'clone', | 'icon' => 'clone', | ||||
'url' => ['/product/index'], | 'url' => ['/product/index'], | ||||
'visible' => $userManager->isCurrentProducer(), | |||||
'visible' => $userModule->isCurrentProducer(), | |||||
'active' => Yii::$app->controller->id == 'product', | 'active' => Yii::$app->controller->id == 'product', | ||||
'items' => [ | 'items' => [ | ||||
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/product/index'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Catégories', 'icon' => 'book', 'url' => ['/product-category/index'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Import prix', 'icon' => 'upload', 'url' => ['/product/price-import'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/product/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Catégories', 'icon' => 'book', 'url' => ['/product-category/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Import prix', 'icon' => 'upload', 'url' => ['/product/price-import'], 'visible' => $userModule->isCurrentProducer()], | |||||
] | ] | ||||
], | ], | ||||
['label' => 'Points de vente', 'icon' => 'map-marker', 'url' => ['/point-sale/index'], 'visible' => $userManager->isCurrentProducer(), 'active' => Yii::$app->controller->id == 'point-sale'], | |||||
['label' => 'Points de vente', 'icon' => 'map-marker', 'url' => ['/point-sale/index'], 'visible' => $userModule->isCurrentProducer(), 'active' => Yii::$app->controller->id == 'point-sale'], | |||||
[ | [ | ||||
'label' => 'Utilisateurs', | 'label' => 'Utilisateurs', | ||||
'icon' => 'users', | 'icon' => 'users', | ||||
'url' => ['/user/index'], | 'url' => ['/user/index'], | ||||
'items' => [ | 'items' => [ | ||||
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/user/index'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/user/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
[ | [ | ||||
'label' => 'Crédit', | 'label' => 'Crédit', | ||||
'icon' => 'euro', | 'icon' => 'euro', | ||||
'url' => ['/credit/index'], | 'url' => ['/credit/index'], | ||||
'template' => '<a href="{url}">{icon} {label}' . $sumUserProducerCreditsLabel . '</a>', | 'template' => '<a href="{url}">{icon} {label}' . $sumUserProducerCreditsLabel . '</a>', | ||||
'visible' => $userManager->isCurrentProducer() && $producerManager->getConfig('credit') | |||||
'visible' => $userModule->isCurrentProducer() && $producerManager->getConfig('credit') | |||||
], | ], | ||||
['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
], | ], | ||||
], | ], | ||||
['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => $userManager->isCurrentProducer(), 'active' => Yii::$app->controller->id == 'subscription'], | |||||
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate/index'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => $userModule->isCurrentProducer(), 'active' => Yii::$app->controller->id == 'subscription'], | |||||
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
[ | [ | ||||
'label' => 'Documents', | 'label' => 'Documents', | ||||
'icon' => 'clone', | 'icon' => 'clone', | ||||
'url' => ['/delivery-note/index'], | 'url' => ['/delivery-note/index'], | ||||
'items' => [ | 'items' => [ | ||||
['label' => 'Bons de livraison', 'icon' => 'sticky-note-o', 'url' => ['/delivery-note/index'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Factures', 'icon' => 'sticky-note-o', 'url' => ['/invoice/index'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Devis', 'icon' => 'sticky-note-o', 'url' => ['/quotation/index'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Bons de livraison', 'icon' => 'sticky-note-o', 'url' => ['/delivery-note/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Factures', 'icon' => 'sticky-note-o', 'url' => ['/invoice/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Devis', 'icon' => 'sticky-note-o', 'url' => ['/quotation/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
], | ], | ||||
], | ], | ||||
[ | [ | ||||
'icon' => 'line-chart', | 'icon' => 'line-chart', | ||||
'url' => ['/stats/index'], | 'url' => ['/stats/index'], | ||||
'items' => [ | 'items' => [ | ||||
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats/index'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Rapports', 'icon' => 'pencil-square-o', 'url' => ['/report/index'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Produits', 'icon' => 'table', 'url' => ['/stats/products'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Rapports', 'icon' => 'pencil-square-o', 'url' => ['/report/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Produits', 'icon' => 'table', 'url' => ['/stats/products'], 'visible' => $userModule->isCurrentProducer()], | |||||
], | ], | ||||
], | ], | ||||
['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/producer/update'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Accès', 'icon' => 'lock', 'url' => ['/access/index'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => "Opendistrib", 'options' => ['class' => 'header'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/producer/update'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Accès', 'icon' => 'lock', 'url' => ['/access/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => "Opendistrib", 'options' => ['class' => 'header'], 'visible' => $userModule->isCurrentProducer()], | |||||
[ | [ | ||||
'label' => 'Développement', | 'label' => 'Développement', | ||||
'icon' => 'code', | 'icon' => 'code', | ||||
'url' => ['/development/index'], | 'url' => ['/development/index'], | ||||
'visible' => $userManager->isCurrentProducer(), | |||||
'visible' => $userModule->isCurrentProducer(), | |||||
'active' => Yii::$app->controller->id == 'development', | 'active' => Yii::$app->controller->id == 'development', | ||||
'template' => '<a href="{url}">{icon} {label}' . $newVersionOpendistribLabel . '</a>' | 'template' => '<a href="{url}">{icon} {label}' . $newVersionOpendistribLabel . '</a>' | ||||
], | ], | ||||
['label' => 'Tarifs', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => $userManager->isCurrentProducer()], | |||||
['label' => 'Tarifs', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $userManager->isCurrentAdmin()], | |||||
['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $userModule->isCurrentAdmin()], | |||||
[ | [ | ||||
'label' => 'Tickets', | 'label' => 'Tickets', | ||||
'icon' => 'comments', | 'icon' => 'comments', | ||||
'url' => ['support-admin/index'], | 'url' => ['support-admin/index'], | ||||
'visible' => $userManager->isCurrentAdmin(), | |||||
'visible' => $userModule->isCurrentAdmin(), | |||||
'template' => '<a href="{url}">{icon} {label}' . $countTicketsAdminUnreadLabel . '</a>' | 'template' => '<a href="{url}">{icon} {label}' . $countTicketsAdminUnreadLabel . '</a>' | ||||
], | ], | ||||
['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => $userManager->isCurrentAdmin()], | |||||
['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => $userModule->isCurrentAdmin()], | |||||
[ | [ | ||||
'label' => 'Statistiques', | 'label' => 'Statistiques', | ||||
'icon' => 'line-chart', | 'icon' => 'line-chart', | ||||
'url' => ['/stats-admin/matomo'], | 'url' => ['/stats-admin/matomo'], | ||||
'visible' => $userManager->isCurrentAdmin(), | |||||
'visible' => $userModule->isCurrentAdmin(), | |||||
'items' => [ | 'items' => [ | ||||
['label' => 'Matomo', 'icon' => 'line-chart', 'url' => ['/stats-admin/matomo'], 'visible' => $userManager->isCurrentAdmin()], | |||||
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats-admin/turnover'], 'visible' => $userManager->isCurrentAdmin()], | |||||
['label' => 'Commandes clients', 'icon' => 'calendar', 'url' => ['/stats-admin/customer-orders'], 'visible' => $userManager->isCurrentAdmin()], | |||||
['label' => 'Matomo', 'icon' => 'line-chart', 'url' => ['/stats-admin/matomo'], 'visible' => $userModule->isCurrentAdmin()], | |||||
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats-admin/turnover'], 'visible' => $userModule->isCurrentAdmin()], | |||||
['label' => 'Commandes clients', 'icon' => 'calendar', 'url' => ['/stats-admin/customer-orders'], 'visible' => $userModule->isCurrentAdmin()], | |||||
], | ], | ||||
], | ], | ||||
['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => $userManager->isCurrentAdmin()], | |||||
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $userManager->isCurrentAdmin()], | |||||
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => $userManager->isCurrentAdmin()], | |||||
['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => $userModule->isCurrentAdmin()], | |||||
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $userModule->isCurrentAdmin()], | |||||
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => $userModule->isCurrentAdmin()], | |||||
//['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => $userManager->isCurrentAdmin()], | |||||
//['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => $userManager->isCurrentAdmin()], | |||||
//['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => $userManager->isCurrentAdmin()], | |||||
['label' => 'Login', 'url' => ['site/login'], 'visible' => !$userManager->isCurrentConnected()], | |||||
//['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => $userModule->isCurrentAdmin()], | |||||
//['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => $userModule->isCurrentAdmin()], | |||||
//['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => $userModule->isCurrentAdmin()], | |||||
['label' => 'Login', 'url' => ['site/login'], 'visible' => !$userModule->isCurrentConnected()], | |||||
], | ], | ||||
] | ] | ||||
) ?> | ) ?> |
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use yii\helpers\ArrayHelper; | use yii\helpers\ArrayHelper; | ||||
use common\logic\Producer\Producer\Model\Producer; | use common\logic\Producer\Producer\Model\Producer; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
?> | ?> | ||||
<?= $form->field($model, 'id_user', [ | <?= $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}', | '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($userManager->populateUserDropdownList(), ['class' => 'select2']) | |||||
->dropDownList($userModule->populateUserDropdownList(), ['class' => 'select2']) | |||||
->hint('Utilisé lors de la facturation'); ?> | ->hint('Utilisé lors de la facturation'); ?> | ||||
<?php | <?php | ||||
$addHintCredit = ''; | $addHintCredit = ''; | ||||
. 'Dans le cas des boîtes à pain, il vous est possible de spécifier un commentaire pour chaque utilisateur sélectionné afin de lui renseigner son numéro de boîte ou son code.') ?> | . 'Dans le cas des boîtes à pain, il vous est possible de spécifier un commentaire pour chaque utilisateur sélectionné afin de lui renseigner son numéro de boîte ou son code.') ?> | ||||
<div id="users"> | <div id="users"> | ||||
<?= Html::activeCheckboxList($model, 'users', ArrayHelper::map($users, 'user_id', function ($model_user, $defaultValue) use ($model) { | <?= Html::activeCheckboxList($model, 'users', ArrayHelper::map($users, 'user_id', function ($model_user, $defaultValue) use ($model) { | ||||
$userManager = UserManager::getInstance(); | |||||
return Html::encode($userManager->getUsernameFromArray($model_user)) . '<br />' | |||||
$userModule = UserModule::getInstance(); | |||||
return Html::encode($userModule->getUsernameFromArray($model_user)) . '<br />' | |||||
. Html::activeTextInput( | . Html::activeTextInput( | ||||
$model, | $model, | ||||
'users_comment[' . $model_user['user_id'] . ']', | 'users_comment[' . $model_user['user_id'] . ']', |
use common\logic\Document\Document\Model\Document; | use common\logic\Document\Document\Model\Document; | ||||
use yii\helpers\ArrayHelper; | use yii\helpers\ArrayHelper; | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
\backend\assets\VuejsProducerUpdateAsset::register($this); | \backend\assets\VuejsProducerUpdateAsset::register($this); | ||||
$this->setTitle('Paramètres'); | $this->setTitle('Paramètres'); | ||||
<script> | <script> | ||||
var appInitValues = { | var appInitValues = { | ||||
isAdmin: <?= (int) $userManager->isCurrentAdmin() ?> | |||||
isAdmin: <?= (int) $userModule->isCurrentAdmin() ?> | |||||
}; | }; | ||||
</script> | </script> | ||||
use yii\bootstrap\ActiveForm; | use yii\bootstrap\ActiveForm; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$userGroupManager = $this->getUserGroupManager(); | $userGroupManager = $this->getUserGroupManager(); | ||||
$pointSaleManager = $this->getPointSaleManager(); | $pointSaleManager = $this->getPointSaleManager(); | ||||
$productManager = $this->getProductManager(); | $productManager = $this->getProductManager(); | ||||
'options' => ['enctype' => 'multipart/form-data'] | 'options' => ['enctype' => 'multipart/form-data'] | ||||
]); ?> | ]); ?> | ||||
<?= $form->field($model, 'id_user')->dropDownList($userManager->populateUserDropdownList()); ?> | |||||
<?= $form->field($model, 'id_user')->dropDownList($userModule->populateUserDropdownList()); ?> | |||||
<?= $form->field($model, 'id_user_group')->dropDownList($userGroupManager->populateUserGroupDropdownList()); ?> | <?= $form->field($model, 'id_user_group')->dropDownList($userGroupManager->populateUserGroupDropdownList()); ?> | ||||
<?= $form->field($model, 'id_point_sale')->dropDownList($pointSaleManager->populatePointSaleDropdownList()); ?> | <?= $form->field($model, 'id_point_sale')->dropDownList($pointSaleManager->populatePointSaleDropdownList()); ?> | ||||
<?= $form->field($model, 'from_quantity')->label('À partir de la quantité ('. $productManager->strUnit($productManager->getRefUnit($modelProduct->unit), 'wording').')'); ?> | <?= $form->field($model, 'from_quantity')->label('À partir de la quantité ('. $productManager->strUnit($productManager->getRefUnit($modelProduct->unit), 'wording').')'); ?> |
* termes. | * termes. | ||||
*/ | */ | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use common\helpers\Price; | use common\helpers\Price; | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
use common\logic\Product\Product\Wrapper\ProductManager; | use common\logic\Product\Product\Wrapper\ProductManager; | ||||
$productManager = ProductManager::getInstance(); | $productManager = ProductManager::getInstance(); | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$this->setTitle('Liste des prix (' . Html::encode($model->name) . ')'); | $this->setTitle('Liste des prix (' . Html::encode($model->name) . ')'); | ||||
$this->addBreadcrumb(['label' => 'Produits', 'url' => ['index']]); | $this->addBreadcrumb(['label' => 'Produits', 'url' => ['index']]); | ||||
[ | [ | ||||
'attribute' => 'id_user', | 'attribute' => 'id_user', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($model) use ($userManager) { | |||||
'value' => function ($model) use ($userModule) { | |||||
if ($model->user) { | if ($model->user) { | ||||
return $userManager->getUsername($model->user); | |||||
return $userModule->getUsername($model->user); | |||||
} | } | ||||
return '<span class="label label-success">Tous</span>'; | return '<span class="label label-success">Tous</span>'; | ||||
} | } |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
$quotationManager = $this->getQuotationManager(); | $quotationManager = $this->getQuotationManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$this->setTitle('Devis'); | $this->setTitle('Devis'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | 'headerOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | 'filterOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | 'contentOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'value' => function ($quotation) use ($userManager) { | |||||
return $userManager->getUsername($quotation->user); | |||||
'value' => function ($quotation) use ($userModule) { | |||||
return $userModule->getUsername($quotation->user); | |||||
} | } | ||||
], | ], | ||||
[ | [ |
\backend\assets\VuejsSubscriptionFormAsset::register($this); | \backend\assets\VuejsSubscriptionFormAsset::register($this); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$pointSaleManager = $this->getPointSaleManager(); | $pointSaleManager = $this->getPointSaleManager(); | ||||
?> | ?> | ||||
<?= $form->field($model, 'id')->hiddenInput() ?> | <?= $form->field($model, 'id')->hiddenInput() ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<div class="col-md-5" id="bloc-select-user"> | <div class="col-md-5" id="bloc-select-user"> | ||||
<?= $form->field($model, 'id_user')->dropDownList($userManager->populateUserDropdownList(), ['class' => 'select2']); ?> | |||||
<?= $form->field($model, 'id_user')->dropDownList($userModule->populateUserDropdownList(), ['class' => 'select2']); ?> | |||||
</div> | </div> | ||||
<div class="col-md-1" id="or-user"> | <div class="col-md-1" id="or-user"> | ||||
<span>OU</span> | <span>OU</span> |
<?php | <?php | ||||
use common\logic\Ticket\Ticket\Wrapper\TicketManager; | use common\logic\Ticket\Ticket\Wrapper\TicketManager; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
$ticketManager = TicketManager::getInstance(); | $ticketManager = TicketManager::getInstance(); | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$this->setTitle('Voir un ticket'); | $this->setTitle('Voir un ticket'); | ||||
$this->addBreadcrumb(['label' => 'Support', 'url' => ['index']]); | $this->addBreadcrumb(['label' => 'Support', 'url' => ['index']]); | ||||
$this->addBreadcrumb('Voir un ticket'); | $this->addBreadcrumb('Voir un ticket'); | ||||
<td><strong>Statut</strong></td> | <td><strong>Statut</strong></td> | ||||
<td><?= $ticketManager->getTicketStatusLabelAsHtml($ticket); ?></td> | <td><?= $ticketManager->getTicketStatusLabelAsHtml($ticket); ?></td> | ||||
</tr> | </tr> | ||||
<?php if($userManager->isCurrentAdmin()): ?> | |||||
<?php if($userModule->isCurrentAdmin()): ?> | |||||
<tr> | <tr> | ||||
<td><strong>Producteur</strong></td> | <td><strong>Producteur</strong></td> | ||||
<td><?= $ticketManager->isTicketUnread($ticket, $ticket->user) ? | <td><?= $ticketManager->isTicketUnread($ticket, $ticket->user) ? | ||||
<a name="bottom"></a> | <a name="bottom"></a> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<a name="<?= $ticketMessage->id ?>"></a> | <a name="<?= $ticketMessage->id ?>"></a> | ||||
<i class="fa fa-user <?= $userManager->isAdmin($ticketMessage->user) ? 'bg-orange' : 'bg-aqua'; ?>"></i> | |||||
<i class="fa fa-user <?= $userModule->isAdmin($ticketMessage->user) ? 'bg-orange' : 'bg-aqua'; ?>"></i> | |||||
<div class="timeline-item"> | <div class="timeline-item"> | ||||
<span class="time"><i class="fa fa-clock-o"></i> <?= date('d/m/Y à H:i', strtotime($ticketMessage->created_at)) ?></span> | <span class="time"><i class="fa fa-clock-o"></i> <?= date('d/m/Y à H:i', strtotime($ticketMessage->created_at)) ?></span> | ||||
<h3 class="timeline-header"><?= Html::encode($userManager->getUsername($ticketMessage->user)); ?></h3> | |||||
<h3 class="timeline-header"><?= Html::encode($userModule->getUsername($ticketMessage->user)); ?></h3> | |||||
<div class="timeline-body"> | <div class="timeline-body"> | ||||
<?= nl2br($ticketMessage->message); ?> | <?= nl2br($ticketMessage->message); ?> | ||||
</div> | </div> |
\backend\assets\VuejsUserFormAsset::register($this); | \backend\assets\VuejsUserFormAsset::register($this); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
?> | ?> | ||||
]); ?> | ]); ?> | ||||
<?= $form->field($model, 'type') | <?= $form->field($model, 'type') | ||||
->dropDownList($userManager->getTypeChoicesArray(), [ | |||||
->dropDownList($userModule->getTypeChoicesArray(), [ | |||||
'v-model' => 'type' | 'v-model' => 'type' | ||||
]); ?> | ]); ?> | ||||
<?= $form->field($model, 'name_legal_person', ['options' => ['v-show' => "type == 'legal-person'"]])->textInput() ?> | <?= $form->field($model, 'name_legal_person', ['options' => ['v-show' => "type == 'legal-person'"]])->textInput() ?> |
$paymentManager = $this->getPaymentManager(); | $paymentManager = $this->getPaymentManager(); | ||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$this->setTitle('Créditer <small>'.Html::encode($user->lastname.' '.$user->name).'</small>', 'Créditer '.Html::encode($user->lastname.' '.$user->name)) ; | $this->setTitle('Créditer <small>'.Html::encode($user->lastname.' '.$user->name).'</small>', 'Créditer '.Html::encode($user->lastname.' '.$user->name)) ; | ||||
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]) ; | $this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]) ; | ||||
</div> | </div> | ||||
<div class="col-md-8"> | <div class="col-md-8"> | ||||
<h2>Historique <span class="the-credit"><?= number_format($userManager->getCredit($user), 2); ?> €</span></h2> | |||||
<h2>Historique <span class="the-credit"><?= number_format($userModule->getCredit($user), 2); ?> €</span></h2> | |||||
<?= GridView::widget([ | <?= GridView::widget([ | ||||
'dataProvider' => $dataProvider, | 'dataProvider' => $dataProvider, |
use common\logic\Producer\Producer\Wrapper\ProducerManager; | use common\logic\Producer\Producer\Wrapper\ProducerManager; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use common\logic\Order\Order\Model\Order; | use common\logic\Order\Order\Model\Order; | ||||
use common\logic\User\UserProducer\Model\UserProducer; | use common\logic\User\UserProducer\Model\UserProducer; | ||||
use common\logic\User\User\Model\User; | use common\logic\User\User\Model\User; | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$producerManager = ProducerManager::getInstance(); | $producerManager = ProducerManager::getInstance(); | ||||
$this->setTitle('Utilisateurs'); | $this->setTitle('Utilisateurs'); | ||||
'attribute' => 'username', | 'attribute' => 'username', | ||||
'label' => 'Nom', | 'label' => 'Nom', | ||||
'value' => function ($model) { | 'value' => function ($model) { | ||||
$userManager = UserManager::getInstance(); | |||||
return $userManager->getUsername($model); | |||||
$userModule = UserModule::getInstance(); | |||||
return $userModule->getUsername($model); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | 'headerOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | 'filterOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | 'contentOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'filter' => $userManager->getTypeChoicesArray(), | |||||
'filter' => $userModule->getTypeChoicesArray(), | |||||
'value' => function ($model) { | 'value' => function ($model) { | ||||
$userManager = UserManager::getInstance(); | |||||
$typeArray = $userManager->getTypeChoicesArray(); | |||||
$userModule = UserModule::getInstance(); | |||||
$typeArray = $userModule->getTypeChoicesArray(); | |||||
if(isset($typeArray[$model['type']])) { | if(isset($typeArray[$model['type']])) { | ||||
return $typeArray[$model['type']]; | return $typeArray[$model['type']]; | ||||
} | } | ||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | 'filterOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | 'contentOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'value' => function ($model) { | 'value' => function ($model) { | ||||
$userManager = UserManager::getInstance(); | |||||
if($userManager->isUserSubscribedNewsletter($model)) { | |||||
$userModule = UserModule::getInstance(); | |||||
if($userModule->isUserSubscribedNewsletter($model)) { | |||||
return '<span class="label label-success">Oui</span>'; | return '<span class="label label-success">Oui</span>'; | ||||
} | } | ||||
]); | ]); | ||||
}, | }, | ||||
'switch' => function($url, $model) { | 'switch' => function($url, $model) { | ||||
$userManager = UserManager::getInstance(); | |||||
if($userManager->isCurrentAdmin()) { | |||||
$userModule = UserModule::getInstance(); | |||||
if($userModule->isCurrentAdmin()) { | |||||
return Html::a('<span class="glyphicon glyphicon-user"></span>', Yii::$app->urlManager->createUrl(['user/switch-identity', 'id' => $model->id]), [ | return Html::a('<span class="glyphicon glyphicon-user"></span>', Yii::$app->urlManager->createUrl(['user/switch-identity', 'id' => $model->id]), [ | ||||
'title' => 'Prendre la main', 'class' => 'btn btn-default' | 'title' => 'Prendre la main', 'class' => 'btn btn-default' | ||||
]); | ]); |
use yii\grid\GridView; | use yii\grid\GridView; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$orderManager = $this->getOrderManager(); | $orderManager = $this->getOrderManager(); | ||||
$this->setTitle('Commandes <small>' . Html::encode($userManager->getUsername($user)) . '</small>', 'Commandes de ' . Html::encode($userManager->getUsername($user))); | |||||
$this->setTitle('Commandes <small>' . Html::encode($userModule->getUsername($user)) . '</small>', 'Commandes de ' . Html::encode($userModule->getUsername($user))); | |||||
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]); | $this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]); | ||||
$this->addBreadcrumb(['label' => Html::encode($user->lastname . ' ' . $user->name)]); | $this->addBreadcrumb(['label' => Html::encode($user->lastname . ' ' . $user->name)]); | ||||
$this->addBreadcrumb('Commandes'); | $this->addBreadcrumb('Commandes'); |
use common\logic\Ticket\TicketUser\Wrapper\TicketUserManager; | use common\logic\Ticket\TicketUser\Wrapper\TicketUserManager; | ||||
use common\logic\User\User\Wrapper\UserContainer; | use common\logic\User\User\Wrapper\UserContainer; | ||||
use common\logic\User\User\Wrapper\UserManager; | use common\logic\User\User\Wrapper\UserManager; | ||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use common\logic\User\UserGroup\Wrapper\UserGroupContainer; | use common\logic\User\UserGroup\Wrapper\UserGroupContainer; | ||||
use common\logic\User\UserGroup\Wrapper\UserGroupManager; | use common\logic\User\UserGroup\Wrapper\UserGroupManager; | ||||
use common\logic\User\UserProducer\Wrapper\UserProducerContainer; | use common\logic\User\UserProducer\Wrapper\UserProducerContainer; | ||||
return PaymentManager::getInstance(); | return PaymentManager::getInstance(); | ||||
} | } | ||||
public function getUserManager(): UserManager | |||||
public function getUserModule(): UserModule | |||||
{ | { | ||||
return UserManager::getInstance(); | |||||
return UserModule::getInstance(); | |||||
} | |||||
public function getUserContainer(): UserContainer | |||||
{ | |||||
return UserContainer::getInstance(); | |||||
} | } | ||||
public function getUserGroupManager(): UserGroupManager | public function getUserGroupManager(): UserGroupManager | ||||
return TicketUserManager::getInstance(); | return TicketUserManager::getInstance(); | ||||
} | } | ||||
public function getUserContainer(): UserContainer | |||||
{ | |||||
return UserContainer::getInstance(); | |||||
} | |||||
public function getProducerContainer(): ProducerContainer | public function getProducerContainer(): ProducerContainer | ||||
{ | { | ||||
return ProducerContainer::getInstance(); | return ProducerContainer::getInstance(); |
public function beforeAction($event) | public function beforeAction($event) | ||||
{ | { | ||||
if (!Yii::$app->user->isGuest) { | if (!Yii::$app->user->isGuest) { | ||||
$this->getUserManager()->updateUserLastConnection(Yii::$app->user->identity); | |||||
$this->getUserModule()->updateUserLastConnection(Yii::$app->user->identity); | |||||
} | } | ||||
return parent::beforeAction($event); | return parent::beforeAction($event); | ||||
public function isUserCurrentAdmin() | public function isUserCurrentAdmin() | ||||
{ | { | ||||
return $this->getUserManager()->isAdmin($this->getUserCurrent()); | |||||
return $this->getUserModule()->isAdmin($this->getUserCurrent()); | |||||
} | } | ||||
public function getRequest() | public function getRequest() |
use common\logic\Subscription\ProductSubscription\Model\ProductSubscription; | use common\logic\Subscription\ProductSubscription\Model\ProductSubscription; | ||||
use common\logic\Subscription\Subscription\Model\Subscription; | use common\logic\Subscription\Subscription\Model\Subscription; | ||||
use common\logic\Subscription\Subscription\Wrapper\SubscriptionManager; | use common\logic\Subscription\Subscription\Wrapper\SubscriptionManager; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use Yii; | use Yii; | ||||
use yii\base\Model; | use yii\base\Model; | ||||
*/ | */ | ||||
public function save() | public function save() | ||||
{ | { | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$subscriptionManager = SubscriptionManager::getInstance(); | $subscriptionManager = SubscriptionManager::getInstance(); | ||||
if ($this->id) { | if ($this->id) { | ||||
$subscription = Subscription::searchOne(['id' => $this->id]) ; | $subscription = Subscription::searchOne(['id' => $this->id]) ; | ||||
$subscription->populateUpdatedBy($userManager->getCurrent()); | |||||
$subscription->populateUpdatedBy($userModule->getCurrent()); | |||||
} | } | ||||
else { | else { | ||||
$subscription = $subscriptionManager->instanciateSubscription($userManager->getCurrent()) ; | |||||
$subscription = $subscriptionManager->instanciateSubscription($userModule->getCurrent()) ; | |||||
} | } | ||||
if ($subscription) { | if ($subscription) { |
<?php | |||||
namespace common\logic; | |||||
use yii\base\ErrorException; | |||||
abstract class AbstractModule extends AbstractSingleton implements ModuleInterface | |||||
{ | |||||
protected ContainerInterface $container; | |||||
public function __call($method, $args) | |||||
{ | |||||
foreach($this->getContainer()->getServices() as $serviceClass) { | |||||
if(method_exists($serviceClass, $method)) { | |||||
return call_user_func_array( | |||||
[$serviceClass::getInstance(), $method], | |||||
$args | |||||
); | |||||
} | |||||
} | |||||
throw new ErrorException('La méthode '.$method.' est introuvable dans les services du container '.get_class($this->container)); | |||||
} | |||||
protected function setContainer(ContainerInterface $container): void | |||||
{ | |||||
$this->container = $container; | |||||
} | |||||
public function getContainer(): ContainerInterface | |||||
{ | |||||
return $this->container; | |||||
} | |||||
public function initContainer(): void | |||||
{ | |||||
$containerFqcn = $this->getContainerFqcn(); | |||||
$this->setContainer($containerFqcn::getInstance()); | |||||
} | |||||
} |
if (!isset(self::$instances[$c])) { | if (!isset(self::$instances[$c])) { | ||||
self::$instances[$c] = new $c; | self::$instances[$c] = new $c; | ||||
if(in_array(ManagerInterface::class, class_implements(self::$instances[$c]))) { | |||||
if(in_array(ManagerInterface::class, class_implements(self::$instances[$c])) | |||||
|| in_array(ModuleInterface::class, class_implements(self::$instances[$c]))) { | |||||
self::$instances[$c]->initContainer(); | self::$instances[$c]->initContainer(); | ||||
} | } | ||||
<?php | |||||
namespace common\logic; | |||||
interface ModuleInterface | |||||
{ | |||||
public function getContainerFqcn(): string; | |||||
public function getServices(): ContainerInterface; | |||||
} |
use common\logic\Order\Order\Event\OrderDeleteEvent; | use common\logic\Order\Order\Event\OrderDeleteEvent; | ||||
use common\logic\Order\Order\Model\Order; | use common\logic\Order\Order\Model\Order; | ||||
use common\logic\Payment\Wrapper\PaymentManager; | use common\logic\Payment\Wrapper\PaymentManager; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use justcoded\yii2\eventlistener\observers\Observer; | use justcoded\yii2\eventlistener\observers\Observer; | ||||
class OrderObserver extends Observer | class OrderObserver extends Observer | ||||
{ | { | ||||
$order = $event->order; | $order = $event->order; | ||||
$paymentManager = PaymentManager::getInstance(); | $paymentManager = PaymentManager::getInstance(); | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$paymentManager->refundOrderCredit($order, $userManager->getCurrent()); | |||||
$paymentManager->refundOrderCredit($order, $userModule->getCurrent()); | |||||
} | } | ||||
} | } |
<?php | <?php | ||||
namespace common\logic\User\User\Event; | namespace common\logic\User\User\Event; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use justcoded\yii2\eventlistener\observers\ActiveRecordObserver; | use justcoded\yii2\eventlistener\observers\ActiveRecordObserver; | ||||
use yii\db\AfterSaveEvent; | use yii\db\AfterSaveEvent; | ||||
public function inserted(AfterSaveEvent $event) | public function inserted(AfterSaveEvent $event) | ||||
{ | { | ||||
$ticket = $event->sender; | $ticket = $event->sender; | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$userManager->sendMailNewTicketAdmin($ticket); | |||||
$userModule->sendMailNewTicketAdmin($ticket); | |||||
} | } | ||||
} | } |
use common\logic\PointSale\PointSale\Model\PointSale; | use common\logic\PointSale\PointSale\Model\PointSale; | ||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | use common\logic\Producer\Producer\Wrapper\ProducerManager; | ||||
use common\logic\User\User\Repository\UserRepository; | use common\logic\User\User\Repository\UserRepository; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use yii\data\ActiveDataProvider; | use yii\data\ActiveDataProvider; | ||||
class UserSearch extends User | class UserSearch extends User | ||||
public function search($params = []) | public function search($params = []) | ||||
{ | { | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$producerManager = ProducerManager::getInstance(); | $producerManager = ProducerManager::getInstance(); | ||||
$producer = GlobalParam::getCurrentProducer(); | $producer = GlobalParam::getCurrentProducer(); | ||||
]); | ]); | ||||
} | } | ||||
if ($userManager->isTypeValid($this->type)) { | |||||
if ($userModule->isTypeValid($this->type)) { | |||||
$query->andWhere(['user.type' => $this->type]); | $query->andWhere(['user.type' => $this->type]); | ||||
} | } | ||||
use common\logic\User\UserProducer\Service\UserProducerBuilder; | use common\logic\User\UserProducer\Service\UserProducerBuilder; | ||||
use common\logic\UtilsInterface; | use common\logic\UtilsInterface; | ||||
class NewsletterUtils extends AbstractService implements UtilsInterface | |||||
class NewsletterManager extends AbstractService implements UtilsInterface | |||||
{ | { | ||||
protected UserProducerRepository $userProducerRepository; | protected UserProducerRepository $userProducerRepository; | ||||
protected UserProducerBuilder $userProducerBuilder; | protected UserProducerBuilder $userProducerBuilder; |
namespace common\logic\User\User\Service; | namespace common\logic\User\User\Service; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\helpers\Mailjet; | |||||
use common\logic\AbstractService; | |||||
use common\logic\AbstractNotifier; | |||||
use common\logic\Producer\Producer\Model\Producer; | use common\logic\Producer\Producer\Model\Producer; | ||||
use common\logic\Ticket\Ticket\Model\Ticket; | use common\logic\Ticket\Ticket\Model\Ticket; | ||||
use common\logic\User\User\Model\User; | use common\logic\User\User\Model\User; | ||||
use common\logic\UtilsInterface; | use common\logic\UtilsInterface; | ||||
class UserUtils extends AbstractService implements UtilsInterface | |||||
class UserNotifier extends AbstractNotifier implements UtilsInterface | |||||
{ | { | ||||
protected UserSolver $userSolver; | protected UserSolver $userSolver; | ||||
public function loadDependencies(): void | public function loadDependencies(): void | ||||
{ | { | ||||
parent::loadDependencies(); | |||||
$this->userSolver = $this->loadService(UserSolver::class); | $this->userSolver = $this->loadService(UserSolver::class); | ||||
} | } | ||||
public function sendEmailSignup(User $user, Producer $producer) | public function sendEmailSignup(User $user, Producer $producer) | ||||
{ | { | ||||
\Yii::$app->mailerService->sendFromSite( | |||||
$this->mailer->sendFromSite( | |||||
'Inscription', | 'Inscription', | ||||
'signup', | 'signup', | ||||
[ | [ | ||||
{ | { | ||||
if (strlen($user->email)) { | if (strlen($user->email)) { | ||||
$producer = Producer::findOne(GlobalParam::getCurrentProducerId()); | $producer = Producer::findOne(GlobalParam::getCurrentProducerId()); | ||||
\Yii::$app->mailerService->sendFromProducer( | |||||
$this->mailer->sendFromProducer( | |||||
'Inscription', | 'Inscription', | ||||
'createUserAdmin', | 'createUserAdmin', | ||||
[ | [ | ||||
public function sendMailNewTicketAdmin(Ticket $ticket) | public function sendMailNewTicketAdmin(Ticket $ticket) | ||||
{ | { | ||||
\Yii::$app->mailerService->sendAdmin( | |||||
$this->mailer->sendAdmin( | |||||
'Nouveau ticket', | 'Nouveau ticket', | ||||
'newTicketAdmin', | 'newTicketAdmin', | ||||
[ | [ |
use common\logic\AbstractContainer; | use common\logic\AbstractContainer; | ||||
use common\logic\User\User\Repository\UserRepository; | use common\logic\User\User\Repository\UserRepository; | ||||
use common\logic\User\User\Repository\UserRepositoryQuery; | use common\logic\User\User\Repository\UserRepositoryQuery; | ||||
use common\logic\User\User\Service\NewsletterManager; | |||||
use common\logic\User\User\Service\NewsletterUtils; | use common\logic\User\User\Service\NewsletterUtils; | ||||
use common\logic\User\User\Service\UserBuilder; | use common\logic\User\User\Service\UserBuilder; | ||||
use common\logic\User\User\Service\UserDefinition; | use common\logic\User\User\Service\UserDefinition; | ||||
use common\logic\User\User\Service\UserNotifier; | |||||
use common\logic\User\User\Service\UsersCreditCsvGenerator; | use common\logic\User\User\Service\UsersCreditCsvGenerator; | ||||
use common\logic\User\User\Service\UserSolver; | use common\logic\User\User\Service\UserSolver; | ||||
use common\logic\User\User\Service\UserUtils; | use common\logic\User\User\Service\UserUtils; | ||||
UserRepositoryQuery::class, | UserRepositoryQuery::class, | ||||
UserRepository::class, | UserRepository::class, | ||||
UserBuilder::class, | UserBuilder::class, | ||||
UserNotifier::class, | |||||
UsersCreditCsvGenerator::class, | UsersCreditCsvGenerator::class, | ||||
UserUtils::class, | |||||
NewsletterUtils::class, | |||||
NewsletterManager::class, | |||||
]; | ]; | ||||
} | } | ||||
return UserBuilder::getInstance(); | return UserBuilder::getInstance(); | ||||
} | } | ||||
public function getUtils(): UserUtils | |||||
public function getNotifier(): UserNotifier | |||||
{ | { | ||||
return UserUtils::getInstance(); | |||||
return UserNotifier::getInstance(); | |||||
} | |||||
public function getNewsletterManager(): NewsletterManager | |||||
{ | |||||
return NewsletterManager::getInstance(); | |||||
} | } | ||||
} | } |
namespace common\logic\User\User\Wrapper; | namespace common\logic\User\User\Wrapper; | ||||
use common\logic\AbstractManager; | |||||
use common\logic\AbstractModule; | |||||
use common\logic\User\User\Repository\UserRepository; | use common\logic\User\User\Repository\UserRepository; | ||||
use common\logic\User\User\Service\NewsletterUtils; | |||||
use common\logic\User\User\Service\NewsletterManager; | |||||
use common\logic\User\User\Service\UserBuilder; | use common\logic\User\User\Service\UserBuilder; | ||||
use common\logic\User\User\Service\UserDefinition; | use common\logic\User\User\Service\UserDefinition; | ||||
use common\logic\User\User\Service\UserNotifier; | |||||
use common\logic\User\User\Service\UsersCreditCsvGenerator; | use common\logic\User\User\Service\UsersCreditCsvGenerator; | ||||
use common\logic\User\User\Service\UserSolver; | use common\logic\User\User\Service\UserSolver; | ||||
use common\logic\User\User\Service\UserUtils; | |||||
/** | /** | ||||
* @mixin UserDefinition | * @mixin UserDefinition | ||||
* @mixin UserSolver | * @mixin UserSolver | ||||
* @mixin UserRepository | * @mixin UserRepository | ||||
* @mixin UserBuilder | * @mixin UserBuilder | ||||
* @mixin UserUtils | |||||
* @mixin UserNotifier | |||||
* @mixin UsersCreditCsvGenerator | * @mixin UsersCreditCsvGenerator | ||||
* @mixin NewsletterUtils | |||||
* @mixin NewsletterManager | |||||
*/ | */ | ||||
class UserManager extends AbstractManager | |||||
class UserModule extends AbstractModule | |||||
{ | { | ||||
public function getContainerFqcn(): string | public function getContainerFqcn(): string | ||||
{ | { | ||||
return UserContainer::class; | return UserContainer::class; | ||||
} | } | ||||
public function getServices(): UserContainer | |||||
{ | |||||
return $this->container; | |||||
} | |||||
} | } |
termes. | termes. | ||||
*/ | */ | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
?> | ?> | ||||
<p>Bonjour,</p> | <p>Bonjour,</p> | ||||
<p>Le client <strong><?= $userManager->getUsername($user) ?></strong> vient de passer une commande pour le <strong><?= date('d/m/Y',strtotime($distribution->date)) ?></strong> mais le paiement par carte bancaire n'a pas abouti.<br /> | |||||
<p>Le client <strong><?= $userModule->getUsername($user) ?></strong> vient de passer une commande pour le <strong><?= date('d/m/Y',strtotime($distribution->date)) ?></strong> mais le paiement par carte bancaire n'a pas abouti.<br /> | |||||
Il vient de recevoir un message pour régulariser le paiement par virement bancaire.</p> | Il vient de recevoir un message pour régulariser le paiement par virement bancaire.</p> | ||||
<p>Sa commande a été enregistrée avec l'état "non payé".</p> | <p>Sa commande a été enregistrée avec l'état "non payé".</p> |
termes. | termes. | ||||
*/ | */ | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
?> | ?> | ||||
Bonjour, | Bonjour, | ||||
Le client <?= $userManager->getUsername() ?> vient de passer une commande pour le <?= date('d/m/Y',strtotime($distribution->date)) ?> mais le paiement par carte bancaire n'a pas abouti. | |||||
Le client <?= $userModule->getUsername() ?> vient de passer une commande pour le <?= date('d/m/Y',strtotime($distribution->date)) ?> mais le paiement par carte bancaire n'a pas abouti. | |||||
Il vient de recevoir un message pour régulariser le paiement par virement bancaire. | Il vient de recevoir un message pour régulariser le paiement par virement bancaire. | ||||
Sa commande a été enregistrée avec l'état "non payé". | Sa commande a été enregistrée avec l'état "non payé". |
<?php | <?php | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
function version(string $date, array $featuresMaintenanceArray, array $featuresMaintenanceAdminArray = []) { | function version(string $date, array $featuresMaintenanceArray, array $featuresMaintenanceAdminArray = []) { | ||||
release_date($date); | release_date($date); | ||||
} | } | ||||
function features(array $featuresArray, array $featuresAdminArray) { | function features(array $featuresArray, array $featuresAdminArray) { | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
if(count($featuresArray) > 0 || count($featuresAdminArray) > 0) { | if(count($featuresArray) > 0 || count($featuresAdminArray) > 0) { | ||||
$html = '<div class="block block-features">'; | $html = '<div class="block block-features">'; | ||||
$html .= '<h4><span class="glyphicon glyphicon-flash"></span> Évolutions</h4>'; | $html .= '<h4><span class="glyphicon glyphicon-flash"></span> Évolutions</h4>'; | ||||
foreach($featuresArray as $feature) { | foreach($featuresArray as $feature) { | ||||
$html .= '<li>'.$feature.'</li>'; | $html .= '<li>'.$feature.'</li>'; | ||||
} | } | ||||
if($userManager->isCurrentAdmin()) { | |||||
if($userModule->isCurrentAdmin()) { | |||||
foreach($featuresAdminArray as $feature) { | foreach($featuresAdminArray as $feature) { | ||||
$html .= '<li class="admin">'.$feature.'</li>'; | $html .= '<li class="admin">'.$feature.'</li>'; | ||||
} | } | ||||
} | } | ||||
function maintenance(array $maintenanceArray, array $maintenanceAdminArray) { | function maintenance(array $maintenanceArray, array $maintenanceAdminArray) { | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
if(count($maintenanceArray) > 0 || count($maintenanceAdminArray) > 0) { | if(count($maintenanceArray) > 0 || count($maintenanceAdminArray) > 0) { | ||||
$html = '<div class="block block-maintenance">'; | $html = '<div class="block block-maintenance">'; | ||||
$html .= '<h4><span class="glyphicon glyphicon-wrench"></span> Maintenance</h4>'; | $html .= '<h4><span class="glyphicon glyphicon-wrench"></span> Maintenance</h4>'; | ||||
foreach($maintenanceArray as $maintenance) { | foreach($maintenanceArray as $maintenance) { | ||||
$html .= '<li>'.$maintenance.'</li>'; | $html .= '<li>'.$maintenance.'</li>'; | ||||
} | } | ||||
if($userManager->isCurrentAdmin()) { | |||||
if($userModule->isCurrentAdmin()) { | |||||
foreach ($maintenanceAdminArray as $maintenance) { | foreach ($maintenanceAdminArray as $maintenance) { | ||||
$html .= '<li class="admin">' . $maintenance . '</li>'; | $html .= '<li class="admin">' . $maintenance . '</li>'; | ||||
} | } |
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\logic\Producer\Producer\Model\Producer; | use common\logic\Producer\Producer\Model\Producer; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use yii\bootstrap\Nav; | use yii\bootstrap\Nav; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$producer = null; | $producer = null; | ||||
if ($userManager->isCurrentProducer()) { | |||||
if ($userModule->isCurrentProducer()) { | |||||
$producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]); | $producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]); | ||||
} | } | ||||
$itemAdministration = [ | $itemAdministration = [ | ||||
'label' => '<span class="glyphicon glyphicon-cog"></span> <span class="link-text">Administration</span>', | 'label' => '<span class="glyphicon glyphicon-cog"></span> <span class="link-text">Administration</span>', | ||||
'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['dashboard/index']), | 'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['dashboard/index']), | ||||
'visible' => $userManager->isCurrentProducer(), | |||||
'visible' => $userModule->isCurrentProducer(), | |||||
'linkOptions' => ['class' => 'btn btn-default navbar-btn'] | 'linkOptions' => ['class' => 'btn btn-default navbar-btn'] | ||||
]; | ]; | ||||
$itemProducerSpace = [ | $itemProducerSpace = [ | ||||
'label' => '<span class="glyphicon glyphicon-eye-open"></span> <span class="link-text">Mon espace producteur</span>', | 'label' => '<span class="glyphicon glyphicon-eye-open"></span> <span class="link-text">Mon espace producteur</span>', | ||||
'url' => $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer ? $producer->slug : '']), | 'url' => $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer ? $producer->slug : '']), | ||||
'visible' => $userManager->isCurrentProducer(), | |||||
'visible' => $userModule->isCurrentProducer(), | |||||
'linkOptions' => ['class' => 'btn btn-default navbar-btn'] | 'linkOptions' => ['class' => 'btn btn-default navbar-btn'] | ||||
]; | ]; | ||||
$itemProducers = [ | $itemProducers = [ |
$aboutFewNumbers = Yii::$app->cache->getOrSet('about_few_numbers7', function () { | $aboutFewNumbers = Yii::$app->cache->getOrSet('about_few_numbers7', function () { | ||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$pointSaleManager = $this->getPointSaleManager(); | $pointSaleManager = $this->getPointSaleManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$orderManager = $this->getOrderManager(); | $orderManager = $this->getOrderManager(); | ||||
$countProducersActive = $producerManager->countProducersActiveWithTurnover(); | $countProducersActive = $producerManager->countProducersActiveWithTurnover(); | ||||
$timeSavedByProducersAverage = $producerManager->getTimeSavedByProducersAverage(); | $timeSavedByProducersAverage = $producerManager->getTimeSavedByProducersAverage(); | ||||
$countProducersWithOptionTimeSaved = $producerManager->countProducersWithTimeSaved(); | $countProducersWithOptionTimeSaved = $producerManager->countProducersWithTimeSaved(); | ||||
$countPointSalesActive = $pointSaleManager->countPointSalesActiveLastThreeMonths(); | $countPointSalesActive = $pointSaleManager->countPointSalesActiveLastThreeMonths(); | ||||
$countUsersActive = $userManager->countUsersActiveLastThreeMonths(); | |||||
$countUsersActive = $userModule->countUsersActiveLastThreeMonths(); | |||||
$averageOrdersPerDay = $orderManager->countGlobalUserOrdersAverageLastSevenDays(); | $averageOrdersPerDay = $orderManager->countGlobalUserOrdersAverageLastSevenDays(); | ||||
$averageTurnover = $orderManager->getAverageTurnoverLastThreeMonths(); | $averageTurnover = $orderManager->getAverageTurnoverLastThreeMonths(); | ||||
$resultMatomoApiVisitSummary = json_decode(file_get_contents(Yii::$app->parameterBag->get('matomoApiVisitSummaryUrl'))); | $resultMatomoApiVisitSummary = json_decode(file_get_contents(Yii::$app->parameterBag->get('matomoApiVisitSummaryUrl'))); |
*/ | */ | ||||
protected function findModel($id) | protected function findModel($id) | ||||
{ | { | ||||
$userRepository = $this->getUserManager(); | |||||
$userRepository = $this->getUserModule(); | |||||
if (($model = $userRepository->findOneUserById($id)) !== null) { | if (($model = $userRepository->findOneUserById($id)) !== null) { | ||||
return $model; | return $model; |
namespace frontend\forms; | namespace frontend\forms; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use Yii; | use Yii; | ||||
use yii\base\Model; | use yii\base\Model; | ||||
*/ | */ | ||||
public function rules() | public function rules() | ||||
{ | { | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
return [ | return [ | ||||
[['message'], 'required', 'message' => 'Champs obligatoire'], | [['message'], 'required', 'message' => 'Champs obligatoire'], | ||||
[['name', 'email'], 'required', 'message' => 'Champs obligatoire', 'when' => function($model) use($userManager) { | |||||
return $userManager->isCurrentGuest(); | |||||
[['name', 'email'], 'required', 'message' => 'Champs obligatoire', 'when' => function($model) use($userModule) { | |||||
return $userModule->isCurrentGuest(); | |||||
}], | }], | ||||
['email', 'email', 'message' => 'Email incorrect'], | ['email', 'email', 'message' => 'Email incorrect'], | ||||
['isTest', 'string'], | ['isTest', 'string'], | ||||
['verifyCode', 'captcha', 'message' => 'Veuillez recopier le code de vérification', 'when' => function($model) use($userManager) { | |||||
return $model->isTest != 'isTest' && $userManager->isCurrentGuest(); | |||||
['verifyCode', 'captcha', 'message' => 'Veuillez recopier le code de vérification', 'when' => function($model) use($userModule) { | |||||
return $model->isTest != 'isTest' && $userModule->isCurrentGuest(); | |||||
}], | }], | ||||
]; | ]; | ||||
} | } |
use common\logic\User\User\Model\User; | use common\logic\User\User\Model\User; | ||||
use common\logic\User\User\Service\UserSolver; | use common\logic\User\User\Service\UserSolver; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use yii\base\Model; | use yii\base\Model; | ||||
use yii; | use yii; | ||||
*/ | */ | ||||
public function sendEmail() | public function sendEmail() | ||||
{ | { | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$user = User::findOne([ | $user = User::findOne([ | ||||
'email' => $this->email, | 'email' => $this->email, | ||||
]); | ]); | ||||
if ($user) { | if ($user) { | ||||
if (!$userManager->isPasswordResetTokenValid($user->password_reset_token)) { | |||||
$userManager->generatePasswordResetToken($user); | |||||
if (!$userModule->isPasswordResetTokenValid($user->password_reset_token)) { | |||||
$userModule->generatePasswordResetToken($user); | |||||
} | } | ||||
if ($user->save()) { | if ($user->save()) { |
namespace frontend\forms; | namespace frontend\forms; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use yii\base\InvalidParamException; | use yii\base\InvalidParamException; | ||||
use yii\base\Model; | use yii\base\Model; | ||||
use Yii; | use Yii; | ||||
*/ | */ | ||||
public function __construct($token, $config = []) | public function __construct($token, $config = []) | ||||
{ | { | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
if (empty($token) || !is_string($token)) { | if (empty($token) || !is_string($token)) { | ||||
throw new InvalidParamException('Password reset token cannot be blank.'); | throw new InvalidParamException('Password reset token cannot be blank.'); | ||||
} | } | ||||
$this->_user = $userManager->findOneUserByPasswordResetToken($token); | |||||
$this->_user = $userModule->findOneUserByPasswordResetToken($token); | |||||
if (!$this->_user) { | if (!$this->_user) { | ||||
throw new InvalidParamException('Wrong password reset token.'); | throw new InvalidParamException('Wrong password reset token.'); | ||||
} | } | ||||
*/ | */ | ||||
public function resetPassword() | public function resetPassword() | ||||
{ | { | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$user = $this->_user; | $user = $this->_user; | ||||
$userManager->setPassword($user, $this->password); | |||||
$userManager->removePasswordResetToken($user); | |||||
$userModule->setPassword($user, $this->password); | |||||
$userModule->removePasswordResetToken($user); | |||||
return $user->save(); | return $user->save(); | ||||
} | } |
use common\logic\Producer\Producer\Model\Producer; | use common\logic\Producer\Producer\Model\Producer; | ||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | use common\logic\Producer\Producer\Wrapper\ProducerManager; | ||||
use common\logic\User\User\Model\User; | use common\logic\User\User\Model\User; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use yii\base\Model; | use yii\base\Model; | ||||
/** | /** | ||||
*/ | */ | ||||
public function signup() | public function signup() | ||||
{ | { | ||||
$userManager = \Yii::$app->logic->getUserManager(); | |||||
$userModule = \Yii::$app->logic->getUserModule(); | |||||
$producerManager = \Yii::$app->logic->getProducerManager(); | $producerManager = \Yii::$app->logic->getProducerManager(); | ||||
if ($this->validate()) { | if ($this->validate()) { | ||||
$user = $userManager->instanciateUser(); | |||||
$user = $userModule->instanciateUser(); | |||||
$this->populateUser($user); | $this->populateUser($user); | ||||
if ($this->isProducer()) { | if ($this->isProducer()) { | ||||
\Yii::$app->logic->setProducerContext($producer); | \Yii::$app->logic->setProducerContext($producer); | ||||
$producerManager->addUser($user, $producer, true, $this->newsletter); | $producerManager->addUser($user, $producer, true, $this->newsletter); | ||||
$userManager->sendEmailSignup($user, $producer); | |||||
$userModule->sendEmailSignup($user, $producer); | |||||
return $user; | return $user; | ||||
} | } | ||||
public function processFormProducer($user) | public function processFormProducer($user) | ||||
{ | { | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$producerManager = ProducerManager::getInstance(); | $producerManager = ProducerManager::getInstance(); | ||||
// Création du producteur | // Création du producteur | ||||
$producerManager->sendEmailNewProducer($producer); | $producerManager->sendEmailNewProducer($producer); | ||||
// Initialisation de l'utilisateur (statut et liaison au producteur) | // Initialisation de l'utilisateur (statut et liaison au producteur) | ||||
$userManager->initProducer($user, $producer); | |||||
$userModule->initProducer($user, $producer); | |||||
return $producer; | return $producer; | ||||
} | } | ||||
public function populateUser($user) | public function populateUser($user) | ||||
{ | { | ||||
$userManager = UserManager::getInstance(); | |||||
$userManager->initPassword($user, $this->password); | |||||
$userModule = UserModule::getInstance(); | |||||
$userModule->initPassword($user, $this->password); | |||||
$user->username = $this->email; | $user->username = $this->email; | ||||
$user->email = $this->email; | $user->email = $this->email; |
* termes. | * termes. | ||||
*/ | */ | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\bootstrap\Nav; | use yii\bootstrap\Nav; | ||||
use common\logic\Producer\Producer\Model\Producer; | use common\logic\Producer\Producer\Model\Producer; | ||||
\common\assets\CommonAsset::register($this); | \common\assets\CommonAsset::register($this); | ||||
\frontend\assets\AppAsset::register($this); | \frontend\assets\AppAsset::register($this); | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$isHome = (Yii::$app->controller->id == 'site' && \Yii::$app->controller->action->id == 'index'); | $isHome = (Yii::$app->controller->id == 'site' && \Yii::$app->controller->action->id == 'index'); | ||||
$producer = null; | $producer = null; | ||||
if ($userManager->isCurrentProducer()) { | |||||
if ($userModule->isCurrentProducer()) { | |||||
$producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]); | $producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]); | ||||
} | } | ||||
*/ | */ | ||||
use common\logic\Config\TaxRate\Model\TaxRate; | use common\logic\Config\TaxRate\Model\TaxRate; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\bootstrap\ActiveForm; | use yii\bootstrap\ActiveForm; | ||||
use yii\helpers\ArrayHelper; | use yii\helpers\ArrayHelper; | ||||
$this->setMeta('description', 'Inscrivez-vous afin de profiter des fonctionnalités de la plateforme.'); | $this->setMeta('description', 'Inscrivez-vous afin de profiter des fonctionnalités de la plateforme.'); | ||||
$this->params['breadcrumbs'][] = $this->title; | $this->params['breadcrumbs'][] = $this->title; | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$urlRedirect = null; | $urlRedirect = null; | ||||
if($userManager->isProducer($user)) { | |||||
if($userModule->isProducer($user)) { | |||||
$urlRedirect = $this->getUrlManagerBackend()->createAbsoluteUrl(['dashboard/index']); | $urlRedirect = $this->getUrlManagerBackend()->createAbsoluteUrl(['dashboard/index']); | ||||
$redirectLabel = "Redirection vers votre tableau de bord ..."; | $redirectLabel = "Redirection vers votre tableau de bord ..."; | ||||
} | } |
return $this->redirect($this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $producer->id])); | return $this->redirect($this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $producer->id])); | ||||
} | } | ||||
$userContainer = $this->getUserContainer(); | |||||
$userModule = $this->getUserModule(); | |||||
$paymentContainer = $this->getPaymentContainer(); | $paymentContainer = $this->getPaymentContainer(); | ||||
$userCurrent = $this->getUserCurrent(); | $userCurrent = $this->getUserCurrent(); | ||||
return $this->render('history', [ | return $this->render('history', [ | ||||
'dataProvider' => $paymentContainer->getRepository() | 'dataProvider' => $paymentContainer->getRepository() | ||||
->queryPaymentsCreditHistoryByUser($userCurrent)->getDataProvider(20), | ->queryPaymentsCreditHistoryByUser($userCurrent)->getDataProvider(20), | ||||
'creditUser' => $userContainer->getRepository()->getCredit($userCurrent) | |||||
'creditUser' => $userModule->getCredit($userCurrent) | |||||
]); | ]); | ||||
} | } | ||||
$orderManager = $this->getOrderManager(); | $orderManager = $this->getOrderManager(); | ||||
$paymentManager = $this->getPaymentManager(); | $paymentManager = $this->getPaymentManager(); | ||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$producer = $this->getProducerCurrent(); | $producer = $this->getProducerCurrent(); | ||||
$contactProducer = $producerManager->getMainContact($producer); | $contactProducer = $producerManager->getMainContact($producer); | ||||
$idUser = $paymentIntentMetadata->user_id; | $idUser = $paymentIntentMetadata->user_id; | ||||
if($idUser) { | if($idUser) { | ||||
$user = $userManager->findOneUserById($idUser); | |||||
$user = $userModule->findOneUserById($idUser); | |||||
if (isset($paymentIntentMetadata->order_id)) { | if (isset($paymentIntentMetadata->order_id)) { | ||||
$order = $this->getOrderManager()->findOneOrderById($paymentIntentMetadata->order_id); | $order = $this->getOrderManager()->findOneOrderById($paymentIntentMetadata->order_id); |
return $this->redirectProducerLoginFrontend('subscribe'); | return $this->redirectProducerLoginFrontend('subscribe'); | ||||
} | } | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$userCurrent = $this->getUserCurrent(); | $userCurrent = $this->getUserCurrent(); | ||||
$userManager->subscribeUserNewsletter($userCurrent); | |||||
$userModule->subscribeUserNewsletter($userCurrent); | |||||
$this->setFlash('success', "Votre inscription au bulletin d'information a bien été prise en compte."); | $this->setFlash('success', "Votre inscription au bulletin d'information a bien été prise en compte."); | ||||
return $this->redirect('index'); | return $this->redirect('index'); | ||||
} | } | ||||
return $this->redirectProducerLoginFrontend('unsubscribe'); | return $this->redirectProducerLoginFrontend('unsubscribe'); | ||||
} | } | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$userCurrent = $this->getUserCurrent(); | $userCurrent = $this->getUserCurrent(); | ||||
$userManager->unsubscribeUserNewsletter($userCurrent); | |||||
$userModule->unsubscribeUserNewsletter($userCurrent); | |||||
$this->setFlash('success', "À partir de maintenant, vous ne recevrez plus d'email de la part de ce producteur."); | $this->setFlash('success', "À partir de maintenant, vous ne recevrez plus d'email de la part de ce producteur."); | ||||
return $this->redirect('index'); | return $this->redirect('index'); | ||||
} | } |
$orderManager = $this->getOrderManager(); | $orderManager = $this->getOrderManager(); | ||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$producer = $this->getProducerCurrent(); | $producer = $this->getProducerCurrent(); | ||||
$redirect = null; | $redirect = null; | ||||
$user = new User; | $user = new User; | ||||
$user->id_producer = 0; | $user->id_producer = 0; | ||||
$user->type = User::TYPE_GUEST; | $user->type = User::TYPE_GUEST; | ||||
$userManager->setPassword($user, Password::generate()); | |||||
$userManager->generateAuthKey($user); | |||||
$userModule->setPassword($user, Password::generate()); | |||||
$userModule->generateAuthKey($user); | |||||
$user->username = $posts['user']['email']; | $user->username = $posts['user']['email']; | ||||
$user->email = $posts['user']['email']; | $user->email = $posts['user']['email']; | ||||
$user->name = $posts['user']['firstname']; | $user->name = $posts['user']['firstname']; | ||||
$orderManager = $this->getOrderManager(); | $orderManager = $this->getOrderManager(); | ||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$productOrderManager = $this->getProductOrderManager(); | $productOrderManager = $this->getProductOrderManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$userModule = $this->getUserModule(); | |||||
$paymentManager = $this->getPaymentManager(); | $paymentManager = $this->getPaymentManager(); | ||||
$posts = \Yii::$app->request->post(); | $posts = \Yii::$app->request->post(); |
use common\logic\Order\Order\Model\Order; | use common\logic\Order\Order\Model\Order; | ||||
use common\logic\Producer\Producer\Model\Producer; | use common\logic\Producer\Producer\Model\Producer; | ||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | use common\logic\Producer\Producer\Wrapper\ProducerManager; | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use common\logic\User\UserProducer\Model\UserProducer; | use common\logic\User\UserProducer\Model\UserProducer; | ||||
use yii\bootstrap\Nav; | use yii\bootstrap\Nav; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
\common\assets\CommonAsset::register($this); | \common\assets\CommonAsset::register($this); | ||||
\producer\assets\AppAsset::register($this); | \producer\assets\AppAsset::register($this); | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$userCurrent = GlobalParam::getCurrentUser(); | $userCurrent = GlobalParam::getCurrentUser(); | ||||
$producerManager = ProducerManager::getInstance(); | $producerManager = ProducerManager::getInstance(); | ||||
$producerUser = null; | $producerUser = null; | ||||
if($userManager->isCurrentProducer()) { | |||||
if($userModule->isCurrentProducer()) { | |||||
$producerUser = $producerManager->findOneProducerById($userCurrent->id_producer); | $producerUser = $producerManager->findOneProducerById($userCurrent->id_producer); | ||||
} | } | ||||
$producer = $this->context->getProducerCurrent(); | $producer = $this->context->getProducerCurrent(); | ||||
->count(); | ->count(); | ||||
$labelOrders = $countOrders > 0 ? 'success' : 'default'; | $labelOrders = $countOrders > 0 ? 'success' : 'default'; | ||||
$isUserSubscribedNewsletter = $userManager->isUserSubscribedNewsletter($userCurrent); | |||||
$isUserSubscribedNewsletter = $userModule->isUserSubscribedNewsletter($userCurrent); | |||||
echo Nav::widget([ | echo Nav::widget([ | ||||
'encodeLabels' => false, | 'encodeLabels' => false, |
termes. | termes. | ||||
*/ | */ | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
$userManager = UserManager::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$this->setTitle("Bulletin d'information"); | $this->setTitle("Bulletin d'information"); | ||||
?> | ?> | ||||
<div class="newsletter-index"> | <div class="newsletter-index"> | ||||
<?php if($userManager->isUserSubscribedNewsletter($user)): ?> | |||||
<?php if($userModule->isUserSubscribedNewsletter($user)): ?> | |||||
<div class="panel panel-default"> | <div class="panel panel-default"> | ||||
<div class="panel-body"> | <div class="panel-body"> | ||||
Vous êtes inscrit au bulletin d'information <strong><?= Html::encode($producer->name) ?></strong>. | Vous êtes inscrit au bulletin d'information <strong><?= Html::encode($producer->name) ?></strong>. |