add_edit.ctp 3.92 KB
<?php
/**
 * @var \App\View\AppView $this
 * @var \App\Model\Entity\Projet $projet
 */


// add or edit mode ? true=add ; false=edit
$IS_ADD = $IS_ADD;
$IS_EDIT = !$IS_ADD;
$entity = $entity;
$entity_name = 'projet';
$groupes_thematiques = $groupes_thematiques;
$pis = $pis;
$pms = $pms;

//debug($entity);
//debug($pis);

// ADD only
if ($IS_ADD) {
    $verb = 'Ajouter';
    $icon = 'icon-plus';
    $redirect_action = 'index';
}
// EDIT only
else {
    $verb = 'Éditer';
    $icon = 'icon-edit';
    $redirect_action = 'view';
}


?>

<!-- 
<nav class="large-3 medium-4 columns" id="actions-sidebar">
    <ul class="side-nav">
        <li class="heading"><S= __('Actions') ?></li>
        <li><S= $this->Html->link(__('List Projets'), ['action' => 'index']) ?></li>
        <li><S= $this->Html->link(__('List Groupes Thematiques'), ['controller' => 'GroupesThematiques', 'action' => 'index']) ?></li>
        <li><S= $this->Html->link(__('New Groupes Thematique'), ['controller' => 'GroupesThematiques', 'action' => 'add']) ?></li>
        <li><S= $this->Html->link(__('List Users'), ['controller' => 'Users', 'action' => 'index']) ?></li>
        <li><S= $this->Html->link(__('New User'), ['controller' => 'Users', 'action' => 'add']) ?></li>
        <li><S= $this->Html->link(__('List Materiels'), ['controller' => 'Materiels', 'action' => 'index']) ?></li>
        <li><S= $this->Html->link(__('New Materiel'), ['controller' => 'Materiels', 'action' => 'add']) ?></li>
    </ul>
</nav>
-->
<div class="projets form large-9 medium-8 columns content">
    <?= $this->Form->create($entity) ?>
    <fieldset>
        <legend><?= __("$verb $entity_name") ?></legend>
        <?php
            echo $this->Form->control('nom');
            echo $this->Form->control('description');
            echo $this->Form->control('groupes_thematique_id', ['label'=>'Groupe thématique', 'options' => $groupes_thematiques, 'empty' => true]);
            echo $this->Form->control('chef_science_id', ['label' => 'Responsable scientifique', 'options' => $pis, 'empty' => true]);
            echo $this->Form->control('chef_projet_id', ['label' => 'Chef de projet', 'options' => $pms, 'empty' => true]);
            
            $comment = 'Entrez une date (JJ/MM/AAAA)';
            echo $this->Form->control('date_start', [
                //'empty' => true,
                'type' => 'text',
                'label' => 'Date début projet',
                'class' => 'datepicker',
                'placeholder' => $comment,
                // ADD only
                'default' => date("d/m/Y"),
                // A CAUSE DE CE FICHU PHP5 ET VIEUX MYSQL !!!, INUTILE EN PHP7 !!
                // Affichage dd/mm/yy
                //'value' => $materiel->date_acquisition->format('d/m/y'),
                'value' => $IS_ADD ? null : ($entity->date_start ? $entity->date_start->format('d/m/Y') : null),
                // EDIT only
                //'disabled' => $IS_ADD ? false : $isReadonlyField('date_acquisition', $myReadonlyFields)
            ]);
            
            echo $this->Form->control('date_stop', [
                //'empty' => true,
                'type' => 'text',
                'label' => 'Date fin projet',
                'class' => 'datepicker',
                'placeholder' => $comment,
                // ADD only
                //'default' => date("d/m/Y"),
                // A CAUSE DE CE FICHU PHP5 ET VIEUX MYSQL !!!, INUTILE EN PHP7 !!
                // Affichage dd/mm/yy
                //'value' => $materiel->date_acquisition->format('d/m/y'),
                'value' => $IS_ADD ? null : ($entity->date_stop ? $entity->date_stop->format('d/m/Y') : null),
                // EDIT only
                //'disabled' => $IS_ADD ? false : $isReadonlyField('date_acquisition', $myReadonlyFields)
            ]);
            
        ?>
    </fieldset>
    <?= $this->Form->submit(__('Valider')) ?>
    <?php //= $this->Form->button(__('Submit')) ?>
    <?= $this->Form->end() ?>
</div>