public function save($user_id)
 {
     $attendance_data = Input::get('attended');
     $calender_data = Input::get('calender_entry');
     foreach ($calender_data as $id => $value) {
         $calender_event = CalendarEvent::find($id);
         $calender_event->status = isset($attendance_data[$id]) ? 'attended' : 'approved';
         $calender_event->save();
     }
     if (Request::segment(2) == 'wingman') {
         return Redirect::to(URL::to('/') . "/attendance/wingman/" . $user_id)->with('success', 'Attendence Saved.');
     } else {
         return Redirect::to(URL::to('/') . "/attendance/" . $user_id)->with('success', 'Attendence Saved.');
     }
     return Redirect::to(URL::to('/') . "/attendance/" . $user_id)->with('success', 'Attendence Saved.');
 }
Example #2
0
 /**
  * Deletes an event from this calendar.
  *
  * @param string|object $calendar_event The id of an event or an event object of type CalendarEvent.
  * @param boolean $all If true all events of a group event will be deleted.
  * @return boolean|int The number of deleted events. False if the event was not deleted.
  */
 public function deleteEvent($calendar_event, $all = false)
 {
     if ($this->havePermission(Calendar::PERMISSION_WRITABLE)) {
         if (!is_object($calendar_event)) {
             $calendar_event = CalendarEvent::find(array($this->getRangeId(), $calendar_event));
         }
         if (!($calendar_event && $calendar_event->havePermission(Event::PERMISSION_WRITABLE))) {
             return false;
         }
         if (!is_a($calendar_event, 'CalendarEvent')) {
             return false;
         }
         if ($this->getRange() == Calendar::RANGE_USER) {
             $event_message = clone $calendar_event;
             $author_id = $calendar_event->getAuthorId();
             $deleted = $calendar_event->delete();
             if ($deleted && !$this->havePermission(Calendar::PERMISSION_OWN)) {
                 $this->sendDeleteMessage($event_message);
             }
             if ($all && $deleted && $author_id == $this->getRangeId()) {
                 CalendarEvent::findEachBySQL(function ($ce) use($deleted) {
                     $calendar = new SingleCalendar($ce->range_id);
                     $deleted += $calendar->deleteEvent($ce);
                 }, 'event_id = ?', array($event_message->event_id));
             }
             return $deleted;
         } else {
             if ($this->getRange() == Calendar::RANGE_SEM) {
                 $deleted = $calendar_event->delete();
                 return $deleted;
             }
         }
     }
     return false;
 }
 /**
  * Remove the specified resource from storage.
  * DELETE /location/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $location = CalendarEvent::find($id);
     $location->delete();
     // Modify destroy() to send back JSON if it's been requested
     if (Request::wantsJson()) {
         return Response::json(array('Response', "Good!"));
     } else {
         return Redirect::action('LocationController@index');
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $event_page = CalendarEvent::find($id);
     $event_page->delete();
     return Redirect::action("EventsController@index");
 }
 /**
  * Show the form for editing the specified CalendarEvent.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $calendarevent = CalendarEvent::find($id);
     return View::make('calendarevents.edit', compact('calendarEvent'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $event = CalendarEvent::find($id);
     if (!$event) {
         Session::flash('errorMessage', "Event with id of {$id} is not found");
         App::abort(404);
     }
     $event->delete();
     return Redirect::action('EventsController@index');
 }
 /**
  * Remove the specified resource from storage.
  * DELETE /calendarevents/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $event = CalendarEvent::find($id);
     if (!$event) {
         Log::info(Input::all());
         App::abort(404);
     }
     $event->delete();
     Log::info(Input::all());
     return Redirect::action('CalendarEventsController@index');
 }
 public static function findEventsByDate(DateTime $date)
 {
     $date_str = $date->format(CALENDAR_SQL_DATE_FORMAT);
     return CalendarEvent::find(array('where' => 'date_from = :date1 OR (:date2 BETWEEN date_from AND date_to)', 'values' => array('date1' => $date_str, 'date2' => $date_str)));
 }
 /**
  * Controller's action: List all events.
  */
 public function events()
 {
     $events = CalendarEvent::find(array('order' => 'date_from DESC, date_to DESC'));
     $this->display(CALENDAR_VIEWS_RELATIVE_ADMIN . '/events', array('events' => $events));
 }
 /**
  * Update the specified event in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $event = CalendarEvent::find($id);
     if (!$event) {
         Session::flash('errorMessage', "Event with id of {$id} is not found");
         App::abort(404);
     }
     if (Input::hasFile('img_url')) {
         $file = Input::file('img_url');
         $destinationPath = public_path() . '/img';
         $filename = $file->getClientOriginalName();
         Input::file('img_url')->move($destinationPath, $filename);
         $event->event_name = Input::get('event_name');
         $event->event_description = Input::get('event_description');
         $event->event_location = Input::get('event_location');
         $event->event_start = Input::get('event_start');
         $event->event_end = Input::get('event_end');
         $event->img_url = $filename;
         $event->save();
     }
     $event->event_name = Input::get('event_name');
     $event->event_description = Input::get('event_description');
     $event->event_location = Input::get('event_location');
     $event->event_start = Input::get('event_start');
     $event->event_end = Input::get('event_end');
     $event->save();
     Session::flash('successMessage', 'Event updated successfully!');
     return Redirect::action('EventsController@show', array($id));
 }