<?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("iIncidentes.php");
class_exists('Incidente') || require_once(ADT_PATH . 'Incidente.class.php');
class_exists('Conexion') || require_once(DBMS_PATH . 'Conexion.class.php');
class_exists('ConsultaVaciaException') || require_once(EXCEPTION_PATH . 'ConsultaVaciaException.class.php');
class_exists('LimiteIngresosException') || require_once(EXCEPTION_PATH . 'LimiteIngresosException.class.php');
final class Incidentes implements iIncidentes {
public static function IngresarIncidente($fechaDeOcurrencia, $fechaDescubierto, $descripcion, $fechaReportado,
$prioridad, $impacto, $efecto, $accionesTomadas, $estado) {
$cx = new Conexion('localhost','gestin',false);
$cx->conectar('temp','temp');
$nuevoIncidente = new Incidente(0, $fechaDeOcurrencia,$fechaDescubierto, $descripcion, $fechaReportado,
$prioridad, $impacto, $efecto, $accionesTomadas, $estado);
if($nuevoIncidente != null) {
$cx->insertar('incidentes',
'inccod,incfecocu,incfecdes,incdes,incfecrep,incpri,incimp,incefe,incacttom,incest',
$nuevoIncidente,'');
}
}
public static function ModificarIncidente($id,$fechaDeOcurrencia, $fechaDescubierto, $descripcion,
$prioridad, $impacto, $efecto,
$accionesTomadas, $estado) {
$cx = new Conexion('localhost','gestin',false);
$cx->conectar('temp','temp');
$rs = $cx->consultar('incidentes','*',"inccod=$id");
if($rs != null) {
$incidenteModificado = new Incidente($rs[0]['inccod'], $fechaDeOcurrencia, $fechaDescubierto,
$descripcion, '',
$prioridad, $impacto, $efecto, $accionesTomadas, $estado);
$cx->actualizar('incidentes',
'incfecocu,incfecdes,incdes,incpri,incimp,incefe,incacttom,incest',
$incidenteModificado->toUpdateString(),"inccod=$id");
}
}
public static function ProcesarIncidente($id, $idTecnico) {
//Implementar
}
public static function ControlarIngreso() {
$cx = new Conexion('localhost','gestin',false);
$cx->conectar('temp','temp');
$rs = $cx->consultar('usuarioincidente, incidentes, usuarios',
'count(*)',
"usuarios.usuci = usuarioincidente.usuci and usuarios.usuali = 'anonimo' and " .
"usuarioincidente.inccod = incidentes.inccod and incidentes.incfecrep >= curdate()");
if($rs[0]['count(*)'] == 5)
throw new LimiteIngresosException();
else
return $rs[0]['count(*)'];
}
public static function ConsultarIncidente($id=0,$fechaDeOcurrencia='', $fechaDescubierto='', $descripcion = '',$fechaReportado='',
$prioridad='', $impacto='', $efecto='', $accionesTomadas='', $estado='') {
$cx = new Conexion('localhost','gestin',false);
$cx->conectar('temp','temp');
$cond = array((($id != '') ? "inccod=$id" : ''),
(($fechaDeOcurrencia != '') ? "incfecocu >= '$fechaDeOcurrencia' " : ''),
(($fechaDescubierto != '') ? "incfecdes >= '$fechaDescubierto' " : ''),
(($fechaReportado != '') ? "incfecrep = '$fechaReportado' " : ''),
(($efecto != '') ? "incefe LIKE '%$efecto%' " : ''),
(($descripcion != '') ? "incdes LIKE '%$descripcion%' " : ''));
$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('incidentes','*',(($condicion == '') ? null : $condicion));
}
catch(ConsultaVaciaException $e) {
throw $e;
}
if(isset($rs) && $rs != null) {
return $rs;
}
}
public static function EliminarIncidente($id) {
$cx = new Conexion('localhost','gestin',false);
$cx->conectar('temp','temp');
$rs = $cx->consultar('incidentes','*',"inccod=$id");
if($rs != null) {
$cx->actualizar('incidentes',"incest","Descartado","inccod=$id");
}
}
public static function ResolverIncidente($id, $idTecnico, $actividades, $solucion, $estado, $leccAprendidas) {
//Implementar
}
}
?>