Commit 1230eb71 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

On n'affiche pas le bloc si on n'a rien dedans

parent be3a51bf
Loading
Loading
Loading
Loading
+28 −21
Changes for module/Dossier/view/dossier/intervenant-dossier/partial/formAutres.phtml: 28 added lines, 21 removed lines.
Original line number Diff line number Diff line
@@ -24,11 +24,31 @@ $dossierAutres = $form->get('DossierAutres');
</style>

<!-- Fiedlset Autres -->
<?php if (count($champsAutres) > 0): ?>
<?php

$autres = [];
foreach ($champsAutres as $champsAutre) {
    $canView = $this->isAllowed($intervenant, constant('Dossier\Assertion\IntervenantDossierAssertion::PRIV_VIEW_AUTRE' . $champsAutre->getId()));
    $canEdit = $this->isAllowed($intervenant, constant('Dossier\Assertion\IntervenantDossierAssertion::PRIV_EDIT_AUTRE' . $champsAutre->getId()));

    if ($canView) {
        $method = 'getAutre' . $champsAutre->getId();
        $value = $intervenantDossier->$method();

        $autres[] = [
            'id'      => $champsAutre->getId(),
            'canView' => $canView,
            'canEdit' => $canEdit,
            'value'   => $value,
        ];
    }
}

if (empty($autres)) return;

?>
<div class="col-md-6">
    <div class="card bg-default ">

        <div class="card-header">
            AUTRES
            <?php if (!empty($tblDossier)): ?>
@@ -38,38 +58,25 @@ $dossierAutres = $form->get('DossierAutres');
                    <span class="badge bg-success">Complet</span>
                <?php endif; ?>
            <?php endif; ?>

        </div>
        <div class="card-body">
                <?php foreach ($champsAutres as $champ): ?>
                    <?php if (!$this->isAllowed($intervenant, constant('Dossier\Assertion\IntervenantDossierAssertion::PRIV_EDIT_AUTRE' . $champ->getId()))): ?>
                        <?php if ($this->isAllowed($intervenant, constant('Dossier\Assertion\IntervenantDossierAssertion::PRIV_VIEW_AUTRE' . $champ->getId()))): ?>

            <?php foreach ($autres as $champ): ?>
                <div class="form-group">
                                <?php echo $this->formLabel($dossierAutres->get('champ-autre-' . $champ->getId()),); ?>
                 <?php if (!$champ['canEdit']): ?>
                    <?= $this->formLabel($dossierAutres->get('champ-autre-' . $champ['id']),); ?>
                    <div class="input-group cold-md-6 readonly">
                        <?php
                                    $method = 'getAutre' . $champ->getId();
                                    $value  = $intervenantDossier->$method();
                                    if (!empty($intervenantDossier->$method())) {
                                        $viewAutre = $this->isAllowed($intervenant, constant('Dossier\Assertion\IntervenantDossierAssertion::PRIV_VIEW_AUTRE' . $champ->getId()));
                                        echo ($viewAutre) ? $intervenantDossier->$method() : '***************';
                        if ($champ['value']) {
                            echo ($champ['canView']) ? $champ['value'] : '***************';
                        }
                        ?>
                    </div>
                </div>
                        <?php endif; ?>
                <?php else: ?>
                        <?php echo $this->formControlGroup($dossierAutres->get('champ-autre-' . $champ->getId())); ?>
                <?= $this->formControlGroup($dossierAutres->get('champ-autre-' . $champ['id'])); ?>
                <?php endif; ?>
            <?php endforeach; ?>

        </div>
    </div>
</div>
 No newline at end of file
<?php endif; ?>