Mostrar logo de compañía en información de cliente.
[ecomupi.git] / include / fecha.php
blobd83cd672edeb0d1605ef2819ae53a248bf29131f
1 <?php
2 /* Configuración */
3 $MesInicio = 1;
4 $DiaInicio = 13;
5 $AnioInicio = 2009;
7 /*****************************/
8 /* Constantes exportadas */
9 define ("_F_AMBAS", 0);
10 define ("_F_INICIOS", 1);
11 define ("_F_FINES", 2);
13 /*****************************/
14 function Combobox_catorcenas($nombre="catorcena", $default=NULL, $cuantas = 26, $tipo=_F_AMBAS) {
15 global $MesInicio, $DiaInicio, $AnioInicio;
16 if ( !$default ) { $default=time(); }
17 $inicio=Obtener_catorcena_cercana(mktime(0,0,0,1,1,date('Y')));
18 $s='<select name="'.$nombre.'">';
19 for ($i=0; $i<$cuantas; $i++){
20 $catorcena = strtotime("+13 day",$inicio);
21 if ( $inicio == $default || $catorcena == $default ) { $selected = ' selected="selected"'; } else { $selected = ""; }
23 switch ( $tipo ) {
24 case _F_AMBAS:
25 $s.='<option value="'.$inicio.'"'.$selected.'>'."Del " . date('d-m-Y',$inicio) . ' al ' . date('d-m-Y',$catorcena) .'</option>';
26 break;
27 case _F_INICIOS:
28 $s.='<option value="'.$inicio.'"'.$selected.'>'."Del " . date('d-m-Y',$inicio) .'</option>';
29 break;
30 case _F_FINES:
31 $s.='<option value="'.$catorcena.'"'.$selected.'>'.'al ' . date('d-m-Y',$catorcena) .'</option>';
32 break;
34 $inicio = strtotime("+1 day",$catorcena);
36 $s.= '</select>';
37 return $s;
40 function Obtener_catorcena_cercana ($referencia = NULL ) {
41 global $MesInicio, $DiaInicio, $AnioInicio;
42 if ( !$referencia ) { $referencia = mktime(0,0,0,date('n'),date('d'),date('y')); }
43 $inicio=mktime(0,0,0,$MesInicio,$DiaInicio,$AnioInicio);
44 if ($referencia < $inicio ) { $referencia = $inicio;}
45 do {
46 $catorcena = strtotime("+13 day",$inicio);
47 if (($referencia >= $inicio) && ($referencia <= $catorcena)) {return $inicio; }
48 $inicio = strtotime("+1 day",$catorcena);
49 } while ( 1 );
52 function Obtener_catorcena_siguiente() {
53 return strtotime("+14 day",Obtener_catorcena_cercana());
56 function Contar_catorcenas ($inicio=0, $fin=0 ) {
57 if ($fin)
58 return ceil((($fin-$inicio)/1209600));
59 return ceil((($inicio)/1209600));
62 function Fin_de_catorcena ($referencia = NULL) {
63 if (!$referencia) {return NULL;}
64 return strtotime("+13 day",$referencia);