예제 #1
0
 public function home()
 {
     $page_title = "لوحة التحكم";
     $section_title = "لوحة التحكم";
     Date::setLocale('ar');
     $date = Date::now()->format('j F Y');
     $day = Date::now()->format('l');
     $month = Date::now()->format('F');
     $year = Date::now()->format('Y');
     //**************Tasks***************
     $tasksToday = Task::orderBy('task_date', 'desc')->today()->take(5);
     $tasksWeek = Task::orderBy('task_date', 'desc')->thisweek()->take(5);
     $tasksMonth = Task::orderBy('task_date', 'desc')->thisMonth()->take(5);
     $tasks_count = count($tasksToday->toArray());
     //**************Fails***************
     $failsToday = Failure::orderBy('fail_time', 'desc')->today()->take(5);
     $failsWeek = Failure::orderBy('fail_time', 'desc')->thisweek()->take(5);
     $failsMonth = Failure::orderBy('fail_time', 'desc')->thisMonth()->take(5);
     $fails_count = count($failsToday->toArray());
     //**************Repairs***************
     $repairsToday = Repair::today();
     $repairsWeek = Repair::thisweek();
     $repairsMonth = Repair::thisMonth();
     $repairs_count = count($repairsToday->toArray());
     return view('dashboard.dashboard', compact('page_title', 'section_title', 'date', 'day', 'month', 'year', 'tasksToday', 'tasksMonth', 'tasksWeek', 'tasks_count', 'failsToday', 'failsMonth', 'failsWeek', 'fails_count', 'repairsToday', 'repairsMonth', 'repairsWeek', 'repairs_count'));
 }
예제 #2
0
 /**
  *
  */
 public function trash()
 {
     if ($this->isDeleted()) {
         return;
     }
     $this->deletedAt = Date::now();
 }
 public function getInsert()
 {
     //if(Input::old('tanggal')!="" and Input::old('nis')!="") {
     $siswa = \DB::table('t_siswa_tingkat')->where('nis', Input::old('nis'))->first();
     if ($siswa == null) {
         \Session::flash('siswa_ilang', 'NIS tidak ditemukan');
         return redirect('/home');
     }
     $date = Date::createFromFormat('Y-m-d', Input::old('tanggal'));
     $tapel = AbsencesController::checkPeriode($date);
     $tapel['kd_tapel'] = \DB::table('t_tahun_ajaran')->where('tahun_ajaran', $tapel['tahun_ajaran'])->first()->kd_tahun_ajaran;
     $siswa_tingkat = \DB::table('t_siswa_tingkat')->where('nis', $siswa->nis)->where('kd_tahun_ajaran', $tapel['kd_tapel'])->where('kd_periode_belajar', $tapel['periode'])->first();
     if ($siswa_tingkat == null) {
         \Session::flash('tahun_ajaran', 'Tahun ajaran belum dimulai');
         return redirect('/home');
     }
     $siswa = \DB::table('t_siswa')->where('nis', $siswa->nis)->first();
     $pikets = \DB::table('t_piket')->where('hari', $date->format('l'))->first();
     $piket = \DB::table('t_guru')->where('kd_guru', $pikets->kd_guru)->first();
     $jam_masuk = Date::createFromFormat('H:i:s', $pikets->jam_masuk, Date::now()->tzName);
     return view('absences.insert', compact('date', 'jam_masuk', 'siswa', 'siswa_tingkat', 'piket', 'tapel'));
     //}
     //else
     //    return redirect('home');
 }
예제 #4
0
파일: view.php 프로젝트: ankhzet/Ankh
function today()
{
    global $today;
    if (!isset($today)) {
        $today = Date::now();
        $today->hour = 0;
        $today->minute = 0;
        $today->second = 0;
    }
    return $today;
}
 public function getIndex()
 {
     $absens = \DB::table('t_kesiangan')->get();
     $kelas = \DB::table('t_siswa_tingkat')->distinct('kd_rombel')->orderBy('kd_rombel')->get(['kd_rombel']);
     $headers = ['NIS', 'Nama', 'Kelas', 'Tahun Ajaran', 'Semester', 'Hari', 'Tanggal', 'Jam Datang', 'Menit Kesiangan', 'Piket', 'Keterangan'];
     $date = Date::now();
     $th1 = strval($date->year - 1) . "/" . strval($date->year);
     $th2 = strval($date->year) . "/" . strval($date->year + 1);
     $t1 = \DB::table('t_tahun_ajaran')->where('tahun_ajaran', $th1)->get();
     $t2 = \DB::table('t_tahun_ajaran')->where('tahun_ajaran', $th2)->get();
     $tahun_ajaran = (object) array_merge((array) $t1, (array) $t2);
     return view('laporan.index', compact('headers', 'absens', 'tahun_ajaran', 'kelas'));
 }
