Full calendar
- Questo topic ha 6 risposte, 2 partecipanti ed è stato aggiornato l'ultima volta 2 anni, 11 mesi fa da francesco.
- AutorePost
- 13 Novembre 2013 alle 13:14 #5526francescoPartecipante
Buongiorno a tutti,
ho creato una pagina web con il full calendar (lato settimana) con inizio del giorno a Domenica e fine al Sabato. Inoltre nel mio calendario (in testa) ho inserito l’icona del’excel per poter esportare i miei dati su un excel. Fin qui tutto bene. Vorrei sapere se, oltre ai miei dati esportati sull’excel (in realtà chiamo una nuova pagina php e li lavoro i dati ricevuti e creo il corrispondente excel), é possibile anche portarsi i dati relativi alla visualizzazione della settimana, ad esempio l’inizio della settimana settimana ( 11/11/2013) e fine settimana ( 16/11/2013). In pratica nel mio php mi occorrono anche queste due date.
Grazie
13 Novembre 2013 alle 15:44 #5527jqueryitaliaAmministratoreDa quel che ho capito stai utilizzando la vista basicWeek.
Per recuperare le date di inizio e fine settimana, devi utilizzare le funzioni visStart e visEnd.In pratica, supponendo che il contenitore del calendario abbia ID “calendar” e che tu voglia estrarre le date di inizio e fine settimana nel formato gg/mm/yyyy dovrai scrivere:
viewStart = $('#calendar').fullCalendar('getView').visStart; viewEnd = $('#calendar').fullCalendar('getView').visEnd; start = viewStart.getDate() + '/' + ( viewStart.getMonth() + 1 ) + '/' + viewStart.getFullYear(); end = ( viewEnd.getDate() - 1 ) + '/' + ( viewEnd.getMonth() + 1 ) + '/' + viewEnd.getFullYear();
Tieni conto che per il mese va sempre aggiunto 1 per avere il valore corretto e che al giorno di fine settimana va tolto 1 in quanto il range è da domenica a domenica, mentre la visualizzazione va da domenica a sabato.
Buon lavoro!
13 Novembre 2013 alle 18:29 #5528francescoPartecipanteTi posto il codice di creazione del mio Calendar, cosi’ mi indichi dove andare a scrivere le righe di codice da te suggerite:
function CreaCalendario(cdsede, cdtuto, cdalli, cdindi, cdmate, cdpath) { var firstUrl = null; var secondUrl = null; $('.external-class').each(function() { // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/) // it doesn't need to have a start or end var eventObject = { title: $.trim($(this).text()) // use the element's text as the event title }; // store the Event Object in the DOM element so we can get to it later $(this).data('eventObject', eventObject); // make the event draggable using jQuery UI $(this).draggable({ zIndex: 999, revert: true, // will cause the event to go back to its revertDuration: 0, // original position after the drag start: function(){ $('#calendar').fullCalendar('changeView', 'agendaWeek'); } }); }); $('#calendar').fullCalendar({ day: 'dddd, MMM d, yyyy', theme: true, header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, titleFormat: { month: 'MMMM yyyy', week: "MMMM d[ yyyy]{ '—'[ MMM] d, yyyy}", day: 'dddd, d MMMM yyyy' }, columnFormat: { month: 'ddd', week: 'ddd d', day: 'dddd M/d' }, eventColor: '#378006', editable: true, //disableDragging: true, disableResizing: true, selectable: true, droppable: false, // this allows things to be dropped onto the calendar !!! minTime: 9, firstHour: 9, maxTime: 21, lastHour: 21, allDaySlot : false, events: "php/eventi.php?cdsede="+cdsede+"&cdtuto="+cdtuto+"&cdalli="+cdalli+"&cdindi="+cdindi+"&cdmate="+cdmate+"&cdpath="+cdpath+"", eventClick: function(calEvent, jsEvent, view) { if(cdpath === 'xx01') { firstUrl = 'php/Source01.php'; secondUrl = 'php/Source02.php'; } else if(cdpath === 'xx02') { firstUrl = 'php/Source03.php'; secondUrl = 'php/Source04.php'; } $.ajax({
… etc etc etc …
Grazie 1000
13 Novembre 2013 alle 19:09 #5530jqueryitaliaAmministratoreSe devi passare i dati al file php che ti stampa l’Excel, inseriscili prima della chiamata 😉
14 Novembre 2013 alle 11:21 #5531francescoPartecipanteMi permetto di chiedere un ulteriore aiuto poiché non capisco dove poter inserire le istruzioni relative al prelievo delle due date, che dovrei poi passare al pgm che costruisce il mio excel.
Questa é la funzione CreaCalendario (posto il codice con le righe iniziali):function CreaCalendario(param01, param02,.....) { var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); var firstUrl = null; var secondUrl = null; $('.external-class').each(function() { // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/) // it doesn't need to have a start or end var eventObject = { title: $.trim($(this).text()) // use the element's text as the event title }; // store the Event Object in the DOM element so we can get to it later $(this).data('eventObject', eventObject); // make the event draggable using jQuery UI $(this).draggable({ zIndex: 999, revert: true, // will cause the event to go back to its revertDuration: 0, // original position after the drag start: function(){ $('#calendar').fullCalendar('changeView', 'agendaWeek'); } }); }); $('#calendar').fullCalendar({ day: 'dddd, MMM d, yyyy', theme: true, header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, titleFormat: { month: 'MMMM yyyy', week: "MMMM d[ yyyy]{ '—'[ MMM] d, yyyy}", day: 'dddd, d MMMM yyyy' }, columnFormat: { month: 'ddd', week: 'ddd d', day: 'dddd M/d' }, eventColor: '#378006', editable: true, //disableDragging: true, disableResizing: true, selectable: true, droppable: false, // this allows things to be dropped onto the calendar !!! minTime: 9, firstHour: 9, maxTime: 21, lastHour: 21, allDaySlot : false, events: "php/eventi.php?param01="+param01+"¶m02="+param02+....", eventClick: function(calEvent, jsEvent, view)
Ho questo ajax che mi chiama il php gestione01.php, dove ho la chiamata al secondo php per la gestione dei dati che andranno stampati su excel.
$.ajax( { type: "GET", url: "gestione01.php", data: "param01="+param01+"¶m02="+param02+"¶m03="+param03, dateType: 'html', cache: false, success: function(msg) { $('#dialog').html(msg); $('#dialog').dialog( { width: 1200, height: 600, modal: true, buttons: { "Esci": function() { $(this).dialog("close"); } } ,open: function() { var cd0001 = " "; CreaCalendario(cd0001, cd0002, cd0003); } }); } });
Questo é il secondo php (frammento di pgm):
<?php //include('session.php'); $param01 = $_GET['param01']; $param02 = $_GET['param02']; $param03 = $_GET['param03']; $stringa = (htmlentities('Planning della settimana: ')).' '.$param01.' '.$param02; ?> <fieldset> <div align="center"> <h2><font color = "green"><?php echo $stringa; ?></font></h2></div> <br> <table border="0" cellpadding="0" cellspacing="0" width="100%" id='tableContent'> ¶m02=<?php echo $param02;?>"> </table> <br> <br> <table border="0" cellpadding="0" cellspacing="0" width="100%" id='tableContent'> <div align="center" id='calendar'> </div> </table> </fieldset> <div id="dialog" style="background-color:#CCCCCC; display:none"></div>
Naturalmente c’é anche una seconda soluzione. Cioé reperire le due date (Domenica 10/11/2013 e Sabato 16/11/2013) lavorando con una nuova funzione in php (reperisco la data odierna di lavoro e vado avanti e indietro per reperire il Sabato (16/11/2013) e la Domenica (10/11/2013). Però non vorrei risolvere il problema con questa seconda opzione.
Grazie.
14 Novembre 2013 alle 19:21 #5533jqueryitaliaAmministratoreSe non ho capito male, la chiamata ajax la fai all’interno della funzione eventClick di FullCalendar.
Quindi:..... eventClick: function(calEvent, jsEvent, view) { if(cdpath === 'xx01') { firstUrl = 'php/Source01.php'; secondUrl = 'php/Source02.php'; } else if ( cdpath === 'xx02' ) { firstUrl = 'php/Source03.php'; secondUrl = 'php/Source04.php'; } viewStart = $('#calendar').fullCalendar('getView').visStart; viewEnd = $('#calendar').fullCalendar('getView').visEnd; start = viewStart.getDate() + '/' + ( viewStart.getMonth() + 1 ) + '/' + viewStart.getFullYear(); end = ( viewEnd.getDate() - 1 ) + '/' + ( viewEnd.getMonth() + 1 ) + '/' + viewEnd.getFullYear(); $.ajax({ .....
Se così non fosse, basta semplicemente che aggiungi le righe prima della chiamata ajax, “portandoti dietro” le variabili start ed end. 😉
15 Novembre 2013 alle 10:11 #5534francescoPartecipanteBuongiorno,
ok funziona. Grazie per l’aiuto.
Franco
- AutorePost
- Devi essere connesso per rispondere a questo topic.