@@ -118,7 +118,6 @@ class DistributionController extends BackendController | |||
// products | |||
$productsArray = Product::find() | |||
->orWhere(['id_producer' => Producer::getId(),]) | |||
->orWhere(['id_producer' => 0,]) // produit "Don" | |||
->joinWith(['productDistribution' => function($query) use($distribution) { | |||
$query->andOnCondition('product_distribution.id_distribution = '.$distribution->id) ; | |||
}]) | |||
@@ -128,17 +127,17 @@ class DistributionController extends BackendController | |||
$potentialRevenues = 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; | |||
} | |||
} | |||
@@ -47,6 +47,8 @@ use yii\web\NotFoundHttpException; | |||
use yii\filters\VerbFilter; | |||
use common\models\User; | |||
use common\models\UserPointSale; | |||
use common\models\Order ; | |||
use yii\helpers\Html; | |||
/** | |||
* PointVenteController implements the CRUD actions for PointVente model. | |||
@@ -136,6 +138,7 @@ class PointSaleController extends BackendController | |||
$model->processPointProduction(); | |||
$model->processRestrictedAccess(); | |||
Distribution::linkPointSaleIncomingDistributions($model) ; | |||
Yii::$app->getSession()->setFlash('success', 'Point de vente modifié.'); | |||
return $this->redirect(['index']); | |||
} else { | |||
return $this->render('update', array_merge($this->initForm($id), [ | |||
@@ -166,11 +169,22 @@ class PointSaleController extends BackendController | |||
* @param integer $id | |||
* @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']); | |||
} | |||
@@ -174,13 +174,19 @@ class ProductController extends BackendController | |||
* @param integer $id | |||
* @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']); | |||
} |
@@ -44,6 +44,9 @@ use yii\helpers\ArrayHelper; | |||
/* @var $this \yii\web\View */ | |||
/* @var $content string */ | |||
$producer = Producer::getCurrent() ; | |||
?> | |||
<header class="main-header"> | |||
@@ -131,9 +134,14 @@ use yii\helpers\ArrayHelper; | |||
</li> | |||
<?php if (User::isCurrentProducer() || User::isCurrentAdmin()): ?> | |||
<li class="dropdown"> | |||
<li class="dropdown producer-menu"> | |||
<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> | |||
<i class="fa fa-caret-down"></i> | |||
</a> |
@@ -1409,126 +1409,137 @@ body.skin-black .main-header .notifications-menu ul.menu li a p { | |||
margin-left: 10px; | |||
} | |||
/* 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 { | |||
border-color: #FF7F00; | |||
} | |||
/* line 83, ../sass/_adminlte.scss */ | |||
/* line 91, ../sass/_adminlte.scss */ | |||
body.skin-black .content-wrapper { | |||
background-color: #f5f5f5; | |||
} | |||
/* line 86, ../sass/_adminlte.scss */ | |||
/* line 94, ../sass/_adminlte.scss */ | |||
body.skin-black .content-wrapper .content-header { | |||
background-color: #F5F5F5; | |||
padding-bottom: 15px; | |||
border-bottom: 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 { | |||
padding: 3px 6px; | |||
font-size: 13px; | |||
} | |||
/* line 97, ../sass/_adminlte.scss */ | |||
/* line 105, ../sass/_adminlte.scss */ | |||
body.skin-black .content-wrapper .content-header h1 { | |||
font-family: "highvoltageregular"; | |||
} | |||
/* line 104, ../sass/_adminlte.scss */ | |||
/* line 112, ../sass/_adminlte.scss */ | |||
body.skin-black .content-wrapper a { | |||
color: #FF7F00; | |||
} | |||
/* line 108, ../sass/_adminlte.scss */ | |||
/* line 116, ../sass/_adminlte.scss */ | |||
body.skin-black .content-wrapper .btn { | |||
color: white; | |||
} | |||
/* line 112, ../sass/_adminlte.scss */ | |||
/* line 120, ../sass/_adminlte.scss */ | |||
body.skin-black .content-wrapper .btn-default { | |||
color: #333; | |||
} | |||
/* line 116, ../sass/_adminlte.scss */ | |||
/* line 124, ../sass/_adminlte.scss */ | |||
body.skin-black .content-wrapper .btn-primary { | |||
background-color: #FF7F00; | |||
color: white; | |||
border-color: #FF7F00; | |||
} | |||
/* line 123, ../sass/_adminlte.scss */ | |||
/* line 131, ../sass/_adminlte.scss */ | |||
body.skin-black .content-wrapper .alert a { | |||
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 { | |||
margin-right: 7px; | |||
} | |||
/* line 132, ../sass/_adminlte.scss */ | |||
/* line 144, ../sass/_adminlte.scss */ | |||
body.skin-black .content-wrapper .callout a { | |||
color: white; | |||
} | |||
/* line 135, ../sass/_adminlte.scss */ | |||
/* line 147, ../sass/_adminlte.scss */ | |||
body.skin-black .content-wrapper .callout .btn { | |||
color: #333; | |||
text-decoration: none; | |||
} | |||
/* line 142, ../sass/_adminlte.scss */ | |||
/* line 154, ../sass/_adminlte.scss */ | |||
body.skin-black .content-wrapper .table th { | |||
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 { | |||
width: 150px; | |||
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 { | |||
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 { | |||
background-color: #FF7F00; | |||
border: solid 1px #FF7F00; | |||
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 { | |||
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 { | |||
color: #cc6600; | |||
} | |||
/* line 168, ../sass/_adminlte.scss */ | |||
/* line 180, ../sass/_adminlte.scss */ | |||
body.skin-black .main-footer a { | |||
color: #FF7F00; | |||
} | |||
/* line 174, ../sass/_adminlte.scss */ | |||
/* line 186, ../sass/_adminlte.scss */ | |||
body.login-page { | |||
background: none; | |||
background-color: white; | |||
} | |||
/* line 178, ../sass/_adminlte.scss */ | |||
/* line 190, ../sass/_adminlte.scss */ | |||
body.login-page .login-box .login-logo { | |||
text-align: center; | |||
font-family: "comfortaalight"; | |||
} | |||
/* line 181, ../sass/_adminlte.scss */ | |||
/* line 193, ../sass/_adminlte.scss */ | |||
body.login-page .login-box .login-logo img { | |||
width: 50px; | |||
} | |||
/* line 186, ../sass/_adminlte.scss */ | |||
/* line 198, ../sass/_adminlte.scss */ | |||
body.login-page .login-box .login-box-body .btn-primary { | |||
background-color: #FF7F00; | |||
border-color: #FF7F00; | |||
padding: 5px 10px; | |||
} | |||
/* line 191, ../sass/_adminlte.scss */ | |||
/* line 203, ../sass/_adminlte.scss */ | |||
body.login-page .login-box .login-box-body .btn-primary:active { | |||
background-color: #ff8c1a; | |||
border-color: #FF7F00; | |||
} | |||
/* line 197, ../sass/_adminlte.scss */ | |||
/* line 209, ../sass/_adminlte.scss */ | |||
body.login-page .login-box .login-box-body a { | |||
color: #FF7F00; | |||
} | |||
/* line 199, ../sass/_adminlte.scss */ | |||
/* line 211, ../sass/_adminlte.scss */ | |||
body.login-page .login-box .login-box-body a:hover { | |||
color: #ff8c1a; | |||
} |
@@ -74,6 +74,14 @@ body.skin-black { | |||
} | |||
} | |||
} | |||
.navbar .nav li.producer-menu { | |||
.label { | |||
position: relative ; | |||
top: -2px ; | |||
left: 0px ; | |||
} | |||
} | |||
} | |||
.sidebar-menu > li.active > a { | |||
@@ -123,6 +131,10 @@ body.skin-black { | |||
a { | |||
color: white ; | |||
} | |||
a.btn { | |||
color: #333 ; | |||
text-decoration: none ; | |||
} | |||
} | |||
.callout { |
@@ -51,7 +51,6 @@ class LoginForm extends Model | |||
public $rememberMe = true; | |||
public $email; | |||
private $_user = false; | |||
public $code ; | |||
public $id_producer ; | |||
/** | |||
@@ -70,22 +69,6 @@ class LoginForm extends Model | |||
['rememberMe', 'boolean'], | |||
// password is validated by 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', function($attribute, $params) { | |||
if ($this->id_producer) { |
@@ -404,7 +404,9 @@ class SiteController extends FrontendController | |||
if (Yii::$app->user->isGuest) { | |||
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); | |||
} | |||
@@ -425,5 +427,22 @@ class SiteController extends FrontendController | |||
'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, | |||
]); | |||
} | |||
} |
@@ -60,13 +60,6 @@ $this->title = 'Producteur '.Html::encode($producer->name) ; | |||
<p> | |||
Si vous avez oublié votre mot de passe, vous pouvez le <?= Html::a('réinitialiser', ['site/request-password-reset']) ?>. | |||
</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"> | |||
<?= Html::submitButton('Connexion', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?> | |||
</div> |
@@ -0,0 +1,49 @@ | |||
<?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> |
@@ -318,10 +318,6 @@ class OrderController extends ProducerBaseController | |||
$amountRemaining = $order->getAmount(Order::AMOUNT_REMAINING) ; | |||
$credit = Yii::$app->user->identity->getCredit($distribution->id_producer); | |||
if ($amountRemaining > $credit) { | |||
$amountRemaining = $credit; | |||
} | |||
if ($amountRemaining > 0) { | |||
$order->saveCreditHistory( | |||
CreditHistory::TYPE_PAYMENT, |
@@ -85,6 +85,12 @@ class ProducerBaseController extends CommonController | |||
} | |||
} | |||
} | |||
/* | |||
* 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); | |||
} |