diff --git a/src/Controller/PagesController.php b/src/Controller/PagesController.php index 2d97cafd..46a26e13 100644 --- a/src/Controller/PagesController.php +++ b/src/Controller/PagesController.php @@ -12,10 +12,12 @@ use App\Controller\AppController; use Cake\Core\Configure; +use Cake\Datasource\ConnectionManager; use Cake\Event\Event; use Cake\Network\Exception\NotFoundException; use Cake\View\Exception\MissingTemplateException; use GithubApi; +use Migrations\CakeManager; /** * Pages controller @@ -555,11 +557,36 @@ public function statistics() */ public function administration($img = null) { + $conn = ConnectionManager::get('default'); + $this->loadModel("Projects"); $projects = $this->Projects->find('all', ['conditions' => ['accepted' => 0, 'archived' => 0]])->toArray(); $this->loadModel("Organizations"); - $organizations = $this->Organizations->find('all', ['conditions' => ['isValidated' => 0, 'isRejected' => 0]])->toArray(); + /*$organizations = $this->Organizations + ->find() + ->select(['id', 'name', 'created']) + ->innerJoinWith('projects', function ($q) { + return $q->where(['organizations.id' => 'organizations_projects.organization_id']); + }) + ->where(['isValidated' => 0, 'isRejected' => 0]) + ->order(['created' => 'DESC']) + ->limit(10) + ->toArray(); */ + + $organizations = $conn->execute('SELECT + id, name, created, + ( + SELECT + COUNT(id) + FROM organizations_projects p + WHERE p.organization_id = o.id + ) pj + FROM organizations o + WHERE o.isValidated = 0 AND o.isRejected = 0 + ORDER BY o.created DESC + LIMIT 10' + )->fetchAll('assoc'); //gestion des images du carousel $pathCar = WWW_ROOT . "img/carousel/"; diff --git a/src/Template/Pages/administration.ctp b/src/Template/Pages/administration.ctp index 0532c186..64ef939b 100644 --- a/src/Template/Pages/administration.ctp +++ b/src/Template/Pages/administration.ctp @@ -49,12 +49,16 @@
-
+

- + - + +
Html->link($organization->getName(), ['controller' => 'Organizations', 'action' => 'view', $organization->id]); ?> + Html->link($organization['name'], ['controller' => 'Organizations', 'action' => 'view', $organization['id']]); ?> + +