Bugfix e miglioramento add.php

This commit is contained in:
Matteo 2018-11-08 10:58:29 +01:00
parent fde5ae03a8
commit 35393986a6
9 changed files with 107 additions and 110 deletions

View File

@ -65,9 +65,9 @@ if (isset($id_record)) {
<script>
$(document).ready( function(){
$('.colorpicker').colorpicker().on('changeColor', function(){
$('#colore_').parent().find('.square').css('background', $('#colore_').val());
$('#bs-popup #colore_').parent().find('.square').css('background', $('#bs-popup #colore_').val());
});
$('#colore_').parent().find('.square').css('background', $('#colore_').val());
$('#bs-popup #colore_').parent().find('.square').css('background', $('#bs-popup #colore_').val());
});
</script>

View File

@ -65,9 +65,9 @@ if (isset($id_record)) {
<script>
$(document).ready( function(){
$('.colorpicker').colorpicker().on('changeColor', function(){
$('#colore_').parent().find('.square').css('background', $('#colore_').val());
$('#bs-popup #colore_').parent().find('.square').css('background', $('#bs-popup #colore_').val());
});
$('#colore_').parent().find('.square').css('background', $('#colore_').val());
$('#bs-popup #colore_').parent().find('.square').css('background', $('#bs-popup #colore_').val());
});
</script>

View File

@ -28,12 +28,12 @@ include_once __DIR__.'/../../core.php';
<script type="text/javascript">
$(document).ready( function(){
$('#default').click( function(){
$('#bs-popup #default').click( function(){
if (confirm ('Generare un componente di default?')){
var ini = '[Nome]\ntipo = span\nvalore = "Componente di esempio"\n\n[Marca]\ntipo = input\nvalore =\n\n[Tipo]\ntipo = select\nvalore =\nopzioni = "Tipo 1", "Tipo 2"\n\n[Data di installazione]\ntipo = date\nvalore =\n\n[Note]\ntipo = textarea\nvalore =\n';
$("#contenuto_add").val(ini);
$("#bs-popup #contenuto_add").val(ini);
}
});
});

View File

@ -35,16 +35,16 @@ foreach ($imports as $key => $value) {
</form>
<script>
$('#id_record').change( function(){
$('#bs-popup #id_record').change( function(){
if ($(this).val()>0){
$( "#example" ).removeClass('hide');
$( "#bs-popup #example" ).removeClass('hide');
}else{
$( "#example" ).addClass('hide');
$( "#bs-popup #example" ).addClass('hide');
}
});
$( "#example" ).click(function(event) {
var module = $('#id_record').find(':selected').data('text').toLowerCase();
$( "#bs-popup #example" ).click(function(event) {
var module = $('#bs-popup #id_record').find(':selected').data('text').toLowerCase();
var dir = "<?php echo ROOTDIR; ?>/modules/"+module+"/import.php";
var file = "<?php echo ROOTDIR; ?>/files/"+module+"/"+module+".csv";

View File

@ -300,23 +300,23 @@ if (!empty($id_intervento)) {
<script type="text/javascript">
$(document).ready(function(){
if(!$("#idanagrafica").val()){
$("#idsede").prop("disabled", true);
$("#idpreventivo").prop("disabled", true);
$("#idcontratto").prop("disabled", true);
$("#idimpianti").prop("disabled", true);
$("#componenti").prop("disabled", true);
if(!$("#bs-popup #idanagrafica").val()){
$("#bs-popup #idsede").prop("disabled", true);
$("#bs-popup #idpreventivo").prop("disabled", true);
$("#bs-popup #idcontratto").prop("disabled", true);
$("#bs-popup #idimpianti").prop("disabled", true);
$("#bs-popup #componenti").prop("disabled", true);
<?php
if (!empty($idcontratto) && (!empty($idordineservizio) || !empty($idcontratto_riga))) {
// Disabilito i campi che non devono essere modificati per poter collegare l'intervento all'ordine di servizio
echo '
$("#idanagrafica").prop("disabled", true);
$("#idclientefinale").prop("disabled", true);
$("#idzona").prop("disabled", true);
$("#idtipointervento").prop("disabled", true);
$("#impianti").find("button").prop("disabled", true);';
$("#bs-popup #idanagrafica").prop("disabled", true);
$("#bs-popup #idclientefinale").prop("disabled", true);
$("#bs-popup #idzona").prop("disabled", true);
$("#bs-popup #idtipointervento").prop("disabled", true);
$("#bs-popup #impianti").find("button").prop("disabled", true);';
}
?>
}
@ -325,27 +325,27 @@ if (!empty($id_intervento)) {
if (!empty($id_intervento)) {
echo '
$("#idsede").prop("disabled", true);
$("#idpreventivo").prop("disabled", true);
$("#idcontratto").prop("disabled", true);
$("#idimpianti").prop("disabled", true);
$("#componenti").prop("disabled", true);
$("#idanagrafica").prop("disabled", true);
$("#idanagrafica").find("button").prop("disabled", true);
$("#idclientefinale").prop("disabled", true);
$("#idzona").prop("disabled", true);
$("#idtipointervento").prop("disabled", true);
$("#idstatointervento").prop("disabled", true);
$("#richiesta").prop("disabled", true);
$("#data_richiesta").prop("disabled", true);
$("#impianti").find("button").prop("disabled", true);
$("#bs-popup #idsede").prop("disabled", true);
$("#bs-popup #idpreventivo").prop("disabled", true);
$("#bs-popup #idcontratto").prop("disabled", true);
$("#bs-popup #idimpianti").prop("disabled", true);
$("#bs-popup #componenti").prop("disabled", true);
$("#bs-popup #idanagrafica").prop("disabled", true);
$("#bs-popup #idanagrafica").find("button").prop("disabled", true);
$("#bs-popup #idclientefinale").prop("disabled", true);
$("#bs-popup #idzona").prop("disabled", true);
$("#bs-popup #idtipointervento").prop("disabled", true);
$("#bs-popup #idstatointervento").prop("disabled", true);
$("#bs-popup #richiesta").prop("disabled", true);
$("#bs-popup #data_richiesta").prop("disabled", true);
$("#bs-popup #impianti").find("button").prop("disabled", true);
';
}
?>
// Quando modifico orario inizio, allineo anche l'orario fine
$("#orario_inizio").on("dp.change", function (e) {
$("#orario_fine").data("DateTimePicker").minDate(e.date).format(globals.timestampFormat);
$("#bs-popup #orario_inizio").on("dp.change", function (e) {
$("#bs-popup #orario_fine").data("DateTimePicker").minDate(e.date).format(globals.timestampFormat);
});
// Refresh modulo dopo la chiusura di una pianificazione attività derivante dalle attività
@ -357,92 +357,92 @@ if (!empty($id_intervento)) {
}
});
$('#idanagrafica').change( function(){
$('#bs-popup #idanagrafica').change( function(){
session_set('superselect,idanagrafica', $(this).val(), 0);
var value = !$(this).val() ? true : false;
var placeholder = !$(this).val() ? '<?php echo tr("Seleziona prima un cliente...");?>' : '<?php echo tr("-Seleziona un\'opzione-");?>';
$("#idsede").prop("disabled", value);
$("#idsede").selectReset(placeholder);
$("#bs-popup #idsede").prop("disabled", value);
$("#bs-popup #idsede").selectReset(placeholder);
$("#idpreventivo").prop("disabled", value);
$("#idpreventivo").selectReset(placeholder);
$("#bs-popup #idpreventivo").prop("disabled", value);
$("#bs-popup #idpreventivo").selectReset(placeholder);
$("#idcontratto").prop("disabled", value);
$("#idcontratto").selectReset(placeholder);
$("#bs-popup #idcontratto").prop("disabled", value);
$("#bs-popup #idcontratto").selectReset(placeholder);
$("#idimpianti").prop("disabled", value);
$("#impianti").find("button").prop("disabled", value);
$("#idimpianti").selectReset(placeholder);
$("#bs-popup #idimpianti").prop("disabled", value);
$("#bs-popup #impianti").find("button").prop("disabled", value);
$("#bs-popup #idimpianti").selectReset(placeholder);
if (($(this).val())) {
if (($(this).selectData().idzona)){
$('#idzona').val($(this).selectData().idzona).change();
$('#bs-popup #idzona').val($(this).selectData().idzona).change();
}else{
$('#idzona').val('').change();
$('#bs-popup #idzona').val('').change();
}
// session_set('superselect,idzona', $(this).selectData().idzona, 0);
}
});
$('#idsede').change( function(){
$('#bs-popup #idsede').change( function(){
session_set('superselect,idsede', $(this).val(), 0);
$("#idimpianti").selectReset();
$("#bs-popup #idimpianti").selectReset();
if (($(this).val())) {
if (($(this).selectData().idzona)){
$('#idzona').val($(this).selectData().idzona).change();
$('#bs-popup #idzona').val($(this).selectData().idzona).change();
}else{
$('#idzona').val('').change();
$('#bs-popup #idzona').val('').change();
}
// session_set('superselect,idzona', $(this).selectData().idzona, 0);
}
});
$('#idpreventivo').change( function(){
if($('#idcontratto').val() && $(this).val()){
$("#idcontratto").selectReset();
$('#bs-popup #idpreventivo').change( function(){
if($('#bs-popup #idcontratto').val() && $(this).val()){
$("#bs-popup #idcontratto").selectReset();
}
if($(this).val()){
$('#idtipointervento').selectSetNew($(this).selectData().idtipointervento, $(this).selectData().idtipointervento_descrizione);
$('#bs-popup #idtipointervento').selectSetNew($(this).selectData().idtipointervento, $(this).selectData().idtipointervento_descrizione);
}
});
$('#idcontratto').change( function(){
if($('#idpreventivo').val() && $(this).val()){
$("#idpreventivo").selectReset();
$('#bs-popup #idcontratto').change( function(){
if($('#bs-popup #idpreventivo').val() && $(this).val()){
$("#bs-popup #idpreventivo").selectReset();
$('input[name=idcontratto_riga]').val('');
}
});
$('#idimpianti').change( function(){
$('#bs-popup #idimpianti').change( function(){
session_set('superselect,marticola', $(this).val(), 0);
$("#componenti").prop("disabled", !$(this).val() ? true : false);
$("#componenti").selectReset();
$("#bs-popup #componenti").prop("disabled", !$(this).val() ? true : false);
$("#bs-popup #componenti").selectReset();
});
// tempo standard
$('#idtipointervento').change( function(){
$('#bs-popup #idtipointervento').change( function(){
if ( (($(this).selectData().tempo_standard)>0) && ('<?php echo filter('orario_fine'); ?>' == '')){
tempo_standard = $(this).selectData().tempo_standard;
data = moment($('#orario_inizio').val(), globals.timestampFormat);
data = moment($('#bs-popup #orario_inizio').val(), globals.timestampFormat);
orario_fine = data.add(tempo_standard, 'hours');
$('#orario_fine').val(orario_fine.format(globals.timestampFormat));
$('#bs-popup #orario_fine').val(orario_fine.format(globals.timestampFormat));
}
});
$('#idtecnico').change( function(){
$('#bs-popup #idtecnico').change( function(){
<?php if (!get('ref')) {
?>
var value = ($(this).val()>0) ? true : false;
$('#orario_inizio').prop("required", value);
$('#orario_fine').prop("required", value);
$('#data').prop("required", value);
$('#bs-popup #orario_inizio').prop("required", value);
$('#bs-popup #orario_fine').prop("required", value);
$('#bs-popup #data').prop("required", value);
<?php
} ?>
});

View File

@ -36,13 +36,13 @@ include_once __DIR__.'/../../core.php';
<script>
$(document).ready(function(){
$('#esente-add').change(function(){
$('#bs-popup #esente-add').change(function(){
var checkbox = $(this).parent().find('[type=hidden]');
if (checkbox.val() == 1) {
$("#percentuale-add").prop("disabled", true);
$("#bs-popup #percentuale-add").prop("disabled", true);
} else {
$("#percentuale-add").prop("disabled", false);
$("#bs-popup #percentuale-add").prop("disabled", false);
}
});
});

View File

@ -51,18 +51,18 @@ if ($source == 'Attività') {
<script type="text/javascript">
$(document).ready(function(){
$('#idanagrafica').change( function(){
$('#bs-popup #idanagrafica').change( function(){
session_set('superselect,idanagrafica', $(this).val(), 0);
var value = !$(this).val() ? true : false;
$("#idsede").prop("disabled", value);
$("#idsede").selectReset();
$("#bs-popup #idsede").prop("disabled", value);
$("#bs-popup #idsede").selectReset();
});
$('#idsede').change( function(){
$('#bs-popup #idsede').change( function(){
//session_set('superselect,idsede', $(this).val(), 0);
});

View File

@ -248,7 +248,7 @@ include_once __DIR__.'/../../core.php';
<script type="text/javascript">
$(document).ready( function(){
$('input[id*=dare], input[id*=avere]').each(function(){
$('#bs-popup input[id*=dare], #bs-popup input[id*=avere]').each(function(){
if($(this).val() != "<?php echo Translator::numberToLocale(0); ?>") $(this).prop("disabled", false);
});
@ -264,26 +264,26 @@ include_once __DIR__.'/../../core.php';
}
});
$('input[id*=dare]').on('keyup change', function(){
$('#bs-popup input[id*=dare]').on('keyup change', function(){
if(!$(this).prop('disabled')){
if($(this).val()) {
$(this).parent().parent().find('input[id*=avere]').prop("disabled", true);
$(this).parent().parent().find('#bs-popup input[id*=avere]').prop("disabled", true);
}
else {
$(this).parent().parent().find('input[id*=avere]').prop("disabled", false);
$(this).parent().parent().find('#bs-popup input[id*=avere]').prop("disabled", false);
}
calcolaBilancio();
}
});
$('input[id*=avere]').on('keyup change', function(){
$('#bs-popup input[id*=avere]').on('keyup change', function(){
if(!$(this).prop('disabled')){
if($(this).val()) {
$(this).parent().parent().find('input[id*=dare]').prop("disabled", true);
$(this).parent().parent().find('#bs-popup input[id*=dare]').prop("disabled", true);
}
else {
$(this).parent().parent().find('input[id*=dare]').prop("disabled", false);
$(this).parent().parent().find('#bs-popup input[id*=dare]').prop("disabled", false);
}
calcolaBilancio();
@ -297,69 +297,66 @@ include_once __DIR__.'/../../core.php';
totale_avere = 0.00;
// Calcolo il totale dare e totale avere
$('input[id*=dare]').each( function(){
$('#bs-popup input[id*=dare]').each( function(){
if( $(this).val() == '' ) valore = 0;
else valore = $(this).val().toEnglish();
totale_dare += Math.round(valore*100)/100;
});
$('input[id*=avere]').each( function(){
$('#bs-popup input[id*=avere]').each( function(){
if( $(this).val() == '' ) valore = 0;
else valore = $(this).val().toEnglish();
totale_avere += Math.round(valore*100)/100;
});
$('#totale_dare').text(totale_dare.toLocale());
$('#totale_avere').text(totale_avere.toLocale());
$('#bs-popup #totale_dare').text(totale_dare.toLocale());
$('#bs-popup #totale_avere').text(totale_avere.toLocale());
bilancio = Math.round(totale_dare*100)/100 - Math.round(totale_avere*100)/100;
if(bilancio == 0){
$("#testo_aggiuntivo").removeClass('text-danger').html("");
$("#btn_submit").removeClass('hide');
$('#btn_crea_modello').removeClass('hide');
$('#bs-popup #testo_aggiuntivo').removeClass('text-danger').html("");
$('#bs-popup #btn_submit').removeClass('hide');
$('#bs-popup #btn_crea_modello').removeClass('hide');
}
else{
$("#testo_aggiuntivo").addClass('text-danger').html("sbilancio di " + bilancio.toLocale() + " &euro;" );
$("#btn_submit").addClass('hide');
$('#btn_crea_modello').addClass('hide');
$('#bs-popup #testo_aggiuntivo').addClass('text-danger').html("sbilancio di " + bilancio.toLocale() + " &euro;" );
$('#bs-popup #btn_submit').addClass('hide');
$('#bs-popup #btn_crea_modello').addClass('hide');
}
}
// Trigger dell'evento keyup() per la prima volta, per eseguire i dovuti controlli nel caso siano predisposte delle righe in prima nota
$("input[id*=dare][value!=''], input[id*=avere][value!='']").keyup();
$("#bs-popup input[id*=dare][value!=''], #bs-popup input[id*=avere][value!='']").keyup();
$("select[id*=idconto]").click( function(){
$("input[id*=dare][value!=''], input[id*=avere][value!='']").keyup();
$("#bs-popup select[id*=idconto]").click( function(){
$("#bs-popup input[id*=dare][value!=''], #bs-popup input[id*=avere][value!='']").keyup();
});
$('#modello_primanota').change(function(){
$('#bs-popup #modello_primanota').change(function(){
var idmastrino = $(this).val();
if(idmastrino!=''){
$('#btn_crea_modello').addClass('hide');
var causale = $(this).find('option:selected').text();
$('#desc').val(causale);
$('#bs-popup #desc').val(causale);
$.get('<?php echo $rootdir; ?>/ajax_complete.php?op=get_conti&idmastrino='+idmastrino, function(data){
var conti = data.split(',');
for(i=0;i<conti.length;i++){
var conto = conti[i].split(';');
var option = $("<option selected></option>").val(conto[0]).text(conto[1]);
$('#conto'+i).selectReset();
$('#conto'+i).append(option).trigger('change');
$('#bs-popup #conto'+i).selectReset();
$('#bs-popup #conto'+i).append(option).trigger('change');
}
});
}else{
$('#btn_crea_modello').removeClass('hide');
}
});
$('#btn_crea_modello').click(function(){
$("#crea_modello").val("1");
$("#add-form").submit();
$('#bs-popup #btn_crea_modello').click(function(){
$('#bs-popup #crea_modello').val("1");
$('#bs-popup #add-form').submit();
});
});

View File

@ -31,9 +31,9 @@ include_once __DIR__.'/../../core.php';
<script>
$(document).ready( function(){
$('.colorpicker').colorpicker().on('changeColor', function(){
$('#colore_').parent().find('.square').css( 'background', $('#colore_').val() );
$('#bs-popup #colore_').parent().find('.square').css( 'background', $('#bs-popup #colore_').val() );
});
$('#colore_').parent().find('.square').css( 'background', $('#colore_').val() );
$('#bs-popup #colore_').parent().find('.square').css( 'background', $('#bs-popup #colore_').val() );
});
</script>