Ejemplo n.º 1
0
 /**
  * Create a Google_Service_Calendar_EventDateTime
  *
  * var $time String
  * return Google_Service_Calendar_EventDateTime
  */
 private function newDateTime($time = false)
 {
     $dateTime = new \Google_Service_Calendar_EventDateTime();
     $date = $this->newDate($time);
     $dateTime->setDateTime($date);
     $dateTime->setTimeZone(date_default_timezone_get());
     return $dateTime;
 }
Ejemplo n.º 2
0
 public function CalenderTime_Convertion($startdate,$startdate_starttime,$startdate_endtime){
     if($startdate!=''&&$startdate_starttime!=''&&$startdate_endtime!='') {
         $splitStart = explode(':', $startdate_starttime);
         $startdate_starttime = $splitStart[0] . ':' . $splitStart[1];
         $splitEnd = explode(':', $startdate_endtime);
         $startdate_endtime = $splitEnd[0] . ':' . $splitEnd[1];
     }
     $start = new Google_Service_Calendar_EventDateTime();
     $start->setDateTime($startdate.'T'.$startdate_starttime.':00.000+08:00');
     $end = new Google_Service_Calendar_EventDateTime();
     $end->setDateTime($startdate.'T'.$startdate_endtime.':00.000+08:00');
     return array($start,$end);
 }
Ejemplo n.º 3
0
 public function testModelMutation()
 {
     $htmlLink = 'https://www.google.com/calendar/event?' . 'eid=NWdpMmFjNDkzbm5yZzh2N2poZXNhZmdldDggaWFuLmJhcmJlckBt';
     $data = json_decode('{
        "kind": "calendar#event",
        "etag": "\\"-kteSF26GsdKQ5bfmcd4H3_-u3g/MTE0NTUyNTAxOTk0MjAwMA\\"",
        "id": "1234566",
        "status": "confirmed",
        "htmlLink": "' . $htmlLink . '",
        "created": "2006-04-13T14:22:08.000Z",
        "updated": "2006-04-20T09:23:39.942Z",
        "summary": "Evening Jolt Q3 CTFL",
        "description": "6.30 - Adminning\\n9.30 - Game",
        "creator": {
          "email": "*****@*****.**",
          "displayName": "Ian Test",
          "self": true
        },
        "organizer": {
          "email": "*****@*****.**",
          "displayName": "Ian Test",
          "self": true
        },
        "start": {
          "date": "2006-04-23"
        },
        "end": {
          "date": "2006-04-24"
        },
        "iCalUID": "*****@*****.**",
        "sequence": 0,
        "reminders": {
          "useDefault": false
        }
      }', true);
     $event = new Google_Service_Calendar_Event($data);
     $date = new Google_Service_Calendar_EventDateTime();
     date_default_timezone_set('UTC');
     $dateString = Date("c");
     $summary = "hello";
     $date->setDate($dateString);
     $event->setStart($date);
     $event->setEnd($date);
     $event->setSummary($summary);
     $simpleEvent = $event->toSimpleObject();
     $this->assertEquals($dateString, $simpleEvent->start->date);
     $this->assertEquals($dateString, $simpleEvent->end->date);
     $this->assertEquals($summary, $simpleEvent->summary);
     $event2 = new Google_Service_Calendar_Event();
     $this->assertNull($event2->getStart());
 }
Ejemplo n.º 4
0
 /**
  * @param string $calendarId
  * @param string $summary
  * @param \DateTimeImmutable $start
  * @param \DateTimeImmutable $end
  * @param null|string $description
  * @return string Event ID in calendar
  */
 public function insertEvent($calendarId, $summary, \DateTimeImmutable $start, \DateTimeImmutable $end, $description = null)
 {
     $event = new \Google_Service_Calendar_Event();
     $event->setSummary($summary);
     $eventStart = new \Google_Service_Calendar_EventDateTime();
     $eventStart->setDateTime($start->format('c'));
     $event->setStart($eventStart);
     $eventEnd = new \Google_Service_Calendar_EventDateTime();
     $eventEnd->setDateTime($end->format('c'));
     $event->setEnd($eventEnd);
     $event->setDescription($description);
     $createdEvent = $this->service->events->insert($calendarId, $event);
     return $createdEvent->id;
 }
 public function registrarEvento()
 {
     require_once 'complements/Google/Client.php';
     require_once 'complements/Google/Service/Calendar.php';
     session_start();
     $client = new Google_Client();
     $client->setApplicationName("Google Calendar PHP Starter Application");
     // Visit https://code.google.com/apis/console?api=calendar to generate your
     // client id, client secret, and to register your redirect uri.
     $client->setClientId('1027408579728-fomlujink6upq6e1j2fu7nb4tu1frqq7.apps.googleusercontent.com');
     $client->setClientSecret('BTzww96MUByc_Ibsy2xX0asR');
     $client->setRedirectUri('http://www.hostf5.com.br/f5admin/agenda/redirect');
     $client->setDeveloperKey('AIzaSyB9AHH2apXJ7RJ25m5n2yLEMyhKOKA6sMU');
     $client->setScopes(array('https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.readonly'));
     $cal = new Google_Service_Calendar($client);
     if (isset($_GET['logout'])) {
         unset($_SESSION['token']);
     }
     if (isset($_GET['code'])) {
         $client->authenticate($_GET['code']);
         $_SESSION['token'] = $client->getAccessToken();
         header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
     }
     if (isset($_SESSION['token'])) {
         $client->setAccessToken($_SESSION['token']);
     }
     if ($client->getAccessToken()) {
         $event = new Google_Service_Calendar_Event();
         $event->setSummary($title);
         $event->setLocation($location);
         $start = new Google_Service_Calendar_EventDateTime();
         $start->setTimeZone('America/Montreal');
         $start->setDateTime($date . 'T' . $startTime . ':00.000-06:00');
         $event->setStart($start);
         $end = new Google_Service_Calendar_EventDateTime();
         $end->setTimeZone('America/Montreal');
         $end->setDateTime($date . 'T' . $endTime . ':00.000-06:00');
         $event->setEnd($end);
         $attendee1 = new Google_Service_Calendar_EventAttendee();
         $attendee1->setEmail($email);
         $attendees = array($attendee1);
         $event->attendees = $attendees;
         $cal->events->insert($email, $event);
         $_SESSION['token'] = $client->getAccessToken();
     } else {
         $authUrl = $client->createAuthUrl();
         print "<a class='login' href='{$authUrl}'>Connect me!</a>";
     }
 }
 /**
  * Add an Event to the specified calendar
  *
  * @param string   $calendarId        Calendar's ID in which you want to insert your event
  * @param datetime $eventStart        Event's start date
  * @param datetime $eventEnd          Event's end date
  * @param string   $eventSummary      Event's title
  * @param string   $eventDescription  Event's description where you should put all your informations
  * @param array    $eventAttendee     Event's attendees : to use the invitation system you should add the calendar owner to the attendees
  * @param array    $optionalParams    Optional params
  *
  * @return object Event
  */
 public function addEvent($calendarId, $eventStart, $eventEnd, $eventSummary, $eventDescription, $eventAttendee, $optionalParams = [])
 {
     // Your new GoogleEvent object
     $event = new \Google_Service_Calendar_Event();
     // Set the title
     $event->setSummary($eventSummary);
     // Set and format the start date
     $formattedStart = $eventStart->format(\DateTime::RFC3339);
     $formattedEnd = $eventEnd->format(\DateTime::RFC3339);
     $start = new \Google_Service_Calendar_EventDateTime();
     $start->setDateTime($formattedStart);
     $event->setStart($start);
     $end = new \Google_Service_Calendar_EventDateTime();
     $end->setDateTime($formattedEnd);
     $event->setEnd($end);
     // Default status for newly created event
     $event->setStatus('tentative');
     // Set event's description
     $event->setDescription($eventDescription);
     // Attendees - permit to manage the event's status
     $attendee = new \Google_Service_Calendar_EventAttendee();
     $attendee->setEmail($eventAttendee);
     $event->attendees = [$attendee];
     // Event insert
     return $this->getCalendarService()->events->insert($calendarId, $event, $optionalParams);
 }
 public function testModelMutation()
 {
     $data = json_decode($this->calendarData, true);
     $event = new Google_Service_Calendar_Event($data);
     $date = new Google_Service_Calendar_EventDateTime();
     date_default_timezone_set('UTC');
     $dateString = Date("c");
     $summary = "hello";
     $date->setDate($dateString);
     $event->setStart($date);
     $event->setEnd($date);
     $event->setSummary($summary);
     $simpleEvent = $event->toSimpleObject();
     $this->assertEquals($dateString, $simpleEvent->start->date);
     $this->assertEquals($dateString, $simpleEvent->end->date);
     $this->assertEquals($summary, $simpleEvent->summary);
     $event2 = new Google_Service_Calendar_Event();
     $this->assertNull($event2->getStart());
 }
