public function showHome()
 {
     $todaysDate = Carbon::now();
     $event = CalendarEvent::where('date', '>', $todaysDate)->get()->random();
     // dd($event);
     $categoryId = $event->category_id;
     $category = Category::where('id', '=', $categoryId)->first();
     $group = Group::with('categories')->where('group_name', '<>', '')->get()->random();
     return View::make('index')->with(array('event' => $event, 'group' => $group, 'category' => $category));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $event_page = CalendarEvent::find($id);
     $events = CalendarEvent::where('category_id', '=', $event_page->category_id)->where('id', '!=', $event_page->id)->get();
     if (!$event_page) {
         Session::flash('errorMessage', 'The user does not exist');
         App::abort(404);
         // return View::make('errors.register');
     }
     return View::make('events.show')->with(array('events' => $events, 'event_page' => $event_page));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     /*CalendarEvent is the Class name in CalendarEvent model*/
     $query = new CalendarEvent();
     $search = Input::get('search');
     if (Input::has('search')) {
         $query->where('title', 'like', '%' . $search . "%")->orWhere('description', 'like', '%' . $search . "%");
         /* ->orWhereHas('tag', function($q) use ($name){
         	  	$q->where('name', 'like', '%' . $search . "%")
         	  }*/
         /* ->orWhereHas('user', function($q) use ($search){			
         			$q->where('first_name', 'like', '%' . $search . "%")
         			  ->orWhere('last_name', 'like', '%' . $search . "%");
         		  });*/
     }
     //display a listing of calendar events
     $calendar_events = $query->orderBy('start_date_time', 'desc')->paginate(10);
     $calendar_events = $query->get();
     /*->orderBy('start_date_time', 'desc')->paginate(10)
     		// dd($calendar_events);
     /*		compact() is a PHP function. It creates an array containing variables and their values*/
     return View::make('calendar_events.index', compact('calendar_events'));
     /*return View::make('calendar_events.index')->with('calendar_events', $calendar_events);*/
 }
 /**
  * Display the specified resource.
  * GET /users/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $events = CalendarEvent::where('user_id', '=', $id)->get();
     $user = User::find($id);
     return View::make('users.otherProfile', compact('events', 'user'));
 }
 /**
  * Login user with facebook
  *
  * @return void
  */
 public function loginWithFacebook()
 {
     // get data from input
     $code = Input::get('code');
     // get fb service
     $fb = OAuth::consumer('Facebook');
     // check if code is valid
     // if code is provided get user data and sign in
     if (!empty($code)) {
         // This was a callback request from facebook, get the token
         $token = $fb->requestAccessToken($code);
         // Send a request with it
         $result = json_decode($fb->request('/me?fields=id,name,email'), true);
         $email = $result['email'];
         $userId = User::where('email', '=', $email)->first()->id;
         $user = User::find($userId);
         $groups = Group::where('user_id', '=', $user->id)->get();
         $events = CalendarEvent::where('user_id', '=', $user->id)->get();
         Auth::login($user);
         return View::make('users.show')->with(array('user' => $user, 'groups' => $groups, 'events' => $events));
     } else {
         // get fb authorization
         $url = $fb->getAuthorizationUri();
         // return to facebook login url
         return Redirect::to((string) $url);
     }
 }
Example #6
0
 public function approveSelected()
 {
     $wingman_id = $_SESSION['user_id'];
     $data = Input::get('submit_value');
     if (is_array($data)) {
         foreach ($data as $datapoint) {
             $fragments = explode('/', $datapoint);
             $student_id = $fragments[0];
             $month = $fragments[1];
             $year = $fragments[2];
             $calendar_event = CalendarEvent::where('student_id', '=', $student_id)->get();
             $wingman_id = DB::table('propel_student_wingman')->select('wingman_id')->where('student_id', '=', $student_id)->first();
             foreach ($calendar_event as $event) {
                 $monthCurr = date('n', strtotime($event->start_time));
                 $yearCurr = date('Y', strtotime($event->start_time));
                 $status = $event->status;
                 if ($monthCurr == $month && $yearCurr == $year && $status != 'cancelled') {
                     $event->status = 'approved';
                     $event->save();
                 }
             }
         }
     }
     return Redirect::to(URL::to('/calendar/approve-calendar/'));
 }
Example #7
0
 public function showCenterReport($city_id, $center_id)
 {
     $cities = City::where('id', '<=', '25')->orderby('name', 'ASC')->get();
     $centers = Center::where('city_id', '=', $city_id)->where('status', '=', 1)->orderby('name', 'ASC')->get();
     $tables = DB::table('Student')->join('propel_student_wingman as B', 'Student.id', '=', 'B.student_id')->join('User as C', 'C.id', '=', 'B.wingman_id')->join('Center as D', 'D.id', '=', 'Student.center_id')->join('City as E', 'E.id', '=', 'D.city_id');
     $child_data = $tables->select('Student.id as id', 'Student.name as name', 'C.name as wingman_name', 'D.id as center_id', 'D.name as center_name', 'E.name as city_name', 'E.id as city_id')->distinct()->where('E.id', '=', $city_id)->orderby('D.name', 'ASC')->where('D.id', '=', $center_id)->get();
     //$child_data = $tables->select('Student.name as name','C.name as wingman_name','D.id as center_id','D.name as center_name','E.name as city_name','E.id as city_id','F.id','F.id as journal_count','G.id as event_count')->distinct()->where('E.id','=',$city_id)->where('F.type','=','child_feedback')->orderby('D.name','ASC')->get(); //Test Query
     $child_data = (array) $child_data;
     $total = array();
     $total['wingman_session_count'] = 0;
     $total['asv_session_count'] = 0;
     $total['journal_count'] = 0;
     foreach ($child_data as $child) {
         $calendarEvent = CalendarEvent::where('student_id', '=', $child->id)->where('status', '<>', 'cancelled')->where('type', '=', 'wingman_time')->get();
         $child->wingman_session_count = count($calendarEvent);
         $total['wingman_session_count'] += $child->wingman_session_count;
         $calendarEvent = DB::table('propel_calendarEvents as A')->join('propel_wingmanTimes as B', 'A.id', '=', 'B.calendar_event_id')->where('A.student_id', '=', $child->id)->where('A.status', '=', 'attended')->get();
         $child->wingman_module_attended = count($calendarEvent);
         $calendarEvent = CalendarEvent::where('student_id', '=', $child->id)->where('status', '<>', 'cancelled')->where('type', '=', 'volunteer_time')->get();
         $child->asv_session_count = count($calendarEvent);
         $total['asv_session_count'] += $child->asv_session_count;
         $journalEntry = WingmanJournal::where('student_id', '=', $child->id)->where('type', '=', 'child_feedback')->get();
         $child->journal_count = count($journalEntry);
         $total['journal_count'] += $child->journal_count;
     }
     return View::make('reports.child-report.city-report')->with('child_data', $child_data)->with('cities', $cities)->with('city_id', $city_id)->with('centers', $centers)->with('center_id', '0')->with('total', $total);
 }