edit.ctp 7.5 KB
Newer Older
1 2 3 4
<?php
    if (isset($this->validationErrors['Norme']) && !empty($this->validationErrors['Norme'])) {
        ?>
        <div class="alert alert-danger" role="alert">
5
            <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"><!----></span>
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
            <span class="sr-only">Error:</span>
            Ces erreurs se sont produites:
            <ul>
                <?php
                foreach ($this->validationErrors as $donnees) {
                    foreach ($donnees as $champ) {
                        foreach ($champ as $error) {
                            echo '<li>' . $error . '</li>';
                        }
                    }
                }
                ?>
            </ul>
        </div>
        <?php
    }
?>

<div class="users form">
    <?php
        echo $this->WebcilForm->create('Norme',[
            'autocomplete' => 'off',
            'inputDefaults' => ['div' => false],
            'class' => 'form-horizontal',
            'novalidate' => 'novalidate',
            'type' => 'file'
        ]);
    ?>
    
    <fieldset>
        <div class="col-md-6">
            <?php
                echo $this->WebcilForm->input('norme', [
                    'id' => 'norme',
                    'options' => $options['Norme']['norme'],
                    'class' => 'form-control usersDeroulant',
                    'data-placeholder' => __d('norme', 'norme.placeholderSelectionnerNorme' ),
                    'empty' => true,
                    'required' => true,
                    'placeholder' => false
                ]);
            ?>
        </div>
        
50
        <span class="fa fa-arrow-right pull-left" style="margin-left:10px; margin-top: 7px"><!----></span>
51 52 53 54
        
        <div class="col-md-5">
            <?php
                $prefixNumero = $norme['Norme']['norme'] . '-' . $norme['Norme']['numero'] . ' : ' . $norme['Norme']['libelle'];
tguillon's avatar
tguillon committed
55

56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
                echo $this->WebcilForm->input('prefixNumero', [
                    'id' => 'prefixNumero',
                    'label' => [
                        'text' => false,
                        'class' => false
                    ],
                    'readonly' => true,
                    'placeholder' => false,
                    'value' => $prefixNumero 
                ]);
            ?>
        </div>
    </fieldset>
    
    <div class="row">
        <!-- Colonne de gauche -->
        <div class="col-md-6">
            <?php
                echo $this->WebcilForm->inputs([
                    'numero' => [
                        'id' => 'numero',
                        'type' => 'text',
                        'required' => true,
                        'maxlength' => 3
                    ],
                    'libelle' => [
                        'id' => 'libelle',
                        'required' => true
                    ],
                    'description' => [
                        'id' => 'description', 
                        'type' => 'textarea'
                    ]
                ]);
90

91 92 93 94 95 96 97 98 99 100
                if (empty($this->request->data('Norme.fichier'))) {
                    // Ajouter le PDF de la norme
                    echo $this->WebcilForm->input('Norme.fichier', [
                        'id' => 'logo_file',
                        'div' => 'input-group inputsForm',
                        'type' => 'file',
                        'class' => 'filestyle',
                        'data-buttonText' => ' Ajouter le PDF de la norme',
                        'data-buttonName' => "btn-default-primary",
                        'data-buttonBefore' => "true",
101
                        'accept' => 'application/pdf',
102 103 104 105 106 107 108 109 110 111
                        'label' => [
                            'text' => false
                        ]
                    ]);
                } else {
                    ?>
                    <table class="table" id="render">
                        <tbody>
                            <tr>
                                <td class="col-md-1">
112
                                    <i class="fa fa-file-text-o fa-lg"><!----></i>
113 114 115 116 117 118 119 120 121 122
                                </td>

                                <td class="col-md-9 tdleft">
                                    <?php
                                        echo $this->request->data('Norme.name_fichier');
                                    ?>
                                </td>

                                <td class="col-md-2">
                                    <?php
123
                                        echo $this->Html->link('<span class="fa fa-download fa-lg"><!----></span>', [
124 125 126 127 128 129 130 131 132 133
                                            'controller' => 'normes',
                                            'action' => 'download',
                                            $norme['Norme']['fichier'],
                                            $norme['Norme']['name_fichier']
                                                ], [
                                            'class' => 'btn btn-default-default boutonShow btn-sm my-tooltip',
                                            'title' => 'Télécharger la norme',
                                            'escapeTitle' => false
                                        ]);
                                        
134
                                        echo $this->Html->link('<span class="fa fa-trash fa-lg"><!----></span>', [
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
                                            'controller' => 'normes',
                                            'action' => 'deleteFileSave',
                                            $norme['Norme']['id'],
                                            $norme['Norme']['fichier'],
                                                ], [
                                            'class' => 'btn btn-default-danger boutonShow btn-sm my-tooltip',
                                            'title' => __d('norme','norme.btnSupprimerFichierNorme'),
                                            'escapeTitle' => false
                                        ]);
                                    ?>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <?php
                }
            ?>
        </div>
    </div>
</div>

<div style="clear: both">
    <?php
        echo $this->WebcilForm->buttons(['Cancel', 'Save']);
    ?>
</div>

<?php
    echo $this->WebcilForm->end();
?>

<script type="text/javascript">
    
    $(document).ready(function () {
        
tguillon's avatar
tguillon committed
170 171 172
        var prefixNorme = '';
        var numeroNorme = '';
        var libelleNorme = '';
173 174
        
        // Lors d'action sur le menu déroulant
tguillon's avatar
tguillon committed
175
        $('#norme').change(function () {
176
            prefixNorme = $(this).val();
tguillon's avatar
tguillon committed
177
            $('#prefixNumero').val(prefixNorme + numeroNorme + libelleNorme);
178 179
        });
        
tguillon's avatar
tguillon committed
180
        $('#numero').change(function () {
181 182 183 184 185 186 187
            
            if ($(this).val() === '') {
                numeroNorme = "";
            } else {
                numeroNorme = '-' + $(this).val();
            }
            
tguillon's avatar
tguillon committed
188
            $('#prefixNumero').val(prefixNorme + numeroNorme + libelleNorme);
189 190
        });
        
tguillon's avatar
tguillon committed
191
        $('#libelle').change(function () {
192 193 194 195 196 197
            if ($(this).val() === '') {
                libelleNorme = "";
            } else {
                libelleNorme = ' : ' + $(this).val();
            }
            
tguillon's avatar
tguillon committed
198
            $('#prefixNumero').val(prefixNorme + numeroNorme + libelleNorme);
199
        });
tguillon's avatar
tguillon committed
200 201 202

        $('span.icon-span-filestyle').removeClass('icon-span-filestyle');

203 204
    });
</script>