• Jueves 28 de Marzo de 2024, 15:04

Autor Tema:  agradeceria una mano, para modificar la creacion de un pdf  (Leído 2937 veces)

pacorubio77

  • Miembro MUY activo
  • ***
  • Mensajes: 207
    • Ver Perfil
agradeceria una mano, para modificar la creacion de un pdf
« en: Martes 1 de Diciembre de 2009, 14:18 »
0
Hola , amigos estoy modificanco código, pero mi gran problema es que no se de donde viene, ya que no lo he echo yo, la cuestion es que me han encargado que cuando se imprime un pdf (para mayoristas) , una columna no le interesa "al jefe" que salga.

Preguntaba como me podeis ayudar..os enseño parte del código que yo creo que sería el encargado de crear dicho pdf?

necesito ayuda..urgente..

En cuanto me digan algo, pongo código para me ayuden.

muchas gracias, espero respuesta.

F_Tanori

  • Moderador
  • ******
  • Mensajes: 1919
  • Nacionalidad: mx
    • Ver Perfil
Re: agradeceria una mano, para modificar la creacion de un pdf
« Respuesta #1 en: Martes 1 de Diciembre de 2009, 22:58 »
0
pues necesitamos, saber que quieres hacer...


Saludos
" ExIsTo y A vEcEs PiEnSo "

NOTA:
===========================================================================================================================
Este foro es para ayudar, aprender, compartir... usenlo para eso,
NO SE RESUELVEN DUDAS POR MENSAJE PRIVADO Y MENOS POR CORREO
===========================================================================================================================

pacorubio77

  • Miembro MUY activo
  • ***
  • Mensajes: 207
    • Ver Perfil
Re: agradeceria una mano, para modificar la creacion de un pdf
« Respuesta #2 en: Martes 1 de Diciembre de 2009, 23:34 »
0
Lo que me han dicho que tengo que hacer es que tengo un formulario

Catalogo para mayorista
Catalago..et.ect
Catalogo para clientes

es decir según seas, se imprime de una forma el pdf (que contiene una serie de productos) con unas caracteristicas diferentes, por ejemplo el pdf para clientes tiene
Modelo      Caracteristicas       preciounidades  oferta

es decir cuatro columnas y me han dicho que no les interesa que salga la columna de preciounidades, es decir sería eliminarla.


Os puedo enseñar código que os haga falta...y explicando como lo interpreta, en los siguientes post, os lo muestro para que me ayudeis.

pacorubio77

  • Miembro MUY activo
  • ***
  • Mensajes: 207
    • Ver Perfil
Re: agradeceria una mano, para modificar la creacion de un pdf
« Respuesta #3 en: Martes 1 de Diciembre de 2009, 23:37 »
0
El codigo entero de todo es muy extenso, intentaré seleccionar las zonas de atencion y las partes que no se lo que hace, porque repito, yo estoy modificando código que me han dado y de anteriores trabajadores.

Decir en que consiste, existe un formulario, donde me salen una serie de productos, y segun si yo soy cliente mayorista o cliente minorista (vereis opciones), tiene que imprimirse el pdf de una forma u otra.

El pdf del cliente , no quiero que salga las cantidades.

En el siguiente post, pongo código

mirar este seria el fichero opciones.php, en dicho fichero es como si tuvieramos los formularios

