Mejoras generales.
[ecomupi.git] / include / fecha.php
blobcea06fa6de550eefb01cbbbdaa64400b41042d17
1 <?php
2 /* ConfiguraciĆ³n */
3 $MesInicio = 1;
4 $DiaInicio = 13;
5 $AnioInicio = 2009;
7 /*****************************/
8 function Combobox_catorcenas($nombre="catorcena", $default=NULL, $cuantas = 26) {
9 global $MesInicio, $DiaInicio, $AnioInicio;
10 if ( !$default ) { $default=time(); }
11 $inicio=Obtener_catorcena_cercana($default);
12 $s='<select name="'.$nombre.'">';
13 for ($i=0; $i<$cuantas; $i++){
14 $catorcena = strtotime("+13 day",$inicio);
15 if ( $default && $inicio == $default ) { $selected = ' selected="selected"'; } else { $selected = ""; }
16 $s.='<option value="'.$inicio.'"'.$selected.'>'."Del " . date('d-m-Y',$inicio) . ' al ' . date('d-m-Y',$catorcena) .'</option>';
17 $inicio = strtotime("+1 day",$catorcena);
19 $s.= '</select>';
20 return $s;
23 function Obtener_catorcena_cercana ($referencia = NULL ) {
24 global $MesInicio, $DiaInicio, $AnioInicio;
25 if ( !$referencia ) { $referencia = time(); }
26 $inicio=mktime(0,0,0,$MesInicio,$DiaInicio,$AnioInicio);
27 if ($referencia < $inicio ) { return NULL;}
28 do {
29 $catorcena = strtotime("+13 day",$inicio);
30 if (($referencia >= $inicio) && ($referencia <= $catorcena)) { return $inicio; }
31 $inicio = strtotime("+1 day",$catorcena);
32 } while ( 1 );