0 && strlen($as_dato)<9){ for($i=strlen($as_dato); $i<9; $i++) $as_dato="0".$as_dato;} return $as_dato; } function str_squeeze($test) { return trim(ereg_replace( ' +', '', $test)); } $codigos=$_GET['codigos']; //$codigos=str_replace(" ", "", $codigos); switch ($codigos){ case '':{ require_once ("$base_path/includes/init.inc.php"); echo "
$msg[tejuelo_cdu] 
"; break;} default:{ $matriz=array(); $base_noheader = 1; require_once ("$base_path/includes/init.inc.php"); $codigos=str_squeeze($codigos); require("$base_path/includes/db_param.inc.php"); $link2 = @mysql_connect(SQL_SERVER, USER_NAME, USER_PASS) OR die("Error MySQL"); $size = count($matriz); //Determinamos margenes de los barcode $barcode_h_margin = ((LABEL_WIDTH-(BARCODE_WIDTH/72))/2); $barcode_v_margin = ((LABEL_HEIGHT-(BARCODE_HEIGHT/72))/2); // Creamos objeto PDF $pdf=new FPDF('P','in','A4'); // Metadata $pdf->SetAuthor('Lliurex'); $pdf->SetTitle('Tejuelo Lliurex'); //Otras características $pdf->SetDisplayMode('real'); // Mostramos el zoom al 100% // Añadimos una pagina al documento PDF $pdf->AddPage(); // Fijamos los márgenes $pdf->SetMargins(H_MARGIN, V_MARGIN); // Manejamos nosotros cuando la pagina debe acabar $pdf->SetAutoPageBreak(false); $pdf->AddFont('barcode', '', "barcode.php"); $y = V_MARGIN; //Esta variable sigue la posición y (vertical) $x = H_MARGIN; // Nueva fila, reseteamos x-position $new_row=1; $new_col=1; $q = 'SELECT expl_cote, expl_cb,autor.value FROM exemplaires, notices_fields_global_index,(SELECT `id_notice` , value FROM `notices_fields_global_index` WHERE `code_champ` =27 AND `code_ss_champ` =1) as autor WHERE expl_notice = notices_fields_global_index.id_notice and expl_notice=autor.id_notice AND code_champ =20 AND notices_fields_global_index.value LIKE \''.$codigos.'\' order by autor.value'; $resultData = @mysql_query($q, $link2); if (@mysql_num_rows($resultData) != 0) { //Recuperamos los datos de cada solicitud confirmada while ($rowData = mysql_fetch_array($resultData)) { //dato cote $cote=$rowData['expl_cote']; if (is_numeric($exe_cote)) { if (is_numeric($rowData['expl_cb'])) { if ((int) $exe_cote === (int) $rowData['expl_cb']) $cb=(int)$rowData['expl_cb']; else continue; } else continue; } else $cb=$rowData['expl_cb']; if ($new_row > 8) // Nueva pagina, reseteamos x-position { // Creamos una nueva pagina $pdf->AddPage(); $pdf->SetMargins(H_MARGIN, V_MARGIN); $pdf->SetAutoPageBreak(false); $y = V_MARGIN; $x = H_MARGIN; $new_row=1; $new_col=1; } $matriz2=explode(" ",$cote); $pdf->SetFont('Arial','B',10); $pdf->SetY($y); $pdf->SetX($x); if (strlen($matriz2[0])>6) $align=""; else $align="C"; $pdf->Cell(LABEL_WIDTH/5, ($barcode_v_margin*1),$matriz2[0],"LT", 0, $align); $pdf->Cell(LABEL_WIDTH-1, ($barcode_v_margin*1),"","TR", 0,'C'); $pdf->Ln(); $pdf->SetX($x); $pdf->Cell(LABEL_WIDTH/5, ($barcode_v_margin*1),$matriz2[1],"L", 0,'C'); $pdf->setFont('barcode',"",25); $pdf->Cell(LABEL_WIDTH-1, ($barcode_v_margin*1),"*".f_rellena_ceros($cb)."*","R", 0,'C'); $pdf->SetFont('Arial','B',10); $pdf->Ln(); $pdf->SetX($x); $pdf->Cell(LABEL_WIDTH/5, ($barcode_v_margin*1),$matriz2[2],"LB", 0,'C'); $pdf->Cell(LABEL_WIDTH-1, ($barcode_v_margin*1),f_rellena_ceros($cb),"BR", 0,'C'); if (($new_col%COLS_PER_PAGE)==0) { $x = H_MARGIN; $y += LABEL_HEIGHT-0.03; $new_row++; $new_col=1; } else { $new_col++; $x += LABEL_WIDTH-0.10; } } @mysql_free_result($resultData); }//else continue; // Desconexión de la Base de Datos mysql_close(); $pdf->Output('tejuelo_cdu.pdf', 'D'); // Salida es un pdf descargable } } ?>