Пример #1
0
 public function index($id, $build_id)
 {
     if (!($build = Build::find($build_id))) {
         return $this->try_($build);
     }
     if (!($institution = Institution::find($build->institution_id))) {
         return $this->try_($institution);
     }
     $config = Grids::make($id)->toIndexConfig($id);
     $config['row-source'] .= '/' . $build_id;
     $config['breadcrumbs'] = [['name' => 'Institutii de tip:' . Institution::categories()[$institution->category_id], 'route' => "institutions_index", 'ids' => ['type' => $institution->category_id]], ['name' => 'Clădirea ' . $build->name, 'route' => 'buildings_index', 'ids' => ['institution_id' => $institution->id, 'id' => 'cladiri']], ['name' => 'Contoare', 'route' => 'counters_index', 'ids' => ['build_id' => $build_id, 'id' => 'contoare']]];
     return $this->show($config + ['other-info' => ['build' => $build]]);
 }
Пример #2
0
 public function byType($type, $id)
 {
     if (!($cladire = Build::find($id))) {
         return $this->try_($cladire);
     }
     $cladirea = Build::with('counters.bills')->where('id', $id)->first();
     $out = new Collection();
     foreach ($cladirea['counters'] as $k => $contor) {
         foreach ($contor['bills'] as $i => $factura) {
             if ($factura['type_bill'] == $type) {
                 $out->push($factura);
             }
         }
     }
     /* out -> toate facturile pe tipul respectiv */
     $out = $this->sortDateAsc($out);
     $this->out_months = $this->consum_lunar($out);
     $all = $this->out_months;
     $t = array_values($all);
     $first = array_shift($t);
     $data = $first['months'];
     $header = '';
     $content = '';
     $i = 0;
     foreach ($all as $k => $al) {
         $class = $i == 0 ? 'active' : '';
         $i++;
         $header .= view('consum.lunar.tabs.title')->with(['id' => $k, 'class' => $class])->render();
         $content .= view('consum.lunar.tabs.model')->with(['id' => $k, 'data' => $al, 'class' => $class])->render();
     }
     $tabs = view('consum.lunar.tabs.index')->with(['header' => $header, 'content' => $content])->render();
     if (count($all) == 0) {
         return redirect()->back()->withFlashWarning('Nu sunt date suficinte pentru acest tip de raport');
     }
     return $view = view('consum.lunar.index')->with(compact('data', 'chart', 'data', 'tabs', 'all'));
 }