426 lines
9.3 KiB
PHP
Raw Normal View History

2011-01-05 09:59:49 +00:00
<?php
class Menu
{
2011-01-05 15:14:23 +00:00
protected $menu = null;
2011-04-15 09:05:30 +00:00
protected $siret = null;
protected $id = 0;
2011-01-05 09:59:49 +00:00
protected $defineMenu = array(
array(
'label' => 'RECHERCHES',
'pages' => array(
array(
'label' => "Rechercher une entreprise",
2011-01-06 08:37:20 +00:00
'title' => "Rechercher une entreprise",
'controller' => 'recherche',
'action' => 'entreprise',
2011-01-05 09:59:49 +00:00
),
array(
'label' => "Rechercher par dirigeant",
2011-01-06 08:37:20 +00:00
'controller' => 'recherche',
'action' => 'dirigeant',
2011-01-05 09:59:49 +00:00
),
array(
'label' => "Recherche Internationale",
'controller' => '',
'action' => '',
2011-04-15 10:25:46 +00:00
'permission' => 'INTERNATIONAL'
2011-01-05 09:59:49 +00:00
),
2011-04-15 09:05:30 +00:00
array( // idClient = 1
2011-01-05 09:59:49 +00:00
'label' => "Rechercher une annonce",
'controller' => '',
'action' => '',
),
2011-04-15 09:05:30 +00:00
array( // ModeEdition
'label' => "Rechercher par actionnaire",
'controller' => '',
'action' => ''
),
array( // Vérifier la présence d'au moins une recherche
2011-01-05 09:59:49 +00:00
'label' => "Dernière recherche",
2011-01-06 08:37:20 +00:00
'controller' => 'recherche',
'action' => 'last',
2011-01-05 09:59:49 +00:00
),
2011-04-15 09:05:30 +00:00
array( // Vérifier la présence d'au moins une recherche
2011-01-05 09:59:49 +00:00
'label' => "Liste des dernières recherches",
2011-01-06 08:37:20 +00:00
'controller' => 'recherche',
'action' => 'list',
2011-01-05 09:59:49 +00:00
),
array(
'label' => "Centrale IparI",
2011-04-15 09:05:30 +00:00
'controller' => 'recherche',
'action' => 'ipari',
2011-01-05 15:14:23 +00:00
'permission' => 'ipari',
2011-01-05 09:59:49 +00:00
),
),
),
array(
'label' => 'IDENTITE',
'pages' => array(
2011-04-15 09:05:30 +00:00
array( // Vérification paramètres
2011-01-05 09:59:49 +00:00
'label' => "Fiche d'identité",
2011-04-15 09:05:30 +00:00
'controller' => 'identite',
'action' => 'fiche',
2011-01-05 09:59:49 +00:00
),
2011-04-15 09:05:30 +00:00
array( // Vérification paramètres
2011-01-05 09:59:49 +00:00
'label' => "Fiche Procédure Collective",
2011-04-15 09:05:30 +00:00
'controller' => 'identite',
'action' => 'fichepc',
2011-01-05 09:59:49 +00:00
),
2011-04-15 09:05:30 +00:00
array( // Vérification paramètres
2011-01-05 09:59:49 +00:00
'label' => "Liste des établissements",
2011-04-15 09:05:30 +00:00
'controller' => 'identite',
'action' => 'etablissements',
2011-01-05 09:59:49 +00:00
),
2011-04-15 09:05:30 +00:00
array( // Vérificaiton paramètres
2011-01-05 09:59:49 +00:00
'label' => "Liens inter-entreprise",
'controller' => 'identite',
'action' => 'liens',
2011-01-05 09:59:49 +00:00
),
array(
'label' => "Modifications Insee",
'controller' => 'identite',
'action' => 'insee',
2011-01-05 09:59:49 +00:00
),
),
),
array(
'label' => 'DIRIGEANTS',
'pages' => array(
2011-04-15 09:05:30 +00:00
array( // Vérification paramètres
2011-01-05 09:59:49 +00:00
'label' => "Liste des dirigeants",
2011-04-19 06:23:20 +00:00
'controller' => 'dirigeant',
'action' => 'liste',
2011-01-05 09:59:49 +00:00
),
2011-04-15 09:05:30 +00:00
array( // Vérification paramètres
2011-01-05 09:59:49 +00:00
'label' => "Historique des dirigeants",
2011-04-19 06:23:20 +00:00
'controller' => 'dirigeant',
'action' => 'histo',
2011-01-05 09:59:49 +00:00
),
),
),
array(
'label' => 'ELEMENTS FINANCIERS',
'pages' => array(
array(
'label' => "Synthèse",
2011-04-19 07:21:06 +00:00
'controller' => 'finance',
'action' => 'synthese',
2011-01-05 09:59:49 +00:00
),
array(
'label' => "Bilans, Compte de résultat",
2011-04-19 07:21:06 +00:00
'controller' => 'finance',
'action' => 'bilan',
2011-01-05 09:59:49 +00:00
),
array(
'label' => "Ratios",
2011-04-19 07:21:06 +00:00
'controller' => 'finance',
'action' => 'ratios',
2011-01-05 09:59:49 +00:00
),
array(
'label' => "Liasse fiscale",
2011-04-19 07:21:06 +00:00
'controller' => 'finance',
'action' => 'liasse',
2011-01-05 09:59:49 +00:00
),
array(
'label' => "Bourse & Cotations",
2011-04-19 07:21:06 +00:00
'controller' => 'finance',
'action' => 'bourse',
2011-01-05 09:59:49 +00:00
),
array(
'label' => "Relations bancaires",
2011-04-19 07:21:06 +00:00
'controller' => 'finance',
'action' => 'banque',
2011-01-05 09:59:49 +00:00
),
),
),
array(
'label' => 'ELEMENTS JURIDIQUES',
'pages' => array(
array(
'label' => "Annonces Légales",
'controller' => '',
'action' => '',
),
array(
'label' => "Information Réglementée",
'controller' => '',
'action' => '',
),
array(
'label' => "Compétences Territoriales",
'controller' => '',
'action' => '',
),
array(
'label' => "Conventions collectives",
'controller' => '',
'action' => '',
),
array(
'label' => "Marques déposées",
'controller' => '',
'action' => '',
),
),
),
array(
'label' => 'BANQUE DE FRANCE',
2011-01-05 15:14:23 +00:00
'permission' => 'BDF',
2011-01-05 09:59:49 +00:00
'pages' => array(
array(
'label' => "27. Panorama",
'controller' => '',
'action' => '',
),
array(
'label' => "28. Concours Bancaires",
'controller' => '',
'action' => '',
),
array(
'label' => "29. Impayés",
'controller' => '',
'action' => '',
),
array(
'label' => "37. Cotation",
'controller' => '',
'action' => '',
),
array(
'label' => "40. Relations Bancaires",
'controller' => '',
'action' => '',
),
array(
'label' => "51. Dirigeants",
'controller' => '',
'action' => '',
),
array(
'label' => "Autres",
'controller' => '',
'action' => '',
),
),
),
array(
'label' => 'EVALUATION',
'pages' => array(
array(
'label' => "IndiScore",
'controller' => '',
'action' => '',
),
array(
'label' => "Rapport de synthèse",
'controller' => '',
'action' => '',
),
array(
'label' => "Rapport complet",
'controller' => '',
'action' => '',
),
array(
'label' => "Scoring Credit Safe",
'controller' => '',
'action' => '',
),
array(
'label' => "Enquête commerciale",
'controller' => '',
'action' => '',
),
),
),
array(
'label' => 'PIECES OFFICIELLES',
'pages' => array(
array(
'label' => "Commande de Pièces",
'controller' => '',
'action' => '',
),
array(
'label' => "Comptes annuels",
'controller' => '',
'action' => '',
),
array(
'label' => "Actes & Statuts",
'controller' => '',
'action' => '',
),
array(
'label' => "Suivi Privilèges",
'controller' => '',
'action' => '',
),
),
),
array(
'label' => 'OPTIONS',
'pages' => array(
array(
'label' => "Mes options",
2011-01-07 17:16:07 +00:00
'controller' => 'user',
'action' => 'index',
2011-01-05 09:59:49 +00:00
),
array(
'label' => "Mes surveillances",
'controller' => '',
'action' => '',
),
array(
'label' => "Mon portefeuille",
'controller' => '',
'action' => '',
),
array(
'label' => "Administration",
'controller' => '',
'action' => '',
),
array(
'label' => "Commandes Greffe",
'controller' => '',
'action' => '',
),
array(
'label' => "Commandes International",
'controller' => '',
'action' => '',
),
array(
'label' => "Commandes Giant",
'controller' => '',
'action' => '',
),
array(
'label' => "Statistiques",
'controller' => '',
'action' => '',
),
array(
'label' => "Surveillances",
'controller' => '',
'action' => '',
),
array(
'label' => "Se déconnecter",
'controller' => 'user',
'action' => 'logout',
),
),
),
);
2011-04-15 09:05:30 +00:00
public function __construct($siret = null, $id = 0){
$this->siret = $siret;
$this->id = $id;
2011-01-05 15:14:23 +00:00
$this->menu = new Zend_Navigation();
2011-01-05 09:59:49 +00:00
$this->computeMenu();
}
public function getMenu(){
return $this->menu;
}
protected function computeMenu(){
foreach($this->defineMenu as $element){
$perm = true;
2011-01-05 15:14:23 +00:00
if (array_key_exists('permission', $element)){
$perm = $this->checkPermission($element['permission']);
2011-01-05 09:59:49 +00:00
}
if ($perm){
$menu = array();
$menu['label'] = $element['label'];
2011-01-05 15:14:23 +00:00
$menu['uri'] = '#';
2011-04-01 12:14:40 +00:00
$menu['class'] = 'header';
2011-01-05 09:59:49 +00:00
if (array_key_exists('pages', $element)){
2011-01-05 15:14:23 +00:00
$menu['pages'] = $this->computePage($element['pages']);
2011-01-05 09:59:49 +00:00
}
2011-01-05 15:14:23 +00:00
$this->menu->addPage($menu);
2011-01-05 09:59:49 +00:00
}
}
}
2011-04-15 09:05:30 +00:00
protected function computePage($pages) {
2011-01-05 15:14:23 +00:00
$computePages = array();
foreach($pages as $page){
$visible = false;
if (array_key_exists('visibleSansPermission', $page)){
$visible = $page['visibleSansPermission'];
//unset($page['visibleSansPermission']);
}
2011-01-05 09:59:49 +00:00
$perm = true;
2011-01-05 15:14:23 +00:00
if (array_key_exists('permission', $page)){
$perm = $this->checkPermission($page['permission']);
//unset($page['permission']);
2011-01-05 09:59:49 +00:00
}
2011-01-05 15:14:23 +00:00
if ($perm){
$computePage = array();
$computePage = $page;
2011-04-15 09:05:30 +00:00
$computePage['params'] = $this->setParams($page['controller'], $page['action']);
2011-01-05 15:14:23 +00:00
$computePages[] = $computePage;
} elseif (!$perm && $visible){
$computePage = array();
$computePage['label'] = $page['label'];
$computePage['uri'] = '#';
$computePages[] = $computePage;
2011-01-05 09:59:49 +00:00
}
}
2011-01-05 15:14:23 +00:00
return $computePages;
2011-01-05 09:59:49 +00:00
}
2011-04-15 09:05:30 +00:00
protected function checkPermission($perm) {
2011-01-05 09:59:49 +00:00
$hasPerm = false;
2011-01-05 15:14:23 +00:00
if (is_array($perm)){
$list = $perm;
} else if (is_string($perm)){
$list = (array)$perm;
}
2011-01-07 17:16:07 +00:00
$auth = Zend_Auth::getInstance();
$droits = $auth->getIdentity()->droits;
2011-01-05 15:14:23 +00:00
foreach($list as $permission){
2011-01-07 17:16:07 +00:00
if (preg_match('/\b'.$permission.'\b/i', $droits)){
2011-01-05 15:14:23 +00:00
$hasPerm = true;
break;
2011-01-05 09:59:49 +00:00
}
}
return $hasPerm;
}
2011-04-15 09:05:30 +00:00
protected function checkModeEdition() {
2011-01-05 15:14:23 +00:00
2011-04-15 09:05:30 +00:00
}
protected function setParams($controller, $action){
$params = array();
switch($controller) {
2011-04-15 10:25:46 +00:00
case 'recherche':
switch($action) {
}
2011-04-19 07:21:06 +00:00
case 'finance':
if (!empty($this->siret)) { $params['siret'] = $this->siret; }
if (!empty($this->id)) { $params['id'] = $this->id; }
break;
2011-04-15 09:05:30 +00:00
case 'identite':
2011-04-19 07:21:06 +00:00
if (!empty($this->siret)) { $params['siret'] = $this->siret; }
if (!empty($this->id)) { $params['id'] = $this->id; }
2011-04-15 09:05:30 +00:00
break;
2011-04-19 06:23:20 +00:00
case 'dirigeant':
2011-04-19 07:21:06 +00:00
if (!empty($this->siret)) { $params['siret'] = $this->siret; }
if (!empty($this->id)) { $params['id'] = $this->id; }
2011-04-19 06:23:20 +00:00
break;
2011-04-15 09:05:30 +00:00
}
return $params;
}
protected function checkParams($controller, $action) {
2011-01-05 09:59:49 +00:00
2011-01-05 15:14:23 +00:00
}
2011-01-05 09:59:49 +00:00
}