diff options
Diffstat (limited to 'generator/after-bake/src')
-rw-r--r-- | generator/after-bake/src/Controller/AdherentsController.php | 26 | ||||
-rw-r--r-- | generator/after-bake/src/Template/Adherents/index.ctp | 12 |
2 files changed, 12 insertions, 26 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 : <?= $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') |