/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function displayDashboard()
 {
     $todaysWorkoutList = Auth::user()->plans()->join('plan_workouts', 'plans.id', '=', 'plan_workouts.plan_id')->join('workouts', 'workouts.id', '=', 'plan_workouts.workout_id')->join('plan_dates', 'plan_workouts.id', '=', 'plan_dates.plan_workout_id')->whereBetween('plan_dates.planned_date', [Carbon::today(), Carbon::today()->addDay()->subMinute()])->select('plan_workouts.id', 'workouts.title')->lists('title', 'id');
     $planWorkoutList = Auth::user()->plans()->join('plan_workouts', 'plans.id', '=', 'plan_workouts.plan_id')->join('workouts', 'workouts.id', '=', 'plan_workouts.workout_id')->select('plan_workouts.id', 'workouts.title')->lists('title', 'id');
     $exerciseList = Auth::user()->exercises()->select('exercises.id', 'exercises.title')->lists('title', 'id');
     $plans = Auth::user()->plans()->get();
     $events = [];
     foreach ($plans as $plan) {
         foreach ($plan->planWorkouts as $planWorkout) {
             foreach ($planWorkout->planDates as $planDate) {
                 $events[] = \Calendar::event($planDate->planWorkout->workout->title, true, $planDate->planned_date, $planDate->planned_date);
             }
         }
     }
     // Documentation to help with interacting with madhatters fullCalendar.io interface
     //
     // $calendar = \Calendar::addEvents($events) //add an array with addEvents
     //     ->setOptions([ //set fullcalendar options
     //         'weekends' => false,
     //         'header' =>  ['left' => 'prev', 'center' => 'title', 'right' => 'next']
     //     ])->setCallbacks([ //set fullcalendar callback options (will not be JSON encoded)
     //         'viewRender' => 'function() {alert("Callbacks!");}'
     //     ]);
     $calendar = \Calendar::addEvents($events)->setOptions(['header' => ['left' => 'prev', 'center' => 'title', 'right' => 'next']])->setCallbacks([]);
     return view('dashboard', compact('todaysWorkoutList', 'planWorkoutList', 'exerciseList', 'plans', 'calendar'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $plan = Auth::user()->plans()->with('planWorkouts')->findOrFail($id);
     $events = [];
     foreach ($plan->planWorkouts as $planWorkout) {
         foreach ($planWorkout->planDates as $planDate) {
             $events[] = \Calendar::event($planDate->planWorkout->workout->title, true, $planDate->planned_date, $planDate->planned_date);
         }
     }
     $calendar = \Calendar::addEvents($events)->setOptions(['firstDay' => 1]);
     return view('plans.editPlanDates', compact('plan', 'calendar'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function calendar()
 {
     $events = [];
     $getevents = Event::all();
     foreach ($getevents as $event) {
         $events[] = \Calendar::event($event->titl, false, new \DateTime($event->start), new \DateTime($event->end), $event->event_id);
     }
     $events[] = \Calendar::event('Event One', false, '2015-11-11T0800', '2015-11-12T0800', 0);
     $events[] = \Calendar::event("Valentine's Day", true, new \DateTime('2015-11-14'), new \DateTime('2015-11-14'), 'stringEventId');
     $eloquentEvent = Event::first();
     //Event implements MaddHatter\LaravelFullcalendar\Event
     $calendar = \Calendar::addEvents($events);
     return view('calendar', compact('calendar'));
 }
 public function index()
 {
     if (Auth::user()) {
         $events = [];
         $array_events = DB::table('tasks')->where('user_id', '=', Auth::user()->id)->get();
         foreach ($array_events as $e) {
             //print_r($e);
             //echo '<br>';
             $events[] = \Calendar::event($e->name, $e->allDay, $e->start, $e->end);
         }
         $calendar = \Calendar::addEvents($events)->setOptions(['firstDay' => 1])->setCallbacks(['viewRender' => 'function() {}']);
         //return view('hello', compact('calendar'));
         return view('calendar.index', ['calendar' => $calendar, 'name' => Auth::user()->name]);
     }
     return redirect('/auth/login');
 }
    public function index()
    {
        //code should be inside a method
        //if using guzzle - Restful API
        $client = new Client();
        $response = $client->get('http://api.enviefitness.com/v1/events');
        $body = json_decode($response->getBody(), TRUE);
        foreach ($body['events'] as $e) {
            $events[] = \Calendar::event($e['activityType'] . ': ' . $e['title'], false, $e['start'], $e['end'], $e['id']);
        }
        //if using model
        $events[] = \Calendar::event('Test', false, '2015-07-07T1030', '2015-07-07T1200', 0, 'This is a test Event');
        $events[] = \Calendar::event('Sample', false, '2015-07-07T1200', '2015-07-07T1230', 0, 'This is a sample event');
        $calendar = \Calendar::addEvents($events)->setOptions(['firstDay' => 7, 'editable' => true, 'eventLimit' => true, 'header' => array('left' => 'prev,next today', 'center' => 'title', 'right' => 'month,basicWeek,basicDay')])->setCallbacks(['eventClick' => 'function(calEvent, jsEvent, view) {
					$("#modalTitle").html(calEvent.title);
		            $("#modalBody").html(calEvent.description);
		            $("#eventUrl").attr("href",calEvent.linkurl);
		            $("#fullCalModal").modal();
				}']);
        $content = view('calendar', compact('calendar'));
        return View::make($content);
    }
 /**
  * Modifie les disponibilités du bénévole sélectionné.
  *
  * @param  int  $id l'id du bénévole pour lequel on veut modifier
  * les disponibilités.
  * @return View
  */
 public function edit($id)
 {
     try {
         $benevole = Benevole::findOrFail($id);
         $disponibilites = $benevole->disponibilites;
         $calendrier = \Calendar::addEvents($disponibilites)->setOptions(['editable' => true, 'selectable' => true, 'displayEventTime' => true, 'displayEventEnd' => true, 'dragOpacity' => '.50', 'lang' => 'fr']);
         $calendrier->setCallbacks(['select' => $this->getSelectCallback($id, $calendrier), 'eventClick' => $this->getClickCallback($calendrier), 'eventDrop' => $this->getDropCallback($calendrier), 'eventResize' => $this->getEventResizeCallback($calendrier)]);
     } catch (ModelNotFoundException $e) {
         App::abort(404);
     }
     return View::make('disponibilites.edit', compact('benevole', 'calendrier'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $plan = Plan::with('planWorkouts')->findOrFail($id);
     $events = [];
     foreach ($plan->planWorkouts as $planWorkout) {
         foreach ($planWorkout->planDates as $planDate) {
             $events[] = \Calendar::event($planDate->planWorkout->workout->title, true, $planDate->planned_date, $planDate->planned_date);
         }
     }
     $calendar = \Calendar::addEvents($events)->setOptions(['header' => ['left' => 'prev', 'center' => 'title', 'right' => 'next']])->setCallbacks([]);
     return view('plans.showOne', compact('plan', 'calendar'));
 }
Example #8
0
 public static function getcalendar($fulldate)
 {
     if (empty($fulldate)) {
         //กำหนดตัวแปรที่ใช้คำนวณวัน
         $now = strtotime("now");
         //if(isset($_GET['now']) && !empty($_GET['now'])){
         //$now = $_GET['now'];
         //}
     } else {
         $now = strtotime("{$fulldate}");
     }
     $user_id = Auth::user()->id;
     $Year = date('Y', $now);
     $month = date('n', $now);
     $first_of_month = strtotime("{$Year}-{$month}-1");
     $first_day_of_week = date('w', $first_of_month);
     $last_day_of_month = date('t', $now);
     $lastday_previousmonth = date("j", strtotime("{$Year}-{$month}-1" . "last day of previous month"));
     $weekrow_of_month = Calendar::getweekofmonth($now);
     $today = date("Y-n-j");
     //กำหนดวันแรกของหน้าปฏฺทิน
     $startday = 1 - $first_day_of_week;
     //กำหนดลำดับวันประจำสัปดาห์
     $day_of_week = 1;
     $row_of_month = 1;
     //
     $all_event_of_week = "";
     echo "\n\t\t\t  <div class='panel-body'>\n\n\t\t\t    <div id='gridcontainer' style='height: 631px;position:relative;' >\n\t\t\t      <div class='mv-container'>\n\n              <div class='row' style='padding-bottom:8px;'>\n                <div class='col-xs-7'>\n                    <span style='font-size: 18px;'><b>" . date('F', $now) . "</b> " . $Year . "</span>\n                </div>\n                  <div class='col-xs-5 text-right'>\n                        <button class='btn btn-outline btn-info btn-xs' type='submit' name = 'btn-previous' onclick='getprecalendar(" . date('d', $now) . "," . date('m', $now) . "," . $Year . ")' > < </button>\n                        <button class='btn btn-outline btn-info btn-xs' type='submit' name = 'btn-previous' onclick='gettodaycalendar()' > today </button>\n                        <button class='btn btn-outline btn-info btn-xs' type='submit' name = 'btn-next' onclick='getnextcalendar(" . date('d', $now) . "," . date('m', $now) . "," . $Year . ")'> > </button>\n                  </div>\n              </div>\n\n\t\t\t        <table cellspacing='0' cellpadding='0' class='mv-daynames-table' >\n\t\t\t          <tbody>\n\t\t\t            <tr>\n\t\t\t              <th title='Sun' class='mv-dayname'>Sun</th>\n\t\t\t              <th title='Mon' class='mv-dayname'>Mon</th>\n\t\t\t              <th title='Tue' class='mv-dayname'>Tue</th>\n\t\t\t              <th title='Wed' class='mv-dayname'>Wed</th>\n\t\t\t              <th title='Thu' class='mv-dayname'>Thu</th>\n\t\t\t              <th title='Fri' class='mv-dayname'>Fri</th>\n\t\t\t              <th title='Sat' class='mv-dayname'>Sat</th>\n\t\t\t            </tr>\n\t\t\t          </tbody>\n\t\t\t        </table>\n\n\t\t\t        <div class='mv-event-container' >";
     //Set variable echo
     //กำหนดตัวแปริาร์เรย์ทมีหลายค่าไม่เหมือนกันี่
     $weekrow = array();
     $table1_row = array();
     $table2_row = array();
     $table2_row_event = array();
     $week_event_row = array();
     //จำนวนกิจกรรมในวันนั้น
     $weekrowfoot = "</div>";
     $table1_head = "<table cellspacing='0' cellpadding='0' class='st-bg-table'><tbody><tr>";
     $table1_foot = "</tr></tbody></table>";
     $table2_head = "<table cellspacing='0' cellpadding='0' class='st-grid' ><tbody>";
     $table2_foot = "</tbody></table>";
     $table2_row_foot = "</tr>";
     //End set variable echo
     //ใช้คำสั่ง for เพื่อสร้างปฏิทิน ===================================================================================
     for ($run_day = $startday;; $run_day++) {
         //กำหนดวันที่ปัจจุบัน
         $current_day = "{$Year}-{$month}-{$run_day}";
         $text_current_day = "{$Year},{$month},{$run_day}";
         //กำหนดค่าเริ่มต้น array ถ้า array ว่างอยู่
         if (empty($table1_row[$row_of_month - 1]) && empty($table2_row[$row_of_month - 1])) {
             $table1_row[$row_of_month - 1] = "";
             $table2_row[$row_of_month - 1] = "<tr>";
         }
         if ($row_of_month == 1) {
             $class = "st-dtitle-fr";
         } else {
             $class = "";
         }
         //ถ้าวันปัจจุบันน้อยกว่าวันแรกของเดือน
         if ($run_day < 1) {
             $table1_row[$row_of_month - 1] .= "<td class='st-bg'>&nbsp;</td>";
             $table2_row[$row_of_month - 1] .= "<td class='st-dtitle " . $class . " st-dtitle-nonmonth' >\n\t\t\t                                                  <span>" . ($lastday_previousmonth + $run_day) . "</span>\n\t\t\t                                                  </td>";
             //ถ้าวันปัจจุบันมากกว่าวันสุดท้ายของเดือน
         } else {
             if ($run_day > $last_day_of_month) {
                 $table1_row[$row_of_month - 1] .= "<td class='st-bg'>&nbsp;</td>";
                 $table2_row[$row_of_month - 1] .= "<td class='st-dtitle " . $class . " st-dtitle-nonmonth' >\n\t\t\t                                                  <span>" . ($run_day - $last_day_of_month) . "</span>\n\t\t\t                                                  </td>";
                 if ($day_of_week == 7) {
                     $weekrow[$row_of_month - 1] = "<div class='month-row weekrow" . $row_of_month . "_" . $weekrow_of_month . "' >";
                     //หลายค่า
                     break;
                 }
                 //ถ้าวันปัจจุบันเท่ากับวันสุดท้ายของเดือน และเป็นวันสุดท้ายของสัปดาห์
             } else {
                 if ($run_day == $last_day_of_month && $day_of_week == 7) {
                     if ($today == $current_day) {
                         $class_today = "st-bg-today";
                     } else {
                         $class_today = "";
                     }
                     $table1_row[$row_of_month - 1] .= "<td class='st-bg " . $class_today . "' id='" . $current_day . "' >&nbsp;</td>";
                     $table2_row[$row_of_month - 1] .= "<td class='st-dtitle " . $class . "' id='" . $current_day . "'>\n\t\t\t                                                  <span>" . $run_day . "</span>\n\t\t\t                                                  </td>";
                     $weekrow[$row_of_month - 1] = "<div class='month-row weekrow" . $row_of_month . "_" . $weekrow_of_month . "' >";
                     //หลายค่า
                     break;
                 } else {
                     if ($today == $current_day) {
                         $class_today = "st-bg-today";
                     } else {
                         $class_today = "";
                     }
                     if ($run_day == 1) {
                         $month_in_calendar = date('M', $now);
                     } else {
                         $month_in_calendar = "";
                     }
                     $table1_row[$row_of_month - 1] .= "<td class='st-bg " . $class_today . "' id='" . $current_day . "' >&nbsp;</td>";
                     $table2_row[$row_of_month - 1] .= "<td class='st-dtitle " . $class . "' id='" . $current_day . "'>\n\t\t\t                                                <span>" . $month_in_calendar . $run_day . "</span>\n\t\t\t                                                </td>";
                 }
             }
         }
         //ถ้าปัจจุบันเป็นวันสุดท้ายของสัปดาห์
         if ($day_of_week == 7) {
             $weekrow[$row_of_month - 1] = "<div class='month-row weekrow" . $row_of_month . "_" . $weekrow_of_month . "' >";
             //หลายค่า
             $day_of_week = 1;
             $row_of_month++;
             //ถ้าปัจจุบันไม่ใช่วันสุดท้ายของสัปดาห์
         } else {
             $day_of_week++;
         }
     }
     //จบคำสั่ง for เพื่อสร้างปฏิทิน ===================================================================================
     //เริ่มคำสั่ง for เพื่อนับจำนวนแถว event ==================================================================================
     $day_of_week = 1;
     $row_of_month = 1;
     $week_event_row_run = 0;
     for ($run_day = $startday;; $run_day++) {
         //กำหนดวันที่ปัจจุบัน
         $current_day = "{$Year}-{$month}-{$run_day}";
         $text_current_day = "{$Year},{$month},{$run_day}";
         //เช็คเงื่อนไข และกำหนดวันเริ่ม วันจบ ที่ดึง event
         if ($run_day < 1) {
             $this_day = $lastday_previousmonth + $run_day;
             if ($month == 1) {
                 $this_month = 12;
                 $this_year = $Year - 1;
             } else {
                 $this_month = $month - 1;
                 $this_year = $Year;
             }
             $start = "{$this_year}-{$this_month}-{$this_day}";
             $end = "{$this_year}-{$this_month}-{$this_day}";
         } else {
             if ($run_day > $last_day_of_month) {
                 $this_day = $run_day - $last_day_of_month;
                 if ($month == 12) {
                     $this_month = 1;
                     $this_year = $Year + 1;
                 } else {
                     $this_month = $month - 1;
                     $this_year = $Year;
                 }
                 $start = "{$this_year}-{$this_month}-{$this_day}";
                 $end = "{$this_year}-{$this_month}-{$this_day}";
             } else {
                 $start = "{$Year}-{$month}-{$run_day}";
                 $end = "{$Year}-{$month}-{$run_day}";
             }
         }
         //จบเช็คเงื่อนไข และกำหนดวันเริ่ม วันจบ ที่ดึง event
         //ดึง event จาก DB ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
         $eventmulti = RequestJob::getrequestjobmulti($start, $end, $user_id);
         $event = RequestJob::getrequestonejob($start, $user_id);
         $numberevent_of_day = count($event);
         $numbermultievent_of_day = count($eventmulti);
         $all_event_of_day = $numberevent_of_day + $numbermultievent_of_day;
         //เช็คแถว event ทั้งหมดในสัปดาห์
         if ($week_event_row_run < $all_event_of_day) {
             $week_event_row_run = $all_event_of_day;
         }
         //จบดึง event จาก DB ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
         //ตรวจสอบวันสุดท้ายของเดือน
         if ($run_day > $last_day_of_month && $day_of_week == 7 || $run_day == $last_day_of_month && $day_of_week == 7) {
             //เก็บค่า event row ในแต่ละสัปดาห์
             $week_event_row[$row_of_month - 1] = $week_event_row_run;
             break;
         } else {
         }
         //ถ้าปัจจุบันเป็นวันสุดท้ายของสัปดาห์
         if ($day_of_week == 7) {
             //เก็บค่า event row ในแต่ละสัปดาห์
             $week_event_row[$row_of_month - 1] = $week_event_row_run;
             $week_event_row_run = 0;
             $day_of_week = 1;
             $row_of_month++;
             //ถ้าปัจจุบันไม่ใช่วันสุดท้ายของสัปดาห์
         } else {
             $day_of_week++;
         }
     }
     //จบคำสั่ง for เพื่อนับจำนวนแถว event =================================================================================
     //เริ่มคำสั่ง for สร้าง event ==================================================================================
     $day_of_week = 1;
     $row_of_month = 1;
     for ($run_day = $startday;; $run_day++) {
         //กำหนดวันที่ปัจจุบัน
         $current_day = "{$Year}-{$month}-{$run_day}";
         $text_current_day = "{$Year},{$month},{$run_day}";
         //เช็คเงื่อนไข และกำหนดวันเริ่ม วันจบ ที่ดึง event
         if ($run_day < 1) {
             $this_day = $lastday_previousmonth + $run_day;
             if ($month == 1) {
                 $this_month = 12;
                 $this_year = $Year - 1;
             } else {
                 $this_month = $month - 1;
                 $this_year = $Year;
             }
             $start = "{$this_year}-{$this_month}-{$this_day}";
             $end = "{$this_year}-{$this_month}-{$this_day}";
         } else {
             if ($run_day > $last_day_of_month) {
                 $this_day = $run_day - $last_day_of_month;
                 if ($month == 12) {
                     $this_month = 1;
                     $this_year = $Year + 1;
                 } else {
                     $this_month = $month - 1;
                     $this_year = $Year;
                 }
                 $start = "{$this_year}-{$this_month}-{$this_day}";
                 $end = "{$this_year}-{$this_month}-{$this_day}";
             } else {
                 $start = "{$Year}-{$month}-{$run_day}";
                 $end = "{$Year}-{$month}-{$run_day}";
             }
         }
         //จบเช็คเงื่อนไข และกำหนดวันเริ่ม วันจบ ที่ดึง event
         //ดึง event จาก DB ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
         $eventmulti = RequestJob::getrequestjobmulti($start, $end, $user_id);
         $event = RequestJob::getrequestonejob($start, $user_id);
         $numberevent_of_day = count($event);
         $numbermultievent_of_day = count($eventmulti);
         $all_event_of_day = $numberevent_of_day + $numbermultievent_of_day;
         //จบดึง event จาก DB ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
         if ($all_event_of_day > 0) {
             $eventmultincount = 0;
             $eventcount = 0;
             for ($i = 0; $i < $week_event_row[$row_of_month - 1]; $i++) {
                 if (empty($table2_row_event[$row_of_month - 1][$i])) {
                     $table2_row_event[$row_of_month - 1][$i] = "<tr>";
                 }
                 //เพิ่มจำกัดกำนวนที่แสดง
                 if ($i == 4) {
                     $table2_row_event[$row_of_month - 1][$i] = "<tr><td class='st-c st-more-c'><span class='ca-mlp23595 st-more st-moreul' id='" . $current_day . "'>+ more</span></td>";
                     break;
                 }
                 //เพิ่มจำกัดกำนวนที่แสดง
                 //เช็ค event หลายวัน
                 if ($numbermultievent_of_day > 0 && $numbermultievent_of_day > $eventmultincount) {
                     $number_of_multiday = $eventmulti[$eventmultincount]['Numberofday'] + 1;
                     $today_week_number = date('w', strtotime($current_day));
                     if (!empty($eventmulti[$eventmultincount]['request_name'])) {
                         $title = $eventmulti[$eventmultincount]['request_name'];
                     } else {
                         $title = "&nbsp;";
                     }
                     //เช็คช่วงเวลา request
                     if ($eventmulti[$eventmultincount]['duration'] == 2) {
                         $event_color_class = "event_color_morning";
                     } else {
                         if ($eventmulti[$eventmultincount]['duration'] == 3) {
                             $event_color_class = "event_color_afternoon";
                         } else {
                             $event_color_class = "event_color_allday";
                         }
                     }
                     if (strtotime($eventmulti[$eventmultincount]['start_date']) == strtotime($current_day)) {
                         if (7 - $today_week_number >= $number_of_multiday) {
                             $colspan = $number_of_multiday;
                         } else {
                             $colspan = 7 - $today_week_number;
                         }
                         $table2_row_event[$row_of_month - 1][$i] .= "<td class='st-c' colspan='" . $colspan . "'>\n                                                                        <div id='" . $eventmulti[$eventmultincount]['id'] . "' class='st-c-pos'>\n                                                                            <div class='rb-n " . $event_color_class . "' >\n                                                                            <div class='rb-ni'>" . $title . "</div>\n                                                                            </div>\n                                                                        </div>\n                                                                        </td>";
                     } else {
                         if ($today_week_number == 0) {
                             $timeDiff = abs(strtotime($current_day) - strtotime($eventmulti[$eventmultincount]['start_date']));
                             $numberDays = $timeDiff / 86400;
                             // 86400 seconds in one day
                             $eventpassdate = intval($numberDays);
                             $resultdate = $number_of_multiday - $eventpassdate;
                             if (7 - $today_week_number >= $resultdate) {
                                 $colspan = $resultdate;
                             } else {
                                 $colspan = 7 - $today_week_number;
                             }
                             $table2_row_event[$row_of_month - 1][$i] .= "<td class='st-c' colspan='" . $colspan . "'>\n                                                                      <div id='" . $eventmulti[$eventmultincount]['id'] . "' class='st-c-pos'>\n                                                                          <div class='rb-n " . $event_color_class . "' >\n                                                                          <div class='rb-ni'>" . $title . "</div>\n                                                                          </div>\n                                                                      </div>\n                                                                      </td>";
                         }
                     }
                     //เพิ่มทีหลัง
                     /*else{
                     
                                                 $rowspan = $week_event_row[$row_of_month-1] - $i;
                     
                                                 $table2_row_event[$row_of_month-1][$i] .= "<td id='". $current_day ."' rowspan='". $rowspan ."' class='st-c st-s'>&nbsp;</td>";
                     
                                               }*/
                     //เพิ่มทีหลัง
                     $eventmultincount++;
                 } else {
                     //เช็ค event เดี่ยว
                     if ($numberevent_of_day > 0 && $numberevent_of_day > $eventcount && $numbermultievent_of_day == $eventmultincount) {
                         if (!empty($event[$eventcount]['request_name'])) {
                             $title = $event[$eventcount]['request_name'];
                         } else {
                             $title = "&nbsp;";
                         }
                         //เช็คช่วงเวลา request
                         if ($event[$eventcount]['duration'] == 2) {
                             $event_color_class = "event_color_morning";
                         } else {
                             if ($event[$eventcount]['duration'] == 3) {
                                 $event_color_class = "event_color_afternoon";
                             } else {
                                 $event_color_class = "event_color_allday";
                             }
                         }
                         if ($numberevent_of_day == $eventcount + 1) {
                             $rowspan = $week_event_row[$row_of_month - 1] - $i;
                             $table2_row_event[$row_of_month - 1][$i] .= "<td class='st-c' rowspan='" . $rowspan . "'>\n                                                                      <div id='" . $event[$eventcount]['id'] . "' class='st-c-pos'>\n                                                                          <div class='rb-n " . $event_color_class . "' >\n                                                                          <div class='rb-ni'>" . $title . "</div>\n                                                                          </div>\n                                                                      </div>\n                                                                      </td>";
                             break;
                         } else {
                             $table2_row_event[$row_of_month - 1][$i] .= "<td class='st-c'>\n                                                                      <div id='" . $event[$eventcount]['id'] . "' class='st-c-pos'>\n                                                                          <div class='rb-n " . $event_color_class . "' >\n                                                                          <div class='rb-ni'>" . $title . "</div>\n                                                                          </div>\n                                                                      </div>\n                                                                      </td>";
                         }
                         $eventcount++;
                     } else {
                         if ($numberevent_of_day == $eventcount && $numbermultievent_of_day == $eventmultincount) {
                             $rowspan = $week_event_row[$row_of_month - 1] - $i;
                             $table2_row_event[$row_of_month - 1][$i] .= "<td id='" . $current_day . "' rowspan='" . $rowspan . "' class='st-c st-s'>&nbsp;</td>";
                             break;
                         }
                     }
                 }
             }
         } else {
             if (empty($table2_row_event[$row_of_month - 1][0])) {
                 $table2_row_event[$row_of_month - 1][0] = "<tr>";
             }
             $table2_row_event[$row_of_month - 1][0] .= "<td id='" . $current_day . "' rowspan='" . $week_event_row[$row_of_month - 1] . "' class='st-c st-s'>&nbsp;</td>";
         }
         //ถ้าปัจจุบันเป็นวันสุดท้ายของสัปดาห์
         if ($day_of_week == 7) {
             if ($all_event_of_day > 0) {
                 for ($i = 0; $i < $week_event_row[$row_of_month - 1]; $i++) {
                     $table2_row_event[$row_of_month - 1][$i] .= "</tr>";
                 }
             } else {
                 $table2_row_event[$row_of_month - 1][0] .= "</tr>";
             }
             $day_of_week = 1;
             $row_of_month++;
             //เช็ควันสุดท้าย
             if ($run_day > $last_day_of_month || $run_day == $last_day_of_month) {
                 break;
             }
             //ถ้าปัจจุบันไม่ใช่วันสุดท้ายของสัปดาห์
         } else {
             $day_of_week++;
         }
     }
     //จบคำสั่ง for เพื่อสร้าง event =================================================================================
     //run เพื่อแสดงผล
     for ($round = 0; $round < $weekrow_of_month; $round++) {
         $all_event_of_week = "";
         if ($week_event_row[$round] != 0) {
             $countthisweek[$round] = count($table2_row_event[$round]);
         } else {
             $countthisweek[$round] = 0;
         }
         for ($i = 0; $i < $countthisweek[$round]; $i++) {
             /*if(empty($all_event_of_week)){
                 $all_event_of_week = "";
               }*/
             $all_event_of_week .= $table2_row_event[$round][$i];
         }
         echo $weekrow[$round] . $table1_head . $table1_row[$round] . $table1_foot . $table2_head . $table2_row[$round] . $table2_row_foot . $all_event_of_week . $table2_row_foot . $table2_foot . $weekrowfoot;
     }
     echo "</div>\n\t\t\t      </div>\n\t\t\t    </div>\n\n\t\t\t  </div>\n\t\t\t";
     //add test
     /*echo "<div>";
           for($i = 0 ;$i < count($countthisweek); $i++){
             echo $countthisweek[$i] . "<br>";
           }
           echo "</div><br>";
           //end test
     
           echo "<div>";
           for($i = 0 ;$i < count($week_event_row); $i++){
             echo $week_event_row[$i] . "<br>";
           }
           echo "</div>";*/
     //end test
 }
 public function cal(Project $project)
 {
     $events = [];
     foreach ($project->tasks as $task) {
         $events[] = \Calendar::event($task->taskname, true, $task->due_date, $task->end_date, route('projects.tasks.show', [$project->slug, $task->slug]));
     }
     $calendar = \Calendar::addEvents($events);
     //add an array with addEvents
     return view('projects.cal', compact('project', 'calendar'));
 }