コード例 #1
0
 public function unregister($booking_item_id, $user_id = null)
 {
     if (empty($user_id)) {
         $user_id = Auth::id();
     }
     if (!Auth::user()->isSuperAdmin() && Auth::id() != $user_id) {
         App::abort(403);
     }
     BookingItemUser::where('users_id', '=', $user_id)->where('booking_item_id', '=', $booking_item_id)->delete();
     $user = User::find($user_id);
     $booking_item = BookingItem::find($booking_item_id);
     Mail::send('booking::emails.unregister', array('booking_item' => $booking_item, 'user' => $user), function ($m) use($user, $booking_item) {
         $m->from('*****@*****.**', 'Sébastien Hordeaux')->bcc('*****@*****.**', 'Sébastien Hordeaux')->to($booking_item->booking->user->email, $booking_item->booking->user->fullname)->subject(sprintf('%s - Désinscription - %s', $_ENV['organisation_name'], $booking_item->booking->title));
     });
     return Response::json(array('status' => 'OK', 'user_id' => $user_id));
 }
コード例 #2
0
 public function ical($key)
 {
     switch ($key) {
         case 'public':
             $items = BookingItem::where('start_at', '>=', date('Y-m-d'))->where('booking.is_private', '=', false)->with('booking', 'ressource')->get();
             $description = '';
             break;
         default:
             $filter = true;
             if (preg_match('/^(.+)_(.+)$/', $key, $tokens)) {
                 $key = $tokens[1];
                 if ($tokens[2] != 'all') {
                     App::abort(404);
                     return false;
                 }
                 $filter = false;
             }
             $owner = User::where('booking_key', '=', $key)->first();
             if (!$owner) {
                 App::abort(404);
                 return false;
             }
             $description = $owner->fullname;
             $items = BookingItem::where('start_at', '>=', date('Y-m-d'))->join('booking', 'booking_item.booking_id', '=', 'booking.id')->join('users', 'booking.user_id', '=', 'users.id');
             if ($filter) {
                 $items = $items->where('users.booking_key', '=', $key);
             }
             $items = $items->with('booking', 'ressource')->get();
             break;
     }
     $vCalendar = new \Eluceo\iCal\Component\Calendar(Request::server('SERVER_NAME'));
     $vCalendar->setDescription($description);
     $tz = new DateTimeZone(date_default_timezone_get());
     foreach ($items as $booking_item) {
         $start = new \DateTime($booking_item->start_at);
         $start->setTimezone($tz);
         $end = new \DateTime($booking_item->start_at);
         $start->setTimezone($tz);
         $end->modify(sprintf('+%d minutes', $booking_item->duration));
         $vEvent = new \Eluceo\iCal\Component\Event();
         $vEvent->setDtStart($start)->setDtEnd($end)->setUseTimezone(true)->setSummary(sprintf('%s (%s)', $booking_item->booking->title, $booking_item->ressource->name));
         $vCalendar->addComponent($vEvent);
     }
     $response = Response::make($vCalendar->render());
     $response->header('Content-Type', 'text/calendar; charset=utf-8');
     $response->header('Content-Disposition', 'attachment; filename="cal.ics"');
     return $response;
 }
コード例 #3
0
<?php

$events = BookingItem::where('start_at', '>', date('Y-m-d H:i:s'))->join('booking', 'booking_item.booking_id', '=', 'booking.id')->where('booking.is_private', '=', false)->where('start_at', '<', date('Y-m-d', strtotime('+2 weeks')))->with('booking', 'ressource')->orderBy('start_at', 'ASC')->get();
?>
@if(count($events) > 0)
    <div class="ibox">
        <div class="ibox-title">
            <h5>Prochains rendez-vous</h5>
        </div>
        <div class="ibox-content">
            <div class="feed-activity-list">
                @foreach($events as $booking_item)
                    <div class="feed-element">
                        <div class="media-body ">
                            <small class="pull-right text-navy">{{date('d/m H:i', strtotime($booking_item->start_at))}}</small>
                            <strong>
                                <a href="{{route('booking')}}">{{ $booking_item->booking->title }}</a>
                            </strong><br/>
                            {{--<small class="text-muted">X participants</small>--}}
                            {{--<div class="actions pull-right">--}}
                            {{--<a class="btn btn-xs btn-white"><i class="fa fa-thumbs-up"></i> Participer </a>--}}
                            {{--</div>--}}
                        </div>
                    </div>
                @endforeach
            </div>
        </div>
    </div>
@endif