git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_Intranet/trunk/src@1 e2b1556b-49f8-d141-9351-52d6861a72d9
82 lines
2.0 KiB
PHP
82 lines
2.0 KiB
PHP
<?php
|
|
/*
|
|
* Clase Agenda
|
|
*
|
|
* Gestiona la agenda personal de un usuario.
|
|
*
|
|
* 2008-10-21 (diego): Se crea la clase con los métodos necesarios para gestionar
|
|
* la agenda de un usuario.
|
|
*/
|
|
|
|
include_once("BD.php");
|
|
|
|
class Agenda{
|
|
private $usuario;
|
|
|
|
private $fecha;
|
|
|
|
private $agenda = null;
|
|
|
|
private $locale;
|
|
|
|
public function Agenda($usuario, $fecha, $locale){
|
|
$this->usuario = $usuario;
|
|
$this->fecha = date("Y-n-d",$fecha);
|
|
$this->locale = $locale;
|
|
}
|
|
|
|
|
|
public function getAgenda(){
|
|
if($this->agenda == null){
|
|
$agenda = array();
|
|
$consulta = "SELECT hora, notas FROM agenda WHERE oid = '".$this->usuario->getValor("oid")."' AND fecha = '".$this->fecha."'";
|
|
$bd = new BD();
|
|
$agenda = $bd->keyValueQuery($consulta, "hora", "notas");
|
|
if(gettype($agenda) == "array"){
|
|
$this->agenda = $agenda;
|
|
}else{
|
|
$this->agenda = array();
|
|
}
|
|
}
|
|
return $this->agenda;
|
|
}
|
|
|
|
public function getObservacion($hora){
|
|
if(($hora >= 0) && ($hora < 24)){
|
|
$this->getAgenda();
|
|
return $this->agenda[$hora];
|
|
}else{
|
|
$error = $this->locale['3022'];
|
|
throw new Exception($error);
|
|
return false;
|
|
exit;
|
|
}
|
|
}
|
|
|
|
public function setAgenda($hora, $notas){
|
|
if(($hora >= 0) && ($hora < 24)){
|
|
$consulta = "DELETE FROM agenda WHERE oid = '".$this->usuario->getValor("oid")."' AND fecha = '".$this->fecha."' AND hora = '".$hora."'";
|
|
$bd = new BD();
|
|
$bd->execQuery($consulta);
|
|
if($notas != ""){
|
|
$consulta = "INSERT INTO agenda (oid, fecha, hora, notas) VALUES ('".$this->usuario->getValor("oid")."', '".$this->fecha."', '".$hora."', '".$notas."')";
|
|
$bd = new BD();
|
|
if($bd->execQuery($consulta)){
|
|
$this->agenda[$hora] = $notas;
|
|
}else{
|
|
$error = $this->locale['3023'];
|
|
throw new Exception($error);
|
|
return false;
|
|
exit;
|
|
}
|
|
}
|
|
}else{
|
|
$error = $this->locale['3022'];
|
|
throw new Exception($error);
|
|
return false;
|
|
exit;
|
|
}
|
|
}
|
|
|
|
}
|
|
?>
|