예제 #6
0
 /**
  * Returns the rendered Blade templates.
  *
  * @return \Illuminate\View\View
  */
 public function showIndex()
 {
     $today = Date::now();
     $startDate = Date::now();
     segment_page('Status Page');
     // Check if we have another starting date
     if (Binput::has('start_date')) {
         try {
             // If date provided is valid
             $oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date'));
             segment_track('Status Page', ['start_date' => $oldDate->format('Y-m-d')]);
             // If trying to get a future date fallback to today
             if ($today->gt($oldDate)) {
                 $startDate = $oldDate;
             }
         } catch (Exception $e) {
             // Fallback to today
         }
     }
     $metrics = null;
     if ($displayMetrics = Setting::get('display_graphs')) {
         $metrics = Metric::where('display_chart', 1)->get();
     }
     $daysToShow = Setting::get('app_incident_days') ?: 7;
     $incidentDays = range(0, $daysToShow - 1);
     $dateTimeZone = Setting::get('app_timezone');
     $incidentVisiblity = Auth::check() ? 0 : 1;
     $allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisiblity)->whereBetween('created_at', [$startDate->copy()->subDays($daysToShow)->format('Y-m-d') . ' 00:00:00', $startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) use($dateTimeZone) {
         return (new Date($incident->created_at))->setTimezone($dateTimeZone)->toDateString();
     });
     // Add in days that have no incidents
     foreach ($incidentDays as $i) {
         $date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i);
         if (!isset($allIncidents[$date->toDateString()])) {
             $allIncidents[$date->toDateString()] = [];
         }
     }
     // Sort the array so it takes into account the added days
     $allIncidents = $allIncidents->sortBy(function ($value, $key) {
         return strtotime($key);
     }, SORT_REGULAR, true)->all();
     // Scheduled maintenance code.
     $scheduledMaintenance = Incident::scheduled()->orderBy('scheduled_at')->get();
     // Component & Component Group lists.
     $usedComponentGroups = Component::where('group_id', '>', 0)->groupBy('group_id')->lists('group_id');
     $componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
     $ungroupedComponents = Component::where('group_id', 0)->orderBy('order')->orderBy('created_at')->get();
     $canPageBackward = Incident::notScheduled()->where('created_at', '<', $startDate->format('Y-m-d'))->count() != 0;
     return View::make('index', ['componentGroups' => $componentGroups, 'ungroupedComponents' => $ungroupedComponents, 'displayMetrics' => $displayMetrics, 'metrics' => $metrics, 'allIncidents' => $allIncidents, 'scheduledMaintenance' => $scheduledMaintenance, 'aboutApp' => Markdown::convertToHtml(Setting::get('app_about')), 'canPageForward' => (bool) $today->gt($startDate), 'canPageBackward' => $canPageBackward, 'previousDate' => $startDate->copy()->subDays($daysToShow)->toDateString(), 'nextDate' => $startDate->copy()->addDays($daysToShow)->toDateString(), 'pageTitle' => Setting::get('app_name') . ' Status']);
 }
 /**
  * Check if access is allowed given an RFID card identifier.
  *
  * @param   Resource  $resource
  * @param   string    $cardId
  * @return  Response
  */
 public function check(Resource $resource, $cardId)
 {
     $now = Date::now();
     try {
         $card = Card::findOrFail($cardId);
         // @todo: refactor for single responsibility
         $reservation = $resource->reservations()->where('starts_at', '<=', $now)->where('ends_at', '>', $now)->where('user_id', '=', $card->user->id)->first();
         $allow = $reservation ? true : false;
         //
     } catch (ModelNotFoundException $e) {
         $reservation = null;
         $allow = false;
     }
     return ['time' => $now->format('Y-m-d H:i:s'), 'reservation' => $reservation, 'allow' => $allow];
 }
