var aggiorna_dimensioni; var aggiornamento_possibile = false; var aggiornata_alt_riga = false; var aggiornata_alt_frame_body = false; var aggiornata_alt_agenda = false; var aggiornata_alt_detcli = false; var c_aggiornata_alt_frame_body = 1; var c_aggiornata_alt_agenda = 1; var c_aggiornata_alt_detcli = 1; var maintab = null; function aggiorna_dimensioni_finestra ( ) { if ( aggiornamento_possibile ) { window.location='index.php'; } } function js_ricerca_cliente ( e ) { if ( e && e.which == 13) { e.preventDefault(); } var testo = $('#iRicCli').val(); $('#imgRicLoading').toggle(); $('#EleCli').toggle(); $('#sEleCli').load('interact.php', { cmd: 1, 'riccli': testo, 'tdummy': js_random_jam() }, function( rT, tS ) { $('#imgRicLoading').toggle(); $('#EleCli').toggle(); if ( $('#sEleCli option').length == 2 ) { $("#sEleCli option:nth-child(2)").attr("selected","selected"); js_seleziona_cliente ( 'sEleCli', document ); } }); } function js_cambia_stato_pratica ( dummy, id ) { $('#'+dummy).load('interact.php', { cmd: 9, 'id': id, 'tdummy': js_random_jam() }, function( rT, tS ) { if ( rT == "OK" ) { window.location.reload(); } else { alert ( "Errore" ); //+ rT ); } }); } function jcg ( dummy, cmd, id, val1, val2, val3, agg, callback, parse_res ) { js_comando_generico ( dummy, cmd, id, val1, val2, val3, agg, callback, parse_res ); } function js_comando_generico ( dummy, cmd, id, val1, val2, val3, agg, callback, parse_res ) { if ( ! agg ) { agg = 'si'; } if ( ! callback ) { callback = ''; } if ( ! parse_res ) { parse_res = false; } $('#'+dummy).load('interact.php', { 'cmd': cmd, 'id': id, 'val1': val1, 'val2': val2, 'val3': val3, 'tdummy': js_random_jam() }, function( rT, rS ) { if ( rT == "OK" ) { if ( agg == 'si' ) { window.location.reload(); } } else { if ( ! parse_res ) { alert ( "Errore" ); // + rT ); } else { alert ( "Errore:" + rT.substring(2) ); } } if ( callback != '' ) { callback ( rT, rS ); } }); } function js_del_client_complete ( rT, rS ) { if ( rT == "OK" ) { js_deseleziona_cliente( '', window.parent.parent.document, 'si' ); js_deseleziona_cliente( '', window.parent.parent.document, 'no' ); } } function js_new_event_complete ( rT, rS ) { if ( rT == "OK" ) { $calendar.weekCalendar("refresh"); } $('#dialog_new_event').dialog ( 'close' ); } function js_comando_annota ( dummy, cmd, tab, id, txt, but, agg ) { if ( ! txt ) { txt = ""; } if ( ! but ) { but = ""; } if ( ! agg ) { agg = ""; } $('#'+dummy).load('interact.php', { 'cmd': cmd, 'id': id, 'tab': tab, 'dummy': dummy, 'txt': txt, 'but': but, 'agg': agg, 'tdummy': js_random_jam() }, function( rT, tS ) { $('#'+dummy).dialog ( 'open' ); if ( agg == 'si' && but != "" ) { $( '#'+but ).html('Not*'); } if ( agg == 'ext' && but != "" ) { $( '#'+but ).html('Note *'); } }); } function js_crea_fattura ( dummy, cmd, classe_ricerca, suff_chk1, suff_chk2 ) { if ( ! confirm ( "Confermi la creazione della fattura per le prestazioni/appuntamenti selezionati?\nUna volta emessa la fattura non sarą pił modificabile." ) ) { return false; } if ( ! suff_chk2 ) { suff_chk2 = ""; } var prestazioni = new Array (); // RICERCA CHECK $("."+classe_ricerca+":checked").each ( function ( index, element ) { var parts = this.id.split("_"); var prest = parts[1]; // VALUTA STATO var valido = true; if ( $('#'+suff_chk1+"_"+prest).val() != "" ) { valido = false; } if ( suff_chk2 != "" && $('#'+suff_chk2+"_"+prest).val() != "" ) { valido = false; } if ( valido ) { prestazioni.push( prest ); } }); // VALUTA ESECUZIONE if ( prestazioni.length ) { var ids = prestazioni.join("|"); js_comando_generico ( dummy, cmd, '', ids, '', '', 'si', '', true ); } else { alert ( "Nessuna prestazione selezionata o fatturabile" ); } } function js_deseleziona_cliente ( id, contest, speciale ) { if ( ! contest ) { contest = document; } if ( ! speciale ) { speciale = 'no'; } if ( id != '' ) { var cliente = $('#'+id, contest).val(''); } set_cliente_a_frame ( 'QUICK_FRAME', '', contest ); if ( speciale == 'no' ) { set_cliente_a_frame ( 'BODY_FRAME', '', contest ); } } function js_quick_gotoDate ( time ) { window.parent.document.getElementById('BODY_FRAME').contentWindow.document.getElementById('AGENDA_FRAME').contentWindow.$calendar.weekCalendar('gotoDate', time ); window.parent.document.getElementById('BODY_FRAME').contentWindow.maintab.tabs('select',0); } function js_seleziona_cliente ( id, contest, speciale ) { if ( ! contest ) { contest = document; } if ( ! speciale ) { speciale = 'no'; } if ( speciale == 'no' ) { var cliente = $('#'+id, contest ).val(); set_cliente_a_frame ( 'QUICK_FRAME', cliente, contest ); //alert ( "norm + " + cliente ); } else { var cliente = $('#'+id, document ).val(); //alert ( "spec + " + cliente ); } set_cliente_a_frame ( 'BODY_FRAME', cliente, contest ); } function js_nuovo_cliente ( id_db ) { var contest = window.opener.document; $('#hNuovoCliente', contest ).val( id_db ); js_seleziona_cliente ( 'hNuovoCliente', contest ); $( '#iRicCli', contest ).val(''); } function js_load_des_e_cos ( src, src1, des1, des2, des3 ) { var val = $('#'+src ).val(); var val1 = $('#'+src1).val(); if ( val ) { $.getJSON('interact.php', { "cmd": 15, "id": val, "id1": val1, 'tdummy': js_random_jam() }, function(json) { if ( json != "KO" ) { $('#'+des1).val ( json[des1] ); $('#'+des2).val ( json[des2] ); $('#'+des3).val ( json[des3] ); } }); } } function js_ricerca_generica ( e, tab, key ) { if ( e && e.which == 13) { e.preventDefault(); } var b_id = '#'+key; var t_id = b_id+"_t"; var s_id = b_id+"_s"; var i_id = b_id+"_i"; var testo = $(t_id).val(); $(i_id).toggle(); $(s_id).load('interact.php', { "cmd": 6, "tab": tab, "key": key, "ric": testo, 'tdummy': js_random_jam() }, function( rT, tS ) { $(i_id).toggle(); // alert( s_id + " " + rT + " " + tS ); /* // RIMOSSO PER EDIT if ( $(s_id+' option').length == 2 ) { $(s_id+' option:nth-child(2)').attr('selected','selected'); js_seleziona_generica ( key ); } */ }); } function js_seleziona_generica ( key ) { var b_id = '#'+key; var t_id = b_id+"_t"; var s_id = b_id+"_s"; $(b_id).val( $(s_id).val() ); $(t_id).val( $(s_id+' option:selected').text() ); } function js_home_page ( id_t, id_s ) { $('#'+id_t).val('').keyup(); js_deseleziona_cliente ( id_s, document ); } function js_selezione_agenda ( iframe, tab ) { $( '#'+tab, $('#'+iframe).contents() ).tabs(); $( '#'+tab, $('#'+iframe).contents() ).tabs('select',0); } function set_cliente_a_frame ( frame_id, cliente, contest ) { var url = ""; switch ( frame_id ) { case 'BODY_FRAME': url = 'body_wrapper.php'; break; case 'QUICK_FRAME': url = 'quick_look.php'; break; } if ( url != "" ) { url = url + "?dummy=" + js_random_jam(); if ( cliente != "" ) { url = url + '&hClient=' + cliente; } $('#'+frame_id, contest ).attr( 'src', 'empty.htm' ); $('#'+frame_id, contest ).attr( 'src', url ); //alert ( frame_id + " " + url + " " + cliente ); } } function jsoom ( tab, key, id, type, agg, ext, subid ) { js_open_operaz_manute ( tab, key, id, type, agg, ext, subid ); } function jma ( id ) { js_open_operaz_manute ( 'APPUNT', 'AP_ID', id, 'M', 'si' ); } function jia ( id ) { js_comando_generico ( 'dummy_cmd_new_event', '23', id, $('#new_event_start_time').val(), $('#new_event_user').val(), '', 'no', js_new_event_complete ); } function jsc ( id ) { js_seleziona_cliente( 'id_cli_'+id, window.parent.document, 'si' ); } function js_open_operaz_manute ( tab, key, id, type, agg, ext, subid ) { if ( ! subid ) { subid = ""; } //alert ( tab + " " + key + " " + id + " " + type + " " + agg + " Interact su altra finestra con refresh opener e sotto comando" ); var url = "interact.php?cmd=4"; url += "&tab=" + tab; url += "&key=" + key; url += "&id=" + id; url += "&ids=" + subid; url += "&tip=" + type; url += "&agg=" + agg; url += "&ext=" + ext; url += "&dummy=" + js_random_jam(); window.open( url, "Operazione", "width=650,height=650,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no" ); } function js_visualizza_fattura ( tipo, id, print ) { var url = "interact.php?cmd=28"; url += "&tipo=" + tipo; url += "&id=" + id; url += "&print=" + print; url += "&dummy=" + js_random_jam(); window.open( url, "Fattura_"+ tipo + "_" + id ); //, "fullscreen=yes" ); } function js_allegato ( tab, id ) { //alert ( tab + " " + id ) ; var url = "interact.php?cmd=18"; url += "&tab=" + tab; url += "&id=" + id; url += "&dummy=" + js_random_jam(); window.open( url, "Allegato", "width=650,height=650,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no" ); } /* ************************************************************************** */ function js_random_jam () { return Math.floor ( Math.random() * 10000000000 ); } /* ************************************************************************** */ // HINT function js_crea_hint_note ( target, tab, key ) { if ( document.getElementById ( "hint-"+target ) ) { return; } var content = ""; // "recuperare ajax - mettere classe hint-note - prova su div scrollata "; $.ajax({ url: "interact.php", data: { "cmd": "32", "tab": tab, "id": key }, cache: false, success: function (res) { content = res; if ( content != "" ) { var tobj = $('#'+target); var off = tobj.offset(); var p_top = off.top + 5 - $(document).scrollTop(); var p_left = off.left + 5 - $(document).scrollLeft() + tobj.width(); if ( p_left + 350 >= $(window).width() ) { p_left = off.left - $(document).scrollLeft() - 15 - 350 /* da hint-note */; } if ( p_top + 200 >= $(window).height() ) { p_top = off.top - $(document).scrollTop() - 15 - 200 /* da hint-note */; } if ( p_left <= 0 ) { p_left = off.left; } tobj.before( $('
').attr('id', "hint-"+target).attr('style', 'top:'+p_top+'px; left:'+p_left+'px' ).html(content).attr("class","hint-note") .mouseover(js_sospendi_rimozione_hint).mouseleave(js_abilita_e_rimuovi_hint) ); } } }); } var js_hint_abilita_rimozione = true; function js_sospendi_rimozione_hint ( ) { js_hint_abilita_rimozione = false; } function js_abilita_e_rimuovi_hint ( ) { js_hint_abilita_rimozione = true; js_rimuovi_hint_note ( ); } function js_rimuovi_hint_note () { setTimeout( function() { if ( js_hint_abilita_rimozione ) { $(".hint-note").remove(); } }, 50 ); }