Integration menu

This commit is contained in:
Michael RICOIS 2016-04-08 09:25:27 +00:00
parent 962330f1c3
commit 752d405001
11 changed files with 438 additions and 82 deletions

View File

@ -21,6 +21,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$front->setControllerDirectory(array(
'default' => __DIR__ . '/modules/default/controllers',
'file' => __DIR__ . '/modules/file/controllers',
'search' => __DIR__ . '/modules/search/controllers',
));
return $front;
@ -76,9 +77,9 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
//Firebug
$writer = new Zend_Log_Writer_Firebug();
if(APPLICATION_ENV=='production') {
/*if(APPLICATION_ENV=='production') {
$writer->setEnabled(false);
}
}*/
$logger = new Zend_Log($writer);
Zend_Registry::set('firebug', $logger);

View File

@ -1,11 +1,9 @@
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="<?=$this->url(array('controller'=>'index', 'action'=>'index'), 'default', true)?>">Scores & Décisions</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<ul class="nav navbar-nav navbar-right navbar-top-links">
<?php if ($this->MenuEdit !== null) {?>
<li class="dropdown">
<a href="#" class="dropdown-toggle sd-edit" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
@ -14,7 +12,6 @@
</ul>
</li>
<?php }?>
<?php if ($this->print) {?>
<li class="dropdown">
<a href="#" class="dropdown-toggle sd-bgblue" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
@ -33,7 +30,6 @@
</ul>
</li>
<?php }?>
<?php if ($this->MenuSuivi !== null) {?>
<li class="dropdown">
<a href="#" class="dropdown-toggle sd-bgblue" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
@ -52,7 +48,29 @@
</ul>
</li>
<?php }?>
<li class="dropdown">
<a href="#" class="dropdown-toggle sd-bgblue" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-history fa-fw"></i> <span class="hidden-xs hidden-sm">Mon historique</span> <span class="caret"></span></a>
<ul class="dropdown-menu">
<?php if (count($this->UserHisto) > 0) {?>
<?php foreach ($this->UserHisto as $item) {?>
<li><a href="<?=$this->url(array('module'=>'default', 'controller'=>'identite', 'action'=>'fiche',
'siret'=>$item->CompanyId), 'default', true)?>" target="_blank">
<div>
<strong><?=$item->CompanyName?></strong>
</div>
<div class="clearfix">
<small><?=$item->CompanyId?></small>
<span class="text-muted"><small><em><?=$item->Date?></em></small></span></div>
</a>
</li>
<li class="divider"></li>
<?php }?>
<?php }?>
<li><a class="text-center" href="#"><strong>Voir plus</strong> <i class="fa fa-angle-right"></i></a></li>
</ul>
</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle sd-bgblue" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
Outils Métier <span class="caret"></span></a>
@ -60,8 +78,7 @@
<li><a href="/" target="_blank"><div><strong>Extranet</strong></div><div>Données légales</div></a></li>
<li class="divider"></li>
<li><a href="http://ws.scores-decisions.com" target="_blank" title="Web Service API">
<div><strong>WebService</strong></div><div>Web Service API</div>
</a></li>
<div><strong>WebService</strong></div><div>Web Service API</div></a></li>
<li class="divider"></li>
<li><a href="<?=$this->url(array('module'=>'default', 'controller'=>'index', 'action'=>'odea'), 'default', true)?>" target="_blank">
<div><strong>ODEA</strong></div><div>Données et prospection</div></a></li>
@ -107,7 +124,9 @@
</ul>
</div>
<?php echo $this->render('menu.phtml')?>
</div>
<?php if ($this->MenuAdvanced) { ?>
<?php echo $this->render('menu-advanced.phtml')?>
<?php } else {?>
<?php echo $this->render('menu.phtml')?>
<?php }?>
</nav>

View File

@ -1 +1,21 @@
<?php
<div role="navigation" class="navbar-default sidebar">
<div class="sidebar-nav navbar-collapse">
<ul id="side-menu" class="nav in">
<li class="sidebar-head"><strong>Recherche</strong></li>
<?php foreach ($this->navigation()->getContainer() as $page) {?>
<li>
<a href="#" class="<?php if ($page->isActive(true)) { echo 'active'; } ?>"><?=$page->label?>
<?php if ($page->hasPages()) {?><span class="fa arrow"></span><?php }?>
</a>
<?php if ($page->hasPages()) {?>
<ul class="nav nav-second-level collapse" aria-expanded="false" style="height: 0px;">
<?php foreach ( $page->getPages() as $child ) {?>
<li><a class="<?php if ($child->isActive(true)) { echo 'active'; } ?>" href="<?=$child->getHref()?>"><?=$child->label?></a></li>
<?php }?>
</ul>
<?php }?>
</li>
<?php }?>
</ul>
</div>
</div>

