<?php namespace App\Http\Controllers; use DB; use Illuminate\Http\Request; use App\Models\DailyLog\CaptionDailyUserProject; use App\Models\DailyLog\UserRangeActivityDaily; use App\Models\DailyLog\UserActivityDaily; use App\Models\Application; use App\Models\RegistrySession; use App\Models\Caption; use App\Models\DailyCaptionResume; use App\Models\ManualTimePending; class AgentDailyReportController extends Controller { function report(Request $request) { $data = $request->all(); $user = \Auth::user(); \Log::debug("--------------------------------------------------------------------------\n Report: ".json_encode(array_keys($data))." Usuario:".$user->name." Id:".$user->id." Data:".json_encode($data)." Headers:".json_encode(getallheaders())." ------------------------------------------------------"); $result = []; $httpCode = 200; foreach ($data as $key => $report) { $result = ""; $errorMessage = ""; switch ($key) { case "daily_user_app_usage": $result = $this->report_daily_user_app_usage($data[$key]); break; case "daily_user_activity": $result = $this->report_user_activity_daily($data[$key],$request); break; case "user_range_activity_daily": $result = $this->report_user_range_activity_daily($data[$key],$request); break; case "daily_caption_resume": $result = $this->report_daily_caption_resume($data[$key],$request); break; } if (strlen($result) > 0) { $httpCode = 207; $errorMessage = $result; $result = false; }else{ $result = true; } $result = [$key => ["status" => $result, "error_message" => $errorMessage]]; } return response($result, $httpCode); } function report_daily_user_app_usage($data) { try { $user = \Auth::user(); $user_id = $user->id; $enterprise_id = $user->enterprise_id; foreach ($data as $row) { $category_id = isset($row["category_id"]) && $row["category_id"] > 0 ? $row["category_id"] : null; $cumulative = isset($row["cumulative"]) ? $row["cumulative"] : false; // $application_name = $row["application_name"]; $process_name = $row["application"]; $project_id = $row["task_id"] && strlen($row["task_id"]) > 0 ? $row["task_id"] : null; $date = strtotime($row["datetime"]); $date = date("Y-m-d", $date); $duration = $row["duration"]; $application = Application::firstOrCreate(["name" => $process_name/*,"official_name"=>$application_name*/]); $registro = CaptionDailyUserProject::where("category_id", "=", $category_id) ->where("enterprise_id", "=", $enterprise_id) ->where("application_id", "=", $application->id) ->where("user_id", "=", $user_id) ->where("project_id", "=", $project_id) ->where("date", "=", $date)->get(); if ($registro->count()) { $registro = $registro->first(); $registro->duration = $cumulative ? \DB::raw("ADDTIME(duration,'$duration')") : $duration; $registro->save(); } else { $registro = new CaptionDailyUserProject(); $registro->category_id = $category_id; $registro->enterprise_id = $enterprise_id; $registro->application_id = $application->id; $registro->user_id = $user_id; $registro->project_id = $project_id; $registro->date = $date; $registro->duration = $duration; } $registro->save(); //$this->saveCaptionResume($captions,$application->id,$date,$user_id,$cumulative,$category_id); } } catch (\Throwable $th) { return $th->getMessage(); } return ""; }
#### Experience: I've worked with php for about 10 years and I really like it. #### Why do you want to work on this project?: I have the opportunity to learn about the latest technology and contribute to the community #### How much time can you devote to this project?: I can work on this project for about 20 hours a week. #### What is your skill level with the language you are applying for (0-5)?: I consider myself an advanced user, I can work with laravel 5.0 and I can use the latest functionalities of the language. #### What is your skill level with JavaScript (0-5)?: I consider myself an advanced user, I can work with vue and I can use the latest functionalities of the language. #### Additional comments: I'm a really hard worker and I'm willing to learn new things. I have a good sense of humor and I'm a responsable person.