コード例 #1
0
 static function hoursMergeForRidesInfo($weekdayHours, $dateHours)
 {
     $result = array();
     MainController::printArray($dateHours);
     //        if ($weekdayHours['hour_from'] == $dateHours['hour_from']
     //                && $weekdayHours['hour_to'] == $dateHours['hour_to']
     //                && $weekdayHours['direction_id'] == $dateHours['direction_id'])
     //        {
     //            $result[] = $weekdayHours;
     //        }
     self::sortHours($result);
     return $result;
 }
コード例 #2
0
 public function addInstructorCalendarEvent($reservationsInfo, $instructorInfo, $prevInsrtuctorInfo, $hoursInfo)
 {
     $date = "";
     $description = "";
     $total_choosen_places = 0;
     $attendee_index = 0;
     $instructorID = $instructorInfo['id'];
     $hour_id = $hoursInfo['id'];
     $prevInsrtuctorID = $prevInsrtuctorInfo['id'];
     $reservationsInfoSize = count($reservationsInfo);
     for ($resIndex = 0; $resIndex < $reservationsInfoSize; $resIndex++) {
         if ($resIndex == 0) {
             $date = $reservationsInfo[$resIndex]['resDate'];
             $hourCursor = Dispatcher::$mysqli->query("select * from event join instructor " . "on event.`instructor_Person_id`=instructor.`Person_id` " . "where event.`date`='{$date}' " . "and (event.`instructor_Person_id`={$prevInsrtuctorID} or event.`instructor_Person_id`={$instructorID}) " . "and event.hours_id={$hour_id}");
             print_r(Dispatcher::$mysqli->error);
             if ($hourCursor->num_rows > 0) {
                 $hourRow = $hourCursor->fetch_assoc();
                 $prev_calendar_id = $hourRow['calendar_id'];
                 $prev_event_id = $hourRow['clndr_event_id'];
                 $event = $this->google_api_service->events->get($prev_calendar_id, $prev_event_id);
             } else {
                 $event = new Google_Service_Calendar_Event();
                 $event->setLocation('Saska, Praha 1');
                 $start = new Google_Service_Calendar_EventDateTime();
                 $start->setDateTime($reservationsInfo[$resIndex]['resDate'] . 'T' . $reservationsInfo[$resIndex]['hour_from'] . ':00.000+02:00');
                 $start->setTimeZone('Europe/Prague');
                 $event->setStart($start);
                 $end = new Google_Service_Calendar_EventDateTime();
                 $end->setDateTime($reservationsInfo[$resIndex]['resDate'] . 'T' . $reservationsInfo[$resIndex]['hour_to'] . ':00.000+02:00');
                 $end->setTimeZone('Europe/Prague');
                 $event->setEnd($end);
             }
         }
         $client_email = $reservationsInfo[$resIndex]['email'];
         $client_name = $reservationsInfo[$resIndex]['name'];
         $client_telefon = $reservationsInfo[$resIndex]['telefone'];
         $choosen_places = $reservationsInfo[$resIndex]['choosen_places'];
         $voucherName = $reservationsInfo[$resIndex]['vocuherName'];
         $total_choosen_places += $choosen_places;
         MainController::printArray($reservationsInfo);
         $description .= $client_name . "\n" . $client_email . "\n" . $client_telefon . "\n" . $choosen_places . "\n\n";
         $attendee[$attendee_index] = new Google_Service_Calendar_EventAttendee();
         $attendee[$attendee_index]->setEmail($client_email);
         $attendee[$attendee_index]->setDisplayName($client_name);
         $attendee[$attendee_index]->setOptional($client_telefon);
         $attendee_index++;
     }
     if ($reservationsInfoSize > 0) {
         if ($hourCursor->num_rows > 0) {
             try {
                 $event->setSummary($total_choosen_places . " " . $voucherName);
                 $event->description = $description;
                 $event->attendees = $attendee;
                 $updatedEvent = $this->google_api_service->events->update($prevInsrtuctorInfo['calendar_id'], $event->getId(), $event);
             } catch (Google_Service_Exception $e) {
                 echo '<pre>';
                 print_r($e);
                 syslog(LOG_ERR, $e->getMessage());
             }
             $event = $this->google_api_service->events->get($prevInsrtuctorInfo['calendar_id'], $updatedEvent->getId());
             $event_id = $event->getId();
             Dispatcher::$mysqli->query("update event set clndr_event_id='{$event_id}', `instructor_Person_id`={$instructorID} " . "where date='{$date}' and hours_id={$hour_id} and `instructor_Person_id`={$prevInsrtuctorID}");
             if ($prev_calendar_id != $instructorInfo['calendar_id']) {
                 $result = $this->google_api_service->events->move($prev_calendar_id, $event_id, $instructorInfo['calendar_id']);
                 print_r(Dispatcher::$mysqli->error);
                 echo '<pre>';
                 print_r($result);
             }
         } else {
             try {
                 $event->attendees = $attendee;
                 $event->description = $description;
                 $organizer = new Google_Service_Calendar_EventOrganizer();
                 $organizer->setEmail($instructorInfo['email']);
                 $organizer->setDisplayName($instructorInfo['name']);
                 $event->setOrganizer($organizer);
                 $new_event = $this->google_api_service->events->insert($instructorInfo['calendar_id'], $event);
             } catch (Google_Service_Exception $e) {
                 echo '<pre>';
                 print_r($e);
                 syslog(LOG_ERR, $e->getMessage());
             }
             $event = $this->google_api_service->events->get($instructorInfo['calendar_id'], $new_event->getId());
             $instructorID = $instructorInfo['id'];
             $hour_id = $hoursInfo['id'];
             $event_id = $event->getId();
             Dispatcher::$mysqli->query("insert into event(clndr_event_id, `instructor_Person_id`, hours_id, date, has_changes) " . "values('{$event_id}', {$instructorID}, {$hour_id}, '{$date}', 0)");
             if ($event != null) {
                 //                    echo "Inserted:<br>";
                 //                    echo "EventID=" . $event->getId() . " <br>";
                 //                    echo "Summary=" . $event->getSummary() . " <br>";
                 //                    echo "Status=" . $event->getStatus();
             }
         }
     }
 }
コード例 #3
0
 static function main_editStartPointPopup_text()
 {
     MainController::printArray($_POST);
     $title = $_POST['title'];
     $subtitle = $_POST['subtitle'];
     $content = $_POST['content'];
     $id = $_POST['id'];
     $size = count($title);
     for ($i = 0; $i < $size; $i++) {
         $titleVal = $title[$i];
         $subtitleVal = Dispatcher::$mysqli->real_escape_string($subtitle["element-{$i}"]['value']);
         $contentVal = Dispatcher::$mysqli->real_escape_string($content["element-{$i}"]['value']);
         $idVal = $id[$i];
         Dispatcher::$mysqli->query("update start_pins set " . "name='{$titleVal}', " . "subtitle='{$subtitleVal}', " . "content='{$contentVal}' where id={$idVal}");
     }
     MainController::printArray(Dispatcher::$mysqli->error);
 }