function login(Request $request, Response $response) { $response = $response->withHeader('Content-type', 'application/json'); $data = json_decode($request->getBody(), true); $cont = 0; $std = 0; $roles = array(); $dataCliente = Cliente::select("email", "nombres", "apellidos")->where('email', '=', $data['usuario'])->where('pass', '=', $data['pass'])->first(); if ($dataCliente != null) { $cont++; array_push($roles, "cliente"); } $dataEmpresa = Empresa::select("email", "nombre", "foto")->where('email', '=', $data['usuario'])->where('pass', '=', $data['pass'])->first(); if ($dataEmpresa != null) { $cont++; array_push($roles, "empresa"); } $dataUsuario = Usuario::select("id", "nombres", "apellidos", "idSucursal", "idCategoria")->where('id', '=', $data['usuario'])->where('pass', '=', $data['pass'])->first(); if ($dataUsuario != null) { $cont++; array_push($roles, "usuario"); } if ($cont > 0) { $response = $response->withStatus(200); $std = 1; } else { $response = $response->withStatus(404); } $response->getBody()->write(json_encode(array("std" => $std, "roles" => $roles))); return $response; }
public function general() { $totalClientes = Cliente::select(DB::raw("count(*) as total"))->first(); $totalClientesDeudores = Cliente::select(DB::raw("count(*) as total"))->where('saldo', '>', 0)->first(); $totalClientesDeudoresPasados = Cliente::select(DB::raw("count(*) as total"))->where('saldo', '>', 1000)->where('saldo', '>', 0)->first(); $totalDeuda = Cliente::select(DB::raw('sum(saldo) as total'))->where('saldo', '>', 0)->first(); $data['totalClientes'] = $totalClientes->total; $data['totalClientesDeudores'] = $totalClientesDeudores->total; $data['totalClientesDeudoresPasados'] = $totalClientesDeudoresPasados->total; $data['totalDeuda'] = $totalDeuda->total; return View::make('reportes.general', compact('data')); }
public function exportarEmail() { Excel::create('Clientes' . date('Ymd'), function ($excel) { $excel->sheet('Clientes', function ($sheet) { $clientes = Cliente::select('email')->distinct()->get(); $datos = array(array('Email')); foreach ($clientes as $cliente) { array_push($datos, array($cliente->email)); } $sheet->fromModel($datos, null, 'A1', false, false); $sheet->row(1, function ($row) { // call cell manipulation methods $row->setFontWeight('bold'); }); }); })->download('xls'); }
public function getIdPushByPeticionCliente($id) { $data = Cliente::select("cliente.email", "cliente.idPush", "peticion.nombre as nombrePeticion")->join("peticion", "cliente.email", "=", "peticion.idCliente")->where("peticion.id", "=", $id)->first(); return $data; }
function validarcorreo(Request $request, Response $response) { $response = $response->withHeader('Content-type', 'application/json'); $response = $response->withStatus(200); $correo = $request->getAttribute("email"); $data = Cliente::select("email")->where('email', '=', $correo)->first(); if ($data != null) { $respuesta = json_encode(array("std" => 1, "msg" => "Este correo ya esta registrado")); } else { $respuesta = json_encode(array("std" => 0, "msg" => "Este correo esta disponible")); } $response->getBody()->write($respuesta); return $response; }
public function postReservaAnonimo(Request $request, Response $response) { $response = $response->withHeader('Content-type', 'application/json'); $data = json_decode($request->getBody(), true); //VALIDAR SI EL CLIENTE EXISTE $cli = Cliente::select("id")->where("email", "=", $data["email"])->first(); $idCliente = ""; if ($cli == null) { try { $cliente = new Cliente(); $cliente->email = $data['email']; $cliente->nombres = $data['nombres']; $cliente->apellidos = $data['apellidos']; $cliente->telefono = ""; $cliente->pass = sha1($data['email']); $cliente->estado = "ACTIVO"; $cliente->save(); $idCliente = $cliente->id; } catch (Exception $err) { } } else { $idCliente = $cli->id; } //INSERTAR TURNO try { $turno = new Turno(); $turno->idCliente = $idCliente; $turno->idEmpleado = $data['idEmpleado']; $turno->idSucursal = $data['idSucursal']; $turno->idServicio = $data['idServicio']; $turno->tiempo = 0; $turno->turno = 0; $turno->turnoReal = 0; $turno->tipoTurno = 1; $turno->estadoTurno = "SOLICITADO"; $turno->estado = "ACTIVO"; $turno->reserva = "A"; $turno->fechaReserva = $data['fechaReserva']; $turno->horaReserva = $data['horaReserva']; $horaInicial = $data['horaReserva']; for ($i = 0; $i < $data["cupos"]; $i++) { $segundos_horaInicial = strtotime($horaInicial); $segundos_minutoAnadir = $data["minutos"] * 60; $nuevaHora = date("H:i", $segundos_horaInicial + $segundos_minutoAnadir); $horaInicial = $nuevaHora; } $turno->horaFinalReserva = $nuevaHora; $turno->save(); $respuesta = json_encode(array('msg' => "Guardado correctamente", "std" => 1, "numeroTurno" => $turnoSiguiente)); $response = $response->withStatus(200); //ENVIAR NOTIFICACION AL EMPLEADO Y AL ADMINISTRADOR DE LA SUCURSAL } catch (Exception $err) { $respuesta = json_encode(array('msg' => "error al pedir el turno", "std" => 0, "err" => $err->getMessage())); $response = $response->withStatus(404); } $response->getBody()->write($respuesta); return $response; }