Exemple #1
0
 public function isDoctorVisited($doctorId, $date)
 {
     $visited = AMReport::where('am_id', \Auth::user()->id)->where('doctor_id', $doctorId)->where('date', '>=', $date)->count();
     if ($visited > 0) {
         return true;
     }
 }
Exemple #2
0
 public function doAMSearch(AMSalesSearchRequest $request)
 {
     $productSales = [];
     $from = $request->date_from;
     $to = $request->date_to;
     $product = $request->product;
     $doctor = $request->doctor;
     $AM = $request->am;
     $allSearchedReport = AMReport::select('id')->where('date', '>=', $from)->where('date', '<=', $to);
     if (!empty($AM)) {
         $allSearchedReport = $allSearchedReport->where('am_id', $AM);
     }
     if (!empty($doctor)) {
         $allSearchedReport = $allSearchedReport->where('doctor_id', $doctor);
     }
     $searchResult = AMReportSoldProduct::whereIn('report_id', $allSearchedReport->get());
     if (!empty($product)) {
         $searchResult->where('product_id', $product);
     }
     foreach ($searchResult->get() as $singleResult) {
         if (isset($productSales[$singleResult->product->name])) {
             $productSales[$singleResult->product->name] += $singleResult->quantity;
         } else {
             $productSales[$singleResult->product->name] = $singleResult->quantity;
         }
     }
     $dataView = ['productSales' => $productSales];
     \Session::flash('date_from', $from);
     \Session::flash('date_to', $to);
     \Session::flash('productSales', $productSales);
     return view('admin.search.sales.result', $dataView);
 }
Exemple #3
0
 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);
 }
Exemple #4
0
 public function singleReport($level, $id, $type)
 {
     if ($level == 'sm') {
         $singleReport = SMReport::findOrFail($id);
     } elseif ($level == 'am') {
         $singleReport = AMReport::findOrFail($id);
     } elseif ($level == 'mr') {
         $singleReport = Report::findOrFail($id);
     }
     \Excel::create('report-' . $level . '-' . $singleReport->emp->name . '-' . $singleReport->date, function ($excel) use($singleReport) {
         $excel->sheet('report', function ($sheet) use($singleReport) {
             $sheet->setAllBorders('thin');
             $sheet->loadView('admin.export.single_report')->with('singleReport', $singleReport);
         });
     })->export($type);
 }
Exemple #5
0
 public function singleAM($id)
 {
     $singleReport = AMReport::findOrFail($id);
     $singleReport['promotedProducts'] = AMReportPromotedProduct::select('product_id')->where('report_id', $singleReport->id)->get();
     $singleReport['sampleProducts'] = AMReportSampleProduct::select('product_id')->where('report_id', $singleReport->id)->get();
     $singleReport['gifts'] = AMReportGift::select('gift_id')->where('report_id', $singleReport->id)->get();
     $singleReport['soldProducts'] = AMReportSoldProduct::select('product_id', 'quantity')->where('report_id', $singleReport->id)->get();
     $dataView = ['singleReport' => $singleReport];
     return view('sm.report.single', $dataView);
 }