| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 
 | <?php
/**
*/
 
require_once ('conf.inc.php') ;
require_once ('user.class.php') ;
 
/** Class of HTMLUtilsStatic utilities */
class OutputUtils {
 
	/** Static array for page information storage */
	private static $PAGES_ARRAY = array (
	0 => array('title' => 'Demandes d\'achat', 'desc' => '', 'order' => '0', 'menu' => TRUE, 'entity' => 'application', 'sub' => array (
			0 => array(	'title' => 'Liste',			'desc' => 'Liste des demandes d\'achat',
						'rights' => 'r', 'menu' => TRUE, 'href' => 'application.php?list'),
			1 => array(	'title' => 'Saisie',		'desc' => 'Saisie d\'une demande d\'achat',
						'rights' => 'i', 'menu' => TRUE, 'href' => 'application.php?insert'),
			2 => array(	'title' => 'Modification',	'desc' => 'Modification d\'une demande d\'achat',
						'rights' => 'w', 'menu' => FALSE, 'href' => ''),
			3 => array(	'title' => 'Suppression',	'desc' => 'Suppression d\'une demande d\'achat',
						'rights' => 'w', 'menu' => FALSE, 'href' => ''),
			4 => array(	'title' => 'Détails',		'desc' => 'Détails de la demande d\'achat',
						'rights' => 'r', 'menu' => FALSE, 'href' => '')
		)),
	1 => array('title' => 'Contrats', 'desc' => '', 'order' => '0', 'menu' => TRUE, 'entity' => 'contract', 'sub' => array (
			0 => array(	'title' => 'Régie',			'desc' => 'Liste des contrats',
						'rights' => 'r', 'menu' => TRUE, 'href' => 'contract.php?list=1'),
			1 => array(	'title' => 'Forfait',		'desc' => 'Liste des contrats',
						'rights' => 'r', 'menu' => TRUE, 'href' => 'contract.php?list=2'),
			2 => array(	'title' => 'Maintenance',	'desc' => 'Liste des contrats',
						'rights' => 'r', 'menu' => TRUE, 'href' => 'contract.php?list=3'),
			3 => array(	'title' => 'Saisie',		'desc' => 'Saisie d\'un contrat',
						'rights' => 'i', 'menu' => TRUE, 'href' => 'contract.php?insert'),
			4 => array(	'title' => 'Modification',	'desc' => 'Modification d\'un contrat',
						'rights' => 'w', 'menu' => FALSE, 'href' => ''),
			5 => array(	'title' => 'Suppression',	'desc' => 'Suppression d\'un contrat',
						'rights' => 'w', 'menu' => FALSE, 'href' => ''),
			6 => array(	'title' => 'Détails',		'desc' => 'Détails du contrat',
						'rights' => 'r', 'menu' => FALSE, 'href' => ''),
			7 => array(	'title' => 'Avenant',		'desc' => 'Passage Ã* l\'avenant',
						'rights' => 'r', 'menu' => FALSE, 'href' => '')
		)),
	2 => array('title' => 'Factures', 'desc' => '', 'order' => '0', 'menu' => TRUE, 'entity' => 'invoice', 'sub' => array (
			0 => array(	'title' => 'Régie',	'desc' => 'Liste des factures',
						'role' => ROLE_ACCOUNTING, 'rights' => 'r', 'menu' => TRUE, 'href' => 'invoice.php?list=manday'),
			1 => array(	'title' => 'Autres',		'desc' => 'Liste des factures',
						'role' => ROLE_ACCOUNTING, 'rights' => 'r', 'menu' => TRUE, 'href' => 'invoice.php?list=other'),
			3 => array(	'title' => 'Modification',	'desc' => 'Modification d\'une facture',
						'rights' => 'w', 'menu' => FALSE, 'href' => ''),
			4 => array(	'title' => 'Suppression',	'desc' => 'Suppression d\'une facture',
						'rights' => 'w', 'menu' => FALSE, 'href' => ''),
			5 => array(	'title' => 'Emargement',	'desc' => 'Associer une facture',
						'rights' => 'w', 'menu' => FALSE, 'href' => ''),
			6 => array(	'title' => 'Régie',	'desc' => 'Liste des factures',
						'role' => ROLE_SECRETARY, 'rights' => 'r', 'menu' => TRUE, 'href' => 'invoice.php?list=manday'),
			7 => array(	'title' => 'Forfait',		'desc' => 'Liste des factures',
						'role' => ROLE_SECRETARY, 'rights' => 'r', 'menu' => TRUE, 'href' => 'invoice.php?list=package'),
			8 => array(	'title' => 'Maintenance',	'desc' => 'Liste des factures',
						'role' => ROLE_SECRETARY, 'rights' => 'r', 'menu' => TRUE, 'href' => 'invoice.php?list=maintenance'),
			9 => array(	'title' => 'Autres',		'desc' => 'Liste des factures',
						'role' => ROLE_SECRETARY, 'rights' => 'r', 'menu' => TRUE, 'href' => 'invoice.php?list=other'),
			2 => array(	'title' => 'Saisie',		'desc' => 'Saisie d\'une facture',
						'rights' => 'i', 'menu' => TRUE, 'href' => 'invoice.php?insert'),
			10 => array('title' => 'Détails',		'desc' => 'Détails de la facture',
						'rights' => 'r',			'menu' => FALSE, 'href' => '')
		)),
	3 => array('title' => 'Sociétés', 'desc' => '', 'order' => '0', 'menu' => TRUE, 'entity' => 'company', 'sub' => array (
			0 => array(	'title' => 'Liste',			'desc' => 'Liste des sociétés',
						'rights' => 'r', 'menu' => TRUE, 'href' => 'company.php?list'),
			1 => array(	'title' => 'Saisie',		'desc' => 'Saisie d\'une société',
						'rights' => 'i', 'menu' => TRUE, 'href' => 'company.php?insert'),
			2 => array(	'title' => 'Modification',	'desc' => 'Modification d\'une société',
						'rights' => 'w', 'menu' => FALSE, 'href' => ''),
			3 => array(	'title' => 'Suppression',	'desc' => 'Suppression d\'une société',
						'rights' => 'w', 'menu' => FALSE, 'href' => ''),
			4 => array(	'title' => 'Détails',		'desc' => 'Détails de la société',
						'rights' => 'r', 'menu' => FALSE, 'href' => '')
		)),
	4 => array('title' => 'Produits', 'desc' => '', 'order' => '0', 'menu' => TRUE, 'entity' => 'product', 'sub' => array (
			0 => array(	'title' => 'Liste',			'desc' => 'Liste des produits',
						'rights' => 'r', 'menu' => TRUE, 'href' => 'product.php?list'),
			1 => array(	'title' => 'Saisie',		'desc' => 'Saisie d\'un produit',
						'rights' => 'i', 'menu' => TRUE, 'href' => 'product.php?insert'),
			2 => array(	'title' => 'Modification',	'desc' => 'Modification d\'un produit',
						'rights' => 'w', 'menu' => FALSE, 'href' => ''),
			3 => array(	'title' => 'Suppression',	'desc' => 'Suppression d\'un produit',
						'rights' => 'w', 'menu' => FALSE, 'href' => '')
		)),
	5 => array('title' => 'Bienvenue', 'desc' => 'Accueil', 'order' => '0', 'menu' => FALSE, 'href' => 'index.php'),
	6 => array('title' => 'Utilisateurs', 'desc' => '', 'order' => '0', 'menu' => TRUE, 'entity' => 'user', 'sub' => array (
			0 => array(	'title' => 'Liste',			'desc' => 'Liste des utilisateurs',
						'rights' => 'r', 'menu' => TRUE, 'href' => 'user.php?list'),
			1 => array(	'title' => 'Saisie',		'desc' => 'Saisie d\'un utilisateur',
						'rights' => 'i', 'menu' => TRUE, 'href' => 'user.php?insert'),
			2 => array(	'title' => 'Modification',	'desc' => 'Modification d\'un utilisateur',
						'rights' => 'w', 'menu' => FALSE, 'href' => ''),
			3 => array(	'title' => 'Suppression',	'desc' => 'Suppression d\'un utilisateur',
						'rights' => 'w', 'menu' => FALSE, 'href' => ''),
			4 => array(	'title' => 'Login',			'desc' => 'Identification',
						'rights' => 'a', 'menu' => FALSE, 'href' => ''),
			5 => array(	'title' => 'Logout',		'desc' => 'Se déconnecter',
						'rights' => 'a', 'menu' => FALSE, 'href' => ''),
			6 => array(	'title' => 'Journaux d\'accès',	'desc' => 'Journaux d\'accès',
						'rights' => 'w', 'menu' => TRUE, 'href' => 'user.php?logs'),
			7 => array(	'title' => 'Purge',	'desc' => 'Purge des journaux d\'accès',
						'rights' => 'w', 'menu' => FALSE, 'href' => '')
		)),
	7 => array('title' => 'Lignes budgétaires', 'desc' => '', 'order' => '0', 'menu' => TRUE, 'entity' => 'budgetline', 'sub' => array (
			0 => array(	'title' => 'Liste',			'desc' => 'Liste des lignes budgétaires',
						'rights' => 'r', 'menu' => TRUE, 'href' => 'budgetline.php?list'),
			1 => array(	'title' => 'Saisie',		'desc' => 'Saisie d\'une lignes budgétaire',
						'rights' => 'i', 'menu' => TRUE, 'href' => 'budgetline.php?insert'),
			2 => array(	'title' => 'Modification',	'desc' => 'Modification d\'une lignes budgétaire',
						'rights' => 'w', 'menu' => FALSE, 'href' => ''),
			3 => array(	'title' => 'Suppression',	'desc' => 'Suppression d\'une lignes budgétaire',
						'rights' => 'w', 'menu' => FALSE, 'href' => '')
		)),
	8 => array('title' => 'Pilotage', 'desc' => '', 'order' => '0', 'menu' => TRUE, 'entity' => 'management', 'sub' => array (
			0 => array(	'title' => 'Lignes budgétaires','desc' => 'Liste des lignes budgétaires',
						'rights' => 'r', 'menu' => TRUE, 'href' => 'management.php?bl'),
			1 => array(	'title' => 'Centres analytiques','desc' => 'Liste des centres analytiques',
						'rights' => 'i', 'menu' => TRUE, 'href' => 'management.php?ca')
		))
	) ;
 
