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; } } } ?>