Sfoglia il codice sorgente

Système de paiement

Finalisation de la page de paiement (ajout d'informations pour le boulanger).
Finalisation de l'ajout d'infos dans le header relatives à l'abonnement (période d'essai, retard de paiement). En passant, amélioration graphique du header.

Sur le frontend, suppression de la boulangerie si elle n'est pas à jour au niveau du paiement.
master
keun 8 anni fa
parent
commit
5db4b31661
13 ha cambiato i file con 271 aggiunte e 105 eliminazioni
  1. +10
    -5
      backend/views/layouts/main.php
  2. +29
    -3
      backend/views/paiement/index.php
  3. BIN
      backend/web/.sass-cache/c8fef7d48da4dc7f024edc2b0fada9d8d6de5dac/screen.scssc
  4. +108
    -63
      backend/web/css/screen.css
  5. BIN
      backend/web/img/laboulange3.png
  6. +45
    -4
      backend/web/sass/screen.scss
  7. +38
    -8
      common/models/Etablissement.php
  8. +16
    -17
      common/models/User.php
  9. +12
    -1
      frontend/controllers/CommandeController.php
  10. +5
    -4
      frontend/views/commande/_form.php
  11. +6
    -0
      frontend/views/commande/_liste_etablissements.php
  12. +1
    -0
      frontend/views/commande/create.php
  13. +1
    -0
      frontend/views/commande/update.php

+ 10
- 5
backend/views/layouts/main.php Vedi File

@@ -4,6 +4,7 @@ use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use common\models\Etablissement ;

/* @var $this \yii\web\View */
/* @var $content string */
@@ -18,7 +19,7 @@ AppAsset::register($this);
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/favicon3.png" />
<?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?> - Réservation de pain</title>
<title><?= Html::encode($this->title) ?> - La boîte à pain</title>
<?php $this->head() ?>
</head>
<body>
@@ -26,7 +27,7 @@ AppAsset::register($this);
<div class="wrap">
<?php
NavBar::begin([
'brandLabel' => '<img class="logo" src="'.Yii::$app->urlManager->getBaseUrl().'/img/laboulange2.png" />',
'brandLabel' => '<img class="logo" src="'.Yii::$app->urlManager->getBaseUrl().'/img/laboulange3.png" />',
'brandUrl' => Yii::$app->homeUrl,
'innerContainerOptions' => ['class'=>'container-fluid'],
'options' => [
@@ -77,11 +78,15 @@ AppAsset::register($this);
<?php $etat_paiement_etablissement = Yii::$app->user->identity->etatPaiementEtablissement(); ?>
<?php if($etat_paiement_etablissement == 'essai'): ?>
<span id="etat-paiement-etablissement">Période d'essai gratuite
<span class="strong"><?php echo Yii::$app->user->identity->periodeEssai(); ?> jours</span>
<span class="strong"><?php echo Yii::$app->user->identity->periodeEssai(); ?> jours</span> <a class="btn btn-success" href="<?php echo Yii::$app->urlManager->createUrl(['paiement/index']) ?>">S'abonner</a>
</span>
<?php elseif($etat_paiement_etablissement == 'essai-terminee'): ?>
<?php elseif($etat_paiement_etablissement == Etablissement::PAIEMENT_ESSAI_TERMINE || $etat_paiement_etablissement == Etablissement::PAIEMENT_RETARD): ?>
<span id="etat-paiement-etablissement">
<span class="strong">Période d'essai gratuite terminée</span>
<span class="strong">
<?php if($etat_paiement_etablissement == Etablissement::PAIEMENT_ESSAI_TERMINE): ?>Période d'essai gratuite terminée
<?php elseif($etat_paiement_etablissement == Etablissement::PAIEMENT_RETARD): ?>Retard de paiement
<?php endif; ?>
</span>
</span>
<?php endif; ?>
</div>

+ 29
- 3
backend/views/paiement/index.php Vedi File

@@ -1,25 +1,50 @@
<?php

use yii ;
use common\models\Etablissement ;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

$this->title = 'Paiement';

$etat_paiement = Yii::$app->user->identity->etatPaiementEtablissement() ;

?>

<h1>Paiement</h1>

<h2>Prod</h2>
<div class="alert alert-warning">
<?php if($etat_paiement == Etablissement::PAIEMENT_ESSAI_TERMINE): ?>
Votre période d'essai gratuite est terminée.<br />
Vous pouvez continuer à bénéficier de ce service en vous abonnant à <strong>La boîte à pain</strong>
pour <strong>30 € / mois</strong>
<?php elseif($etat_paiement == Etablissement::PAIEMENT_RETARD): ?>
Nous constatons un retard de paiement sur votre compte.<br />
Nous vous invitons à vérifier que tout est en ordre au niveau de votre compte Paypal ou à vous
abonner à nouveau en utilisant le bouton ci-dessous (<strong>30 € / mois</strong>).
<?php elseif($etat_paiement == Etablissement::PAIEMENT_ESSAI): ?>
Si vous souhaitez profiter de ce service au-delà de la période d'essai gratuite,
abonnez-vous à <strong>La boîte à pain</strong> pour <strong>30 € / mois</strong>.
<?php endif; ?>
</div>
<div class="alert alert-info">Si vous rencontrez des difficultés, n'hésitez pas à nous contacter.</div>


<!--<h2>Prod</h2>
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="K96K2WLBSBDSA">
<input name="custom" value="<?php echo Yii::$app->user->identity->id; ?>" type="hidden" />
<input type="image" src="https://www.paypalobjects.com/fr_FR/FR/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal, le réflexe sécurité pour payer en ligne">
<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
</form>
</form>-->

<h2>Test</h2>
<!--<h2>Test</h2>-->
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="USASPWAC39S4N">
@@ -27,3 +52,4 @@
<input type="image" src="https://www.sandbox.paypal.com/fr_FR/FR/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal, le réflexe sécurité pour payer en ligne">
<img alt="" border="0" src="https://www.sandbox.paypal.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
</form>


BIN
backend/web/.sass-cache/c8fef7d48da4dc7f024edc2b0fada9d8d6de5dac/screen.scssc Vedi File


+ 108
- 63
backend/web/css/screen.css Vedi File

@@ -48,7 +48,7 @@ a:hover, a:focus, a:active {

/* line 48, ../sass/screen.scss */
.nav-header .retour-site {
border-left: solid 1px #9d9d9d;
border-left: solid 1px #F8F1DD;
padding: 10px 15px;
}

@@ -66,6 +66,39 @@ a:hover, a:focus, a:active {
}

/* line 67, ../sass/screen.scss */
.navbar-inverse {
background-color: #BB8757;
border-bottom: 0px none;
}
/* line 71, ../sass/screen.scss */
.navbar-inverse .navbar-nav {
padding-top: 12px;
}
/* line 75, ../sass/screen.scss */
.navbar-inverse .navbar-nav > li > a {
color: white;
padding: 3px 14px;
}
/* line 79, ../sass/screen.scss */
.navbar-inverse .navbar-nav > li > a:hover {
color: #F8F1DD;
}
/* line 85, ../sass/screen.scss */
.navbar-inverse .navbar-nav > li.active a {
background-color: #F8F1DD;
color: #BB8757;
padding: 3px 14px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
/* line 91, ../sass/screen.scss */
.navbar-inverse .navbar-nav > li.active a:hover {
background-color: #BB8757;
color: #BB8757;
}

/* line 99, ../sass/screen.scss */
.nom-boulange {
margin-bottom: 15px;
text-align: left;
@@ -73,19 +106,27 @@ a:hover, a:focus, a:active {
top: 51px;
left: 0px;
width: 100%;
background-color: #BB8757;
color: white;
background-color: #515151;
background-color: #F8F1DD;
color: #8d6139;
z-index: 100;
font-size: 20px;
padding: 8px 15px;
padding-bottom: 2px;
padding-top: 5px;
border-bottom: solid 1px #e0e0e0;
-moz-box-shadow: 0px 0px 5px gray;
-webkit-box-shadow: 0px 0px 5px gray;
box-shadow: 0px 0px 5px gray;
}
/* line 81, ../sass/screen.scss */
/* line 118, ../sass/screen.scss */
.nom-boulange #etat-paiement-etablissement {
float: right;
text-align: right;
color: #F8F1DD;
color: #8d6139;
font-size: 16px;
}
/* line 85, ../sass/screen.scss */
/* line 123, ../sass/screen.scss */
.nom-boulange #etat-paiement-etablissement .strong {
background-color: white;
color: #BB8757;
@@ -94,151 +135,155 @@ a:hover, a:focus, a:active {
border-radius: 10px;
padding: 0px 10px;
}
/* line 129, ../sass/screen.scss */
.nom-boulange #etat-paiement-etablissement .btn {
padding: 2px 5px;
}

/* line 96, ../sass/screen.scss */
/* line 137, ../sass/screen.scss */
.table thead th.actions {
width: 220px;
}
/* line 99, ../sass/screen.scss */
/* line 140, ../sass/screen.scss */
.table thead th.order {
width: 58px;
}
/* line 102, ../sass/screen.scss */
/* line 143, ../sass/screen.scss */
.table thead th.actif {
width: 75px;
text-align: center;
}
/* line 108, ../sass/screen.scss */
/* line 149, ../sass/screen.scss */
.table tbody td.center {
text-align: center;
}

/* line 121, ../sass/screen.scss */
/* line 162, ../sass/screen.scss */
#page-commande h1 .btn-group {
float: right;
}
/* line 126, ../sass/screen.scss */
/* line 167, ../sass/screen.scss */
#page-commande #jours-production {
display: none;
}
/* line 132, ../sass/screen.scss */
/* line 173, ../sass/screen.scss */
#page-commande #calendar h2 {
font-size: 20px;
position: relative;
top: 3px;
}
/* line 138, ../sass/screen.scss */
/* line 179, ../sass/screen.scss */
#page-commande #calendar .fc-header-title {
margin-left: 10px;
}
/* line 144, ../sass/screen.scss */
/* line 185, ../sass/screen.scss */
#page-commande #calendar .dayWithEvent {
background-color: #fee48d;
cursor: pointer;
}
/* line 148, ../sass/screen.scss */
/* line 189, ../sass/screen.scss */
#page-commande #calendar .fc-event-container {
display: none;
}
/* line 149, ../sass/screen.scss */
/* line 190, ../sass/screen.scss */
#page-commande #calendar .fc-today {
border-bottom: solid 1px #C9302C;
background-color: white;
}
/* line 153, ../sass/screen.scss */
/* line 194, ../sass/screen.scss */
#page-commande #calendar .fc-today.dayWithEvent {
background-color: #fee48d;
}
/* line 158, ../sass/screen.scss */
/* line 199, ../sass/screen.scss */
#page-commande #calendar .fc-day {
cursor: pointer;
text-align: center;
}
/* line 161, ../sass/screen.scss */
/* line 202, ../sass/screen.scss */
#page-commande #calendar .fc-day:hover {
-moz-box-shadow: 0px 0px 2px black inset;
-webkit-box-shadow: 0px 0px 2px black inset;
box-shadow: 0px 0px 2px black inset;
}
/* line 166, ../sass/screen.scss */
/* line 207, ../sass/screen.scss */
#page-commande #calendar .current-date {
-moz-box-shadow: 0px 0px 2px black inset;
-webkit-box-shadow: 0px 0px 2px black inset;
box-shadow: 0px 0px 2px black inset;
}
/* line 170, ../sass/screen.scss */
/* line 211, ../sass/screen.scss */
#page-commande #calendar .fc-day-number {
float: none;
padding-top: 2px;
}
/* line 182, ../sass/screen.scss */
/* line 223, ../sass/screen.scss */
#page-commande #produits-production .overflow table {
width: 100%;
}
/* line 186, ../sass/screen.scss */
/* line 227, ../sass/screen.scss */
#page-commande #produits-production .overflow thead, #page-commande #produits-production .overflow tbody, #page-commande #produits-production .overflow tr, #page-commande #produits-production .overflow td, #page-commande #produits-production .overflow th {
display: block;
}
/* line 188, ../sass/screen.scss */
/* line 229, ../sass/screen.scss */
#page-commande #produits-production .overflow tr:after {
content: ' ';
display: block;
visibility: hidden;
clear: both;
}
/* line 195, ../sass/screen.scss */
/* line 236, ../sass/screen.scss */
#page-commande #produits-production .overflow thead th {
height: 30px;
/*text-align: left;*/
}
/* line 201, ../sass/screen.scss */
/* line 242, ../sass/screen.scss */
#page-commande #produits-production .overflow tbody {
height: 200px;
overflow-y: auto;
}
/* line 209, ../sass/screen.scss */
/* line 250, ../sass/screen.scss */
#page-commande #produits-production .overflow thead th {
width: 32%;
float: left;
}
/* line 214, ../sass/screen.scss */
/* line 255, ../sass/screen.scss */
#page-commande #produits-production .overflow tbody td {
width: 33%;
float: left;
}
/* line 219, ../sass/screen.scss */
/* line 260, ../sass/screen.scss */
#page-commande #produits-production .overflow .td-produit {
width: 60%;
}
/* line 222, ../sass/screen.scss */
/* line 263, ../sass/screen.scss */
#page-commande #produits-production .overflow .td-actif, #page-commande #produits-production .overflow .td-max {
width: 20%;
text-align: center;
}
/* line 228, ../sass/screen.scss */
/* line 269, ../sass/screen.scss */
#page-commande #produits-production .overflow thead .td-produit {
width: 57%;
}
/* line 234, ../sass/screen.scss */
/* line 275, ../sass/screen.scss */
#page-commande #produits-production input.quantite-max {
background-color: white;
border: 1px solid #e0e0e0;
text-align: center;
width: 50px;
}
/* line 242, ../sass/screen.scss */
/* line 283, ../sass/screen.scss */
#page-commande #produits-production td label {
font-weight: normal;
}
/* line 248, ../sass/screen.scss */
/* line 289, ../sass/screen.scss */
#page-commande .form-commandes-point-vente {
margin-top: 20px;
}
/* line 252, ../sass/screen.scss */
/* line 293, ../sass/screen.scss */
#page-commande .form-commandes-point-vente table {
border-bottom: solid 1px #e0e0e0;
}
/* line 256, ../sass/screen.scss */
/* line 297, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .title-point-vente {
background-color: #fff8e2;
border-left: solid 3px #BB8757;
@@ -246,76 +291,76 @@ a:hover, a:focus, a:active {
text-align: left;
padding: 10px;
}
/* line 264, ../sass/screen.scss */
/* line 305, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .title-totaux {
text-align: center;
}
/* line 268, ../sass/screen.scss */
/* line 309, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .border-left {
border-left: solid 1px #e0e0e0;
}
/* line 272, ../sass/screen.scss */
/* line 313, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .border-right {
border-right: solid 1px #e0e0e0;
}
/* line 276, ../sass/screen.scss */
/* line 317, ../sass/screen.scss */
#page-commande .form-commandes-point-vente input.quantite {
width: 30px;
background-color: white;
border: solid 1px #e0e0e0;
text-align: center;
}
/* line 284, ../sass/screen.scss */
/* line 325, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .td-produit {
text-align: center;
}
/* line 288, ../sass/screen.scss */
/* line 329, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .submit-pv {
float: right;
}
/* line 292, ../sass/screen.scss */
/* line 333, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .select-user {
background-color: #F9F9F9;
border: solid 1px #e0e0e0;
}
/* line 297, ../sass/screen.scss */
/* line 338, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .date-commande {
font-size: 12px;
}
/* line 301, ../sass/screen.scss */
/* line 342, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .datepicker, #page-commande .form-commandes-point-vente .text {
background-color: white;
border: solid 1px #e0e0e0;
margin-top: 3px;
width: 100px;
}
/* line 309, ../sass/screen.scss */
/* line 350, ../sass/screen.scss */
#page-commande .form-commandes-point-vente td.center {
text-align: center;
}
/* line 315, ../sass/screen.scss */
/* line 356, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .depasse {
color: #b32815;
}
/* line 319, ../sass/screen.scss */
/* line 360, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .total strong span {
font-weight: normal;
font-size: 13px;
}
/* line 324, ../sass/screen.scss */
/* line 365, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .vrac {
display: none;
}
/* line 328, ../sass/screen.scss */
/* line 369, ../sass/screen.scss */
#page-commande .form-commandes-point-vente td.client {
text-align: left;
padding: 3px;
}
/* line 331, ../sass/screen.scss */
/* line 372, ../sass/screen.scss */
#page-commande .form-commandes-point-vente td.client .date-commande {
color: gray;
}
/* line 342, ../sass/screen.scss */
/* line 383, ../sass/screen.scss */
#page-commande .table-header-rotated td {
width: 20px;
padding: 0px;
@@ -325,7 +370,7 @@ a:hover, a:focus, a:active {
vertical-align: middle;
text-align: center;
}
/* line 352, ../sass/screen.scss */
/* line 393, ../sass/screen.scss */
#page-commande .table-header-rotated th.rotate-45 {
height: 80px;
width: 20px;
@@ -337,7 +382,7 @@ a:hover, a:focus, a:active {
font-size: 12px;
line-height: 0.8;
}
/* line 364, ../sass/screen.scss */
/* line 405, ../sass/screen.scss */
#page-commande .table-header-rotated th.rotate-45 > div {
position: relative;
top: 0px;
@@ -354,7 +399,7 @@ a:hover, a:focus, a:active {
border-right: 1px solid #dddddd;
border-top: 1px solid #dddddd;
}
/* line 380, ../sass/screen.scss */
/* line 421, ../sass/screen.scss */
#page-commande .table-header-rotated th.rotate-45 span {
-ms-transform: skew(45deg, 0deg) rotate(315deg);
-moz-transform: skew(45deg, 0deg) rotate(315deg);
@@ -377,35 +422,35 @@ a:hover, a:focus, a:active {
/*whether to display in one line or not*/
}

