Commit 56d1ee8b authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

suppression suite refactoring

parent 8e1a0931
Loading
Loading
Loading
Loading
+0 −80
Original line number Diff line number Diff line
<?php

use Application\Provider\Privilege\Privileges;

/**
 * @var $this                 \Application\View\Renderer\PhpRenderer
 * @var $title                string
 * @var $structure            \Application\Entity\Db\Structure
 * @var $form                 \Plafond\Form\PlafondConfigForm
 */

$canEdit = $this->isAllowed(Privileges::getResourceId(Privileges::PLAFONDS_STRUCTURE_EDITION));

?>
<h1 class="page-header"><?= $title ?></h1>

<table class="table table-condensed table-hover table-bordered plafonds-admin">
    <thead>
    <tr>
        <th rowspan="2">Plafond</th>
        <th>Prévisionnel</th>
        <th>Réalisé</th>
        <th>Heures<sup>*</sup></th>
    </tr>
    </thead>
    <tbody>
    <?php foreach ($form->getPlafonds() as $plafond): $ps = $plafond->getPlafondStructure() ?>
        <tr>
            <td style="width:50%"><?= $ps->getPlafond() ?></td>
            <?php if ($canEdit): ?>
                <td><?php echo $this->formControlGroup($form->getElement($ps, 'plafondEtatPrevu')); ?></td>
                <td><?php echo $this->formControlGroup($form->getElement($ps, 'plafondEtatRealise')); ?></td>
                <td><?php echo $this->formControlGroup($form->getElement($ps, 'heures')); ?></td>
            <?php else: ?>
                <td><?php echo $ps->getEtatPrevu(); ?></td>
                <td><?php echo $ps->getEtatRealise(); ?></td>
                <td><?php echo floatToString($ps->getHeures()); ?></td>
            <?php endif; ?>
        </tr>
    <?php endforeach; ?>
    </tbody>
</table>
<script type="text/javascript">
    $(function () {

        WidgetInitializer.add('plafonds-admin', {

            change: function (el)
            {

                var params = {
                    plafond: el.data('plafond-id'),
                    name: el.data('name'),
                    value: el.val()
                };

                $.post("<?= $this->url('plafond/structure/modifier', ['structure' => $structure->getId()]) ?>", params, function (data)
                {
                    alertFlash('Votre modification a bien été prise en compte', 'success', 3000);
                }).fail(function (jqXHR)
                {
                    alertFlash(jqXHR.responseText, 'danger', 3000);
                });
            },

            _create: function ()
            {
                var that = this;
                var elsel = '[data-name="plafondEtatPrevu"],[data-name="plafondEtatRealise"],[data-name="heures"]';

                this.element.find(elsel).each(function () {
                    var thatthat = $(this);
                    thatthat.change(function () { that.change(thatthat) });
                });
            },

        });

    });
</script>
 No newline at end of file