<?php echo csrf_field(); ?>
<?php if(isset($registro)): ?>
    <?php echo method_field('put'); ?>
<?php endif; ?>

<?php $__currentLoopData = ['q', 'ano', 'con_modalidade', 'con_status', 'page']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $filterKey): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    <?php if(request()->filled($filterKey)): ?>
        <input type="hidden" name="<?php echo e($filterKey); ?>" value="<?php echo e(request($filterKey)); ?>">
    <?php endif; ?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

<div class="card border-0 shadow rounded-4">
    <div class="card-body p-4">
        <h5 class="mb-4 fw-semibold">
            <i class="fa-solid fa-file-contract me-2"></i>
            <?php echo e(__('Dados do Contrato')); ?>

        </h5>

        <div class="row g-4">
            <div class="col-md-3">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Número')); ?></label>
                <input type="text" name="con_numero" maxlength="50" class="form-control shadow-sm" value="<?php echo e(old('con_numero', $registro->con_numero ?? '')); ?>">
            </div>

            <div class="col-md-2">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Ano')); ?></label>
                <input type="text" name="con_ano" maxlength="4" class="form-control shadow-sm" value="<?php echo e(old('con_ano', $registro->con_ano ?? '')); ?>">
            </div>

            <div class="col-md-3">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Modalidade')); ?></label>
                <select class="form-select shadow-sm" name="con_modalidade">
                    <option value=""><?php echo e(__('Selecione')); ?></option>
                    <?php $__currentLoopData = \App\Models\Contratos\Contrato::MODALIDADES; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($key); ?>" <?php if((string) old('con_modalidade', $registro->con_modalidade ?? '') === (string) $key): echo 'selected'; endif; ?>><?php echo e(__($label)); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

            <div class="col-md-4">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Status')); ?></label>
                <select class="form-select shadow-sm" name="con_status">
                    <option value=""><?php echo e(__('Selecione')); ?></option>
                    <?php $__currentLoopData = \App\Models\Contratos\Contrato::STATUS; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($key); ?>" <?php if((string) old('con_status', $registro->con_status ?? '') === (string) $key): echo 'selected'; endif; ?>><?php echo e(__($label)); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

            <div class="col-md-8">
                <label class="form-label fw-semibold text-secondary" for="con_titulo"><?php echo e(__('Título')); ?></label>
                <textarea name="con_titulo" id="con_titulo" rows="3" maxlength="1024" class="form-control shadow-sm" required aria-describedby="con_titulo_counter"><?php echo e(old('con_titulo', $registro->con_titulo ?? '')); ?></textarea>
                <div class="d-flex justify-content-end mt-1">
                    <small id="con_titulo_counter" class="text-muted">
                        <span id="con_titulo_count">0</span>/1024
                    </small>
                </div>
            </div>

            <div class="col-md-4">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Processo')); ?></label>
                <input type="text" name="con_processo" maxlength="50" class="form-control shadow-sm" value="<?php echo e(old('con_processo', $registro->con_processo ?? '')); ?>">
            </div>

            <div class="col-md-8 position-relative">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Licitação vinculada')); ?></label>
                <input type="hidden"
                       name="licitacao_procedimento_id"
                       id="licitacao_procedimento_id"
                       value="<?php echo e(old('licitacao_procedimento_id', $registro->licitacao_procedimento_id ?? '')); ?>">
                <input type="text"
                       class="form-control shadow-sm"
                       id="licitacao_search"
                       placeholder="<?php echo e(__('Nº do processo, nº da licitação ou trecho do objeto (mín. 2 caracteres)')); ?>"
                       autocomplete="off"
                       data-search-url="<?php echo e(route('admin.contratos.searchLicitacoes')); ?>"
                       value="<?php echo e($licitacaoSelecionada['text'] ?? ''); ?>">
                <div id="licitacao_search_results" class="list-group position-absolute w-100 mt-1 d-none"></div>
                <small class="text-muted d-block mt-2">
                    <i class="fa-solid fa-link me-1"></i>
                    <?php echo e(__('Vincule este contrato a uma licitação para acesso direto no portal.')); ?>

                </small>
            </div>

            <div class="col-md-4">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('CNPJ do Favorecido')); ?></label>
                <input type="text" name="con_favorecido" maxlength="14" class="form-control shadow-sm" value="<?php echo e(old('con_favorecido', $registro->con_favorecido ?? '')); ?>">
            </div>

            <div class="col-md-8">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Nome do Favorecido')); ?></label>
                <input type="text" name="fav_nome" maxlength="200" class="form-control shadow-sm" value="<?php echo e(old('fav_nome', $registro->favorecido->fav_nome ?? '')); ?>">
            </div>

            <div class="col-md-3">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Data de Assinatura')); ?></label>
                <input type="text" name="con_dataassinatura" maxlength="10" class="form-control shadow-sm" data-mask-date value="<?php echo e(old('con_dataassinatura', $registro->con_dataassinatura ?? '')); ?>" placeholder="<?php echo e(__('dd/mm/aaaa')); ?>">
            </div>

            <div class="col-md-3">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Data Inicial')); ?></label>
                <input type="text" name="con_dataini" maxlength="10" class="form-control shadow-sm" data-mask-date value="<?php echo e(old('con_dataini', $registro->con_dataini ?? '')); ?>" placeholder="<?php echo e(__('dd/mm/aaaa')); ?>">
            </div>

            <div class="col-md-3">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Data Final')); ?></label>
                <input type="text" name="con_datafim" maxlength="10" class="form-control shadow-sm" data-mask-date value="<?php echo e(old('con_datafim', $registro->con_datafim ?? '')); ?>" placeholder="<?php echo e(__('dd/mm/aaaa')); ?>">
            </div>

            <div class="col-md-3">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Data Publicação')); ?></label>
                <input type="text" name="con_datapub" maxlength="10" class="form-control shadow-sm" data-mask-date value="<?php echo e(old('con_datapub', $registro->con_datapub ?? '')); ?>" placeholder="<?php echo e(__('dd/mm/aaaa')); ?>">
            </div>

            <div class="col-md-3">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Valor')); ?></label>
                <input type="text" name="con_valor" maxlength="20" class="form-control shadow-sm" value="<?php echo e(old('con_valor', $registro->con_valor ?? '')); ?>">
            </div>

            <div class="col-md-6">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Secretaria')); ?></label>
                <select class="form-select shadow-sm" name="con_secretaria">
                    <option value=""><?php echo e(__('Selecione')); ?></option>
                    <?php $__currentLoopData = $secretarias; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $secretaria): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($secretaria->id); ?>" <?php if((string) old('con_secretaria', $registro->con_secretaria ?? '') === (string) $secretaria->id): echo 'selected'; endif; ?>><?php echo e($secretaria->name); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

            <div class="col-md-6">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Secretaria Gestora')); ?></label>
                <select class="form-select shadow-sm" name="con_secretaria_gestora">
                    <option value=""><?php echo e(__('Selecione')); ?></option>
                    <?php $__currentLoopData = $secretariasGestoras; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $secretaria): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($secretaria->id); ?>" <?php if((string) old('con_secretaria_gestora', $registro->con_secretaria_gestora ?? '') === (string) $secretaria->id): echo 'selected'; endif; ?>><?php echo e($secretaria->name); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

            <div class="col-md-2">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Covid')); ?></label>
                <select class="form-select shadow-sm" name="con_covid">
                    <option value=""><?php echo e(__('Selecione')); ?></option>
                    <option value="S" <?php if(old('con_covid', $registro->con_covid ?? '') === 'S'): echo 'selected'; endif; ?>><?php echo e(__('Sim')); ?></option>
                    <option value="N" <?php if(old('con_covid', $registro->con_covid ?? '') === 'N'): echo 'selected'; endif; ?>><?php echo e(__('Não')); ?></option>
                </select>
            </div>

            <div class="col-md-10">
                <label class="form-label fw-semibold text-secondary"><?php echo e(__('Fiscais')); ?></label>
                <textarea name="con_fiscais" rows="2" class="form-control shadow-sm"><?php echo e(old('con_fiscais', $registro->con_fiscais ?? '')); ?></textarea>
            </div>
        </div>

        <div class="d-flex justify-content-end mt-4">
            <button class="btn btn-success px-4 py-2 shadow-sm">
                <i class="fa-solid fa-check me-2"></i><?php echo e(__('Salvar')); ?>

            </button>
        </div>
    </div>
</div>

<?php $__env->startPush('scripts'); ?>
<link rel="stylesheet" href="<?php echo e(asset('pmar/css/admin/contratos/form.css')); ?>">
<script src="<?php echo e(asset('pmar/js/admin/contratos/form.js')); ?>"></script>
<?php $__env->stopPush(); ?>
<?php /**PATH /var/www/html/portal/resources/views/admin/contratos/_form.blade.php ENDPATH**/ ?>