	public static function displayLeftMenu($page, $subPage)
	{
		$o = '<ul id="left-menu">' ;
		if (!isset($_SESSION['login']))
			$o .= '<li><div>Accueil</div><ul class="left-sub-menu"><li><a href="user.php?login">Identification</a></li></ul></li>' ;
 
		foreach (OutputUtils::$PAGES_ARRAY as $key => $mpage)
		{
			if (!$mpage['menu'])
				continue ;
 
			$sel = ($key == $page) ? ' class="selected"' : '' ;
 
			$o2 = '<li'.$sel.'><div>'.$mpage['title'].'</div>' ;
			$o3 = '' ;
 
			if (count($mpage['sub']))
			{
				$i = 0 ;
				$o3 .= '<ul class="left-sub-menu">' ;
				foreach ($mpage['sub'] as $skey => $spage)
				{
					if (isset($mpage['entity']) && $spage['rights'] != 'a' &&
						!$_SESSION['rights']['entity'][$mpage['entity']]['rights'][$spage['rights']])
						continue ;
 
					if (isset($spage['role']) && $spage['role'] != $_SESSION['rights']['role'])
						continue ;
 
					if (!$spage['menu'])
						continue ;
 
					$sel = (($skey == $subPage) && ($key == $page)) ? ' class="selected"' : '' ;
 
					$o3 .= '<li'.$sel.'><a href="'.$spage['href'].'">'.$spage['title'].'</a></li>' ;
					$i++ ;
				}
				$o3 .= '</ul>' ;
			}
 
			if ($i)
				$o .= $o2.$o3.'</li>';
		}
 
		echo $o .= '</ul>' ;
	}
 
