Explorar el Código

Formulaire de contact "producteur"

refactoring
keun hace 6 años
padre
commit
c9bcd52cf0
Se han modificado 17 ficheros con 133 adiciones y 58 borrados
  1. +0
    -1
      common/config/bootstrap.php
  2. +1
    -1
      common/models/ContactForm.php
  3. +4
    -0
      common/models/Etablissement.php
  4. +1
    -1
      frontend/controllers/SiteController.php
  5. +0
    -1
      frontend/views/site/contact.php
  6. +5
    -1
      producer/controllers/ProducerBaseController.php
  7. +0
    -41
      producer/controllers/ProducerController.php
  8. +81
    -0
      producer/controllers/SiteController.php
  9. +5
    -5
      producer/views/layouts/main.php
  10. +29
    -0
      producer/views/site/contact.php
  11. +0
    -0
      producer/views/site/error.php
  12. +0
    -0
      producer/views/site/index.php
  13. BIN
      producer/web/.sass-cache/66263a48087a904211dee8da4b068fa8f43a96db/_index.scssc
  14. BIN
      producer/web/.sass-cache/df296f4d5446ec0f190b7ff1f23eb998ea1b56e7/screen.scssc
  15. +4
    -4
      producer/web/css/screen.css
  16. +1
    -1
      producer/web/sass/screen.scss
  17. +2
    -2
      producer/web/sass/site/_index.scss

+ 0
- 1
common/config/bootstrap.php Ver fichero

Import::using('yii\helpers\*'); Import::using('yii\helpers\*');
Import::using('yii\web\NotFoundHttpException'); Import::using('yii\web\NotFoundHttpException');



// models // models
Import::using('common\models\*'); Import::using('common\models\*');
Import::using('frontend\models\*'); Import::using('frontend\models\*');

frontend/models/ContactForm.php → common/models/ContactForm.php Ver fichero

<?php <?php


namespace frontend\models;
namespace common\models;


use Yii; use Yii;
use yii\base\Model; use yii\base\Model;

+ 4
- 0
common/models/Etablissement.php Ver fichero

public function getUser() { public function getUser() {
return $this->hasMany(User::className(), ['id_etablissement' => 'id']); return $this->hasMany(User::className(), ['id_etablissement' => 'id']);
} }
public function getContact() {
return $this->hasMany(User::className(), ['id_etablissement' => 'id'])->where(['status' => User::STATUS_BOULANGER]);
}


