Exemplo n.º 1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $unit = Unit::find($id);
     if (isset($unit)) {
         $unit->delete();
     }
 }
Exemplo n.º 2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $product = Product::find($id);
     if (!$product) {
         $product = Product::where('alias', $id)->first();
     }
     if ($product) {
         $unit = Unit::find($product->unit_id);
         $category = ProductCategory::find($product->product_category_id);
         return view('product', ['categories' => $this->categories, 'selectedCategory' => $category, 'product' => $product, 'unit' => $unit, 'title' => LANG . '_title', 'description' => LANG . '_description', 'tech_description' => LANG . '_tech_description', 'text' => LANG . '_text', 'color' => LANG . '_color', 'unit_title' => LANG . '_unit', 'file' => LANG . '_file', 'seo_title' => LANG . '_seo_title', 'seo_description' => LANG . '_seo_description', 'seo_keywords' => LANG . '_seo_keywords']);
     }
     return redirect('catalog');
 }
Exemplo n.º 3
0
 public function storeData(Request $request)
 {
     $parameter = $request->input('parameter');
     $local = $request->input('local');
     $data = json_decode($request->input('data'));
     $local = Local::where('name', '=', $local)->get();
     switch ($parameter) {
         case 'device':
             $device = new Device();
             $device->id = (int) $data->id + (int) $local[0]->constant;
             $device->name = $data->name;
             $device->location = $data->location;
             $device->interval = $data->interval;
             $device->local_id = $local[0]->id;
             $device->save();
             break;
         case 'mapping':
             $mapping = new Mapping();
             $mapping->id = (int) $data->id + (int) $local[0]->constant;
             $mapping->device_id = (int) $data->device_id + (int) $local[0]->constant;
             $mapping->type_id = $data->type_id;
             $mapping->unit_id = $data->unit_id;
             $mapping->min_threshold = $data->min_threshold;
             $mapping->max_threshold = $data->max_threshold;
             $mapping->save();
             break;
         case 'data':
             $mapping_id = (int) $data->mapping_id + (int) $local[0]->constant;
             $mapping = Mapping::where('id', '=', $mapping_id)->get();
             $device_id = $mapping[0]->device_id;
             $type_id = $mapping[0]->type_id;
             $unit = Unit::find($mapping[0]->unit_id)->unit;
             $convert = new Convert();
             $convert->device_id = $device_id;
             $convert->type_id = $type_id;
             $convert->value = $this->convert($data->value, $type_id, $unit);
             $convert->timestamp = $data->timestamp;
             $convert->save();
             break;
         default:
             break;
     }
     return 'true';
 }
Exemplo n.º 4
0
 public function destroy($id)
 {
     $unit = Unit::find($id);
     if ($unit != null) {
         $unit->delete();
     }
     return back();
 }
Exemplo n.º 5
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $unit = Unit::find($id);
     return view('units.edit', compact('unit'));
 }
Exemplo n.º 6
0
 public function bulananPpk()
 {
     if (Request::get('monthFrom') < 10) {
         $dateFrom = Request::get('yearFrom') . '-0' . Request::get('monthFrom') . '-01';
     } else {
         $dateFrom = Request::get('yearFrom') . '-' . Request::get('monthFrom') . '-01';
     }
     if (Request::get('monthTo') < 10) {
         $dateTo = Request::get('yearTo') . '-0' . Request::get('monthTo') . '-01';
     } else {
         $dateTo = Request::get('yearTo') . '-' . Request::get('monthTo') . '-01';
     }
     $counts = [];
     $bil = 1;
     $units = Unit::find(\Auth::user()->unit);
     $kategoris = Kategori::where('unit', \Auth::user()->unit)->where('status', 'active')->get();
     if (\Auth::user()->level->id == 1) {
         $kategoris = Kategori::where('status', 'active')->get();
     }
     foreach ($kategoris as $kategori) {
         $peralatans = Peralatan::where('kategori_id', $kategori->id)->get();
         foreach ($peralatans as $peralatan) {
             $count = Laporan::where('tarikh', '>=', $dateFrom)->where('tarikh', '<=', $dateTo)->where('peralatan_id', $peralatan->id)->count();
             array_push($counts, ['kategori' => $kategori->nama, 'peralatan' => $peralatan->nama, 'count' => $count]);
         }
     }
     $bil = 1;
     $jumlah = 0;
     foreach ($counts as $count) {
         $jumlah += $count['count'];
     }
     //        dd($counts);
     return View('members.supervisor.laporan.bulananPenempatan', compact('bil', 'counts', 'units', 'kategoris', 'jumlah'));
 }
Exemplo n.º 7
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $object = Model::find($id);
     if ($object) {
         $object->delete();
     }
     return redirect()->back();
 }