Example #1
0
 public function index()
 {
     $hours = Hour::all();
     $programs = Program::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->get();
     $menu = 'data';
     return View::make('hours.index', compact('hours', 'programs', 'menu'));
 }
Example #2
0
 public function studentPerprogramFilter($id)
 {
     $program_id = $id;
     $program = Program::with('courses')->find($program_id);
     $programs = Program::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->get();
     $menu = 'report';
     return View::make('reports.studentperprogram', compact('programs', 'program', 'menu'));
 }
Example #3
0
 public function create()
 {
     $classifications = Classification::where('category', '=', 'Course')->get();
     $programs = Program::where('project_id', '=', Auth::user()->curr_project_id)->get();
     $majors = Major::all();
     $generations = Generation::all();
     $menu = 'project';
     return View::make('courses.create', compact('classifications', 'programs', 'generations', 'majors', 'menu'));
 }
Example #4
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $programlist = Program::where('programs.degreelevel', 'U')->whereNotIn('programs.programid', array(62, 66, 38))->get();
     //Averaage students per program
     $programAveArray = [];
     $programBatchAttrition = [];
     foreach ($programlist as $program) {
         $progStudents = round($program->getAveStudents(), 2);
         $programAveArray[$program->programtitle] = $progStudents;
         $programBatchAttrition[$program->programtitle] = $program->getAveAttrition();
     }
     //return page
     return View::make('program.program', ['programlist' => $programlist, 'programAveArray' => $programAveArray, 'programBatchAttrition' => $programBatchAttrition]);
 }
Example #5
0
 public function getYearlySemDifference($year)
 {
     $studentsSem1 = $this->studentterms()->where('aysem', strval($year) . '1')->count();
     $studentsSem2 = $this->studentterms()->where('aysem', strval($year) . '2')->count();
     if ($this->programid == 28) {
         $domProgram = Program::where('programid', 38)->first();
         $domSem1 = $domProgram->studentterms()->whereIn('yearlevel', array(3, 4))->where('aysem', strval($year) . '1')->count();
         $domSem2 = $domProgram->studentterms()->whereIn('yearlevel', array(3, 4))->where('aysem', strval($year) . '2')->count();
         $studentsSem1 = $studentsSem1 + $domSem1;
         $studentsSem2 = $studentsSem2 + $domSem2;
     }
     $semDifference = $studentsSem2 - $studentsSem1;
     return $semDifference;
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('units', function (Blueprint $table) {
         $table->decimal('years_before_drop')->nullable();
     });
     //campus
     $campus = Campus::where('unitid', 2)->first();
     $campus->years_before_drop = $campus->getAveYearsBeforeDropout();
     $campus->ave_batch_attrition = $campus->getAveAttrition();
     $campus->save(['timestamps' => false]);
     //program
     $programlist = Program::where('programs.degreelevel', 'U')->whereNotIn('programs.programid', array(62, 66, 38, 22))->get();
     foreach ($programlist as $program) {
         $program->years_stay = $program->getAveYearsOfStay();
         $program->years_before_shift = $program->getAveYearsBeforeShifting();
         $program->years_before_drop = $program->getAveYearsBeforeDropout();
         $program->ave_batch_attrition = $program->getAveAttrition();
         $program->ave_batch_shift = $program->getAveShiftRate();
         $program->ave_students = $program->getAveStudents();
         $program->save(['timestamps' => false]);
     }
     //department
     $departmentlist = Department::whereHas('programs', function ($q) {
         $q->whereNotIn('programid', array(62, 66, 38, 22));
         $q->where('degreelevel', 'U');
     })->get();
     foreach ($departmentlist as $department) {
         $department->ave_batch_attrition = $department->getAveAttrition();
         $department->ave_batch_shift = $department->getAveShiftRate();
         $department->ave_students = $department->getAveStudents();
         $department->save(['timestamps' => false]);
     }
     //college
     $departmentlist = Department::whereHas('programs', function ($q) {
         $q->whereNotIn('programid', array(62, 66, 38, 22));
         $q->where('degreelevel', 'U');
     })->get();
     $collegelist = [];
     foreach ($departmentlist as $department) {
         array_push($collegelist, $department->college);
     }
     $collegelist = array_unique($collegelist);
     foreach ($collegelist as $college) {
         $college->ave_batch_attrition = $college->getAveAttrition();
         $college->ave_batch_shift = $college->getAveShiftRate();
         $college->ave_students = $college->getAveStudents();
         $college->save(['timestamps' => false]);
     }
 }