Código: PHP
  1.  
  2. if(@mysql_num_rows($categories)>0)     {
  3. ?>
  4.     <tr>
  5.       <td valign="top" class="formAreaTitle"> </td>
  6.       <td class="main">
  7.                 <input name="box_opciones" type="radio" value="1" <?php if($opcion==1) { echo  "checked"; } ?>>Catalogo para Mayorista<br>
  8.                 <input name="box_opciones" type="radio" value="2" <?php if($opcion==2) { echo  "checked"; } ?>>Catalogo para Mayorista con fotos<br>
  9.                 <input name="box_opciones" type="radio" value="3" <?php if($opcion==3) { echo  "checked"; } ?>>Catalogo para Clientes<br>
  10.                 <input name="box_opciones" type="radio" value="4" <?php if($opcion==4) { echo  "checked"; } ?>>Catalogo para Clientes con fotos<br>    
  11.                 <input type="hidden" name="opcion" value="<?php echo $opcion; ?>">  
  12.       </td>
  13.      
  14.       <td class="main" valign="top">
  15.           <table width="100%" border="0">
  16.             <tr>
  17.                 <td>
  18.                 <input type="button" name="bot_generarHTML" value="Generar HTML" onClick="javascript:generarHTML();">
  19.                 <input type="button" name="bot_generarCSV" value="Generar CSV" onClick="javascript:generarCSV();">
  20.                 <input type="button" name="bot_generarPDF" value="Generar PDF" onClick="javascript:generarPDF();">
  21.                 </td>
  22.             </tr>
  23.             <tr>
  24.                 <td>
  25.                 <input type="button" name="bot_modPrecios" value="Modificar todos los precios seleccionados" onClick="javascript:modTodosPrecios();">
  26.                 </td>
  27.             </tr>
  28.             <tr>
  29.                 <td>
  30.                 <input type="button" name="bot_guardarMarcados" value="Guardar Productos Seleccionados" onClick="javascript:guardarProdSelec();">
  31.                 <input type="hidden" name="guardarMarcados" value="<?php echo $guardarMarcados ?>">
  32.                 </td>
  33.             </tr>
  34.         </table>
  35.       </td>
  36.     </tr>
  37.     <tr>
  38.         <td valign="top" class="formAreaTitle"></td>
  39.         <td colspan="2">
  40.             <a class="infoBoxNoticeContents" href="javascript:act_products()">Actualizar productos</a>            
  41. <?php if(@mysql_num_rows($products)>0) { ?>
  42.             | <a class="infoBoxNoticeContents" href="javascript:seleccionar_todo()">Marcar todos</a>
  43.             | <a class="infoBoxNoticeContents" href="javascript:deseleccionar_todo()">Marcar ninguno</a>
  44.  
  45.  

Como veis aqui se hace una llamada a onClick="javascript:generarPDF();">
eso se encuentra en un fichero javascript que es el siguiente

function generarHTML() { generarGenerico('HTML'); }
function generarCSV() { generarGenerico('CSV'); }
function generarPDF() { generarGenerico('PDF'); }

Código: PHP
  1.  
  2. function generarGenerico(tipo) {
  3.     var f = window.document.opciones;
  4.     var comp_products = false;
  5.     if(f && f.valor_products && f.box_products){
  6.         f.valor_products.value = "0";
  7.         var max = f.box_products.length;
  8.         for (var idx = 0; idx < max; idx++) {
  9.             if (eval("f.box_products[" + idx + "].checked") == true) {
  10.                 f.valor_products.value=f.valor_products.value+","+eval("f.box_products[" + idx + "].value");
  11.                 comp_products = true;
  12.            }
  13.         }
  14.     }
  15.     if (comp_products==true) {
  16.         f.action = "formato"+tipo+".php";
  17.         f.submit();
  18.     }else{
  19.         alert("Debe marcar algún producto para generar "+tipo);
  20.     }
  21. }  
  22.  
  23.  

y ahi tengo una pregunta

var f = window.document.opciones;
en esta sentencia f que guarda? cuanto vale f?

tengo tambien un fichero llamado conexion.php, que me hace la comunicacion con mysql, este seria el fichero

Código: PHP
  1.  
  2. <?php
  3. //Conexion con la base
  4. mysql_connect('emma-express.de', 'web90', 'LmT1950!');
  5. //selección de la base de datos con la que vamos a trabajar
  6. mysql_select_db('usr_web90_2');  //1=test 2=producción
  7.  
  8.  
  9. function f_gurdarMarcados($vc,$vp){
  10.     $sql = "
  11.        UPDATE     products B, products_to_categories A
  12.        SET     B.marcarCatalogo =0
  13.        WHERE     A.products_id = B.products_id
  14.        AND     A.categories_id IN (".$vc.")
  15.    ";
  16.     //echo $upd."<br>";
  17.     mysql_query($sql);
  18.        
  19.     $a = $vp;
  20.     $a = explode(",", $a);
  21.     $n = count($a);
  22.     $i = 1;
  23.     while ($n>$i)    {        
  24.         $sql = "
  25.            Update  products
  26.            Set        marcarCatalogo = 1
  27.            Where     products_id = ".$a[$i]."
  28.        ";
  29.         //echo $upd."<br>";
  30.         mysql_query($sql);
  31.         $i=$i+1;
  32.     }
  33. }
  34.  
  35. function f_cargarProductos($op,$sl,$vc,$vp=false){
  36.     $products=false;
  37.  
  38.     if ($op==1 or $op==2) {
  39.         $sql = "
  40. SELECT  p.products_id, p.products_model, p.products_price, pd.products_name, p.products_image, p.products_ve,
  41.        p2.precio AS precio2, p3.precio AS precio3,
  42.        cd.categories_id, cd.categories_name, tr.tax_rate, p.marcarCatalogo
  43. FROM     languages l inner join
  44.        products_description pd on (l.languages_id = pd.language_id) inner join
  45.        categories_description cd on (l.languages_id = cd.language_id) inner join
  46.        products p on (p.products_id = pd.products_id) inner join                    
  47.        categories c on (c.categories_id = cd.categories_id) inner join
  48.        products_to_categories pc on (pc.categories_id = c.categories_id and pc.products_id = p.products_id) left outer join
  49.        (SELECT products_id AS pid, customers_group_price AS precio FROM products_groups WHERE customers_group_id=4) p2 on (p2.pid = p.products_id)  inner join
  50.        (SELECT products_id AS pid, customers_group_price AS precio FROM products_groups WHERE customers_group_id=3) p3 on (p3.pid = p.products_id)  inner join
  51.        tax_class tc on (tc.tax_class_id = p.products_tax_class_id) inner join
  52.        tax_rates tr on (tr.tax_class_id = tc.tax_class_id)
  53. WHERE     l.languages_id = ".$sl."
  54.        and c.parent_id = 0
  55.        and cd.categories_id in (".$vc.")
  56.        ".($vp?" and p.products_id in (".$vp.") ":'')."
  57. ORDER BY c.sort_order, pd.products_name
  58.            ";
  59.     //                and p.products_status = '1'
  60.     }else{
  61.         $sql = "
  62. SELECT    p.products_id, p.products_model, p.products_price, pd.products_name, p.products_image, p.products_ve,
  63.        tr.tax_rate,
  64.        IF(s.status, s.specials_new_products_price, NULL) as specials_price,
  65.        IF(s.status, s.specials_new_products_price, p.products_price) as final_price,    
  66.        cd.categories_id, cd.categories_name,
  67.        p.marcarCatalogo
  68. FROM     languages l inner join
  69.        products_description pd on (l.languages_id = pd.language_id) inner join
  70.        categories_description cd on (l.languages_id = cd.language_id) inner join
  71.        products p on (p.products_id = pd.products_id) inner join
  72.        categories c on (c.categories_id = cd.categories_id) inner join
  73.        products_to_categories pc on (pc.categories_id = c.categories_id and pc.products_id = p.products_id) left outer join
  74.        specials s on (s.products_id = p.products_id) inner join
  75.        tax_class tc on (tc.tax_class_id = p.products_tax_class_id) inner join
  76.        tax_rates tr on (tr.tax_class_id = tc.tax_class_id)
  77. WHERE     l.languages_id = ".$sl."
  78.        and c.parent_id = 0
  79.        and cd.categories_id in (".$vc.")
  80.        ".($vp?" and p.products_id in (".$vp.") ":'')."
  81. ORDER BY c.sort_order, pd.products_name
  82.                ";
  83.     //                    and p.products_status = '1'
  84.     }
  85.     $products=mysql_query($sql);
  86.     return $products;
  87. }
  88.  
  89. function f_cargarCategorias($sl){
  90.     $categorias=mysql_query("
  91. SELECT     d.categories_id, d.categories_name
  92. FROM     categories c, categories_description d
  93. WHERE     c.categories_id = d.categories_id
  94.        AND d.language_id = ".$sl."
  95.        AND c.parent_id = 0
  96. ORDER BY c.sort_order
  97.    ");
  98.     return $categorias;
  99. }
  100.  
  101.  
  102. ?>
  103.  
  104.  

pacorubio77

  • Miembro MUY activo
  • ***
  • Mensajes: 207
    • Ver Perfil
Re: agradeceria una mano, para modificar la creacion de un pdf
« Respuesta #4 en: Martes 1 de Diciembre de 2009, 23:38 »
0
Existe otro fichero llamado funciones.php, que la parte de éste que valdría sería (valdria para entender el código)

Código: PHP
  1.  
  2. function f_cabecera_productos(){
  3.     $r='';
  4.     //$r.='<!-- Cabecera -->';
  5.     $r='';
  6.     $r.='<table border="0" cellpadding="5" cellspacing="0"><tr>';
  7.     $r.='<td>'.'<img src="logo-mate-tee-delicatino.jpg" border="0" />'.'</td>';
  8.     $r.='<td valign="bottom">';
  9.     $r.='<b>Delicatino GmbH</b><br />';
  10.     $r.='Neidenburger Str. 8<br />';
  11.     $r.='28207 Bremen<br />';
  12.     $r.='Deutschland<br />';
  13.     $r.='Tel: 0049 421 43 77 361<br />';
  14.     $r.='Fax:  0049 421 43 77 362<br />';
  15.     $r.='</td>';
  16.     $r.='</tr></table>';
  17.     return $r;
  18. }
  19.  
  20. function f_cabecera_tabla_productos(){
  21.     $r='';
  22.     $r.='<br>'."n";
  23.     //$r.='<!-- Cuerpo -->'."n";
  24.     $r.='<table border="1" cellpadding="5" cellspacing="0">'."n";
  25.     return $r;
  26. }
  27.  
  28. function f_pie_tabla_productos(){
  29.     $r='';
  30.     $r.='</table>'."n";
  31.     return $r;
  32. }
  33.  
  34.  
  35. function f_tag_imagen(){
  36.     global $g_tipo_exportacion;
  37.     global $opcion,$row,$products,$letzte_categories,$cabecera,$select_languages;
  38.     $r='';
  39.     $s=$row["products_image"];
  40.     if(strpos($s,'.jpg')>0){
  41.         if(false && $g_tipo_exportacion=='PDF' && strpos($s,'+')!==FALSE){
  42.             $s='';
  43.         }else{
  44.             $s='../../../catalog/images/'.$s;
  45.             if(!file_exists($s)){
  46.                 $s=str_replace('100.jpg','400.jpg',$s);
  47.                 if(!file_exists($s)){
  48.                     $s='';
  49.                 }
  50.             }
  51.             $s=str_replace('+','%2B',$s);
  52.         }
  53.     }else{
  54.         $s='';
  55.     }
  56.     if($s>''){
  57.         $r.='<img src="'.$s.'" border="0" alt="'.f_noc2($row["products_name"]).'" title="'.f_noc2($row["products_name"]).'" width="100" height="80" />';
  58.     }else{
  59.         $r.=' ';
  60.     }
  61.     return $r;
  62. }
  63.  
  64. function f_fila_producto(){
  65.     global $opcion,$row,$products,$letzte_categories,$cabecera,$select_languages;
  66.     $r='';
  67.    
  68.     if($opcion==1) {
  69.         if ($row["categories_name"]!=$letzte_categories) {    
  70.             $r.='<tr bgcolor="#C4C4C4">';
  71.             $r.='<td colspan="4"><font size="+2"><b>'.$row["categories_name"].'</b></font></td>';
  72.             $r.='</tr>';
  73.             $r.='<tr>';
  74.             $r.='<td><font size="+1"><b><i>'.$cabecera[$select_languages]["modelo"].'</i></b></font></td>';
  75.             $r.='<td><font size="+1"><b><i>'.$cabecera[$select_languages]["nombre"].'</i></b></font></td>';
  76.             $r.='<td><b><i>'.$cabecera[$select_languages]["unidad"].'</i></b></td>';
  77.             //$r.='<td><b><i>'.$cabecera[$select_languages]["precio1"].'</i></b></td>';
  78.             $r.='<td><b><i>'.$cabecera[$select_languages]["precio2"].'</i></b></td>';
  79.             //$r.='<td><b><i>'.$cabecera[$select_languages]["precio3"].'</i></b></td>';
  80.             $r.='</tr>';
  81.         }
  82.         $r.='<tr>';
  83.         $r.='<td><font size="+1">'.$row["products_model"].'</font></td>';
  84.         $r.='<td><font size="+1">'.$row["products_name"].'</font></td>';
  85.         $r.='<td align="right">'.f_guion($row["products_ve"]).'</td>';
  86.         //$r.='<td align="right">'.numeros::zeigenPrice($row['products_price'], $row['tax_rate']).'</td>';
  87.         $r.='<td align="right">'.numeros::formatear($row["precio2"],2,"").'</td>';
  88.         //$r.='<td align="right">'.numeros::formatear($row["precio3"],2,"").'</td>';
  89.         $r.='</tr>';
  90.         $letzte_categories=$row["categories_name"];
  91.     }elseif($opcion==2) {
  92.         if ($row["categories_name"]!=$letzte_categories) {    
  93.             $r.='<tr bgcolor="#C4C4C4">';
  94.             $r.='<td colspan="5"><font size="+2"><b>'.$row["categories_name"].'</b></font></td>';
  95.             $r.='</tr>';
  96.             $r.='<tr>';
  97.             $r.='<td><font size="+1"><b><i>'.$cabecera[$select_languages]["foto"].'</i></b></font></td>';
  98.             $r.='<td><font size="+1"><b><i>'.$cabecera[$select_languages]["modelo"].'</i></b></font></td>';
  99.             $r.='<td><font size="+1"><b><i>'.$cabecera[$select_languages]["nombre"].'</i></b></font></td>';
  100.             $r.='<td><b><i>'.$cabecera[$select_languages]["unidad"].'</i></b></td>';
  101.             //$r.='<td><b><i>'.$cabecera[$select_languages]["precio1"].'</i></b></td>';
  102.             $r.='<td><b><i>'.$cabecera[$select_languages]["precio2"].'</i></b></td>';
  103.             //$r.='<td><b><i>'.$cabecera[$select_languages]["precio3"].'</i></b></td>';
  104.             $r.='</tr>';
  105.         }
  106.         $r.='<tr>';
  107.         $r.='<td>';
  108.         $r.=f_tag_imagen();
  109.         $r.='</td>';
  110.         $r.='<td><font size="+1">'.$row["products_model"].'</font></td>';
  111.         $r.='<td><font size="+1">'.$row["products_name"].'</font></td>';
  112.         $r.='<td align="right">'.f_guion($row["products_ve"]).'</td>';
  113.         //$r.='<td align="right">'.numeros::zeigenPrice($row['products_price'], $row['tax_rate']).'</td>';
  114.         $r.='<td align="right">'.numeros::formatear($row["precio2"],2,"").'</td>';
  115.         //$r.='<td align="right">'.numeros::formatear($row["precio3"],2,"").'</td>';
  116.         $r.='</tr>';
  117.         $letzte_categories=$row["categories_name"];
  118.     }elseif($opcion==3) {
  119.         if ($row["categories_name"]!=$letzte_categories) {    
  120.             $r.='<tr bgcolor="#C4C4C4">';
  121.             $r.='<td colspan="5"><font size="+2"><b>'.$row["categories_name"].'</b></font></td>';
  122.             $r.='</tr>';
  123.             $r.='<tr>';
  124.             $r.='<td><font size="+1"><b><i>'.$cabecera[$select_languages]["modelo"].'</i></b></font></td>';
  125.             $r.='<td><font size="+1"><b><i>'.$cabecera[$select_languages]["nombre"].'</i></b></font></td>';
  126.             $r.='<td><b><i>'.$cabecera[$select_languages]["unidad"].'</i></b></td>';
  127.             $r.='<td><b><i>'.$cabecera[$select_languages]["precio1"].'</i></b></td>';
  128.             $r.='<td><b><i>'.$cabecera[$select_languages]["precio_especial"].'</i></b></td>';
  129.             $r.='</tr>';
  130.         }
  131.         $r.='<tr>';
  132.         $r.='<td>'.$row["products_model"].'</td>';
  133.         $r.='<td>'.$row["products_name"].'</td>';
  134.         $r.='<td align="right">'.f_guion($row["products_ve"]).'</td>';
  135.         $r.='<td align="right">'.(($row['specials_price']==NULL)?numeros::zeigenPrice($row['products_price'], $row['tax_rate']):"<s>".numeros::zeigenPrice($row['products_price'], $row['tax_rate'])."</s>").'</td>';
  136.         $s=numeros::zeigenPrice($row['specials_price'], $row['tax_rate']);
  137.         if($s=='') $s='---';
  138.         $r.='<td align="right">'.$s.'</td>';
  139.         $r.='</tr>';
  140.         $letzte_categories=$row["categories_name"];
  141.     }elseif($opcion==4) {
  142.         if ($row["categories_name"]!=$letzte_categories) {    
  143.             $r.='<tr bgcolor="#C4C4C4">';
  144.             $r.='<td colspan="6"><font size="+2"><b>'.$row["categories_name"].'</b></font></td>';
  145.             $r.='</tr>';
  146.             $r.='<tr>';
  147.             $r.='<td><font size="+1"><b><i>'.$cabecera[$select_languages]["foto"].'</i></b></font></td>';
  148.             $r.='<td><font size="+1"><b><i>'.$cabecera[$select_languages]["modelo"].'</i></b></font></td>';
  149.             $r.='<td><font size="+1"><b><i>'.$cabecera[$select_languages]["nombre"].'</i></b></font></td>';
  150.             $r.='<td><b><i>'.$cabecera[$select_languages]["unidad"].'</i></b></td>';
  151.             $r.='<td><b><i>'.$cabecera[$select_languages]["precio1"].'</i></b></td>';
  152.             $r.='<td><b><i>'.$cabecera[$select_languages]["precio_especial"].'</i></b></td>';
  153.             $r.='</tr>';
  154.         }
  155.         $r.='<tr>';
  156.         $r.='<td>';
  157.         $r.=f_tag_imagen();
  158.         $r.='</td>';
  159.         $r.='<td><font size="+1">'.$row["products_model"].'</font></td>';
  160.         $r.='<td><font size="+1">'.$row["products_name"].'</font></td>';
  161.         $r.='<td align="right">'.f_guion($row["products_ve"]).'</td>';
  162.         $r.='<td align="right">'.(($row['specials_price']==NULL)?numeros::zeigenPrice($row['products_price'], $row['tax_rate']):"<s>".numeros::zeigenPrice($row['products_price'], $row['tax_rate'])."</s>").'</td>';
  163.         $s=numeros::zeigenPrice($row['specials_price'], $row['tax_rate']);
  164.         if($s=='') $s='---';
  165.         $r.='<td align="right">'.$s.'</td>';
  166.         $r.='</tr>';
  167.         $letzte_categories=$row["categories_name"];
  168.     }
  169.  
  170.     return $r;
  171. }
  172.  
  173. ?>  
  174.  
  175.  

pacorubio77

  • Miembro MUY activo
  • ***
  • Mensajes: 207
    • Ver Perfil
Re: agradeceria una mano, para modificar la creacion de un pdf
« Respuesta #5 en: Martes 1 de Diciembre de 2009, 23:39 »
0
otro de los ficheros y a los que mireis el código os hará falta será formatoPDF.php
Código: PHP
  1.  
  2. // create new PDF document
  3. $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  4.  
  5. // set document information
  6. $pdf->SetCreator(PDF_CREATOR);
  7. $pdf->SetAuthor('Delicatino GmbH');
  8. $pdf->SetTitle('Catalog');
  9. $pdf->SetSubject('Mate-tee.de');
  10. $pdf->SetKeywords('Yerba mate');
  11.  
  12. // set default header data
  13. $pdf->SetHeaderData('logo-mate-tee-delicatino.jpg', 40, 'Delicatino GmbH', "Neidenburger Str. 8n28207 BremennDeutschlandnTel: 0049 421 43 77 361nFax:  0049 421 43 77 362");
  14.  
  15. // set header and footer fonts
  16. $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  17. $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  18.  
  19. // set default monospaced font
  20. $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  21.  
  22. //set margins
  23. $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP+15, PDF_MARGIN_RIGHT);
  24. $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
  25. $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
  26.  
  27. //set auto page breaks
  28. $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  29.  
  30. //set image scale factor
  31. $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO*2);
  32.  
  33. //set some language-dependent strings
  34. $pdf->setLanguageArray($l);
  35.  
  36. // ---------------------------------------------------------
  37.  
  38. // set font
  39. $pdf->SetFont('times', '', 8);
  40.  
  41. // add a page
  42. $pdf->AddPage();
  43.  
  44. // ---------------------------------------------------------
  45.  
  46. $r='';
  47.  
  48. $letzte_categories='';
  49. $products=f_cargarProductos($opcion,$select_languages,$valor_categories,$valor_products);
  50. //$r.=f_cabecera_productos();
  51. $r.=f_cabecera_tabla_productos(); //si elimino esta linea sólo me saldría por pantalla modelo
  52. $i=0;
  53. while($row=mysql_fetch_array($products)){
  54.     $r.=f_fila_producto();  //muestra las filas por producto
  55.     if(($i%12)==11) {
  56.         $r.=f_pie_tabla_productos();  //modifica cuadricula
  57.         $letzte_categories='';
  58.         $r=flt($r);
  59.         $r=utf8_encode($r);
  60.         $pdf->writeHTML($r, true, false, false, true, '');
  61.         $pdf->AddPage();
  62.         $r='';
  63.         $r.=f_cabecera_tabla_productos();
  64.     }
  65.     $i++;
  66. }
  67. @mysql_free_result($products);
  68.  
  69. $r.=f_pie_tabla_productos();
  70.  
  71. $r=flt($r);
  72. $r=utf8_encode($r);
  73.  
  74. $pdf->writeHTML($r, true, false, false, true, '');
  75.  
  76. // ---------------------------------------------------------
  77.  
  78. //Close and output PDF document
  79. $pdf->Output('catalog.pdf', 'I');
  80. //echo $r;
  81. //echo '<pre>';
  82. //print_r($pdf);
  83.  
  84. //============================================================+
  85. // END OF FILE                                                
  86. //============================================================+
  87.  
  88. ?>  
  89.  
  90.  

y el fichero cabecera.php, en el que se definen lo que se utilizará

Código: PHP
  1.  
  2. <?php
  3.  
  4. // guardar coomo iso
  5.  
  6. $g_url_base_images="http://www.mate-tee.de/catalog/images/";
  7.  
  8. $cabecera=array (
  9. "tipos" =>array  ( // Tipos de variables
  10.     "categories_name" => "S", // String=Cadena
  11.     "mostrar"=>"C",    // Chackbox=Casilla Sí/No
  12.     "mod"=>"A", // A=enlace
  13.     "foto"=>"F", // Foto
  14.     "modelo"=>"S",
  15.     "nombre"=>"T",  // Texto
  16.     "unidad"=>"I", // Integer
  17.     "precio1"=>"E", // Euro
  18.     "precio2"=>"E",
  19.     "precio3"=>"E",
  20.     "precio_final"=>"E",
  21.     "precio_especial"=>"E"
  22.    ),
  23. "3" =>array  ( // Español
  24.     "categories_name" => "Categoría",
  25.     "mostrar"=>"Mostrar",
  26.     "mod"=>"Modificar",
  27.     "foto"=>"Foto",
  28.     "modelo"=>"Modelo",
  29.     "nombre"=>"Descripción",
  30.     "unidad"=>"Unidadesrnpor paquete",
  31.     "precio1"=>"Precio", // Precio minorista
  32.     "precio2"=>"Precio mayorista", //"PreciornHaendler Drn+ ohne UiD Nr",            //cg=4 SELECT products_id AS pid, customers_group_price AS precio FROM products_groups WHERE customers_group_id=4
  33.     "precio3"=>"Precio mayorista", //"PreciornHaendler EU Arnmit Ident. Nummer",    //gc=3 SELECT products_id AS pid, customers_group_price AS precio FROM products_groups WHERE customers_group_id=3
  34.     "precio_final"=>"Preciornfinal",
  35.     "precio_especial"=>"Precio en oferta" // Precio especial
  36.    ),
  37. "2" =>array  ( //Deutsch
  38.     "categories_name" => "Produktkategorie",
  39.     "mostrar"=>"Zeigen",
  40.     "mod"=>"Modifizieren",
  41.     "foto"=>"Bild",
  42.     "modelo"=>"Art. Nr.",
  43.     "nombre"=>"Beschreibung",  
  44.     "unidad"=>"Verpackungseinheit",
  45.     "precio1"=>"Preis", // Precio minorista / Preis Uvp
  46.     "precio2"=>"Preis Händler", // "PreisrnHaendler Drn+ ohne UiD Nr",
  47.     "precio3"=>"Preis Händler", //"PreisrnHaendler EU Arnmit Ident.Nummer",
  48.     "precio_final"=>"Preis final",
  49.     "precio_especial"=>"Angebotspreis" // Precio especial / Preis especial
  50.    ),
  51. "1" =>array  ( //English
  52.     "categories_name" => "Category",
  53.     "mostrar"=>"Show",
  54.     "mod"=>"Modify",
  55.     "foto"=>"Image",
  56.     "modelo"=>"Number",
  57.     "nombre"=>"Name",
  58.     "unidad"=>"Packaging unit",
  59.     "precio1"=>"Price",
  60.     "precio2"=>"Wholesale price", //"PricernHaendler Drn+ ohne UiD Nr",
  61.     "precio3"=>"Wholesale price", //"PricernHaendler EU Arnmit Ident.Nummer",
  62.     "precio_final"=>"Precio final",
  63.     "precio_especial"=>"Special price" // Precio especial
  64.    )
  65. );
  66. //echo $cabecera["3"]["precio3"] //Saca en pantalla: "Precio a partir de 500 Euros"
  67. ?>
  68.  
  69.  

ESPERO ME AYUDEN, DESPUES DE LEER TANTO CÓDIGO

F_Tanori

  • Moderador
  • ******
  • Mensajes: 1919
  • Nacionalidad: mx
    • Ver Perfil
Re: agradeceria una mano, para modificar la creacion de un pdf
« Respuesta #6 en: Miércoles 2 de Diciembre de 2009, 10:44 »
0
Cita de: "pacorubio77"
...

Como veis aqui se hace una llamada a onClick="javascript:generarPDF();">
eso se encuentra en un fichero javascript que es el siguiente

function generarHTML() { generarGenerico('HTML'); }
function generarCSV() { generarGenerico('CSV'); }
function generarPDF() { generarGenerico('PDF'); }

Código: PHP
  1.  
  2. function generarGenerico(tipo) {
  3.     var f = window.document.opciones;
  4.     var comp_products = false;
  5.     if(f && f.valor_products && f.box_products){
  6.         f.valor_products.value = "0";
  7.         var max = f.box_products.length;
  8.         for (var idx = 0; idx < max; idx++) {
  9.             if (eval("f.box_products[" + idx + "].checked") == true) {
  10.                 f.valor_products.value=f.valor_products.value+","+eval("f.box_products[" + idx + "].value");
  11.                 comp_products = true;
  12.            }
  13.         }
  14.     }
  15.     if (comp_products==true) {
  16.         f.action = "formato"+tipo+".php";
  17.         f.submit();
  18.     }else{
  19.         alert("Debe marcar algún producto para generar "+tipo);
  20.     }
  21. }  
  22.  
  23.  

y ahi tengo una pregunta

var f = window.document.opciones;
en esta sentencia f que guarda? cuanto vale f?


f hace referencia a un formulario, el formulario que contiene los botones de generar debe llamarse opciones

las funciones f_cargarProductos y f_fila_producto son las que necesitas revisar para agregarle el caso correspondiente, para devolver las columnas que son necesarias en la consulta, y las que quieras mostrar en el pdf

Saludos
" ExIsTo y A vEcEs PiEnSo "

NOTA:
===========================================================================================================================
Este foro es para ayudar, aprender, compartir... usenlo para eso,
NO SE RESUELVEN DUDAS POR MENSAJE PRIVADO Y MENOS POR CORREO
===========================================================================================================================

pacorubio77

  • Miembro MUY activo
  • ***
  • Mensajes: 207
    • Ver Perfil
Re: agradeceria una mano, para modificar la creacion de un pdf
« Respuesta #7 en: Miércoles 2 de Diciembre de 2009, 12:56 »
0
comentarte un asunto, yo creo que el fichero que deberia tocar es el siguiente, dime si acierto o no
En este fichero imprime segun la opcion que cojas? te lo pregunto


Código: PHP
  1.  
  2. if($opcion==1) {
  3.     //Mostramos los registros
  4.     $data = array();
  5.     $header = array();
  6.     while ($row=mysql_fetch_array($products)){
  7.         foreach ($row as $key => $value) { $row[$key]=flt($value); }
  8.         if ($row["categories_name"]!=$letzte_categories) {
  9.             //Column titles
  10.             $header = array(
  11.                     $cabecera[$select_languages]['categories_name'],
  12.                     $cabecera[$select_languages]["modelo"],
  13.                     $cabecera[$select_languages]["nombre"],
  14.                     $cabecera[$select_languages]["unidad"],
  15.                     $cabecera[$select_languages]["precio1"],
  16.                     $cabecera[$select_languages]["precio2"],
  17.                     $cabecera[$select_languages]["precio3"],
  18.                 );
  19.             $types = array(
  20.                     $cabecera['tipos']['categories_name'],
  21.                     $cabecera['tipos']["modelo"],
  22.                     $cabecera['tipos']["nombre"],
  23.                     $cabecera['tipos']["unidad"],
  24.                     $cabecera['tipos']["precio1"],
  25.                     $cabecera['tipos']["precio2"],
  26.                     $cabecera['tipos']["precio3"],
  27.                 );
  28.             for($i = 0; $i < count($header); $i++)
  29.                 $header[$i]=utf8_encode($header[$i]);
  30.         }
  31.         //Data loading
  32.         $data[] = array(
  33.                 $row["categories_name"],
  34.                 $row["products_model"],
  35.                 $row["products_name"],
  36.                 $row["products_ve"],
  37.                 numeros::zeigenPrice($row['products_price'],$row['tax_rate']),
  38.                 numeros::formatear($row["precio2"],2,""),
  39.                 numeros::formatear($row["precio3"],2,"")
  40.             );
  41.         $letzte_categories=$row["categories_name"];
  42.     }
  43.     if(count($data)>0){ $pdf->ColoredTable($header,$types,$data,$opcion); } // print colored table
  44. }elseif($opcion==2){
  45.     //Mostramos los registros
  46.     while ($row=mysql_fetch_array($products))   {
  47.         foreach ($row as $key => $value) { $row[$key]=flt($value); }
  48.         if ($row["categories_name"]!=$letzte_categories) { 
  49.             //Column titles
  50.             $header = array(
  51.                     $cabecera[$select_languages]['categories_name'],
  52.                     $cabecera[$select_languages]["foto"],
  53.                     $cabecera[$select_languages]["modelo"],
  54.                     $cabecera[$select_languages]["nombre"],
  55.                     $cabecera[$select_languages]["unidad"],
  56.                     $cabecera[$select_languages]["precio1"],
  57.                     $cabecera[$select_languages]["precio2"],
  58.                     $cabecera[$select_languages]["precio3"]
  59.                 );
  60.             $types = array(
  61.                     $cabecera['tipos']['categories_name'],
  62.                     $cabecera['tipos']["foto"],
  63.                     $cabecera['tipos']["modelo"],
  64.                     $cabecera['tipos']["nombre"],
  65.                     $cabecera['tipos']["unidad"],
  66.                     $cabecera['tipos']["precio1"],
  67.                     $cabecera['tipos']["precio2"],
  68.                     $cabecera['tipos']["precio3"]
  69.                 );
  70.         }
  71.         //Data loading
  72.         $data[] = array(
  73.                 $row["categories_name"],
  74.                 $g_url_base_images.$row["products_image"],
  75.                 $row["products_model"],
  76.                 $row["products_name"],
  77.                 $row["products_ve"],
  78.                 numeros::zeigenPrice($row['products_price'], $row['tax_rate']),
  79.                 numeros::formatear($row["precio2"],2,""),
  80.                 numeros::formatear($row["precio3"],2,"")
  81.             );
  82.         $letzte_categories=$row["categories_name"];
  83.     }
  84.     if(count($data)>0){ $pdf->ColoredTable($header,$types,$data,$opcion); } // print colored table
  85. }elseif($opcion==3){
  86.     //Mostramos los registros
  87.     while ($row=mysql_fetch_array($products))   {
  88.         foreach ($row as $key => $value) { $row[$key]=flt($value); }
  89.         if ($row["categories_name"]!=$letzte_categories) { 
  90.             //Column titles
  91.             $header = array(
  92.                     $cabecera[$select_languages]['categories_name'],
  93.                     $cabecera[$select_languages]["modelo"],
  94.                     $cabecera[$select_languages]["nombre"],
  95.                     $cabecera[$select_languages]["unidad"],
  96.                     $cabecera[$select_languages]["precio1"],
  97.                     $cabecera[$select_languages]["precio_especial"]
  98.                 );
  99.             $types = array(
  100.                     $cabecera['tipos']['categories_name'],
  101.                     $cabecera['tipos']["modelo"],
  102.                     $cabecera['tipos']["nombre"],
  103.                     $cabecera['tipos']["unidad"],
  104.                     $cabecera['tipos']["precio1"],
  105.                     $cabecera['tipos']["precio_especial"]
  106.                 );
  107.         }
  108.         //Data loading
  109.         $data[] = array(
  110.                 $row["categories_name"],
  111.                 $row["products_model"],
  112.                 $row["products_name"],
  113.                 $row["products_ve"],
  114.                 ($row['specials_price']==NULL)?numeros::zeigenPrice($row['products_price'], $row['tax_rate']):numeros::zeigenPrice($row['products_price'], $row['tax_rate']),
  115.                 numeros::zeigenPrice($row['specials_price'], $row['tax_rate'])
  116.             );
  117.         $letzte_categories=$row["categories_name"];
  118.     }
  119.     if(count($data)>0){ $pdf->ColoredTable($header,$types,$data,$opcion); } // print colored table
  120. }elseif($opcion==4){
  121.     //Mostramos los registros
  122.     while ($row=mysql_fetch_array($products))   {
  123.         foreach ($row as $key => $value) { $row[$key]=flt($value); }
  124.         if ($row["categories_name"]!=$letzte_categories) { 
  125.             //Column titles
  126.             $header = array(
  127.                     $cabecera[$select_languages]['categories_name'],
  128.                     $cabecera[$select_languages]["foto"],
  129.                     $cabecera[$select_languages]["modelo"],
  130.                     $cabecera[$select_languages]["nombre"],
  131.                     $cabecera[$select_languages]["unidad"],
  132.                     $cabecera[$select_languages]["precio1"],
  133.                     $cabecera[$select_languages]["precio_especial"]
  134.                 );
  135.             $types = array(
  136.                     $cabecera['tipos']['categories_name'],
  137.                     $cabecera['tipos']["foto"],
  138.                     $cabecera['tipos']["modelo"],
  139.                     $cabecera['tipos']["nombre"],
  140.                     $cabecera['tipos']["unidad"],
  141.                     $cabecera['tipos']["precio1"],
  142.                     $cabecera['tipos']["precio_especial"]
  143.                 );
  144.         }
  145.         //Data loading
  146.         $data[] = array(
  147.                 $row["categories_name"],
  148.                 $row["products_image"],
  149.                 $row["products_model"],
  150.                 $row["products_name"],
  151.                 $row["products_ve"],
  152.                 ($row['specials_price']==NULL)?numeros::zeigenPrice($row['products_price'], $row['tax_rate']):numeros::zeigenPrice($row['products_price'], $row['tax_rate']),
  153.                 numeros::zeigenPrice($row['specials_price'], $row['tax_rate'])
  154.             );
  155.         $letzte_categories=$row["categories_name"];
  156.     }
  157.     if(count($data)>0){ $pdf->ColoredTable($header,$types,$data,$opcion); } // print colored table
  158. }
  159.  
  160.  
  161. @mysql_free_result($products);
  162.  
  163. //Close and output PDF document
  164. $pdf->Output('catalog.pdf', 'I');
  165.  
  166. //============================================================+
  167. // END OF FILE                                                
  168. //============================================================+
  169.  
  170.  
  171.  
  172.  

Si hay algo que no entiendes, comúnicamelo.

Un saludo.