-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
10022015 - se agregan archivos a repo
- Loading branch information
0 parents
commit cfff6b4
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
error_reporting(0); | ||
|
||
function nombreMes($numero_mes){ | ||
|
||
$mesArray = array( | ||
1 => "Enero", | ||
2 => "Febrero", | ||
3 => "Marzo", | ||
4 => "Abril", | ||
5 => "Mayo", | ||
6 => "Junio", | ||
7 => "Julio", | ||
8 => "Agosto", | ||
9 => "Septiembre", | ||
10 => "Octubre", | ||
11 => "Noviembre", | ||
12 => "Diciembre", | ||
13 => "Todos" | ||
); | ||
|
||
return $mesArray[$numero_mes]; | ||
} | ||
|
||
function imprimirUF($mes_usr,$anio){ | ||
|
||
$contenido = file_get_contents("http://www.sii.cl/pagina/valores/uf/uf".$anio.".htm"); | ||
|
||
$dom = new DOMDocument; | ||
$dom->loadHTML($contenido); | ||
|
||
foreach($dom->getElementsByTagName('tr') as $meses => $tr){ | ||
|
||
foreach($tr->getElementsByTagName('td') as $dias => $td){ | ||
$valores_por_mes[$dias][$meses] = $td->nodeValue; | ||
} | ||
} | ||
|
||
$array_uf = array(); | ||
foreach($valores_por_mes as $meses => $arreglo_dias){ | ||
|
||
$mes = intval($meses+1); | ||
if(strlen($mes)==1){ | ||
$mes = "0".$mes; | ||
}else{ | ||
$mes; | ||
} | ||
|
||
foreach($arreglo_dias as $dias => $valor){ | ||
if($mes == $mes_usr || $mes_usr == 13){ | ||
if (strpos($valor,'.') !== false) { | ||
if(strlen($dias)==1){ $dias = "0".$dias; }else{ $dias; } | ||
$fecha = $dias."-".$mes."-".$anio; | ||
$array_uf[$fecha] = $valor; | ||
} | ||
} | ||
} | ||
} | ||
|
||
echo '<pre>'; | ||
echo '<p> ' . nombreMes($mes_usr) . '</p>'; | ||
echo json_encode($array_uf); | ||
echo '</pre>'; | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<p>Seleccione mes</p> | ||
<form method="POST" action="<?php $_SERVER["PHP_SELF"] ?>"> | ||
<select name="mes" onchange=""> | ||
<option value="13">Todos</option> | ||
<option value="01">Enero</option> | ||
<option value="02">Febrero</option> | ||
<option value="03">Marzo</option> | ||
<option value="04">Abril</option> | ||
<option value="05">Mayo</option> | ||
<option value="06">Junio</option> | ||
<option value="07">Julio</option> | ||
<option value="08">Agosto</option> | ||
<option value="09">Septiembre</option> | ||
<option value="10">Octubre</option> | ||
<option value="11">Noviembre</option> | ||
<option value="12">Diciembre</option> | ||
</select> | ||
<input type="submit" value="enviar"> | ||
</form> | ||
|
||
<?php | ||
if($_POST["mes"]){ | ||
require 'obtener_uf.php'; | ||
return imprimirUF($_POST["mes"],date("Y")); | ||
} | ||
?> |