Browse Source

Crédit pain : pouvoir activer et désactiver la fonctionnalité

Le boulanger peut activer ou désactiver le système de crédit pain. Ce choix est ensuite répercuté sur le frontend.
prodstable
keun 8 years ago
parent
commit
9aec972d75
11 changed files with 134 additions and 70 deletions
  1. +5
    -0
      backend/controllers/UserController.php
  2. +12
    -0
      backend/views/etablissement/update.php
  3. +14
    -2
      backend/views/user/credit.php
  4. +16
    -40
      backend/views/user/index.php
  5. +2
    -1
      common/models/Etablissement.php
  6. +17
    -0
      console/migrations/m161214_131720_add_champs_etablissement_activer_credit_pain.php
  7. +30
    -11
      frontend/views/commande/_form.php
  8. +2
    -0
      frontend/views/commande/_liste_etablissements.php
  9. BIN
      frontend/web/.sass-cache/e1a48ee3204d3a535cdbe440c2995954a615ac19/_systeme_commandes.scssc
  10. +25
    -16
      frontend/web/css/screen.css
  11. +11
    -0
      frontend/web/sass/_systeme_commandes.scss

+ 5
- 0
backend/controllers/UserController.php View File

->andWhere('user_etablissement.id_etablissement = '.Yii::$app->user->identity->id_etablissement) ->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', [ return $this->render('index', [
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'etablissement' => $etablissement
]); ]);
} }



+ 12
- 0
backend/views/etablissement/update.php View File

], []) ], [])
->hint('Heure limite jusqu\'à laquelle les clients peuvent commander pour satisfaire le délai de commande.<br />' ->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.') ; ?> . '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() ?> <?= $form->field($model, 'photo')->fileInput() ?>
<?php <?php
if (strlen($model->photo)) { if (strlen($model->photo)) {

+ 14
- 2
backend/views/user/credit.php View File

use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
use common\models\CreditHistorique; use common\models\CreditHistorique;
use common\models\Etablissement;


$this->title = 'Créditer <small>'.Html::encode($user->nom.' '.$user->prenom).'</small>'; $this->title = 'Créditer <small>'.Html::encode($user->nom.' '.$user->prenom).'</small>';
$this->params['breadcrumbs'][] = ['label' => 'Utilisateurs', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => 'Utilisateurs', 'url' => ['index']];
?> ?>


<div class="user-credit"> <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"> <div class="col-md-12">
<h1><?= $this->title ?></h1> <h1><?= $this->title ?></h1>
<?php $form = ActiveForm::begin(); ?> <?php $form = ActiveForm::begin(); ?>
(supprimée) (supprimée)
<?php endif; ?> <?php endif; ?>
<?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>
<td> <td>
<?= $ch->montant ; ?> € <?= $ch->montant ; ?> €

+ 16
- 40
backend/views/user/index.php View File

<?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-primary']) ?> <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-primary']) ?>
<?= Html::a('<span class="glyphicon glyphicon-envelope"></span> Liste des emails', ['mail'], ['class' => 'btn btn-default']) ?> <?= Html::a('<span class="glyphicon glyphicon-envelope"></span> Liste des emails', ['mail'], ['class' => 'btn btn-default']) ?>
</h1> </h1>
<?= GridView::widget([ <?= GridView::widget([
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'columns' => [ 'columns' => [
[ [
'attribute' => 'credit', 'attribute' => 'credit',
'format' => 'raw', '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 ; return $html ;
} }
], ],
'update' => function ($url, $model) { 'update' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/update','id' => $model['id']]) ; $url = Yii::$app->urlManager->createUrl(['user/update','id' => $model['id']]) ;
$user = User::find()->with('userEtablissement')->where(['id' => $model['id']])->one() ; $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, [ return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default' 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'

+ 2
- 1
common/models/Etablissement.php View File

} }
}], }],
[['description'], 'string'], [['description'], 'string'],
[['solde_negatif'], 'boolean'],
[['solde_negatif', 'credit_pain'], 'boolean'],
[['nom', 'siret', 'logo', 'photo', 'code_postal', 'ville','code'], 'string', 'max' => 255], [['nom', 'siret', 'logo', 'photo', 'code_postal', 'ville','code'], 'string', 'max' => 255],
]; ];
} }
'heure_limite_commande' => 'Heure limite de commande', 'heure_limite_commande' => 'Heure limite de commande',
'delai_commande' => 'Délai de commande', 'delai_commande' => 'Délai de commande',
'solde_negatif' => 'Solde négatif', 'solde_negatif' => 'Solde négatif',
'credit_pain' => 'Crédit pain'
]; ];
} }

