/** * Sub-function to collect events within a period * @param Date the starting date of the period * @param Date the ending date of the period * @param array by-ref an array of links to append new items to * @param int the length to truncate entries by * @author Andrew Eddie <*****@*****.**> */ function getEventLinks($startPeriod, $endPeriod, &$links, $strMaxLen, $minical = false) { global $event_filter; $events = CEvent::getEventsForPeriod($startPeriod, $endPeriod, $event_filter); $cwd = explode(',', w2PgetConfig('cal_working_days')); // assemble the links for the events foreach ($events as $row) { $start = new CDate($row['event_start_date']); $end = new CDate($row['event_end_date']); $date = $start; for ($i = 0, $i_cmp = $start->dateDiff($end); $i <= $i_cmp; $i++) { // the link // optionally do not show events on non-working days if ($row['event_cwd'] && in_array($date->getDayOfWeek(), $cwd) || !$row['event_cwd']) { if ($minical) { $link = array(); } else { $url = '?m=calendar&a=view&event_id=' . $row['event_id']; $link['href'] = ''; $link['alt'] = ''; $link['text'] = w2PtoolTip($row['event_title'], getEventTooltip($row['event_id']), true) . w2PshowImage('event' . $row['event_type'] . '.png', 16, 16, '', '', 'calendar') . '</a> ' . '<a href="' . $url . '"><span class="event">' . $row['event_title'] . '</span></a>' . w2PendTip(); } $links[$date->format(FMT_TIMESTAMP_DATE)][] = $link; } $date = $date->getNextDay(); } } }
$descript .= "<b> View_parent_project</b>"; //$row['event_name']; $descript .= $href_proj ? '</a>' : '<br><br>'; } if ($row['event_task']) { $href_task = '?m=tasks&a=view&task_id=' . $row['event_task']; $descript .= $href_task ? '<a href="' . $href_task . '" class="event">' : ''; $descript .= "<b> View parent task</b>"; //$row['event_name']; $descript .= $href_task ? '</a>' : ''; } if ($href | $href_edit | $href_task | $href_proj) { $descript .= "<br><br>"; } // $descript.="<br>".w2PshowImage('event' . $row['event_type'] . '.png', 16, 16, '', '', 'calendar'). $AppUI->_($types[$row['event_type']])."<br>"; $descript .= getEventTooltip($row['event_id']); //Javascript date January is 0, Dec. is 11 $html .= "{title: '{$row['event_name']}',\n start: new Date(Number({$start->year}), Number({$start->month}-1),Number({$start->day}),Number({$start->hour}),Number({$start->minute})),\n end: new Date(Number({$end->year}), Number({$end->month}-1),({$end->day}),Number({$end->hour}),Number({$end->minute})),\n \t\t\t\t\tallDay: false,\n// \t\t\t\t\tcolor:'green',\n id: Number({$row['event_id']}),\n description: '{$descript}',\n edited: false \n },\n "; } $html .= "\t\n \n \n\t\t\t],\n\n\t\t\tdroppable: true, // this allows things to be dropped onto the calendar !!!\n eventResize: function(event,dayDelta,minuteDelta,revertFunc) {\n\n event.edited=true;\n \$.post('{$w2p_base_url}/index.php?m=planner&a=test&suppressHeaders=true', { id: event.id, \n starttime: \$.fullCalendar.formatDate( event.start, 'yyyy-MM-dd HH:mm:ss' ),endtime: \$.fullCalendar.formatDate( event.end, 'yyyy-MM-dd HH:mm:ss' ) }, function(data) {\n // alert('Data Loaded: ' + data);\n if (data=='0') {\n alert('could not save to w2p. Will revert to original event data');\n revertFunc();};\n });\n if (event.edited==true) edittxt='yes' ; else edittxt='no'\n /*\n alert(\n 'The end date of ' + event.title + ' id:' + event.id + ' has been moved ' +\n dayDelta + ' days and ' +\n minuteDelta + ' minutes.'\n + 'edited='+ edittxt\n );\n\n if (!confirm('is this okay?')) {\n revertFunc();\n }\n else\n {\n }\n*/\n },\n\n eventDrop: function(event,dayDelta,minuteDelta,allDay,revertFunc) {\n\n event.edited=true;\n \$.post('{$w2p_base_url}/index.php?m=planner&a=testev&suppressHeaders=true&user_id=1', { id: event.id, \n starttime: \$.fullCalendar.formatDate( event.start, 'yyyy-MM-dd HH:mm:ss' ),endtime: \$.fullCalendar.formatDate( event.end, 'yyyy-MM-dd HH:mm:ss' ) }, function(data) {\n // alert('Data Loaded: ' + data);\n if (data=='0') {\n alert('could not save to web2project. Will revert to original event data');\n revertFunc();};\n });\n /*\n if (event.edited==true) edittxt='yes' ; else edittxt='no';\nalert(\n event.title + ' was moved ' +\n dayDelta + ' days and ' +\n minuteDelta + ' minutes.'\n );\n\n if (allDay) {\n alert('Event is now all-day');\n }else{\n alert('Event has a time-of-day');\n }\n\n if (!confirm('Are you sure about this change?')) {\n revertFunc();\n }\n*/\n },\n\n\n\ndrop: function(date, allDay) { // this function is called when something is dropped\n\t\t\t\n\t\t\t\t// retrieve the dropped element's stored Event Object\n\t\t\t\tvar originalEventObject = \$(this).data('eventObject');\n\t\t\t\t\n\t\t\t\t// we need to copy it, so that multiple events don't have a reference to the same object\n\t\t\t\tvar copiedEventObject = \$.extend({}, originalEventObject);\n\t\t\t\t //\n\t\t\t\t// assign it the date that was reported\n\t\t\t\tcopiedEventObject.start = date;\n\t\t\t\tcopiedEventObject.allDay = false; //allDay;\n\t\t\t\tcopiedEventObject.end =new Date(date.getTime()+900000);//.setTime( (date.getTime() + 900000)); \n// alert(date.getTime());alert(copiedEventObject.end);\n\n// \$(this).qtip({ content: 'Event will be displayed after insert into to database',\n//});\n\n// \$(this).qtip('show');\n\n \$.post('{$w2p_base_url}/index.php?m=planner&a=testev&suppressHeaders=true', { id: 0, event_name: copiedEventObject.title, private: 1, event_description: copiedEventObject.description,\n starttime: \$.fullCalendar.formatDate( copiedEventObject.start, 'yyyy-MM-dd HH:mm:ss' ),endtime: \$.fullCalendar.formatDate( copiedEventObject.end, 'yyyy-MM-dd HH:mm:ss' ) }, function(data) {\n // alert('Data Loaded: ' + data);\n// \$(this).qtip('hide');\n if (data=='0') {\n alert('Could not save to web2project. Can not display event at this time');\n }\n else {\n copiedEventObject.id=Number(data);\n // alert(data);\n // alert( copiedEventObject.id);\n \n//RENDER\n\n// render the event on the calendar\n\t\t\t\t// the last `true` argument determines if the event sticks (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)\n\t\t\t\t\$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);\n\t\t\t\t\n\t\t\t\t// is the remove after drop checkbox checked?\n\t\t\t\tif (\$('#drop-remove').is(':checked')) {\n\t\t\t\t\t// if so, remove the element from the Draggable Events list\n\t\t\t\t\t\$(this).remove();\n\t\t\t\t}\n//END RENDER\n };\n });\n\n\n\n\t\t\t\t\n\t\t\t}\n\n});\n\t\t\n\t});\n\n</script>"; /* $html .= '<table cellspacing="1" cellpadding="2" border="0" width="100%" class="tbl">'; $rows = 0; for ($i = 0, $n = ($end - $start) * 60 / $inc; $i < $n; $i++) { $html .= '<tr>'; $tm = $this_day->format($tf); $html .= '<td width="1%" align="right" nowrap="nowrap">' . ($this_day->getMinute() ? $tm : '<b>' . $tm . '</b>') . '</td>'; $timeStamp = $this_day->format('%H%M%S');
$tm = $this_day->format($tf); $html .= '<td width="1%" align="right" nowrap="nowrap">' . ($this_day->getMinute() ? $tm : '<b>' . $tm . '</b>') . '</td>'; $timeStamp = $this_day->format('%H%M%S'); if (isset($events2[$timeStamp])) { $count = count($events2[$timeStamp]); for ($j = 0; $j < $count; $j++) { $row = $events2[$timeStamp][$j]; $et = new CDate($row['event_end_date']); $rows = ($et->getHour() * 60 + $et->getMinute() - ($this_day->getHour() * 60 + $this_day->getMinute())) / $inc; $href = '?m=calendar&a=view&event_id=' . $row['event_id']; $alt = $row['event_description']; $html .= '<td class="event" rowspan="' . $rows . '" valign="top">'; $html .= '<table cellspacing="0" cellpadding="0" border="0"><tr>'; $html .= '<td>' . w2PshowImage('event' . $row['event_type'] . '.png', 16, 16, '', '', 'calendar'); $html .= '</td><td> <b>' . $AppUI->_($types[$row['event_type']]) . '</b></td></tr></table>'; $html .= w2PtoolTip($row['event_title'], getEventTooltip($row['event_id']), true); $html .= $href ? '<a href="' . $href . '" class="event">' : ''; $html .= $row['event_title']; $html .= $href ? '</a>' : ''; $html .= w2PendTip(); $html .= '</td>'; } } else { if (--$rows <= 0) { $html .= '<td></td>'; } } $html .= '</tr>'; $this_day->addSeconds(60 * $inc); } $html .= '</table>';