Skip to content

Instantly share code, notes, and snippets.

@ChrisGehm
Forked from ricardosiri68/generarrecibo.php
Created November 4, 2013 00:53
Show Gist options
  • Save ChrisGehm/7296580 to your computer and use it in GitHub Desktop.
Save ChrisGehm/7296580 to your computer and use it in GitHub Desktop.
<?php
$id="1";
$fecha = "29/12/2002";
$cliente = "Carlitos Bala";
$para = "Ernesto Sabato";
$concepto = " ... con cariño de carlitos .. una aspiradora";
$responsable = "Carlos Flavio Jacinto Bala";
$link = "http://www.poringa.net";
// Lee la plantilla
$plantilla = file_get_contents('plantilla.rtf');
$plantilla = addslashes($plantilla);
$plantilla = str_replace('\r','\\r',$plantilla);
$plantilla = str_replace('\t','\\t',$plantilla);
//$plantilla = stripslashes($plantilla);
$plantilla = str_replace("\'f1","'f1",$plantilla); // Letra ñ
$plantilla = str_replace("\'e1","'e1",$plantilla); // Letra á
$plantilla = str_replace("\'e9","'e9",$plantilla); // Letra é
$plantilla = str_replace("\'ed","'ed",$plantilla); // Letra í
$plantilla = str_replace("\'f3","'f3",$plantilla); // Letra ó
$plantilla = str_replace("\'fa","'fa",$plantilla); // Letra ú
$plantilla = str_replace("\'80","'80",$plantilla); // Letra € Euro
$plantilla = str_replace("\'º","'º",$plantilla); //
// $id = $_POST["id"];
// $fecha = $_POST["fecha"];
// $cliente = $_POST["cliente"];
// $para = $_POST["para"];
// $concepto = $_POST["concepto"];
// $responsable = $_POST["responsable"];
// Procesa la plantilla
eval( '$rtf = <<<EOF_RTF
' . $plantilla . '
EOF_RTF;
' );
// Guarda el RTF generado, el nombre del RTF en este caso sera el nombre.rtf
file_put_contents("recibos/$id-$cliente.rtf",$rtf);
$link= $id.'-'.$cliente;
echo '<a href="/envio/recibos/'.$link.'.rtf" >Descargar</a>';
echo '<br>';
echo '<br>';
echo '<a href="envio.php">Volver</a>';
?>
<?php
include("../includes/connect.php");
if(!isset($_GET['id']))
{
exit("Error");
}
$id = $_GET['id'];
$query = "SELECT Id, Fecha, Cliente, Para, Concepto, Responsable, Enviado_Por, Receptor, Observaciones
FROM envio
WHERE id = $id
LIMIT 1";
// ejecuto la consulta
$envio = mysql_query($query);
// veo si existe
if($envio)
{
$f = mysql_fetch_array($envio);
}
else
{
exit("No se encontro");
}
?>
<table>
<form method="POST" action="generarrecibo.php" enctype="multipart/form-data">
<input type="hidden" name="id" value=<?php echo $id;?> />
<td>Numero</td>
<td>Fecha</td>
<td>Cliente</td>
<td>Para</td>
<td>Concepto</td>
<td>Responsable</td>
<tr>
<td><input id="id" type="text" name="id" readonly value=<?php echo $f['Id']; ?> /></td>
<td><input id="fecha" type="text" name="fecha" readonly value=<?php echo $f['Fecha'];?> /></td>
<td><textarea name="cliente" readonly><?php echo $f['Cliente'];?></textarea></td>
<td><textarea name="para" ><?php echo $f['Para'];?></textarea></td>
<td><textarea name="concepto"><?php echo $f['Concepto'];?></textarea></td>
<td><input id="responsable" type="text" name="responsable" readonly value=<?php echo $f['Responsable']; ?> /></td>
</tr>
<td><input type="submit" value="Generar" >
</form>
</table>
$id $fecha
$cliente
$para
$concepto
$responsable
$id $fecha
$cliente
$para
$concepto
$responsable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment