Beispiel #1
0
 public function store_base(Request $request)
 {
     $name = $request->name;
     $address = $request->address;
     $id = $request->base_id;
     if ($id == null) {
         $base = new Base();
     } else {
         $base = Base::find($id);
     }
     $base->name = $name;
     $base->address = $address;
     $base->center = $request->center;
     $base->save();
     return redirect('manage/bases');
 }
Beispiel #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $date = new \DateTime();
     $date->modify('+3 days');
     $formatted_date_from = $date->format('Y-m-d');
     $date->modify('+6 days');
     $formatted_date_to = $date->format('Y-m-d');
     $dates = createDateRangeArray(strtotime($formatted_date_from), strtotime($formatted_date_to));
     $bases = Base::where('center', 1)->get();
     $current_gen = Gen::getCurrentGen();
     $shiftSessions = ShiftSession::where('active', 1)->get();
     $lastShift = Shift::where('gen_id', $current_gen->id)->orderBy('week', 'desc')->first();
     $week = $lastShift ? $lastShift->week : 0;
     foreach ($dates as $date) {
         foreach ($bases as $base) {
             foreach ($shiftSessions as $shiftSession) {
                 $shift = new Shift();
                 $shift->gen_id = $current_gen->id;
                 $shift->base_id = $base->id;
                 $shift->shift_session_id = $shiftSession->id;
                 $shift->week = $week + 1;
                 $shift->date = $date;
                 $shift->save();
             }
         }
     }
     $role_ids = Tab::find(35)->roles->pluck('id')->unique()->toArray();
     $roles = Role::whereIn('id', $role_ids)->get();
     if ($week == 0) {
         $week = 1;
     }
     foreach ($roles as $role) {
         $users = $role->users;
         foreach ($users as $user) {
             send_mail_regis_shift($user, $week, $current_gen, ['*****@*****.**']);
         }
     }
     $this->info('done');
 }
Beispiel #3
0
 public function landing(Request $request)
 {
     $landing = Landing::find($request->id);
     $course_id = $landing->course_id;
     $course = Course::find($course_id);
     $courses = Course::all();
     $current_gen = Gen::getCurrentGen();
     $classes = StudyClass::getClassesByCourseAndGen($current_gen->id, $course_id);
     $date_start = $course->classes->sortbyDesc('datestart')->first();
     $bases = Base::all();
     $demos = json_decode($landing->demos, true);
     $timeline = json_decode($landing->timeline, true);
     $feedbacks = json_decode($landing->feedbacks, true);
     $reasons = json_decode($landing->reasons, true);
     $demo_contents = array();
     for ($i = 1; $i <= 6; $i++) {
         if ($demos['demo' . $i]) {
             $product = Product::find($demos['demo' . $i]);
             if ($product->type == 2) {
                 $demo_contents[$i] = $product->content;
             } else {
                 $demo_contents[$i] = '<img src=' . $product->url . '>';
             }
         } else {
             $demo_contents[$i] = '';
         }
     }
     //        dd($demo_contents);
     $this->data['landing'] = $landing;
     $this->data['demo_contents'] = $demo_contents;
     $this->data['demos'] = $demos;
     $this->data['timeline'] = $timeline;
     $this->data['feedbacks'] = $feedbacks;
     $this->data['reasons'] = $reasons;
     $this->data['bases'] = $bases;
     $this->data['date_start'] = $date_start->datestart;
     $this->data['current_gen_id'] = $current_gen->id;
     $this->data['course_id'] = $course_id;
     $this->data['course'] = $course;
     $this->data['classes'] = $classes;
     $this->data['courses'] = $courses;
     return view('public.landing-promo', $this->data);
 }
Beispiel #4
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);
 }
Beispiel #5
0
 public function edit_class($class_id = null)
 {
     $courses = Course::all();
     $this->data['courses'] = $courses;
     $this->data['staffs'] = User::where('role', 1)->get();
     $gens = Gen::all();
     $this->data['gens'] = $gens;
     $this->data['isEdit'] = true;
     $this->data['bases'] = Base::all();
     $this->data['class'] = StudyClass::find($class_id);
     $this->data['current_tab'] = 9;
     return view('manage.editclass', $this->data);
 }