function saber_dia($nombredia) {
$dias = array('','Lunes','Martes','Miercoles','Jueves','Viernes','Sabado','Domingo');
$fecha = $dias[date('N', strtotime($nombredia))];
return $fecha;
}
// p�gina actual
$pagina_actual = parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH);
//verificamos si en la ruta nos han indicado el directorio en el que se encuentra
if ( strpos($pagina_actual, '/') !== FALSE )
//de ser asi, lo eliminamos, y solamente nos quedamos con el nombre y su extension
$pagina_actual = array_pop(explode('/', $pagina_actual));
// dia actual de este mes
$dia_actual = date("Y-m-d");
$dia_actual = substr($dia_actual,8,2);
// fecha defaul
$fecha_defaul = date("Y-m-01");
if ($_REQUEST['dia_vin']>0){
$dia_actual = $_REQUEST['dia_vin'];
$fecha_defaul = $_REQUEST['aa']."-".$_REQUEST['mm']."-01";
}
if ($_REQUEST['f_sig']==1){
//echo "entra... ";
$fecha_defaul = $_REQUEST['fdefa'];
$aa = substr($fecha_defaul,0,4);
$mm = substr($fecha_defaul,5,2);
$dd = substr($fecha_defaul,8,2);
$mm++;
if ($mm==13){
$aa++;
$mm="1";
}
if ($mm<10){
$mm = "0".$mm;
}
$fecha_defaul = "$aa-$mm-01";
//echo "fecha_defaul: ".$fecha_defaul;
}
if ($_REQUEST['f_ant']==1){
//echo "entra... ";
$fecha_defaul = $_REQUEST['fdefa'];
$aa = substr($fecha_defaul,0,4);
$mm = substr($fecha_defaul,5,2);
$dd = substr($fecha_defaul,8,2);
$mm--;
if ($mm==0){
$aa--;
$mm="12";
}
if ($mm<10){
$mm = "0".$mm;
}
$fecha_defaul = "$aa-$mm-01";
//echo "fecha_defaul: ".$fecha_defaul;
}
$dia_semana_inicio = date("w", strtotime("$fecha_defaul"));
//echo $dia_semana_inicio." ";
$aa = substr($fecha_defaul,0,4);
$mm = substr($fecha_defaul,5,2);
$dd = substr($fecha_defaul,2,2);
if ($mm=="01"){
$txt_mes = "Enero";
$maximo_dias = 31;
}
if ($mm=="02"){
$txt_mes = "Febrero";
$maximo_dias = 28;
if ($aa==2016 or $aa==2020 or $aa==2024 or $aa==2028 or $aa==2032 or $aa==2036 or $aa==2040){
$maximo_dias = 29;
}
}
if ($mm=="03"){
$txt_mes = "Marzo";
$maximo_dias = 31;
}
if ($mm=="04"){
$txt_mes = "Abril";
$maximo_dias = 30;
}
if ($mm=="05"){
$txt_mes = "Mayo";
$maximo_dias = 31;
}
if ($mm=="06"){
$txt_mes = "Junio";
$maximo_dias = 30;
}
if ($mm=="07"){
$txt_mes = "Julio";
$maximo_dias = 31;
}
if ($mm=="08"){
$txt_mes = "Agosto";
$maximo_dias = 31;
}
if ($mm=="09"){
$txt_mes = "Septiembre";
$maximo_dias = 30;
}
if ($mm=="10"){
$txt_mes = "Octubre";
$maximo_dias = 31;
}
if ($mm=="11"){
$txt_mes = "Noviembre";
$maximo_dias = 30;
}
if ($mm=="12"){
$txt_mes = "Diciembre";
$maximo_dias = 31;
}
?>
| Calendario |
| << |
- |
>> |
| L |
M |
M |
J |
V |
S |
D |
 |