Example #7
0
 public function getYearlySemDifference($year)
 {
     $programs = $this->programs()->whereNotIn('programid', array(62, 66, 38, 117))->where('degreelevel', 'U')->lists('programid');
     $studentsSem1 = Studentterm::where('aysem', strval($year) . '1')->whereIn('programid', $programs)->count();
     $studentsSem2 = Studentterm::where('aysem', strval($year) . '2')->whereIn('programid', $programs)->count();
     //if College of Medicine
     if ($this->unitid === 7) {
         $domProgram = Program::where('programid', 38)->first();
         $domSem1 = $domProgram->studentterms()->whereIn('yearlevel', array(3, 4))->where('aysem', strval($year) . '1')->count();
         $domSem2 = $domProgram->studentterms()->whereIn('yearlevel', array(3, 4))->where('aysem', strval($year) . '2')->count();
         $studentsSem1 = $studentsSem1 + $domSem1;
         $studentsSem2 = $studentsSem2 + $domSem2;
     }
     $semDifference = $studentsSem2 - $studentsSem1;
     return $semDifference;
 }
Example #8
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $list = [];
     $n = 0;
     DB::table('tmp_musics')->chunk(10000, function ($data) use(&$list, &$n) {
         foreach ($data as $record) {
             ++$n;
             // 合并整段记录
             $key = implode('_', [$record->audio_part, $record->acrid]);
             if (empty($list) or isset($list[$key])) {
                 $list[$key][] = $record;
                 if (!empty($record->acrid)) {
                     continue;
                 }
                 // 插入数据
             } else {
                 // 插入歌手记录
                 $list = current($list);
                 $first = current($list);
                 $end = end($list);
                 $artistIds = [];
                 foreach (explode('|', $first->artists) as $name) {
                     $artist = Artist::firstOrCreate(['name' => $name]);
                     $artist->increment('counts', 1);
                     $artistIds[] = $artist->id;
                 }
                 // 插入音乐记录
                 $music = Music::firstOrCreate(['title' => $first->title, 'album' => $first->album, 'genres' => $first->genres, 'label' => $first->label, 'release_date' => $first->release_date, 'acrid' => $first->acrid, 'isrc' => $first->isrc, 'upc' => $first->upc, 'external_metadata' => $first->external_metadata]);
                 // 插入音乐歌手记录
                 $music->artists()->sync($artistIds);
                 // 插入节目音乐记录
                 Program::where('date', $first->program_date)->first()->musics()->attach($music->id, ['program_part' => $first->audio_part, 'start_sec' => $first->audio_start_sec, 'end_sec' => $end->audio_start_sec, 'url' => self::getQiniuUrl($first->program_date, $first->audio_start_sec, $end->audio_start_sec)]);
                 // 插入节目歌手记录
                 foreach ($music->artists as $artist) {
                     Program::where('date', $first->program_date)->first()->artists()->attach($artist->id);
                 }
                 // 输出日志
                 $this->info(implode("\t", [$n, $music->id, $first->artists, $first->title]));
             }
             // 清空列表
             $list = [];
         }
     });
 }
