Ejemplo n.º 1
0
<?php

namespace Ventus\Calendar;

require '../includes/php/bootstrap.php';
//============================================================================================
// Model
//============================================================================================
$hol = new Holidays($dbo);
$department_ids = array('global' => array('department_id' => null, 'cfname' => 'SASS', 'clname' => '', 'description' => 'SASS Event'), 'access' => array('department_id' => SERVICE_ID_ACCESS, 'cfname' => 'Access', 'clname' => 'Service', 'description' => ''), 'counselling' => array('department_id' => SERVICE_ID_COUNSELLING, 'cfname' => 'Counselling', 'clname' => 'Service', 'description' => ''));
$event_array = array();
if (isset($department_ids[$_GET['page']])) {
    $hols = array_filter($hol->listHolidayEvents($_GET['start'], $_GET['end']), function ($h) use($department_ids) {
        return $h['department_id'] === $department_ids[$_GET['page']]['department_id'];
    });
    //Create the event array the itself holds event objects
    foreach ($hols as $h) {
        $event_array[] = array('id' => $h['holiday_id'], 'title' => "{$h['holiday_name_fr']} - {$h['holiday_name']}", 'start' => $h['holiday_start'], 'end' => $h['holiday_end'], 'className' => 'sassglobal', 'description' => $department_ids[$_GET['page']]['description'], 'sname' => ' ', 'estatus' => '', 'allDay' => false, 'cfname' => $department_ids[$_GET['page']]['cfname'], 'clname' => $department_ids[$_GET['page']]['clname'], 'color' => 'black', 'textColor' => 'white', 'borderColor' => 'black');
    }
}
header('Content-Type: application/json; charset=utf-8');
echo json_encode($event_array);
exit;