Ejemplo n.º 1
0
 public function enroll($domain, $classId)
 {
     $register = $this->user->registers()->where('class_id', $classId)->first();
     if ($register) {
         return $this->respond(['message' => "Bạn đă đăng kí lớp học này. "]);
     } else {
         $register = new Register();
         $register->user_id = $this->user->id;
         $register->gen_id = Gen::getCurrentGen()->id;
         $register->class_id = $classId;
         $register->status = 0;
         $register->save();
         send_mail_confirm_registration($this->user, $classId, ["*****@*****.**", "*****@*****.**"]);
         return $this->respond(['message' => "Bạn đă đăng kí thành công. Bạn hãy check email để kiểm tra thông tin đăng kí."]);
     }
 }
Ejemplo n.º 2
0
 public function index()
 {
     $classes = StudyClass::all();
     $teacher_ids = array();
     $assist_ids = array();
     foreach ($classes as $class) {
         if ($class->teach != null) {
             $teacher_ids[] = $class->teach->id;
         }
         if ($class->assist != null) {
             $assist_ids[] = $class->assist->id;
         }
     }
     $teachers = User::whereIn('id', $teacher_ids)->get();
     foreach ($teachers as &$teacher) {
         $class_ids = array();
         foreach ($teacher->teach as $t) {
             $class_ids[] = $t->id;
         }
         $teacher->rating_number = Register::whereIn('class_id', $class_ids)->where('rating_teacher', '>', -1)->count();
         $teacher->rating_avg = Register::whereIn('class_id', $class_ids)->where('rating_teacher', '>', -1)->avg('rating_teacher');
     }
     $assistants = User::whereIn('id', $assist_ids)->get();
     foreach ($assistants as &$assistant) {
         $class_ids = array();
         foreach ($assistant->assist as $t) {
             $class_ids[] = $t->id;
         }
         $assistant->rating_number = Register::whereIn('class_id', $class_ids)->where('rating_ta', '>', -1)->count();
         $assistant->rating_avg = Register::whereIn('class_id', $class_ids)->where('rating_ta', '>', -1)->avg('rating_ta');
     }
     $this->data['teachers'] = $teachers;
     $this->data['assistants'] = $assistants;
     return view('manage.personal_rating.all', $this->data);
 }
Ejemplo n.º 3
0
 public function scopeGetTotalCalled($scope)
 {
     $current_gen = Gen::getCurrentGen();
     $classes = StudyClass::where('gen_id', $current_gen->id)->get();
     $class_id_list = $classes->pluck('id')->all();
     $count = Register::whereIn('class_id', $class_id_list)->select('user_id')->where('call_status', 1)->groupBy('user_id')->get()->count();
     return $count;
 }
 public function deregister($id, $event)
 {
     $user = Auth::user();
     $fest = Fest::find($id);
     $reg = Register::find($user->id)->where('eventid', $event);
     $reg->delete();
     return Redirect::back()->with(['user' => $user, 'fest' => $fest]);
 }
Ejemplo n.º 5
0
 public function change_class($registerId)
 {
     $register = Register::find($registerId);
     $current_gen = $register->gen;
     $classes = $current_gen->studyclasses()->where('course_id', '=', $register->studyClass->course_id)->where('id', '!=', $register->class_id)->get();
     $this->data['register'] = $register;
     $this->data['classes'] = $classes;
     return view('manage.student.change_class', $this->data);
 }
 public function showevent($id, $event)
 {
     $user = Auth::user();
     $reg = NULL;
     if ($user) {
         $reg = Register::where('userid', $user->id)->where('eventid', $event)->first();
     }
     $fest = Fest::find($id);
     $event = Event::find($event);
     return view('user.event', ['user' => Auth::user(), 'event' => $event, 'fest' => $fest, 'reg' => $reg]);
 }
 public function store()
 {
     $data = Input::except(array('_token'));
     $rule = array('name' => 'required|unique:users', 'email' => 'required|email|unique:users', 'phone' => 'required', 'city' => 'required', 'area' => 'required', 'password' => 'required|min:6|same:cpassword', 'cpassword' => 'required|min:6');
     $validator = Validator::make($data, $rule);
     if ($validator->fails()) {
         return Redirect::to('register')->withErrors($validator->messages());
     } else {
         Register::saveFormData(Input::except(array('_token', 'cpassword')));
         return Redirect::to('register')->withMessage('Data inserted');
     }
 }
