Browse Source

Champs type d'établissement

Utilisé en baseline du nom de l'établissement.
dev
keun 6 years ago
parent
commit
e2da20f1ae
6 changed files with 35 additions and 6 deletions
  1. +5
    -0
      backend/views/etablissement/update.php
  2. +3
    -2
      common/models/Etablissement.php
  3. +15
    -0
      console/migrations/m180314_081214_add_champs_etablissement.php
  4. +9
    -0
      frontend/models/SignupForm.php
  5. +1
    -0
      frontend/views/site/signup.php
  6. +2
    -4
      producer/views/layouts/main.php

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

@@ -22,6 +22,11 @@ $this->params['breadcrumbs'][] = 'Paramètres';
], [])
->label('Activer le producteur')
->hint('Activez cette option pour rendre votre établissement visible à vos clients.') ; ?>
<?= $form->field($model, 'nom') ?>
<?= $form->field($model, 'type') ?>
<?= $form->field($model, 'description')
->textarea(['rows' => 6])
->hint('Affiché sur la page d\'accueil') ?>
<?= $form->field($model, 'code_postal') ?>
<?= $form->field($model, 'ville') ?>

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

@@ -37,7 +37,7 @@ class Etablissement extends \yii\db\ActiveRecord {
*/
public function rules() {
return [
[['nom', 'siret', 'heure_limite_commande', 'delai_commande'], 'required'],
[['nom', 'siret', 'heure_limite_commande', 'delai_commande','type'], 'required'],
[['heure_limite_commande', 'delai_commande'], 'integer'],
['heure_limite_commande', 'in', 'range' => [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]],
['delai_commande', 'in', 'range' => [1, 2, 3, 4, 5, 6, 7]],
@@ -52,7 +52,7 @@ class Etablissement extends \yii\db\ActiveRecord {
}],
[['description', 'infos_commande','slug'], 'string'],
[['solde_negatif', 'credit_pain', 'actif'], 'boolean'],
[['nom', 'siret', 'logo', 'photo', 'code_postal', 'ville', 'code'], 'string', 'max' => 255],
[['nom', 'siret', 'logo', 'photo', 'code_postal', 'ville', 'code','type'], 'string', 'max' => 255],
['prix_libre', 'double'],
['prix_libre', 'compare', 'compareValue' => 0, 'operator' => '>=', 'type' => 'number', 'message' => 'Prix libre doit être supérieur ou égal à 0'],
];
@@ -80,6 +80,7 @@ class Etablissement extends \yii\db\ActiveRecord {
'date_creation' => 'Date de création',
'infos_commande' => 'Informations',
'slug' => 'Slug',
'type' => 'Type d\'établissement'
];
}


+ 15
- 0
console/migrations/m180314_081214_add_champs_etablissement.php View File

@@ -0,0 +1,15 @@
<?php

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

class m180314_081214_add_champs_etablissement extends Migration {

public function up() {
$this->addColumn('etablissement', 'type', Schema::TYPE_STRING);
}

public function down() {
$this->dropColumn('etablissement','type');
}
}

+ 9
- 0
frontend/models/SignupForm.php View File

@@ -29,6 +29,7 @@ class SignupForm extends Model {
public $option_client_boulanger;
public $cgv;
public $code;
public $type;

/**
* @inheritdoc
@@ -68,6 +69,12 @@ class SignupForm extends Model {
}, 'whenClient' => "function (attribute, value) {
return $('#option-boulanger').prop('checked') ;
}"],
['type', 'string'],
['type', 'required', 'message' => 'Champs obligatoire', 'when' => function($model) {
return $model->option_client_boulanger == 'boulanger';
}, 'whenClient' => "function (attribute, value) {
return $('#option-boulanger').prop('checked') ;
}"],
['siret', 'string'],
['siret', 'required', 'message' => 'Champs obligatoire', 'when' => function($model) {
return $model->option_client_boulanger == 'boulanger';
@@ -155,6 +162,7 @@ class SignupForm extends Model {
// etablissement
$etablissement = new Etablissement;
$etablissement->nom = $this->nom_magasin;
$etablissement->type = $this->type;
$etablissement->siret = $this->siret;
$etablissement->code_postal = $this->code_postal;
$etablissement->ville = $this->ville;
@@ -252,6 +260,7 @@ class SignupForm extends Model {
'code_postal' => 'Code postal',
'ville' => 'Commune',
'id_etablissement' => 'Producteur',
'type' => 'Type d\'établissement',
];
}


+ 1
- 0
frontend/views/site/signup.php View File

@@ -39,6 +39,7 @@ $this->params['breadcrumbs'][] = $this->title;

<div id="champs-boulanger">
<?= $form->field($model, 'nom_magasin') ?>
<?= $form->field($model, 'type')->textInput(['placeholder' => 'Boulangerie, brasserie, ferme ...']); ?>
<?= $form->field($model, 'siret') ?>
<?= $form->field($model, 'code_postal') ?>
<?= $form->field($model, 'ville') ?>

+ 2
- 4
producer/views/layouts/main.php View File

@@ -27,7 +27,7 @@ $producer = $this->getProducer() ;
<div id="header-bap">
<div class="container">
<a id="logo" href="<?= Url::frontend(); ?>">
<a id="logo" href="<?= Yii::$app->urlManager->createUrl(['producer/index']); ?>">
<img class="icon" src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/laboulange3.png" alt="" />
<span class="text">La boîte à pain</span>
</a>
@@ -65,15 +65,13 @@ $producer = $this->getProducer() ;
'options' => ['id' =>'nav-bap'],
]);
?>

</div>
</div>
<header id="header">
<div class="container">
<h1><?= Html::encode($producer->nom); ?></h1>
<h2>Boulangerie à <?= Html::encode($producer->ville); ?> (<?= Html::encode($producer->code_postal); ?>)</h2>
<h2><?= Html::encode($producer->type) ?> à <?= Html::encode($producer->ville); ?> (<?= Html::encode($producer->code_postal); ?>)</h2>
<?php if(!Yii::$app->user->isGuest): ?>
<?php
$user_etablissement = UserEtablissement::findOne(['id_user' => Yii::$app->user->identity->id, 'id_etablissement' => $producer->id ]) ;

Loading…
Cancel
Save