View File

@ -0,0 +1,67 @@
<?php
class Application_Controller_Plugin_Histo extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$module = $request->getModuleName();
$controller = $request->getControllerName();
$action = $request->getActionName();
if ($module == 'default' && $controller == 'index' && $action = 'index') {
return;
}
Zend_Registry::get('firebug')->info('PLUGIN HISTO - START');
$siret = $request->getParam('siret');
$layout = Zend_Layout::getMVCInstance();
if ( $layout->isEnabled() ) {
$user = new Scores_Utilisateur();
if ( $user->isLog() ) {
// --- Detecter les changements d'entité pour ne recharger la liste qu'au changement
$session = new Zend_Session_Namespace('histo');
$getLogs = true;
if (count($session->UserHisto) > 0) {
Zend_Registry::get('firebug')->info($session->UserHisto);
$lastHisto = $session->UserHisto[0];
/*if ($lastHisto->CompanyId == $siret) {
$getLogs = false;
}
if ($siret === null) {
$getLogs = false;
}*/
}
// --- Get Log
$view = $layout->getView();
if ($getLogs) {
$view->UserHisto = array();
$ws = new Scores_Ws_Client('gestion', '0.4');
try {
$result = $ws->getUserHistory();
if ($result !== false) {
if (count($result->item) > 0) {
foreach ($result->item as $i) {
$struct = new stdClass();
$struct->CompanyName = $i->CompanyName;
$struct->CompanyId = $i->CompanyId;
$date = new Zend_Date($i->Date);
$struct->Date = $date->toString('dd/MM/yyyy HH:mm:ss');
$view->UserHisto[] = $struct;
}
}
}
Zend_Registry::get('firebug')->info('PLUGIN HISTO - MAJ');
$session->UserHisto = $view->UserHisto;
} catch (Exception $e) {
Zend_Registry::get('firebug')->info($e->getMessage());
}
} else {
$view->UserHisto = $session->UserHisto;
}
}
}
Zend_Registry::get('firebug')->info('PLUGIN HISTO - END');
}
}

View File

