* @copyright 2012 Jurian Sluiman. * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @link http://zf-commons.github.com */ namespace ZfcAdmin\Controller; use Zend\Mvc\Controller\AbstractActionController; use Reservation\Model\Listes; use Reservation\Model\User; /** * Placeholder controller * * This controller is just here in case you have not defined a controller * behind the 'admin' route yourself. If you haven't, you would otherwise * get a 404: Page not found error. * * If you want to override this controller (and action), create a module and * put this in the module configuration: * * * array( * 'routes' => array( * 'zfcadmin' => array( * 'options' => array( * 'defaults' => array( * 'controller' => 'MyFoo\Controller\OtherController', * 'action' => 'custom', * ), * ), * ), * ), * ), * ); * * * @package ZfcAdmin * @subpackage Controller */ class AdminController extends AbstractActionController { protected $userTable; protected $listesTable; public function indexAction(){ $auth = $this->getServiceLocator()->get('zfcuser_auth_service'); $gestId = 1; if( $auth->hasIdentity() ){ $user = $auth->getIdentity(); $gestId = $user->getId(); } $adapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter'); $listes = array(); $listesDp = array(); $idProfile = $this->getUserTable()->getUserProfil($gestId)->role_id; $listesDeProfile = $this->getListesTable()->fetchAllByProfile($idProfile); foreach($listesDeProfile as $liste){ $listes[] = $liste; } $allListes = $this->getListesTable()->fetchAllPrivate($gestId); if ($allListes) { foreach ($allListes as $liste){ $listes[] = $liste; } } //listes DP $listesDeProfile = $this->getListesTable()->fetchAllByProfile($idProfile,'dp',$adapter); foreach($listesDeProfile as $liste){ $liste = (object) $liste; $listesDp[] = $liste; } $allListes = $this->getListesTable()->fetchAllPrivate($gestId,'dp',$adapter); if ($allListes) { foreach ($allListes as $liste){ $liste = (object) $liste; $listesDp[] = $liste; } } return array('listes'=>$listes,'listesDp'=>$listesDp); } public function getUserTable() { if (!$this->userTable) { $sm = $this->getServiceLocator(); $this->userTable = $sm->get('Reservation\Model\UserTable'); } return $this->userTable; } public function getListesTable() { if (!$this->listesTable) { $sm = $this->getServiceLocator(); $this->listesTable = $sm->get('Reservation\Model\ListesTable'); } return $this->listesTable; } }