/* line 405, ../sass/screen.scss */
/* line 446, ../sass/screen.scss */
#email-masse-form #ids-users {
line-height: 30px;
}
/* line 407, ../sass/screen.scss */
/* line 448, ../sass/screen.scss */
#email-masse-form #ids-users .label {
text-transform: capitalize;
}

/* line 415, ../sass/screen.scss */
/* line 456, ../sass/screen.scss */
.produit-create #jours-production .form-group {
float: left;
margin-right: 15px;
}
/* line 419, ../sass/screen.scss */
/* line 460, ../sass/screen.scss */
.produit-create #jours-production .form-group label {
font-weight: normal;
}
/* line 424, ../sass/screen.scss */
/* line 465, ../sass/screen.scss */
.produit-create .field-produit-id_etablissement {
display: none;
}

/* line 430, ../sass/screen.scss */
/* line 471, ../sass/screen.scss */
.produit-index .td-photo {
max-width: 100px;
width: 100px;
}
/* line 434, ../sass/screen.scss */
/* line 475, ../sass/screen.scss */
.produit-index .photo-produit {
max-width: 100px;
}

BIN
backend/web/img/laboulange3.png Vedi File

Before After
Width: 200  |  Height: 199  |  Size: 1.7KB

+ 45
- 4
backend/web/sass/screen.scss Vedi File

