Browse Source

Dépôts : pouvoir activer ou désactiver les Crédits Pain

prodstable
keun 8 years ago
parent
commit
2765625db7
10 changed files with 117 additions and 53 deletions
  1. +10
    -3
      backend/views/point-vente/_form.php
  2. +10
    -0
      backend/views/point-vente/index.php
  3. +3
    -2
      common/models/PointVente.php
  4. +17
    -0
      console/migrations/m161221_101644_champs_point_vente_credit_pain.php
  5. +1
    -1
      frontend/controllers/CommandeController.php
  6. +5
    -2
      frontend/views/commande/_form.php
  7. BIN
      frontend/web/.sass-cache/e1a48ee3204d3a535cdbe440c2995954a615ac19/_systeme_commandes.scssc
  8. +11
    -6
      frontend/web/css/screen.css
  9. +55
    -39
      frontend/web/js/lechatdesnoisettes.js
  10. +5
    -0
      frontend/web/sass/_systeme_commandes.scss

+ 10
- 3
backend/views/point-vente/_form.php View File

<?php $form = ActiveForm::begin(); ?> <?php $form = ActiveForm::begin(); ?>


<div class="col-md-8"> <div class="col-md-8">
<?= $form->field($model, 'point_fabrication')
->checkbox()
->hint('Cochez cette case si ce point de vente correspond à votre lieu de production.') ?>
<?= $form->field($model, 'nom')->textInput(['maxlength' => 255]) ?> <?= $form->field($model, 'nom')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'localite')->textInput(['maxlength' => 255]) ?> <?= $form->field($model, 'localite')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'adresse')->textarea(['rows' => 6]) ?> <?= $form->field($model, 'adresse')->textarea(['rows' => 6]) ?>


<?= $form->field($model, 'point_fabrication')
->checkbox()
->hint('Cochez cette case si ce point de vente correspond à votre lieu de production.') ?>

<?= $form->field($model, 'credit_pain')
->checkbox()
->hint('Cochez cette case si le client peut régler ses commandes via son compte Crédit Pain pour ce point de vente.') ?>

<h2>Horaires</h2> <h2>Horaires</h2>
<div class="alert alert-info">Laisser vide si le point de vente est fermé</div> <div class="alert alert-info">Laisser vide si le point de vente est fermé</div>
<?= $form->field($model, 'horaires_lundi')->textarea(['rows' => 3]) ?> <?= $form->field($model, 'horaires_lundi')->textarea(['rows' => 3]) ?>

+ 10
- 0
backend/views/point-vente/index.php View File

} }
} }
], ],
[
'attribute' => 'credit_pain',
'label' => 'Crédit pain',
'format' => 'raw',
'value' => function($model) {
if($model->credit_pain)
return '<span class="glyphicon glyphicon-euro"></span>' ;
return '' ;
}
],
[ [
'class' => 'yii\grid\ActionColumn', 'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}', 'template' => '{update} {delete}',

+ 3
- 2
common/models/PointVente.php View File

[['acces_restreint'], 'boolean'], [['acces_restreint'], 'boolean'],
[['nom'], 'string', 'max' => 255], [['nom'], 'string', 'max' => 255],
[['adresse','localite','horaires_lundi','horaires_mardi','horaires_mercredi','horaires_jeudi','horaires_vendredi','horaires_samedi','horaires_dimanche'], 'string'], [['adresse','localite','horaires_lundi','horaires_mardi','horaires_mercredi','horaires_jeudi','horaires_vendredi','horaires_samedi','horaires_dimanche'], 'string'],
[['point_fabrication','vrac','pain'], 'boolean'],
[['point_fabrication','vrac','pain', 'credit_pain'], 'boolean'],
['point_fabrication', 'default','value'=>0], ['point_fabrication', 'default','value'=>0],
['id_etablissement','integer'], ['id_etablissement','integer'],
['id_etablissement','required'], ['id_etablissement','required'],
'horaires_dimanche' => 'Dimanche', 'horaires_dimanche' => 'Dimanche',
'vrac' => 'Livraison de vrac', 'vrac' => 'Livraison de vrac',
'pain' => 'Livraison de pain', 'pain' => 'Livraison de pain',
'acces_restreint' => 'Accès restreint'
'acces_restreint' => 'Accès restreint',
'credit_pain' => 'Activer le Crédit Pain'
]; ];
} }

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

<?php

use yii\db\Migration;
use yii\db\Schema;

