@@ -14,13 +14,20 @@ use yii\helpers\ArrayHelper ; | |||
<?php $form = ActiveForm::begin(); ?> | |||
<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, 'localite')->textInput(['maxlength' => 255]) ?> | |||
<?= $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> | |||
<div class="alert alert-info">Laisser vide si le point de vente est fermé</div> | |||
<?= $form->field($model, 'horaires_lundi')->textarea(['rows' => 3]) ?> |
@@ -55,6 +55,16 @@ $this->params['breadcrumbs'][] = $this->title; | |||
} | |||
} | |||
], | |||
[ | |||
'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', | |||
'template' => '{update} {delete}', |
@@ -44,7 +44,7 @@ class PointVente extends \yii\db\ActiveRecord | |||
[['acces_restreint'], 'boolean'], | |||
[['nom'], 'string', 'max' => 255], | |||
[['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], | |||
['id_etablissement','integer'], | |||
['id_etablissement','required'], | |||
@@ -72,7 +72,8 @@ class PointVente extends \yii\db\ActiveRecord | |||
'horaires_dimanche' => 'Dimanche', | |||
'vrac' => 'Livraison de vrac', | |||
'pain' => 'Livraison de pain', | |||
'acces_restreint' => 'Accès restreint' | |||
'acces_restreint' => 'Accès restreint', | |||
'credit_pain' => 'Activer le Crédit Pain' | |||
]; | |||
} | |||
@@ -0,0 +1,17 @@ | |||
<?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') ; | |||
} | |||
} |
@@ -368,7 +368,7 @@ class CommandeController extends \yii\web\Controller { | |||
// 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() | |||
->with('commandeProduits') |
@@ -99,7 +99,7 @@ use common\models\Etablissement; | |||
} | |||
} | |||
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>' . | |||
'<div class="nom">' . Html::encode($pv->nom) . '</div>' . | |||
'<div class="adresse">à ' . Html::encode($pv->localite) . '</div>' . | |||
@@ -211,6 +211,8 @@ use common\models\Etablissement; | |||
<?php | |||
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" > | |||
<?php if($credit || $model->getMontantPaye()): ?> | |||
@@ -219,9 +221,10 @@ use common\models\Etablissement; | |||
<?= 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 <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> | |||
<?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 class="clr"></div> | |||
<?php endif; ?> |
@@ -1144,29 +1144,34 @@ h2 { | |||
.commande-form #bar-fixed #checkbox-credit-pain #info-credit-vide { | |||
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 { | |||
float: left; | |||
margin-right: 5px; | |||
} | |||
/* line 621, ../sass/_systeme_commandes.scss */ | |||
/* line 626, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed .annuler-commande { | |||
color: #b92c28; | |||
background-color: white; | |||
} | |||
/* line 626, ../sass/_systeme_commandes.scss */ | |||
/* line 631, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed #total-commande-bottom { | |||
display: none; | |||
font-weight: bold; | |||
font-family: "comfortaalight"; | |||
font-size: 24px; | |||
} | |||
/* line 633, ../sass/_systeme_commandes.scss */ | |||
/* line 638, ../sass/_systeme_commandes.scss */ | |||
.commande-form #bar-fixed .field-commande-commentaire { | |||
display: none; | |||
} | |||
/* line 641, ../sass/_systeme_commandes.scss */ | |||
/* line 646, ../sass/_systeme_commandes.scss */ | |||
.ui-datepicker .ui-widget-header { | |||
background: none; | |||
background-color: gray; | |||
@@ -1174,7 +1179,7 @@ h2 { | |||
color: black; | |||
font-weight: normal; | |||
} | |||
/* line 649, ../sass/_systeme_commandes.scss */ | |||
/* line 654, ../sass/_systeme_commandes.scss */ | |||
.ui-datepicker .ui-datepicker-current-day a, | |||
.ui-datepicker a.ui-state-hover { | |||
background: none; |
@@ -94,6 +94,9 @@ function chat_event_click_point_vente(id, force) { | |||
$('#produits, .valider-commande, .btn-commentaire, #bar-fixed').fadeIn() ; | |||
// credit pain | |||
chat_systeme_commande_credit_pain_event(chat_systeme_commande_maj_table_prix()) ; | |||
// scroll | |||
if(!force) | |||
boulange_scroll('step-choix-produits') ; | |||
@@ -479,57 +482,70 @@ function chat_systeme_commande_credit_pain_event(prix_global) { | |||
if($('#id-commande').size() && $('#id-commande').val()) { | |||
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) { | |||
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) ; | |||
} | |||
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 { | |||
$('#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) { |
@@ -611,6 +611,11 @@ h2 { | |||
#info-credit-vide { | |||
font-size: 12px ; | |||
} | |||
#credit-pain-disabled { | |||
display: none ; | |||
font-size: 12px ; | |||
} | |||
} | |||
.btn-retour, .annuler-commande { |