Location: PHPKode > projects > Gestin > gestin/per/lib/AreasOrganizacionales.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('iAreasOrg.php');
class_exists('AreaOrganizacional') || require_once(ADT_PATH . 'AreaOrganizacional.class.php');

final class AreasOrganizacionales implements iAreasOrg  {
	
	public static function IngresarArea($nombre, $descripcion, $ubicacion, $telefonoContacto, $telAlterno, $responsableContacto, $mail)  {
		$cx = new Conexion(DB_SERVER,DB_NAME, false);
		$cx->conectar(DB_MIN_USER,DB_MIN_USER_PW);
		
		$nuevaArea = new AreaOrganizacional(0, $nombre, $descripcion, $ubicacion, $telefonoContacto, $telAlterno, $responsableContacto, $mail);
		if(isset($nuevaArea))  {
			$cx->insertar('areaorganizacional','arecod, arenom, aredes, areubi, aretelcon, aretelalt, arerescon, aremai',$nuevaArea,'');
			}		
		}
		
	public static function ModificarArea($id, $nuevoNombre, $nuevaDescripcion, $nuevaUbicacion, $nuevoTelefonoContacto, $nuevoTelAlterno, $nuevoResponsableContacto, $nuevoMail)  {
		$cx = new Conexion(DB_SERVER,DB_NAME,false);
		$cx->conectar(DB_MIN_USER,DB_MIN_USER_PW);
		$rs = $cx->consultar('areaorganizacional','*', "arecod=$id");
		
		if($rs != null)  {
			$areaModificada = new AreaOrganizacional($rs[0]['arecod'], $nuevoNombre, $nuevaDescripcion,
											  $nuevaUbicacion, $nuevoTelefonoContacto,
											  $nuevoTelAlterno, 
											  $nuevoResponsableContacto,$nuevoMail);
			$cx->actualizar('areaorganizacional','arenom,aredes,areubi,aretelcon,aretelalt,arerescon,aremai',
					        $areaModificada->toUpdateString(),"arecod=$id");
			}
		}
	
	public static function EliminarArea($id)  {
		$cx = new Conexion(DB_SERVER,DB_NAME,false);		
		$cx->conectar(DB_MIN_USER,DB_MIN_USER_PW);
		$rs = $cx->consultar('areaorganizacional','*',"arecod=$id");
		
		if($rs != null)  {
			$cx->eliminar('areaorganizacional',"arecod=$id");						
			}				
		}
		
	public static function ConsultarArea($id=0, $nombre='', $descripcion='', $ubicacion='', $telefonoContacto='', $telAlterno='', $responsableContacto='', $mail='')  {
		$cx = new Conexion(DB_SERVER,DB_NAME,false);				
		$cx->conectar(DB_MIN_USER,DB_MIN_USER_PW);
		$cond = array((($id != '') ? "arecod=$id " : ''),
			  (($nombre != '') ? "arenom LIKE '%$nombre%' " : ''),
			  (($descripcion != '') ? "aredes LIKE '%$descripcion%' " : ''),
			  (($ubicacion != '') ? "areubi LIKE '%$ubicacion%'" : ''),
			  (($telefonoContacto != '') ? "aretelcon LIKE '%$telefonoContacto%'" : ''),
			  (($telAlterno != '') ? "aretelalt LIKE '%$telAlterno%'" : ''),
			  (($responsableContacto != '') ? "arerescon LIKE '%$responsableContacto%'" : ''),
			  (($mail != '') ? "aremai LIKE '%$mail%'" : '')  );
		
		$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];
				}
			}
		}
		$rs = $cx->consultar('areaorganizacional','*',(($condicion == '') ? null : $condicion));

		if(isset($rs) && $rs != null)  {
			return $rs;
			}	
		}
	
	}
?>
Return current item: Gestin