@@ -46,7 +46,7 @@ a {

.nav-header {
.retour-site {
border-left : solid 1px #9d9d9d ;
border-left : solid 1px $color2 ;
padding: 10px 15px ;
}
}
@@ -64,6 +64,38 @@ a {
padding-bottom: 50px ;
}

.navbar-inverse {
background-color: $color1 ;
border-bottom: 0px none ;
.navbar-nav {
padding-top: 12px ;
}
.navbar-nav > li > a {
color: white ;
padding: 3px 14px ;
&:hover {
color: $color2 ;
}
}
.navbar-nav > li.active {
a {
background-color: $color2 ;
color: $color1 ;
padding: 3px 14px ;
@include border-radius(10px) ;
&:hover {
background-color: $color1 ;
color: $color1 ;
}
}
}
}

.nom-boulange {
//font-family: 'Georgia' ;
margin-bottom: 15px ;
@@ -72,22 +104,31 @@ a {
top: 51px ;
left: 0px ;
width: 100% ;
background-color: $color1 ;
color: white ;
background-color: #515151 ;
background-color: $color2 ;
color: darken($color1,15) ;
z-index: 100 ;
font-size: 20px ;
padding: 8px 15px ;
padding-bottom: 2px ;
padding-top: 5px ;
border-bottom: solid 1px #e0e0e0 ;
@include box-shadow(0px 0px 5px gray) ;
#etat-paiement-etablissement {
float: right ;
text-align: right ;
color: $color2;
color: darken($color1,15) ;
font-size: 16px ;
.strong {
background-color: white ;
color: $color1 ;
@include border-radius(10px) ;
padding: 0px 10px ;
}
.btn {
padding: 2px 5px ;
}
}
}


+ 38
- 8
common/models/Etablissement.php Vedi File

@@ -20,6 +20,11 @@ use yii\helpers\Html ;
*/
class Etablissement extends \yii\db\ActiveRecord
{
const PAIEMENT_OK = 'ok' ;
const PAIEMENT_ESSAI = 'essai' ;
const PAIEMENT_ESSAI_TERMINE = 'essai-terminee' ;
const PAIEMENT_RETARD = 'retard-paiement' ;
/**
* @inheritdoc
*/
@@ -69,18 +74,43 @@ class Etablissement extends \yii\db\ActiveRecord
$options_etablissements_dispos = [] ;
foreach($etablissements_dispos as $e)
{
if(!key_exists('d'. substr($e['code_postal'], 0, 2), $data_etablissements_dispos))
if($e->etatPaiement() == self::PAIEMENT_OK || $e->etatPaiement() == self::PAIEMENT_ESSAI)
{
$data_etablissements_dispos['d'. substr($e['code_postal'], 0, 2)] = '<strong>'.$departements[substr($e['code_postal'], 0, 2)].'</strong>' ;
$options_etablissements_dispos['d'. substr($e['code_postal'], 0, 2)] = ['disabled' => true] ;
if(!key_exists('d'. substr($e->code_postal, 0, 2), $data_etablissements_dispos))
{
$data_etablissements_dispos['d'. substr($e->code_postal, 0, 2)] = '<strong>'.$departements[substr($e->code_postal, 0, 2)].'</strong>' ;
$options_etablissements_dispos['d'. substr($e->code_postal, 0, 2)] = ['disabled' => true] ;
}

$data_etablissements_dispos[$e->id] = Html::encode($e->nom).' - '.Html::encode($e->code_postal).' '.Html::encode($e->ville) ;

}
$data_etablissements_dispos[$e['id']] = Html::encode($e['nom']).' - '.Html::encode($e['code_postal']).' '.Html::encode($e['ville']) ;
}
return ['data' => $data_etablissements_dispos, 'options' => $options_etablissements_dispos] ;
}
public function etatPaiement()
{
$date_limite = strtotime($this->date_creation) + 30*24*60*60 ;
$date = time() ;
$date_paiement = strtotime($this->date_paiement) ;

if($date < $date_paiement + 30*24*60*60 || $this->gratuit)
{
return 'ok' ;
}
else {
if($date < $date_limite)
{
return 'essai' ;
}
else {
if(!$this->date_paiement)
return 'essai-terminee' ;
else
return 'retard-paiement' ;
}
}
}
}

