Преглед изворни кода

Produits sur la page d'accueil

refactoring
keun пре 6 година
родитељ
комит
378f731a4a
5 измењених фајлова са 80 додато и 36 уклоњено
  1. +29
    -13
      producer/controllers/SiteController.php
  2. +39
    -21
      producer/views/site/index.php
  3. BIN
      producer/web/.sass-cache/66263a48087a904211dee8da4b068fa8f43a96db/_index.scssc
  4. +5
    -0
      producer/web/css/screen.css
  5. +7
    -2
      producer/web/sass/site/_index.scss

+ 29
- 13
producer/controllers/SiteController.php Прегледај датотеку

@@ -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
]) ;
}

+ 39
- 21
producer/views/site/index.php Прегледај датотеку

@@ -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>

BIN
producer/web/.sass-cache/66263a48087a904211dee8da4b068fa8f43a96db/_index.scssc Прегледај датотеку


+ 5
- 0
producer/web/css/screen.css Прегледај датотеку

@@ -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
- 2
producer/web/sass/site/_index.scss Прегледај датотеку

@@ -7,7 +7,12 @@
width: 100% ;
max-width: 500px ;
}
}
}
}
#produits {
img.photo-produit {
width: 100px ;
height: auto ;
}
}
}

Loading…
Откажи
Сачувај