<?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('iEquiposTrab.php');
class_exists('Conexion') || require(DBMS_PATH . 'Conexion.class.php');
class_exists('EquipoDeTrabajo') || require(ADT_PATH . 'EquipoDeTrabajo.class.php');
final class EquiposDeTrabajo implements iEquiposTrab {
public static function IngresarEquipo($nombre, $descripcion, $fecha, $mail) {
$cx = new Conexion(DB_SERVER,DB_NAME,false);
$cx->conectar(DB_MIN_USER,DB_MIN_USER_PW);
$nuevoEquipo = new EquipoDeTrabajo(0, $nombre, $descripcion, $fecha, $mail);
if($nuevoEquipo != null) {
$cx->insertar('equiposdetrabajo','equcod,equnom,equdes,equfec,equmai',$nuevoEquipo,'');
}
}
public static function ModificarEquipo($id, $nuevoNombre, $nuevaDescripcion, $nuevaFecha, $nuevoMail) {
$cx = new Conexion(DB_SERVER,DB_NAME,false);
$cx->conectar(DB_MIN_USER,DB_MIN_USER_PW);
$rs = $cx->consultar('equiposdetrabajo','*',"equcod=$id");
if($rs != null) {
$equipoModificado =
new EquipoDeTrabajo($rs[0]['equcod'], $nuevoNombre,
$nuevaDescripcion,$nuevaFecha, $nuevoMail);
$cx->actualizar('equiposdetrabajo','equnom,equdes,equfec,equmai',
$equipoModificado->toUpdateString(),"equcod=$id");
}
}
public static function EliminarEquipo($id) {
$cx = new Conexion(DB_SERVER,DB_NAME,false);
$cx->conectar(DB_MIN_USER,DB_MIN_USER_PW);
$rs = $cx->consultar('equiposdetrabajo','*',"equcod=$id");
if($rs != null) {
$cx->eliminar('equiposdetrabajo',"equcod=$id");
}
}
public static function ConsultarEquipo($id = 0,$nom='',$fec='',$mai='',$des='') {
$cx = new Conexion(DB_SERVER,DB_NAME,false);
$cx->conectar(DB_MIN_USER,DB_MIN_USER_PW);
$equipo = new EquipoDeTrabajo($id,$nom,$fec,$mai,$des);
$datos = explode($equipo, ',');
$flags = false;
$cond = array((($id != '') ? "equcod=$id " : ''),
(($nom != '') ? "equnom LIKE '%$nom%' " : ''),
(($fec != '') ? "equfec >= '$fec' " : ''),
(($mai != '') ? "equmai LIKE '%$mai%' " : ''),
(($des != '') ? "equdes LIKE '%$des%' " : ''));
$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('equiposdetrabajo','*',"$condicion");
}
catch(ConsultaVaciaException $cvExc) {
throw $cvExc;
}
catch(ErrorConsultaException $ecExc) {
throw $ecExc;
}
if(isset($rs))
if($rs != null)
return $rs;
}
}
?>