<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>

<?= $this->section('content'); ?>
<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <h4><?= $boxTitle ?></h4>
            </div>
            <div class="card-body">

                <input type="hidden" id="tipo_envio" value="<?= $tipo_envio ?>" />

                <?= view("themes/_commonPartialsBs/_alertBoxes") ?>

                <div class="card accordion-item active mb-5">
                    <h4 class="accordion-header px-4 py-3">
                        <?= lang("Logistica.nuevoEnvio") ?>
                    </h4>

                    <div id="accordionNuevoEnvioTip" class="accordion-collapse collapse show">
                        <div class="accordion-body px-4 py-3">

                            <div class="row">
                                <div class="mb-1 col-sm-6">
                                    <label for="buscadorPedidos" class="form-label">
                                        <?= lang("Logistica.buscadorPedidosTitle2") ?>
                                    </label>
                                    <select id="buscadorPedidos" name="buscador_pedidos" tabindex="1" maxlength="50"
                                        class="form-control select2bs2">
                                    </select>
                                </div>
                            </div>

                            <div class="row select-direcciones d-none">
                                <div class="col-sm-6 px-3">
                                    <label for="selectDirecciones" class="form-label">
                                        <?= lang("Logistica.selectDirecciones") ?>
                                    </label>
                                    <select id="selectDirecciones" name="select_direcciones" tabindex="1" maxlength="50"
                                        class="form-control select2bs2" style="width: 100%;">
                                    </select>
                                </div>
                            </div>

                            <div class="row add-envio d-none">
                                <div class="col-sm-2 px-3">
                                    <button id="btnAddEnvio" name="btn_add_envio" tabindex="1"
                                        class="btn btn-primary mt-4 w-100">
                                        <?= lang("Logistica.add") ?>
                                        <ti class="ti ti-circle-plus"></ti>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>


                <div class="card accordion-item active">
                    <h4 class="accordion-header px-4 py-3">
                        <?= lang("Logistica.listadoEnvios") ?>
                    </h4>

                    <div id="accordionListadoEnviosTip" class="accordion-collapse collapse show">
                        <div class="accordion-body px-4 py-3">

                            <div class="row">
                                <table id="tableOfEnvios" class="table table-striped table-hover w-100">
                                    <thead>
                                        <tr>
                                            <th><?= lang('Logistica.idEnvio') ?? 'ID Envío' ?></th>
                                            <th><?= lang('Logistica.numeroOts') ?? 'Nº OTs' ?></th>
                                            <th><?= lang('Logistica.numeroLineas') ?? 'Nº Líneas' ?></th>
                                            <th><?= lang('Logistica.att') ?? 'Att' ?></th>
                                            <th><?= lang('Logistica.direccion') ?? 'Dirección' ?></th>
                                            <th><?= lang('Logistica.ciudad') ?? 'Ciudad' ?></th>
                                            <th><?= lang('Logistica.pais') ?? 'País' ?></th>
                                            <th><?= lang('Logistica.cp') ?? 'CP' ?></th>
                                            <th><?= lang('Logistica.email') ?? 'Email' ?></th>
                                            <th><?= lang('Logistica.telefono') ?? 'Teléfono' ?></th>
                                            <th><?= lang('Logistica.finalizado') ?? 'Finalizado' ?></th>
                                            <th><?= lang('Logistica.acciones') ?? 'Acciones' ?></th>
                                        </tr>
                                        <tr>    
                                            <th><input type="text" class="form-control envio-filter" name="id"></th>
                                            <th><input type="text" class="form-control envio-filter-ots" name="ots"></th>
                                            <th></th>
                                            <th><input type="text" class="form-control envio-filter" name="att"></th>
                                            <th><input type="text" class="form-control envio-filter" name="direccion"></th>
                                            <th><input type="text" class="form-control envio-filter" name="ciudad"></th>
                                            <th><input type="text" class="form-control envio-filter" name="pais"></th>
                                            <th><input type="text" class="form-control envio-filter" name="cp"></th>
                                            <th><input type="text" class="form-control envio-filter" name="email"></th>
                                            <th><input type="text" class="form-control envio-filter" name="telefono"></th>
                                            <th>
                                                <select class="form-control envio-filter-select" name="finalizado">
                                                    <option value=""><?= lang('Logistica.todos')?></option>
                                                    <option value="0"><?=  lang('Basic.global.no') ?></option>
                                                    <option value="1"><?=  lang('Basic.global.yes') ?></option>
                                                </select>
                                            </th>
                                            <th></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>


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

                <div class="mt-3">
                    <button type="button" class="btn btn-secondary" id="btnImprimirEtiquetas"
                        onclick="window.location.href='<?= route_to('LogisticaPanel') ?>'">
                        <?= lang('Logistica.backToPanel') ?>
                    </button>
                </div>
            </div>

        </div>
    </div>
    <?= $this->endSection() ?>


    <?= $this->section('css') ?>
    <link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
    <?= $this->endSection() ?>

    <?= $this->section('additionalExternalJs') ?>
    <script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
    <script type="module" src="<?= site_url("assets/js/safekat/pages/logistica/envio.js") ?>"></script>
    <?= $this->endSection() ?>