+ 16
- 17
common/models/User.php Vedi File

@@ -240,12 +240,25 @@ class User extends ActiveRecord implements IdentityInterface
public function getEtablissementsFavoris()
{
return (new \yii\db\Query())
$etabs = (new \yii\db\Query())
->select('*')
->from(['user_etablissement', 'etablissement'])
->where('user_etablissement.id_etablissement = etablissement.id')
->andWhere(['user_etablissement.id_user' => $this->id])
->all();
$arr_etabs = array() ;
foreach($etabs as $e)
{
$etablissement = Etablissement::findOne($e['id_etablissement']) ;
if($etablissement->etatPaiement() == Etablissement::PAIEMENT_OK || $etablissement->etatPaiement() == Etablissement::PAIEMENT_ESSAI)
{
$arr_etabs[] = $e ;
}
}
return $arr_etabs ;
}
public function etatPaiementEtablissement()
@@ -254,23 +267,9 @@ class User extends ActiveRecord implements IdentityInterface
if($etablissement)
{
$date_limite = strtotime($etablissement->date_creation) + 30*24*60*60 ;
$date = time() ;
$date_paiement = strtotime($etablissement->date_paiement) ;
return $etablissement->etatPaiement() ;
if($date < $date_paiement + 30*24*60*60 || $etablissement->gratuit)
{
return 'ok' ;
}
else {
if($date < $date_limite)
{
return 'essai' ;
}
else {
return 'essai-terminee' ;
}
}
}
}

