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

<?= $this->section("content") ?>
<div class="row">
    <div class="col-12">
		<div class="card card-info">
			<div class="card-header">
        		<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
			</div><!--//.card-header -->
			<form id="addFacturaForm" class="card-body" method="post" action="<?= $formAction ?>">
				<?= csrf_field() ?>
                <?= view("themes/_commonPartialsBs/_alertBoxes") ?>
                <?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
                
                <div class="row">                                    

                    <div class="col-md-12 col-lg-6 px-4">
                        <div class="mb-3">
                            <label for="cliente_id" class="form-label">
                                <?= lang('Presupuestos.clienteId') ?>*
                            </label>
                            <select id="cliente_id" name="cliente_id" class="form-control select2bs2" style="width: 100%;"></select>
                        </div><!--//.mb-3 -->
                    </div><!--//.col -->

                </div><!--//.row -->    

                <div class="row">         

                    <div class="col-md-12 col-lg-6 px-4">
                        <div class="mb-3">
                            <label for="serie_id" class="form-label">
                                <?= lang('Facturas.serieFacturacion') ?>*
                            </label>
                            <select id="serie_id" name="serie_id" class="form-control select2bs2" style="width: 100%;"></select>
                        </div><!--//.mb-3 -->
                    </div><!--//.col -->

                </div><!--//.row -->
                
                
                <div class="pt-4">
					<input type="submit"
								class="btn btn-primary float-start me-sm-3 me-1"
								name="save"
								value="<?= lang("Basic.global.Save") ?>"
					/>
					<?= anchor(route_to("tarifaAcabadoList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
				</div><!-- /.card-footer -->
			</form>
		</div><!-- //.card -->
    </div><!--//.col -->
    
</div><!--//.row --> 

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

<?= $this->section("additionalInlineJs") ?>

$('#cliente_id').select2({
    allowClear: false,
    ajax: {
        url: '<?= route_to("menuItemsOfClientes") ?>',
        type: 'post',
        dataType: 'json',

        data: function(params) {
            return {
                id: 'id',
                text: 'nombre',
                searchTerm: params.term,
                <?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
            };
        },
        delay: 60,
        processResults: function(response) {
            yeniden(response.<?= csrf_token() ?>);
            return {
                results: response.menu
            };
        },
        cache: true
    }
});


$('#serie_id').select2({
    allowClear: false,
    minimumResultsForSearch: -1,
    ajax: {
        url: '<?= route_to("menuItemsOfSeriesFacturas") ?>',
        type: 'post',
        dataType: 'json',

        data: function(params) {
            return {
                id: 'id',
                text: 'nombre',
                searchTerm: params.term,
                <?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
            };
        },
        delay: 60,
        processResults: function(response) {
            yeniden(response.<?= csrf_token() ?>);
            return {
                results: response.menu
            };
        },
        cache: true
    }
});

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