Slim API
This commit is contained in:
8
resources/routes/api.php
Normal file
8
resources/routes/api.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
$files = new DirectoryIterator(__DIR__ . '/api');
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
6
resources/routes/api/unidades.php
Normal file
6
resources/routes/api/unidades.php
Normal 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']);
|
||||
});
|
@ -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');
|
||||
|
Reference in New Issue
Block a user