index_groups.ctp 3.8 KB
<?php 
// Variables passées par le controleur
$CAN_ADD = $CAN_ADD;
/*
$group_type1 = 'thematique';
$group_type2 = 'thématique';
$group_type1 = 'metier';
$group_type2 = 'métier';
*/
$group_type1 = $group_type1;
$group_type2 = $group_type2;
$lab_website_url = $lab_website_url;
$groups = $groups;
?>

<!-- 
<div class="groupesThematiques index">
 -->
<div class="groups index">

	<?php
	// Nom du groupe au pluriel (chaque mot)
	//echo '<h2><i class="icon-list"></i> Liste des '.$configuration->nom_groupe_thematique.'s</h2>';
	$group_type_name = $configuration->{'nom_groupe_'.$group_type1};
	$words = explode(' ',$group_type_name);
	$group_type_name_plural = '';
	foreach($words as $word) $group_type_name_plural .= $word.'s ';
	$group_type_name_plural = ucwords($group_type_name_plural);
	echo "<h2><i class='icon-list'></i> Liste des $group_type_name_plural</h2>";
	
	// Si une url est donnée vers la page des Groupes thématiques sur le site web du labo, on l'affiche
	if ($lab_website_url)
	    echo "=> <a href=$lab_website_url>Groupes {$group_type2}s sur le site web du laboratoire</a><br/><br/>";

    if ($CAN_ADD) echo $this->element('button_add'); 
    ?>

    <table style="border-collapse: separate; border-spacing: 0; width: 270px;">
		
		<thead>
			<tr>
				<th class="actions"><?= __('') ?></th>
				<!-- Pas de tri sur les colonnes, inutile
				<th><= $this->Paginator->sort('nom', 'Nom') ?></th>
				<th><= $this->Paginator->sort('description', 'Description') ?></th>
				 -->
				<th>Nom</th>
				<th>Description</th>
			</tr>
		</thead>
		
		<tbody>
            <?php
            foreach ($groups as $group) :
                //if ($group->nom != 'N/A') {
                if ($group->id) {
                    ?>
                    <tr>
                    
        				<td class="actions" style="padding: 6px 0; text-align: left;">  
                            <?php 
                            if (in_array($role, ['Administration Plus', 'Super Administrateur']))
                                echo $this->Html->link(__('<i class="icon-pencil"></i>'), ['action' => 'edit', $group->id], ['title' => 'Editer', 'style' => 'margin: 0 2px', 'escape' => false ]);
                            if (in_array($role, ['Super Administrateur']))
                                echo $this->Form->postLink(__('<i class="icon-trash"></i>'), ['action' => 'delete', $group->id], ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer ce groupe ?', $group->id)]);
                                //echo $this->Form->postLink(__('<i class="icon-trash"></i>'), ['action' => 'delete', $group->id], ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $group->id)]);
                            ?>
                        </td>
        
        				<td class="smallText"><?= $this->Html->link($group->nom, ['action' => 'view', $group->id]) ?></td>
        				
        				<?php
        				// On n'affiche que la 1ère ligne de la description
        				//$group->description = null;
        				$description_first_line = explode("\n", $group->description)[0];
        				//debug($description_short);
        				//$description_short = $description_short[0];
        				?>
        				<td class="smallText"><?=h($description_first_line)?></td>
        				
        			</tr>
            		<?php
                } // if
            endforeach;
            ?>
        </tbody>
        
	</table>

	<?php
	// Inutile
	//echo $this->element('pagination'); 
	?> 
    
</div>

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

echo $this->element('menu_index', [
    'pluralHumanName' => $configuration->nom_groupe_thematique . 's',
    'singularHumanName' => $configuration->nom_groupe_thematique
])?>
		</div>
-->