@ -7,80 +7,108 @@ class Application_Controller_Plugin_Menu extends Zend_Controller_Plugin_Abstract
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
<<<<<<< Upstream, based on master
Zend_Registry::get('firebug')->info('PLUGIN MENU - START');
$layout = Zend_Layout::getMVCInstance();
$user = new Scores_Utilisateur();
=======
/**
* Définition du menu à afficher par module
* admin => Administration : Liste des utilisateurs, etc
* file => Distribution des fichier + print, pas de navbar
* help => Aide, Faq, Nouveautés
* legal => Identite, Dirigeants, Finance, Juridique, Evaluation, Pieces Officielles, BDF !!!!!
* order => Commandes
* input => Element de saisie, pas de navbar
* search => Formulaire de recherche
* user => Paramètres, Portefeuille, Surveillances
*/
>>>>>>> 489b002 Integration menu
$module = $request->getModuleName();
$controller = $request->getControllerName();
$action = $request->getActionName();
if ( $user->isLog() && $layout->isEnabled() && $controller != 'print' ) {
/**
* Définition du menu à afficher par module
* admin => Administration : Liste des utilisateurs, etc
* file => Distribution des fichier, pas de navbar
* help => Aide, Faq, Nouveautés
* legal => Identite, Dirigeants, Finance, Juridique, Evaluation, Pieces Officielles, BDF !!!!!
* order => Commandes
* user => Paramètres, Portefeuille, Surveillances
* saisie => Element de saisie pas de navbar
* search => Formulaire de recherche
*/
// --- Override SIRET to complete with zero by left
$siret = $request->getParam('siret');
if ( intval($siret)>100 ) {
$request->setParam('siret', str_pad($siret, 9, '0', STR_PAD_LEFT));
}
// --- Génération du menu
$computeMenu = new Scores_Menu($request->getParams());
$menu = $computeMenu->getMenu();
$view = $layout->getView();
$view->navigation($menu);
// --- Identifiant Menu
$view->menuId = $computeMenu->getIdMenu($controller, $action);
// --- Page Access
$hasPerm = true;
$permPage = $computeMenu->getPagePermission($controller, $action);
if ( !empty($permPage) ) {
$hasPerm = false;
if (is_array($permPage)){
$list = $permPage;
} else if (is_string($permPage)){
$list = (array)$permPage;
}
foreach($list as $permission){
if ($user->checkPerm($permission)){
$hasPerm = true;
break;
}
}
}
if ( !$hasPerm ) {
$request->setModuleName('default')->setControllerName('error')->setActionName('perms');
} else {
//Gestion affichage Lien Print / PDF / XML
$page = new Scores_Export_Print($controller, $action);
if ($page->exportable('print')){
$view->print = $page->filename('print', $request->getParams());
}
if ($page->exportable('pdf')){
$view->pdf = $page->filename('pdf', $request->getParams());
}
if ($page->exportable('xml') && in_array($user->getIdClient(), array(1,147)) ){
$view->xml = $page->filename('xml', $request->getParams());
}
}
$module = $request->getModuleName();
$controller = $request->getControllerName();
$action = $request->getActionName();
if ($module == 'default' && $controller == 'index' && $action = 'index') {
return;
}
<<<<<<< Upstream, based on master
=======
Zend_Registry::get('firebug')->info('PLUGIN MENU - START');
$layout = Zend_Layout::getMVCInstance();
if ($layout->isEnabled() && $controller != 'print' ) {
$user = new Scores_Utilisateur();
if ($user->isLog()) {
switch ($module) {
case 'search':
$view = $layout->getView();
$view->MenuAdvanced = true;
$config = include APPLICATION_PATH . '/configs/menu.search.php';
$container = new Zend_Navigation($config);
$view->navigation($container);
$view->headLink()
->appendStylesheet('/libs/metisMenu/metisMenu.css', 'all');
$view->headScript()
->appendFile('/libs/metisMenu/metisMenu.js', 'text/javascript');
break;
default:
// --- Override SIRET to complete with zero by left
$siret = $request->getParam('siret');
if ( intval($siret)>100 ) {
$request->setParam('siret', str_pad($siret, 9, '0', STR_PAD_LEFT));
}
// --- Génération du menu
$computeMenu = new Scores_Menu($request->getParams());
$menu = $computeMenu->getMenu();
$view = $layout->getView();
$view->navigation($menu);
// --- Identifiant Menu
$view->menuId = $computeMenu->getIdMenu($controller, $action);
// --- Page Access
$hasPerm = true;
$permPage = $computeMenu->getPagePermission($controller, $action);
if ( !empty($permPage) ) {
$hasPerm = false;
if (is_array($permPage)){
$list = $permPage;
} else if (is_string($permPage)){
$list = (array)$permPage;
}
foreach($list as $permission){
if ($user->checkPerm($permission)){
$hasPerm = true;
break;
}
}
}
if ( !$hasPerm ) {
$request->setModuleName('default')->setControllerName('error')->setActionName('perms');
} else {
//Gestion affichage Lien Print / PDF / XML
$page = new Scores_Export_Print($controller, $action);
if ($page->exportable('print')){
$view->print = $page->filename('print', $request->getParams());
}
if ($page->exportable('pdf')){
$view->pdf = $page->filename('pdf', $request->getParams());
}
if ($page->exportable('xml') && in_array($user->getIdClient(), array(1,147)) ){
$view->xml = $page->filename('xml', $request->getParams());
}
}
break;
}
}
}
>>>>>>> 489b002 Integration menu
Zend_Registry::get('firebug')->info('PLUGIN MENU - END');
}
}

View File

@ -42,6 +42,9 @@ return array(
'getServices' => null,
'getUser' => null,
'getUserEmail' => null,
'getUserHistory' => array(
'debug' => true,
),
'getUsers' => null,
'loginAuthenticate' => null,
'setCGU' => null,

View File

@ -5,7 +5,7 @@ defined('APPLICATION_PATH')
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));
// --- Composer autoload
require_once realpath(__DIR__ . '/../vendor/autoload.php');

View File

