public function getConfiguracion($idEquipment = null, $idCustomer = null) { $dataHotspots = Hostpots::find($idEquipment); if ($idCustomer == null) { $idCustomer = Auth::customer()->user()->id; } $dataCampania = Campania::whereCustomerId($idCustomer)->get()->toArray(); if ($dataHotspots->geocode == 0) { $typeCampania = Campania::where('flagactive', '=', '1')->whereCustomerId(null)->lists('name', 'id'); } else { if ($idCustomer == null) { $idCustomer = Auth::customer()->user()->id; } $typeCampania = Campania::where('flagactive', '=', '1')->whereCustomerId($idCustomer)->lists('name', 'id'); } $datos = HotspotsCampania::join('campania as c', 'c.id', '=', 'hotspots_campania.campania_id')->select('hotspots_campania.day_id')->where('hotspots_campania.hotspots_id', '=', $idEquipment)->get()->toArray(); foreach ($datos as $value) { $days[] = $value['day_id']; } $day = Day::all(); foreach ($day as $d) { $checked = isset($days) ? in_array($d->id, $days) : false; if ($checked) { $datos = HotspotsCampania::join('campania as c', 'c.id', '=', 'hotspots_campania.campania_id')->select('c.*', 'hotspots_campania.*')->where('hotspots_campania.hotspots_id', '=', $idEquipment)->where('hotspots_campania.day_id', '=', $d->id)->first(); $d->campania_id = $datos->campania_id; $d->campania_name = $datos->name; $d->campania_imagen = $datos->imagen; } } return viewc('client.' . self::NAMEC . '.configuracion', compact('idEquipment', ['datos', 'dataCampania', 'day', 'idCustomer']), ['typeCampania' => $typeCampania]); }
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')); }
public function postConfiguracion2(Request $request) { $data = $request->all(); GroupsCampania::whereGroupsId($data['groups_id'])->forceDelete(); GroupsCampania::create($data); $dataEquipos = Hostpots::whereGeocode($data['groups_id'])->get(); $datosCampania = Campania::whereId($data['campania_id'])->get(); $datosCampaniaFinal = $datosCampania->toArray(); $datosGrupo = Groups::find($data['groups_id'])->lists('name'); Radgroupreply::whereGroupname($datosGrupo[0])->forceDelete(); foreach ($dataEquipos->toArray() as $v) { $valor1 = array('groupname' => $datosGrupo[0], 'MikroTik-Advertise-URL', 'op' => '==', 'value' => $datosCampaniaFinal[0]['url']); Radgroupreply::create($valor1); $valor2 = array('groupname' => $datosGrupo[0], 'MikroTik-Advertise-Interval', 'op' => '==', 'value' => $datosCampaniaFinal[0]['expiracion']); Radgroupreply::create($valor2); $valor3 = array('groupname' => $datosGrupo[0], 'MikroTik-Rate-Limit', 'op' => '==', 'value' => $datosCampaniaFinal[0]['megas']); Radgroupreply::create($valor3); } echo nl2br("\r\n\r\n\r\n\r\nCONFIGURACION GUARDADA CORRECTAMENTE", false); exit; }
public function postFormcampania(FormCampaniaRequest $request) { if (!empty($request)) { $data = $request->all(); if ($request->file('imagen')) { $imageFile = $request->file('imagen'); $destinationPath = Config::get('app.DINAMIC_PATH') . '/campania'; $fileName = date('Ymdhis') . rand(1, 1000) . '.' . $imageFile->getClientOriginalExtension(); $imageFile->move($destinationPath, $fileName); $data['imagen'] = '/dinamic/campania/' . $fileName; } $data['flagactive'] = $request->get('flagactive', 1); if ($request->id) { $obj = Campania::find($request->id); $obj->update($data); } else { if (empty($data['customer_id'])) { $data['customer_id'] = null; } $obj = Campania::create($data); } if (empty($data['customer_id'])) { return redirect('admclient/' . self::NAMEC . '/campania-list')->with('messageSuccess', 'Caracteristicas Guardado'); } return redirect('admclient/' . self::NAMEC . '/campania/' . $data['customer_id'])->with('messageSuccess', 'Caracteristicas Guardado'); } return redirect('admclient')->with('messageError', 'Error al guardar la region'); }
public function getDelete($id, $CustomerId = null) { if ($CustomerId == null) { $CustomerId = Auth::customer()->user()->id; } $table = null; if (!empty($id)) { $table = Campania::whereId($id)->whereCustomerId($CustomerId); $table->delete(); } return response()->json(array('msg' => 'ok', 'state' => 1, 'data' => null)); }