+ 17
- 0
console/migrations/m161214_131720_add_champs_etablissement_activer_credit_pain.php View File

<?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') ;
}
}

+ 30
- 11
frontend/views/commande/_form.php View File



use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
use common\models\Etablissement;


/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\Commande */ /* @var $model common\models\Commande */


</div> </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"> <div class="container">
<?php if (isset($model->id)): ?> <?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> <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; ?> <?php endif; ?>
<span id="total-commande-bottom"><span></span> €</span> <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']) ?> <?= 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>
</div> </div>

+ 2
- 0
frontend/views/commande/_liste_etablissements.php View File

<?= Html::encode($e['delai_commande']) ?> jour<?php if($e['delai_commande'] > 1): ?>s<?php endif; ?> <?= Html::encode($e['delai_commande']) ?> jour<?php if($e['delai_commande'] > 1): ?>s<?php endif; ?>
</span> </span>
</div> </div>
<?php if($e['credit_pain']): ?>
<div class="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 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 class="montant"><?= number_format($e['credit'],2); ?> <span class="glyphicon glyphicon-euro"></span></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> <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> </div>
<?php endif; ?>
<div class="clr"></div> <div class="clr"></div>
</div> </div>
</div> </div>

BIN
frontend/web/.sass-cache/e1a48ee3204d3a535cdbe440c2995954a615ac19/_systeme_commandes.scssc View File


+ 25
- 16
frontend/web/css/screen.css View File

