Location: PHPKode > projects > Gestin > gestin/per/lib/Evidencias.class.php
<?php
/*
  GESTIN - Sistema de Gestion de Incidencias
  Copyright (C) 2007 Mathias Rodriguez, Diego Martorell, Matias Bisay
 
  This file is part of GESTIN.

  GESTIN 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 3 of the License, or
  (at your option) any later version.

  GESTIN 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
  along with GESTIN.  If not, see <http://www.gnu.org/licenses/>.
 */

include_once($_SERVER['DOCUMENT_ROOT'] . '/gestin/config.inc.php');
require_once('iEvidencia.php');

class_exists('Evidencia') || require_once(ADT_PATH . 'Evidencia.class.php');
class_exists('ConsultaVaciaException') || require_once(EXCEPTION_PATH . 'ConsultaVaciaException.class.php');
class_exists('ErrorConsultaException') || require_once(EXCEPTION_PATH . 'ErrorConsultaException.class.php');
class_exists('Conexion') || require_once(DBMS_PATH . 'Conexion.class.php');


final class Evidencias implements iEvidencia  {
	
	public static function IngresarEvidencia($descripcion, $uso)  {
		$cx = new Conexion(DB_SERVER,DB_NAME, false);
		$cx->conectar(DB_MIN_USER,DB_MIN_USER_PW);
		
		$nuevaEvidencia = new Evidencia(0, $descripcion, $uso);
		
		if($nuevaEvidencia != null)  {
			$cx->insertar('evidencias','evicod, evides, eviuso',$nuevaEvidencia,'');
			}
		}
	
	public static function EliminarEvidencia($id)  {
		$cx = new Conexion(DB_SERVER,DB_NAME,false);
		$cx->conectar(DB_MIN_USER,DB_MIN_USER_PW);
		
		$rs = $cx->consultar('evidencias','*',"evicod=$id");
		
		if($rs != null)  {
			$cx->eliminar('evidencias',"evicod=$id");
			}
		}
		 
	public static function ModificarEvidencia($id, $nuevaDescripcion, $nuevoUso)  {
		$cx = new Conexion(DB_SERVER,DB_NAME, false);
		$cx->conectar(DB_MIN_USER,DB_MIN_USER_PW);
		
		$rs = $cx->consultar('evidencias','*',"evicod=$id");
		
		if($rs != null)  {
			$evidenciaModificada = new Evidencia($rs[0]['evicod'],$nuevaDescripcion, $nuevoUso);
			
			$cx->actualizar('evidencias','evides,eviuso',
							$evidenciaModificada->toUpdateString(),"evicod=$id");
			}
		}
		
	public static function ConsultarEvidencia($id=0,$descripcion='',$uso='')  {
		$cx = new Conexion(DB_SERVER,DB_NAME,false);
		$cx->conectar(DB_MIN_USER,DB_MIN_USER_PW);
		
		$cond = array((($id != '') ? "evicod=$id" : ''),
					  (($descripcion != '') ? "evides LIKE '%$descripcion%' " : ''),
					  (($uso != '') ? "eviuso LIKE '%$uso%' " : ''));
		
		$condicion = '';
		$flags = 0;
		for($i = 0; $i < count($cond); $i++)  {
			if($cond[$i]!= '')  {			
				if ($flags==1)
					$condicion .= ' AND '.$cond[$i];
				else  {
					$flags = 1;
					$condicion .= $cond[$i];
					}
				}
			}
		
		try  {			
			$rs = $cx->consultar('evidencias','*',
							 	 "$condicion");	
			}
		catch(ErrorConsultaException $ecExc)  {
			throw $ecExc;
			}
		catch(ConsultaVaciaException $cvExc)  {
			throw new $cvExc;
			}
		
		if($rs != null)  {
			return $rs;		
			}
		}
	}
?>
Return current item: Gestin