@@ -26,27 +26,43 @@ class SiteController extends ProducerBaseController { | |||
/** | |||
* | |||
* Affiche la page d'accueil des producteurs comprenant une image, une | |||
* description et la liste des points de vente. | |||
* description, la liste des points de vente et les produits | |||
* | |||
* @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() ; | |||
} | |||
// points de vente | |||
$data_provider_points_vente = new ActiveDataProvider([ | |||
'query' => PointVente::find() | |||
->where([ | |||
'id_etablissement' => $this->getProducer()->id, | |||
]), | |||
'pagination' => [ | |||
'pageSize' => 50, | |||
], | |||
'sort' => false, | |||
]); | |||
// produits | |||
$data_provider_produits = new ActiveDataProvider([ | |||
'query' => Produit::find() | |||
->where('(vrac IS NULL OR vrac = 0)') | |||
->andWhere([ | |||
'id_etablissement' => $this->getProducer()->id, | |||
'actif' => true | |||
]) | |||
->orderBy('order ASC'), | |||
'pagination' => [ | |||
'pageSize' => 50, | |||
], | |||
'sort' => false, | |||
]); | |||
return $this->render('index',[ | |||
'points_vente' => $points_vente | |||
'data_provider_points_vente' => $data_provider_points_vente, | |||
'data_provider_produits' => $data_provider_produits | |||
]) ; | |||
} | |||
@@ -26,26 +26,44 @@ else | |||
</section> | |||
<?php endif; ?> | |||
<?php if(is_array($points_vente) && count($points_vente)): ?> | |||
<section id="points-vente"> | |||
<h3><span>Points de vente</span></h3> | |||
<table class="table table-bordered"> | |||
<thead> | |||
<tr> | |||
<th>Nom</th> | |||
<th>Localisation</th> | |||
<th>Jours de livraison</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<?php foreach($points_vente as $pv): ?> | |||
<tr> | |||
<td><?= Html::encode($pv->nom); ?></td> | |||
<td><?= Html::encode($pv->localite); ?></td> | |||
<td><?= Html::encode($pv->strJoursLivraison()); ?></td> | |||
</tr> | |||
<?php endforeach; ?> | |||
</tbody> | |||
</table> | |||
<h3><span>Points de vente</span></h3> | |||
<?= GridView::widget([ | |||
'dataProvider' => $data_provider_points_vente, | |||
'summary' => '', | |||
'columns' => [ | |||
'nom', | |||
'localite', | |||
[ | |||
'label' => 'Jours de livraison', | |||
'value' => function($model) { | |||
return $model->strJoursLivraison() ; | |||
} | |||
] | |||
], | |||
]); ?> | |||
</section> | |||
<?php endif; ?> | |||
<section id="produits"> | |||
<h3><span>Produits</span></h3> | |||
<?= GridView::widget([ | |||
'dataProvider' => $data_provider_produits, | |||
'summary' => '', | |||
'columns' => [ | |||
[ | |||
'attribute' => 'photo', | |||
'format' => 'raw', | |||
'headerOptions' => ['class' => 'td-photo'], | |||
'value' => function($model) { | |||
if(strlen($model->photo)) { | |||
return '<img class="photo-produit" src="'.Yii::$app->urlManagerProducer->baseUrl.'/uploads/'.$model->photo.'" />' ; | |||
} | |||
return '' ; | |||
} | |||
], | |||
'nom', | |||
'description', | |||
], | |||
]); ?> | |||
</section> |
@@ -389,6 +389,11 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active { | |||
width: 100%; | |||
max-width: 500px; | |||
} | |||
/* line 13, ../sass/site/_index.scss */ | |||
.site-index #produits img.photo-produit { | |||
width: 100px; | |||
height: auto; | |||
} | |||
/* line 4, ../sass/commande/_form.scss */ | |||
.commande-create .commande-form, |
@@ -7,7 +7,12 @@ | |||
width: 100% ; | |||
max-width: 500px ; | |||
} | |||
} | |||
} | |||
} | |||
#produits { | |||
img.photo-produit { | |||
width: 100px ; | |||
height: auto ; | |||
} | |||
} | |||
} |