Ejemplo n.º 8
0
 public function search(Request $request)
 {
     if ($request->isMethod('POST')) {
         $res = $request->email;
         $data['searches'] = Register::where('email', 'LIKE', '%' . $res . '%')->get();
         if ($data['searches']) {
             return view('users.search_result', $data);
         } else {
             echo "Nothing";
         }
     }
     return view('search');
 }
 public function register_back(Request $request)
 {
     $reg = new Register();
     $reg->name = $request->name;
     $reg->rollno = Session::get('rollno');
     $reg->phoneno = $request->phoneno;
     $reg->team = $request->team;
     $teams = Register::where('rollno', $reg->rollno)->lists('team');
     if (in_array($reg->teams, array($teams))) {
         return view('register', array('message' => "You have already registered for the team {$reg->team}"));
     }
     $reg->dept = $request->dept;
     $reg->year = $request->year;
     $reg->bloodgrp = $request->bloodgrp;
     $reg->shirtsize = $request->shirtsize;
     $reg->native = $request->native;
     $reg->fatname = $request->fatname;
     $fatprof = $request->fatprof;
     $image = $request->image;
     $rules = array('image' => 'required|image');
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return view('register', array('message' => 'File uploaded not a <200kb sized image'));
     }
     list($width, $height, $type, $attr) = getimagesize($request->file('image')->getPathName());
     if ($width != $height) {
         return view('register', array('message' => "Please upload a image with height-width ratio 1:1"));
     }
     $destinationPath = base_path() . '/public/images/';
     // upload path
     $extension = $request->file('image')->getClientOriginalExtension();
     // getting image extension
     $fileName = str_replace(' ', '_', $reg->rollno) . '_' . $reg->team . '.' . $extension;
     // renameing image
     $request->file('image')->move($destinationPath, $fileName);
     $reg->image = 'images/' . $fileName;
     $reg->save();
     return Redirect::to(action('RegisterController@dashboard'))->with('message', "You have successfully registered for {$reg->team}");
 }
Ejemplo n.º 10
0
 public function get_money(Request $request)
 {
     if ($request->register_id == null || $request->money == null || $request->code == null) {
         return $this->responseBadRequest('Not enough parameters!');
     }
     $register_id = $request->register_id;
     $money = str_replace(array('.', ','), '', $request->money);
     $code = $request->code;
     $register = Register::find($register_id);
     if ($register->status == 1) {
         return $this->responseBadRequest('Học viên này đã đóng tiền rồi');
     }
     $register->money = $money;
     $register->paid_time = format_time_to_mysql(time());
     $register->note = $request->note;
     $register->staff_id = $this->user->id;
     $regis_by_code = Register::where('code', $code)->first();
     if ($regis_by_code != null) {
         return $this->responseBadRequest('code is already existed');
     } else {
         $register->code = $code;
         $register->status = 1;
         $register->save();
         $transaction = new Transaction();
         $transaction->money = $money;
         $transaction->sender_id = $this->user->id;
         $transaction->receiver_id = $register->id;
         $transaction->sender_money = $this->user->money;
         $transaction->note = "Học viên " . $register->user->name . " - Lớp " . $register->studyClass->name;
         $transaction->status = 1;
         $transaction->type = 1;
         $transaction->save();
         DB::insert(DB::raw("\n                insert into attendances(`register_id`,`checker_id`,class_lesson_id)\n                (select registers.id,-1,class_lesson.id\n                from class_lesson\n                join registers on registers.class_id = class_lesson.class_id\n                where registers.id = {$register->id}\n                )\n                "));
         $current_money = $this->user->money;
         $this->user->money = $current_money + $money;
         $this->user->save();
         send_mail_confirm_receive_studeny_money($register, ["*****@*****.**", "*****@*****.**"]);
     }
     $return_data = array('data' => ['money' => $register->money, 'code' => $register->code, 'paid_time' => format_date_full_option($register->paid_time)], 'message' => "success");
     return $this->respond($return_data);
 }
Ejemplo n.º 11
0
                                </div>
                            </td>
                            <td><a href="{{url('manage/allrating?role=t&id='.$class->id)}}">Chi tiết</a></td>
                        </tr>
                    @endforeach
                    </tbody>
                @endif

                @if($role == 'ta')
                    <tbody>
                    @foreach($person->assist()->orderBy('created_at','desc')->where('rating_sended',1)->get() as $class)
                        <tr>
                            <?php 
$rating_avg = Register::where('class_id', $class->id)->where('rating_ta', '>', -1)->avg('rating_ta');
$rated_number = Register::where('class_id', $class->id)->where('rating_ta', '>', -1)->count();
$total_rates = Register::where('class_id', $class->id)->count();
if ($total_rates != 0) {
    $rated_ratio = $rated_number * 100 / $total_rates;
} else {
    $rated_ratio = 0;
}
?>
                            <td>{{$class->name}}</td>
                            <td>{{number_format($rating_avg,1)}}</td>
                            <td>
                                {{$rated_number}}/{{$total_rates}}
                                <div class="progress">
                                    <div class="determinate" style="width: {{$rated_ratio}}%"></div>
                                </div>
                            </td>
                            <td><a href="{{url('manage/allrating?role=ta&id='.$class->id)}}">Chi tiết</a></td>
