<?php
/**
 * @var \App\View\AppView $this
 * @var \App\Model\Entity\ClienteFacturacion $clienteFacturacion
 * @var \App\Model\Entity\ClienteCredencial $credencial
 */
?>

<div class="container mt-4 mb-4">
    <div class="row">
        <div class="col-md-8 offset-md-2">
            <div class="col-12 mb-4">
                <h3 class="text-info"><i class="fas fa-user-lock"></i> Acceso al Portal de Clientes</h3>
                <p class="text-muted">Cliente: <strong><?= h($clienteFacturacion->nombre_razon_social) ?></strong></p>
            </div>

            <?= $this->Form->create($credencial, ['class' => 'row g-3']) ?>

            <div class="col-md-12 mb-3">
                <?= $this->Form->control('email', [
                    'label' => 'Email de acceso',
                    'class' => 'form-control',
                    'required' => true,
                ]) ?>
            </div>

            <div class="col-md-12 mb-3">
                <?= $this->Form->control('password', [
                    'label' => $credencial->isNew() ? 'Contraseña' : 'Nueva contraseña (dejar en blanco para no cambiarla)',
                    'type' => 'password',
                    'class' => 'form-control',
                    'value' => '',
                ]) ?>
            </div>

            <div class="col-md-12 mb-3 form-check">
                <?= $this->Form->checkbox('activo', ['checked' => $credencial->isNew() ? true : (bool) $credencial->activo, 'class' => 'form-check-input']) ?>
                <label class="form-check-label" for="activo">Cuenta activa</label>
            </div>

            <div class="col-12 text-center">
                <?= $this->Form->button(__('Guardar'), ['class' => 'btn btn-info']) ?>
                <?= $this->Html->link(__('Cancelar'), ['action' => 'view', $clienteFacturacion->id], ['class' => 'btn btn-secondary ms-2']) ?>
            </div>

            <?= $this->Form->end() ?>
        </div>
    </div>
</div>