예제 #8
0
 /**
  * Displays the explore page.
  *
  * @return \Illuminate\View\View
  */
 public function showIndex()
 {
     $today = Date::now();
     $startDate = Date::now();
     // Check if we have another starting date
     if (Binput::has('start_date')) {
         try {
             // If date provided is valid
             $oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date'));
             // If trying to get a future date fallback to today
             if ($today->gt($oldDate)) {
                 $startDate = $oldDate;
             }
         } catch (Exception $e) {
             // Fallback to today
         }
     }
     $daysToShow = Setting::get('app_issue_days', 0) - 1;
     if ($daysToShow < 0) {
         $daysToShow = 0;
         $issueDays = [];
     } else {
         $issueDays = range(0, $daysToShow);
     }
     $dateTimeZone = Setting::get('app_timezone');
     $issueVisiblity = Auth::check() ? 0 : 1;
     $allIssues = Issue::where('visible', '>=', $issueVisiblity)->whereBetween('created_at', [$startDate->copy()->subDays($daysToShow)->format('Y-m-d') . ' 00:00:00', $startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->groupBy(function (Issue $issue) use($dateTimeZone) {
         // If it's scheduled, get the scheduled at date.
         if ($issue->is_scheduled) {
             return (new Date($issue->scheduled_at))->setTimezone($dateTimeZone)->toDateString();
         }
         return (new Date($issue->created_at))->setTimezone($dateTimeZone)->toDateString();
     });
     // Add in days that have no issues
     foreach ($issueDays as $i) {
         $date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i);
         if (!isset($allIssues[$date->toDateString()])) {
             $allIssues[$date->toDateString()] = [];
         }
     }
     // Sort the array so it takes into account the added days
     $allIssues = $allIssues->sortBy(function ($value, $key) {
         return strtotime($key);
     }, SORT_REGULAR, true)->all();
     return View::make('index')->withDaysToShow($daysToShow)->withAllIssues($allIssues)->withCanPageForward((bool) $today->gt($startDate))->withCanPageBackward(Issue::where('created_at', '<', $startDate->format('Y-m-d'))->count() > 0)->withPreviousDate($startDate->copy()->subDays($daysToShow)->toDateString())->withNextDate($startDate->copy()->addDays($daysToShow)->toDateString());
 }
예제 #9
0
 /**
  * Displays the explore page.
  *
  * @return \Illuminate\View\View
  */
 public function indexAction()
 {
     $this->subMenu['explore']['active'] = true;
     $today = Date::now();
     $startDate = Date::now();
     // Check if we have another starting date
     if (Request::has('start_date')) {
         try {
             // If date provided is valid
             $oldDate = Date::createFromFormat('Y-m-d', Request::get('start_date'));
             // If trying to get a future date fallback to today
             if ($today->gt($oldDate)) {
                 $startDate = $oldDate;
             }
         } catch (Exception $e) {
             // Fallback to today
         }
     }
     $daysToShow = Setting::get('app_issue_days', 0) - 1;
     if ($daysToShow < 0) {
         $daysToShow = 0;
         $issueDays = [];
     } else {
         $issueDays = range(0, $daysToShow);
     }
     $dateTimeZone = Setting::get('app_timezone');
     $allIssues = Issue::whereBetween('created_at', [$startDate->copy()->subDays($daysToShow)->format('Y-m-d') . ' 00:00:00', $startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('created_at', 'desc')->get()->groupBy(function (Issue $issue) use($dateTimeZone) {
         return (new Date($issue->created_at))->setTimezone($dateTimeZone)->toDateString();
     });
     // Add in days that have no issues
     foreach ($issueDays as $i) {
         $date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i);
         if (!isset($allIssues[$date->toDateString()])) {
             $allIssues[$date->toDateString()] = [];
         }
     }
     // Sort the array so it takes into account the added days
     $allIssues = $allIssues->sortBy(function ($value, $key) {
         return strtotime($key);
     }, SORT_REGULAR, true)->all();
     return View::make('explore.index')->withPageTitle(trans('dashboard.explore'))->withProjects([])->withSubMenu($this->subMenu)->withDaysToShow($daysToShow)->withAllIssues($allIssues)->withCanPageForward((bool) $today->gt($startDate))->withCanPageBackward(Issue::where('created_at', '<', $startDate->format('Y-m-d'))->count() > 0)->withPreviousDate($startDate->copy()->subDays($daysToShow)->toDateString())->withNextDate($startDate->copy()->addDays($daysToShow)->toDateString());
 }
 /**
  * @param OnFlushEventArgs $args
  */
 public function onFlush(OnFlushEventArgs $args)
 {
     $entityManager = $args->getEntityManager();
     $unitOfWork = $entityManager->getUnitOfWork();
     foreach ($unitOfWork->getScheduledEntityDeletions() as $entity) {
         if (!$this->isSoftDeletable($entity)) {
             continue;
         }
         $metadata = $entityManager->getClassMetadata(get_class($entity));
         $oldValue = $metadata->getFieldValue($entity, $this->propertyName);
         if ($oldValue !== null) {
             continue;
         }
         $newValue = Date::now();
         $metadata->setFieldValue($entity, $this->propertyName, $newValue);
         $entityManager->persist($entity);
         $unitOfWork->propertyChanged($entity, $this->propertyName, $oldValue, $newValue);
         $unitOfWork->scheduleExtraUpdate($entity, [$this->propertyName => [$oldValue, $newValue]]);
     }
 }
 /**
  * @return string
  */
 public function createOrUpdateFixtures()
 {
     $dateOfBeginningMonth = Date::now()->startOfMonth()->format('d.m.Y');
     $dateOfEndingMonth = Date::now()->endOfMonth()->format('d.m.Y');
     $request = 'matches?comp_id=' . $this->premierleague . ',' . $this->ucl . ',' . $this->europa . ',' . $this->facup . '&team_id=' . $this->liverpoolfc . '&from_date=' . $dateOfBeginningMonth . '&to_date=' . $dateOfEndingMonth . '&';
     $getMatches = $this->connector($request);
     foreach ($getMatches as $match) {
         $match['match_id'] = $match['id'];
         unset($match['id']);
         $mergeDateTime = Date::createFromFormat('d.m.Y H:i', $match['formatted_date'] . ' ' . $match['time'], 'UTC')->tz('Asia/Bangkok')->toDateTimeString();
         $date = Date::createFromFormat('Y-m-d H:i:s', $mergeDateTime)->format('Y-m-d');
         $match['formatted_date'] = $date;
         $time = Date::createFromFormat('Y-m-d H:i:s', $mergeDateTime)->format('H:i');
         $matchStatus = $match['status'];
         $match['status'] === $match['time'] ? $match['status'] = $time : ($match['status'] = $matchStatus);
         $match['time'] = $time;
         if ($match['localteam_score'] === '?' and $match['visitorteam_score'] === '?' or $match['localteam_score'] === '' and $match['visitorteam_score'] === '') {
             if ($match['status'] !== 'FT' or $match['status'] !== 'AET') {
                 $match['localteam_score'] = '-';
                 $match['visitorteam_score'] = '-';
             }
         }
         $this->footballMatches->updateOrCreate(['match_id' => $match['match_id']], $match);
         if (!empty($match['events'])) {
             $events = $match['events'];
             $matchId = $match['match_id'];
             foreach ($events as $event) {
                 $event['match_id'] = $matchId;
                 $event['event_id'] = $event['id'];
                 unset($event['id']);
                 $this->footballMatchEvents->updateOrCreate(['event_id' => $event['event_id']], $event) ? Log::info('Event of ' . $matchId . ' update completed!.') : Log::error('Event update process of ' . $matchId . ' failed');
             }
         }
         Log::info('All data of ' . $match['match_id'] . ' update completed!');
     }
     return Event::fire(new FootballMatchUpdated($this->footballMatches));
 }
예제 #12
0
 public function testAgoTranslated()
 {
     Date::setLocale('nl');
     $date = Date::parse('-5 years');
     $this->assertSame("5 jaar geleden", $date->ago());
     $date = Date::parse('-5 months');
     $this->assertSame("5 maanden geleden", $date->ago());
     $date = Date::parse('-32 days');
     $this->assertSame("1 maand geleden", $date->ago());
     $date = Date::parse('-4 days');
     $this->assertSame("4 dagen geleden", $date->ago());
     $date = Date::parse('-1 day');
     $this->assertSame("1 dag geleden", $date->ago());
     $date = Date::parse('-3 hours');
     $this->assertSame("3 uur geleden", $date->ago());
     $date = Date::parse('-1 hour');
     $this->assertSame("1 uur geleden", $date->ago());
     $date = Date::parse('-2 minutes');
     $this->assertSame("2 minuten geleden", $date->ago());
     $date = Date::parse('-1 minute');
     $this->assertSame("1 minuut geleden", $date->ago());
     $date = Date::parse('-50 second');
     $this->assertSame("50 seconden geleden", $date->ago());
     $date = Date::parse('-1 second');
     $this->assertSame("1 seconde geleden", $date->ago());
     $date = Date::parse('+5 days');
     $this->assertSame("5 dagen vanaf nu", $date->ago());
     $date = Date::parse('+5 days');
     $this->assertSame("5 dagen na", $date->ago(Date::now()));
     $date = Date::parse('-5 days');
     $this->assertSame("5 dagen voor", $date->ago(Date::now()));
     Date::setLocale('ru');
     $date = Date::parse('-21 hours');
     $this->assertSame("21 час до", $date->ago(Date::now()));
     $date = Date::parse('-11 hours');
     $this->assertSame("11 часов до", $date->ago(Date::now()));
 }
 public function scopeActive($query)
 {
     return $query->where('ends_at', '>=', Date::now());
 }
예제 #14
0
파일: index.php 프로젝트: bart/salary
<?php

require 'vendor/autoload.php';
use Acme\CsvExporter;
use Acme\DataGenerator;
use Jenssegers\Date\Date;
$start = Date::now()->firstOfMonth();
$csvExporter = new CsvExporter('salaryDates.csv');
$dataGenerator = new DataGenerator($start);
$data = $dataGenerator->generate();
$csvExporter->export($data);
예제 #15
0
 private function makeTimelineData($timeline)
 {
     Carbon::setLocale('pt_BR');
     foreach ($timeline as $key => $item) {
         $now = Carbon::now();
         $start = Carbon::createFromFormat('Y-m-d H:i:s', $item['start']);
         $end = Carbon::createFromFormat('Y-m-d H:i:s', $item['end']);
         $startW3c = Carbon::createFromFormat('Y-m-d H:i:s', $item['start'])->addSeconds(env('TIME_OFFSET_ADD'));
         $endW3c = Carbon::createFromFormat('Y-m-d H:i:s', $item['end'])->addSeconds(env('TIME_OFFSET_ADD'));
         $timeline[$key]['startW3c'] = $startW3c->toW3cString();
         $timeline[$key]['endW3c'] = $endW3c->toW3cString();
         $end->addSeconds(2);
         $diff = $start->diffInDays($end);
         if ($diff <= 1) {
             $period = $start->format('d \\d\\e F');
         } else {
             if ($start->month == $end->month) {
                 $period = $start->format('d') . ' a ' . $end->format('d \\d\\e F');
             } else {
                 $period = $start->format('d \\d\\e F') . ' a ' . $end->format('d \\d\\e F');
             }
         }
         $timeline[$key]['period'] = $period;
         $timeline[$key]['past'] = $start->diffInSeconds($now) > 0;
     }
     return ['lines' => $timeline, 'now' => $now->toW3cString()];
 }
예제 #16
0
 /**
  * Get topics from IPBoard that most comments in past a week
  * @return array|static[]
  */
 public function getHotTopics()
 {
     $subWeek = Date::now()->subWeek()->timestamp;
     $hotTopics = Topic::whereForumId(2)->where('approved', 1)->where('start_date', '>', $subWeek)->select('title', 'posts', 'title_seo', 'starter_name', 'start_date')->orderBy('posts', 'desc')->take(5)->get();
     return $hotTopics;
 }
예제 #17
0
 public function createproyecto()
 {
     $nuevoproyecto["name"] = ucfirst($this->datosempresa["name"]) . " " . ucfirst(Date::now()->format('F Y'));
     $nuevoproyecto["user_id"] = $this->datosempresa["user_id"];
     Proyecto::create($nuevoproyecto);
     return redirect('proyectos');
 }
예제 #18
0
 /**
  * @ORM\PreUpdate
  */
 public function updateAt()
 {
     $this->updatedAt = Date::now();
 }
예제 #19
0
function humanize($date)
{
    return Date::now()->timespan($date);
}
예제 #20
0
 /**
  * @ORM\PreUpdate
  */
 public function preUpdate()
 {
     $this->updatedAt = Date::now();
 }