Ejemplo n.º 1
0
 public function liste($month = null)
 {
     //        if (Input::has('filtre_month') && Input::has('filtre_year')) {
     //            Session::put('filtre_pasttime.month', Input::get('filtre_month'));
     //            Session::put('filtre_pasttime.year', Input::get('filtre_year'));
     //        }
     if (Input::has('filtre_submitted')) {
         if (Input::has('filtre_user_id')) {
             Session::put('filtre_pasttime.user_id', Input::get('filtre_user_id'));
         }
         if (Input::has('filtre_start')) {
             $date_start_explode = explode('/', Input::get('filtre_start'));
             Session::put('filtre_pasttime.start', $date_start_explode[2] . '-' . $date_start_explode[1] . '-' . $date_start_explode[0]);
             if (!Input::has('filtre_user_id')) {
                 Session::forget('filtre_pasttime.user_id');
             }
         }
         if (Input::has('filtre_end')) {
             $date_end_explode = explode('/', Input::get('filtre_end'));
             Session::put('filtre_pasttime.end', $date_end_explode[2] . '-' . $date_end_explode[1] . '-' . $date_end_explode[0]);
         } else {
             Session::put('filtre_pasttime.end', date('Y-m-d'));
         }
         if (Input::has('filtre_toinvoice')) {
             Session::put('filtre_pasttime.filtre_toinvoice', Input::get('filtre_toinvoice'));
         } else {
             Session::put('filtre_pasttime.filtre_toinvoice', false);
         }
     }
     if (Session::has('filtre_pasttime.start')) {
         $date_filtre_start = Session::get('filtre_pasttime.start');
         $date_filtre_end = Session::get('filtre_pasttime.end');
     } else {
         $date_filtre_start = date('Y-m') . '-01';
         $date_filtre_end = date('Y-m') . '-' . date('t', date('m'));
     }
     //        if (Session::has('filtre_pasttime.month')) {
     //            $date_filtre_start = Session::get('filtre_pasttime.year').'-'.Session::get('filtre_pasttime.month').'-01';
     //            $date_filtre_end = Session::get('filtre_pasttime.year').'-'.Session::get('filtre_pasttime.month').'-'.date('t', Session::get('filtre_pasttime.month'));
     //        } else {
     //            $date_filtre_start = date('Y-m').'-01';
     //            $date_filtre_end = date('Y-m').'-'.date('t', Session::get('filtre_pasttime.month'));
     //        }
     $recapFilter = false;
     $q = PastTime::whereBetween('date_past', array($date_filtre_start, $date_filtre_end));
     $q->with('user', 'ressource');
     if (Session::get('filtre_pasttime.filtre_toinvoice')) {
         $q->where('invoice_id', 0);
         $q->where('is_free', false);
     }
     if (Auth::user()->isSuperAdmin()) {
         if (Session::has('filtre_pasttime.user_id')) {
             $recapFilter = Session::get('filtre_pasttime.user_id');
             $q->whereUserId($recapFilter);
         }
     } else {
         $recapFilter = Auth::user()->id;
         $q->whereUserId(Auth::user()->id);
     }
     $recap = PastTime::Recap($recapFilter, $date_filtre_start, $date_filtre_end);
     $pending_invoice_amount = 0;
     foreach ($recap as $recap_item) {
         $pending_invoice_amount += $recap_item->amount;
     }
     $params = array();
     $params['times'] = $q->orderBy('date_past', 'DESC')->paginate(15);
     $params['recap'] = $recap;
     $params['pending_invoice_amount'] = $pending_invoice_amount;
     $params = array_merge($params, Subscription::getActiveSubscriptionInfos());
     return View::make('pasttime.liste', $params);
 }
<?php

extract(Subscription::getActiveSubscriptionInfos());
?>
@if($active_subscription)
<div class="ibox">
    <div class="ibox-title">
        <h5>Abonnement en cours</h5>
    </div>
    <div class="ibox-content">
        <small>
            Du {{date('d/m/Y', strtotime($active_subscription->subscription_from ))}}
            au {{date('d/m/Y', strtotime('-1 day', strtotime($active_subscription->subscription_to)))}}
        </small>
        <h1 class="no-margins">
            @if($subscription_used)
                @if ($subscription_used->hours)
                    {{ $subscription_used->hours }} h
                @endif
                @if ($subscription_used->minutes)
                    {{ $subscription_used->minutes }} min
                @endif
            @else
                0 h
            @endif
            @if($active_subscription->subscription_hours_quota > 0)
                / {{$active_subscription->subscription_hours_quota}} h
            @else
                / Illimité
            @endif
        </h1>