index_gen.ctp 2.43 KB
<?php

$DEBUG=false;
//$DEBUG=true;

// Variables passées par le contrôleur
$role = $role;
$entities = $entities;
$entity_plural = $entity_plural;
$fields_names = $fields_names;

?>

<div class="entities index">

	<?php echo "<h2><i class='icon-list'></i> Liste des $entity_plural</h2>"; ?>
	
	<?=$this->element('button_add'); ?>
    
    <table style="border-collapse: separate; border-spacing: 0;width: 270px;">
		
		<thead>
			<tr>
				<th class="actions"><?= __('') ?></th>
				<!-- 
				<th><?= $this->Paginator->sort('sur_categorie_id', 'Domaine') ?></th>
				 -->
				<?php 
				foreach ($fields_names as $fname=>$fnicename)
				    echo "<th>".$this->Paginator->sort($fname, $fnicename)."</th>";
				?>
			</tr>
		</thead>
		
		<tbody>
            <?php foreach ($entities as $e): ?>
            <tr>
            
            	<!-- 
            	Actions edit / delete 
            	 -->
				<td class="actions" style="padding: 6px 0; text-align: left;">   
                    <?php if (in_array($role, ['Administration Plus', 'Super Administrateur'])) { ?>
                    <?= $this->Html->link(__('<i class="icon-pencil"></i>'), ['action' => 'edit', $e->id], ['title' => 'Editer', 'style' => 'margin: 0 2px', 'escape' => false ]) ?>
                   	<?php } ?>
                   	
                    <?php if (in_array($role, ['Super Administrateur'])) { ?>
                    <?= $this->Form->postLink(__('<i class="icon-trash"></i>'), ['action' => 'delete', $e->id], ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $e->id)]) ?>
               		<?php } ?>
                </td>
				
				<!--
				Data 
				 -->
				<td class="smallText"><?= $this->Html->link($e->nom, ['action' => 'view', $e->id]) ?></td>
				<td class="smallText"><?= $e->has('sur_category') ? $this->Html->link($e->sur_category->nom, ['controller' => 'SurCategories', 'action' => 'view', $e->sur_category->id]) : '' ?></td>
				<?php
				/*
				//TODO:
		        foreach ($e->toArray() as $fname=>$fval) {
		        }
		        */
				?>
			
			</tr>
            <?php endforeach; ?>
        </tbody>
        
	</table>
	
	<?php echo $this->element('pagination_with_first_and_last'); ?> 
	

</div>

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

echo $this->element('menu_index', [
    'pluralHumanName' => 'Catégories',
    'singularHumanName' => 'Catégorie'
])?>
		</div>
-->