Ejemplo n.º 12
0
 public function store_rating(Request $request)
 {
     $register = Register::find($request->register_id);
     $register->rating_teacher = $request->rating_teacher;
     $register->rating_ta = $request->rating_ta;
     $register->comment_teacher = $request->comment_teacher;
     $register->comment_ta = $request->comment_ta;
     //        dd($request->rating_teacher);
     $register->rated = 1;
     $register->save();
     return "<strong class=\"green-text\">Cám ơn bạn đã đánh giá và góp ý cho giảng viên và trợ giảng của colorME</strong>";
 }
Ejemplo n.º 13
0
 public function reject($team, $id)
 {
     Register::where('id', $id)->where('team', $team)->update(array("approved" => 2));
     return back()->with('message', 'Successfully rejected0!');
 }
Ejemplo n.º 14
0
 public function register(RegistrationRequest $request, Register $register)
 {
     return $register->execute($request);
 }
Ejemplo n.º 15
0
 public function landing_register(Request $request)
 {
     $user = User::where('email', '=', $request->email)->first();
     //        dd('WORK');
     if ($user == null) {
         $user = new User();
         $user->name = $request->name;
         $user->phone = $request->phone;
         $user->email = $request->email;
         $user->university = $request->university;
         $user->work = $request->work;
         $user->address = $request->address;
         $user->how_know = $request->how_know;
         $user->username = $request->email;
         $user->facebook = $request->facebook;
         $user->gender = $request->gender;
         $user->dob = strtotime($request->dob);
         $user->password = bcrypt($request->phone);
         $user->save();
     } else {
         $user->university = $request->university;
         $user->work = $request->work;
         $user->address = $request->address;
         $user->phone = $request->phone;
         $user->gender = $request->gender;
         $user->dob = date('Y-m-d', strtotime($request->dob));
         $user->facebook = $request->facebook;
         $user->save();
     }
     $register = new Register();
     $register->user_id = $user->id;
     $register->gen_id = Gen::getCurrentGen()->id;
     $register->class_id = $request->class_id;
     $register->status = 0;
     $register->leader_phone = $request->leader_phone;
     $register->coupon = $request->coupon;
     $register->save();
     send_mail_confirm_registration($user, $request->class_id, ["*****@*****.**", "*****@*****.**"]);
     return redirect('register_success');
 }