class m161221_101644_champs_point_vente_credit_pain extends Migration
{
public function up()
{
$this->addColumn('point_vente', 'credit_pain', Schema::TYPE_BOOLEAN) ;
}

public function down()
{
$this->dropColumn('point_vente', 'credit_pain') ;
}
}

+ 1
- 1
frontend/controllers/CommandeController.php View File

// credit pain // credit pain
$credit_pain = isset($posts['credit_pain']) && $posts['credit_pain'] ; $credit_pain = isset($posts['credit_pain']) && $posts['credit_pain'] ;
if($credit_pain)
if($credit_pain && ($pv->credit_pain || $commande->getMontantPaye()))
{ {
$commande = Commande::find() $commande = Commande::find()
->with('commandeProduits') ->with('commandeProduits')

+ 5
- 2
frontend/views/commande/_form.php View File

} }
} }
echo '<li class="bloc point-vente point-vente-' . $pv->id . '" data-vrac="' . (int) $pv->vrac . '" data-pain="' . (int) $pv->pain . '"><div class="contenu">' .
echo '<li class="bloc point-vente point-vente-' . $pv->id . '" data-vrac="' . (int) $pv->vrac . '" data-pain="' . (int) $pv->pain . '" data-credit-pain="'.(int) $pv->credit_pain.'"><div class="contenu">' .
'<span style="display:none;" class="id">' . $pv->id . '</span>' . '<span style="display:none;" class="id">' . $pv->id . '</span>' .
'<div class="nom">' . Html::encode($pv->nom) . '</div>' . '<div class="nom">' . Html::encode($pv->nom) . '</div>' .
'<div class="adresse">à ' . Html::encode($pv->localite) . '</div>' . '<div class="adresse">à ' . Html::encode($pv->localite) . '</div>' .
<?php <?php
if($etablissement->credit_pain): if($etablissement->credit_pain):
$lien_credit_pain = '<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 id="checkbox-credit-pain" > <div id="checkbox-credit-pain" >
<?php if($credit || $model->getMontantPaye()): ?> <?php if($credit || $model->getMontantPaye()): ?>
<?= Html::hiddenInput('str_montant_credit_pain', number_format($credit,2).' €', ['id' => 'str-montant-credit-pain']) ?> <?= Html::hiddenInput('str_montant_credit_pain', number_format($credit,2).' €', ['id' => 'str-montant-credit-pain']) ?>
<?php else: ?> <?php else: ?>
<div id="info-credit-vide"> <div id="info-credit-vide">
Votre compte Crédit Pain est vide <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>
Votre compte Crédit Pain est vide <?= $lien_credit_pain ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<div id="credit-pain-disabled">Le Crédit Pain est désactivé<br /> pour ce point de vente <?= $lien_credit_pain ?></div>
</div> </div>
<div class="clr"></div> <div class="clr"></div>
<?php endif; ?> <?php endif; ?>

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


+ 11
- 6
frontend/web/css/screen.css View File

.commande-form #bar-fixed #checkbox-credit-pain #info-credit-vide { .commande-form #bar-fixed #checkbox-credit-pain #info-credit-vide {
font-size: 12px; font-size: 12px;
} }
/* line 616, ../sass/_systeme_commandes.scss */
/* line 615, ../sass/_systeme_commandes.scss */
.commande-form #bar-fixed #checkbox-credit-pain #credit-pain-disabled {
display: none;
font-size: 12px;
}
/* line 621, ../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 621, ../sass/_systeme_commandes.scss */
/* line 626, ../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 626, ../sass/_systeme_commandes.scss */
/* line 631, ../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 633, ../sass/_systeme_commandes.scss */
/* line 638, ../sass/_systeme_commandes.scss */
.commande-form #bar-fixed .field-commande-commentaire { .commande-form #bar-fixed .field-commande-commentaire {
display: none; display: none;
} }


