tools_sm.ctp 6.61 KB
<?php

// Variables passées par le controleur
$role = $role;




//global $verb;
$CAN_MANAGE=false;
$title = '';
if (in_array($role, [
    //'Administration',
    //'Administration Plus',
    'Super Administrateur'
])) {
    $title = "Gérer le contenu variable de l'application";
    //$verb = 'Gérer';
    $CAN_MANAGE=true;
}
else {
    $title = "Voir les autres listes";
    //$verb = 'Voir';
}


// Elements that the "Administration" profile can manage (and not only view)
$admin_can_manage = array(
    'sur_categories',
    'type_documents',
    'fournisseurs',
    'groupes_thematiques',
    'groupes_metiers',
    'organismes',
    //"unites",
    //"formules",
    'projets',
    'sites',
    'type_suivis',
)

?>


<div class="index">
	<h2>
		<i class="icon-wrench"></i>
		<!-- 
		Gérer le contenu variable de l'application
		-->
		<?= $title; ?>
	</h2>
	<table style="border-collapse: separate; border-spacing: 0; width: 270px;">
	
		<tr>
			<th colspan=2></th>
		</tr>


<?php

/* moved to View/Helper
function echo_list($html, $list_name, $controller_name, $action_name='index', $changed_verb='') {
//function echo_list($html, $verb, $list_name, $controller_name, $action_name) {
    global $verb;
    $local_verb = $verb;
    if ($changed_verb != '') $local_verb = $changed_verb;
    //if ($role == 'Administration' && in_array($controller_name,$admin_can_manage)) $verb = 'Gérer';
    echo '<tr><td>';
    //echo $this->Html->link('Gérer les Catégories', [
    echo $html->link($local_verb . ' les ' . $list_name, [
    'controller' => $controller_name,
    // default action is 'index'
    'action' => $action_name,
    'sort' => 'nom'
    ]);
    echo '</td></tr>';
}
*/


//echo_list($this->Html, 'Catégories', 'categories');
//echo_list($this->Html, 'Catégories', 'pages', 'tools_cat');
$entity_name = 'sur_categories';
$can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) );
$this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, 'Domaines & Catégories', $entity_name);

    
/*
echo '<tr><td>';
//echo $this->Html->link('Gérer les Catégories', [
echo $this->Html->link($verb . ' les Catégories', [
    'controller' => 'pages',
    'action' => 'tools_cat'
]);
echo '</td></tr>';
*/


// types de DOCUMENTS
$entity_name = 'type_documents';
$can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) );
$this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, 'types de Documents', $entity_name);
/*
 echo '<tr><td>';
 echo $this->Html->link('Gérer les types de Documents', [
 'controller' => 'type_documents',
 'sort' => 'nom'
 ]);
 echo '</td></tr>';
*/


// FOURNISSEURS
$entity_name = 'fournisseurs';
$can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) ); 
$this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, 'Fournisseurs', $entity_name, 'index');

/*
 echo '<tr><td>';
 echo $this->Html->link('Gérer les Fournisseurs', [
 'controller' => 'fournisseurs',
 'sort' => 'nom'
 ]);
 echo '</td></tr>';
 */


// GROUPES métier & thématique
foreach (['metier','thematique'] as $group_type) {
    //$names = explode(" ", $configuration->nom_groupe_thematique);
    $group_type_name = 'nom_groupe_'.$group_type;
    $names = explode(" ", $configuration->$group_type_name);
    if (isset($names[1])) {
        $nom = $names[0] . 's ' . $names[1] . 's';
    } else {
        $nom = $names[0] . 's';
    }
    //$this->MyHelper->echoListToManageOrViewWithIcon($this->Html, $nom, 'groupes_thematiques');
    //$this->MyHelper->echoListToManageOrViewWithIcon($CAN_MANAGE, $nom, 'groupes_'.$group_type.'s');
    $entity_name = 'groupes_'.$group_type.'s';
    $can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) );
    $this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, $nom, $entity_name, 'index');
    /*
     echo '<tr><td>';
     echo $this->Html->link('Gérer les ' . $nom, [
     'controller' => 'groupes_thematiques',
     'sort' => 'nom'
     ]);
     echo '</td></tr>';
     */
}

//$configuration->metrologie=true;
// METROLOGIE MODULE ONLY
if ($configuration->metrologie) {
    
    $this->MyHelper->echoListToManageOrViewWithIcon($CAN_MANAGE, 'Métrologie : Unités', 'unites');
    /*
     echo '<tr><td>';
     echo $this->Html->link('Gérer les Unités (Métrologie)', [
     'controller' => 'unites',
     'sort' => 'nom'
     ]);
     echo '</td></tr>';
     */
    
    $this->MyHelper->echoListToManageOrViewWithIcon($CAN_MANAGE, 'Métrologie : Formules', 'formules');
    /*
     echo '<tr><td>';
     echo $this->Html->link('Gérer les Formules (Métrologie)', [
     'controller' => 'formules',
     'sort' => 'nom'
     ]);
     echo '</td></tr>';
     */
}


// ORGANISMES
//$this->MyHelper->echoListToManageOrViewWithIcon($CAN_MANAGE, 'Organismes', 'organismes');
$entity_name = 'organismes';
$can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) );
$this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, 'Organismes', $entity_name);

/*
echo '<tr><td>';
echo $this->Html->link('Gérer les Organismes', [
    'controller' => 'organismes',
    'sort' => 'nom'
]);
echo '</td></tr>';
*/

//$this->MyHelper->echoListToManageOrViewWithIcon($CAN_MANAGE, 'Projets', 'projets');
$entity_name = 'projets';
$can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) );
$this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, 'Projets', $entity_name, 'index');


//$this->MyHelper->echoListToManageOrViewWithIcon($CAN_MANAGE, 'Sites', 'sites');
$entity_name = 'sites';
$can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) );
$this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, 'Sites', $entity_name, 'index');
/*
echo '<tr><td>';
echo $this->Html->link('Gérer les Sites', [
    'controller' => 'sites',
    'sort' => 'nom',
    //'action' => 'index',
]);
echo '</td></tr>';
*/


//$this->MyHelper->echoListToManageOrViewWithIcon($CAN_MANAGE, 'types de Suivis', 'type_suivis');
$entity_name = 'type_suivis';
$can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) );
$this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, 'types de Suivis', $entity_name, 'index');
/*
echo '<tr><td>';
echo $this->Html->link('Gérer les types de Suivis', [
    'controller' => 'type_suivis',
    'sort' => 'nom'
]);
echo '</td></tr>';
*/




?>
	</table>
</div>

<!--
<div class="actions">
	<php echo $this->element('menu') ?>
</div>
-->