Skip to content

Instantly share code, notes, and snippets.

@ChrisGehm
Created November 3, 2013 20:32
Show Gist options
  • Save ChrisGehm/7294477 to your computer and use it in GitHub Desktop.
Save ChrisGehm/7294477 to your computer and use it in GitHub Desktop.
generarrecibo.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>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment