test() ) { $failed = true; break; } } } # end if pre_sql_conditions if ( $failed ) { ZM\Logger::Debug("Pre conditions failed, not doing sql"); } $results = $failed ? null : dbQuery($eventsSql); $nEvents = $results ? $results->rowCount() : 0; ZM\Logger::Debug("Pre conditions succeeded sql return $nEvents events"); if ( !empty($limit) && ($nEvents > $limit) ) { $nEvents = $limit; } $pages = (int)ceil($nEvents/ZM_WEB_EVENTS_PER_PAGE); #Logger::Debug("Page $page Limit $limit #vents: $nEvents pages: $pages "); if ( !empty($page) ) { if ( $page < 0 ) $page = 1; else if ( $pages and ( $page > $pages ) ) $page = $pages; $limitStart = (($page-1)*ZM_WEB_EVENTS_PER_PAGE); if ( empty($limit) ) { $limitAmount = ZM_WEB_EVENTS_PER_PAGE; } else { $limitLeft = $limit - $limitStart; $limitAmount = ($limitLeft>ZM_WEB_EVENTS_PER_PAGE)?ZM_WEB_EVENTS_PER_PAGE:$limitLeft; } $eventsSql .= " LIMIT $limitStart, $limitAmount"; } else if ( !empty($limit) ) { $eventsSql .= ' LIMIT 0, '.$limit; } $maxShortcuts = 5; $pagination = getPagination($pages, $page, $maxShortcuts, $filterQuery.$sortQuery.$limitQuery); $focusWindow = true; $storage_areas = ZM\Storage::find(); $StorageById = array(); foreach ( $storage_areas as $S ) { $StorageById[$S->Id()] = $S; } xhtmlHeaders(__FILE__, translate('Events')); ?>