public function executeLogin(sfWebRequest $request) { if ($this->getUser()->isAuthenticated()) { $this->redirect('@homepage'); } $this->getUser()->getAttributeHolder()->clear(); $this->form = new LoginPortalForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter("login")); if ($this->form->isValid()) { $user = sfContext::getInstance()->getUser(); $user->setAuthenticated(true); $valido = $this->getUser()->getAttribute('usuario', null, 'seguridad'); $this->getUser()->setAttribute('empresa', null, 'seleccion'); $usuario = UsuarioQuery::create()->findOneById($valido); $this->getUser()->setAttribute('usuario', false, 'administrador'); if ($usuario->getAdministrador()) { $this->getUser()->setAttribute('empresa', 'Administrador', 'seleccion'); $this->getUser()->setAttribute('usuario', true, 'administrador'); } else { $usuarioEmpresas = UsuarioEmpresaQuery::create()->findByUsuarioId($usuario->getId()); if (sizeof($usuarioEmpresas) == 0) { $this->getUser()->setAttribute('empresa', null, 'seleccion'); $this->getUser()->setFlash('error', 'Este usuario no tiene ninguna empresa definida.'); } elseif (sizeof($usuarioEmpresas) == 1) { $this->getUser()->setAttribute('empresa', $usuarioEmpresas[0]->getEmpresaId(), 'seleccion'); } else { $this->redirect('inicio/seleccionEmpresa'); } } $valores = $this->form->getValues(); $this->redirect("@homepage"); } } }
function executeClave(sfWebRequest $request) { $this->id = $request->getParameter('id'); $this->form = new CAmbioClaveForm(); if ($request->isMethod('POST')) { $this->form->bind($request->getParameter('cambio_clave')); if ($this->form->isValid()) { $valores = $this->form->getValues(); $Usuario = UsuarioQuery::create()->findOneById($this->id); $Usuario->setClave(sha1($valores['clave'])); $Usuario->save(); $this->getUser()->setFlash('exito', 'Cambio de clave efecutado correctamente.'); $this->redirect('usuario/index'); } } }
public function save(PropelPDO $con = null) { $BitacoraCambios = new BitacoraCambios(); $BitacoraCambios->setModelo('Proveedor'); $BitacoraCambios->setIp(sfContext::getInstance()->getRequest()->getRemoteAddress()); if ($this->isNew()) { $BitacoraCambios->setDescripcion('Creacion de Proveedor: ' . $this->getNombre()); } else { $BitacoraCambios->setDescripcion('Modificacion de Proveedor: ' . $this->getNombre()); } $Usuario = UsuarioQuery::create()->findOneById(sfContext::getInstance()->getUser()->getAttribute('usuario', null, 'seguridad')); if ($Usuario) { $BitacoraCambios->setCreatedBy($Usuario->getUsuario()); } $BitacoraCambios->save(); return parent::save($con); }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { $this->form = new IngresoInventarioForm(); if ($request->isMethod('POST')) { $this->form->bind($request->getParameter('ingreso_inventario')); if ($this->form->isValid()) { $valores = $this->form->getValues(); $BitacoraCambios = new BitacoraCambios(); $BitacoraCambios->setModelo('Inventario'); $Producto = ProductoQuery::create()->findOneById($valores['Producto']); $BitacoraCambios->setDescripcion('Ingreso de Inventario de Producto: ' . $Producto->getDescripcion() . ' con cantidad ' . $valores['Cantidad']); $BitacoraCambios->setIp($request->getRemoteAddress()); $Usuario = UsuarioQuery::create()->findOneById(sfContext::getInstance()->getUser()->getAttribute('usuario', null, 'seguridad')); if ($Usuario) { $BitacoraCambios->setCreatedBy($Usuario->getUsuario()); } $Movimiento = new Movimiento(); $Movimiento->setTipoMovimiento('+'); $Movimiento->setProveedorId($valores['Proveedor']); $Movimiento->setProductoId($Producto->getId()); $Movimiento->setCantidad($valores['Cantidad']); $Movimiento->setPrecio($valores['Precio']); $Movimiento->save(); $BitacoraCambios->save(); $Comprobacion = InventarioQuery::create()->filterByProductoId($valores['Producto'])->filterByProveedorId($valores['Proveedor'])->findOne(); if ($Comprobacion) { $Comprobacion->setCantidad($Comprobacion->getCantidad() + $valores['Cantidad']); $anterior = $Comprobacion->getCantidad() * $Comprobacion->getPrecioCompra(); $actual = $valores['Cantidad'] * $valores['Precio']; $suma = ($anterior + $actual) / ($valores['Cantidad'] + $Comprobacion->getCantidad()); $Comprobacion->setPrecioCompra($suma); $Comprobacion->save(); } else { $Inventario = new Inventario(); $Inventario->setPrecioCompra($valores['Precio']); $Inventario->setProductoId($valores['Producto']); $Inventario->setProveedorId($valores['Proveedor']); $Inventario->setCantidad($valores['Cantidad']); $Inventario->save(); } $this->redirect('inventario/index'); } } $this->cinco = InventarioQuery::create()->orderById('DESC')->limit(5)->find(); }
public function executeLogin(sfWebRequest $request) { if ($this->getUser()->isAuthenticated()) { $this->redirect('@homepage'); } $this->getUser()->getAttributeHolder()->clear(); $this->form = new LoginPortalForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter("login")); if ($this->form->isValid()) { $user = sfContext::getInstance()->getUser(); $user->setAuthenticated(true); $valido = $this->getUser()->getAttribute('usuario', null, 'seguridad'); $usuario = UsuarioQuery::create()->findOneById($valido); $valores = $this->form->getValues(); $this->redirect("@homepage"); } } }
public static function validaUsuario($u, $c) { $intentos = 10; // sfConfig::get("app_seguridad_intentos",3); $segundos_bloqueo = 10; // sfConfig::get("app_seguridad_tiempo",60); $hora_bloqueo = date('Y-m-d H:i:s', mktime(date('H'), date('i'), date('s') + $segundos_bloqueo, date('m'), date('d'), date('Y'))); $usuario = UsuarioQuery::create()->filterByUsuario($u)->findOne(); $msg = null; if ($usuario) { if ($usuario->getClave() == $c) { } else { $msg = 'Usuario/Clave Inválido'; $usuario = null; } } else { $usuario = null; $msg = 'Usuario/Clave Inválido'; } sfContext::getInstance()->getUser()->setFlash('login', $msg); return $usuario; }
/** * Get the associated Usuario object * * @param PropelPDO Optional Connection object. * @return Usuario The associated Usuario object. * @throws PropelException */ public function getUsuario(PropelPDO $con = null) { if ($this->aUsuario === null && $this->id_usuario !== null) { $this->aUsuario = UsuarioQuery::create()->findPk($this->id_usuario, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aUsuario->addListas($this); */ } return $this->aUsuario; }
<?php //die; error_reporting(E_ALL); ini_set("display_errors", 1); include_once "../../data/config.php"; //$libros = LibroQuery::create()->findOneById($_GET['id']); //$usuarios = UsuarioQuery::create()->find(); $idusuario = $_SESSION['userid']; $usuario = UsuarioQuery::create()->findOneById($idusuario); $audiolibros = AudiolibroQuery::create()->find(); $idLibro = $_GET['id']; $libro = LibroQuery::create()->findOneById($idLibro); //echo $libro->getEs_editable(); //$options = "<option value = ''>Seleccione un libro</option> "; $listaaudios = ""; //$arr=array(); foreach ($audiolibros as $reg) { //if(!array_key_exists($reg->getId(), $arr)){ //$arr[$reg->getId()] = ""; $listaaudios .= "<li>" . $reg->getNombre() . "</li>"; //$options .= "<option value = '".$reg->getId()."'>".$reg->getNombre()."</option> "; //$options .= "<option value = '".$reg->getId()."'>".$reg->getNombre()."</option> "; //$options .= "<option value = '".$reg->getId()."'>".$reg->getNombre()."</option> "; //} } //echo $listaLibros; //$listaLibros = ""; //$libros = LibroQuery::create()->find(); ?> <table>
session_start(); error_reporting(E_ALL); ini_set("display_errors", 0); include_once "data/config.php"; $errMsg = ""; $registroCorrecto = false; $psw1Val = ""; $psw2Val = ""; $nombreVal = ""; $mailVal = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $psw1Val = $_POST['psw1']; $psw2Val = $_POST['psw2']; $nombreVal = $_POST['nombre']; $mailVal = $_POST['mail']; $Usuario = UsuarioQuery::create()->filterBymail($_POST['mail'])->find()->count(); if ($Usuario == 0) { if ($_POST['psw1'] != $_POST['psw2']) { $errMsg += "Las password deben ser iguales.\n"; } else { if ($_POST['nombre'] == "") { $errMsg += "Debe completar el campo nombre.\n"; } else { if ($_POST['psw1'] == "") { $errMsg += "Debe completar los campos password.\n"; } else { if ($_POST['mail'] == "") { $errMsg += "Debe completar el campo mail.\n"; } else { $usuario2 = new Usuario(); $usuario2->setmail($_POST['mail']);
$datos = json_decode($_POST['json']); //$libros = LibroQuery::create()->find(); //$usuarios = UsuarioQuery::create()->find(); switch ($datos->accion) { case "e": //Edit $usuarioObj = UsuarioQuery::create()->findOneById($datos->id); //echo $usuarioObj->toArray(); $usuarioObj->setNombre($datos->nombre); $usuarioObj->setMail($datos->mail); $usuarioObj->save(); echo json_encode(array('error' => 0, 'msg' => "Usuario modificado correctamente")); break; case "d": //Delete $usuarioObj = UsuarioQuery::create()->findOneById($datos->id); //$objTerapia = TerapiasQuery::create()->findOneById($_GET["id"]); if ($usuarioObj != null) { $usuarioObj->delete(); } echo json_encode(array('error' => 0, 'msg' => "Usuario borrado correctamente")); break; case "n": //New $usuarioObj = new Usuario(); $usuarioObj->setNombre($datos->nombre); $usuarioObj->setMail($datos->mail); $usuarioObj->save(); echo json_encode(array('error' => 0, 'msg' => "Usuario creado correctamente")); break; }
break; case "n": //New $clasificadosObj = new Clasificados(); $clasificadosObj->setTexto_corto($datos->texto_corto); $clasificadosObj->setTexto_largo($datos->texto_largo); $clasificadosObj->setId_libro($datos->libro); $clasificadosObj->save(); echo json_encode(array('error' => 0, 'msg' => "Clasificado creado correctamente")); break; case "obtener_datos": $clasificadosObj = ClasificadosQuery::create()->findOneById($datos->id); //echo $clasificadosObj->toArray(); echo json_encode(array('texto_corto' => $clasificadosObj->getTexto_corto(), 'texto_largo' => $clasificadosObj->getTexto_largo(), 'libro' => $clasificadosObj->getId_libro())); break; case "solicitarcolaborar": $clasificadosObj = ClasificadosQuery::create()->findOneById($datos->id); $solicitud = new Solicitud(); $solicitud->setId_libro($clasificadosObj->getId_libro()); $solicitud->setId_usuario_solicitante($_SESSION['userid']); $solicitud->setId_estado("1"); $solicitud->setFecha_solic(date('Y-m-d')); $solicitud->setHora_solic(date('H:i:s')); $solicitud->save(); include 'notificacion_data.php'; $mesajeNotificacion = "<span onclick=\"refreshDivs('cuerpocentro','pages/layout/perfillibro.php?id=" . $clasificadosObj->getId_libro() . "')\">El usuario '" . UsuarioQuery::create()->findOneById($_SESSION["userid"])->getNombre() . "' solicito colaborar en tu libro '" . $clasificadosObj->getLibro()->getNombre() . "'.</span>"; guardarNotificacion($clasificadosObj->getLibro()->getId_usuario(), $mesajeNotificacion, 11); //echo $clasificadosObj->toArray(); echo json_encode(array('msg' => "Solicitud enviada correctamente")); break; }
case "n": //New include 'notificacion_data.php'; $libroObj = new Libro(); //$libroObj->setNombre($datos->nombre); $libroObj->setNombre($_POST["nombrelibro"]); $libroObj->setId_genero($_POST["vinculogenero"]); $libroObj->setFecha(date('Y-m-d')); $libroObj->setAutor($_POST["autor"]); $libroObj->setEs_editable("n"); $libroObj->setSinopsis($_POST["sinopsis"]); $libroObj->setId_privacidad($_POST["privacidad"]); $libroObj->setId_usuario($_SESSION["userid"]); $libroObj->save(); $idImage = $libroObj->getId(); $mesajeNotificacion = "<span onclick=\"refreshDivs('cuerpocentro','pages/layout/perfillibro.php?id=" . $idImage . "')\">El usuario '" . UsuarioQuery::create()->findOneById($_SESSION["userid"])->getNombre() . "' ha subido un libro.</span>"; guardarNotificacion(ID_ADMIN_USER, $mesajeNotificacion, 6); // obtenemos los datos del archivo //$tamano = $_FILES["image"]['size']; //$tipo = $_FILES["image"]['type']; $archivo = $_FILES["image"]['name']; if ($archivo != "") { //$nom=date('Y-m-d H:i:s'); //$hasharchivo = hash('md5',$nom); // $audiolibroObj->setHash($datosaudio->hasharchivo); //echo $hasharchivo; // guardamos el archivo a la carpeta files $destino = "../../portadas/" . $idImage . '.jpg'; if (copy($_FILES['image']['tmp_name'], $destino)) { //$status = "Archivo subido: ".$archivo.""; $libroObj->setImage($idImage);
public function executeEdita(sfWebRequest $request) { $this->id = $request->getParameter('id'); $iddet = $request->getParameter('det'); $dets = DetallePedidoProveedorQuery::create()->filterById($iddet)->findOne(); $this->form = new IngresoDetallePedidoProveedorForm(array("Producto" => $dets->getProducto(), "Cantidad" => $dets->getCantidad(), "Precio" => $dets->getPrecio())); if ($request->isMethod('POST')) { $this->form->bind($request->getParameter('ingreso_detpedprov')); if ($this->form->isValid()) { $valores = $this->form->getValues(); $BitacoraCambios = new BitacoraCambios(); $BitacoraCambios->setModelo('Detalle Pedido Proveedores'); $BitacoraCambios->setDescripcion('Edicion de Detalle de Pedido a Proveedor con id :' . $iddet); $BitacoraCambios->setIp($request->getRemoteAddress()); $pedido = $dets; $Usuario = UsuarioQuery::create()->findOneById(sfContext::getInstance()->getUser()->getAttribute('usuario', null, 'seguridad')); $pedido->setProductoId($valores['Producto']); $pedido->setCantidad($valores['Cantidad']); $pedido->setPrecio($valores['Precio']); $pedido->save(); $url = 'pedido_proveedor/detalle?id=' . $this->id; $this->redirect($url); } } }
public function executeConfirmar(sfWebRequest $request) { $Factura = FacturaQuery::create()->findOneById($request->getParameter('id')); $Detalles = FacturaDetalleQuery::create()->findByFacturaId($request->getParameter('id')); if (sizeof($Detalles) == 0) { $this->getUser()->setFlash('error', 'No existen productos ingresados en esta factura.'); $this->redirect('venta/detalle?id=' . $request->getParameter('id')); } if ($Factura->getActivo()) { foreach ($Detalles as $detalle) { $fecha = date("d/m/Y"); $Promocion = PromocionQuery::create()->filterByProductoId($detalle->getProductoId())->where("fecha_inicio <= '{$fecha}' and fecha_fin >= '{$fecha}'")->findOne(); $descuento = 1; if ($Promocion) { $descuento = 1 - $Promocion->getDescuento() / 100; } $Movimiento = new Movimiento(); $Movimiento->setTipoMovimiento('-'); $Movimiento->setClienteId($Factura->getClienteId()); $Movimiento->setProductoId($detalle->getProductoId()); $Movimiento->setCantidad($detalle->getCantidad()); $Movimiento->setProveedorId($detalle->getProveedorId()); $Movimiento->setPrecio($detalle->getPrecioUnitario() * $descuento); $Movimiento->setFecha(date('Y-m-d')); $Movimiento->save(); } $BitacoraCambios = new BitacoraCambios(); $BitacoraCambios->setModelo('Factura'); $BitacoraCambios->setIp(sfContext::getInstance()->getRequest()->getRemoteAddress()); $BitacoraCambios->setDescripcion('Creacion de Factura con id: ' . sprintf("%05d", $Factura->getId())); $Usuario = UsuarioQuery::create()->findOneById(sfContext::getInstance()->getUser()->getAttribute('usuario', null, 'seguridad')); if ($Usuario) { $Factura->setCreatedBy($Usuario->getUsuario()); $BitacoraCambios->setCreatedBy($Usuario->getUsuario()); } $BitacoraCambios->save(); $Cliente = ClienteQuery::create()->findOneById($Factura->getClienteId()); if (Factura::obtenerTotal($request->getParameter('id')) >= 200) { $Cliente->setPuntos($Cliente->getPuntos() + 10); $Cliente->save(); } } $Factura->setActivo(false); $Factura->save(); $pdf = new sfTCPDF("P", "mm", "Letter"); $this->id = $request->getParameter("id"); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('SALUD_INTEGRAL'); $pdf->SetTitle('Factura'); $pdf->SetSubject('Factura'); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetHeaderMargin(0.1); $pdf->SetFooterMargin(0.1); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetFont('dejavusans', '', 7); $pdf->AddPage(); $html = ''; $detalles = FacturaDetalleQuery::create()->findByFacturaId($Factura->getId()); $html = $this->getPartial('venta/soporteTabla', array("factura" => $Factura, "detalles" => $detalles)); $pdf->writeHTML($html); $pdf->Output('Factura.pdf', 'D'); }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(UsuarioPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = UsuarioQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * Returns the number of related Usuario objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Usuario objects. * @throws PropelException */ public function countUsuarios(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collUsuariosPartial && !$this->isNew(); if (null === $this->collUsuarios || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collUsuarios) { return 0; } else { if ($partial && !$criteria) { return count($this->getUsuarios()); } $query = UsuarioQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByPerfil($this)->count($con); } } else { return count($this->collUsuarios); } }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @throws Exception * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(UsuarioPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = UsuarioQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // symfony_behaviors behavior foreach (sfMixer::getCallables('BaseUsuario:delete:pre') as $callable) { if (call_user_func($callable, $this, $con)) { $con->commit(); return; } } if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); // symfony_behaviors behavior foreach (sfMixer::getCallables('BaseUsuario:delete:post') as $callable) { call_user_func($callable, $this, $con); } $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
<?php session_start(); error_reporting(E_ALL); ini_set("display_errors", 0); include_once "data/config.php"; if ($_SERVER["REQUEST_METHOD"] == "POST") { $Usuario = UsuarioQuery::create()->filterBymail($_POST['mail'])->filterByPassword($_POST['psw'])->count(); if ($Usuario == 0) { $errLogin = true; } else { $Usuario2 = UsuarioQuery::create()->findOneBymail($_POST['mail']); $_SESSION['userid'] = $Usuario2->getId(); $_SESSION['nombre'] = $Usuario2->getNombre(); $_SESSION['mail'] = $_POST['mail']; header('location: index.php'); } } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Proyecto Lectura</title> <link rel="icon" href="<?php echo PROJECT_REL_DIR; ?> /images/favicon.ico" /> <!-- Tell the browser to be responsive to screen width -->
<?php error_reporting(E_ALL); ini_set("display_errors", 1); include_once "../../data/config.php"; $usuario = UsuarioQuery::create()->find(); //$usuario = UsuarioQuery :: create() ->findOneById(1); //$mensaje->getUsuarioRelatedById_usuario_remitente()->getNick(); //'<li class="header">You have 5 messages</li>' foreach ($usuario as $reg) { //$listaLibros .= "<li>".$reg->getNombre()."</li>"; $lista_usuarios .= '<option value = "' . $reg->getId() . '">' . $reg->getNombre() . '</option>'; } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Proyecto Lectura</title> <!-- Tell the browser to be responsive to screen width --> <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> <!-- Bootstrap 3.3.5 --> <link rel="stylesheet" href="../../bootstrap/css/bootstrap.min.css"> <!-- Font Awesome --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> <!-- Ionicons --> <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> <!-- fullCalendar 2.2.5--> <link rel="stylesheet" href="../../plugins/fullcalendar/fullcalendar.min.css"> <link rel="stylesheet" href="../../plugins/fullcalendar/fullcalendar.print.css" media="print">