summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2016-06-12 17:31:34 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2016-06-12 17:31:34 +0200
commit61256d532e8a0155aaa9c28977f542823073e4ec (patch)
tree2f527bb0a161262666a9ce4e0f212c11d762921e
parent10f837374404d8686e74f983622ced5e10a6ee40 (diff)
downloadchd_gestion-61256d532e8a0155aaa9c28977f542823073e4ec.zip
chd_gestion-61256d532e8a0155aaa9c28977f542823073e4ec.tar.gz
chd_gestion-61256d532e8a0155aaa9c28977f542823073e4ec.tar.bz2
Adherent/index : add by AdherentTypes filter
-rw-r--r--generator/after-bake/src/Controller/AdherentsController.php26
-rw-r--r--generator/after-bake/src/Template/Adherents/index.ctp12
-rw-r--r--generator/before-bake/config/bake_extra.php10
3 files changed, 21 insertions, 27 deletions
diff --git a/generator/after-bake/src/Controller/AdherentsController.php b/generator/after-bake/src/Controller/AdherentsController.php
index abec8a0..566f5a6 100644
--- a/generator/after-bake/src/Controller/AdherentsController.php
+++ b/generator/after-bake/src/Controller/AdherentsController.php
@@ -21,7 +21,6 @@
namespace App\Controller;
use App\Controller\AppController;
-use Cake\Datasource\ConnectionManager;
/**
* Adherents Controller
@@ -31,7 +30,6 @@ use Cake\Datasource\ConnectionManager;
class AdherentsController extends AppController
{
-
public function initialize()
{
parent::initialize();
@@ -56,39 +54,25 @@ class AdherentsController extends AppController
$this->set('adherents', $this->paginate($query));
$this->set('_serialize', ['adherents']);
+ $this->loadModel('AdherentTypes');
+ $this->set('adherentTypes', $this->AdherentTypes->find('list')->toArray());
$this->loadModel('Villes');
$this->set('villes', $this->Villes->find('list')->toArray());
-
- //TODO : quick'n'dirty, à améliorer
- $conn = ConnectionManager::get('default');
- //$rawq = 'SELECT CASE WHEN COUNT(*)=0 THEN 0 ELSE ROUND(SUM(adherent_statut_id-1) * 100 / (4*COUNT(*))) END FROM adherents WHERE adherent_statut_id <> 1';
- $rawq='
-SELECT
- ROUND( COUNT(*) * 100 /
- (
- SELECT CASE WHEN COUNT(*)=0 THEN 1 ELSE COUNT(*) END
- FROM adherents WHERE adherent_statut_id NOT IN (1,8)
- )
- )
-FROM adherents WHERE adherent_statut_id = 5;
-';
- $stmt = $conn->execute($rawq);
- $score = current($stmt->fetch());
- $this->set('score', $score);
}
/**
* View method
*
* @param string|null $id Adherent id.
- * @return void
- * @throws \Cake\Network\Exception\NotFoundException When record not found.
+ * @return \Cake\Network\Response|null
+ * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function view($id = null)
{
$adherent = $this->Adherents->get($id, [
'contain' => ['AdherentRoles' => ['AdherentRoleTypes', 'Villes'], 'AdherentTypes', 'Villes', 'AdherentStatuts', 'Civilites', 'Services' => ['ServiceTypes', 'ServiceStatuts'] ]
]);
+
$this->set('adherent', $adherent);
$this->set('_serialize', ['adherent']);
}
diff --git a/generator/after-bake/src/Template/Adherents/index.ctp b/generator/after-bake/src/Template/Adherents/index.ctp
index 9f62c14..353f4b7 100644
--- a/generator/after-bake/src/Template/Adherents/index.ctp
+++ b/generator/after-bake/src/Template/Adherents/index.ctp
@@ -33,22 +33,24 @@
</ul>
</nav>
<div class="adherents index large-10 medium-9 columns content">
- <!-- TODO : quick'n' dirty, à reprendre -->
- <div style="float:right">
- <h5>Progression&nbsp;: <?= $score ?> %</h5>
- </div>
<h3><?= __('Adherents') ?></h3>
<table cellpadding="0" cellspacing="0">
<?= $this->Form->create(null) . "\n" ?>
<thead>
<tr class="filter">
- <th colspan="5">
+ <th colspan="3">
<?= $this->Form->input('q', [
'placeholder' => __('Find...'),
'empty' => __('Find...')
]) ?>
</th>
<th colspan="2">
+ <?= $this->Form->input('adherent_type_id', [
+ 'placeholder' => __('AdherentTypes'),
+ 'empty' => __('AdherentTypes')
+ ]) ?>
+ </th>
+ <th colspan="2">
<?= $this->Form->input('ville_id', [
'placeholder' => __('Villes'),
'empty' => __('Villes')
diff --git a/generator/before-bake/config/bake_extra.php b/generator/before-bake/config/bake_extra.php
index bff1a9a..2fded68 100644
--- a/generator/before-bake/config/bake_extra.php
+++ b/generator/before-bake/config/bake_extra.php
@@ -49,9 +49,17 @@ EOT
'before' => 'true',
'after' => 'true',
'columns' => ['id','nom','nom2','prenom','prenom2','raison','proprio','tel_mobile1','tel_mobile2'],
- 'colspan' => 5,
+ 'colspan' => 3,
'hint' => 'Find...',
],
+ 'adherent_type_id' => [
+ 'mode' => 'value',
+ 'before' => 'false',
+ 'after' => 'false',
+ 'model' => 'AdherentTypes',
+ 'colspan' => 2,
+ 'hint' => 'AdherentTypes',
+ ],
'ville_id' => [
'mode' => 'value',
'before' => 'false',