Ejemplo 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' => ''));
 }
Ejemplo n.º 2
0
function az_send_telegram_notifications()
{
    global $current_user;
    if (current_user_can('edit_posts')) {
        $timeslot_model = new TimeslotModel();
        // Get all current bookings
        $current_bookings = $timeslot_model->getForCurrentDate($_POST['date'], $_POST['venue_id']);
        send_telegram_notications($current_user, $current_bookings);
        echo json_encode(1);
        wp_die();
    }
    echo json_encode(0);
    wp_die();
}