/* line 641, ../sass/_systeme_commandes.scss */
/* line 646, ../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 649, ../sass/_systeme_commandes.scss */
/* line 654, ../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;

+ 55
- 39
frontend/web/js/lechatdesnoisettes.js View File

$('#produits, .valider-commande, .btn-commentaire, #bar-fixed').fadeIn() ; $('#produits, .valider-commande, .btn-commentaire, #bar-fixed').fadeIn() ;
// credit pain
chat_systeme_commande_credit_pain_event(chat_systeme_commande_maj_table_prix()) ;
// scroll // scroll
if(!force) if(!force)
boulange_scroll('step-choix-produits') ; boulange_scroll('step-choix-produits') ;
if($('#id-commande').size() && $('#id-commande').val()) { if($('#id-commande').size() && $('#id-commande').val()) {
credit_pain_dispo = credit_pain + montant_paye ; credit_pain_dispo = credit_pain + montant_paye ;
} }
if(prix_global > credit_pain_dispo) {
var reste_payer = prix_global - credit_pain_dispo ;
if(use_credit_pain) {
if(montant_paye) {
html += '<span class="montant-paye">'+montant_paye+' € déjà payé</span><br />' ;
}
html += '<strong>'+credit_pain+' €</strong> seront débités<br />' ;
html += 'Restera <strong>'+reste_payer+' €</strong> à payer à la boulangerie' ;
$('#checkbox-credit-pain .info').html(html) ;
}
else {
$('#checkbox-credit-pain .info').html('') ;
}
}
else {
var credit_pain_active = $('.point-vente.selected').data('credit-pain') ;
if(credit_pain_active || montant_paye) {
$('#checkbox-credit-pain #info-credit-vide').show() ;
$('#checkbox-credit-pain label').show() ;
$('#checkbox-credit-pain #credit-pain-disabled').hide() ;
$('#checkbox-credit-pain').removeClass('paiement-impossible') ;
$('input[name=credit_pain]').removeAttr('disabled') ;
if(use_credit_pain) {
var html = '' ;
// à payer
if(prix_global > montant_paye)
{
montant = prix_global - montant_paye ;
if(prix_global > credit_pain_dispo) {
var reste_payer = prix_global - credit_pain_dispo ;
if(use_credit_pain) {
if(montant_paye) { if(montant_paye) {
html += '<span class="montant-paye">'+montant_paye+' € déjà payé</span><br />' ; html += '<span class="montant-paye">'+montant_paye+' € déjà payé</span><br />' ;
} }
html += '<strong>'+montant+' €</strong> seront débités' ;
$('#checkbox-credit-pain .info').html(html) ;
}
// remboursé
else if(prix_global < montant_paye) {
montant = montant_paye - prix_global ;
if(montant_paye) {
html += '<span class="montant-paye">'+montant_paye+' € déjà payé</span><br />' ;
}
html += '<strong>'+montant+' €</strong> seront remboursés' ;
html += '<strong>'+credit_pain+' €</strong> seront débités<br />' ;
html += 'Restera <strong>'+reste_payer+' €</strong> à payer à la boulangerie' ;
$('#checkbox-credit-pain .info').html(html) ; $('#checkbox-credit-pain .info').html(html) ;
} }
else { else {
if(montant_paye > 0)
$('#checkbox-credit-pain .info').html('<span class="montant-paye">'+montant_paye+' € déjà payé</span>') ;
else
$('#checkbox-credit-pain .info').html('') ;
$('#checkbox-credit-pain .info').html('') ;
} }
} }
else { else {
$('#checkbox-credit-pain .info').html('')

$('#checkbox-credit-pain').removeClass('paiement-impossible') ;
$('input[name=credit_pain]').removeAttr('disabled') ;
if(use_credit_pain) {
var html = '' ;
// à payer
if(prix_global > montant_paye)
{
montant = prix_global - montant_paye ;
if(montant_paye) {
html += '<span class="montant-paye">'+montant_paye+' € déjà payé</span><br />' ;
}
html += '<strong>'+montant+' €</strong> seront débités' ;
$('#checkbox-credit-pain .info').html(html) ;
}
// remboursé
else if(prix_global < montant_paye) {
montant = montant_paye - prix_global ;
if(montant_paye) {
html += '<span class="montant-paye">'+montant_paye+' € déjà payé</span><br />' ;
}
html += '<strong>'+montant+' €</strong> seront remboursés' ;
$('#checkbox-credit-pain .info').html(html) ;

}
else {
if(montant_paye > 0)
$('#checkbox-credit-pain .info').html('<span class="montant-paye">'+montant_paye+' € déjà payé</span>') ;
else
$('#checkbox-credit-pain .info').html('') ;
}
}
else {
$('#checkbox-credit-pain .info').html('')
}
} }
} }
else {
$('#checkbox-credit-pain #info-credit-vide').hide() ;
$('#checkbox-credit-pain label').hide() ;
$('#checkbox-credit-pain #credit-pain-disabled').show() ;
}
} }


function formate_prix(prix) { function formate_prix(prix) {

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

#info-credit-vide { #info-credit-vide {
font-size: 12px ; font-size: 12px ;
} }
#credit-pain-disabled {
display: none ;
font-size: 12px ;
}
} }
.btn-retour, .annuler-commande { .btn-retour, .annuler-commande {

Loading…
Cancel
Save