Ejemplo n.º 16
0
 public function dashboard($domain, $gen_id, $base_id = null)
 {
     //        $current_gen = Gen::getCurrentGen();
     if ($this->user->role == 0) {
         return $this->responseUnAuthorized('Bạn không có quyền truy cập dữ liệu này');
     }
     $data = [];
     if ($gen_id) {
         $current_gen = Gen::find($gen_id);
     } else {
         return response()->json([message => "gen_id is required"], 400);
     }
     $data['current_gen'] = $this->genTransformer->transform($current_gen);
     if ($base_id == null) {
         $zero_paid_num = Register::where('gen_id', $current_gen->id)->where('status', '=', 1)->where('money', '=', 0)->count();
         $total_money = Register::where('gen_id', $current_gen->id)->sum('money');
         $num = Register::where('gen_id', $current_gen->id)->count();
         $paid_number = Register::where('gen_id', $current_gen->id)->where('code', "!=", "")->count();
         $uncalled_number = Register::where('gen_id', $current_gen->id)->where('call_status', 0)->groupBy('user_id')->count();
         $total_classes = $current_gen->studyclasses->count();
         $remain_days = strtotime($current_gen->end_time) - time();
         $registers_by_date = Register::select(DB::raw('count(1) as num'))->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(created_at)'))->pluck('num')->toArray();
         $money_by_date = Register::select(DB::raw('sum(money) as money'))->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(paid_time)'))->pluck('money')->toArray();
         $registers_by_hour = Register::select(DB::raw('HOUR(created_at) as \'hour\', count(1) as num'))->where('gen_id', $current_gen->id)->groupBy(DB::raw('HOUR(created_at)'))->get();
         $registers_hour_array = array();
         for ($i = 0; $i < 24; $i++) {
             $registers_hour_array[$i] = 0;
         }
         foreach ($registers_by_hour as $regis) {
             $registers_hour_array[$regis->hour] = $regis->num;
         }
         $data['money_by_date'] = $money_by_date;
         $data['zero_paid_num'] = $zero_paid_num;
         $data['classes'] = $this->classTransformer->transformCollection($current_gen->studyclasses);
         $data['total_money'] = is_numeric($total_money) ? $total_money : 0;
         $data['register_number'] = is_numeric($num) ? $num : 0;
         $data['paid_number'] = is_numeric($paid_number) ? $paid_number : 0;
         $data['uncalled_number'] = is_numeric($uncalled_number) ? $uncalled_number : 0;
         $data['total_classes'] = is_numeric($total_classes) ? $total_classes : 0;
         $data['remain_days'] = round((is_numeric($remain_days) ? $remain_days : 0) / (24 * 3600), 2);
         $data['date_array'] = createDateRangeArray(strtotime($current_gen->start_time), strtotime($current_gen->end_time));
         $data['registers_by_date'] = $registers_by_date;
         $data['registers_by_hour'] = $registers_hour_array;
     } else {
         $base = Base::find($base_id);
         $classes = $base->classes()->where('gen_id', $current_gen->id);
         $registers = Register::where('gen_id', $current_gen->id)->where('gen_id', $current_gen->id)->whereIn('class_id', $classes->pluck('id'));
         $zero_paid_num = Register::where('status', '=', 1)->where('money', '=', 0)->whereIn('class_id', $classes->pluck('id'))->count();
         $total_money = $registers->sum('money');
         $num = $registers->count();
         $paid_number = $registers->where('gen_id', $current_gen->id)->where('code', "!=", "")->count();
         $uncalled_number = $registers->where('call_status', 0)->groupBy('user_id')->count();
         $total_classes = $classes->count();
         $remain_days = strtotime($current_gen->end_time) - time();
         $classes_id = $classes->pluck("id");
         $registers_by_date = Register::select(DB::raw('count(1) as num'))->whereIn("class_id", $classes_id)->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(created_at)'))->pluck('num')->toArray();
         $registers_by_hour = Register::select(DB::raw('HOUR(created_at) as \'hour\', count(1) as num'))->whereIn("class_id", $classes_id)->where('gen_id', $current_gen->id)->groupBy(DB::raw('HOUR(created_at)'))->get();
         $money_by_date = Register::select(DB::raw('sum(money) as money'))->whereIn("class_id", $classes_id)->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(paid_time)'))->pluck('money')->toArray();
         $registers_hour_array = array();
         for ($i = 0; $i < 24; $i++) {
             $registers_hour_array[$i] = 0;
         }
         foreach ($registers_by_hour as $regis) {
             $registers_hour_array[$regis->hour] = $regis->num;
         }
         $data['money_by_date'] = $money_by_date;
         $data['zero_paid_num'] = $zero_paid_num;
         $data['classes'] = $this->classTransformer->transformCollection($current_gen->studyclasses);
         $data['total_money'] = is_numeric($total_money) ? $total_money : 0;
         $data['register_number'] = is_numeric($num) ? $num : 0;
         $data['paid_number'] = is_numeric($paid_number) ? $paid_number : 0;
         $data['uncalled_number'] = is_numeric($uncalled_number) ? $uncalled_number : 0;
         $data['total_classes'] = is_numeric($total_classes) ? $total_classes : 0;
         $data['remain_days'] = round((is_numeric($remain_days) ? $remain_days : 0) / (24 * 3600), 2);
         $data['date_array'] = createDateRangeArray(strtotime($current_gen->start_time), strtotime($current_gen->end_time));
         $data['registers_by_date'] = $registers_by_date;
         $data['registers_by_hour'] = $registers_hour_array;
     }
     return response()->json($data, 200);
 }
Ejemplo n.º 17
0
 public function about_us_data($domain)
 {
     $gen = Gen::getCurrentGen();
     $classes = $gen->studyclasses()->where('name', 'like', '%.%')->count();
     $student = Register::where('code', '!=', null)->count() + 2000;
     $posts = Product::count() + 4000;
     return $this->respond(['gen' => ['name' => $gen->name, 'detail' => $gen->detail], 'studentsNumber' => $student, 'classesNumber' => $classes, 'postsNumber' => $posts]);
 }
Ejemplo n.º 18
0
 public function get_attendances_by_code(Request $request)
 {
     $code = $request->code;
     $register = Register::where('code', '=', $code)->first();
     $attendances = $register->attendances;
     $student = $register->user;
     $this->data['attendances'] = $attendances;
     $this->data['student'] = $student;
     $this->data['register'] = $register;
     return view('ajax.attendances', $this->data);
 }
 public function view2()
 {
     $registrants = Register::paginate(2);
     $registrants->setPath('registrants');
     return view('admin/view2', compact('registrants'));
 }
Ejemplo n.º 20
0
 public function index()
 {
     $registros = Register::all();
     return response()->json(['type' => 'success', 'data' => $registros]);
 }
 public function list_reg($id)
 {
     $list = Register::where('eventid', $id)->get();
     $event = Event::find($id);
     $fest = Fest::find($event->festid);
     return view('department.list', ['user' => Auth::user(), 'list' => $list, 'event' => $event, 'fest' => $fest]);
 }