public function isDoctorVisited($doctorId, $date) { $visited = Report::where('mr_id', \Auth::user()->id)->where('doctor_id', $doctorId)->where('date', '>=', $date)->count(); if ($visited > 0) { return true; } }
public static function totalMonthlyCoverage() { $visitClass = Customer::select('class')->where('mr_id', \Auth::user()->id)->get()->toArray(); $totalVisitsCount = VisitClass::whereIn('name', $visitClass)->sum('visits_count'); $actualVisitsCount = Report::where('mr_id', \Auth::user()->id)->where('month', date('M') . '-' . date('Y'))->count(); return number_format($actualVisitsCount / $totalVisitsCount * 100, 2); }
public function index() { $me = Auth::user()->id; $myReports = Report::where('id_reported', $me)->get(); foreach ($myReports as $key => $value) { $myReports[$key]['reported'] = Patrimony::find($myReports[$key]['id_reported']); $myReports[$key]['reporter'] = Patrimony::find($myReports[$key]['id_reporter']); if ($myReports[$key]['done'] === 1) { $myReports[$key]['done'] = 'done'; } else { $myReports[$key]['done'] = 'pending'; } } $iReported = Report::where('id_reporter', $me)->get(); foreach ($iReported as $key => $value) { $iReported[$key]['reported'] = Patrimony::find($iReported[$key]['id_reported']); $iReported[$key]['reporter'] = Patrimony::find($iReported[$key]['id_reporter']); if ($iReported[$key]['done'] === 1) { $iReported[$key]['done'] = 'done'; } else { $iReported[$key]['done'] = 'pending'; } } return $myReports; // return ['myReports' => $myReports, 'iReported' => $iReported]; // return view('reports/index', ['myReports' => $myReports, 'iReported' => $iReported]); }
public function single($mr, $currentMonth) { $actualVisits = []; $MonthlyCustomerProducts = []; $MRLine = []; $doctors = Customer::where('mr_id', $mr)->get(); foreach ($doctors as $singleDoctor) { $actualVisits[$singleDoctor->id] = Report::where('mr_id', $mr)->where('month', $currentMonth)->where('doctor_id', $singleDoctor->id)->count(); $MonthlyCustomerProducts[$singleDoctor->id] = Customer::monthlyProductsBought([$singleDoctor->id])->toArray(); } $products = Product::where('line_id', Employee::findOrFail($mr)->line_id)->get(); $coverageStats = Employee::coverageStats($mr, $currentMonth); $allManagers = Employee::yourManagers($mr); $totalProducts = Employee::monthlyDirectSales($mr, $currentMonth); $totalSoldProductsSales = $totalProducts['totalSoldProductsSales']; $totalSoldProductsSalesPrice = $totalProducts['totalSoldProductsSalesPrice']; $currentMonth = \Carbon\Carbon::parse($currentMonth); $lines = MrLines::select('line_id', 'from', 'to')->where('mr_id', $mr)->get(); foreach ($lines as $line) { $lineFrom = \Carbon\Carbon::parse($line->from); $lineTo = \Carbon\Carbon::parse($line->to); if (!$currentMonth->lte($lineTo) && $currentMonth->gte($lineFrom)) { $MRLine = MrLines::where('mr_id', $mr)->where('line_id', $line->line_id)->get(); } } $dataView = ['doctors' => $doctors, 'MonthlyCustomerProducts' => $MonthlyCustomerProducts, 'actualVisits' => $actualVisits, 'products' => $products, 'totalVisitsCount' => $coverageStats['totalVisitsCount'], 'actualVisitsCount' => $coverageStats['actualVisitsCount'], 'totalMonthlyCoverage' => $coverageStats['totalMonthlyCoverage'], 'allManagers' => $allManagers, 'totalSoldProductsSales' => $totalSoldProductsSales, 'totalSoldProductsSalesPrice' => $totalSoldProductsSalesPrice, 'MRLines' => $MRLine]; return view('am.line.single', $dataView); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $notify_report = false; for ($i = 0; $i < count($request->all()); $i++) { if ($request->input($i . '.include')) { $this->validate($request, [$i . '.id' => 'required', $i . '.member.id' => 'required|numeric', $i . '.position_id' => 'required|numeric', $i . '.project_id' => 'required|numeric', $i . '.target_id' => 'required|numeric', $i . '.output' => 'required|numeric', $i . '.date_start' => 'required|date', $i . '.date_end' => 'required|date', $i . '.hours_worked' => 'required|numeric', $i . '.daily_work_hours' => 'required|numeric', $i . '.output_error' => 'required|numeric']); // check if a report is already created if (!$notify_report) { $admin = User::where('role', 'admin')->first(); $report = Report::where('id', $request->input($i . '.report_id'))->first(); // create a notification $notification = new Notification(); $notification->message = 'updated a '; $notification->sender_user_id = $request->user()->id; $notification->receiver_user_id = $admin->id; $notification->subscriber = 'admin'; $notification->state = 'main.weekly-report'; $notification->event_id = $report->id; $notification->event_id_type = 'report_id'; $notification->seen = false; $notification->save(); $notify = DB::table('reports')->join('users', 'users.id', '=', 'reports.user_id')->join('projects', 'projects.id', '=', 'reports.project_id')->join('notifications', 'notifications.event_id', '=', 'reports.id')->select('reports.*', 'users.*', DB::raw('LEFT(users.first_name, 1) as first_letter'), 'projects.*', 'notifications.*')->where('notifications.id', $notification->id)->first(); // foreach ($query as $key => $value) { // $notify = $value; // } event(new ReportSubmittedBroadCast($notify)); $activity_type = ActivityType::where('action', 'update')->first(); $activity = new Activity(); $activity->report_id = $report->id; $activity->user_id = $request->user()->id; $activity->activity_type_id = $activity_type->id; $activity->save(); // report $create_report = true; } $old_performance = Performance::where('id', $request->input($i . '.id'))->first(); // record history of the performance $performance_history = new PerformanceHistory(); $performance_history->activity_id = $activity->id; $performance_history->performance_id = $old_performance->id; $performance_history->report_id = $old_performance->report_id; $performance_history->member_id = $old_performance->member_id; $performance_history->position_id = $old_performance->position_id; $performance_history->department_id = $old_performance->department_id; $performance_history->project_id = $old_performance->project_id; $performance_history->target_id = $old_performance->target_id; $performance_history->date_start = $old_performance->date_start; $performance_history->date_end = $old_performance->date_end; $performance_history->daily_work_hours = $old_performance->daily_work_hours; $performance_history->output = $old_performance->output; $performance_history->hours_worked = $old_performance->hours_worked; $performance_history->output_error = $old_performance->output_error; $performance_history->average_output = $old_performance->average_output; $performance_history->productivity = $old_performance->productivity; $performance_history->quality = $old_performance->quality; $performance_history->quadrant = $old_performance->quadrant; $performance_history->save(); } } }
public function project($report_id) { $report = Report::where('id', $report_id)->first(); $project = DB::table('projects')->where('id', $report->project_id)->first(); $project->positions = DB::table('positions')->where('project_id', $report->project_id)->get(); $project->beginner_productivity = array(); $project->moderately_experienced_productivity = array(); $project->experienced_productivity = array(); $project->beginner_quality = array(); $project->moderately_experienced_quality = array(); $project->experienced_quality = array(); foreach ($project->positions as $key => $value) { /* Productivity */ $beginner_productivity_query = Target::where('position_id', $value->id)->where('type', 'Productivity')->where('experience', 'Beginner')->where('created_at', '<=', $report->date_end)->orderBy('created_at', 'desc')->first(); if ($beginner_productivity_query) { $beginner_productivity = $beginner_productivity_query->value; } else { $beginner_productivity = Target::where('position_id', $value->id)->where('type', 'Productivity')->where('experience', 'Beginner')->orderBy('created_at', 'desc')->first()->value; } $moderately_experienced_productivity_query = Target::where('position_id', $value->id)->where('type', 'Productivity')->where('experience', 'Moderately Experienced')->where('created_at', '<=', $report->date_end)->orderBy('created_at', 'desc')->first(); if ($moderately_experienced_productivity_query) { $moderately_experienced_productivity = $moderately_experienced_productivity_query->value; } else { $moderately_experienced_productivity = Target::where('position_id', $value->id)->where('type', 'Productivity')->where('experience', 'Moderately Experienced')->orderBy('created_at', 'desc')->first()->value; } $experienced_productivity_query = Target::where('position_id', $value->id)->where('type', 'Productivity')->where('experience', 'Experienced')->where('created_at', '<=', $report->date_end)->orderBy('created_at', 'desc')->first(); if ($experienced_productivity_query) { $experienced_productivity = $experienced_productivity_query->value; } else { $experienced_productivity = Target::where('position_id', $value->id)->where('type', 'Productivity')->where('experience', 'Experienced')->orderBy('created_at', 'desc')->first()->value; } /* Quality */ $beginner_quality_query = Target::where('position_id', $value->id)->where('type', 'Quality')->where('experience', 'Beginner')->where('created_at', '<=', $report->date_end)->orderBy('created_at', 'desc')->first(); if ($beginner_quality_query) { $beginner_quality = $beginner_quality_query->value; } else { $beginner_quality = Target::where('position_id', $value->id)->where('type', 'Quality')->where('experience', 'Beginner')->orderBy('created_at', 'desc')->first()->value; } $moderately_experienced_quality_query = Target::where('position_id', $value->id)->where('type', 'Quality')->where('experience', 'Moderately Experienced')->where('created_at', '<=', $report->date_end)->orderBy('created_at', 'desc')->first(); if ($moderately_experienced_quality_query) { $moderately_experienced_quality = $moderately_experienced_quality_query->value; } else { $moderately_experienced_quality = Target::where('position_id', $value->id)->where('type', 'Quality')->where('experience', 'Moderately Experienced')->orderBy('created_at', 'desc')->first()->value; } $experienced_quality_query = Target::where('position_id', $value->id)->where('type', 'Quality')->where('experience', 'Experienced')->where('created_at', '<=', $report->date_end)->orderBy('created_at', 'desc')->first(); if ($experienced_quality_query) { $experienced_quality = $experienced_quality_query->value; } else { $experienced_quality = Target::where('position_id', $value->id)->where('type', 'Quality')->where('experience', 'Experienced')->orderBy('created_at', 'desc')->first()->value; } array_push($project->beginner_productivity, $beginner_productivity); array_push($project->moderately_experienced_productivity, $moderately_experienced_productivity); array_push($project->experienced_productivity, $experienced_productivity); array_push($project->beginner_quality, $beginner_quality); array_push($project->moderately_experienced_quality, $moderately_experienced_quality); array_push($project->experienced_quality, $experienced_quality); } return response()->json($project); }
public function run() { DB::table('reporttrackers')->delete(); $users = User::where('app', 'staff')->where('role_id', '!=', 20)->get(); $reports = Report::where('is_required', 1)->get(); for ($u = 3; $u < count($users); $u++) { for ($r = 1; $r < count($reports); $r++) { Reporttracker::create(['report_id' => $r, 'user_id' => $u, 'cnt_warned' => rand(0, 15), 'cnt_alerted' => rand(0, 15), 'made_required' => Carbon::now()->subDay(rand(11, 140)), 'last_acknowledged' => Carbon::now()->subDay(rand(0, 10))]); } } }
public function index($month = '2015-09-01') { // if (isset($month)) { $reports = Report::with('employee', 'employee.company', 'employee.department', 'employee.level', 'flag')->where('months', '=', $month)->get(); } else { $month = Carbon::now()->firstOfMonth(); } $reports = Report::with('employee', 'employee.company', 'employee.department', 'employee.level', 'flag')->where('months', '=', $month)->get(); $reportStatus['counts'] = Report::where('months', '=', $month)->where('flag_id', 1)->count(); $reportStatus['total'] = Report::where('months', '=', $month)->count(); return view('report.index')->with('reports', $reports)->with('reportStatus', $reportStatus); }
public function ucenik($id) { // $student = Student::find($id); $ulogovani_user_id = \Auth::user()->id; $odabrani_razred_id = $student->category->id; $odabrani_ucenik_id = $student->id; $count = Report::where('user_id', '=', $ulogovani_user_id)->where('category_id', '=', $odabrani_razred_id)->where('student_id', '=', $odabrani_ucenik_id)->count(); if ($count < 1) { return view('reports.create')->with('ulogovani_user_id', $ulogovani_user_id)->with('odabrani_razred_id', $odabrani_razred_id)->with('odabrani_ucenik_id', $odabrani_ucenik_id); //return $count; } else { $report = Report::where('user_id', '=', $ulogovani_user_id)->where('category_id', '=', $odabrani_razred_id)->where('student_id', '=', $odabrani_ucenik_id)->first(); return view('reports.index')->with('report', $report); } }
public function doSearch(CoverageSearchRequest $request) { $searchResult = null; $from = $request->date_from; $to = $request->date_to; $MR = $request->mr; $class = $request->class; $specialty = $request->specialty; $allReportsInRange = Report::where('date', '>=', $from)->where('date', '<=', $to)->where('report.mr_id', $MR); if (!empty($class)) { $allReportsInRange->join('customer', 'report.doctor_id', '=', 'customer.id')->where('class', $class); } if (!empty($specialty)) { $allReportsInRange->where('specialty', $specialty); } $searchResult = $allReportsInRange->get(); $dataView = ['searchResult' => $searchResult]; return view('sm.search.coverage.result', $dataView); }
public function single($currentMonth) { $actualVisits = []; $MonthlyCustomerProducts = []; $doctors = Customer::where('mr_id', \Auth::user()->id)->get(); foreach ($doctors as $singleDoctor) { $actualVisits[$singleDoctor->id] = Report::where('mr_id', \Auth::user()->id)->where('month', $currentMonth)->where('doctor_id', $singleDoctor->id)->count(); $MonthlyCustomerProducts[$singleDoctor->id] = Customer::monthlyProductsBought([$singleDoctor->id])->toArray(); } $products = Product::where('line_id', Employee::findOrFail(\Auth::user()->id)->line_id)->get(); $coverageStats = Employee::coverageStats(\Auth::user()->id, $currentMonth); $allManagers = Employee::yourManagers(\Auth::user()->id); $totalProducts = Employee::monthlyDirectSales(\Auth::user()->id, $currentMonth); $totalSoldProductsSales = $totalProducts['totalSoldProductsSales']; $totalSoldProductsSalesPrice = $totalProducts['totalSoldProductsSalesPrice']; $dataView = ['doctors' => $doctors, 'MonthlyCustomerProducts' => $MonthlyCustomerProducts, 'actualVisits' => $actualVisits, 'products' => $products, 'totalVisitsCount' => $coverageStats['totalVisitsCount'], 'actualVisitsCount' => $coverageStats['actualVisitsCount'], 'totalMonthlyCoverage' => $coverageStats['totalMonthlyCoverage'], 'allManagers' => $allManagers, 'totalSoldProductsSales' => $totalSoldProductsSales, 'totalSoldProductsSalesPrice' => $totalSoldProductsSalesPrice]; \Session::set('customers', $doctors); return view('mr.line.single', $dataView); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy() { Report::where('user_id', $this->user->id)->delete(); return redirect()->back(); }
public function performanceEdit(Request $request, $reportID) { $create_notification = false; for ($i = 0; $i < count($request->all()); $i++) { if ($request->input($i . '.include')) { $this->validate($request, [$i . '.id' => 'required|numeric', $i . '.position_id' => 'required|numeric', $i . '.department_id' => 'required|numeric', $i . '.project_id' => 'required|numeric', $i . '.output' => 'required|numeric', $i . '.target_id' => 'required', $i . '.date_start' => 'required|date', $i . '.date_end' => 'required|date', $i . '.hours_worked' => 'required|numeric', $i . '.daily_work_hours' => 'required|numeric', $i . '.output_error' => 'required|numeric', $i . '.message' => 'required']); if (!$create_notification) { $admin = User::where('email', '*****@*****.**')->first(); $approval = new Approval(); $approval->action = 'update'; $approval->report_id = $reportID; $approval->status = 'pending'; $approval->save(); $report = Report::where('id', $request->input($i . '.report_id'))->first(); $report->user_id = $request->user()->id; $report->save(); // create a notification $notification = new Notification(); $notification->message = 'updates '; $notification->receiver_user_id = $admin->id; $notification->sender_user_id = $request->user()->id; $notification->subscriber = 'admin'; $notification->state = 'main.approvals'; $notification->event_id = $report->id; $notification->event_id_type = 'report_id'; $notification->seen = false; $notification->save(); $notify = DB::table('reports')->join('users', 'users.id', '=', 'reports.user_id')->join('projects', 'projects.id', '=', 'reports.project_id')->join('notifications', 'notifications.event_id', '=', 'reports.id')->select('reports.*', 'users.*', DB::raw('LEFT(users.first_name, 1) as first_letter'), 'projects.*', 'notifications.*')->where('notifications.id', $notification->id)->first(); event(new ReportSubmittedBroadCast($notify)); // report $create_notification = true; } $target = Target::withTrashed()->where('id', $request->input($i . '.target_id'))->first(); $performance_approval = new PerformanceApproval(); $performance_approval->approval_id = $approval->id; $performance_approval->report_id = $reportID; $performance_approval->message = $request->input($i . '.message'); // $performance_approval->result_id = $request->input($i.'.result_id'); $performance_approval->performance_id = $request->input($i . '.id'); $performance_approval->member_id = $request->input($i . '.member_id'); $performance_approval->position_id = $request->input($i . '.position_id'); $performance_approval->department_id = $request->input($i . '.department_id'); $performance_approval->project_id = $request->input($i . '.project_id'); $performance_approval->target_id = $target->id; $performance_approval->date_start = Carbon::parse($request->input($i . '.date_start')); $performance_approval->date_end = Carbon::parse($request->input($i . '.date_end')); $performance_approval->daily_work_hours = $request->input($i . '.daily_work_hours'); $performance_approval->output = $request->input($i . '.output'); $performance_approval->hours_worked = $request->input($i . '.hours_worked'); $performance_approval->output_error = $request->input($i . '.output_error'); // Round((Output / Hours Worked) * Daily Work Hours) // store the rounded value $performance_approval->average_output = round($request->input($i . '.output') / $request->input($i . '.hours_worked') * $request->input($i . '.daily_work_hours'), 2); // average output / target output * 100 to convert to percentage $performance_approval->productivity = round($performance_approval->average_output / $target->productivity * 100, 1); // 1 - output w/error / output * 100 to convert to percentage $performance_approval->quality = round((1 - $performance_approval->output_error / $performance_approval->output) * 100, 1); // Quadrant if ($performance_approval->productivity < 100 && $performance_approval->quality >= $target->quality) { $performance_approval->quadrant = 'Quadrant 1'; } else { if ($performance_approval->productivity >= 100 && $performance_approval->quality >= $target->quality) { $performance_approval->quadrant = 'Quadrant 2'; } else { if ($performance_approval->productivity >= 100 && $performance_approval->quality < $target->quality) { $performance_approval->quadrant = 'Quadrant 3'; } else { if ($performance_approval->productivity < 100 && $performance_approval->quality < $target->quality) { $performance_approval->quadrant = 'Quadrant 4'; } } } } // save performance_approval request to database $performance_approval->save(); } } }
/** * Renders the post edit form. */ public function getReport(Request $request, Board $board, Post $post, $global = false) { if (!$post->exists) { abort(404); } $actions = ["report"]; $ContentFormatter = new ContentFormatter(); $reportText = ""; if ($global === "global") { if (!$post->canReportGlobally($this->user)) { abort(403); } $actions[] = "global"; $reportText = $ContentFormatter->formatReportText($this->option('globalReportText')); } else { if (!$post->canReport($this->user)) { abort(403); } $reportText = $ContentFormatter->formatReportText($board->getConfig('boardReportText')); } if (!isset($report)) { $report = Report::where('post_id', '=', $post->post_id)->where('global', $global === "global")->where('board_uri', $board->board_uri)->whereByIPOrUser($this->user)->first(); } return $this->view(static::VIEW_MOD, ['actions' => $actions, 'form' => "report", 'board' => $board, 'post' => $post, 'report' => $report ?: false, 'reportText' => $reportText, 'reportGlobal' => $global === "global"]); }
/** * Renders the post edit form. */ public function getReport(Request $request, Board $board, $post, $global = false) { // Validate the request parameters. if (!($post = $this->validatePost($board, $post)) instanceof Post) { // If the response isn't a Post, it's a redirect or error. // Return the message. return $post; } $actions = ["report"]; $ContentFormatter = new ContentFormatter(); $reportText = ""; if ($global === "global") { if (!$post->canReportGlobally($this->user)) { abort(403); } $actions[] = "global"; $reportText = $ContentFormatter->formatReportText($this->option('globalReportText')); } else { if (!$post->canReport($this->user)) { abort(403); } $reportText = $ContentFormatter->formatReportText($board->getConfig('boardReportText')); } if (!isset($report)) { $user = $this->user; $report = Report::where('post_id', '=', $post->post_id)->where('global', $global === "global")->where('board_uri', $board->board_uri)->where(function ($query) use($user) { $query->where('reporter_ip', inet_pton(Request::ip())); if (!$user->isAnonymous()) { $query->orWhere('user_id', $user->user_id); } })->first(); } return $this->view(static::VIEW_MOD, ['actions' => $actions, 'form' => "report", 'board' => $board, 'post' => $post, 'report' => $report ?: false, 'reportText' => $reportText, 'reportGlobal' => $global === "global"]); }
public static function getOpenReportCountForMachine($serverid) { return Report::where('server_id', $serverid)->where('status', 'open')->count(); }
protected function deleteReport($id, $reportId) { if ($id == null || $reportId == null) { return Response::json('', 400); } $Report = Report::where('Project_FK', '=', $id)->where('id', '=', $reportId)->first(); if (empty($Report)) { return Response::json('', 400); } $Report->delete(); return Response::json(); }
public function index() { $dataView = ['productsCount' => Product::count(), 'plansCount' => Plan::where('month', \Config::get('app.current_month'))->count(), 'reportsCount' => Report::where('month', \Config::get('app.current_month'))->count(), 'customersCount' => Customer::count(), 'employeesCount' => Employee::count()]; return view('admin.index', $dataView); }
public function reports($from, $to) { $reports = Report::where('datetime', '>=', $from)->where('datetime', '<=', $to)->where('user_id', Auth::user()->id)->with('type', 'lists', 'user')->orderBy('datetime')->get(); return $reports; }
public static function notPlanned() { return Report::where('mr_id', \Auth::user()->id)->where('month', date('M-Y'))->where('is_planned', 0)->get(); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $ot = Ot::find($id); $ot_detail = OtDetail::where('ot_id', $id)->get(); $report = Report::where('ot_id', $id)->get(); $requester = Requester::find($ot->requester_id); $ot->requester_id = $requester->name; if ($report[0]->user_id != 0) { $user = User::find($report[0]->user_id); $report[0]->user_id = $user->name; } else { $report[0]->user_id = "No ingresado"; } $report[0]->status = Report::$statuses[$report[0]->status]; if ($ot->group_id != 0) { $group = Group::find($ot->group_id); $ot->group_id = $group->name; } else { $ot->group_id = "No ingresado"; } if ($ot->car_id != 0) { $car = Car::find($ot->car_id); $ot->car_id = $car->name; } else { $ot->car_id = "No ingresado"; } if ($ot->driver_user_id != 0) { $driver = User::find($ot->driver_user_id); $ot->driver_user_id = $driver->name; } else { $ot->driver_user_id = "No ingresado"; } if ($ot_detail[0]->allowance_id != 0) { $allowance = Allowance::find($ot_detail[0]->allowance_id); $ot_detail[0]->allowance_id = $allowance->name; } else { $ot_detail[0]->allowance_id = "No ingresado"; } if ($ot->type == 1) { $ot->status = Ot::$statusesDt[$ot->status]; if ($ot_detail[0]->ingdt_user_id != 0) { $ingdt_user_id = User::find($ot_detail[0]->ingdt_user_id); $ot_detail[0]->ingdt_user_id = $ingdt_user_id->name; } else { $ot_detail[0]->ingdt_user_id = "No ingresado"; } if ($ot_detail[0]->ingdt_user_id != 0) { $ingdt_user_id = User::find($ot_detail[0]->ingdt_user_id); $ot_detail[0]->ingdt_user_id = $ingdt_user_id->name; } else { $ot_detail[0]->ingdt_user_id = "No ingresado"; } $ot_detail[0]->detail_type = Ot::$typeDt[$ot_detail[0]->detail_type]; } return json_encode(array('ot' => $ot, 'ot_detail' => $ot_detail, 'report' => $report)); }
public function byMobileNetwork($mobile_network) { return Report::where('mobile_network', $mobile_network)->get(); }
public function doSearch(ReportSearchRequest $request) { $searchResult = null; $from = date('Y-m-d', strtotime($request->date_from)); $to = date('Y-m-d', strtotime($request->date_to)); $doctors = $request->doctors; $promoted_product = $request->promoted_product; $sample_product = $request->sample_product; $sold_product = $request->sold_product; $gift = $request->gift; $follow_up = $request->follow_up; $feedback = $request->feedback; $allReportsInRange = Report::where('date', '>=', $from)->where('date', '<=', $to)->where('mr_id', \Auth::user()->id); if (!empty($doctors)) { $allReportsInRange->whereIn('doctor_id', $doctors); } if (!empty($promoted_product)) { $allReportsInRange->join('report_promoted_product', 'report_promoted_product.report_id', '=', 'report.id')->where('report_promoted_product.product_id', $promoted_product); } if (!empty($sample_product)) { $allReportsInRange->join('report_sample_product', 'report_sample_product.report_id', '=', 'report.id')->where('report_sample_product.product_id', $sample_product); } if (!empty($sold_product)) { $allReportsInRange->join('report_sold_product', 'report_sold_product.report_id', '=', 'report.id')->where('report_sold_product.product_id', $sold_product); } if (!empty($gift)) { $allReportsInRange->join('report_gift', 'report_gift.report_id', '=', 'report.id')->where('report_gift.gift_id', $gift); } if ($follow_up == 1) { $allReportsInRange->whereNotNull('report.follow_up'); } else { $allReportsInRange->whereNull('report.follow_up'); } if ($feedback == 1) { $allReportsInRange->where('report.feedback', '<>', ''); } else { $allReportsInRange->whereNull('report.feedback'); } $searchResult = $allReportsInRange->get(); $dataView = ['searchResult' => $searchResult]; \Session::flash('date_from', $from); \Session::flash('date_to', $to); \Session::flash('searchResult', $searchResult); return view('mr.search.reports.result', $dataView); }
public static function coverageStats($mrId, $currentMonth) { $totalVisitsCount = 0; $visitsClassCount = Customer::select('class')->where('mr_id', $mrId)->get()->toArray(); foreach ($visitsClassCount as $class) { $totalVisitsCount += VisitClass::where('name', $class)->first()->visits_count; } $actualVisitsCount = Report::where('mr_id', $mrId)->where('month', $currentMonth)->count(); return ['totalVisitsCount' => $totalVisitsCount, 'actualVisitsCount' => $actualVisitsCount, 'totalMonthlyCoverage' => $totalVisitsCount != 0 ? number_format($actualVisitsCount / $totalVisitsCount * 100, 2) : '0']; }
public function statisticDetail(Request $request) { $created = $request->created; $send = Report::where('created_at', $created)->get(); return view('page.statistic-detail', compact('send', 'created')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { Report::where('id', $id)->delete(); Performance::where('report_id', $id)->delete(); // Result::where('report_id', $id)->delete(); DB::table('approvals')->where('report_id')->delete(); DB::table('performance_approvals')->where('report_id')->delete(); DB::table('performance_histories')->where('report_id')->delete(); }
Route::get('add-service-request', ['as' => 'amAddServiceRequest', 'uses' => 'AM\\ReportController@createServiceRequest']); Route::post('add-service-request', ['as' => 'amDoAddServiceRequest', 'uses' => 'AM\\ReportController@doCreateServiceRequest']); Route::get('pending-services-requests', ['as' => 'amPendingServicesRequests', 'uses' => 'AM\\ReportController@listAllPendingServicesRequests']); Route::get('approve-service-request/{id}', ['as' => 'amApprovePendingServiceRequest', 'uses' => 'AM\\ReportController@approvePendingServiceRequest']); Route::get('decline-service-request/{id}', ['as' => 'amDeclinePendingServiceRequest', 'uses' => 'AM\\ReportController@declinePendingServiceRequest']); }); // Medical Rep. Section Route::group(['prefix' => 'mr', 'middleware' => 'mr'], function () { // Medical Rep. Dashboard Route::get('test-coverage/{id}', ['as' => 'specialtyCoverageStats', 'uses' => 'MR\\LineController@specialtyCoverageStats']); Route::get('test-sales/{id}/{month}', ['as' => 'monthlyDirectSales', 'uses' => 'MR\\LineController@monthlyDirectSales']); Route::get('test-target', ['uses' => 'MR\\LineController@target']); Route::get('dashboard', ['as' => 'mr', function () { $coverageStats = Employee::coverageStats(\Auth::user()->id, date('M-Y')); $totalProducts = Employee::monthlyDirectSales(\Auth::user()->id, date('M-Y')); $reports = Report::where('mr_id', \Auth::user()->id)->where('month', date('M-Y')); $monthlyReports = $reports->get(); $monthlyFollowsUp = $reports->whereNotNull('follow_up')->get(); $doctors = Customer::where('mr_id', \Auth::user()->id)->get(); $announcements = Announcement::where('level_id', 7)->where('start', '>=', date('Y-m-d'))->where('end', '<=', date('Y-m-d', strtotime('+1 week')))->get(); $dataView = ['doctors' => count($doctors), 'totalVisitsCount' => $coverageStats['totalVisitsCount'], 'actualVisitsCount' => $coverageStats['actualVisitsCount'], 'totalMonthlyCoverage' => $coverageStats['totalMonthlyCoverage'], 'totalSoldProductsSalesPrice' => $totalProducts['totalSoldProductsSalesPrice'], 'monthlyReports' => $monthlyReports, 'monthlyFollowsUp' => $monthlyFollowsUp, 'announcements' => $announcements]; return view('mr.index', $dataView); }]); //Profile Route::get('profile', ['as' => 'mrProfile', 'uses' => 'AuthController@editMRProfile']); Route::post('profile', ['as' => 'postMRProfile', 'uses' => 'AuthController@postEditMRProfile']); // Message Route::get('all-messages', ['as' => 'mrInbox', 'uses' => 'MR\\InboxController@all']); Route::get('sent-messages', ['as' => 'mrSentMessages', 'uses' => 'MR\\InboxController@sent']); Route::get('create-message', ['as' => 'mrCreateMessage', 'uses' => 'MR\\InboxController@create']); Route::post('create-message', ['as' => 'mrDoCreateMessage', 'uses' => 'MR\\InboxController@doCreate']);
public function report(Request $request) { $report = $_GET['report']; Report::where('key', $report)->update(['status' => 'citit']); }
public function report($id) { if (Report::where('user_id', Auth::user()->id)->where('post_id', $id)->first()) { return response()->json(['message' => 'You have already reported this post.'], 500); } $report = Auth::user()->reports()->create(['post_id' => $id]); return $report; }