REC_ID) { $WeekDayS[0] = 'P'; $WeekDayS[1] = 'E'; $WeekDayS[2] = 'T'; $WeekDayS[3] = 'K'; $WeekDayS[4] = 'N'; $WeekDayS[5] = 'R'; $WeekDayS[6] = 'L'; $WeekDayS[7] = 'P'; $oopaev = 60*60*24; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Disposition: attachment; filename=events_".DATE("Y-m-d", MKTIME(0,0,0,$fbm,$fbd,$fby)).'-'.DATE("Y-m-d", MKTIME(0,0,0,$fem,$fed,$fey)).".xls"); header("Content-Transfer-Encoding: binary "); $res = ''; $res .= xlsBOF(); $res .= xlsWriteLabel(0,0,""); $res .= xlsWriteLabel(0,1,UTF8_DECODE("Kuupäev")); $res .= xlsWriteLabel(0,2,UTF8_DECODE("Üritus")); $res .= xlsWriteLabel(0,3,"Koht"); $res .= xlsWriteLabel(0,4,"Aeg"); $res .= xlsWriteLabel(0,5,"Lisaja"); $res .= xlsWriteLabel(0,6,"Varjatud"); # PRINT"\"\";\"Kuupäev\";\"Üritus\";\"Koht\";\"Aeg\";\"Lisaja\"\n"; $adw = ''; IF ($Category) { $adw .= " AND ("; $done = false; FOREACH ($Category AS $k => $v) { IF ($done) { $adw .= " OR "; } $adw .= " FIND_IN_SET('$v', Event.Categories) "; $done = true; } $adw .= " ) "; } IF ($GeoPlace) { $adw .= " AND EventPlace.GeoPlace = '$GeoPlace' "; } IF ($County) { $adw .= " AND EventGeoPlace.County = '$County' "; } IF ($Place) { $adw .= " AND EventPlace.REC_ID = '$Place' "; } // MYSQL_QUERY("SET NAMES cp1250"); $sql = MYSQL_QUERY("SELECT Event.REC_ID, Event.Hidden, (DATE_FORMAT(EventTimes.StartTime, '%H:%i')) AS Hours, UNIX_TIMESTAMP(DATE_FORMAT(EventTimes.StartTime, '%Y-%m-%d')) AS StartDateT, UNIX_TIMESTAMP(EventTimes.StartTime) AS StartTimeT, Event.Name, Event.Extra, EventPlace.Name, CONCAT(EventUser.FirstName,' ',EventUser.LastName) AS EventAddedBy FROM Event LEFT JOIN EventTimes ON Event.REC_ID = EventTimes.MasterID LEFT JOIN EventPlace ON EventTimes.Place = EventPlace.REC_ID LEFT JOIN EventGeoPlace ON EventPlace.GeoPlace = EventGeoPlace.REC_ID LEFT JOIN EventUser ON Event.AddedBy = EventUser.REC_ID WHERE Event.Deleted = '0' AND DATE_FORMAT(EventTimes.StartTime, '%Y-%m-%d') BETWEEN '".DATE("Y-m-d",MKTIME(0,0,0,$fbm,$fbd,$fby))."' AND '".DATE("Y-m-d",MKTIME(0,0,0,$fem,$fed+1,$fey))."' $adw GROUP BY EventTimes.REC_ID ORDER BY EventTimes.StartTime"); print mysql_error(); $_PStartDate = MKTIME(0,0,0,$fbm,$fbd-1,$fby); $_EStartDate = MKTIME(0,0,0,$fem,$fed,$fey); $xlsRow = 1; FOR ($i = 0; $i < MYSQL_NUMROWS($sql); $i++) { $_REC_ID = MYSQL_RESULT($sql, $i, "Event.REC_ID"); $_Extra = MYSQL_RESULT($sql, $i, "Event.Extra"); $_AddedBy = UTF8_DECODE(STRIPSLASHES(MYSQL_RESULT($sql, $i, "EventAddedBy"))); $_StartTime = MYSQL_RESULT($sql, $i, "StartTimeT"); $_StartDate = MYSQL_RESULT($sql, $i, "StartDateT"); $_Hours = MYSQL_RESULT($sql, $i, "Hours"); $_Hidden = MYSQL_RESULT($sql, $i, "Event.Hidden"); $_Hidden = $_Hidden === 'true' ? true : false; IF ($_Hours == '00:00') $_Hours = ''; $_Name = UTF8_DECODE(STRIPSLASHES(MYSQL_RESULT($sql, $i, "Event.Name"))); $_Place = UTF8_DECODE(STRIPSLASHES(MYSQL_RESULT($sql, $i, "EventPlace.Name"))); IF ($_PStartDate && $_StartDate > $_PStartDate + $oopaev) { for ($j = $_PStartDate+$oopaev; $j < $_StartDate; $j += $oopaev) { $res .= xlsWriteLabel($xlsRow,0,$WeekDayS[DATE("w",$j)]); $res .= xlsWriteLabel($xlsRow,1,DATE("d.m.Y",$j)); # PRINT"\"".$WeekDayS[DATE("w",$j)]."\";\"".DATE("d.m.Y",$j)."\"\n"; $xlsRow++; } } IF ($_PStartDate <> $_StartDate): $res .= xlsWriteLabel($xlsRow,0,$WeekDayS[DATE("w",$_StartTime)]); $res .= xlsWriteLabel($xlsRow,1,DATE("d.m.Y",$_StartTime)); # PRINT"\"".$WeekDayS[DATE("w",$_StartTime)]."\";\"".DATE("d.m.Y",$_StartTime)."\";"; ELSE: # PRINT"\"\";\"\";"; ENDIF; $res .= xlsWriteLabel($xlsRow,2,$_Name); $res .= xlsWriteLabel($xlsRow,3,$_Place); $res .= xlsWriteLabel($xlsRow,4,$_Hours); $res .= xlsWriteLabel($xlsRow,5,$_AddedBy); $res .= xlsWriteLabel($xlsRow,6,($_Hidden ? 'jah' : 'ei')); # PRINT"\"$_Name\";\"$_Place\";\"$_Hours\";\"$_AddedBy\"\n"; $_PStartDate = $_StartDate; $xlsRow++; } IF ($_PStartDate < $_EStartDate) { for ($j = $_PStartDate+$oopaev; $j < $_EStartDate; $j += $oopaev) { $res .= xlsWriteLabel($xlsRow,0,$WeekDayS[DATE("w",$j)]); $res .= xlsWriteLabel($xlsRow,1,DATE("d.m.Y",$j)); # PRINT"\"".$WeekDayS[DATE("w",$j)]."\";\"".DATE("d.m.Y",$j)."\"\n"; $xlsRow++; } } $res .= xlsEOF(); Header('Content-length: '.strlen($res)); print $res; EXIT; } if ($op == 'events') { IF ($cat) $CName = @STRIPALL(MYSQL_RESULT(MYSQL_QUERY("SELECT Name FROM EventCategory WHERE REC_ID = '$cat'"), 0, "Name")); IF ($geo) $GName = @STRIPALL(MYSQL_RESULT(MYSQL_QUERY("SELECT Name FROM EventGeoPlace WHERE REC_ID = '$geo'"), 0, "Name")); } ?> Kultuuri.net