This commit is contained in:
2021-03-25 23:33:37 -03:00
parent cd1ee7d446
commit 8fe357cc95
16 changed files with 216 additions and 58 deletions

8
resources/routes/api.php Normal file
View File

@ -0,0 +1,8 @@
<?php
$files = new DirectoryIterator(__DIR__ . '/api');
foreach ($files as $file) {
if ($file->isDir()) {
continue;
}
include_once $file->getRealPath();
}

View File

@ -0,0 +1,6 @@
<?php
use App\Controller\API\Unidades;
$app->group('/unidades', function($app) {
$app->get('/no_reservadas/{id_proyecto}/{id_tipo}', [Unidades::class, 'no_reservadas']);
});

View File

@ -69,8 +69,7 @@
@push('scripts')
<script type="text/javascript">
function findUnidades(proyecto) {
$.getJSON('{!!api('unidades', 'unidades_no_reservadas')!!}&proyecto=' + proyecto + '&tipo=1', function(data) {
//$.post('{!!nUrl('ajax', 'unidades', ['ajax' => true])!!}', {proyecto: proyecto, tipo: 1}, function(data) {
$.getJSON('{!!$locations['api']!!}/unidades/no_reservadas/' + proyecto + '/1', function(data) {
var unidades = $('#departamento')
unidades.html('')
$.each(data, function(i, el) {
@ -79,13 +78,12 @@
}
unidades.append($('<option></option>').attr('value', el.id).html(el.descripcion));
})
})//, 'json')
})
}
var unis = []
function agregarUnidad(tipo) {
var proyecto = $('#proyecto').val()
$.getJSON('{!!api('unidades', 'unidades_no_reservadas')!!}&proyecto=' + proyecto + '&tipo=' + tipo, function(data) {
//$.post('{!!nUrl('ajax', 'unidades', ['ajax' => true])!!}', {proyecto: proyecto, tipo: tipo}, function(data) {
$.getJSON('{!!$locations['api']!!}/unidades/no_reservadas/' + proyecto + '/' + tipo, function(data) {
var unidades = $('#unidades')
var n = unis[unis.length - 1] + 1;
if (unis.length == 0) {
@ -128,7 +126,7 @@
i = $(this).attr('data-id');
removeUnidad(i);
});
})//, 'json')
})
}
function removeUnidad(n) {
var unidades = $('#unidades');