public function getCenter() { $id = Input::get('city'); $centers = Center::where('city_id', $id)->lists('center_name', 'id'); $final_list = []; foreach ($centers as $key => $value) { array_push($final_list, array("id" => $key, "value" => $value)); } $data['success'] = 'true'; $data['message'] = $final_list; return json_encode($data); }
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); }