Last active
December 29, 2015 02:39
-
-
Save ChrisGehm/7602024 to your computer and use it in GitHub Desktop.
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
<?php | |
include("../includes/connect.php"); | |
$denominacion = ""; | |
$id = ""; | |
$mes = date("m"); | |
$año = date("Y"); | |
if(!isset($_GET['id'])) | |
{ | |
exit("No se argumentó correctamente"); | |
} | |
$id = $_GET['id']; | |
$query = mysql_query("SELECT ft.Denominacion, ft.Concepto, ft.Debe, ft.Haber, ft.Fecha, ft.Observaciones | |
FROM fondos_terceros ft | |
WHERE ft.Activo = 1 AND ft.Id = '".$id."'"); | |
while ($ft = mysql_fetch_array($query)) | |
{ | |
$denominacion = $ft['Denominacion']; | |
} | |
?> | |
<table> | |
<form method="POST" action="mostrarmayor.php" > | |
<input type="hidden" name="id" value=<?php echo $id;?> /> | |
<tr> | |
<td><label>Cliente: </label> | |
<label name="denominacion"><?php echo $denominacion?></label> | |
<label>Periodo: </label> | |
<input type="number" name="periodo"/> | |
<label>Año: </label> | |
<input type="number" name="año" value=<?php echo $año;?> /> | |
<input type="submit" value="Buscar" ></td> | |
</tr> | |
</form> | |
</table> | |
<?php | |
if (isset($_POST['periodo'])) | |
{ | |
$periodo = $_POST['periodo']; | |
$añoelegido = $_POST['año']; | |
} | |
else | |
{ | |
$periodo = ""; | |
$añoelegido = $año; | |
} | |
include ('../includes/connect.php'); | |
?> | |
<?php | |
//mes actual | |
$saldoinicial = 0; | |
$primerdia = ""; | |
$sfinal = 0; | |
if($periodo == "" AND $añoelegido == $año) | |
{ | |
$sql = "SELECT ROUND(SUM(Debe-Haber),2) AS Saldo | |
FROM fondos_terceros | |
WHERE MONTH(Fecha) < '".$mes."' AND YEAR(Fecha) <= '".$añoelegido."' AND Activo = 1 AND Denominacion = '".$denominacion."'"; | |
$result = mysql_query("$sql",$conexion) or die(mysql_error()); | |
echo '<div class="labels">Trabajando sobre el período: ' .$mes. ' de ' .$añoelegido.'</div>'; | |
while($f = mysql_fetch_array($result)) | |
{ | |
setlocale(LC_MONETARY, 'it_IT'); | |
$saldoinicial = $f['Saldo']; | |
} | |
$primerdia = "01/$mes/$año"; | |
$ultimodia = date('t/m/Y', mktime(0, 0, 0, $mes, 1, $año)); | |
//Consulta | |
$busqueda = mysql_query("SELECT Id, date_format(ft.Fecha,'%d/%m/%Y') As Fecha, c.Grupo, ft.Denominacion, ft.Concepto, ft.Debe, ft.Haber, (Debe-Haber) As Saldo, ft.Observaciones | |
FROM Fondos_Terceros ft, clientes c | |
WHERE ft.Denominacion = c.Denominacion AND MONTH(Fecha) = '".$mes."' AND YEAR(Fecha) = '".$añoelegido."' AND ft.Activo = 1 AND ft.Denominacion = '".$denominacion."' | |
ORDER BY DATE_FORMAT(Fecha,'%Y/%m/%d')"); | |
?> | |
<!--Genero Tabla --> | |
<table> | |
<tr> | |
<td>Fecha</td> | |
<td>Grupo</td> | |
<td>Cliente</td> | |
<td>Concepto</td> | |
<td>Debe</td> | |
<td>Haber</td> | |
<td>Saldo</td> | |
<td>Observaciones</td> | |
</tr> | |
<?php | |
echo '<tr>'; | |
echo '<td>'.$primerdia.'</td>'; | |
echo '<td></td>'; | |
echo '<td></td>'; | |
echo '<td>Saldo Inicial</td>'; | |
echo '<td>0</td>'; | |
echo '<td>0</td>'; | |
echo '<td>'.$saldoinicial.'</td>';//muestra saldo acumulado | |
echo '<td></td>'; | |
while($f = mysql_fetch_array($busqueda)) | |
{ | |
setlocale(LC_MONETARY, 'it_IT'); | |
$debeformato = $f['Debe']; | |
$debefinal = number_format($debeformato, 2,',', '.' ); //formato moneda 1.000,00 | |
$haberformato = $f['Haber']; | |
$haberfinal = number_format($haberformato, 2,',', '.' ); //formato moneda 1.000,00 | |
$saldoformato = $f['Saldo']; | |
$saldofinal = number_format($saldoformato, 2,',', '.' ); //formato moneda 1.000,00 | |
$saldoinicial = $f['Saldo'] + $saldoinicial; //acumulo saldo y después lo muestro | |
$sformato = $saldoinicial; | |
$sfinal = number_format($sformato, 2,',', '.' ); //formato moneda 1.000,00 | |
echo '<tr>'; | |
echo '<td>'.$f['Fecha'].'</td>'; | |
echo '<td>'.$f['Grupo'].'</td>'; | |
echo '<td>'.$f['Denominacion'].'</td>'; | |
echo '<td>'.$f['Concepto'].'</td>'; | |
echo '<td>'.$debefinal.'</td>'; | |
echo '<td>'.$haberfinal.'</td>'; | |
echo '<td>'.$sfinal.'</td>';//muestra saldo acumulado | |
echo '<td>'.$f['Observaciones'].'</td>'; | |
}//end while | |
if ($sfinal == 0) | |
{ | |
echo '<tr>'; | |
echo '<td>'.$ultimodia.'</td>'; | |
echo '<td></td>'; | |
echo '<td></td>'; | |
echo '<td>Saldo Final</td>'; | |
echo '<td>0</td>'; | |
echo '<td>0</td>'; | |
echo '<td>'.$saldoinicial.'</td>';//muestra saldo acumulado | |
echo '<td></td>'; | |
echo '</tr>'; | |
}//end if | |
else | |
{ | |
echo '<tr>'; | |
echo '<td>'.$ultimodia.'</td>'; | |
echo '<td></td>'; | |
echo '<td></td>'; | |
echo '<td>Saldo Final</td>'; | |
echo '<td>0</td>'; | |
echo '<td>0</td>'; | |
echo '<td>'.$sfinal.'</td>';//muestra saldo acumulado | |
echo '<td></td>'; | |
echo '</tr>'; | |
} | |
} | |
?> | |
</table> | |
<?php | |
//lista indexada por período | |
if ($periodo != "" AND $año != "") | |
{ | |
$id = $_GET['id']; | |
echo $id; | |
$denominacion = $_POST['denominacion']; | |
$periodo = $_POST['periodo']; | |
$saldoinicial = 0; | |
$mes = $periodo; | |
$primerdia = "01/$mes/$año"; | |
$ultimodia = date('t/m/Y', mktime(0, 0, 0, $mes, 1, $año)); | |
$sql = "SELECT ROUND(SUM(Debe-Haber),2) AS Saldo | |
FROM fondos_terceros | |
WHERE Denominacion = '".$denominacion."' AND MONTH(Fecha) < '".$periodo."' AND YEAR(Fecha) <= '".$año."' AND Activo = 1"; | |
$result = mysql_query("$sql",$conexion) or die(mysql_error()); | |
echo 'Trabajando sobre el período: ' .$periodo. ' de ' .$año.''; | |
while($f = mysql_fetch_array($result)) | |
{ | |
setlocale(LC_MONETARY, 'it_IT'); | |
$saldoinicial = $f['Saldo']; | |
} | |
$busqueda = mysql_query("SELECT Id, date_format(fondos_terceros.Fecha,'%d/%m/%Y') As Fecha, clientes.Grupo, fondos_terceros.Denominacion, fondos_terceros.Concepto, fondos_terceros.Debe, fondos_terceros.Haber, (Debe-Haber) As Saldo, fondos_terceros.Observaciones | |
FROM Fondos_Terceros, clientes | |
WHERE fondos_terceros.Denominacion = '".$denominacion."' AND fondos_terceros.Denominacion = clientes.Denominacion AND MONTH(Fecha) = '".$mes."' AND YEAR(Fecha) = '".$año."' AND fondos_terceros.Activo = 1 | |
ORDER BY DATE_FORMAT(Fecha,'%Y/%m/%d')"); | |
?> | |
<!--Genero Tabla --> | |
<table> | |
<tr> | |
<td>Fecha</td> | |
<td>Grupo</td> | |
<td>Cliente</td> | |
<td>Concepto</td> | |
<td>Debe</td> | |
<td>Haber</td> | |
<td>Saldo</td> | |
<td>Observaciones</td> | |
</tr> | |
<?php | |
echo '<tr>'; | |
echo '<td>'.$primerdia.'</td>'; | |
echo '<td></td>'; | |
echo '<td></td>'; | |
echo '<td>Saldo Inicial</td>'; | |
echo '<td>0</td>'; | |
echo '<td>0</td>'; | |
echo '<td>'.$saldoinicial.'</td>';//muestra saldo acumulado | |
echo '<td></td>'; | |
while($f = mysql_fetch_array($busqueda)) | |
{ | |
setlocale(LC_MONETARY, 'it_IT'); | |
$debeformato = $f['Debe']; | |
$debefinal = number_format($debeformato, 2,',', '.' ); //formato moneda 1.000,00 | |
$haberformato = $f['Haber']; | |
$haberfinal = number_format($haberformato, 2,',', '.' ); //formato moneda 1.000,00 | |
$saldoformato = $f['Saldo']; | |
$saldofinal = number_format($saldoformato, 2,',', '.' ); //formato moneda 1.000,00 | |
$saldoinicial= $f['Saldo'] + $saldoinicial; //acumulo saldo y después lo muestro | |
$sformato = $saldoinicial; | |
$sfinal = number_format($sformato, 2,',', '.' ); //formato moneda 1.000,00 | |
echo '<tr>'; | |
echo '<td>'.$f['Fecha'].'</td>'; | |
echo '<td>'.$f['Grupo'].'</td>'; | |
echo '<td>'.$f['Denominacion'].'</td>'; | |
echo '<td>'.$f['Concepto'].'</td>'; | |
echo '<td>'.$debefinal.'</td>'; | |
echo '<td>'.$haberfinal.'</td>'; | |
echo '<td>'.$sfinal.'</td>';//muestra saldo acumulado | |
echo '<td>'.$f['Observaciones'].'</td>'; | |
}//end while | |
if ($sfinal == 0) | |
{ | |
echo '<tr>'; | |
echo '<td>'.$ultimodia.'</td>'; | |
echo '<td></td>'; | |
echo '<td></td>'; | |
echo '<td>Saldo Final</td>'; | |
echo '<td>0</td>'; | |
echo '<td>0</td>'; | |
echo '<td>'.$saldoinicial.'</td>';//muestra saldo acumulado | |
echo '<td></td>'; | |
echo '</tr>'; | |
} | |
else | |
{ | |
echo '<tr>'; | |
echo '<td>'.$ultimodia.'</td>'; | |
echo '<td></td>'; | |
echo '<td></td>'; | |
echo '<td>Saldo Final</td>'; | |
echo '<td>0</td>'; | |
echo '<td>0</td>'; | |
echo '<td>'.$sfinal.'</td>';//muestra saldo acumulado | |
echo '<td></td>'; | |
echo '</tr>'; | |
} | |
}//end if | |
?> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment