+<?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80:
+-------------------------------------------------------------------------------
+ Ministerio de Economía
+ meconlib
+-------------------------------------------------------------------------------
+This file is part of meconlib.
+
+meconlib is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+
+meconlib is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License; if not,
+write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+Boston, MA 02111-1307 USA
+-------------------------------------------------------------------------------
+Creado: Thu Aug 11 15:17:11 2003
+Autor: Manuel Nazar <manazar@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id: Usuario.php 242 2003-08-11 18:02:16Z manazar $
+-----------------------------------------------------------------------------*/
+
+require_once 'DB.php';
+
+// +X2C Class 131 :MECON_Usuario
+/**
+ * @access public
+ */
+class MECON_Usuario {
+ /**
+ * @var int $dni
+ * @access public
+ */
+ var $dni;
+
+ /**
+ * @var string $login
+ * @access public
+ */
+ var $login;
+
+
+ /**
+ * @var string $nombre
+ * @access public
+ */
+ var $nombre;
+ /**
+ * @var string $dsn
+ * @access public
+ */
+ var $dsn = 'mysql://intranet:intranet@bal747f.mecon.ar/usuario';
+
+
+ // ~X2C
+
+// +X2C Operation 138
+ /**
+ * @param string $dni
+ *
+ * @return void
+ * @access public
+ */
+ function ArmarconDNI($dni) // ~X2C
+ {
+ $db = DB::connect($this->dsn);
+ if (DB::isError($db))
+ {
+ die ($db->getMessage("No pudo conectarse a la base"));
+ }
+ else
+ {
+ $sql = "SELECT login,nombre
+ from Usuario
+ where dni = $dni";
+ $result = $db->query($sql);
+ $row = $result->fetchRow();
+ $login = $row[0];
+ $nombre = $row[1];
+ $this->login=$login;
+ $this->nombre=$nombre;
+ $this->dni=$dni;
+ }
+ }
+ // -X2C
+
+
+// +X2C Operation 136
+ /**
+ * @param string $login
+ *
+ * @return void
+ * @access public
+ */
+ function ArmarconLOGIN($login) // ~X2C
+ {
+ $db = DB::connect($this->dsn);
+ if (DB::isError($db))
+ {
+ die ($db->getMessage("No pudo conectarse a la base"));
+ }
+ else
+ {
+ $sql = "SELECT dni,nombre
+ from Usuario
+ where login = '$login'";
+ $result = $db->query($sql);
+ $row = $result->fetchRow();
+ $dni = $row[0];
+ $nombre = $row[1];
+ $this->dni=$dni;
+ $this->nombre=$nombre;
+ $this->login=$login;
+ }
+ }
+ // -X2C
+
+ // +X2C Operation 135
+ /**
+ * @param int $dni
+ *
+ * @return void
+ * @access public
+ */
+ function MECON_Usuario($dni = NULL, $login = NULL) // ~X2C
+ {
+ if(! is_null($dni))
+ {
+ $this->ArmarconDNI($dni);
+ $this->buscarUsuarioDNI($dni);
+ }
+ if(! is_null($login))
+ {
+ $this->ArmarconLOGIN($login);
+ $this->buscarUsuarioDNI($dni);
+ }
+
+ }
+ // -X2C
+
+ // +X2C Operation 136
+ /**
+ * @param int $uario
+ *
+ * @return void
+ * @access public
+ */
+ function Insertar_Usuario($dni = NULL, $login = NULL, $nombre = NULL) // ~X2C
+ {
+ if((! is_null($dni)) && (! is_null($login)) && (! is_null($nombre)))
+ {
+ $db = DB::connect($this->dsn);
+ if (DB::isError($db))
+ {
+ die ($db->getMessage("No pudo conectarse a la base"));
+ }
+ else
+ {
+ $sql = "REPLACE INTO Usuario (login,dni,nombre)
+ values ('$login',$dni,'$nombre')";
+ $result = $db->query($sql);
+ }
+ }
+ }
+ // -X2C
+
+ // +X2C Operation 137
+ /**
+ * @return string
+ * @access public
+ */
+ function getLogin() // ~X2C
+ {
+ return $this->login;
+ }
+ // -X2C
+
+ // +X2C Operation 138
+ /**
+ * @return string
+ * @access public
+ */
+ function getNombre() // ~X2C
+ {
+ return $this->nombre;
+ }
+ // -X2C
+
+
+ // +X2C Operation 154
+ /**
+ * @param int $dni
+ *
+ * @return void
+ * @access public
+ */
+ function buscarUsuarioDNI($dni) // ~X2C
+ {
+ $this->dni = $dni;
+ $dsn = 'mysql://intranet:intranet@intranet-db/novedades';
+ $db = DB::connect($dsn);
+ if (DB::isError($db)) die ($db->getMessage("No pudo conectarse a la base"));
+ $sql = "SELECT nombre
+ FROM web003
+ WHERE nrodoc = $dni";
+ $result = $db->query($sql);
+ if(DB::isError($result))
+ die($result->getMessage("query mal hecho"));
+ if($result->numRows() > 0)
+ {
+ $row = $result->fetchRow();
+ $nombre = $row[0];
+ $this->nombre = $nombre;
+ }
+ else
+ {
+ $dsn = 'mysql://intranet:intranet@intranet-db/Contratados';
+ $db = DB::connect($dsn);
+ if (DB::isError($db)) die ($db->getMessage("No pudo conectarse a la base"));
+ $sql = "SELECT nombre
+ FROM Contratados
+ WHERE nrodoc = $dni";
+ $result = $db->query($sql);
+ if(DB::isError($result))
+ die($result->getMessage("query mal hecho"));
+ if($result->numRows() > 0)
+ {
+ $row = $result->fetchRow();
+ $nombre = $row[0];
+ $this->nombre = $nombre;
+ }
+ else
+ return false;
+ }
+ return true;
+ }
+ // -X2C
+
+} // -X2C Class :MECON_Usuario
+?>
\ No newline at end of file