summaryrefslogtreecommitdiff
path: root/generator/after-bake/src/Controller/AdherentsController.php
diff options
context:
space:
mode:
Diffstat (limited to 'generator/after-bake/src/Controller/AdherentsController.php')
-rw-r--r--generator/after-bake/src/Controller/AdherentsController.php26
1 files changed, 5 insertions, 21 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']);
}