예제 #1
0
 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);
 }
예제 #2
0
 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);
 }
예제 #3
0
파일: routes.php 프로젝트: m-gamal/crm
    Route::get('services-requests', ['as' => 'amServicesRequests', 'uses' => 'AM\\ReportController@listAllServicesRequests']);
    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']);