	public static function startSession()
	{
		session_start() ;
 
		if (!isset($_SESSION['login']) && isset($_COOKIE[COOKIE_NAME]) && !empty($_COOKIE[COOKIE_NAME]))
		{
			$dbh = dbConnect() ;
			$u = new User($dbh) ;
			$u->cookieLogin($_COOKIE[COOKIE_NAME]) ;
		}
	}
 
	public static function displayHeader($page, $subPage = -1, $title = '')
	{
		global $CURRENT_TITLE, $ROLE_TYPES ;
 
		$ariane = 'Vous êtes ici : <a href="/engagements/">Accueil</a>' ;
 
		$title = 'Engagements / ' ;
 
		if ($subPage == -1)
		{
			$CURRENT_TITLE = OutputUtils::$PAGES_ARRAY[$page]['title'] ;
			$title .=	$CURRENT_TITLE ;
			$desc =		OutputUtils::$PAGES_ARRAY[$page]['desc'] ;
 
			$ariane .= ' <img src="img/icons/arrow.gif" alt="»"/> <a href="'.OutputUtils::$PAGES_ARRAY[$page]['href'].'">'.OutputUtils::$PAGES_ARRAY[$page]['title'].'</a>' ;
		}
		else
		{
			$CURRENT_TITLE = OutputUtils::$PAGES_ARRAY[$page]['title'].' » '.
						OutputUtils::$PAGES_ARRAY[$page]['sub'][$subPage]['title'] ;
 
			$title .= $CURRENT_TITLE ;
 
			$ariane .=	' <img src="img/icons/arrow.gif" alt="»"/> <a href="'.OutputUtils::$PAGES_ARRAY[$page]['href'].'">'.OutputUtils::$PAGES_ARRAY[$page]['title'].'</a>'.
						' <img src="img/icons/arrow.gif" alt="»"/> <a href="'.OutputUtils::$PAGES_ARRAY[$page]['sub'][$subPage]['href'].'">'.OutputUtils::$PAGES_ARRAY[$page]['sub'][$subPage]['title'].'</a>' ;
 
			$desc = 	OutputUtils::$PAGES_ARRAY[$page]['sub'][$subPage]['desc'] ;
		}
 
		if (isset($_SESSION['login']) && !empty($_SESSION['login']))
		{
			$loginBox = '<div id="login-box"><div>'.$ROLE_TYPES[$_SESSION['rights']['role']]['name'].'</div><img src="img/icons/user.gif" alt=""/> '.$_SESSION['firstname'].' '.$_SESSION['lastname'].'<br/><a href="user.php?logout"><img src="img/icons/exit.gif" alt=""/> Déconnexion</a></div>' ;
 
			if (count($_SESSION['historic']))
			{
				$a = array_reverse($_SESSION['historic']);
				$historic = '<a href="'.$a[0][1].'"><img src="img/icons/back.gif" alt="<" /> Retour</a> <select id="histo-back" onchange="javascript:document.location=this.options[this.selectedIndex].value;">' ;
				foreach ($a as $h)
					$historic .= '<option value="'.$h[1].'">'.$h[0].'</option>' ;
				$historic .= '</select>' ;
			}
			else
				$historic = '' ;
		}
		else
		{
			$historic = '' ;
			$loginBox = '<div id="login-box"><a href="user.php?login"><img src="img/icons/enter.gif" alt=""/> S\'identifier</a></div>' ;
		}
 
		header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
		header('Cache-Control: no-cache');
		header('Pragma: no-cache');
 
	?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html	xmlns="http://www.w3.org/1999/xhtml"
		xml:lang="en" >
<head>
	<title><?php echo $title ?></title>
 
	<meta name="description" content="<?php echo $desc ?>" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="expires" content="0" />
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache, must-revalidate" />
 
	<link href="style/design.css" rel="stylesheet" type="text/css" />
	<link href="img/favicon.png" rel="icon" type="image/png" />
 
	<script type="text/javascript" src="js/calendar.js"></script>
	<script type="text/javascript" src="js/prototype.js"></script>
	<script type="text/javascript" src="js/common.js"></script>
 
	<!-- Scriptaculous -->
	<script type="text/javascript" src="js/scriptaculous/scriptaculous.js"></script>
	<script type="text/javascript" src="js/scriptaculous/controls.js"></script>
	<script type="text/javascript" src="js/scriptaculous/effects.js"></script>
	<script type="text/javascript" src="js/scriptaculous/builder.js"></script>
</head>
<body>
<table id="container">
	<tr><td id="header" colspan="2"><?php echo $loginBox ?><div style="float:left;"><img src="img/logo-sg.png" alt="SGCF"/> <a href="/engagements/" id="title">Suivi des engagements</a></div>
	</td></tr>
	<tr><td id="sub-header" colspan="2"><div style="float:left;"><?php echo $ariane ?></div><div id="historic"><?php echo $historic ?></div></td></tr>
	<tr><td id="left-column"><br/><div><?php OutputUtils::displayLeftMenu($page, $subPage) ?></div></td>
	<td id="right-column">
	<h1><?php echo $desc ?></h1>
 
	<?php
	}
 
	public static function displayFooter()
	{
	?>
	</td></tr>
</table>
<div id="footer">COPYRIGHT © 2008 SGCF</div>
</body>
</html>
	<?php
	}
 
	public static function renderHTMLErrors($errors)
	{
		$o = '<div class="error">' ;
 
		foreach($errors as $err)
			$o .= $err[1].'<br/>' ;
 
		echo $o . '</div>' ;
	}
 
	public static function renderJSONErrors($errors)
	{
		echo json_encode($errors);
	}
}
 
OutputUtils::startSession() ;
 
?> | 
Partager