public function getManageEvent() { $events = Events::orderBy('start', 'ASC')->get(); foreach ($events as $event) { $times = array("start", "finish"); for ($i = 0; $i < sizeof($times); $i++) { $strDate = $event->{$times}[$i]; $strYear = date("Y", strtotime($strDate)) + 543; $strMonth = date("n", strtotime($strDate)); $strDay = date("j", strtotime($strDate)); $strHour = date("H", strtotime($strDate)); $strMinute = date("i", strtotime($strDate)); $strSeconds = date("s", strtotime($strDate)); $strMonthCut = array("", "มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม ", "พฤศจิกายน", "ธันวาคม"); $strMonthThai = $strMonthCut[$strMonth]; $event->{$times}[$i] = "{$strDay} {$strMonthThai} {$strYear}, {$strHour}:{$strMinute}"; } } return View::make('admin.manage_event')->with('events', $events); }
public function filterEvents() { $location = Input::get('location'); if ($location == "ทั้งหมด") { $events = Events::orderBy('start', 'ASC')->get(); } else { $events = Events::where('location', $location)->orderBy('start', 'ASC')->get(); } foreach ($events as $event) { date_default_timezone_set('Asia/Bangkok'); $date11 = $event->start; $date21 = $event->finish; if (date("Y-m-d H:i:s") < $date11) { $date1 = new DateTime($date11); $date2 = new DateTime(date("Y-m-d H:i:s")); $interval = $date2->diff($date1); if ($interval->days == 0) { $event['status'] = "-3"; $event['hr'] = $interval->h; } else { //$event['status'] = $interval->days; $event['status'] = "-3"; } //$event['status'] = $interval->days; } elseif (date("Y-m-d H:i:s") >= $date11 && date("Y-m-d H:i:s") <= $date21) { $event['status'] = "-1"; } elseif (date("Y-m-d H:i:s") >= $date21) { $event['status'] = "-2"; } else { $event['status'] = "9999"; } $start = new DateTime($date11); $finish = new DateTime($date21); $interval1 = $start->diff($finish); //dd($event->start); if ($interval1->days < 1) { $strDate = $event->start; $strYear = date("Y", strtotime($strDate)) + 543; $strMonth = date("n", strtotime($strDate)); $strDay = date("j", strtotime($strDate)); $strHour = date("H", strtotime($strDate)); $strMinute = date("i", strtotime($strDate)); $strSeconds = date("s", strtotime($strDate)); $strMonthCut = array("", "มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม ", "พฤศจิกายน", "ธันวาคม"); $strMonthThai = $strMonthCut[$strMonth]; $event['format'] = "{$strDay} {$strMonthThai} {$strYear}"; } elseif ($interval1->days > 0) { if ($strMonth = date("n", strtotime($event->start)) == ($strMonth = date("n", strtotime($event->finish)))) { $strDate = $event->start; $strYear = date("Y", strtotime($strDate)) + 543; $strMonth = date("n", strtotime($strDate)); $strDay = date("j", strtotime($strDate)); $strHour = date("H", strtotime($strDate)); $strMinute = date("i", strtotime($strDate)); $strSeconds = date("s", strtotime($strDate)); $strMonthCut = array("", "มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม ", "พฤศจิกายน", "ธันวาคม"); $strMonthThai = $strMonthCut[$strMonth]; $strDayFinish = date("j", strtotime($event->finish)); $event['format'] = "{$strDay} - {$strDayFinish} {$strMonthThai} {$strYear}"; } else { $strDate = $event->start; $strYear = date("Y", strtotime($strDate)) + 543; $strMonth = date("n", strtotime($strDate)); $strDay = date("j", strtotime($strDate)); $strHour = date("H", strtotime($strDate)); $strMinute = date("i", strtotime($strDate)); $strSeconds = date("s", strtotime($strDate)); $strMonthCut = array("", "มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม ", "พฤศจิกายน", "ธันวาคม"); $strMonthThai = $strMonthCut[$strMonth]; $strDayFinish = date("j", strtotime($event->finish)); $strMonthFinish = date("n", strtotime($event->finish)); $event['format'] = "{$strDay} {$strMonthThai} - {$strDayFinish} {$strMonthCut[$strMonthFinish]} {$strYear}"; } } $times = array("start", "finish"); for ($i = 0; $i < sizeof($times); $i++) { $strDate = $event->{$times}[$i]; $strYear = date("Y", strtotime($strDate)) + 543; $strMonth = date("n", strtotime($strDate)); $strDay = date("j", strtotime($strDate)); $strHour = date("H", strtotime($strDate)); $strMinute = date("i", strtotime($strDate)); $strSeconds = date("s", strtotime($strDate)); $strMonthCut = array("", "มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม ", "พฤศจิกายน", "ธันวาคม"); $strMonthThai = $strMonthCut[$strMonth]; $event->{$times}[$i] = "{$strDay} {$strMonthThai} - {$strDayFinish} {$strMonthCut[$strMonthFinish]} {$strYear} เวลา {$strHour}:{$strMinute} น."; //$event['stat'] = 'newenw'; } } foreach ($events as $event) { if ($event->status != -2 && $event->status == -1) { echo "<div class=\"col-xs-12 col-sx-6 col-sm-6 col-md-6 col-lg-4\">\n <div class=\"feature\">\n <a href=\"/events/{$event->id}/show\">\n <div class=\"event-title\">\n {$event->name}\n </div>\n <div class=\"event-img\">\n <img class=\"lazy img-responsive\" data-original=\"/uploads/events/{$event->img}\" alt=\"BMW M1 Hood\" src=\"/uploads/events/{$event->img}\" style=\"display: block;\">\n\n </div>\n <div class=\"event-desc\">"; if (!$event->repeat) { echo "<p>{$event->format}</p>\n <p>@ {$event->where}, {$event->location}</p>"; } else { echo "<p>ทุก{$event->day} เริ่ม {$event->start}</p>\n <p>@ {$event->where}, {$event->location}</p>"; } echo "</div>\n </a>\n </div>\n </div>"; } } }
@extends('layouts.qlm_administrator') @section('content') <?php $_countPage = DB::table('qlm_events')->count(); $_resultPage1st = Events::orderBy('eventDate', 'desc')->get(); ?> <!-- Page Heading --> <div class="row"> <div class="col-lg-12"> <h1 class="page-header"> List of events </h1> </div> </div> <!-- /.row --> <div class="row"> <div class="col-lg-12 col-md-12"> <div class="panel panel-primary"> <div class="panel-heading"> <div class="row"> <div class="col-xs-3"> <i class="fa fa-edit fa-5x"></i> </div> <div class="col-xs-9 text-right"> <div class="huge">{{ $_countPage }}</div> <div>events in database!</div> </div> </div> </div> <a href="{{asset('qlm-admin/add-new-events')}}"> <div class="panel-footer">