public static function getEtablissementsPopulateDropdown() { public static function getEtablissementsPopulateDropdown() {



+ 1
- 1
frontend/controllers/SiteController.php Ver fichero

use frontend\models\PasswordResetRequestForm; use frontend\models\PasswordResetRequestForm;
use frontend\models\ResetPasswordForm; use frontend\models\ResetPasswordForm;
use frontend\models\SignupForm; use frontend\models\SignupForm;
use frontend\models\ContactForm;
use common\models\ContactForm;
use yii\base\InvalidParamException; use yii\base\InvalidParamException;
use yii\web\BadRequestHttpException; use yii\web\BadRequestHttpException;
use yii\web\Controller; use yii\web\Controller;

+ 0
- 1
frontend/views/site/contact.php Ver fichero



/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */ /* @var $form yii\bootstrap\ActiveForm */
/* @var $model \frontend\models\ContactForm */


$this->title = 'Contact'; $this->title = 'Contact';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;

+ 5
- 1
producer/controllers/ProducerBaseController.php Ver fichero

return $this->producer ; return $this->producer ;
} }
else { else {
$producer = Etablissement::findOne(['slug' => Yii::$app->getRequest()->getQueryParam('slug_producer')]) ;
$producer = Etablissement::find()
->with('contact')
->where(['slug' => Yii::$app->getRequest()->getQueryParam('slug_producer')])
->one() ;
if($producer) { if($producer) {
$this->producer = $producer ; $this->producer = $producer ;
return $this->producer ; return $this->producer ;

+ 0
- 41
producer/controllers/ProducerController.php Ver fichero

<?php

namespace producer\controllers;

class ProducerController extends ProducerBaseController {

/**
* @inheritdoc
*/
public function behaviors() {
return [];
}
public function actions() {
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
];
}
public function actionIndex() {
$etablissement = Etablissement::findOne(['slug' => Yii::$app->getRequest()->getQueryParam('slug_producer')]) ;
$points_vente = [] ;
if($etablissement) {
$points_vente = PointVente::find()
->where([
'id_etablissement' => $etablissement->id,
])
->all() ;
}
return $this->render('index',[
'points_vente' => $points_vente
]) ;
}
}

?>

+ 81
- 0
producer/controllers/SiteController.php Ver fichero

<?php

namespace producer\controllers;

class SiteController extends ProducerBaseController {

/**
* @inheritdoc
*/
public function behaviors() {
return [];
}
public function actions() {
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
/**
*
* Affiche la page d'accueil des producteurs comprenant une image, une
* description et la liste des points de vente.
*
* @return ProducerView
*/
public function actionIndex() {
$etablissement = Etablissement::findOne([
'slug' => Yii::$app->getRequest()->getQueryParam('slug_producer')
]) ;
$points_vente = [] ;
if($etablissement) {
$points_vente = PointVente::find()
->where([
'id_etablissement' => $etablissement->id,
])
->all() ;
}
return $this->render('index',[
'points_vente' => $points_vente
]) ;
}
/**
*
* Affiche et traite le formulaire de contact dédié aux producteurs
*
* @return ProducerView
*/
public function actionContact() {
$model = new ContactForm();
$producer = $this->getProducer() ;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if (is_array($producer->contact) && $model->sendEmail($producer->contact[0]->email)) {
Yii::$app->session->setFlash('success', 'Votre message a bien été envoyé.');
}
else {
Yii::$app->session->setFlash('error', 'Il y a eu une erreur lors de l\'envoi de votre message.');
}
return $this->refresh();
}
else {
return $this->render('contact', [
'model' => $model,
]);
}
}
}

?>

+ 5
- 5
producer/views/layouts/main.php Ver fichero

], ],
[ [
'label' => '<span class="glyphicon glyphicon-log-in"></span> Connexion', 'label' => '<span class="glyphicon glyphicon-log-in"></span> Connexion',
'url' => Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/login','return_url' => Yii::$app->urlManager->createAbsoluteUrl(['producer/index'])]),
'url' => Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/login','return_url' => Yii::$app->urlManager->createAbsoluteUrl(['site/index'])]),
'visible' => Yii::$app->user->isGuest 'visible' => Yii::$app->user->isGuest
], ],
[ [
'items' => [ 'items' => [
[ [
'label' => '<span class="glyphicon glyphicon-th-large"></span> Accueil', 'label' => '<span class="glyphicon glyphicon-th-large"></span> Accueil',
'url' => Yii::$app->urlManager->createUrl(['producer/index']),
'active' => $this->getControllerAction() == 'producer/index',
'url' => Yii::$app->urlManager->createUrl(['site/index']),
'active' => $this->getControllerAction() == 'site/index',
], ],
[ [
'label' => '<span class="glyphicon glyphicon-plus"></span> Commander', 'label' => '<span class="glyphicon glyphicon-plus"></span> Commander',
], ],
[ [
'label' => '<span class="glyphicon glyphicon-envelope"></span> Contact', 'label' => '<span class="glyphicon glyphicon-envelope"></span> Contact',
'url' => Yii::$app->urlManager->createUrl(['producer/contact']),
'active' => $this->getControllerAction() == 'producer/contact',
'url' => Yii::$app->urlManager->createUrl(['site/contact']),
'active' => $this->getControllerAction() == 'site/contact',
], ],
[ [
'label' => '<span class="glyphicon glyphicon-cog"></span> Administration', 'label' => '<span class="glyphicon glyphicon-cog"></span> Administration',

+ 29
- 0
producer/views/site/contact.php Ver fichero

<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\captcha\Captcha;

$this->setTitle('Contact');

?>
<div class="site-contact">
<div class="row">
<div class="col-lg-5">
<?php $form = yii\bootstrap\ActiveForm::begin(['id' => 'contact-form', 'enableClientValidation' => false,]); ?>
<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'email') ?>
<?= $form->field($model, 'subject') ?>
<?= $form->field($model, 'body')->textArea(['rows' => 6]) ?>
<?php echo $form->field($model, 'verifyCode')->widget(yii\captcha\Captcha::className(), [
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
]); ?>
<div class="form-group">
<?= Html::submitButton('Envoyer', ['class' => 'btn btn-primary', 'name' => 'contact-button']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>

producer/views/producer/error.php → producer/views/site/error.php Ver fichero


producer/views/producer/index.php → producer/views/site/index.php Ver fichero


BIN
producer/web/.sass-cache/66263a48087a904211dee8da4b068fa8f43a96db/_index.scssc Ver fichero


BIN
producer/web/.sass-cache/df296f4d5446ec0f190b7ff1f23eb998ea1b56e7/screen.scssc Ver fichero


+ 4
- 4
producer/web/css/screen.css Ver fichero

margin-right: 10px; margin-right: 10px;
} }


/* line 4, ../sass/producer/_index.scss */
.producer-index #presentation .photo {
/* line 4, ../sass/site/_index.scss */
.site-index #presentation .photo {
text-align: center; text-align: center;
} }
/* line 6, ../sass/producer/_index.scss */
.producer-index #presentation .photo .img-photo {
/* line 6, ../sass/site/_index.scss */
.site-index #presentation .photo .img-photo {
width: 100%; width: 100%;
max-width: 500px; max-width: 500px;
} }

+ 1
- 1
producer/web/sass/screen.scss Ver fichero

@import "compass"; @import "compass";
@import "compass/reset"; @import "compass/reset";
@import "_layout.scss"; @import "_layout.scss";
@import "producer/_index.scss";
@import "site/_index.scss";
@import "commande/_form.scss"; @import "commande/_form.scss";
@import "commande/_historique.scss"; @import "commande/_historique.scss";

producer/web/sass/producer/_index.scss → producer/web/sass/site/_index.scss Ver fichero



.producer-index {
.site-index {
#presentation { #presentation {
.photo { .photo {
text-align: center ; text-align: center ;
width: 100% ; width: 100% ;
max-width: 500px ; max-width: 500px ;
} }
}
}
} }
} }

Cargando…
Cancelar
Guardar