public function create() { $employees = Employee::select('id')->where('manager_id', \Auth::user()->id)->get(); $doctors = Customer::whereIn('mr_id', $employees)->get(); $dataView = ['doctors' => $doctors]; return view('am.plan.create', $dataView); }
public function listAll() { $employees = Employee::select('id')->where('manager_id', \Auth::user()->id)->get(); $customers = Customer::whereIn('mr_id', $employees)->get(); $dataView = ['customers' => $customers]; return view('am.customer.list', $dataView); }
public function index() { $employees = Employee::select('line_id')->where('manager_id', \Auth::user()->id)->get(); $products = Product::whereIn('line_id', $employees)->get(); $employees = Employee::select('id')->where('manager_id', \Auth::user()->id)->get(); $customers = Customer::whereIn('mr_id', $employees)->get(); $employees = Employee::where('manager_id', \Auth::user()->id)->get(); $dataView = ['productsCount' => count($products), 'plansCount' => AMPlan::where('month', \Config::get('app.current_month'))->count(), 'reportsCount' => AMReport::where('month', \Config::get('app.current_month'))->count(), 'customersCount' => count($customers), 'employeesCount' => count($employees)]; return view('am.index', $dataView); }
public function index() { View::share(['sideBar' => NavigatorHelper::getSideBarBE()]); $status = Status_orders::all(['name', 'id'])->toArray(); $newProduct = Cd::whereIn('public_date', [Carbon::today(), Carbon::today()->subDay(3)])->count(); $newArtist = Artist::whereIn('created_at', [Carbon::today(), Carbon::today()->subDay(3)])->count(); $newOrder = Order::where('status', Order::PENDING)->count(); $newCustomer = Customer::whereIn('created_at', [Carbon::today(), Carbon::today()->subDay(3)])->count(); return view('backend.index')->with(['status' => $status, 'newProduct' => $newProduct, 'newArtist' => $newArtist, 'newOrder' => $newOrder, 'newCustomer' => $newCustomer]); }
public function specialtyCoverageStats($mrId) { $totalVisits = []; $actualVisits = []; $specialtyCoverage = []; $specialty = NULL; $counter = 0; $allSpecialties = Customer::select('specialty')->where('mr_id', $mrId)->get()->toArray(); $allCustomersSpecialties = Customer::whereIn('specialty', $allSpecialties)->get()->toArray(); // Get all medical rep customers specialties foreach ($allCustomersSpecialties as $singleCustomer) { $allSpecialtyClasses[$singleCustomer['specialty']] = Customer::select('class')->where('specialty', $singleCustomer['specialty'])->get()->toArray(); } // Get all customer classes based on specialty foreach ($allSpecialtyClasses as $specialty => $specialtyClasses) { // Calculate total visits based on classes and specialty foreach ($specialtyClasses as $singleSpecialtyClass) { if (isset($totalVisits[$specialty])) { $totalVisits[$specialty] += VisitClass::where('name', $singleSpecialtyClass)->first()->visits_count; } else { $totalVisits[$specialty] = VisitClass::where('name', $singleSpecialtyClass)->first()->visits_count; } } } // Get all doctors visited $doctorsVisited = Report::select('doctor_id')->where('month', date('M-Y'))->where('mr_id', $mrId)->get()->toArray(); foreach ($doctorsVisited as $singleDoctor) { // calculate actual visits $specialty = Customer::select('specialty')->findOrFail($singleDoctor)->first()->specialty; if (isset($actualVisits[$specialty])) { $actualVisits[$specialty] += 1; } else { $actualVisits[$specialty] = 1; } } foreach ($allCustomersSpecialties as $singleCustomerSpecialty) { $specialty = $singleCustomerSpecialty['specialty']; $specialtyCoverage[$specialty] = 0; if (isset($specialtyCoverage[$specialty]) && isset($actualVisits[$specialty]) && isset($totalVisits[$specialty])) { $specialtyCoverage[$specialty] = number_format($actualVisits[$specialty] / $totalVisits[$specialty] * 100, 2); } } foreach ($specialtyCoverage as $specialty => $percentage) { if (isset($specialtyCoverage[$specialty])) { $stats[$counter]['label'] = $specialty; $stats[$counter]['data'] = $percentage; } $counter++; } return $stats; }
public function deleteByIds($ids) { $result = Customer::whereIn('id', $ids)->delete(); return $result; }
public function create($doctorId = NULL) { $AMIds = Employee::select('id')->where('manager_id', 1)->get(); $employees = Employee::select('id')->whereIn('manager_id', $AMIds)->get(); $description_names = Customer::distinct()->select('description_name')->whereIn('mr_id', $employees)->get(); $doctors = Customer::whereIn('mr_id', $employees)->get(); $employeesLines = Employee::select('line_id')->where('manager_id', 4)->get(); $products = Product::where('line_id', $employeesLines)->get(); $gifts = Gift::all(); $dataView = ['description_names' => $description_names, 'doctors' => $doctors, 'products' => $products, 'gifts' => $gifts, 'doctorId' => !empty($doctorId) ? $doctorId : '']; return view('sm.report.create', $dataView); }
public function ajaxLoad(Request $request) { if ($request->get('id')) { return Customer::find($request->get('id')); } elseif ($request->get('ids')) { return Customer::whereIn('id', explode('+', $request->get('ids')))->get(); } else { return Customer::where('kode', 'like', '%' . $request->get('q') . '%')->get(); } }