|
Directory : /home/zjabogados/public_html/Libs/ |
<?php
function controles_particulares($tb, $acc) {
$mensaje = '';
$nivel_de_error = 0;
/*
$nivel_de_error
---------------
1 = Warning
2 = Con Observaciones
3 = Error
*/
switch ($tb) {
case 'tb_ungido':
if ($acc == 'A' or $acc == 'M') {
$filtro_modificacion = '';
if ($acc == 'M') {
$filtro_modificacion = 'AND u.id_ungido <> '.$_POST['form_idvalor'];
}
$query = "Select fecha_desde, fecha_hasta
from tb_ungido u
where u.tb_persona = ".$_POST['tb_persona']."
and (
(u.fecha_desde <= ".FormatoFechaParaQuery($_POST['fecha_desde'])."
AND (u.fecha_hasta >= ".FormatoFechaParaQuery($_POST['fecha_desde'])."
OR u.fecha_hasta is null))
OR (u.fecha_desde >= ".FormatoFechaParaQuery($_POST['fecha_desde'])."
AND (u.fecha_desde <= ".FormatoFechaParaQuery($_POST['fecha_hasta'])."
OR ".FormatoFechaParaQuery($_POST['fecha_hasta'])." is null)))
$filtro_modificacion";
$MGMData = new MGMData($query);
if ($MGMData->cant_rows > 0) {
if ($nivel_de_error < 3) {
$nivel_de_error = 3;
}
for ($i=1; $i<=$MGMData->cant_rows; $i++) {
$MGMData->Next();
$mensaje .= 'Error !! Ya existe una instancia de actividad como Ungido para el periodo especificado mediante las fechas, Ud. pretende definir un periodo Desde: '.$_POST['fecha_desde'].' Hasta: '.$_POST['fecha_hasta'].' y ya existe un periodo definido Desde: '.FormatoFecha($MGMData->row['fecha_desde']).' Hasta: '.FormatoFecha($MGMData->row['fecha_hasta']).'<br><br>';
}
}
}
break;
/*
case 'tb_damnificado_art_junta_medica':
if ($acc == 'A' or $acc == 'M') {
$fecha_de_notificacion_de_incapacidad_dictaminada = $_POST['fecha_de_notificacion_de_incapacidad_dictaminada'];
if ($fecha_de_notificacion_de_incapacidad_dictaminada <> '') {
$titulo = "Mi titulo";
$donde = "Mi donde";
$comentario = "Mi comentario";
$FechaDesde = "2013-10-20";
$HoraDesde = "08:00";
$FechaDesde = "2013-10-20";
$HoraHasta = "09:00";
CrearEvento($titulo, $donde, $comentario, $FechaDesde, $HoraDesde, $FechaHasta, $HoraHasta);
}
}
break;
*/
/*
case 1:
print "i equals 1";
break;
case 2:
print "i equals 2";
break;
default:
print "i no es igual a 0, 1 o 2";
*/
}
return array ($mensaje, $nivel_de_error);
}
function CrearEvento($titulo, $donde, $comentario, $FechaDesde, $HoraDesde, $FechaHasta, $HoraHasta) {
require_once '../genericas/Zend/Loader.php';
// Declaramos las clases
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
// Nombre del servicio de Google Calendar
$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$email="adrizyz@gmail.com";
$password="az2013az2013";
$client = Zend_Gdata_ClientLogin::getHttpClient($email,$password,$service);
$service = new Zend_Gdata_Calendar($client);
$event= $service->newEventEntry();
// Populate the event with the desired information
// Note that each attribute is crated as an instance of a matching class
$event->title = $service->newTitle($titulo);
$event->where = array($service->newWhere($donde));
$event->content =
$service->newContent($comentario);
// Set the date using RFC 3339 format.
$tzOffset = "-08";
$when = $service->newWhen();
$when->startTime = "{$FechaDesde}T{$HoraDesde}:00.000{$tzOffset}:00";
$when->endTime = "{$FechaHasta}T{$HoraHasta}:00.000{$tzOffset}:00";
$event->when = array($when);
// Upload the event to the calendar server
// A copy of the event as it is recorded on the server is returned
$newEvent = $service->insertEvent($event);
}
?>