Caricamento dinamico delle righe dei documenti

This commit is contained in:
Dasc3er 2020-09-14 10:49:23 +02:00
parent cf4d3cef74
commit 1298a321a0
14 changed files with 154 additions and 99 deletions

View File

@ -348,13 +348,8 @@ echo '
<br>
<div class="row">
<div class="col-md-12">';
include $structure->filepath('row-list.php');
echo '
</div>
</div>
<div class="col-md-12" id="righe"></div>
</div>
</div>
</div>
@ -395,6 +390,22 @@ async function gestioneRiga(button, options) {
}
}
/**
* Funzione dedicata al caricamento dinamico via AJAX delle righe del documento.
*/
function caricaRighe() {
let container = $("#righe");
localLoading(container, true);
return container.load("'.$structure->fileurl('row-list.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function() {
localLoading(container, false);
});
}
$(document).ready(function() {
caricaRighe();
});
$(document).ready(function() {
$("#data_accettazione").on("dp.change", function() {
if($(this).val()){

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
include_once __DIR__.'/init.php';
echo '
<div class="table-responsive">

View File

@ -353,19 +353,14 @@ if (!$block_edit) {
<i class="fa fa-plus"></i> '.tr('Sconto/maggiorazione').'
</button>';
}
?>
echo '
</div>
<div class="clearfix"></div>
<br>
<div class="row">
<div class="col-md-12">
<?php
include $structure->filepath('row-list.php');
echo '
</div>
<div class="col-md-12" id="righe"></div>
</div>
</div>
</div>
@ -407,6 +402,22 @@ async function gestioneRiga(button, options) {
}
}
/**
* Funzione dedicata al caricamento dinamico via AJAX delle righe del documento.
*/
function caricaRighe() {
let container = $("#righe");
localLoading(container, true);
return container.load("'.$structure->fileurl('row-list.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function() {
localLoading(container, false);
});
}
$(document).ready(function() {
caricaRighe();
});
$("#idanagrafica").change(function() {
updateSelectOption("idanagrafica", $(this).val());
session_set("superselect,idanagrafica", $(this).val(), 0);

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
include_once __DIR__.'/init.php';
echo '
<div class="table-responsive">

View File

@ -706,14 +706,8 @@ if ($dir == 'entrata') {
<div class="clearfix"></div>
<br>
<div class="row">
<div class="col-md-12">
<?php
include $structure->filepath('row-list.php');
?>
</div>
<div class="row">
<div class="col-md-12" id="righe"></div>
</div>
</div>
</div>
@ -865,18 +859,32 @@ async function gestioneRiga(button, options) {
}
}
$(document).ready(function () {
$("#data_registrazione").on("dp.change", function (e) {
var data = $("#data_competenza");
data.data("DateTimePicker").minDate(e.date);
/**
* Funzione dedicata al caricamento dinamico via AJAX delle righe del documento.
*/
function caricaRighe() {
let container = $("#righe");
if(data.data("DateTimePicker").date() < e.date){
data.data("DateTimePicker").date(e.date);
localLoading(container, true);
return container.load("'.$structure->fileurl('row-list.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function() {
localLoading(container, false);
});
}
$(document).ready(function () {
caricaRighe();
$("#data_registrazione").on("dp.change", function (e) {
let data_competenza = $("#data_competenza");
data_competenza.data("DateTimePicker").minDate(e.date);
if(data_competenza.data("DateTimePicker").date() < e.date){
data_competenza.data("DateTimePicker").date(e.date);
}
});
$("#data").on("dp.change", function (e) {
var data_competenza = $("#data_competenza");
let data_competenza = $("#data_competenza");
data_competenza.data("DateTimePicker").minDate(e.date);
if(data_competenza.data("DateTimePicker").date() < e.date){

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
include_once __DIR__.'/init.php';
echo '
<div class="table-responsive">

View File

@ -228,12 +228,12 @@ if (!$is_completato) {
<!-- AGGIUNTA TECNICO -->
<div class="row">
<div class="col-md-offset-6 col-md-4">
{[ "type": "select", "label": "'.tr('Tecnico').'", "name": "nuovotecnico", "placeholder": "'.tr('Seleziona un tecnico').'", "ajax-source": "tecnici", "icon-after": "add|'.Modules::get('Anagrafiche')['id'].'|tipoanagrafica=Tecnico" ]}
{[ "type": "select", "label": "'.tr('Tecnico').'", "name": "nuovo_tecnico", "placeholder": "'.tr('Seleziona un tecnico').'", "ajax-source": "tecnici", "icon-after": "add|'.Modules::get('Anagrafiche')['id'].'|tipoanagrafica=Tecnico" ]}
</div>
<div class="col-md-2">
<label>&nbsp;</label>
<button type="button" class="btn btn-primary btn-block" onclick="if($(\'#nuovotecnico\').val()){ add_tecnici($(\'#nuovotecnico\').val()); }else{ swal(\''.tr('Attenzione').'\', \''.tr('Seleziona il tecnico da aggiungere').'.\', \'warning\'); $(\'#nuovotecnico\').focus(); }">
<button type="button" class="btn btn-primary btn-block" onclick="if($(\'#nuovo_tecnico\').val()){ add_tecnici($(\'#nuovo_tecnico\').val()); }else{ swal(\''.tr('Attenzione').'\', \''.tr('Seleziona il tecnico da aggiungere').'.\', \'warning\'); $(\'#nuovo_tecnico\').focus(); }">
<i class="fa fa-plus"></i> '.tr('Aggiungi').'
</button>
</div>
@ -262,12 +262,8 @@ async function modificaSessione(button) {
}
}
function caricaTecnici() {
return $("#tecnici").load("'.$module->fileurl('ajax_tecnici.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record);
}
function calcolaConflittiTecnici() {
let tecnici = [input("nuovotecnico").get()];
let tecnici = [input("nuovo_tecnico").get()];
let inizio = moment().startOf("hour");
return $("#info-conflitti").load("'.$module->fileurl('occupazione_tecnici.php').'", {
@ -279,11 +275,7 @@ function calcolaConflittiTecnici() {
});
}
function calcolaCosti() {
return $("#costi").load("'.$module->fileurl('ajax_costi.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record);
}
input("nuovotecnico").change(function() {
input("nuovo_tecnico").change(function() {
calcolaConflittiTecnici();
});
@ -323,7 +315,7 @@ function add_tecnici(id_tecnico) {
type: "post",
success: function() {
caricaTecnici();
calcolaCosti();
caricaCosti();
calcolaConflittiTecnici();
}
@ -346,7 +338,7 @@ function elimina_sessione(id_sessione) {
type: "post",
success: function() {
caricaTecnici();
calcolaCosti();
caricaCosti();
calcolaConflittiTecnici();
}

View File

@ -355,19 +355,7 @@ echo '
<br>
<div class="row">
<div class="col-md-12" id="tecnici">
<?php
if (file_exists($docroot.'/modules/interventi/custom/ajax_tecnici.php')) {
?>
<script>$('#tecnici').load('<?php echo $rootdir; ?>/modules/interventi/custom/ajax_tecnici.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');</script>
<?php
} else {
?>
<script>$('#tecnici').load('<?php echo $rootdir; ?>/modules/interventi/ajax_tecnici.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');</script>
<?php
}
?>
</div>
<div class="col-md-12" id="tecnici"></div>
</div>
</div>
</div>
@ -423,10 +411,8 @@ $articoli = $intervento->articoli;
</div>
</div>
<div id="righe">
<?php
include $structure->filepath('row-list.php');
?>
<div class="row">
<div class="col-md-12" id="righe"></div>
</div>
</div>
</div>
@ -439,19 +425,7 @@ include $structure->filepath('row-list.php');
<div class="panel-body">
<div class="row">
<div class="col-md-12" id="costi">
<?php
if (file_exists($docroot.'/modules/interventi/custom/ajax_costi.php')) {
?>
<script>$('#costi').load('<?php echo $rootdir; ?>/modules/interventi/custom/ajax_costi.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');</script>
<?php
} else {
?>
<script>$('#costi').load('<?php echo $rootdir; ?>/modules/interventi/ajax_costi.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');</script>
<?php
}
?>
</div>
<div class="col-md-12" id="costi"></div>
</div>
</div>
</div>
@ -515,6 +489,48 @@ async function gestioneRiga(button, options) {
}
}
/**
* Funzione dedicata al caricamento dinamico via AJAX delle righe del documento.
*/
function caricaRighe() {
let container = $("#righe");
localLoading(container, true);
return container.load("'.$structure->fileurl('row-list.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function() {
localLoading(container, false);
});
}
/**
* Funzione dedicata al caricamento dinamico via AJAX delle sessioni dei tecnici per l\'Attività.
*/
function caricaTecnici() {
let container = $("#tecnici");
localLoading(container, true);
return container.load("'.$structure->fileurl('ajax_tecnici.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function() {
localLoading(container, false);
});
}
/**
* Funzione dedicata al caricamento dinamico via AJAX delle sessioni dei tecnici per l\'Attività.
*/
function caricaCosti() {
let container = $("#costi");
localLoading(container, true);
return container.load("'.$structure->fileurl('ajax_costi.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function() {
localLoading(container, false);
});
}
$(document).ready(function() {
caricaRighe();
caricaTecnici();
caricaCosti();
});
$("#idanagrafica").change(function () {
updateSelectOption("idanagrafica", $(this).val());
session_set("superselect,idanagrafica", $(this).val(), 0);

View File

@ -17,15 +17,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use Modules\Interventi\Intervento;
include_once __DIR__.'/../../core.php';
include_once __DIR__.'/init.php';
$show_prezzi = Auth::user()['gruppo'] != 'Tecnici' || (Auth::user()['gruppo'] == 'Tecnici' && setting('Mostra i prezzi al tecnico'));
$intervento = $intervento ?: Intervento::find($id_record);
$righe = $intervento->getRighe();
if (!$righe->isEmpty()) {
echo '
<div class="table-responsive">

View File

@ -239,12 +239,7 @@ if (!$block_edit) {
echo '
<div class="row">
<div class="col-md-12">';
include $module->filepath('row-list.php');
echo '
</div>
<div class="col-md-12" id="righe"></div>
</div>
</div>
</div>
@ -286,6 +281,22 @@ async function gestioneRiga(button, options) {
}
}
/**
* Funzione dedicata al caricamento dinamico via AJAX delle righe del documento.
*/
function caricaRighe() {
let container = $("#righe");
localLoading(container, true);
return container.load("'.$structure->fileurl('row-list.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function() {
localLoading(container, false);
});
}
$(document).ready(function() {
caricaRighe();
});
$("#idanagrafica").change(function() {
updateSelectOption("idanagrafica", $(this).val());
session_set("superselect,idanagrafica", $(this).val(), 0);

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
include_once __DIR__.'/init.php';
echo '
<div class="table-responsive">

View File

@ -246,14 +246,8 @@ echo '
<br>
<div class="row">
<div class="col-md-12">';
include $structure->filepath('row-list.php');
echo '
</div>
</div>
<div class="col-md-12" id="righe"></div>
</div>
</div>
</div>
@ -294,6 +288,22 @@ async function gestioneRiga(button, options) {
}
}
/**
* Funzione dedicata al caricamento dinamico via AJAX delle righe del documento.
*/
function caricaRighe() {
let container = $("#righe");
localLoading(container, true);
return container.load("'.$structure->fileurl('row-list.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function() {
localLoading(container, false);
});
}
$(document).ready(function() {
caricaRighe();
});
$(document).ready(function() {
$("#idanagrafica").change(function() {
updateSelectOption("idanagrafica", $(this).val());

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
include_once __DIR__.'/init.php';
echo '
<div class="table-responsive">

View File

@ -65,7 +65,7 @@ foreach ($righe as $riga) {
echo '
<tr '.($id_riferimento == $riga->id ? 'class="success"' : '').' data-dettagli='.json_encode($dettagli).'>
<td>'.( !empty($riga->codice) ? $riga->codice.' - ' : '' ).$riga->descrizione.'</td>
<td>'.(!empty($riga->codice) ? $riga->codice.' - ' : '').$riga->descrizione.'</td>
<td>'.numberFormat($qta_rimanente, 'qta').' / '.numberFormat($riga->qta, 'qta').'</td>
<td class="text-center">';