Skip to content

Instantly share code, notes, and snippets.

@ChrisGehm
Created November 3, 2013 23:00
Show Gist options
  • Save ChrisGehm/7295852 to your computer and use it in GitHub Desktop.
Save ChrisGehm/7295852 to your computer and use it in GitHub Desktop.
formgenerar.php
<?php
$id="";
$fecha = "";
$cliente = "";
$para = "";
$concepto = "";
$responsable = "";
$link = "";
// 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 = 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment