Exemplo n.º 1
0
 public function plan()
 {
     if (isset($_POST[Session::nonceName]) && 1 === wp_verify_nonce($_POST[Session::nonceName], Session::nonceAction)) {
         global $current_user;
         wp_get_current_user();
         $data = Input::all();
         $this->model = new TimeslotModel();
         // Get all current bookings
         // $current_bookings = $this->model->getForCurrentDate( $data['date'], $data['id'] );
         // $this->_send_telegram_notications( $current_user, $current_bookings );
         // Add new booking to the database
         $result = $this->model->insert($data, $current_user->ID);
         echo json_encode($result);
         exit;
     }
     if (!isset($_GET['id'])) {
         $allVenues = VenueModel::all();
         $venuesArray = array();
         foreach ($allVenues as $venue) {
             $venuesArray[$venue['ID']] = $venue;
         }
     } else {
         $venuesArray[$_GET['id']] = VenueModel::details($_GET['id']);
     }
     // Get venue details
     // $venueDetails = VenueModel::details($_GET['id']);
     // Booked slots for the venue
     $bookedSlots = TimeslotModel::perVenue(array_keys($venuesArray));
     $hours = Config::get('application.timeslots');
     $dates = array('monday' => date("Y-m-d", strtotime('next monday', strtotime('previous sunday'))), 'tuesday' => date("Y-m-d", strtotime('next tuesday', strtotime('previous sunday'))), 'wednesday' => date("Y-m-d", strtotime('next wednesday', strtotime('previous sunday'))), 'thursday' => date("Y-m-d", strtotime('next thursday', strtotime('previous sunday'))), 'friday' => date("Y-m-d", strtotime('next friday', strtotime('previous sunday'))), 'saturday' => date("Y-m-d", strtotime('next saturday', strtotime('previous sunday'))), 'sunday' => date("Y-m-d", strtotime('next sunday', strtotime('previous sunday'))));
     return View::make('pages.venue.plan', array('venues' => $venuesArray, 'booked_slots' => $bookedSlots, 'dates' => $dates, 'hours' => Config::get('application.timeslots'), 'highlight' => ''));
 }
Exemplo n.º 2
0
function get_events_callback()
{
    $filter = isset($_POST['filter']) ? $_POST['filter'] : NULL;
    if (!isset($_GET['id'])) {
        $allVenues = VenueModel::all();
        $allVenuesArray = array();
        foreach ($allVenues as $venue) {
            $temp = array();
            $temp['ID'] = $venue['ID'];
            $temp['post_title'] = $venue['post_title'];
            $temp['post_name'] = $venue['post_name'];
            $allVenuesArray[$venue['ID']] = $temp;
        }
        $filteredVenues = VenueModel::all($filter);
        $filteredVenuesArray = array();
        foreach ($filteredVenues as $venue) {
            $temp = array();
            $temp['ID'] = $venue['ID'];
            $temp['post_title'] = $venue['post_title'];
            $temp['post_name'] = $venue['post_name'];
            $filteredVenuesArray[$venue['ID']] = $temp;
        }
    } else {
        $filteredVenuesArray[$_GET['id']] = VenueModel::details($_GET['id']);
    }
    // Booked slots for the venue
    $bookedSlots = TimeslotModel::perVenue(array_keys($filteredVenuesArray));
    $slots = array();
    foreach ($bookedSlots as $slot) {
        // if ($count > 25) $count = 0;
        $date = strtotime($slot['date']);
        $time_from = $slot['time_from'];
        $time_from_hour = $time_from;
        $time_from_minute = '00';
        if ($time_from > floor($time_from)) {
            $time_from_hour = floor($time_from);
            $time_from_minute = '30';
        }
        $time_to = $slot['time_to'];
        $time_to_hour = $time_to;
        $time_to_minute = '00';
        if ($time_to > floor($time_to)) {
            $time_to_hour = floor($time_to);
            $time_to_minute = '30';
        }
        $title = isset($slot['title']) ? $slot['title'] : NULL;
        $colours = array('greenLight', 'red', 'blue', 'darken', 'yellow', 'purple', 'orange');
        $colour = $colours[rand(0, sizeof($colours) - 1)];
        $slot_array = array();
        $delete_icon = '';
        global $current_user;
        if ($current_user->ID == $slot['timeslot_user']) {
            $delete_icon = "<a id='delete-event-link-" . $slot['ID'] . "' style='margin-top: 3px; float: right; margin-right: 4px; z-index: 10;' class='closeon delete-event-link'><i style=\"font-size: 12px; color: white;\" class=\"fa fa-times-circle\"></i></a>";
        }
        $comment_icon = '';
        if (isset($slot['title']) && !empty($slot['title'])) {
            $comment_icon = ' <i class="fa fa-comment"></i>';
        }
        $slot_array['title'] = get_avatar($slot['timeslot_user'], 20) . ' ' . $slot['first_name'] . ' ' . $slot['last_name'] . $comment_icon . $delete_icon;
        $slot_array['start'] = date("Y-m-d", $date) . 'T' . $time_from_hour . ':' . $time_from_minute . ':00';
        $slot_array['end'] = date("Y-m-d", $date) . 'T' . $time_to_hour . ':' . $time_to_minute . ':00';
        $slot_array['allDay'] = false;
        $slot_array['className'] = array('event', 'bg-color-' . $colour, 'event-id-' . $slot['ID']);
        $slot_array['description'] = $title;
        $slot_array['slotWidth'] = 50;
        $slot_array['resourceId'] = 'venue-' . $slot['timeslot_venue'];
        $slot_array['id'] = $slot['ID'];
        $slots[] = $slot_array;
    }
    echo json_encode(array('slots' => $slots, 'all_venues' => $allVenuesArray, 'filtered_venues' => $filteredVenuesArray));
    wp_die();
    // this is required to terminate immediately and return a proper response
}
 public function setFromDataBaseRow($data)
 {
     $this->id = $data['id'];
     $this->site_id = $data['site_id'];
     $this->site_slug = isset($data['site_slug']) ? $data['site_slug'] : null;
     $this->slug = $data['slug'];
     $this->summary = $data['summary'];
     $this->description = $data['description'];
     $utc = new \DateTimeZone("UTC");
     $this->start_at = new \DateTime($data['start_at'], $utc);
     $this->end_at = new \DateTime($data['end_at'], $utc);
     $this->created_at = new \DateTime($data['created_at'], $utc);
     $this->group_id = isset($data['group_id']) ? $data['group_id'] : null;
     $this->group_title = isset($data['group_title']) ? $data['group_title'] : null;
     $this->is_deleted = $data['is_deleted'];
     $this->is_cancelled = $data['is_cancelled'];
     $this->event_recur_set_id = $data['event_recur_set_id'];
     $this->country_id = $data['country_id'];
     $this->venue_id = $data['venue_id'];
     $this->area_id = $data['area_id'];
     $this->timezone = $data['timezone'];
     $this->import_id = $data['import_id'];
     $this->import_url_id = $data['import_url_id'];
     $this->url = $data['url'];
     $this->ticket_url = $data['ticket_url'];
     if (isset($data['venue_slug'])) {
         $this->venue = new VenueModel();
         $this->venue->setTitle($data['venue_title']);
         $this->venue->setSlug($data['venue_slug']);
         $this->venue->setLat($data['venue_lat']);
         $this->venue->setLng($data['venue_lng']);
         $this->venue->setDescription($data['venue_description']);
         $this->venue->setAddress($data['venue_address']);
         $this->venue->setAddressCode($data['venue_address_code']);
     }
     if (isset($data['area_slug'])) {
         $this->area = new AreaModel();
         $this->area->setId($data['area_information_id']);
         $this->area->setTitle($data['area_title']);
         $this->area->setSlug($data['area_slug']);
     }
     if (isset($data['country_two_char_code'])) {
         $this->country = new CountryModel();
         $this->country->setTwoCharCode($data['country_two_char_code']);
         $this->country->setTitle($data['country_title']);
     }
     $this->user_is_plan_attending = isset($data['user_is_plan_attending']) ? (bool) $data['user_is_plan_attending'] : false;
     $this->user_is_plan_maybe_attending = isset($data['user_is_plan_maybe_attending']) ? (bool) $data['user_is_plan_maybe_attending'] : false;
     $this->is_virtual = (bool) $data['is_virtual'];
     $this->is_physical = (bool) $data['is_physical'];
     $this->is_duplicate_of_id = $data['is_duplicate_of_id'];
     $this->is_event_in_curated_list = isset($data['is_event_in_curated_list']) ? (bool) $data['is_event_in_curated_list'] : false;
     $this->in_curated_list_group_id = isset($data['in_curated_list_group_id']) ? $data['in_curated_list_group_id'] : null;
     $this->in_curated_list_group_slug = isset($data['in_curated_list_group_slug']) ? $data['in_curated_list_group_slug'] : null;
     $this->in_curated_list_group_title = isset($data['in_curated_list_group_title']) ? $data['in_curated_list_group_title'] : null;
     $this->media_event_slugs = isset($data['media_event_slugs']) ? $data['media_event_slugs'] : null;
     $this->media_group_slugs = isset($data['media_group_slugs']) ? $data['media_group_slugs'] : null;
     $this->media_venue_slugs = isset($data['media_venue_slugs']) ? $data['media_venue_slugs'] : null;
     if ($data['custom_fields'] && $data['custom_fields'] != '[]') {
         $obj = json_decode($data['custom_fields']);
         foreach (get_object_vars($obj) as $k => $v) {
             $this->custom_fields[$k] = $v;
         }
     }
 }
 private static function validateConference($confTitle, $venueName)
 {
     if (empty($confTitle) || empty($venueName)) {
         Session::push('feedback_negative', Text::get('CONFERENCE_FIELD_EMPTY'));
         return false;
     }
     // no conference by this title should exist
     if (ConferenceModel::getConferenceByTitle($confTitle)) {
         Session::push('feedback_negative', Text::get('CONFERENCE_ALREADY_EXISTS'));
         return false;
     }
     if (!VenueModel::venueExists($venueName)) {
         if (!VenueModel::createVenueInDb($venueName)) {
             Session::push('feedback_negative', Text::get('UNKNOWN_ERROR'));
             return false;
         }
     }
     return true;
 }
Exemplo n.º 5
0
 /**
  * Set up timeslot custom post type
  *
  * @private
  */
 private static function _set_up_timeslot()
 {
     PostType::make('timeslot', 'Time Slots', 'Time Slot')->set();
     $fields = array(Field::select('timeslot_venue', array(array('none' => __('- None -')) + VenueModel::venueSelection()), array('title' => __('Venue'))), Field::select('timeslot_user', array(array('none' => __('- None -')) + UserModel::userSelection()), array('title' => __('User'))), Field::date('date', array('title' => 'Date')), Field::select('time_from', array(Config::get('application.timeslots')), array('title' => __('Start at'))), Field::select('time_to', array(Config::get('application.timeslots')), array('title' => __('Finish at'))));
     Metabox::make('Options', 'timeslot')->set($fields);
 }