// products | // products | ||||
$productsArray = Product::find() | $productsArray = Product::find() | ||||
->orWhere(['id_producer' => Producer::getId(),]) | ->orWhere(['id_producer' => Producer::getId(),]) | ||||
->orWhere(['id_producer' => 0,]) // produit "Don" | |||||
->joinWith(['productDistribution' => function($query) use($distribution) { | ->joinWith(['productDistribution' => function($query) use($distribution) { | ||||
$query->andOnCondition('product_distribution.id_distribution = '.$distribution->id) ; | $query->andOnCondition('product_distribution.id_distribution = '.$distribution->id) ; | ||||
}]) | }]) | ||||
$potentialRevenues = 0; | $potentialRevenues = 0; | ||||
$potentialWeight = 0; | $potentialWeight = 0; | ||||
foreach($productsArray as &$product) { | |||||
$quantityOrder = Order::getProductQuantity($product['id'], $ordersArray) ; | |||||
$product['quantity_ordered'] = $quantityOrder ; | |||||
$product['quantity_remaining'] = $product['quantity_max'] - $quantityOrder ; | |||||
if($product['quantity_remaining'] < 0) $product['quantity_remaining'] = 0 ; | |||||
$product['quantity_form'] = 0 ; | |||||
foreach($productsArray as &$theProduct) { | |||||
$quantityOrder = Order::getProductQuantity($theProduct['id'], $ordersArray) ; | |||||
$theProduct['quantity_ordered'] = $quantityOrder ; | |||||
$theProduct['quantity_remaining'] = $theProduct['quantity_max'] - $quantityOrder ; | |||||
if($theProduct['quantity_remaining'] < 0) $theProduct['quantity_remaining'] = 0 ; | |||||
$theProduct['quantity_form'] = 0 ; | |||||
if($product['productDistribution'][0]['active'] && $product['productDistribution'][0]['quantity_max']) { | |||||
$potentialRevenues += $product['productDistribution'][0]['quantity_max'] * $product['price']; | |||||
$potentialWeight += $product['productDistribution'][0]['quantity_max'] * $product['weight'] / 1000; | |||||
if($theProduct['productDistribution'][0]['active'] && $theProduct['productDistribution'][0]['quantity_max']) { | |||||
$potentialRevenues += $theProduct['productDistribution'][0]['quantity_max'] * $theProduct['price']; | |||||
$potentialWeight += $theProduct['productDistribution'][0]['quantity_max'] * $theProduct['weight'] / 1000; | |||||
} | } | ||||
} | } | ||||
use yii\filters\VerbFilter; | use yii\filters\VerbFilter; | ||||
use common\models\User; | use common\models\User; | ||||
use common\models\UserPointSale; | use common\models\UserPointSale; | ||||
use common\models\Order ; | |||||
use yii\helpers\Html; | |||||
/** | /** | ||||
* PointVenteController implements the CRUD actions for PointVente model. | * PointVenteController implements the CRUD actions for PointVente model. | ||||
$model->processPointProduction(); | $model->processPointProduction(); | ||||
$model->processRestrictedAccess(); | $model->processRestrictedAccess(); | ||||
Distribution::linkPointSaleIncomingDistributions($model) ; | Distribution::linkPointSaleIncomingDistributions($model) ; | ||||
Yii::$app->getSession()->setFlash('success', 'Point de vente modifié.'); | |||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
} else { | } else { | ||||
return $this->render('update', array_merge($this->initForm($id), [ | return $this->render('update', array_merge($this->initForm($id), [ | ||||
* @param integer $id | * @param integer $id | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function actionDelete($id) | |||||
{ | |||||
$this->findModel($id)->delete(); | |||||
UserPointSale::deleteAll(['id_point_sale' => $id]); | |||||
PointSaleDistribution::deleteAll(['id_point_sale' => $id]) ; | |||||
public function actionDelete($id, $confirm = false) | |||||
{ | |||||
$pointSale = $this->findModel($id) ; | |||||
if($confirm) { | |||||
$pointSale->delete(); | |||||
UserPointSale::deleteAll(['id_point_sale' => $id]); | |||||
PointSaleDistribution::deleteAll(['id_point_sale' => $id]) ; | |||||
Order::updateAll(['id_point_sale' => 0], 'id_point_sale = :id_point_sale', [':id_point_sale' => $id]) ; | |||||
Yii::$app->getSession()->setFlash('success', 'Point de vente <strong>'.Html::encode($pointSale->name).'</strong> supprimé.'); | |||||
} | |||||
else { | |||||
Yii::$app->getSession()->setFlash('info', 'Souhaitez-vous vraiment supprimer le point de vente <strong>'.Html::encode($pointSale->name).'</strong> ? ' | |||||
. Html::a('Oui',['point-sale/delete','id' => $id, 'confirm' => 1], ['class' => 'btn btn-default']).' '.Html::a('Non', ['point-sale/index'], ['class' => 'btn btn-default'])); | |||||
} | |||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
} | } | ||||
* @param integer $id | * @param integer $id | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function actionDelete($id) | |||||
public function actionDelete($id, $confirm = false) | |||||
{ | { | ||||
$model = $this->findModel($id) ; | |||||
$model->delete(); | |||||
ProductDistribution::deleteAll(['id_product' => $id]) ; | |||||
$product = $this->findModel($id) ; | |||||
Yii::$app->getSession()->setFlash('success', 'Produit <strong>'.Html::encode($model->name).'</strong> supprimé'); | |||||
if($confirm) { | |||||
$product->delete(); | |||||
ProductDistribution::deleteAll(['id_product' => $id]) ; | |||||
Yii::$app->getSession()->setFlash('success', 'Produit <strong>'.Html::encode($product->name).'</strong> supprimé'); | |||||
} | |||||
else { | |||||
Yii::$app->getSession()->setFlash('info', 'Souhaitez-vous vraiment supprimer le produit <strong>'.Html::encode($product->name).'</strong> ? ' | |||||
. Html::a('Oui',['product/delete','id' => $id, 'confirm' => 1], ['class' => 'btn btn-default']).' '.Html::a('Non', ['product/index'], ['class' => 'btn btn-default'])); | |||||
} | |||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
} | } |
/* @var $this \yii\web\View */ | /* @var $this \yii\web\View */ | ||||
/* @var $content string */ | /* @var $content string */ | ||||
$producer = Producer::getCurrent() ; | |||||
?> | ?> | ||||
<header class="main-header"> | <header class="main-header"> | ||||
</li> | </li> | ||||
<?php if (User::isCurrentProducer() || User::isCurrentAdmin()): ?> | <?php if (User::isCurrentProducer() || User::isCurrentAdmin()): ?> | ||||
<li class="dropdown"> | |||||
<li class="dropdown producer-menu"> | |||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> | <a href="#" class="dropdown-toggle" data-toggle="dropdown"> | ||||
<i class="fa fa-home"></i> | |||||
<?php if($producer->active): ?> | |||||
<i class="fa fa-home"></i> | |||||
<?php else: ?> | |||||
<span class="label label-danger">Hors-ligne</span> | |||||
<?php endif; ?> | |||||
<span><?= Html::encode(Yii::$app->user->identity->getNameProducer()); ?></span> | <span><?= Html::encode(Yii::$app->user->identity->getNameProducer()); ?></span> | ||||
<i class="fa fa-caret-down"></i> | <i class="fa fa-caret-down"></i> | ||||
</a> | </a> |
margin-left: 10px; | margin-left: 10px; | ||||
} | } | ||||
/* line 79, ../sass/_adminlte.scss */ | /* line 79, ../sass/_adminlte.scss */ | ||||
body.skin-black .main-header .navbar .nav li.producer-menu .label { | |||||
position: relative; | |||||
top: -2px; | |||||
left: 0px; | |||||
} | |||||
/* line 87, ../sass/_adminlte.scss */ | |||||
body.skin-black .sidebar-menu > li.active > a { | body.skin-black .sidebar-menu > li.active > a { | ||||
border-color: #FF7F00; | border-color: #FF7F00; | ||||
} | } | ||||
/* line 83, ../sass/_adminlte.scss */ | |||||
/* line 91, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper { | body.skin-black .content-wrapper { | ||||
background-color: #f5f5f5; | background-color: #f5f5f5; | ||||
} | } | ||||
/* line 86, ../sass/_adminlte.scss */ | |||||
/* line 94, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .content-header { | body.skin-black .content-wrapper .content-header { | ||||
background-color: #F5F5F5; | background-color: #F5F5F5; | ||||
padding-bottom: 15px; | padding-bottom: 15px; | ||||
border-bottom: solid 1px #e0e0e0; | border-bottom: solid 1px #e0e0e0; | ||||
border-top: solid 1px #e0e0e0; | border-top: solid 1px #e0e0e0; | ||||
} | } | ||||
/* line 92, ../sass/_adminlte.scss */ | |||||
/* line 100, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .content-header .btn { | body.skin-black .content-wrapper .content-header .btn { | ||||
padding: 3px 6px; | padding: 3px 6px; | ||||
font-size: 13px; | font-size: 13px; | ||||
} | } | ||||
/* line 97, ../sass/_adminlte.scss */ | |||||
/* line 105, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .content-header h1 { | body.skin-black .content-wrapper .content-header h1 { | ||||
font-family: "highvoltageregular"; | font-family: "highvoltageregular"; | ||||
} | } | ||||
/* line 104, ../sass/_adminlte.scss */ | |||||
/* line 112, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper a { | body.skin-black .content-wrapper a { | ||||
color: #FF7F00; | color: #FF7F00; | ||||
} | } | ||||
/* line 108, ../sass/_adminlte.scss */ | |||||
/* line 116, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .btn { | body.skin-black .content-wrapper .btn { | ||||
color: white; | color: white; | ||||
} | } | ||||
/* line 112, ../sass/_adminlte.scss */ | |||||
/* line 120, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .btn-default { | body.skin-black .content-wrapper .btn-default { | ||||
color: #333; | color: #333; | ||||
} | } | ||||
/* line 116, ../sass/_adminlte.scss */ | |||||
/* line 124, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .btn-primary { | body.skin-black .content-wrapper .btn-primary { | ||||
background-color: #FF7F00; | background-color: #FF7F00; | ||||
color: white; | color: white; | ||||
border-color: #FF7F00; | border-color: #FF7F00; | ||||
} | } | ||||
/* line 123, ../sass/_adminlte.scss */ | |||||
/* line 131, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .alert a { | body.skin-black .content-wrapper .alert a { | ||||
color: white; | color: white; | ||||
} | } | ||||
/* line 129, ../sass/_adminlte.scss */ | |||||
/* line 134, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .alert a.btn { | |||||
color: #333; | |||||
text-decoration: none; | |||||
} | |||||
/* line 141, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .callout h4 .fa { | body.skin-black .content-wrapper .callout h4 .fa { | ||||
margin-right: 7px; | margin-right: 7px; | ||||
} | } | ||||
/* line 132, ../sass/_adminlte.scss */ | |||||
/* line 144, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .callout a { | body.skin-black .content-wrapper .callout a { | ||||
color: white; | color: white; | ||||
} | } | ||||
/* line 135, ../sass/_adminlte.scss */ | |||||
/* line 147, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .callout .btn { | body.skin-black .content-wrapper .callout .btn { | ||||
color: #333; | color: #333; | ||||
text-decoration: none; | text-decoration: none; | ||||
} | } | ||||
/* line 142, ../sass/_adminlte.scss */ | |||||
/* line 154, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .table th { | body.skin-black .content-wrapper .table th { | ||||
font-size: 13px; | font-size: 13px; | ||||
} | } | ||||
/* line 145, ../sass/_adminlte.scss */ | |||||
/* line 157, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .table th.column-actions, body.skin-black .content-wrapper .table td.column-actions { | body.skin-black .content-wrapper .table th.column-actions, body.skin-black .content-wrapper .table td.column-actions { | ||||
width: 150px; | width: 150px; | ||||
text-align: right; | text-align: right; | ||||
} | } | ||||
/* line 149, ../sass/_adminlte.scss */ | |||||
/* line 161, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .table td.text-small, body.skin-black .content-wrapper .table th.text-small { | body.skin-black .content-wrapper .table td.text-small, body.skin-black .content-wrapper .table th.text-small { | ||||
font-size: 12px; | font-size: 12px; | ||||
} | } | ||||
/* line 154, ../sass/_adminlte.scss */ | |||||
/* line 166, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .pagination > .active > a, body.skin-black .content-wrapper .pagination > .active > span, body.skin-black .content-wrapper .pagination > .active > a:hover, body.skin-black .content-wrapper .pagination > .active > span:hover, body.skin-black .content-wrapper .pagination > .active > a:focus, body.skin-black .content-wrapper .pagination > .active > span:focus { | body.skin-black .content-wrapper .pagination > .active > a, body.skin-black .content-wrapper .pagination > .active > span, body.skin-black .content-wrapper .pagination > .active > a:hover, body.skin-black .content-wrapper .pagination > .active > span:hover, body.skin-black .content-wrapper .pagination > .active > a:focus, body.skin-black .content-wrapper .pagination > .active > span:focus { | ||||
background-color: #FF7F00; | background-color: #FF7F00; | ||||
border: solid 1px #FF7F00; | border: solid 1px #FF7F00; | ||||
color: white; | color: white; | ||||
} | } | ||||
/* line 159, ../sass/_adminlte.scss */ | |||||
/* line 171, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .pagination > li > a, body.skin-black .content-wrapper .pagination > li > span { | body.skin-black .content-wrapper .pagination > li > a, body.skin-black .content-wrapper .pagination > li > span { | ||||
color: #FF7F00; | color: #FF7F00; | ||||
} | } | ||||
/* line 161, ../sass/_adminlte.scss */ | |||||
/* line 173, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .pagination > li > a:hover, body.skin-black .content-wrapper .pagination > li > span:hover { | body.skin-black .content-wrapper .pagination > li > a:hover, body.skin-black .content-wrapper .pagination > li > span:hover { | ||||
color: #cc6600; | color: #cc6600; | ||||
} | } | ||||
/* line 168, ../sass/_adminlte.scss */ | |||||
/* line 180, ../sass/_adminlte.scss */ | |||||
body.skin-black .main-footer a { | body.skin-black .main-footer a { | ||||
color: #FF7F00; | color: #FF7F00; | ||||
} | } | ||||
/* line 174, ../sass/_adminlte.scss */ | |||||
/* line 186, ../sass/_adminlte.scss */ | |||||
body.login-page { | body.login-page { | ||||
background: none; | background: none; | ||||
background-color: white; | background-color: white; | ||||
} | } | ||||
/* line 178, ../sass/_adminlte.scss */ | |||||
/* line 190, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-logo { | body.login-page .login-box .login-logo { | ||||
text-align: center; | text-align: center; | ||||
font-family: "comfortaalight"; | font-family: "comfortaalight"; | ||||
} | } | ||||
/* line 181, ../sass/_adminlte.scss */ | |||||
/* line 193, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-logo img { | body.login-page .login-box .login-logo img { | ||||
width: 50px; | width: 50px; | ||||
} | } | ||||
/* line 186, ../sass/_adminlte.scss */ | |||||
/* line 198, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body .btn-primary { | body.login-page .login-box .login-box-body .btn-primary { | ||||
background-color: #FF7F00; | background-color: #FF7F00; | ||||
border-color: #FF7F00; | border-color: #FF7F00; | ||||
padding: 5px 10px; | padding: 5px 10px; | ||||
} | } | ||||
/* line 191, ../sass/_adminlte.scss */ | |||||
/* line 203, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body .btn-primary:active { | body.login-page .login-box .login-box-body .btn-primary:active { | ||||
background-color: #ff8c1a; | background-color: #ff8c1a; | ||||
border-color: #FF7F00; | border-color: #FF7F00; | ||||
} | } | ||||
/* line 197, ../sass/_adminlte.scss */ | |||||
/* line 209, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body a { | body.login-page .login-box .login-box-body a { | ||||
color: #FF7F00; | color: #FF7F00; | ||||
} | } | ||||
/* line 199, ../sass/_adminlte.scss */ | |||||
/* line 211, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body a:hover { | body.login-page .login-box .login-box-body a:hover { | ||||
color: #ff8c1a; | color: #ff8c1a; | ||||
} | } |
} | } | ||||
} | } | ||||
} | } | ||||
.navbar .nav li.producer-menu { | |||||
.label { | |||||
position: relative ; | |||||
top: -2px ; | |||||
left: 0px ; | |||||
} | |||||
} | |||||
} | } | ||||
.sidebar-menu > li.active > a { | .sidebar-menu > li.active > a { | ||||
a { | a { | ||||
color: white ; | color: white ; | ||||
} | } | ||||
a.btn { | |||||
color: #333 ; | |||||
text-decoration: none ; | |||||
} | |||||
} | } | ||||
.callout { | .callout { |
public $rememberMe = true; | public $rememberMe = true; | ||||
public $email; | public $email; | ||||
private $_user = false; | private $_user = false; | ||||
public $code ; | |||||
public $id_producer ; | public $id_producer ; | ||||
/** | /** | ||||
['rememberMe', 'boolean'], | ['rememberMe', 'boolean'], | ||||
// password is validated by validatePassword() | // password is validated by validatePassword() | ||||
['password', 'validatePassword'], | ['password', 'validatePassword'], | ||||
['code', 'required', 'message' => 'Champs obligatoire', 'when' => function($model) { | |||||
$producer = Producer::findOne($this->id_producer); | |||||
if ($producer) { | |||||
return strlen($producer->code); | |||||
} else { | |||||
return false; | |||||
} | |||||
}], | |||||
['code', function($attribute, $params) { | |||||
$code = $this->$attribute; | |||||
$producer = Producer::findOne($this->id_producer); | |||||
if ($producer && strtolower(trim($code)) != strtolower(trim($producer->code))) { | |||||
$this->addError($attribute, 'Code incorrect'); | |||||
} | |||||
}], | |||||
['id_producer', 'integer'], | ['id_producer', 'integer'], | ||||
['id_producer', function($attribute, $params) { | ['id_producer', function($attribute, $params) { | ||||
if ($this->id_producer) { | if ($this->id_producer) { |
if (Yii::$app->user->isGuest) { | if (Yii::$app->user->isGuest) { | ||||
if ($loginForm->load(Yii::$app->request->post()) && $loginForm->login()) { | if ($loginForm->load(Yii::$app->request->post()) && $loginForm->login()) { | ||||
Producer::addUser(User::getCurrentId(), $id) ; | |||||
if(!strlen($producer->code)) { | |||||
Producer::addUser(User::getCurrentId(), $id) ; | |||||
} | |||||
$this->redirect($returnUrl); | $this->redirect($returnUrl); | ||||
} | } | ||||
'producer' => $producer, | 'producer' => $producer, | ||||
]); | ]); | ||||
} | } | ||||
/** | |||||
* Indique à l'utilisateur que l'espace d'un producteur est hors ligne | |||||
* | |||||
* @param integer $id | |||||
* @return mixed | |||||
*/ | |||||
public function actionProducerOffline($id) | |||||
{ | |||||
$producer = Producer::searchOne([ | |||||
'id' => $id | |||||
]); | |||||
return $this->render('producer_offline', [ | |||||
'producer' => $producer, | |||||
]); | |||||
} | |||||
} | } |
<p> | <p> | ||||
Si vous avez oublié votre mot de passe, vous pouvez le <?= Html::a('réinitialiser', ['site/request-password-reset']) ?>. | Si vous avez oublié votre mot de passe, vous pouvez le <?= Html::a('réinitialiser', ['site/request-password-reset']) ?>. | ||||
</p> | </p> | ||||
<?php if(strlen($producer->code)): ?> | |||||
<?= $form->field($loginForm, 'code',[ | |||||
'inputTemplate' => '<div class="input-group"><span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>{input}</div>', | |||||
]) | |||||
->label('Code du producteur') | |||||
->hint('Renseignez-vous auprès de votre producteur pour qu\'il vous fournisse le code d\'accès') ; ?> | |||||
<?php endif; ?> | |||||
<div class="form-group"> | <div class="form-group"> | ||||
<?= Html::submitButton('Connexion', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?> | <?= Html::submitButton('Connexion', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?> | ||||
</div> | </div> |
<?php | |||||
/** | |||||
Copyright distrib (2018) | |||||
contact@opendistrib.net | |||||
Ce logiciel est un programme informatique servant à aider les producteurs | |||||
à distribuer leur production en circuits courts. | |||||
Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||||
respectant les principes de diffusion des logiciels libres. Vous pouvez | |||||
utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||||
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||||
sur le site "http://www.cecill.info". | |||||
En contrepartie de l'accessibilité au code source et des droits de copie, | |||||
de modification et de redistribution accordés par cette licence, il n'est | |||||
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||||
seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||||
titulaire des droits patrimoniaux et les concédants successifs. | |||||
A cet égard l'attention de l'utilisateur est attirée sur les risques | |||||
associés au chargement, à l'utilisation, à la modification et/ou au | |||||
développement et à la reproduction du logiciel par l'utilisateur étant | |||||
donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||||
manipuler et qui le réserve donc à des développeurs et des professionnels | |||||
avertis possédant des connaissances informatiques approfondies. Les | |||||
utilisateurs sont donc invités à charger et tester l'adéquation du | |||||
logiciel à leurs besoins dans des conditions permettant d'assurer la | |||||
sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||||
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||||
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||||
pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||||
termes. | |||||
*/ | |||||
use yii\helpers\Html ; | |||||
use yii\bootstrap\ActiveForm; | |||||
$this->title = 'Espace producteur '.Html::encode($producer->name).' désactivé' ; | |||||
?> | |||||
<div id="page-producer"> | |||||
<h1 class="title-system-order"><?= Html::encode($producer->name) ?></h1> | |||||
<p class="info"><span class="alert alert-danger">L'espace de ce producteur est désactivé.</span></p> | |||||
</div> |
$amountRemaining = $order->getAmount(Order::AMOUNT_REMAINING) ; | $amountRemaining = $order->getAmount(Order::AMOUNT_REMAINING) ; | ||||
$credit = Yii::$app->user->identity->getCredit($distribution->id_producer); | $credit = Yii::$app->user->identity->getCredit($distribution->id_producer); | ||||
if ($amountRemaining > $credit) { | |||||
$amountRemaining = $credit; | |||||
} | |||||
if ($amountRemaining > 0) { | if ($amountRemaining > 0) { | ||||
$order->saveCreditHistory( | $order->saveCreditHistory( | ||||
CreditHistory::TYPE_PAYMENT, | CreditHistory::TYPE_PAYMENT, |
} | } | ||||
} | } | ||||
} | } | ||||
/* | |||||
* Producteur hors ligne | |||||
*/ | |||||
if(!$producer->active && (Yii::$app->user->isGuest || Yii::$app->user->identity->id_producer != $producer->id)) { | |||||
$this->redirect(Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer-offline','id' => $producer->id])) ; | |||||
} | |||||
return parent::beforeAction($event); | return parent::beforeAction($event); | ||||
} | } |