Example #9
0
 /**
  * 更新请求
  *
  * @param Request $request
  * @param int $id
  * @return void
  */
 public function update(Request $request, $id)
 {
     // 验证
     $this->validate($request, ['topic' => 'string', 'participants' => 'string', 'state' => 'required|in:1,-1', 'reply_message' => 'required|string']);
     $log = Comment::find($id);
     // 更新
     DB::transaction(function () use($request, $log) {
         if (Comment::STATUS['ENABLE'] == $request->state) {
             // 参与人
             $participantIds = [];
             $participantNames = Participant::filterParticipantNames($request->participants);
             if (!empty($participantNames)) {
                 foreach ($participantNames as $name) {
                     $participant = Participant::firstOrCreate(['name' => $name]);
                     $participant->increment('counts', 1);
                     $participantIds[] = $participant->id;
                 }
             }
             // 节目
             $program = Program::where('date', date('Y-m-d', strtotime($log->metas->thread_key)))->first();
             $topic = Program::filterTopic($request->topic);
             if (!empty($topic)) {
                 $program->update(['topic' => $topic]);
             }
             if (!empty($participantIds)) {
                 $program->participants()->sync($participantIds);
             }
         }
         // 刷新首页文件缓存
         Cache::forget(Program::INDEX_CACHE_KEY);
         // 刷新贡献记录页文件缓存
         Cache::forget(Comment::CONTRIBUTION_CACHE_KEY);
         // 记录日志
         Comment::where('id', $log->id)->update(['ext_is_agree' => $request->state]);
     });
     // 回复评论
     $state = Comment::replyPost($request->reply_message, $log->metas->thread_id, $log->metas->post_id, $log->metas->author_email);
     // 跳转
     $status = ['status' => $state ? 'success' : 'error', 'message' => $state ? '审核成功~' : '审核成功,回复失败'];
     return Redirect::to($request->_redirect_url)->with($status['status'], $status['message']);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('studentdropouts', function (Blueprint $table) {
         //
         /*Add data to include Applied Physics (programid = 117) and batch 2011 and 2012
         		1. Get all students from 2011 and 2012 who is taking applied physics
         		2. Remove students who shifted out
         		3. If batch 2011 and has no studentterm in 2012 and 2013 then add student to studentdropouts table
         		4. If batch 2012 and has no studentterm in 2013 then add student to studentdropouts table
         		*/
         $program = Program::where('programid', 117)->first();
         $shiftees = Studentshift::where('program1id', $program->programid)->lists('studentid');
         $min = 201100000;
         $max = 201300000;
         $studentids = Studentterm::select('studentid')->where('studentid', '>', $min)->where('studentid', '<', $max)->whereNotIn('studentid', $shiftees)->where('programid', $program->programid)->groupBy('studentid')->lists('studentid');
         foreach ($studentids as $studentid) {
             $student = Student::where('studentid', $studentid)->first();
             if ($student->studentid < 201200000) {
                 //batch 2011
                 $stayed = $student->studentterms()->where('year', 2012)->orWhere('year', 2013)->count();
             } else {
                 //batch 2012
                 $stayed = $student->studentterms()->where('year', 2013)->count();
             }
             if ($stayed === 0) {
                 //insert to studentdropout
                 $semcount = $student->studentterms()->where('programid', $program->programid)->whereRaw('CAST(aysem AS TEXT) NOT LIKE \'%3\'')->count();
                 $newDropout = new Studentdropout();
                 $newDropout->studentid = $student->studentid;
                 $newDropout->programid = $program->programid;
                 $newDropout->lastprogramid = $program->programid;
                 $newDropout->collegeid = $program->department->college->unitid;
                 $newDropout->semesters = $semcount;
                 $newDropout->save();
             }
         }
     });
 }
 public function storeUser()
 {
     $redir = $this->check();
     if (isset($redir)) {
         return $redir;
     }
     $user = Sentry::getUser();
     if (Input::has('editor1')) {
         $summary = Input::get('editor1');
         $user->summary = $summary;
     }
     if (Input::has('editor2')) {
         $experience = Input::get('editor2');
         $user->experience = $experience;
     }
     if (Input::has('del-prog')) {
         $del = Input::get('del-prog');
         $ar = array();
         foreach ($del as $key => $val) {
             $ar[] = $key;
         }
         foreach ($ar as $delid) {
             $progs = Program::where('ProgramName', '=', $delid)->get();
             foreach ($progs as $prog) {
                 $user->programs()->detach($prog->id);
             }
         }
     } elseif (Input::has('program') && !Input::has('del-prog')) {
         $id = Input::get('program');
         $progs = Program::where('ProgramName', '=', $id)->take(1)->get();
         foreach ($progs as $prog) {
             $user->programs()->attach($prog->id);
         }
     }
     if (Input::has('email') && Input::has('fname') && Input::has('lname')) {
         $email = Input::get('email');
         $fname = Input::get('fname');
         $lname = Input::get('lname');
         $user->email = $email;
         $user->first_name = $fname;
         $user->last_name = $lname;
     }
     if (Input::hasFile('photo') && Input::file('photo')->isValid()) {
         $formatTable = array('image/jpeg', 'image/png', 'image/gif', 'image/tga', 'image/tif', 'image/bmp');
         $file = Input::file('photo');
         $mime = $file->getMimeType();
         foreach ($formatTable as $mimecheck) {
             if ($mime == $mimecheck) {
                 $filename = Str::random(20) . '.' . $file->getClientOriginalExtension();
                 $destinationPath = "public/uploads";
                 $succes = $file->move($destinationPath, $filename);
                 $bodytag = str_replace("public/", "", $succes->getPathname());
                 $user->avatar = $bodytag;
                 $img = Image::make($bodytag)->resize(612, 612)->save();
             }
         }
     }
     $user->save();
     //$user = Sentry::getUser();
     //$prgs= $user->programs()->get(); var_dump($prgs); $user->programs()->attach(714);
     $this->layout->title = APPNAME;
     $programs = Program::all();
     $this->layout->content = View::make('main.profile.edit')->with('user', $user)->with('programs', $programs);
 }
Example #12
0
 public function index()
 {
     $programs = Program::where('project_id', '=', Auth::user()->curr_project_id)->get();
     $menu = 'project';
     return View::make('programs.index', compact('programs', 'menu'));
 }