Le boulanger peut activer ou désactiver le système de crédit pain. Ce choix est ensuite répercuté sur le frontend.master
@@ -72,8 +72,13 @@ class UserController extends BackendController | |||
->andWhere('user_etablissement.id_etablissement = '.Yii::$app->user->identity->id_etablissement) | |||
]); | |||
$etablissement = Etablissement::find() | |||
->where(['id' => Yii::$app->user->identity->id]) | |||
->one() ; | |||
return $this->render('index', [ | |||
'dataProvider' => $dataProvider, | |||
'etablissement' => $etablissement | |||
]); | |||
} | |||
@@ -44,6 +44,18 @@ $this->params['breadcrumbs'][] = 'Paramètres'; | |||
], []) | |||
->hint('Heure limite jusqu\'à laquelle les clients peuvent commander pour satisfaire le délai de commande.<br />' | |||
. 'Par exemple, si <strong>2 jours</strong> est sélectionné dans le délai de commande, le client devra commander l\'avant-veille de la production avant l\'heure précisée ici.') ; ?> | |||
<?= $form->field($model, 'credit_pain') | |||
->dropDownList([ | |||
0 => 'Non', | |||
1 => 'Oui', | |||
], []) | |||
->label('Activer le système de Crédit Pain') | |||
->hint('Le système de Crédit Pain permet à vos clients d\'avoir un compte prépayé sur le site <em>La boîte à pain</em>.<br />' | |||
. 'Ils créditent leur compte en vous donnant la somme de leur choix à la boulangerie et c\'est ensuite à vous de '.Html::a('mettre à jour', ['user/index']).' leur compte Crédit Pain en ligne.<br />' | |||
. 'Ceci fait, les clients paient leur commande directement via leur compte Crédit Pain.') ; ?> | |||
<?= $form->field($model, 'photo')->fileInput() ?> | |||
<?php | |||
if (strlen($model->photo)) { |
@@ -3,6 +3,7 @@ | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use common\models\CreditHistorique; | |||
use common\models\Etablissement; | |||
$this->title = 'Créditer <small>'.Html::encode($user->nom.' '.$user->prenom).'</small>'; | |||
$this->params['breadcrumbs'][] = ['label' => 'Utilisateurs', 'url' => ['index']]; | |||
@@ -12,7 +13,18 @@ $this->params['breadcrumbs'][] = 'Créditer'; | |||
?> | |||
<div class="user-credit"> | |||
<?php | |||
$etablissement = Etablissement::find() | |||
->where(['id' => Yii::$app->user->identity->id]) | |||
->one() ; | |||
if(!$etablissement->credit_pain) | |||
{ | |||
echo '<div class="alert alert-warning">Attention, la fonctionnalité <strong>Crédit Pain</strong> est désactivée dans vos <a href="'.Yii::$app->urlManager->createurl(['etablissement/update']).'">paramètres</a>.' | |||
. ' Pensez à l\'activer si vous souhaitez qu\'elle soit visible de vos clients.</div>' ; | |||
} | |||
?> | |||
<div class="col-md-12"> | |||
<h1><?= $this->title ?></h1> | |||
<?php $form = ActiveForm::begin(); ?> | |||
@@ -55,7 +67,7 @@ $this->params['breadcrumbs'][] = 'Créditer'; | |||
(supprimée) | |||
<?php endif; ?> | |||
<?php endif; ?> | |||
<?php if($ch->type == CreditHistorique::TYPE_REMBOURSEMENT): ?>Remboursement commande du <?= date('d/m/Y',strtotime($ch->commande->date)) ?><?php endif; ?> | |||
<?php if($ch->type == CreditHistorique::TYPE_REMBOURSEMENT): ?>Remboursement commande <?php if(isset($ch->commande)): ?>du <?= date('d/m/Y',strtotime($ch->commande->date)) ?><?php else: ?>(supprimée)<?php endif; ?><?php endif; ?> | |||
</td> | |||
<td> | |||
<?= $ch->montant ; ?> € |
@@ -17,7 +17,7 @@ $this->params['breadcrumbs'][] = $this->title; | |||
<?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-primary']) ?> | |||
<?= Html::a('<span class="glyphicon glyphicon-envelope"></span> Liste des emails', ['mail'], ['class' => 'btn btn-default']) ?> | |||
</h1> | |||
<?= GridView::widget([ | |||
'dataProvider' => $dataProvider, | |||
'columns' => [ | |||
@@ -28,44 +28,20 @@ $this->params['breadcrumbs'][] = $this->title; | |||
[ | |||
'attribute' => 'credit', | |||
'format' => 'raw', | |||
'value' => function($model) { | |||
$html = $model['credit'].' € ' ; | |||
$html = '<div class="input-group"> | |||
<input type="text" class="form-control input-credit" readonly="readonly" value="'.$model['credit'].' €" placeholder=""> | |||
<span class="input-group-btn"> | |||
'.Html::a( | |||
'<span class="glyphicon glyphicon-euro"></span> Crédit', | |||
Yii::$app->urlManager->createUrl(['user/credit','id' => $model['id']]), | |||
[ | |||
'title' => 'Crédit', | |||
'class' => 'btn btn-default' | |||
] | |||
).' | |||
</span> | |||
</div>' ; | |||
/*$html = '<div class="btn-group" role="group" aria-label=""> | |||
<input type="text" readonly="readonly" class="btn btn-default">'.$model['credit'].' € </button> | |||
'.Html::a( | |||
'<span class="glyphicon glyphicon-euro"></span> Créditer', | |||
Yii::$app->urlManager->createUrl(['user/credit','id' => $model['id']]), | |||
[ | |||
'title' => 'Créditer', | |||
'class' => 'btn btn-default' | |||
] | |||
).' | |||
</div>' ;*/ | |||
/*$html .= Html::a( | |||
'<span class="glyphicon glyphicon-euro"></span> Créditer', | |||
Yii::$app->urlManager->createUrl(['user/credit','id' => $model['id']]), | |||
[ | |||
'title' => 'Créditer', | |||
'class' => 'btn btn-default btn-xs' | |||
] | |||
) ;*/ | |||
'value' => function($model) use($etablissement) { | |||
$html = '<div class="input-group"> | |||
<input type="text" class="form-control input-credit" readonly="readonly" value="'.number_format($model['credit'],2).' €" placeholder=""> | |||
<span class="input-group-btn"> | |||
'.Html::a( | |||
'<span class="glyphicon glyphicon-euro"></span> Crédit', | |||
Yii::$app->urlManager->createUrl(['user/credit','id' => $model['id']]), | |||
[ | |||
'title' => 'Crédit', | |||
'class' => 'btn btn-default' | |||
] | |||
).' | |||
</span> | |||
</div>' ; | |||
return $html ; | |||
} | |||
], | |||
@@ -77,7 +53,7 @@ $this->params['breadcrumbs'][] = $this->title; | |||
'update' => function ($url, $model) { | |||
$url = Yii::$app->urlManager->createUrl(['user/update','id' => $model['id']]) ; | |||
$user = User::find()->with('userEtablissement')->where(['id' => $model['id']])->one() ; | |||
if(count($user->userEtablissement) == 1) | |||
if(count($user->userEtablissement) <= 1) | |||
{ | |||
return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [ | |||
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default' |
@@ -55,7 +55,7 @@ class Etablissement extends \yii\db\ActiveRecord | |||
} | |||
}], | |||
[['description'], 'string'], | |||
[['solde_negatif'], 'boolean'], | |||
[['solde_negatif', 'credit_pain'], 'boolean'], | |||
[['nom', 'siret', 'logo', 'photo', 'code_postal', 'ville','code'], 'string', 'max' => 255], | |||
]; | |||
} | |||
@@ -78,6 +78,7 @@ class Etablissement extends \yii\db\ActiveRecord | |||
'heure_limite_commande' => 'Heure limite de commande', | |||
'delai_commande' => 'Délai de commande', | |||
'solde_negatif' => 'Solde négatif', | |||
'credit_pain' => 'Crédit pain' | |||
]; | |||
} | |||
@@ -0,0 +1,17 @@ | |||
<?php | |||
use yii\db\Migration; | |||
use yii\db\Schema; | |||
class m161214_131720_add_champs_etablissement_activer_credit_pain extends Migration | |||
{ | |||
public function up() | |||
{ | |||
$this->addColumn('etablissement', 'credit_pain', Schema::TYPE_BOOLEAN.' DEFAULT 0') ; | |||
} | |||
public function down() | |||
{ | |||
$this->dropColumn('etablissement', 'credit_pain') ; | |||
} | |||
} |
@@ -2,6 +2,7 @@ | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use common\models\Etablissement; | |||
/* @var $this yii\web\View */ | |||
/* @var $model common\models\Commande */ | |||
@@ -183,24 +184,42 @@ use yii\widgets\ActiveForm; | |||
</div> | |||
<div id="bar-fixed"> | |||
<?php if($id_etablissement): ?> | |||
<?php | |||
$etablissement = Etablissement::findOne($id_etablissement); | |||
?> | |||
<div id="bar-fixed" class="<?php if($etablissement->credit_pain): ?>credit-pain<?php else: ?>no-credit-pain<?php endif; ?>"> | |||
<div class="container"> | |||
<?php if (isset($model->id)): ?> | |||
<a href="<?php echo Yii::$app->urlManager->createUrl(['commande/annuler', 'id' => $model->id]); ?>" class="btn btn-danger annuler-commande">Annuler ma commande</a> | |||
<?php endif; ?> | |||
<span id="total-commande-bottom"><span></span> €</span> | |||
<?= Html::submitButton('<span class="glyphicon glyphicon-comment"></span> Commentaire', ['class' => 'btn btn-default btn-commentaire', 'data-placement' => 'top', 'data-toggle' => 'tooltip', 'data-original-title' => 'Ajouter un commentaire']) ?> | |||
<div id="checkbox-credit-pain" > | |||
<?= Html::checkbox('credit_pain', true, ['label' => 'Utiliser mon Crédit Pain <span class="the-credit" data-toggle="tooltip" data-placement="top" data-original-title="Vous avez actuellement '.number_format($credit,2).' € sur votre compte Crédit Pain">'.number_format($credit,2).' €</span><br /><span class="info"></span>']) ?> | |||
<?= Html::hiddenInput('montant_credit_pain', $credit, ['id' => 'montant-credit-pain']) ?> | |||
<?= Html::hiddenInput('str_montant_credit_pain', number_format($credit,2).' €', ['id' => 'str-montant-credit-pain']) ?> | |||
</div> | |||
<div class="clr"></div> | |||
<?= $form->field($model, 'commentaire')->textarea(['rows' => 3, 'placeholder' => 'Un commentaire ?'])->label(''); ?> | |||
<div id="bloc-valider-commande"> | |||
<?= Html::submitButton('<span class="glyphicon glyphicon-ok"></span> Valider ma commande', ['class' => 'btn btn-primary valider-commande']) ?> | |||
</div> | |||
<?php | |||
if($etablissement->credit_pain): | |||
?> | |||
<div id="checkbox-credit-pain" > | |||
<?php if($credit || $model->getMontantPaye()): ?> | |||
<?= Html::checkbox('credit_pain', true, ['label' => 'Utiliser mon compte Crédit Pain <span class="the-credit" data-toggle="tooltip" data-placement="top" data-original-title="Vous avez actuellement '.number_format($credit,2).' € sur votre compte Crédit Pain">'.number_format($credit,2).' €</span><br /><span class="info"></span>']) ?> | |||
<?= Html::hiddenInput('montant_credit_pain', $credit, ['id' => 'montant-credit-pain']) ?> | |||
<?= Html::hiddenInput('str_montant_credit_pain', number_format($credit,2).' €', ['id' => 'str-montant-credit-pain']) ?> | |||
<?php else: ?> | |||
<div id="info-credit-vide"> | |||
Votre compte Crédit Pain est vide.<br /> | |||
Rendez-vous dans votre boulangerie<br/> | |||
pour le recharger. <a class="info-credit-pain" href="<?= Yii::$app->urlManager->createUrl(['site/creditpain']); ?>" data-toggle="tooltip" data-placement="bottom" title="En savoir plus sur le Crédit Pain"><span class="glyphicon glyphicon-info-sign"></span></a> | |||
</div> | |||
<?php endif; ?> | |||
</div> | |||
<div class="clr"></div> | |||
<?php endif; ?> | |||
<?= $form->field($model, 'commentaire')->textarea(['rows' => 3, 'placeholder' => 'Un commentaire ?'])->label(''); ?> | |||
<div id="bloc-valider-commande"> | |||
<?= Html::submitButton('<span class="glyphicon glyphicon-ok"></span> Valider ma commande', ['class' => 'btn btn-primary valider-commande']) ?> | |||
</div> | |||
<?php endif; ?> | |||
</div> | |||
</div> | |||
@@ -49,12 +49,14 @@ use yii\helpers\Html ; | |||
<?= Html::encode($e['delai_commande']) ?> jour<?php if($e['delai_commande'] > 1): ?>s<?php endif; ?> | |||
</span> | |||
</div> | |||
<?php if($e['credit_pain']): ?> | |||
<div class="credit-pain"> | |||
<span data-toggle="tooltip" data-placement="bottom" title="Montant de votre compte Crédit Pain. Rendez-vous dans votre boulangerie pour créditer votre compte."> | |||
<span class="montant"><?= number_format($e['credit'],2); ?> <span class="glyphicon glyphicon-euro"></span></span> | |||
</span> | |||
<a class="info-credit-pain" href="<?= Yii::$app->urlManager->createUrl(['site/creditpain']); ?>" data-toggle="tooltip" data-placement="bottom" title="En savoir plus sur le Crédit Pain"><span class="glyphicon glyphicon-info-sign"></span></a> | |||
</div> | |||
<?php endif; ?> | |||
<div class="clr"></div> | |||
</div> | |||
</div> |
@@ -1040,7 +1040,12 @@ h2 { | |||
border: solid 1px #e0e0e0; | |||
padding-right: 20px; | |||
} | |||
/* line 521, ../sass/_systeme_commandes.scss */ | |||
/* line 522, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed.no-credit-pain #bloc-valider-commande { | |||
margin-top: 0px; | |||
float: right; | |||
} | |||
/* line 528, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed #total-commande-bottom { | |||
background-color: white; | |||
-moz-border-radius: 20px; | |||
@@ -1049,25 +1054,25 @@ h2 { | |||
padding: 5px 25px; | |||
border: solid 1px #e0e0e0; | |||
} | |||
/* line 528, ../sass/_systeme_commandes.scss */ | |||
/* line 535, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed .btn-commentaire { | |||
float: left; | |||
} | |||
/* line 536, ../sass/_systeme_commandes.scss */ | |||
/* line 543, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed .btn-commentaire { | |||
margin-right: 10px; | |||
} | |||
/* line 540, ../sass/_systeme_commandes.scss */ | |||
/* line 547, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed #bloc-valider-commande { | |||
text-align: right; | |||
margin-top: 20px; | |||
} | |||
/* line 544, ../sass/_systeme_commandes.scss */ | |||
/* line 551, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed #bloc-valider-commande button { | |||
width: 300px; | |||
margin-right: 10px; | |||
} | |||
/* line 550, ../sass/_systeme_commandes.scss */ | |||
/* line 557, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed #checkbox-credit-pain { | |||
float: right; | |||
width: 300px; | |||
@@ -1083,16 +1088,16 @@ h2 { | |||
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 1px 1px rgba(0, 0, 0, 0.075); | |||
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 1px 1px rgba(0, 0, 0, 0.075); | |||
} | |||
/* line 561, ../sass/_systeme_commandes.scss */ | |||
/* line 568, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed #checkbox-credit-pain.paiement-impossible { | |||
background-color: #e0e0e0; | |||
} | |||
/* line 565, ../sass/_systeme_commandes.scss */ | |||
/* line 572, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed #checkbox-credit-pain .info { | |||
color: gray; | |||
font-weight: normal; | |||
} | |||
/* line 570, ../sass/_systeme_commandes.scss */ | |||
/* line 577, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed #checkbox-credit-pain .the-credit { | |||
background-color: #BB8757; | |||
color: white; | |||
@@ -1101,33 +1106,37 @@ h2 { | |||
-webkit-border-radius: 5px; | |||
border-radius: 5px; | |||
} | |||
/* line 577, ../sass/_systeme_commandes.scss */ | |||
/* line 584, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed #checkbox-credit-pain .montant-paye { | |||
color: #BB8757; | |||
} | |||
/* line 582, ../sass/_systeme_commandes.scss */ | |||
/* line 588, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed #checkbox-credit-pain #info-credit-vide { | |||
font-size: 12px; | |||
} | |||
/* line 593, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed .btn-retour, .commande-form #bar-fixed .annuler-commande { | |||
float: left; | |||
margin-right: 5px; | |||
} | |||
/* line 587, ../sass/_systeme_commandes.scss */ | |||
/* line 598, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed .annuler-commande { | |||
color: #b92c28; | |||
background-color: white; | |||
} | |||
/* line 592, ../sass/_systeme_commandes.scss */ | |||
/* line 603, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed #total-commande-bottom { | |||
display: none; | |||
font-weight: bold; | |||
font-family: "comfortaalight"; | |||
font-size: 24px; | |||
} | |||
/* line 599, ../sass/_systeme_commandes.scss */ | |||
/* line 610, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed .field-commande-commentaire { | |||
display: none; | |||
} | |||
/* line 607, ../sass/_systeme_commandes.scss */ | |||
/* line 618, ../sass/_systeme_commandes.scss */ | |||
.ui-datepicker .ui-widget-header { | |||
background: none; | |||
background-color: gray; | |||
@@ -1135,7 +1144,7 @@ h2 { | |||
color: black; | |||
font-weight: normal; | |||
} | |||
/* line 615, ../sass/_systeme_commandes.scss */ | |||
/* line 626, ../sass/_systeme_commandes.scss */ | |||
.ui-datepicker .ui-datepicker-current-day a, | |||
.ui-datepicker a.ui-state-hover { | |||
background: none; |
@@ -518,6 +518,13 @@ h2 { | |||
padding-right: 20px ; | |||
} | |||
&.no-credit-pain { | |||
#bloc-valider-commande { | |||
margin-top: 0px ; | |||
float: right ; | |||
} | |||
} | |||
#total-commande-bottom { | |||
background-color: white ; | |||
@include border-radius(20px) ; | |||
@@ -577,6 +584,10 @@ h2 { | |||
.montant-paye { | |||
color: $color1 ; | |||
} | |||
#info-credit-vide { | |||
font-size: 12px ; | |||
} | |||
} | |||
.btn-retour, .annuler-commande { |