$dia_mes = 0;
$sw = 0;
$dia_hoy = date("d");
for ($i=0; $i < 6; $i++){
?>
$xx = 1;
for ($x=0; $x < 7; $x++){
if ($xx==7){
$xx=0;
}
if ($xx==$dia_semana_inicio and $sw==0){
$dia_mes = 1;
$sw = 1;
}
if ($dia_mes>0){
$muesto = $dia_mes;
$dia_mes++;
}else{
$muesto = " ";
}
if ($x==6){
$color_dia="#FF0000";
}else{
$color_dia="#000000";
}
if ($dia_actual==$muesto){
$fondo_dia = "#BBE5F7";
}else{
$fondo_dia = "";
}
// ver si esta fecha tiene compromiso
$sql_anotacion = mysql_query("select * from mod_anotacion where fecha='$aa-$mm-$muesto'");
$num_anotacion = @mysql_numrows($sql_anotacion);
$dia_palabra = saber_dia("$aa-$mm-$muesto");
if (($num_anotacion>4) or ($dia_palabra=="Sabado" and $num_anotacion>1) or ($dia_palabra=="Domingo" and $num_anotacion>1)){
$fondo_dia = "";
//$color_ocupado = "#DC2D2D";
$color_ocupado = "#3CD966";
}else{
$color_ocupado = "#3CD966";
}
?>
| if ($muesto<=$maximo_dias and $muesto > 0){ ?>
if ($muesto > $dia_hoy){
?>
Ver Horas
}else{ ?>
Ver Horas
}
?>
} ?>
|
$xx++;
}
?>
}
?>
|
|
|
if ($dd<10){
$dd = "0".$dd;
}
$dia_actual;
if ($dia_actual==$dia_hoy){
//$dia_actual++;
if ($dia_actual==29 and $txt_mes=="Febrero"){
$dia_actual="1";
$txt_mes = "Marzo";
$mm++;
}
}else{
}
if ($_REQUEST['dia_vin']>0){
if ($dia_actual<10){
$dia_actual = "0".$dia_actual;
}
}
$fecha_espanol = "$dia_actual-$mm-$aa";
$fecha_eng = "$aa-$mm-$dia_actual";
$dia_palabra = saber_dia($fecha_eng);
?>
Horas Disponibles
,
$ran1 = rand(0,8);
$ran2 = rand(0,8);
$ran3 = rand(0,8);
$ran4 = rand(0,8);
$ran5 = rand(0,8);
$ran6 = rand(0,8);
// cuantas hay ocupadas
$sql_ocu = mysql_query("select * from mod_anotacion where fecha='$fecha_eng'");
$num_ocu = mysql_numrows($sql_ocu);
$inicio = "10:00";
$fin = "21:00";
// Convertimos a segundos
$hora_inicio = strtotime($inicio);
$hora_fin = strtotime($fin);
$contador = 0; // Para contar bloques de 5 minutos
for ($hora = $hora_inicio; $hora <= $hora_fin; $hora += 300) { // 300 segundos = 5 minutos
$hora_turno = date("H:i", $hora);
$contador++;
// Cada 6º bloque será bloqueado
$es_bloqueado = ($contador % 6 == 0) ? true : false;
//-- Buscar si ya está ocupado
$sql = mysql_query("SELECT * FROM mod_anotacion
WHERE fecha='$fecha_eng' AND hora='$hora_turno'");
$num = mysql_numrows($sql);
//-- Validación según tus reglas
if ($es_bloqueado) {
$txt_estado = "No disponible";
$bg_estado = "#ED5456";
} else if ($num == 0 && $fecha_eng == "2025-12-06") {
$txt_estado = "Disponible";
$bg_estado = "#7EF380";
} else {
$txt_estado = "No disponible";
$bg_estado = "#ED5456";
}
// Resultado (puedes imprimir como necesites)
if ($txt_estado=="Disponible" and $num==0 and ($fecha_eng=="2025-12-06")){
echo "";
}else{
echo "$hora_turno - $txt_estado ";
}
}
/*
for ($i=0; $i < 45; $i++){
if ($i==0){
$hora_turno = "10:00";
}
if ($i==1){
$hora_turno = "10:15";
}
if ($i==2){
$hora_turno = "10:30";
}
if ($i==3){
$hora_turno = "10:45";
}
if ($i==4){
$hora_turno = "11:00";
}
if ($i==5){
$hora_turno = "11:15";
}
if ($i==6){
$hora_turno = "11:30";
}
if ($i==7){
$hora_turno = "11:45";
}
if ($i==8){
$hora_turno = "12:00";
}
if ($i==9){
$hora_turno = "12:15";
}
if ($i==10){
$hora_turno = "12:30";
}
if ($i==11){
$hora_turno = "12:45";
}
if ($i==12){
$hora_turno = "13:00";
}
if ($i==13){
$hora_turno = "13:15";
}
if ($i==14){
$hora_turno = "13:30";
}
if ($i==15){
$hora_turno = "13:45";
}
if ($i==16){
$hora_turno = "14:00";
}
if ($i==17){
$hora_turno = "14:15";
}
if ($i==18){
$hora_turno = "14:30";
}
if ($i==19){
$hora_turno = "14:45";
}
if ($i==20){
$hora_turno = "15:00";
}
if ($i==21){
$hora_turno = "15:15";
}
if ($i==22){
$hora_turno = "15:30";
}
if ($i==23){
$hora_turno = "15:45";
}
if ($i==24){
$hora_turno = "16:00";
}
if ($i==25){
$hora_turno = "16:15";
}
if ($i==26){
$hora_turno = "16:30";
}
if ($i==27){
$hora_turno = "16:45";
}
if ($i==28){
$hora_turno = "17:00";
}
if ($i==29){
$hora_turno = "17:15";
}
if ($i==30){
$hora_turno = "17:30";
}
if ($i==31){
$hora_turno = "17:45";
}
if ($i==32){
$hora_turno = "18:00";
}
if ($i==33){
$hora_turno = "18:15";
}
if ($i==34){
$hora_turno = "18:30";
}
if ($i==35){
$hora_turno = "18:45";
}
if ($i==36){
$hora_turno = "19:00";
}
if ($i==37){
$hora_turno = "19:15";
}
if ($i==38){
$hora_turno = "19:30";
}
if ($i==39){
$hora_turno = "19:45";
}
if ($i==40){
$hora_turno = "20:00";
}
if ($i==41){
$hora_turno = "20:15";
}
if ($i==42){
$hora_turno = "20:30";
}
if ($i==43){
$hora_turno = "20:45";
}
if ($i==44){
$hora_turno = "21:00";
}
$sql = mysql_query("select * from mod_anotacion where fecha='$fecha_eng' and hora='$hora_turno'");
$num = mysql_numrows($sql);
$dia_palabra = saber_dia($fecha_eng);
if ($num_ocu<2 and $num==0 and $fecha_eng=="2025-12-06"){
$txt_estado = "Disponible";
$bg_estado = "#7EF380";
}else{
$txt_estado = "No disponible";
$bg_estado = "#ED5456";
}
/*
if ($dia_palabra=="Sabado" or $dia_palabra=="Domingo"){
//Fin de semana
if ($num_ocu<2 and $num==0 and ($ran1!=$i and $ran2!=$i and $ran3!=$i and $ran4!=$i and $ran5!=$i and $ran6!=$i)){
$txt_estado = "Disponible";
$bg_estado = "#7EF380";
}else{
$txt_estado = "No disponible";
$bg_estado = "#ED5456";
}
}else{
// dia se semana
if ($num==0 and ($ran1!=$i and $ran2!=$i and $ran3!=$i and $ran4!=$i and $ran5!=$i and $ran6!=$i) and $num_ocu < 5){
$txt_estado = "Disponible";
$bg_estado = "#7EF380";
}else{
$txt_estado = "No disponible";
$bg_estado = "#ED5456";
}
}
*/
?>
/*
}
*/
?>
|
|