Exemplo n.º 1
0
 public function index(Info $i, $column = 'id', $type = null)
 {
     $column = $i->getColumn($column);
     $type = $i->getType($type);
     $q = $this->request->input('q');
     $adv = $this->request->input('adv');
     if ($q) {
         $infos = Info::where('claimant', 'like', '%' . $q . '%')->orderBy($column, $type)->get();
     } else {
         if ($adv) {
             $infos = $i->getAdvancedSearchModel($this->request);
         } else {
             $infos = Info::orderBy($column, $type)->get();
         }
     }
     $total = count($infos);
     $chart_inc = array_fill_keys(array('dm', 'policy', 'documents'), 0);
     foreach ($infos as $info) {
         if ($info->dm == '') {
             $chart_inc['dm'] += 1;
         }
         if ($info->policy == '') {
             $chart_inc['policy'] += 1;
         }
         if ($info->documents == 'incomplete') {
             $chart_inc['documents'] += 1;
         }
     }
     $chart_complete = array_fill_keys(array('documents'), 0);
     foreach ($infos as $info) {
         if ($info->documents == 'complete') {
             $chart_complete['documents'] += 1;
         }
     }
     $chart_complete['dm'] = $total - $chart_inc['dm'];
     $chart_complete['policy'] = $total - $chart_inc['policy'];
     $stages = array_fill_keys(array('stage_1', 'stage_2', 'stage_3', 'stage_4'), 0);
     foreach ($infos as $info) {
         if ($info->stage == 1) {
             $stages['stage_1'] += 1;
         }
         if ($info->stage == 2) {
             $stages['stage_2'] += 1;
         }
         if ($info->stage == 3) {
             $stages['stage_3'] += 1;
         }
         if ($info->stage == 4) {
             $stages['stage_4'] += 1;
         }
     }
     $stats = array_fill_keys(array('denied', 'approved', 'closed', 'pending'), 0);
     foreach ($infos as $info) {
         if ($info->claim_status == 'denied') {
             $stats['denied'] += 1;
         }
         if ($info->claim_status == 'approved') {
             $stats['approved'] += 1;
         }
         if ($info->claim_status == 'closed') {
             $stats['closed'] += 1;
         }
         if ($info->claim_status == 'pending') {
             $stats['pending'] += 1;
         }
     }
     $months = array_fill_keys(array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'), 0);
     foreach ($infos as $m) {
         if ($m->encoded->month == '1') {
             $months['jan'] += 1;
         }
         if ($m->encoded->month == '2') {
             $months['feb'] += 1;
         }
         if ($m->encoded->month == '3') {
             $months['mar'] += 1;
         }
         if ($m->encoded->month == '4') {
             $months['apr'] += 1;
         }
         if ($m->encoded->month == '5') {
             $months['may'] += 1;
         }
         if ($m->encoded->month == '6') {
             $months['jun'] += 1;
         }
         if ($m->encoded->month == '7') {
             $months['jul'] += 1;
         }
         if ($m->encoded->month == '8') {
             $months['aug'] += 1;
         }
         if ($m->encoded->month == '9') {
             $months['sep'] += 1;
         }
         if ($m->encoded->month == '10') {
             $months['oct'] += 1;
         }
         if ($m->encoded->month == '11') {
             $months['nov'] += 1;
         }
         if ($m->encoded->month == '12') {
             $months['dec'] += 1;
         }
     }
     $claims_amount = $i->claimsAmount($infos);
     $deadline_names = [];
     foreach ($infos as $info) {
         $deadline = $i->isDeadLineToday($info->dead_line);
         $info['deadline_today'] = $deadline;
         if ($deadline == 'deadline' && $info->claim_status == 'pending') {
             $deadline_names[$info->name] = $info;
         }
     }
     return view('home')->with('chart_inc', $chart_inc)->with('chart_complete', $chart_complete)->with('stages', $stages)->with('stats', $stats)->with('months', $months)->with('info', $infos)->with('claims_amount', $claims_amount)->with('message', session('message'))->with('type', $type)->with('column', $column)->with('symbol', $i->getSymbol($type))->with('picture', \App\User::profilePicture())->with('deadline_names', $deadline_names)->with('q', $q)->with('adv', $adv);
 }