<?= $this->extend("layout/index"); ?>
<?= $this->section('content'); ?>

<div class="content-wrapper" style="min-height: 357.039px;">
    <section class="content">
        <div class="card card-info card-outline">
            <div class="card-header">
                <h3 class="card-title text-bold"><?= lang('Administration.user_formEdit_title') ?></h3>

                <span class="float-right">
                    <?= anchor($locale . "/admin/users", "<i class='fa fa-tasks'></i> " . lang("Params.btn_list"), ['class' => 'btn btn-primary btn-sm']) ?>
                </span>

            </div>
            <div class="card-body">
                <div class="row">
                    <p class='text-bold'>
                        <font color='red'>*</font> Champ est obligatoire
                    </p>
                    <?= validation_list_errors() ?>
                </div>

                <?php echo form_open($locale . "/admin/user/".$user->id, NULL, ['id'=>(string)$user->id]); ?>
                <div class="row">
                    <div class="col-md-3 mb-3">
                        <?= form_label(lang('Administration.user_form_firstName')."<font color='red'>*</font>", 'nom'); ?>
                        <?php
                        $prenom = [
                            'type'  => 'text',
                            'name'  => 'prenom',
                            'id'    => 'prenom',
                            'value' => set_value('prenom', $user->prenom),
                            'placeholder' => "Nom",
                            'class' => 'form-control',
                        ];

                        echo form_input($prenom);
                        ?>
                    </div>

                    <div class="col-md-3 mb-3">
                        <?= form_label(lang('Administration.user_form_lastName')."<font color='red'>*</font>", 'prenom'); ?>
                        <?php
                        $nom = [
                            'type'  => 'text',
                            'name'  => 'nom',
                            'id'    => 'nom',
                            'value' => set_value('nom', $user->nom),
                            'placeholder' => "Prenom",
                            'class' => 'form-control',
                        ];

                        echo form_input($nom);
                        ?>
                    </div>

                    <div class="col-md-3 mb-3">
                        <?= form_label(lang('Administration.user_form_mobile')."<font color='red'>*</font>", 'mobile'); ?>
                        <?php
                        $phone = [
                            'type'  => 'text',
                            'name'  => 'telephone',
                            'id'    => 'telephone',
                            'value' => set_value('telephone', $user->telephone),
                            'placeholder' => "Telephone",
                            'class' => 'form-control',
                        ];

                        echo form_input($phone);
                        ?>
                    </div>
                  
                    <div class="col-md-3 mb-3">
                        <?= form_label(lang('Administration.user_form_email')."<font color='red'>*</font>", 'usermane'); ?>
                        <?php
                        $email = [
                            'type'  => 'text',
                            'name'  => 'email',
                            'id'    => 'email',
                            'value' => set_value('username', $user->email),
                            'placeholder' => "Email",
                            'class' => 'form-control',
                        ];

                        echo form_input($email);
                        ?>
                    </div>

                    <div class="col-md-3 mb-3">
                        <?= form_label(lang('Administration.user_form_username')."<font color='red'>*</font>", 'email'); ?>
                        <?php
                        $username = [
                            'type'  => 'text',
                            'name'  => 'username',
                            'id'    => 'username',
                            // 'readonly'    => false,
                            'value' => set_value('username', $user->username),
                            'placeholder' => "Nom d'utilisateur",
                            'class' => 'form-control',
                        ];

                        echo form_input($username);
                        ?>
                    </div>

                    <div class="col-md-3 mb-3">
                        <?= form_label(lang('Administration.user_form_password')."<font color='red'>*</font>", 'password'); ?>
                        <?php
                        $password = [
                            'type'  => 'text',
                            'name'  => 'password',
                            'id'    => 'password',
                            'value' => set_value('password'),
                            'placeholder' => "Mot de passe",
                            'class' => 'form-control',
                        ];

                        echo form_input($password);
                        ?>
                    </div>

                    <div class="col-md-3 mb-3">
                        <?= form_label(lang('Administration.user_form_confPassword')."<font color='red'>*</font>", 'confirm_password'); ?>
                        <?php
                        $confirm_password = [
                            'type'  => 'text',
                            'name'  => 'confirm_password',
                            'id'    => 'confirm_password',
                            'value' => set_value('confirm_password'),
                            'placeholder' => "Confirmer le mot de passe",
                            'class' => 'form-control',
                        ];

                        echo form_input($confirm_password);
                        ?>
                    </div>

                    <div class="col-md-4 mb-3">
                        <?= form_label(lang('Administration.user_form_permissions'), 'confirm_password'); ?>
                        <?php
                        echo form_dropdown('permission[]', $permissions, $selectPermissions,"class='form-control select2' multiple='multiple'");
                        ?>
                    </div>

                    <div class="col-md-4 mb-3">
                        <?= form_label(lang('Administration.user_form_groups'), 'permission'); ?>
                        <?php
                        echo form_dropdown('group[]', $groups, $selectGroups,"class='form-control select2' multiple='multiple'");
                        ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-2 mb-3">
                        <?php
                        echo form_submit("mysubmit", lang("Params.btn_save"), "class='btn btn-primary btn-sm mt-2'");
                        ?>
                    </div>
                </div>
                <?php echo form_close(); ?>

            </div>
        </div>
    </section>
</div>


<?= $this->endSection(); ?>