+ 12
- 1
frontend/controllers/CommandeController.php Vedi File

@@ -55,6 +55,16 @@ class CommandeController extends \yii\web\Controller {
$etablissements = Yii::$app->user->identity->getEtablissementsFavoris() ;
$id_etablissement = Yii::$app->request->get('id_etablissement', 0) ;
$etablissement_paiement_ok = false ;
if($id_etablissement)
{
$etablissement = Etablissement::findOne($id_etablissement);
if($etablissement->etatPaiement() == Etablissement::PAIEMENT_OK || $etablissement->etatPaiement() == Etablissement::PAIEMENT_ESSAI)
{
$etablissement_paiement_ok = true ;
}
}
// points de vente
$points_vente = PointVente::find()
->where(['id_etablissement'=>$id_etablissement])
@@ -131,6 +141,7 @@ class CommandeController extends \yii\web\Controller {
'produits_vrac' => $produits_vrac,
'etablissements' => $etablissements,
'id_etablissement' => $id_etablissement,
'etablissement_paiement_ok' => $etablissement_paiement_ok,
];
}

@@ -146,7 +157,7 @@ class CommandeController extends \yii\web\Controller {
// liste des etablissements
$etablissements = Yii::$app->user->identity->getEtablissementsFavoris();
// liste des boulangeries disponibles
$arr_etablissements = Etablissement::getEtablissementsPopulateDropdown() ;
$data_etablissements_dispos = $arr_etablissements['data'] ;

+ 5
- 4
frontend/views/commande/_form.php Vedi File

@@ -16,7 +16,8 @@ use yii\widgets\ActiveForm;
$this->render('_liste_etablissements.php',[
'etablissements' => $etablissements,
'context' => 'commande',
'id_etablissement' => $id_etablissement
'id_etablissement' => $id_etablissement,
'etablissement_paiement_ok' => $etablissement_paiement_ok,
]) ;
?>
<div class="clr"></div>
@@ -30,7 +31,7 @@ use yii\widgets\ActiveForm;
]);
?>
<?php if($id_etablissement): ?>
<?php if($id_etablissement && $etablissement_paiement_ok): ?>
<h2 id="step-choix-date">Date de commande</h2>

