-<?php
-// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2003 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license, |
-// | that is bundled with this package in the file LICENSE, and is |
-// | available at through the world-wide-web at |
-// | http://www.php.net/license/2_02.txt. |
-// | If you did not receive a copy of the PHP license and are unable to |
-// | obtain it through the world-wide-web, please send a note to |
-// | license@php.net so we can mail you a copy immediately. |
-// +----------------------------------------------------------------------+
-// | Created: Thu Jun 19 15:17:11 2003
-// | Author: Gonzalo Merayo <gmeray@mecon.gov.ar>
-// +----------------------------------------------------------------------+
-//
-// $Id$
-// $Author$
-// $URL$
-// $Date$
-// $Rev$
-//
+<?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 Jun 19 15:17:11 2003
+Autor: Gonzalo Merayo <gmeray@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id$
+-----------------------------------------------------------------------------*/
-#require_once 'PEAR.php';
require_once 'DB.php';
require_once 'MECON/Tiempo/Hora.php';
-
-
-
-// +X2C Class 131 :Agente
/**
* @access public
*/
-class Agente {
+class MECON_Agente {
+
/**
- * @var int $agente
- * @access public
+ * Documento del agente.
*/
var $agente;
/**
- * @var int $datos
- * @access public
+ * Datos del agente
*/
- var $datos;
-
- // ~X2C
+ var $datos=array();
- // +X2C Operation 133
/**
* @return string
- * @access public
*/
- function getDependencia() // ~X2C
- {
- return $this->datos['codep'];//TODO esta no es la columna correcta
- }
- // -X2C
+ function getDependencia()
+ {
+ if(in_array('codep',array_keys($this->datos)))
+ return $this->datos['codep'];//TODO esta no es la columna correcta
+ else
+ return false;
+ }
- // +X2C Operation 134
/**
* @return void
* @access public
*/
- function getTipo() // ~X2C
- {
- if(is_null($this->datos['tipo_agente']))
- return 'CON '.$this->datos['marco_legal'];
- else
- return $this->datos['tipo_agente'];
-
- }
- // -X2C
+ function getTipo()
+ {
+ if(in_array('marco_legal',array_keys($this->datos)))
+ return 'CON '.$this->datos['marco_legal'];
+ elseif(in_array('tipo_agente',array_keys($this->datos)))
+ return $this->datos['tipo_agente'];
+ else
+ return false;
+ }
- // +X2C Operation 135
/**
+ * @param dbh $db
* @param int $agente
*
* @return void
* @access public
*/
- function Agente($agente) // ~X2C
- {
- $this->agente = $agente;
- $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 *
- FROM web003
- WHERE nrodoc = $agente";
- $result = $db->query($sql);
- if(DB::isError($result))
- die($result->getMessage("query mal hecho"));
- if($result->numRows() > 0)
- {
- $this->datos = $result->fetchRow(DB_FETCHMODE_ASSOC);
- }
- 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 *
- FROM Contratados
- WHERE nrodoc = $agente";
- $result = $db->query($sql);
- if(DB::isError($result))
- die($result->getMessage("query mal hecho"));
- if($result->numRows() > 0)
- {
- $this->datos = $result->fetchRow(DB_FETCHMODE_ASSOC);
- }
- else
- trigger_error("Ahhhhh, agente no encontrado!");
- }
- }
- // -X2C
+ function MECON_Agente(&$db,$agente)
+ {
+ $this->_db = $db;
+ //$this->_db = DB::connect('mysql://intranet:intranet@intranet-db.mecon.ar/novedades');
+ if(! is_null($agente)) {
+ $this->buscarAgente($agente);
+ }
+ }
- // +X2C Operation 138
/**
* @return void
* @access public
*/
- function getNombre() // ~X2C
- {
- return $this->datos['nombre'];
- }
- // -X2C
+ function getNombre()
+ {
+ if(in_array('nombre',array_keys($this->datos)))
+ return $this->datos['nombre'];
+ else
+ return false;
+ }
- // +X2C Operation 139
/**
* @return void
* @access public
*/
- function getHoraDesde() // ~X2C
- {
- if(is_null($this->datos['hentra']))
- return new Hora($this->datos['hora_desde']);
- else
- return new Hora($this->datos['hentra']);
- }
- // -X2C
+ function getHoraDesde()
+ {
+ if(in_array('hora_desde',$this->datos))
+ return new MECON_Tiempo_Hora($this->datos['hora_desde']);
+ elseif(in_array('hentra',$this->datos))
+ return new MECON_Tiempo_Hora($this->datos['hentra']);
+ else
+ return false;
+ }
- // +X2C Operation 140
/**
* @return void
* @access public
*/
- function getHoraHasta() // ~X2C
- {
- if(is_null($this->datos['hsale']))
- return new Hora($this->datos['hora_hasta']);
- else
- return new Hora($this->datos['hsale']);
- }
- // -X2C
+ function getHoraHasta()
+ {
+ if(in_array('hora_hasta',$this->datos))
+ return new MECON_Tiempo_Hora($this->datos['hora_hasta']);
+ elseif(in_array('hsale',$this->datos))
+ return new MECON_Tiempo_Hora($this->datos['hsale']);
+ else
+ return false;
+ }
- // +X2C Operation 149
/**
* @return void
* @access public
*/
- function getCuil()// ~X2C
+ function getCuil()
{
- trigger_error('Not implemented!', E_USER_WARNING);
+ if(in_array('cuil',$this->datos))
+ {
+ $aux = $this->datos['cuil'];
+ $aux = preg_replace('/(\d{2})(\d*)(\d{1})/','$1-$2-$3',$aux);
+ return $aux;
+ }else
+ {
+ return false;
+ }
}
- // -X2C
- // +X2C Operation 151
/**
* @return void
* @access public
*/
- function getOtrosDatos()// ~X2C
+ function getOtrosDatos()
{
if(!is_null($this->datos['tipo_agente'])) {
- $aux['fecha_nac'] = $this->datos['fecha_nac'];
- $aux['edad'] = $this->datos['edad'];
- $aux['estado_civil'] = $this->datos['estado_civil'];
- $aux['domicilio'] = $this->datos['domicilio'];
- $aux['puerta'] = $this->datos['num_puerta'];
- $aux['piso'] = $this->datos['piso'];
- $aux['depto'] = $this->datos['depto'];
- $aux['localidad'] = $this->datos['localidad'];
- $aux['provincia'] = $this->datos['provincia'];
- $aux['calle1'] = $this->datos['calle1'];
- $aux['calle2'] = $this->datos['calle2'];
- $aux['cp'] = $this->datos['cp'];
- $aux['telefono'] = $this->datos['telefono'];
- $aux['cargo'] = $this->datos['cargo'];
- $aux['nivel'] = $this->datos['nivel'];
- $aux['grado'] = $this->datos['grado'];
- $aux['func_ejec'] = $this->datos['func_ejec'];
- $aux['obra_social'] = $this->datos['obra_social'];
- $aux['afiliado'] = $this->datos['afiliado'];
- $aux['conyuge'] = $this->datos['conyuge'];
- $aux['fecha_nac_conyuge'] = $this->datos['fecha_nac_cony'];
- $aux['tipo_doc_conyuge'] = $this->datos['tipodoc_cony'];
- $aux['nro_doc_cony'] = $this->datos['nrodoc_cony'];
+ $aux['tipo_doc'] = $this->datos['tipodoc'];
+ $aux['fecha_nac'] = $this->datos['fecha_nac'];
+ $aux['edad'] = $this->datos['edad'];
+ $aux['estado_civil'] = $this->datos['estado_civil'];
+ $aux['domicilio'] = $this->datos['domicilio'];
+ $aux['puerta'] = $this->datos['num_puerta'];
+ $aux['piso'] = $this->datos['piso'];
+ $aux['depto'] = $this->datos['depto'];
+ $aux['localidad'] = $this->datos['localidad'];
+ $aux['provincia'] = $this->datos['provincia'];
+ $aux['calle1'] = $this->datos['calle1'];
+ $aux['calle2'] = $this->datos['calle2'];
+ $aux['cp'] = $this->datos['cp'];
+ $aux['telefono'] = $this->datos['telefono'];
+ $aux['cargo'] = $this->datos['cargo'];
+ $aux['nivel'] = $this->datos['nivel'];
+ $aux['grado'] = $this->datos['grado'];
+ $aux['func_ejec'] = $this->datos['func_ejec'];
+ $aux['obra_social'] = $this->datos['obra_social'];
+ $aux['afiliado'] = $this->datos['afiliado'];
+ $aux['conyuge'] = $this->datos['conyuge'];
+ $aux['fecha_nac_conyuge'] = $this->datos['fecha_nac_cony'];
+ $aux['tipo_doc_conyuge'] = $this->datos['tipodoc_cony'];
+ $aux['nro_doc_cony'] = $this->datos['nrodoc_cony'];
+ return $aux;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * @param int $agente
+ *
+ * @return void
+ * @access public
+ */
+ function buscarAgente($agente)
+ {
+ $this->agente = $agente;
+ $sql = "SELECT *
+ FROM novedades.web003
+ WHERE nrodoc = ".$agente;
+ $result = $this->_db->query($sql);
+ if(DB::isError($result))
+ trigger_error($result->getMessage("query mal hecho"), E_USER_ERROR);
+ if($result->numRows() > 0) {
+ $this->datos = $result->fetchRow(DB_FETCHMODE_ASSOC);
+ } else {
+ $sql = "SELECT *
+ FROM Contratados.Contratados
+ WHERE nrodoc = ".$agente;
+ $result = $this->_db->query($sql);
+ if(DB::isError($result)) {
+ trigger_error($result->getMessage("query mal hecho"), E_USER_ERROR);
+ }
+ if($result->numRows() > 0) {
+ $this->datos = $result->fetchRow(DB_FETCHMODE_ASSOC);
+ } else {
+ return false;
+ }
}
- return $aux;
+ return true;
}
-} // -X2C Class :Agente
-?>
+}
+?>
\ No newline at end of file