@ -0,0 +1,56 @@
.arrow {
float: right;
line-height: 1.42857;
}
.glyphicon.arrow:before {
content: "\e079";
}
.active > a > .glyphicon.arrow:before {
content: "\e114";
}
/*
* Require Font-Awesome
* http://fortawesome.github.io/Font-Awesome/
*/
.fa.arrow:before {
content: "\f104";
}
.active > a > .fa.arrow:before {
content: "\f107";
}
.plus-times {
float: right;
}
.fa.plus-times:before {
content: "\f067";
}
.active > a > .fa.plus-times {
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
.plus-minus {
float: right;
}
.fa.plus-minus:before {
content: "\f067";
}
.active > a > .fa.plus-minus:before {
content: "\f068";
}

View File

@ -0,0 +1,112 @@
;(function($, window, document, undefined) {
var pluginName = "metisMenu",
defaults = {
toggle: true,
doubleTapToGo: false
};
function Plugin(element, options) {
this.element = $(element);
this.settings = $.extend({}, defaults, options);
this._defaults = defaults;
this._name = pluginName;
this.init();
}
Plugin.prototype = {
init: function() {
var $this = this.element,
$toggle = this.settings.toggle,
obj = this;
if (this.isIE() <= 9) {
$this.find("li.active").has("ul").children("ul").collapse("show");
$this.find("li").not(".active").has("ul").children("ul").collapse("hide");
} else {
$this.find("li.active").has("ul").children("ul").addClass("collapse in");
$this.find("li").not(".active").has("ul").children("ul").addClass("collapse");
}
//add the "doubleTapToGo" class to active items if needed
if (obj.settings.doubleTapToGo) {
$this.find("li.active").has("ul").children("a").addClass("doubleTapToGo");
}
$this.find("li").has("ul").children("a").on("click" + "." + pluginName, function(e) {
e.preventDefault();
//Do we need to enable the double tap
if (obj.settings.doubleTapToGo) {
//if we hit a second time on the link and the href is valid, navigate to that url
if (obj.doubleTapToGo($(this)) && $(this).attr("href") !== "#" && $(this).attr("href") !== "") {
e.stopPropagation();
document.location = $(this).attr("href");
return;
}
}
$(this).parent("li").toggleClass("active").children("ul").collapse("toggle");
if ($toggle) {
$(this).parent("li").siblings().removeClass("active").children("ul.in").collapse("hide");
}
});
},
isIE: function() { //https://gist.github.com/padolsey/527683
var undef,
v = 3,
div = document.createElement("div"),
all = div.getElementsByTagName("i");
while (
div.innerHTML = "<!--[if gt IE " + (++v) + "]><i></i><![endif]-->",
all[0]
) {
return v > 4 ? v : undef;
}
},
//Enable the link on the second click.
doubleTapToGo: function(elem) {
var $this = this.element;
//if the class "doubleTapToGo" exists, remove it and return
if (elem.hasClass("doubleTapToGo")) {
elem.removeClass("doubleTapToGo");
return true;
}
//does not exists, add a new class and return false
if (elem.parent().children("ul").length) {
//first remove all other class
$this.find(".doubleTapToGo").removeClass("doubleTapToGo");
//add the class on the current element
elem.addClass("doubleTapToGo");
return false;
}
},
remove: function() {
this.element.off("." + pluginName);
this.element.removeData(pluginName);
}
};
$.fn[pluginName] = function(options) {
this.each(function () {
var el = $(this);
if (el.data(pluginName)) {
el.data(pluginName).remove();
}
el.data(pluginName, new Plugin(this, options));
});
return this;
};
})(jQuery, window, document);

View File

@ -9,6 +9,14 @@ $(function() {
$("#page-wrap").css("min-height", (height) + "px");
}
});
$('#side-menu').metisMenu();
var url = window.location;
var element = $('ul.nav a').filter(function() {
return this.href == url || url.href.indexOf(this.href) == 0;
}).addClass('active').parent().parent().addClass('in').parent();
if (element.is('li')) {
element.addClass('active');
}
$('img.flag').on('click', function() {
var url = window.location.href;

View File

@ -30,7 +30,7 @@ body {
/* Not required for template or sticky footer method. */
.container .credit {
font-size: 12px;
margin: 16px 0;
margin: 16px 0 0 250px;
}
#footer > .container {
@ -64,6 +64,7 @@ body {
border-bottom: 1px solid #e7e7e7;
}
/*
@media(min-width:768px) {
#page-wrap {
position: inherit;
@ -71,6 +72,13 @@ body {
padding: 0 30px;
border-left: 1px solid #e7e7e7;
}
}*/
#page-wrap {
position: inherit;
margin: 0 0 0 250px;
/*padding: 0 30px;*/
border-left: 1px solid #e7e7e7;
}
#global {width:970px; margin:0 auto 15px; text-align:left;}
@ -152,6 +160,40 @@ img {vertical-align:middle;}
color: #ffffff;
}
.navbar-top-links {
margin-right: 0;
}
.sidebar {
margin-top: 1px;
position: absolute;
width: 250px;
z-index: 1;
}
.sidebar .sidebar-head {
padding: 15px;
color: #fff;
background-color: #1a5c7d;
}
.sidebar ul li {
border-bottom: 1px solid #e7e7e7;
}
.sidebar ul li a.active {
background-color: #eee;
}
.sidebar .sidebar-nav.navbar-collapse {
padding-left: 0;
padding-right: 0;
}
.sidebar .arrow {
float: right;
}
/* Menu
----------------------------------*/
div#menu {position: absolute; width: 230px;}