@@ -38,45 +38,46 @@ | |||
namespace common\helpers; | |||
use common\logic\Document\Document\Document; | |||
class Price | |||
{ | |||
public static function format($number, $decimals = 2) | |||
{ | |||
return self::numberTwoDecimals($number, $decimals) . ' €'; | |||
} | |||
public static function format($number, $decimals = 2) | |||
{ | |||
return self::numberTwoDecimals($number, $decimals).' €'; | |||
} | |||
public static function round($number) | |||
{ | |||
return round($number, 2, PHP_ROUND_HALF_UP); | |||
} | |||
public static function round($number) | |||
{ | |||
return round($number, 2, PHP_ROUND_HALF_UP); | |||
} | |||
public static function getPrice($priceWithTax, $taxRate) | |||
{ | |||
return floatval($priceWithTax) / ($taxRate + 1); | |||
} | |||
public static function getPrice($priceWithTax, $taxRate) | |||
{ | |||
return floatval($priceWithTax) / ($taxRate + 1); | |||
} | |||
public static function getPriceWithTax($priceWithoutTax, $taxRate, $taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT) | |||
{ | |||
$vat = self::getVat($priceWithoutTax, $taxRate, $taxCalculationMethod); | |||
public static function getPriceWithTax($priceWithoutTax, $taxRate, $taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT) | |||
{ | |||
$vat = self::getVat($priceWithoutTax, $taxRate, $taxCalculationMethod); | |||
return self::numberTwoDecimals(self::round($priceWithoutTax + $vat)); | |||
} | |||
return self::numberTwoDecimals(self::round($priceWithoutTax + $vat)); | |||
} | |||
public static function getVat($priceTotalWithoutTax, $taxRate, $taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT) | |||
{ | |||
$vat = $priceTotalWithoutTax * $taxRate; | |||
public static function getVat($priceTotalWithoutTax, $taxRate, $taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT) | |||
{ | |||
$vat = $priceTotalWithoutTax * $taxRate; | |||
if($taxCalculationMethod == Document::TAX_CALCULATION_METHOD_SUM_OF_ROUNDINGS) { | |||
$vat = self::round($vat); | |||
} | |||
return $vat; | |||
if ($taxCalculationMethod == Document::TAX_CALCULATION_METHOD_SUM_OF_ROUNDINGS) { | |||
$vat = self::round($vat); | |||
} | |||
public static function numberTwoDecimals($number, $decimals = 2) | |||
{ | |||
return number_format(( ($number * 100)) / 100, $decimals, '.', ' ') ; | |||
} | |||
return $vat; | |||
} | |||
public static function numberTwoDecimals($number, $decimals = 2) | |||
{ | |||
return number_format((($number * 100)) / 100, $decimals, '.', ' '); | |||
} | |||
} |
@@ -21,6 +21,11 @@ class PointSaleRepository extends BaseService implements RepositoryInterface | |||
]; | |||
} | |||
public function getOneById(int $id): ?PointSale | |||
{ | |||
return PointSale::searchOne(['id' => $id]); | |||
} | |||
public function getByDistribution(Distribution $distribution) | |||
{ | |||
return PointSale::find() |
@@ -186,8 +186,9 @@ class Product extends ActiveRecordCommon | |||
} | |||
} | |||
$this->wording_unit = Product::strUnit($this->unit); | |||
$this->price_with_tax = $this->getPriceWithTax(); | |||
$productSolver = new ProductSolver(); | |||
$this->wording_unit = $productSolver->strUnit($this->unit); | |||
$this->price_with_tax = $productSolver->getPriceWithTax($this); | |||
parent::afterFind(); | |||
} |
@@ -5,7 +5,9 @@ namespace common\logic\Subscription\Subscription; | |||
use common\helpers\GlobalParam; | |||
use common\logic\BaseService; | |||
use common\logic\Distribution\Distribution\Distribution; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\logic\RepositoryInterface; | |||
use common\logic\User\User\User; | |||
class SubscriptionRepository extends BaseService implements RepositoryInterface | |||
{ | |||
@@ -93,4 +95,13 @@ class SubscriptionRepository extends BaseService implements RepositoryInterface | |||
return $matchedIncomingDistributionsArray; | |||
} | |||
public function count(User $user, Producer $producer) | |||
{ | |||
return Subscription::find() | |||
->where([ | |||
'subscription.id_user' => $user->id, | |||
'subscription.id_producer' => $producer->id, | |||
])->count(); | |||
} | |||
} |
@@ -20,7 +20,15 @@ class CreditHistoryBuilder extends BaseService implements BuilderInterface | |||
$this->userProducerBuilder = $this->loadService(UserProducerBuilder::class); | |||
} | |||
public function instanciate(string $type, float $amount, Producer $producer, User $user, User $userAction, Order $order = null): CreditHistory | |||
public function instanciate( | |||
string $type, | |||
float $amount, | |||
Producer $producer, | |||
User $user, | |||
User $userAction, | |||
string $meanPayment = null, | |||
Order $order = null | |||
): CreditHistory | |||
{ | |||
$creditHistory = new CreditHistory; | |||
@@ -38,17 +46,29 @@ class CreditHistoryBuilder extends BaseService implements BuilderInterface | |||
$creditHistory->populateRelation('order', $order); | |||
} | |||
if($meanPayment) { | |||
$creditHistory->mean_payment = $meanPayment; | |||
} | |||
return $creditHistory; | |||
} | |||
// saveCreditHistory | |||
public function create(string $type, float $amount, Producer $producer, User $user, User $userAction, Order $order = null): ?CreditHistory | |||
public function create( | |||
string $type, | |||
float $amount, | |||
Producer $producer, | |||
User $user, | |||
User $userAction, | |||
string $meanPayment = null, | |||
Order $order = null | |||
): ?CreditHistory | |||
{ | |||
if ($amount > -0.01 && $amount < 0.01) { | |||
return null; | |||
} | |||
$creditHistory = $this->instanciate($type, $amount, $producer, $user, $userAction, $order); | |||
$creditHistory = $this->instanciate($type, $amount, $producer, $user, $userAction, $meanPayment, $order); | |||
// Initialisation du commentaire avant sauvegarde | |||
$creditHistory->setComment($creditHistory->getComment() . $this->creditHistorySolver->getStrComment($creditHistory)); |
@@ -50,7 +50,6 @@ use yii\filters\VerbFilter; | |||
class CreditController extends ProducerBaseController | |||
{ | |||
/** | |||
* @inheritdoc | |||
*/ | |||
@@ -84,12 +83,10 @@ class CreditController extends ProducerBaseController | |||
/** | |||
* Affiche l'historique du crédit client. | |||
* | |||
*/ | |||
public function actionHistory($returnPayment = '') | |||
public function actionHistory(string $returnPayment = '') | |||
{ | |||
$producer = $this->getProducer(); | |||
if (\Yii::$app->user->isGuest) { | |||
return $this->redirect($this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $producer->id])); | |||
} | |||
@@ -97,18 +94,14 @@ class CreditController extends ProducerBaseController | |||
$searchModel = new CreditHistorySearch(); | |||
$searchModel->id_user = GlobalParam::getCurrentUserId(); | |||
$dataProvider = $searchModel->search(\Yii::$app->request->queryParams); | |||
$userProducer = UserProducer::searchOne([ | |||
'id_producer' => $producer->id, | |||
'id_user' => GlobalParam::getCurrentUserId() | |||
]); | |||
$userProducer = $this->getLogic()->getUserProducerContainer()->getRepository()->getOne(GlobalParam::getCurrentUser(), $producer); | |||
if (strlen($returnPayment)) { | |||
if ($returnPayment == 'success') { | |||
\Yii::$app->getSession()->setFlash('success', "Paiement accepté : votre compte vient d'être crédité."); | |||
$this->setFlash('success', "Paiement accepté : votre compte vient d'être crédité."); | |||
} | |||
if ($returnPayment == 'cancel') { | |||
\Yii::$app->getSession()->setFlash('error', 'Paiement annulé.'); | |||
$this->setFlash('error', 'Paiement annulé.'); | |||
} | |||
} | |||
@@ -122,9 +115,8 @@ class CreditController extends ProducerBaseController | |||
public function actionAdd() | |||
{ | |||
$producer = $this->getProducer(); | |||
if (\Yii::$app->user->isGuest) { | |||
return $this->redirect(\Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer', 'id' => $producer->id])); | |||
return $this->redirect($this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $producer->id])); | |||
} | |||
if ($producer->online_payment || $producer->option_stripe_mode_test) { | |||
@@ -135,7 +127,7 @@ class CreditController extends ProducerBaseController | |||
$user = GlobalParam::getCurrentUser(); | |||
\Stripe\Stripe::setApiKey( | |||
$producer->getPrivateKeyApiStripe() | |||
$this->getLogic()->getProducerContainer()->getSolver()->getPrivateKeyApiStripe($producer) | |||
); | |||
$checkout_session = \Stripe\Checkout\Session::create([ | |||
@@ -146,7 +138,7 @@ class CreditController extends ProducerBaseController | |||
'product_data' => [ | |||
'name' => 'Alimentation crédit', | |||
], | |||
'unit_amount' => (float)$creditForm->amount * 100, | |||
'unit_amount' => (float) $creditForm->amount * 100, | |||
], | |||
'quantity' => 1, | |||
] | |||
@@ -161,13 +153,13 @@ class CreditController extends ProducerBaseController | |||
'producer_id' => $producer->id | |||
], | |||
], | |||
'success_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl( | |||
'success_url' => $this->getUrlManagerProducer()->createAbsoluteUrl( | |||
[ | |||
'credit/history', | |||
'returnPayment' => 'success' | |||
] | |||
), | |||
'cancel_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl( | |||
'cancel_url' => $this->getUrlManagerProducer()->createAbsoluteUrl( | |||
[ | |||
'credit/history', | |||
'returnPayment' => 'cancel' | |||
@@ -191,18 +183,19 @@ class CreditController extends ProducerBaseController | |||
public function actionStripeVerification() | |||
{ | |||
$creditHistoryBuilder = $this->getLogic()->getCreditHistoryContainer()->getBuilder(); | |||
$producerSolver = $this->getLogic()->getProducerContainer()->getSolver(); | |||
$userSolver = $this->getLogic()->getUserContainer()->getSolver(); | |||
$producer = $this->getProducer(); | |||
$contactProducer = $producer->getMainContact(); | |||
$payload = @file_get_contents('php://input'); | |||
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE']; | |||
$event = null; | |||
try { | |||
$event = \Stripe\Webhook::constructEvent( | |||
$payload, | |||
$sig_header, | |||
$producer->getPrivateKeyEndpointStripe() | |||
$producerSolver->getPrivateKeyEndpointStripe($producer) | |||
); | |||
} catch (\UnexpectedValueException $e) { | |||
// Invalid payload | |||
@@ -218,15 +211,13 @@ class CreditController extends ProducerBaseController | |||
$paymentIntentMetadata = $paymentIntent->metadata; | |||
$amount = $paymentIntent->amount / 100; | |||
$idUser = $paymentIntentMetadata->user_id; | |||
$user = User::findOne($paymentIntentMetadata->user_id); | |||
$user = $this->getLogic()->getUserContainer()->getRepository()->getOneById($paymentIntentMetadata->user_id); | |||
$idProducer = $paymentIntentMetadata->producer_id; | |||
if (isset($paymentIntentMetadata->order_id)) { | |||
$order = Order::searchOne([ | |||
'id' => $paymentIntentMetadata->order_id | |||
]); | |||
$pointSale = PointSale::searchOne(['id' => $order->id_point_sale]); | |||
$distribution = DistributionModel::find()->where(['id' => $order->id_distribution])->one(); | |||
$order = $this->getLogic()->getOrderContainer()->getRepository()->getOneById($paymentIntentMetadata->order_id); | |||
$pointSale = $this->getLogic()->getPointSaleContainer()->getRepostory()->getOneById($order->id_point_sale); | |||
$distribution = $this->getLogic()->getDistributionContainer()->getRepository()->getOneById($order->id_distribution); | |||
} | |||
// Handle the event | |||
@@ -244,34 +235,33 @@ class CreditController extends ProducerBaseController | |||
if (!$creditHistoryExist) { | |||
// on crédite le crédit du client | |||
$creditHistory = new CreditHistory(); | |||
$creditHistory->id_user = $idUser; | |||
$creditHistory->id_user_action = $idUser; | |||
$creditHistory->id_producer = $idProducer; | |||
$creditHistory->type = CreditHistory::TYPE_CREDIT; | |||
$creditHistory->comment = null; | |||
$creditHistory->amount = $amount; | |||
$creditHistory->mean_payment = MeanPayment::CREDIT_CARD; | |||
$creditHistoryBuilder->save($creditHistory); | |||
$creditHistoryBuilder->create( | |||
CreditHistory::TYPE_CREDIT, | |||
$amount, | |||
$producer, | |||
$user, | |||
$user, | |||
MeanPayment::CREDIT_CARD | |||
); | |||
if (isset($order) && $order) { | |||
// paiement de la commande | |||
$order->saveCreditHistory( | |||
$creditHistoryBuilder->create( | |||
CreditHistory::TYPE_PAYMENT, | |||
$amount, | |||
$idProducer, | |||
$order->id_user, | |||
$order->id_user | |||
$producer, | |||
$user, | |||
$user, | |||
MeanPayment::CREDIT, | |||
$order | |||
); | |||
// client : envoi d'un email de confirmation de paiement | |||
$paramsEmail = [ | |||
'from_email' => $producer->getEmailOpendistrib(), | |||
'from_email' => $producerSolver->getEmailOpendistrib($producer), | |||
'from_name' => $producer->name, | |||
'to_email' => $user->email, | |||
'to_name' => $user->getUsername(), | |||
'to_name' => $userSolver->getUsername($user), | |||
'subject' => '[' . $producer->name . '] Confirmation de paiement', | |||
'content_view_text' => '@common/mail/paymentOrderConfirm-text.php', | |||
'content_view_html' => '@common/mail/paymentOrderConfirm-html.php', | |||
@@ -285,7 +275,7 @@ class CreditController extends ProducerBaseController | |||
// producteur : mail de confirmation | |||
Mailjet::sendMail([ | |||
'from_email' => $producer->getEmailOpendistrib(), | |||
'from_email' => $producerSolver->getEmailOpendistrib($producer), | |||
'from_name' => $producer->name, | |||
'to_email' => $contactProducer->email, | |||
'to_name' => $contactProducer->name, | |||
@@ -301,19 +291,13 @@ class CreditController extends ProducerBaseController | |||
] | |||
]); | |||
} else { | |||
// envoi d'un email de confirmation | |||
$userProducer = UserProducer::find() | |||
->where([ | |||
'id_user' => $idUser, | |||
'id_producer' => $idProducer | |||
]) | |||
->one(); | |||
$userProducer = $this->getLogic()->getUserProducerContainer()->getRepository()->getOne($user, $producer); | |||
Mailjet::sendMail([ | |||
'from_email' => $producer->getEmailOpendistrib(), | |||
'from_email' => $producerSolver->getEmailOpendistrib($producer), | |||
'from_name' => $producer->name, | |||
'to_email' => $user->email, | |||
'to_name' => $user->getUsername(), | |||
'to_name' => $userSolver->getUsername($user), | |||
'subject' => '[' . $producer->name . '] Alimentation de votre crédit', | |||
'content_view_text' => '@common/mail/creditConfirm-text.php', | |||
'content_view_html' => '@common/mail/creditConfirm-html.php', | |||
@@ -333,10 +317,10 @@ class CreditController extends ProducerBaseController | |||
// client | |||
Mailjet::sendMail([ | |||
'from_email' => $producer->getEmailOpendistrib(), | |||
'from_email' => $producerSolver->getEmailOpendistrib($producer), | |||
'from_name' => $producer->name, | |||
'to_email' => $user->email, | |||
'to_name' => $user->getUsername(), | |||
'to_name' => $userSolver->getUsername($user), | |||
'subject' => '[' . $producer->name . '] Erreur de paiement', | |||
'content_view_text' => '@common/mail/paymentError-text.php', | |||
'content_view_html' => '@common/mail/paymentError-html.php', | |||
@@ -350,7 +334,7 @@ class CreditController extends ProducerBaseController | |||
// producteur | |||
if (isset($order) && $order) { | |||
Mailjet::sendMail([ | |||
'from_email' => $producer->getEmailOpendistrib(), | |||
'from_email' => $producerSolver->getEmailOpendistrib($producer), | |||
'from_name' => $producer->name, | |||
'to_email' => $contactProducer->email, | |||
'to_name' => $contactProducer->name, |
@@ -132,14 +132,14 @@ class SubscriptionController extends ProducerBaseController | |||
} | |||
return $this->render('form', [ | |||
'idSubscription' => (int) $id | |||
'idSubscription' => $id | |||
]); | |||
} | |||
/** | |||
* Modifie une commande récurrente. | |||
*/ | |||
public function actionUpdate($id) | |||
public function actionUpdate(int $id) | |||
{ | |||
if (\Yii::$app->user->isGuest) { | |||
$producer = $this->getProducer(); | |||
@@ -238,7 +238,8 @@ class SubscriptionController extends ProducerBaseController | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
$params = []; | |||
$productSolver = $this->getLogic()->getProductContainer()->getSolver(); | |||
$subscriptionRepositpry = $this->getLogic()->getSubscriptionContainer()->getRepository(); | |||
$user = GlobalParam::getCurrentUser(); | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => GlobalParam::getCurrentUserId() | |||
@@ -250,7 +251,7 @@ class SubscriptionController extends ProducerBaseController | |||
'id_subscription' => $idSubscription | |||
]); | |||
$subscription = $this->getLogic()->getSubscriptionContainer()->getRepository()->getOneById($idSubscription); | |||
$subscription = $subscriptionRepositpry->getOneById($idSubscription); | |||
if ($subscription) { | |||
if ($subscription->id_point_sale) { | |||
@@ -280,9 +281,9 @@ class SubscriptionController extends ProducerBaseController | |||
'index' => $indexProduct++, | |||
'quantity_form' => $quantity, | |||
'coefficient_unit' => $coefficientUnit, | |||
'wording_unit' => Product::strUnit($product->unit, 'wording_unit', true), | |||
'wording_short' => Product::strUnit($product->unit, 'wording_short'), | |||
'price_with_tax' => $product->getPriceWithTax([ | |||
'wording_unit' => $productSolver->strUnit($product->unit, 'wording_unit', true), | |||
'wording_short' => $productSolver->strUnit($product->unit, 'wording_short'), | |||
'price_with_tax' => $productSolver->getPriceWithTax($product, [ | |||
'user' => $user, | |||
'user_producer' => $userProducer, | |||
'point_sale' => $pointSale | |||
@@ -306,9 +307,7 @@ class SubscriptionController extends ProducerBaseController | |||
$params['points_sale'] = $pointsSaleArray; | |||
if ($idSubscription > 0) { | |||
$subscription = Subscription::searchOne([ | |||
'id' => $idSubscription | |||
]); | |||
$subscription = $subscriptionRepositpry->getOneById($idSubscription); | |||
if (!$subscription || $subscription->id_user != GlobalParam::getCurrentUserId()) { | |||
throw new UserException('Abonnement introuvable'); |
@@ -37,13 +37,10 @@ | |||
*/ | |||
use yii\bootstrap\Nav; | |||
use yii\bootstrap\NavBar; | |||
use yii\widgets\Breadcrumbs; | |||
use common\widgets\Alert; | |||
use common\helpers\Url; | |||
use common\helpers\GlobalParam; | |||
use common\logic\User\UserProducer\UserProducer; | |||
use common\logic\User\User\User; | |||
use yii\helpers\Html; | |||
use common\logic\Order\Order\Order; | |||
\common\assets\CommonAsset::register($this); | |||
\producer\assets\AppAsset::register($this); | |||
@@ -151,11 +148,10 @@ if (!Yii::$app->user->isGuest) { | |||
$credit = ' <span class="label label-' . $labelType . '">' . number_format($userProducer->credit, 2) . ' €</span>'; | |||
} | |||
$countSubcriptions = Subscription::find() | |||
->where([ | |||
'subscription.id_user' => GlobalParam::getCurrentUserId(), | |||
'subscription.id_producer' => GlobalParam::getCurrentProducerId(), | |||
])->count(); | |||
$countSubcriptions = $this->getLogic()->getSubscriptionContainer()->getRepository()->count( | |||
GlobalParam::getCurrentUser(), | |||
GlobalParam::getCurrentProducer() | |||
); | |||
$labelSubscription = $countSubcriptions > 0 ? 'success' : 'default'; | |||
$countOrders = Order::find() | |||
@@ -176,48 +172,48 @@ if (!Yii::$app->user->isGuest) { | |||
'items' => [ | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-th-large"></span> Accueil', | |||
'url' => \Yii::$app->urlManager->createUrl(['site/index']), | |||
'url' => $this->getUrlManagerProducer()->createUrl(['site/index']), | |||
'active' => $this->getControllerAction() == 'site/index', | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-plus"></span> Commander', | |||
'url' => \Yii::$app->urlManager->createUrl(['order/order']), | |||
'url' => $this->getUrlManagerProducer()->createUrl(['order/order']), | |||
'visible' => $producer->option_allow_order_guest || !Yii::$app->user->isGuest, | |||
'active' => $this->getControllerAction() == 'order/order', | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-plus"></span> Commander', | |||
'url' => \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer', 'id' => $this->context->getProducer()->id, 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order', 'slug_producer' => $this->context->getProducer()->slug])]), | |||
'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $this->context->getProducer()->id, 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order', 'slug_producer' => $this->context->getProducer()->slug])]), | |||
'visible' => !$producer->option_allow_order_guest && \Yii::$app->user->isGuest, | |||
'active' => $this->getControllerAction() == 'order/order', | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-folder-open"></span> Mes commandes <span class="label label-' . $labelOrders . '">' . $countOrders . '</span>', | |||
'url' => \Yii::$app->urlManager->createUrl(['order/history']), | |||
'url' => $this->getUrlManagerProducer()->createUrl(['order/history']), | |||
'visible' => !Yii::$app->user->isGuest, | |||
'active' => $this->getControllerAction() == 'order/history', | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-repeat"></span> Abonnements <span class="label label-' . $labelSubscription . '">' . $countSubcriptions . '</span>', | |||
'url' => \Yii::$app->urlManager->createUrl(['subscription/index']), | |||
'url' => $this->getUrlManagerProducer()->createUrl(['subscription/index']), | |||
'visible' => !Yii::$app->user->isGuest && $producer->user_manage_subscription, | |||
'active' => $this->getControllerAction() == 'subscription/index', | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-euro"></span> Crédit' . $credit, | |||
'url' => \Yii::$app->urlManager->createUrl(['credit/history']), | |||
'url' => $this->getUrlManagerProducer()->createUrl(['credit/history']), | |||
'visible' => !Yii::$app->user->isGuest && $producer->credit, | |||
'active' => $this->getControllerAction() == 'credit/history', | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-envelope"></span> Contact', | |||
'url' => \Yii::$app->urlManager->createUrl(['site/contact']), | |||
'url' => $this->getUrlManagerProducer()->createUrl(['site/contact']), | |||
'active' => $this->getControllerAction() == 'site/contact', | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-cog"></span> Administration', | |||
'url' => \Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']), | |||
'visible' => isset(Yii::$app->user->identity) && \Yii::$app->user->identity->isProducer(), | |||
'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['site/index']), | |||
'visible' => isset(Yii::$app->user->identity) && $this->getLogic()->getUserContainer()->getSolver()->isProducer(\Yii::$app->user->identity), | |||
'options' => ['id' => 'btn-administration'] | |||
], | |||
], | |||
@@ -235,7 +231,7 @@ if (!Yii::$app->user->isGuest) { | |||
</div> | |||
<?php endif; ?> | |||
<div id="infos-producer"> | |||
<?php if(!$producer->hasSpecificDelays() && $producer->order_deadline && $producer->order_delay): ?> | |||
<?php if(!$this->getLogic()->getProducerContainer()->getSolver()->hasSpecificDelays($producer) && $producer->order_deadline && $producer->order_delay): ?> | |||
<span data-toggle="tooltip" data-placement="bottom" title="Heure limite de commande"> | |||
<span class="glyphicon glyphicon-time"></span> Commande avant | |||
<strong><?php echo Html::encode($producer->order_deadline) ?> h</strong></span>, |
@@ -37,10 +37,15 @@ termes. | |||
*/ | |||
use common\logic\Producer\Producer\Producer; | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\helpers\Price; | |||
$producer = $this->context->getProducer() ; | |||
$productSolver = $this->getLogic()->getProductContainer()->getSolver(); | |||
$this->setTitle('Accueil'); | |||
$this->setPageTitle(Html::encode($producer->type.' à '.$producer->city)) ; | |||
?> | |||
<section id="presentation"> | |||
@@ -182,9 +187,9 @@ $this->setPageTitle(Html::encode($producer->type.' à '.$producer->city)) ; | |||
$columnsProducts[] = [ | |||
'attribute' => 'price', | |||
'value' => function($model) { | |||
'value' => function($model) use ($productSolver) { | |||
if($model->price) { | |||
return Price::format($model->getPriceWithTax()).' ('. Product::strUnit($model->unit, 'wording_unit', true).')' ; | |||
return Price::format($productSolver->getPriceWithTax($model)).' ('. $productSolver->strUnit($model->unit, 'wording_unit', true).')' ; | |||
} | |||
return '' ; | |||
} |