select_db($database);
function buscarDisponibilidad($dia, $mes, $anno, $mannana, $mysqli){
$consulta = «SELECT * FROM calendario WHERE dia = ‘».$dia.»‘ AND mes = ‘».$mes.»‘ AND anno = ‘».$anno.»‘ AND mannana = ‘».$mannana.»‘»;
$datos = mysqli_query($mysqli, $consulta);
while ($fila = mysqli_fetch_array($datos)){
return $fila[«estado»];
};
return 2;
}
function buscarDisponibilidadNew($dia, $mes, $anno, $mysqli){
$disponibilidad=»;
$consulta = «select mannana, estado from calendario where dia='».$dia.»‘ and mes='».$mes.»‘ and anno='».$anno.»‘
UNION
select * from(
select 0 as mannana, 2
UNION
select 1 as mannana, 2
UNION
select 2 as mannana, 2
UNION
select 3 as mannana, 2
UNION
select 4 as mannana, 2
UNION
select 5 as mannana, 2) as C2 where mannana not in(select mannana from calendario where dia='».$dia.»‘ and mes='».$mes.»‘ and anno='».$anno.»‘)
order by mannana»;
$datos = mysqli_query($mysqli, $consulta);
while ($fila = mysqli_fetch_array($datos)){
$disponibilidad.=$fila[«estado»];
};
return $disponibilidad;
}
function draw_calendar($month,$year,$nombres, $mysqli){
$calendar = »;
/* draw table */
$estilo_calendar = ‘font-family: arial; border-width: 2px; border-style:solid; border-color:#09837d’;
//$estilo_calendar = »;
$calendar .= ‘
‘;
/* table headings */
$headings = array(‘LU’,’MA’,’MI’,’JU’,’VI’,’SA’,’DO’);
$mes = «»;
switch ($month) {
case 1:
$mes .= «ENERO»;
break;
case 2:
$mes .= «FEBRERO»;
break;
case 3:
$mes .= «MARZO»;
break;
case 4:
$mes .= «ABRIL»;
break;
case 5:
$mes .= «MAYO»;
break;
case 6:
$mes .= «JUNIO»;
break;
case 7:
$mes .= «JULIO»;
break;
case 8:
$mes .= «AGOSTO»;
break;
case 9:
$mes .= «SEPTIEMBRE»;
break;
case 10:
$mes .= «OCTUBRE»;
break;
case 11:
$mes .= «NOVIEMBRE»;
break;
case 12:
$mes .= «DICIEMBRE»;
break;
}
$calendar.= ‘
‘.$mes.» DE «.$year.» |
«;
$calendar.= ‘
‘.implode(‘ |
‘,$headings).’ |
‘;
/* days and weeks vars now … */
$running_day = date(‘w’,mktime(0,0,0,$month,1,$year));
switch ($running_day) {
case 0:
$running_day = 6;
break;
case 1:
$running_day = 0;
break;
case 2:
$running_day = 1;
break;
case 3:
$running_day = 2;
break;
case 4:
$running_day = 3;
break;
case 5:
$running_day = 4;
break;
case 6:
$running_day = 5;
break;
}
$days_in_month = date(‘t’,mktime(0,0,0,$month,1,$year));
$days_in_this_week = 1;
$day_counter = 0;
$dates_array = array();
/* row for week one */
$calendar.= ‘
‘;
/* print «blank» days until the first of the current week */
for($x = 0; $x < $running_day; $x++):
$calendar.= '
|
‘;
$days_in_this_week++;
endfor;
/* keep going with days…. */
for($list_day = 1; $list_day <= $days_in_month; $list_day++):
$estadoNew = buscarDisponibilidadNew($list_day, $month, $year, $mysqli);
$calendar.= '
‘;
$calendar .= ‘
‘;
$calendar .= ‘
‘;
$calendar .= ‘
‘.$list_day.’ |
‘;
$calendar .= ‘
‘;
$calendar .= ‘
‘;
$estado = substr($estadoNew, 1,1);
switch ($estado) {
case 2:
$calendar .= ‘
‘;
$calendar .= ‘ ‘;
break;
case 0:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
case 1:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
case 3:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
}
$calendar .= ‘ |
‘;
$estado = substr($estadoNew, 3,1);
switch ($estado) {
case 2:
$calendar .= ‘
‘;
$calendar .= ‘ ‘;
break;
case 0:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
case 1:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
case 3:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
}
$calendar .= ‘ |
‘;
$estado = substr($estadoNew, 5,1);
switch ($estado) {
case 2:
$calendar .= ‘
‘;
$calendar .= ‘ ‘;
break;
case 0:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
case 1:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
case 3:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
}
$calendar .= ‘ |
‘;
$calendar .= ‘
‘;
$calendar .= ‘
‘;
$estado = substr($estadoNew, 0,1);
switch ($estado) {
case 2:
$calendar .= ‘
‘;
$calendar .= ‘ ‘;
break;
case 0:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
case 1:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
case 3:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
}
$calendar .= ‘ |
‘;
$estado = substr($estadoNew, 2,1);
switch ($estado) {
case 2:
$calendar .= ‘
‘;
$calendar .= ‘ ‘;
break;
case 0:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
case 1:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
case 3:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
}
$calendar .= ‘ |
‘;
$estado = substr($estadoNew, 4,1);
switch ($estado) {
case 2:
$calendar .= ‘
‘;
$calendar .= ‘ ‘;
break;
case 0:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
case 1:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
case 3:
$calendar .= ‘
| ‘;
$calendar .= ‘ ‘.$anestesistasSesion.’‘;
break;
}
$calendar .= ‘ |
‘;
$calendar .= ‘
‘;
$calendar .= ‘
‘;
$calendar.= ‘ |
‘;
if($running_day == 6):
$calendar.= ‘
‘;
if(($day_counter+1) != $days_in_month):
$calendar.= ‘
‘;
endif;
$running_day = -1;
$days_in_this_week = 0;
endif;
$days_in_this_week++; $running_day++; $day_counter++;
endfor;
/* finish the rest of the days in the week */
if($days_in_this_week < 8):
for($x = 1; $x <= (8 - $days_in_this_week); $x++):
$calendar.= '
|
‘;
endfor;
endif;
/* final row */
//$calendar.= ‘
|
‘;
/* end the table */
$calendar.= ‘
‘;
/* all done, return result */
return $calendar;
}
?>
Disponibilidad
Leyenda calendario
|
– DISPONIBLE |
|
– OCUPADO |
|
– Consultar |
|
– Sin disponibilidad |
Mañana: 8:30h-14:30h. Tarde: 16h-21h – Recomendamos citar los pacientes con sedación a primera hora de cada turno para facilitar disponibilidad. |
Cada día se divide en tres turnos de mañana y tres de tarde |