border: solid 1px #e0e0e0; border: solid 1px #e0e0e0;
padding-right: 20px; 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 { .commande-form #bar-fixed #total-commande-bottom {
background-color: white; background-color: white;
-moz-border-radius: 20px; -moz-border-radius: 20px;
padding: 5px 25px; padding: 5px 25px;
border: solid 1px #e0e0e0; border: solid 1px #e0e0e0;
} }
/* line 528, ../sass/_systeme_commandes.scss */
/* line 535, ../sass/_systeme_commandes.scss */
.commande-form #bar-fixed .btn-commentaire { .commande-form #bar-fixed .btn-commentaire {
float: left; float: left;
} }
/* line 536, ../sass/_systeme_commandes.scss */
/* line 543, ../sass/_systeme_commandes.scss */
.commande-form #bar-fixed .btn-commentaire { .commande-form #bar-fixed .btn-commentaire {
margin-right: 10px; margin-right: 10px;
} }
/* line 540, ../sass/_systeme_commandes.scss */
/* line 547, ../sass/_systeme_commandes.scss */
.commande-form #bar-fixed #bloc-valider-commande { .commande-form #bar-fixed #bloc-valider-commande {
text-align: right; text-align: right;
margin-top: 20px; margin-top: 20px;
} }
/* line 544, ../sass/_systeme_commandes.scss */
/* line 551, ../sass/_systeme_commandes.scss */
.commande-form #bar-fixed #bloc-valider-commande button { .commande-form #bar-fixed #bloc-valider-commande button {
width: 300px; width: 300px;
margin-right: 10px; margin-right: 10px;
} }
/* line 550, ../sass/_systeme_commandes.scss */
/* line 557, ../sass/_systeme_commandes.scss */
.commande-form #bar-fixed #checkbox-credit-pain { .commande-form #bar-fixed #checkbox-credit-pain {
float: right; float: right;
width: 300px; width: 300px;
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 1px 1px rgba(0, 0, 0, 0.075); -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); 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 { .commande-form #bar-fixed #checkbox-credit-pain.paiement-impossible {
background-color: #e0e0e0; background-color: #e0e0e0;
} }
/* line 565, ../sass/_systeme_commandes.scss */
/* line 572, ../sass/_systeme_commandes.scss */
.commande-form #bar-fixed #checkbox-credit-pain .info { .commande-form #bar-fixed #checkbox-credit-pain .info {
color: gray; color: gray;
font-weight: normal; font-weight: normal;
} }
/* line 570, ../sass/_systeme_commandes.scss */
/* line 577, ../sass/_systeme_commandes.scss */
.commande-form #bar-fixed #checkbox-credit-pain .the-credit { .commande-form #bar-fixed #checkbox-credit-pain .the-credit {
background-color: #BB8757; background-color: #BB8757;
color: white; color: white;
-webkit-border-radius: 5px; -webkit-border-radius: 5px;
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 { .commande-form #bar-fixed #checkbox-credit-pain .montant-paye {
color: #BB8757; 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 { .commande-form #bar-fixed .btn-retour, .commande-form #bar-fixed .annuler-commande {
float: left; float: left;
margin-right: 5px; margin-right: 5px;
} }
/* line 587, ../sass/_systeme_commandes.scss */
/* line 598, ../sass/_systeme_commandes.scss */
.commande-form #bar-fixed .annuler-commande { .commande-form #bar-fixed .annuler-commande {
color: #b92c28; color: #b92c28;
background-color: white; background-color: white;
} }
/* line 592, ../sass/_systeme_commandes.scss */
/* line 603, ../sass/_systeme_commandes.scss */
.commande-form #bar-fixed #total-commande-bottom { .commande-form #bar-fixed #total-commande-bottom {
display: none; display: none;
font-weight: bold; font-weight: bold;
font-family: "comfortaalight"; font-family: "comfortaalight";
font-size: 24px; font-size: 24px;
} }
/* line 599, ../sass/_systeme_commandes.scss */
/* line 610, ../sass/_systeme_commandes.scss */
.commande-form #bar-fixed .field-commande-commentaire { .commande-form #bar-fixed .field-commande-commentaire {
display: none; display: none;
} }


/* line 607, ../sass/_systeme_commandes.scss */
/* line 618, ../sass/_systeme_commandes.scss */
.ui-datepicker .ui-widget-header { .ui-datepicker .ui-widget-header {
background: none; background: none;
background-color: gray; background-color: gray;
color: black; color: black;
font-weight: normal; font-weight: normal;
} }
/* line 615, ../sass/_systeme_commandes.scss */
/* line 626, ../sass/_systeme_commandes.scss */
.ui-datepicker .ui-datepicker-current-day a, .ui-datepicker .ui-datepicker-current-day a,
.ui-datepicker a.ui-state-hover { .ui-datepicker a.ui-state-hover {
background: none; background: none;

+ 11
- 0
frontend/web/sass/_systeme_commandes.scss View File

padding-right: 20px ; padding-right: 20px ;
} }
&.no-credit-pain {
#bloc-valider-commande {
margin-top: 0px ;
float: right ;
}
}
#total-commande-bottom { #total-commande-bottom {
background-color: white ; background-color: white ;
@include border-radius(20px) ; @include border-radius(20px) ;
.montant-paye { .montant-paye {
color: $color1 ; color: $color1 ;
} }
#info-credit-vide {
font-size: 12px ;
}
} }
.btn-retour, .annuler-commande { .btn-retour, .annuler-commande {

Loading…
Cancel
Save