Exemple #1
0
 public function listHotspots($idUser, $name)
 {
     $HotsPotsGroups = DB::select("select DISTINCT H.id from hotspots as H " . "inner join hotspots_groups as HG ON H.id=HG.hotspots_id " . "where H.geocode={$idUser}");
     if ($HotsPotsGroups) {
         foreach ($HotsPotsGroups as $value) {
             $idHotspots[] = $value->id;
         }
         $Hostpots = Hostpots::whereNotIn('id', $idHotspots)->whereGeocode($idUser)->lists($name, 'id', 'geocode');
     } else {
         $Hostpots = Hostpots::whereGeocode($idUser)->lists($name, 'id', 'geocode');
     }
     return $Hostpots;
 }
 public function loginUser(Request $request)
 {
     $data = $request->all();
     $validator = Validator::make($data, ['mac' => 'required|min:17|max:17', 'uamport' => 'required', 'uamip' => 'required', 'userurl' => 'required', 'res' => 'required']);
     //var_dump($data);
     if ($validator->fails()) {
         $error = (array) json_decode($validator->errors());
         dd($error);
     }
     $url = $data['userurl'];
     if ($data['res'] == "success") {
         header("Location: " . $url);
         exit;
     }
     $dateHostPots = Hostpots::whereName($data['uamport'])->get();
     if (!empty($dateHostPots->toArray())) {
         $uamip = explode(':', $data['uamip']);
         $obj = Hostpots::find($dateHostPots[0]->id);
         $obj->update(array('owner' => $uamip[0]));
         $ip = $uamip[0];
         $table = HotspotsCampania::whereHotspotsId($dateHostPots[0]->id)->whereDayId(date("N"))->get();
         if ($table->toArray()) {
             $idCampania = $table->toArray()[0]['campania_id'];
         } else {
             $datos = GroupsCampania::whereGroupsId($dateHostPots[0]->geocode)->whereDayId(date("N"))->get();
             $idCampania = $datos[0]->campania_id;
         }
         $datosCampania = \App\Models\Campania::whereId($idCampania)->get();
         $imagen = $datosCampania[0]->imagen;
         $extension = explode('.', $imagen);
         $value = $extension[1] == 'jpg' || $extension[1] == 'png' || $extension[1] == 'jpeg' || $extension[1] == 'gif' ? 'img' : 'video';
     } else {
         $msg = array('msg' => 'no existe equipo asociado');
         dd($msg);
     }
     $User = $this->getUser($data['mac']);
     // Usergroup
     $this->getUsergroup($data['mac'], $data['uamport']);
     //$href = 'http://' . $ip . '?login?user='******'username'] . '&password='******'value'] . '&dst=' . $datosCampania[0]->url;
     $href = 'http://' . $ip . '/login?user='******'username'] . '&password='******'value'] . '&dst=' . $datosCampania[0]->url;
     return viewc('home.login-user.login', compact('ip', 'href', 'imagen', 'value'));
 }
Exemple #3
0
 public function listHotspots(Request $request)
 {
     try {
         $idGroup = $request->input('groups_id');
         $dataGroup = Groups::find($idGroup);
         $exercise = new Hostpots();
         if ($dataGroup->customer_id == Auth::customer()->user()->id) {
             $data = $exercise->listHotspots($dataGroup->customer_id, 'email_owner');
         } else {
             $data = $exercise->listHotspots($dataGroup->customer_id, 'mac');
         }
         $return = array('state' => 1, 'msg' => 'ok', 'data' => $data);
     } catch (Exception $exc) {
         $return = array('state' => 0, 'msg' => $exc->getMessage());
     }
     return response()->json($return);
 }
Exemple #4
0
 public function getListEquipment(Request $request)
 {
     $idGroup = $request->input('idGroup', 0);
     $table = Hostpots::select(['id', 'name', 'mac', 'owner'])->whereGeocode($idGroup);
     $datatable = Datatables::of($table)->addColumn('action', function ($table) {
         return '<a href="' . $table->id . '" class="btn btn-warning">Editar</a>
                 
                     <a href="#" data-url="/admclient/' . self::NAMEC . '/delete/' . $table->id . '" class="btn btn-danger action_delete" data-id="' . $table->id . '" >Eliminar</a>';
     });
     return $datatable->make(true);
 }
 public function getDelete($id)
 {
     $table = null;
     if (!empty($id)) {
         $table = Hostpots::whereId($id);
         $table->delete();
         \App\Models\HotspotsGroups::whereHotspotsId($id)->delete();
     }
     return response()->json(array('msg' => 'ok', 'state' => 1, 'data' => null));
 }