Ejemplo n.º 8
0
 function addEvent($calendarId, $summary, $description, $location, $dataTimeStart, $dataTimeEnd, $email, $accept)
 {
     $event = new Google_Service_Calendar_Event();
     $event->setSummary($summary);
     $event->setLocation($location);
     $event->setDescription($description);
     $event->setVisibility('public');
     $start = new Google_Service_Calendar_EventDateTime();
     $start->setDateTime($dataTimeStart);
     $start->setTimeZone('America/Bogota');
     $event->setStart($start);
     $end = new Google_Service_Calendar_EventDateTime();
     $end->setDateTime($dataTimeEnd);
     $end->setTimeZone('America/Bogota');
     $event->setEnd($end);
     $reminder1 = new Google_Service_Calendar_EventReminder();
     $reminder1->setMethod('email');
     $reminder1->setMinutes('55');
     $reminder2 = new Google_Service_Calendar_EventReminder();
     $reminder2->setMethod('email');
     $reminder2->setMinutes('15');
     $reminder = new Google_Service_Calendar_EventReminders();
     $reminder->setUseDefault('false');
     $reminder->setOverrides(array($reminder1, $reminder2));
     $event->setReminders($reminder);
     //$event->setRecurrence(array('RRULE:FREQ=WEEKLY;UNTIL=20110701T170000Z'));
     $attendee1 = new Google_Service_Calendar_EventAttendee();
     $attendee1->setEmail($email);
     if ($accept == "true") {
         $attendee1->setResponseStatus('accepted');
     }
     $attendees = array($attendee1);
     $event->attendees = $attendees;
     $optParams = array('sendNotifications' => true, 'maxAttendees' => 1000);
     /*$creator = new Google_Service_Calendar_EventCreator();
             $creator->setDisplayName("UNAD Calendar");
             $creator->setEmail("*****@*****.**");
     
             $event->setCreator($creator);*/
     $nEvent = $this->service->events->insert($calendarId, $event, $optParams);
     return $nEvent;
 }
Ejemplo n.º 9
0
 /**
  * add event
  * @param string $class          class string(A,B,C,D,E)
  * @param string $subject        event title
  * @param int    $start_timestamp event start timestamp value
  * @param int    $end_timestamp  event end timestamp value
  */
 public function addEvent($class, $subject, $start_timestamp, $end_timestamp)
 {
     $pd_calendar_id = $this->getPdCalendarId($class);
     $event = new Google_Service_Calendar_Event();
     $event->setSummary($subject);
     $start_datetime = new Google_Service_Calendar_EventDateTime();
     $start_datetime->setDateTime(date('c', $start_timestamp));
     $event->setStart($start_datetime);
     $end_datetime = new Google_Service_Calendar_EventDateTime();
     $end_datetime->setDateTime(date('c', $end_timestamp));
     $event->setEnd($end_datetime);
     $reminder = new Google_Service_Calendar_EventReminder();
     $reminder->setMethod('popup');
     $reminder->setMinutes(10);
     $reminders = new Google_Service_Calendar_EventReminders();
     $reminders->setUseDefault(false);
     $reminders->setOverrides(array($reminder));
     $event->setReminders($reminders);
     echo "invent insert" . $class . ":" . date('c', $start_timestamp) . ":" . $subject . "\n";
     $this->getServiceCalendar()->events->insert($pd_calendar_id, $event);
 }
Ejemplo n.º 10
0
require_once dirname(__FILE__) . '/lib/autoloader.php';
// config parse
$pd_config = new PdConfig();
if ($pd_config->hasErrors()) {
    echo $pd_config->getErrorMessageText();
    exit(1);
}
$pd_calendar = new PdCalendar();
$pd_calendar->setAuthEmail($pd_config->getGcalAuthEmail());
$pd_calendar->setP12Key(file_get_contents($pd_config->getGcalP12KeyfilePath()));
$subject = 'イベント登録テスト';
$start_timestamp = strtotime('2015-04-09 07:00');
$end_timestamp = strtotime('2015-04-09 08:00');
$event = new Google_Service_Calendar_Event();
$event->setSummary($subject);
$start_datetime = new Google_Service_Calendar_EventDateTime();
$start_datetime->setDateTime(date('c', $start_timestamp));
$event->setStart($start_datetime);
$end_datetime = new Google_Service_Calendar_EventDateTime();
$end_datetime->setDateTime(date('c', $end_timestamp));
$event->setEnd($end_datetime);
$reminder = new Google_Service_Calendar_EventReminder();
$reminder->setMethod('popup');
$reminder->setMinutes(13);
$reminders = new Google_Service_Calendar_EventReminders();
$reminders->setUseDefault(false);
$reminders->setOverrides(array($reminder));
$event->setReminders($reminders);
echo "invent insert" . ":" . date('c', $start_timestamp) . ":" . $subject . "\n";
$pd_calendar->getServiceCalendar()->events->insert($pd_calendar->getPdCalendarId('C'), $event);
Ejemplo n.º 11
0
 /**
  * Creates a Google EventDateTime object.
  *
  * @param string $dateTime
  * @param string $timeZone
  * @param bool   $allDay
  *
  * @return \Google_Service_Calendar_EventDateTime
  */
 private function createDateTime($dateTime, $timeZone, $allDay = false)
 {
     $date = new \Google_Service_Calendar_EventDateTime();
     /*
      * If an event is all day, only the date must be set
      *
      * ex.
      *  - All Day - YYYY-MM-DD
      *  - Not All Day - YYYY-MM-DD\TH:I:S:
      */
     if ($allDay) {
         $date->setDate($dateTime);
     } else {
         $date->setDateTime($dateTime);
     }
     $date->setTimeZone($timeZone);
     return $date;
 }
Ejemplo n.º 12
0
/**
 * Book a specific range of dates. A start date and end date
 * combination is provided. If the dates free, the dates
 * are marked as booked. The range is inclusive.
 * @param service the service which the API is 
 * 			called through
 * @param summary - the title of the event
 * @param date_start the start date of the event
 * @param date_end the end date of the event
 * @return nothing
 */
function bookDates($service, $summary, $date_start, $date_end)
{
    $calendarId = '*****@*****.**';
    date_default_timezone_set('Europe/Berlin');
    $event = new Google_Service_Calendar_Event();
    $event->setSummary($summary);
    // $event->setLocation('At the orchard');
    $start = new Google_Service_Calendar_EventDateTime();
    $start->setDateTime($date_start);
    $event->setStart($start);
    $end = new Google_Service_Calendar_EventDateTime();
    $end->setDateTime($date_end);
    $event->setEnd($end);
    $createdEvent = $service->events->insert($calendarId, $event);
}
Ejemplo n.º 13
0
 public function handleTask(&$context)
 {
     $entityDataKey = "block_" . $this->getBlockId() . "_eventid";
     // Setze das Datum und verwende das RFC 3339 Format.
     $startDate = $this->get("eventstartdate", $context);
     $this->addStat('Startdate' . $startDate);
     $startTime = $this->get("eventstarttime", $context);
     $this->addStat('Starttime' . $startTime);
     $parts = explode(':', $startTime);
     if (count($parts) == 3) {
         $startTime = $parts[0] . ':' . $parts[1];
     }
     if (strlen($startTime) < 5) {
         $startTime = "0" . $startTime;
     }
     $duration = $this->get("eventduration", $context);
     $date = strtotime("+" . $duration . " minutes", strtotime($startDate . " " . $startTime));
     $endDate = date("Y-m-d", $date);
     $endTime = date("H:i", $date);
     $tzOffset = "+01";
     $this->init();
     if (1 == 0 && $context->existEntityData($entityDataKey)) {
         $entityId = $context->getEntityData($entityDataKey);
         try {
             $event = $service->getCalendarEventEntry($entityId);
             $when = $service->newWhen();
             $when->startTime = "{$startDate}T{$startTime}:00.000{$tzOffset}:00";
             $when->endTime = "{$endDate}T{$endTime}:00.000{$tzOffset}:00";
             $event->when = array($when);
             $event->save();
             return "yes";
         } catch (Zend_Gdata_App_Exception $e) {
             $this->addStat("existing Event not found. Create new!");
         }
     }
     $event = new Google_Service_Calendar_Event();
     $event->setSummary($this->get("eventtitle", $context));
     #$event->setLocation('Somewhere');
     $start = new Google_Service_Calendar_EventDateTime();
     $start->setDateTime("{$startDate}T{$startTime}:00.000{$tzOffset}:00");
     #$start->setTimeZone('America/Los_Angeles');
     $event->setStart($start);
     $event->setDescription($this->get("eventdescr", $context));
     $end = new Google_Service_Calendar_EventDateTime();
     $end->setDateTime("{$endDate}T{$endTime}:00.000{$tzOffset}:00");
     #$end->setTimeZone('America/Los_Angeles');
     $event->setEnd($end);
     $event->setVisibility($this->get("privacy"));
     $event = $this->service->events->insert(html_entity_decode($this->get("calendar")), $event);
     $context->addEntityData($entityDataKey, $event->getId());
     $this->storeAccessKey();
     return "yes";
 }
Ejemplo n.º 14
0
 /**
  * Tarsform  Vtiger Records to Google Records
  * @param <array> $vtEvents 
  * @return <array> tranformed vtiger Records
  */
 public function transformToTargetRecord($vtEvents)
 {
     $records = array();
     foreach ($vtEvents as $vtEvent) {
         $newEvent = new Google_Service_Calendar_Event();
         if ($vtEvent->getMode() == WSAPP_SyncRecordModel::WSAPP_DELETE_MODE) {
             $newEvent->setId($vtEvent->get('_id'));
         } elseif ($vtEvent->getMode() == WSAPP_SyncRecordModel::WSAPP_UPDATE_MODE && $vtEvent->get('_id')) {
             if ($this->apiConnection->isTokenExpired()) {
                 $this->apiConnection->refreshToken();
                 $this->client->setAccessToken($this->apiConnection->getAccessToken());
                 $this->service = new Google_Service_Calendar($this->client);
             }
             $newEvent = $this->service->events->get('primary', $vtEvent->get('_id'));
         }
         $newEvent->setSummary($vtEvent->get('subject'));
         $newEvent->setLocation($vtEvent->get('location'));
         $newEvent->setDescription($vtEvent->get('description'));
         $newEvent->setVisibility(strtolower($vtEvent->get('visibility')));
         $startDate = $vtEvent->get('date_start');
         $startTime = $vtEvent->get('time_start');
         $endDate = $vtEvent->get('due_date');
         $endTime = $vtEvent->get('time_end');
         if (empty($endTime)) {
             $endTime = "00:00";
         }
         $start = new Google_Service_Calendar_EventDateTime();
         $start->setDateTime($this->googleFormat($startDate . ' ' . $startTime));
         $newEvent->setStart($start);
         $end = new Google_Service_Calendar_EventDateTime();
         $end->setDateTime($this->googleFormat($endDate . ' ' . $endTime));
         $newEvent->setEnd($end);
         $recordModel = Google_Calendar_Model::getInstanceFromValues(array('entity' => $newEvent));
         $recordModel->setType($this->getSynchronizeController()->getSourceType())->setMode($vtEvent->getMode())->setSyncIdentificationKey($vtEvent->get('_syncidentificationkey'));
         $recordModel = $this->performBasicTransformations($vtEvent, $recordModel);
         $recordModel = $this->performBasicTransformationsToTargetRecords($recordModel, $vtEvent);
         $records[] = $recordModel;
     }
     return $records;
 }
 /**
  * The customerCreate method prepares data for Stripe_Customer::create and attempts to
  * create a customer.
  *
  * @param array	$data The data passed directly to Stripe's API.
  * @return array $customer if success, string $error if failure.
  */
 public function updateEvent($data)
 {
     $client = new Google_Client();
     $client->setApplicationName("Plat");
     $key = file_get_contents($this->googleApiKeyFile);
     // separate additional scopes with a comma
     $scopes = "https://www.googleapis.com/auth/calendar";
     //$client->setScopes(array($scopes));
     $cred = new Google_Auth_AssertionCredentials($this->googleEmailAddress, array($scopes), $key);
     $client->setAssertionCredentials($cred);
     if ($client->getAuth()->isAccessTokenExpired()) {
         $client->getAuth()->refreshTokenWithAssertion($cred);
     }
     $service = new Google_Service_Calendar($client);
     $event = new Google_Service_Calendar_Event();
     //$event->setId($data['eventId']);
     $event->setSummary($data['eventSummary']);
     $event->setDescription($data['eventDescription']);
     $event->setLocation($data['eventLocation']);
     $start = new Google_Service_Calendar_EventDateTime();
     $start->setDateTime($data['eventStartDate']);
     $start->setTimeZone($data['eventTimeZone']);
     $event->setStart($start);
     $end = new Google_Service_Calendar_EventDateTime();
     $end->setDateTime($data['eventEndDate']);
     $end->setTimeZone($data['eventTimeZone']);
     $event->setEnd($end);
     $attendee1 = new Google_Service_Calendar_EventAttendee();
     $attendee1->setEmail(Configure::read("ADMIN_ORDER_EVENT_EMAIL"));
     $attendees = array($attendee1);
     $event->attendees = $attendees;
     $event->setSequence(Configure::read("GOOGLE_CALENDAR_API_SEQUENCE"));
     $calendar_id = Configure::read("GOOGLE_CALENDAR_ID");
     try {
         $updateEvent = $service->events->update($calendar_id, $data['eventId'], $event);
         //
         $new_event_status = $updateEvent->getStatus();
         return $new_event_status;
     } catch (Google_Service_Exception $e) {
         syslog(LOG_ERR, $e->getMessage());
         return $e->getMessage();
     }
 }
Ejemplo n.º 16
0
 public function onRaidModify($aRaidId)
 {
     if ($this->authenticate()) {
         $Parameters = array('raid' => $aRaidId, 'canceled' => true, 'closed' => true);
         $RaidResult = Api::queryRaid($Parameters);
         if (count($RaidResult) > 0) {
             $Raid = $RaidResult[0];
             $LocationName = $this->mLocations[$Raid['LocationId']];
             $Timezone = date_default_timezone_get();
             try {
                 date_default_timezone_set('UTC');
                 $Start = new Google_Service_Calendar_EventDateTime();
                 $Start->setDateTime(date($this->mDateFormat, intval($Raid['Start'])));
                 $Start->setTimeZone('UTC');
                 $End = new Google_Service_Calendar_EventDateTime();
                 $End->setDateTime(date($this->mDateFormat, intval($Raid['End'])));
                 $End->setTimeZone('UTC');
                 $Events = $this->mCalService->events->listEvents(GOOGLE_CAL_ID, array('sharedExtendedProperty' => 'RaidId=' . $aRaidId));
                 // There should be only one event, but we're a bit
                 // paranoid here
                 foreach ($Events->getItems() as $Event) {
                     $Event->setLocation($LocationName);
                     $Event->setDescription($Raid['Description']);
                     if ($Raid['Status'] == 'canceled') {
                         $Event->setSummary('[canceled] ' . $LocationName . ' (' . $Raid['Size'] . ')');
                     } else {
                         $Event->setSummary($LocationName . ' (' . $Raid['Size'] . ')');
                     }
                     $Event->setStart($Start);
                     $Event->setEnd($End);
                     $this->mCalService->events->update(GOOGLE_CAL_ID, $Event->getid(), $Event);
                 }
             } catch (Exception $Ex) {
                 $Out = Out::getInstance();
                 $Out->pushError($Ex->getMessage());
             }
             date_default_timezone_set($Timezone);
         }
     }
 }
Ejemplo n.º 17
0
function addDate($date)
{
    global $service;
    global $calId;
    global $existing;
    $time = $date['afternoon'] ? '14' : '09';
    $event = new Google_Service_Calendar_Event();
    $id = isset($existing[$date['id']]) ? $existing[$date['id']] : false;
    $time_test = $date['afternoon'] ? "" : 'NOT';
    #print $date['id'];
    $details = join(fetchCol("\nSELECT \n    CONCAT('*', SUBSTRING(a.first_name, 1, 1),\n      SUBSTRING(a.last_name, 1, 1),\n      if (account_id != '', \n        concat(\n          ' (',\n          if(l.last_name is not NULL, l.last_name, ''),\n          ', ',\n          if(l.first_name is not null, l.first_name, ''),\n          ') '\n        ), ''\n      ),\n      ': ',\n      a.support_needs_c\n      ) AS info\nFROM\n    arrestees a LEFT JOIN legal_lawyers l ON account_id = l.id\nWHERE\n    first_appearance_date_c = '{$date['date']}'\n        AND jurisdiction_c = IF('{$date['jurisdiction']}' = 'SF', 'SF', 'A')\n        AND if(next_hearing_time_c {$time_test} rlike '2[:00 ]*pm', 1, 0)\nGROUP BY a.id    \n   "), "\n");
    //SELECT
    //concat(l.last_name, ', ', l.first_name, ': ', sum(felony_charges), 'F/', (count(*) - sum(felony_charges)), 'M: ',
    //  group_concat( concat( substring(a.first_name, 1, 1), substring(a.last_name, 1, 1), if(felony_charges, '*', ''), ': ', a.charges_c))
    // )
    //as info FROM arrestees a join legal_lawyers l on account_id = l.id where first_appearance_date_c = '$date[date]' and jurisdiction_c = if('$date[jurisdiction]' = 'SF', 'SF', 'A') and next_hearing_time_c rlike '2[:00 ]*pm' group by account_id"), "\n");
    $notes = "";
    if ($id) {
        $event = $service->events->get($calId, $id);
        $notes = preg_replace("/.* line====!/ms", "", $event->getDescription());
        unset($existing[$date['id']]);
    } else {
        $start = new Google_Service_Calendar_EventDateTime();
        $start->setDateTime($date['date'] . 'T' . $time . ':00:00.000-08:00');
        $event->setStart($start);
        $end = new Google_Service_Calendar_EventDateTime();
        $end->setDateTime($date['date'] . 'T' . ($time + 1) . ':00:00.000-08:00');
        $event->setEnd($end);
    }
    $event->setSummary("{$date['jurisdiction']} - {$date['mis']} Mis. {$date['fel']} Fel.");
    $event->setDescription("{$details}\n!====Don't edit above this line====!{$notes}");
    if ($id) {
        $event = $service->events->update($calId, $id, $event);
    } else {
        $event = $service->events->insert($calId, $event);
    }
    return $event->getId();
}
 private function update_event_on_google_calendar($event, $ext_calendar, $ext_user, $service)
 {
     $insert_event = false;
     //update event
     if ($event->getSpecialID() != "") {
         //First retrieve the event from the google API.
         try {
             $newEvent = $service->events->get($ext_calendar->getOriginalCalendarId(), $event->getSpecialID());
         } catch (Exception $e) {
             Logger::log("Fail to get event from google: " . $event->getId());
             Logger::log($e->getMessage());
             throw $e;
         }
     }
     //insert event
     if (!$newEvent instanceof Google_Service_Calendar_Event) {
         //create google event
         $newEvent = new Google_Service_Calendar_Event();
         $insert_event = true;
     }
     $newEvent->setSummary($event->getObjectName());
     $newEvent->setDescription($event->getDescription());
     $start = new Google_Service_Calendar_EventDateTime();
     $end = new Google_Service_Calendar_EventDateTime();
     //All day event
     if ($event->getTypeId() == 2) {
         $star_time = date("Y-m-d", $event->getStart()->getTimestamp());
         $end_time = date("Y-m-d", $event->getDuration()->getTimestamp());
         $start->setDate($star_time);
         $end->setDate($end_time);
     } else {
         $star_time = date(DATE_RFC3339, $event->getStart()->getTimestamp());
         $end_time = date(DATE_RFC3339, $event->getDuration()->getTimestamp());
         $start->setDateTime($star_time);
         $end->setDateTime($end_time);
     }
     $newEvent->setStart($start);
     $newEvent->setEnd($end);
     try {
         if ($insert_event) {
             // insert event
             $createdEvent = $service->events->insert($ext_calendar->getOriginalCalendarId(), $newEvent);
         } else {
             // update event
             $createdEvent = $service->events->update($ext_calendar->getOriginalCalendarId(), $newEvent->getId(), $newEvent);
         }
     } catch (Exception $e) {
         Logger::log("Fail to add event: " . $event->getId());
         Logger::log($e->getMessage());
         throw $e;
     }
     $event->setSpecialID($createdEvent->getId());
     $event->setUpdateSync(ExternalCalendarController::date_google_to_sql($createdEvent->getUpdated()));
     $event->setExtCalId($ext_calendar->getId());
     $event->save();
     $invitation = EventInvitations::findOne(array('conditions' => array('contact_id = ' . $ext_user->getContactId() . ' AND event_id =' . $event->getId())));
     if ($invitation) {
         $invitation->setUpdateSync(ExternalCalendarController::date_google_to_sql($createdEvent->getUpdated()));
         $invitation->setSpecialId($createdEvent->getId());
         $invitation->save();
     }
 }
Ejemplo n.º 19
0
//format date
$date = str_replace('/', '', $date);
$date = substr($date, 4, 8) . '-' . substr($date, 0, 2) . '-' . substr($date, 2, 2);
$startDateTime = $date . 'T' . $startTime;
$endDateTime = $date . 'T' . $endTime;
// echo $startDateTime.' '.$endDateTime;
// echo 'eventid: '.$eventId.' summary: '.$summary.' location: '.$location.' description: '.$description.' date: '.$date.' starttime: '.$startTime.' endtime: '.$endTime;
$client = new Google_Client();
$client->setAuthConfigFile('client_secrets.json');
$client->addScope(Google_Service_Calendar::CALENDAR);
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
    $client->setAccessToken($_SESSION['access_token']);
    $service = new Google_Service_Calendar($client);
    $calendarId = '*****@*****.**';
    $event = $service->events->get($calendarId, $eventId);
    $event->setSummary($summary);
    $event->setDescription($description);
    $event->setLocation($location);
    $start = new Google_Service_Calendar_EventDateTime();
    $start->setTimeZone('America/Chicago');
    $start->setDateTime($startDateTime);
    $event->setStart($start);
    $end = new Google_Service_Calendar_EventDateTime();
    $end->setTimeZone('America/Chicago');
    $end->setDateTime($endDateTime);
    $event->setEnd($end);
    // print_r($event);
    $optParams = array('sendNotifications' => TRUE);
    $updatedEvent = $service->events->update($calendarId, $event->getId(), $event, $optParams);
    header("Location: main.php");
}
Ejemplo n.º 20
0
 /**
  * A method to edit an existing event in the google calendar
  * @param string $eventId the id of the event to be edited
  * @param string $datetimeStart the starting datetime
  * @param string $datetimeEnd the ending datetime
  * @param null $recurrence whether it should reoccur
  * @param string $timeZone
  * @return mixed the updated event id
  */
 public function editEventInCalendar($eventId, $datetimeStart = "0000-00-00T00:00:00", $datetimeEnd = "0000-00-00T00:00:00", $recurrence = null, $timeZone = "Europe/London")
 {
     # If we want the event to reoccur
     if ($recurrence) {
         $recurrence = 'RRULE:FREQ=WEEKLY;COUNT=' . $recurrence;
     } else {
         $recurrence = array();
     }
     # Get the calendar service
     $service = new Google_Service_Calendar($this->client);
     # Get the existing event from the google calendar
     $event = $service->events->get($this->getUserEmail(), $eventId);
     # Set the starting datetime
     $eventDatetimeStart = new Google_Service_Calendar_EventDateTime();
     $eventDatetimeStart->setDateTime($datetimeStart);
     $eventDatetimeStart->setTimeZone($timeZone);
     $event->setStart($eventDatetimeStart);
     # Set the ending datetime
     $eventDatetimeEnd = new Google_Service_Calendar_EventDateTime();
     $eventDatetimeEnd->setDateTime($datetimeEnd);
     $eventDatetimeEnd->setTimeZone($timeZone);
     $event->setEnd($eventDatetimeEnd);
     # Set whether it should reoccur
     $event->setRecurrence(array($recurrence));
     # Update the event
     $updatedEvent = $service->events->update($this->getUserEmail(), $event->getId(), $event);
     # Return the updated ID
     return $updatedEvent->id;
 }
Ejemplo n.º 21
0
        if ($event["title"] == $data["title"] && $event["start"] == $data["start"] && $event["end"] == $data["end"]) {
            $exist_check = true;
            # 判斷成立
            break;
        }
    }
    // 若 event 已存在的話,跳過進行下一個迴圈
    if ($exist_check) {
        echo $data["title"] . "事件已存在<br>\n";
        continue;
    }
    // 將 event 寫入 calendar 內
    $event = new Google_Service_Calendar_Event();
    $event->setSummary($data["title"]);
    // 事件標題
    $event->setLocation($data["where"]);
    // 事件地點
    $event->setDescription($data["desc"]);
    // 備註
    $start = new Google_Service_Calendar_EventDateTime();
    $start->setDateTime($data["start"]);
    $event->setStart($start);
    // 事件起始時間
    $end = new Google_Service_Calendar_EventDateTime();
    $end->setDateTime($data["end"]);
    $event->setEnd($end);
    // 事件結束時間
    $createdEvent = $service->events->insert($calendar_id, $event);
    // 將事件寫入 calendar
    echo "Event " . $createdEvent->getId() . " created.<br>\n";
}
Ejemplo n.º 22
0
            $attendees[] = $attendee;
        }
        $attendee = new Google_Service_Calendar_EventAttendee();
        $attendee->setEmail($email);
        $attendees[] = $attendee;
        $event->setAttendees($attendees);
        $start = new DateTime($date);
        $start->setTimezone(new DateTimeZone($timezone));
        $gstart = new Google_Service_Calendar_EventDateTime();
        $gstart->setDateTime($start->format(DateTime::ISO8601));
        $gstart->setTimeZone($timezone);
        $event->setStart($gstart);
        $end = new DateTime($date);
        $end->setTimezone(new DateTimeZone($timezone));
        $end->add(new DateInterval("PT1H"));
        $gend = new Google_Service_Calendar_EventDateTime();
        $gend->setDateTime($end->format(DateTime::ISO8601));
        $gend->setTimeZone($timezone);
        $event->setEnd($gend);
        //Next insert it into the calendar
        $calendarService->events->insert($calendarId, $event);
        sendMail($name, $date, $email);
        echo json_encode(true);
    }
}
function sendMail($name, $date, $to)
{
    $date = new DateTime($date);
    $timezone = "America/Los_Angeles";
    $date->setTimezone(new DateTimeZone($timezone));
    $date = $date->format('D, d M y \\a\\t h:i A');
Ejemplo n.º 23
0
 function updateEvent($recordid, $eventOld, $Data, $tzOffset = '+00:00')
 {
     set_include_path($this->root_directory . "modules/Calendar4You/");
     $startDate = $Data["date_start"];
     $endDate = $Data["due_date"];
     global $default_timezone;
     $startTime = $Data["time_start"];
     $endTime = $Data["time_end"];
     $event = $this->gService->events->get($this->selected_calendar, $eventOld);
     $event->setSummary(trim($Data["subject"]));
     $event->setDescription($Data["description"]);
     $event->setLocation(trim($Data["location"]));
     $start = new Google_Service_Calendar_EventDateTime();
     $start->setDateTime($startDate . 'T' . $this->removeLastColon($startTime) . ':00.000');
     $start->setTimeZone("{$default_timezone}");
     $event->setStart($start);
     $end = new Google_Service_Calendar_EventDateTime();
     $end->setDateTime($endDate . 'T' . $this->removeLastColon($endTime) . ':00.000');
     $end->setTimeZone("{$default_timezone}");
     $event->setEnd($end);
     $SendEventNotifications = new Google_Service_Calendar_EventReminders();
     //$SendEventNotifications->setValue(true);
     $event->setReminders($SendEventNotifications);
     $whos = $this->getInvitedUsersEmails($event, $recordid);
     if (count($whos) > 0) {
         $event->attendees = $whos;
     }
     try {
         $this->gService->events->update($this->selected_calendar, $eventOld, $event);
         $status = true;
     } catch (Exception $e) {
         $status = null;
     }
     set_include_path($this->root_directory);
     return $status;
 }
Ejemplo n.º 24
0
 /**
  * Convert google object to model
  *
  * @param \Google_Service_Calendar_EventDateTime $timeItem
  * @param \KevinDitscheid\KdCalendar\Domain\Model\Time $time
  *
  * @return \KevinDitscheid\KdCalendar\Domain\Model\Time
  */
 public static function convert($timeItem, $time = NULL)
 {
     if ($time === NULL) {
         $time = new \KevinDitscheid\KdCalendar\Domain\Model\Time();
     }
     if ($timeItem->getDate() && !$timeItem->getDateTime()) {
         $time->setDate(\date_create($timeItem->getDate()));
         $time->setDateTime(\date_create($timeItem->getDate()));
     } elseif ($timeItem->getDate() && $timeItem->getDateTime()) {
         $time->setDate(\date_create($timeItem->getDate()));
         $time->setDateTime(\date_create($timeItem->getDateTime()));
     } elseif (!$timeItem->getDate() && $timeItem->getDateTime()) {
         $time->setDate(\date_create($timeItem->getDateTime()));
         $time->setDateTime(\date_create($timeItem->getDateTime()));
     }
     $time->setTimeZone($timeItem->getTimeZone());
     return $time;
 }
Ejemplo n.º 25
0
 }
 $event = new Google_Service_Calendar_Event();
 //            $event->setSummary($eventTitle);
 //
 //            $start = new Google_Service_Calendar_EventDateTime();
 //            //5 establishes eastern time
 //            $start->setDateTime("2015-01-04T'T' . $hr . ':' . $min . ':00.000-05:00');
 //            $event->setStart($start);
 //            $end = new Google_Service_Calendar_EventDateTime();
 //            $end->setDateTime($date . 'T' . $endhr . ':' . $endmin . ':00.000-05:00');
 //            $event->setEnd($end);
 $event->setSummary("hello");
 $start = new Google_Service_Calendar_EventDateTime();
 $start->setDateTime('2015-01-03T10:22:00.000-05:00');
 $event->setStart($start);
 $end = new Google_Service_Calendar_EventDateTime();
 $end->setDateTime('2015-01-05T10:25:00.000-05:00');
 $event->setEnd($end);
 alert("hello");
 $attendee1 = new Google_Service_Calendar_EventAttendee();
 $attendee1->setEmail($email);
 $attendees = array($attendee1);
 $createdEvent = $service->events->insert('primary', $event);
 echo $createdEvent->getId();
 alert("Hello2");
 echo $date;
 echo $hr;
 echo $min;
 echo $eventTitle;
 echo $ampm;
 echo $endampm;
 public function addEventAfterReservation($hours_array, $client_id, $resDate, $reservation_id, $reserve_type)
 {
     $hour_id = $hours_array['hours_id'];
     $choosen_places = $hours_array['choosen_places'];
     $direction_id = $hours_array['dirID'];
     $instructorCursor = Dispatcher::$mysqli->query("select * from instructor join instructor_has_hours " . "on instructor.`Person_id`=instructor_has_hours.instructor_id " . "where instructor_has_hours.hours_id={$hour_id}");
     $instructorRow = $instructorCursor->fetch_assoc();
     $defaultInstructorID = $instructorRow['Person_id'];
     $defaultInstructorCalendarID = $instructorRow['calendar_id'];
     $clientCursor = Dispatcher::$mysqli->query("select * from person where id={$client_id}");
     $clientRow = $clientCursor->fetch_assoc();
     $hourCursor = Dispatcher::$mysqli->query("select *, voucher_info.`name` as voucherName from hours_to_display " . "join voucher_info on hours_to_display.during_type=voucher_info.`type` " . "where hours_to_display.id={$hour_id}");
     $hourRow = $hourCursor->fetch_assoc();
     $event = new Google_Service_Calendar_Event();
     $event->setSummary($choosen_places . " " . $hourRow['voucherName']);
     $event->setLocation('Saska, Praha 1');
     $start = new Google_Service_Calendar_EventDateTime();
     $start->setDateTime($resDate . 'T' . $hourRow['hour_from'] . ':00.000+02:00');
     $start->setTimeZone('Europe/Prague');
     $event->setStart($start);
     $end = new Google_Service_Calendar_EventDateTime();
     $end->setDateTime($resDate . 'T' . $hourRow['hour_to'] . ':00.000+02:00');
     $end->setTimeZone('Europe/Prague');
     $event->setEnd($end);
     $event->description = $clientRow['name'] . "\n" . $clientRow['email'] . "\n" . $clientRow['telefone'] . "\n" . $choosen_places . "\n\n";
     try {
         $new_event = $this->google_api_service->events->insert($defaultInstructorCalendarID, $event);
         $new_event_id = $new_event->getId();
         Dispatcher::$mysqli->query("insert into event(clndr_event_id, `instructor_Person_id`, hours_id, date, has_changes) " . "values ('{$new_event_id}', '{$defaultInstructorID}', '{$hour_id}', '{$resDate}', 0)");
         Dispatcher::$mysqli->query("insert into reservation_has_hours (reservation_id, `Person_id`, hours_id, " . "directions_en_id, " . "choosen_places, " . "date, reserve_type, event_clndr_event_id) " . "values ({$reservation_id}, {$client_id}, {$hour_id}, '{$direction_id}', {$choosen_places}, '{$resDate}', '{$reserve_type}', '{$new_event_id}')");
     } catch (Google_Service_Exception $e) {
         echo '<pre>';
         print_r($e);
         syslog(LOG_ERR, $e->getMessage());
     }
     print_r(Dispatcher::$mysqli->error);
 }
Ejemplo n.º 27
0
 /**
  * Saves event
  *
  * @param DateTime booking start
  * @param DateTime booking end
  * @param array additional booking details
  * @param string calendarId of the calendar to save it to
  * @return boolean success or failure
  */
 public function saveEvent($start_date, $end_date, $details, $calendarId)
 {
     if ($this->authorised()) {
         // get memeber details so we can build the title
         $this->Member = new Member();
         $member = $this->Member->getMemberSummaryForMember($details['member'], false);
         // build the parts of the event
         $title = $member['Member']['firstname'] . " " . $member['Member']['surname'];
         $start = new Google_Service_Calendar_EventDateTime();
         $start->setDateTime($start_date->format(self::DATETIME_STR));
         $end = new Google_Service_Calendar_EventDateTime();
         $end->setDateTime($end_date->format(self::DATETIME_STR));
         // set up the event
         $event = new Google_Service_Calendar_Event();
         $event->setSummary($title);
         $event->setDescription(json_encode($details));
         $event->setStart($start);
         $event->setEnd($end);
         // send it to google
         $created = $this->__service->events->insert($calendarId, $event);
         if ($created->getId()) {
             return true;
         }
         return false;
     }
 }
 /**
  * @param User $user
  * @param      $time
  * @param      $summary
  * @param      $description
  *
  * @return bool
  */
 public function schedule(User $user, $time, $summary, $description)
 {
     $client = $this->getAuthenticateClient($user);
     $service = new \Google_Service_Calendar($client);
     /**
      * @var \Google_Service_Calendar_Event[] $events
      */
     $events = [];
     $total = $time;
     $step = $time > 10 ? 10 : $time;
     $count = 0;
     $id = rand(11111111, 99999999);
     while ($total > 0 && $step > 1) {
         $start = $this->getNextAvaliableSchedule($client, $step);
         if (is_null($start)) {
             $step--;
             continue;
         }
         $event = new \Google_Service_Calendar_Event();
         $eventStart = new \Google_Service_Calendar_EventDateTime();
         $eventStart->setDateTime($start->format(\DateTime::RFC3339));
         $event->setStart($eventStart);
         $eventEnd = new \Google_Service_Calendar_EventDateTime();
         $end = new \DateTime('@' . $start->getTimestamp());
         $end->modify('+' . $step * 60 . ' minute');
         $eventEnd->setDateTime($end->format(\DateTime::RFC3339));
         $event->setEnd($eventEnd);
         $event->setId($id . $count++);
         $event->setSummary($summary);
         $event->setDescription($description);
         $events[] = $event;
         $total -= $step;
         $step = $step < $total ? $step : $total;
         $service->events->insert('primary', $event);
     }
     if ($total > 0) {
         foreach ($events as $event) {
             $service->events->delete('primary', $event->getId());
         }
         return false;
     }
     return $events;
 }
Ejemplo n.º 29
0
 /**
  * Creates a simple dummy event with a duration of 1 hour
  * @param string $calendar_id calendar ID
  * @param int $date_from_ts Unix TS, from date
  * @param string $name event name
  * @return error code
  */
 public function createDummyEvent($calendar_id, $date_from_ts, $name)
 {
     $init_res = $this->initService();
     if ($init_res != self::NO_ERRORS) {
         return array($init_res, null);
     }
     $date_to_ts = $date_from_ts + 3600;
     $location = 'Elsewhere';
     $event = new Google_Service_Calendar_Event();
     $event->setSummary($name);
     $event->setLocation($location);
     $start = new Google_Service_Calendar_EventDateTime();
     $start->setDateTime(date('c', $date_from_ts));
     $event->setStart($start);
     $end = new Google_Service_Calendar_EventDateTime();
     $end->setDateTime(date('c', $date_to_ts));
     $event->setEnd($end);
     try {
         $createdEvent = $this->service->events->insert($calendar_id, $event);
         return self::NO_ERRORS;
     } catch (Exception $e) {
         return self::EVENT_CREATION_ERROR;
     }
     return $createdEvent;
 }
Ejemplo n.º 30
-6
 public function updateGoogleCalendarEvent($action)
 {
     try {
         // catch google exceptions so the whole app doesn't crash if google has a problem syncing
         $admin = Yii::app()->settings;
         if ($admin->googleIntegration) {
             if (isset($this->syncGoogleCalendarId) && $this->syncGoogleCalendarId) {
                 //                    // Google Calendar Libraries
                 //                    $timezone = date_default_timezone_get();
                 //                    require_once "protected/extensions/google-api-php-client/src/Google_Client.php";
                 //                    require_once "protected/extensions/google-api-php-client/src/contrib/Google_Service_Calendar.php";
                 //                    date_default_timezone_set($timezone);
                 //
                 //                    $client = new Google_Client();
                 //                    $client->setClientId($admin->googleClientId);
                 //                    $client->setClientSecret($admin->googleClientSecret);
                 //                    //$client->setDeveloperKey($admin->googleAPIKey);
                 //                    $client->setAccessToken($this->syncGoogleCalendarAccessToken);
                 //                    $client->setUseObjects(true); // return objects instead of arrays
                 //                    $googleCalendar = new Google_Service_Calendar($client);
                 $auth = new GoogleAuthenticator();
                 $googleCalendar = $auth->getCalendarService();
                 // check if the access token needs to be refreshed
                 // note that the google library automatically refreshes the access token if we need a new one,
                 // we just need to check if this happend by calling a google api function that requires authorization,
                 // and, if the access token has changed, save this new access token
                 $testCal = $googleCalendar->calendars->get($this->syncGoogleCalendarId);
                 //                    if($this->syncGoogleCalendarAccessToken != $client->getAccessToken()){
                 //                        $this->syncGoogleCalendarAccessToken = $client->getAccessToken();
                 //                        $this->update(array('syncGoogleCalendarAccessToken'));
                 //                    }
                 $summary = $action->actionDescription;
                 if ($action->associationType == 'contacts' || $action->associationType == 'contact') {
                     $summary = $action->associationName . ' - ' . $action->actionDescription;
                 }
                 $event = $googleCalendar->events->get($this->syncGoogleCalendarId, $action->syncGoogleCalendarEventId);
                 if (is_array($event)) {
                     $event = new Google_Service_Calendar_Event($event);
                 }
                 $event->setSummary($summary);
                 if (empty($action->dueDate)) {
                     $action->dueDate = time();
                 }
                 if ($action->allDay) {
                     $start = new Google_Service_Calendar_EventDateTime();
                     $start->setDate(date('Y-m-d', $action->dueDate));
                     $event->setStart($start);
                     if (!$action->completeDate) {
                         $action->completeDate = $action->dueDate;
                     }
                     $end = new Google_Service_Calendar_EventDateTime();
                     $end->setDate(date('Y-m-d', $action->completeDate + 86400));
                     $event->setEnd($end);
                 } else {
                     $start = new Google_Service_Calendar_EventDateTime();
                     $start->setDateTime(date('c', $action->dueDate));
                     $event->setStart($start);
                     if (!$action->completeDate) {
                         $action->completeDate = $action->dueDate;
                     }
                     // if no end time specified, make event 1 hour long
                     $end = new Google_Service_Calendar_EventDateTime();
                     $end->setDateTime(date('c', $action->completeDate));
                     $event->setEnd($end);
                 }
                 if ($action->color && $action->color != '#3366CC') {
                     $colorTable = array(10 => 'Green', 11 => 'Red', 6 => 'Orange', 8 => 'Black');
                     if (($key = array_search($action->color, $colorTable)) != false) {
                         $event->setColorId($key);
                     }
                 }
                 $newEvent = $googleCalendar->events->update($this->syncGoogleCalendarId, $action->syncGoogleCalendarEventId, $event);
             }
         }
     } catch (Exception $e) {
     }
 }