Skip to content

Commit

Permalink
ajout d'information pour ls organisation et correction du bug avec le…
Browse files Browse the repository at this point in the history
…s dates
  • Loading branch information
willkoua committed May 30, 2016
1 parent 50341bd commit 689f958
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
26 changes: 18 additions & 8 deletions src/Controller/PagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -555,18 +557,26 @@ 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()
->select(['id', 'name', 'created'])
->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/";
Expand Down
10 changes: 6 additions & 4 deletions src/Template/Pages/administration.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@
<div class="panel-body table-responsive">
<h3 class="header-title"><?= __('Organizations') ?></h3>
<table class="table">
<?php foreach ($organizations as $organization):?>
<?php foreach ($organizations as $organization): ?>
<tr>
<td><?= $this->Html->link($organization->getName(), ['controller' => 'Organizations', 'action' => 'view', $organization->id]); ?></td>
<td><em class="small"><?= ($organization->getCreated() != null) ? $organization->getCreated() : __("not define"); ?> </em></td>

<td>
<?= $this->Html->link($organization['name'], ['controller' => 'Organizations', 'action' => 'view', $organization['id']]); ?>
<span class='label label-success' title='projets'><?= $organization['pj']; ?></span>
</td>
<td><em class="small"><?= ($organization['created'] != null) ? date("d-m-Y", strtotime($organization['created'])) : __("not define"); ?> </em></td>
</tr>
<?php endforeach; ?>
</table>
Expand Down

0 comments on commit 689f958

Please sign in to comment.