328
define('STAT_LAYOUT_START', 'LayoutStart');
329
define('STAT_LAYOUT_END', 'LayoutEnd');
330
define('STAT_MEDIA_START', 'MediaStart');
331
define('STAT_MEDIA_END', 'MediaEnd');
334
* Records a Stat Record
336
* @param $statType Object
337
* @param $statDate Object
338
* @param $scheduleID Object
339
* @param $displayID Object
340
* @param $layoutID Object
341
* @param $mediaID Object
342
* @param $start Object
345
function StatRecord($statType, $statDate, $scheduleID, $displayID, $layoutID, $mediaID, $start, $end)
349
$infinityDate = "2050-12-31 00:00:00";
351
// Look up the stat type
354
case STAT_LAYOUT_START:
355
// If its a layout start
356
// Check for an open Layout which has this schedule & close it
358
$SQL .= " UPDATE stat SET end = '$end' WHERE scheduleID = '$scheduleID' AND layoutID = '$layoutID' AND end = '$infinityDate' ";
360
if (!$db->query($SQL))
362
trigger_error($db->error());
366
// Insert a new stat record for this layout
368
$SQL .= " INSERT INTO stat (statDate, scheduleID, displayID, layoutID, start, end)";
369
$SQL .= " VALUES ('$statDate', '$scheduleID', '$displayID', '$layoutID', '$start', '$infinityDate')";
371
if (!$db->query($SQL))
373
trigger_error($db->error());
379
case STAT_LAYOUT_END:
380
// If its a layout end
381
// Close the layout stat record for this schedule (by updating the end time)
382
// Also close any open media records (they should all be shut anyway)
384
$SQL .= " UPDATE stat SET end = '$end' WHERE scheduleID = '$scheduleID' AND layoutID = '$layoutID' AND end = '$infinityDate' ";
386
if (!$db->query($SQL))
388
trigger_error($db->error());
393
case STAT_MEDIA_START:
394
// If its a media start
395
// Create a new media stat record for this layout
397
$SQL .= " INSERT INTO stat (statDate, scheduleID, displayID, layoutID, mediaID, start, end)";
398
$SQL .= " VALUES ('$statDate', '$scheduleID', '$displayID', '$layoutID', '$mediaID', '$start', '$infinityDate')";
400
if (!$db->query($SQL))
402
trigger_error($db->error());
408
// If its a media end
409
// Close the stat record
411
$SQL .= " UPDATE stat SET end = '$end' WHERE scheduleID = '$scheduleID' AND layoutID = '$layoutID' AND mediaID = '$mediaID' AND end = '$infinityDate' ";
413
if (!$db->query($SQL))
415
trigger_error($db->error());
428
329
* Gets web safe colors