Ejemplo n.º 1
0
 public function showReport($year = NULL, $week = NULL)
 {
     $departmentId = Auth::user()->current_department;
     $users = Department::find($departmentId)->users;
     $availableReports = Report::select('year', 'week')->where('department_id', '=', $departmentId)->orderBy('year', 'desc')->orderBy('week', 'desc')->distinct()->get();
     if (!$year && !$week) {
         $week = date('W');
         $year = date('Y');
         $week_start = date('Y-m-d', strtotime($year . 'W' . $week));
         $week_end = date('Y-m-d', strtotime($week_start . '+6 days'));
         foreach ($users as &$user) {
             $user->hoursWorked = $this->getHours($departmentId, $user->id, $week, $year);
         }
         $code = NULL;
     } else {
         //if ($week < 10) $week = '0'.$week;
         $week_start = date('Y-m-d', strtotime($year . 'W' . $week));
         $week_end = date('Y-m-d', strtotime($week_start . '+6 days'));
         foreach ($users as &$user) {
             $user->hoursWorked = $this->getHoursFromReports($departmentId, $user->id, $week, $year);
         }
         $code = $year . '-' . $week;
     }
     $this->layout->content = View::make('dashboard.report')->with('title', 'Report')->with('users', $users)->with('weekStart', $week_start)->with('weekEnd', $week_end)->with('available_reports', $availableReports)->with('code', $code);
 }
Ejemplo n.º 2
0
 public function reports()
 {
     Auth::basic('username');
     if (!Auth::check()) {
         // do auth
         Auth::basic('username');
         if (!Auth::check()) {
             return Response::make(View::make('unauth', array()), 401)->header('WWW-Authenticate', 'Basic');
         }
     }
     Report::clearCache();
     $reports = Report::select()->with('pathRecord', 'user')->orderBy('created_at', 'desc')->paginate(30);
     return View::make('reports', array('reports' => $reports, 'pageTitle' => 'Reports'));
 }
Ejemplo n.º 3
0
 /**
  * Report nasty behaviour from the site
  * @return json Success
  */
 private function report()
 {
     Base::requireLogged();
     $ret = array('status' => 0);
     $attacker = $_GET['id'];
     $type = $_GET['type'];
     $properType = in_array($type, array('user', 'playlist', 'track'), 1) && ctype_lower($type);
     if (!Validate::id($attacker) || !$properType) {
         return $ret;
     }
     $attacker = (int) $attacker;
     $victim = LOGGED;
     $report = Report::select('id')->where('attacker', $attacker)->where('victim', $victim)->where('type', $type)->findOne();
     if (!$report) {
         $report = Report::create();
         $report->attacker = $attacker;
         $report->victim = $victim;
         $report->type = $type;
         $report->save();
     }
     $ret['status'] = 1;
     return $ret;
 }
Ejemplo n.º 4
0
 public function reports()
 {
     Report::clearCache();
     $reports = Report::select()->with('pathRecord', 'user')->orderBy('created_at', 'desc')->paginate(30);
     return View::make('reports', array('reports' => $reports, 'pageTitle' => 'Reports'));
 }