@@ -196,8 +197,8 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'commentaire')->textarea(['rows' => 3, 'placeholder' => 'Un commentaire ?'])->label(''); ?>
</div>
</div>
<?php
<?php
// id_etablissement
endif; ?>

+ 6
- 0
frontend/views/commande/_liste_etablissements.php Vedi File

@@ -5,6 +5,12 @@ use yii\helpers\Html ;
?>
<div class="liste-etablissements">
<?php if(count($etablissements)): ?>
<?php if(isset($id_etablissement) && $id_etablissement &&
isset($etablissement_paiement_ok) && !$etablissement_paiement_ok): ?>
<div class="alert alert-warning">Cette boulangerie est désactivée.</div>
<?php endif; ?>
<?php foreach($etablissements as $e): ?>
<div class="col-md-6 boulangerie <?php if(isset($id_etablissement) && $e['id'] == $id_etablissement): ?>selected<?php endif; ?>">
<div class="panel panel-default">

+ 1
- 0
frontend/views/commande/create.php Vedi File

@@ -24,6 +24,7 @@ $this->title = 'Passer une commande';
'produits_vrac' => $produits_vrac,
'etablissements' => $etablissements,
'id_etablissement' => $id_etablissement,
'etablissement_paiement_ok' => $etablissement_paiement_ok,
]) ?>

</div>

+ 1
- 0
frontend/views/commande/update.php Vedi File

@@ -31,6 +31,7 @@ $this->title = 'Modifier une commande';
'produits_vrac' => $produits_vrac,
'etablissements' => $etablissements,
'id_etablissement' => $id_etablissement,
'etablissement_paiement_ok' => $etablissement_paiement_ok,
]) ?>
<?php endif; ?>

Loading…
Annulla
Salva