<?php require 'PDF_Label.php'; /*------------------------------------------------ To create the object, 2 possibilities: either pass a custom format via an array or use a built-in AVERY name ------------------------------------------------*/ // Example of custom format // $pdf = new PDF_Label(array('paper-size'=>'A4', 'metric'=>'mm', 'marginLeft'=>1, 'marginTop'=>1, 'NX'=>2, 'NY'=>7, 'SpaceX'=>0, 'SpaceY'=>0, 'width'=>99, 'height'=>38, 'font-size'=>14)); // Standard format $pdf = new PDF_Label('L7163'); $pdf->AddPage(); // Print labels for ($i = 1; $i <= 20; $i++) { $text = sprintf("%s\n%s\n%s\n%s %s, %s", "Laurent {$i}", 'Immeuble Toto', 'av. Fragonard', '06000', 'NICE', 'FRANCE'); $pdf->Add_Label($text); } $pdf->Output(); ?>
} } // On archive les nouveaux identifiants dans un fichier pdf (classe fpdf + script étiquettes) echo '<ul class="puce">' . NL; if (count($fcontenu_pdf_tab)) { $fnom = 'identifiants_' . $_SESSION['BASE'] . '_' . fabriquer_fin_nom_fichier__date_et_alea(); $pdf = new PDF_Label(array('paper-size' => 'A4', 'metric' => 'mm', 'marginLeft' => 5, 'marginTop' => 5, 'NX' => 3, 'NY' => 8, 'SpaceX' => 7, 'SpaceY' => 5, 'width' => 60, 'height' => 30, 'font-size' => 11)); $pdf->AddFont('Arial', '', 'arial.php'); $pdf->SetFont('Arial'); // Permet de mieux distinguer les "l 1" etc. que la police Times ou Courrier $pdf->AddPage(); $pdf->SetFillColor(245, 245, 245); $pdf->SetDrawColor(145, 145, 145); sort($fcontenu_pdf_tab); foreach ($fcontenu_pdf_tab as $text) { $pdf->Add_Label(To::pdf($text)); } FileSystem::ecrire_sortie_PDF(CHEMIN_DOSSIER_LOGINPASS . $fnom . '.pdf', $pdf); echo '<li><a target="_blank" href="' . URL_DIR_LOGINPASS . $fnom . '.pdf"><span class="file file_pdf">Archiver / Imprimer les identifiants modifiés (étiquettes <em>pdf</em>).</span></a></li>' . NL; echo '<li><label class="alerte">Les mots de passe, cryptés, ne seront plus accessibles ultérieurement !</label></li>' . NL; } // On affiche le bilan echo '<li><b>Résultat de l\'analyse et des opérations effectuées :</b></li>' . NL; echo '</ul>' . NL; echo '<table>' . NL; echo '<tbody>' . NL; echo '<tr><th colspan="3">Utilisateurs trouvés dans le fichier dont les identifiants ont été modifiés.</th></tr>' . NL; echo $lignes_mod ? $lignes_mod : '<tr><td colspan="3">Aucun</td></tr>' . NL; echo '</tbody><tbody>' . NL; echo '<tr><th colspan="3">Utilisateurs trouvés dans le fichier dont les identifiants n\'ont pas pu être modifiés.</th></tr>' . NL; echo $lignes_pb ? $lignes_pb : '<tr><td colspan="3">Aucun</td></tr>' . NL;
} //$sql="SELECT items.id,model,sn,sn3,itemtypeid,dnsname,ipv4,ipv6,label, agents.title as agtitle FROM items,agents ". // " WHERE agents.id=items.manufacturerid AND items.id in ($ids) order by itemtypeid, agtitle, model,sn,sn2,sn3"; $sql = "SELECT items.id,model,sn,sn3,itemtypeid,dnsname,ipv4,ipv6,label, agents.title as agtitle FROM items,agents " . " WHERE agents.id=items.manufacturerid AND items.id in ({$ids}) order by items.id"; $sth = db_execute($dbh, $sql); $idx = 0; $pdf = new PDF_Label(array('paper-size' => "{$labelpapersize}", 'metric' => 'mm', 'marginLeft' => $lmargin, 'marginTop' => $tmargin, 'NX' => $cols, 'NY' => $rows, 'SpaceX' => $hpitch - $lwidth, 'SpaceY' => $vpitch - $lheight, 'width' => $lwidth, 'height' => $lheight, 'font-size' => $fontsize)); $pdf->AddPage(); $pdf->SetAuthor('ITDB Asset Management'); $pdf->SetTitle('Items'); $pdf->setFontSubsetting(true); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); /* skip specified labels, to avoid printing on missing label positions on reused papers*/ for ($skipno = 0; $skipno < $labelskip; $skipno++) { $pdf->Add_Label("", "", 0, 255, "", 0, 0, 6, 6); } $pages = 0; for ($row = 1; $row <= $rows; $row++) { if ($pages > 30) { break; } for ($col = 1; $col <= $cols; $col++) { $r = $sth->fetch(PDO::FETCH_ASSOC); if (!$r) { break; } $idesc = $itypes[$r['itemtypeid']]['typedesc']; $id = sprintf("%04d", $r['id']); $dnsname = $r['dnsname']; $ipv4 = $r['ipv4'];
<?php define('FPDF_FONTPATH', 'fpdf_font/'); require_once 'PDF_Label.php'; /*------------------------------------------------ To create the object, 2 possibilities: either pass a custom format via an array or use a built-in AVERY name ------------------------------------------------*/ // Example of custom format /* $pdf = new PDF_Label(array('paper-size'=>'A4', 'metric'=>'mm', 'marginLeft'=>1, 'marginTop'=>1, 'NX'=>2, 'NY'=>7, 'SpaceX'=>0, 'SpaceY'=>0, 'width'=>99, 'height'=>38, 'font-size'=>14)); */ // Standard format $pdf = new PDF_Label('L7163'); $pdf->AddPage(); // Print labels for ($i = 1; $i <= 20; $i++) { $text = sprintf("%s\n%s\n%s\n%s %s, %s", "Laurent {$i}", 'Immeuble Toto', 'av. Fragonard', '06000', 'NICE', 'FRANCE'); $pdf->Add_Label($text, 0, "images/eoalogo250.jpg", 10); } $pdf->Output(); ?>
function print_certificate_labels($courseid, $students) { $students_arr = explode(',', $students); if (count($students_arr) > 0) { $pdf = new PDF_Label('L7163'); $pdf->AddPage(); if (!is_dir($this->labels_path)) { if (!mkdir($dir_path)) { die('Could not write to disk'); } // end if !mkdir($dir_path) } // end if !is_dir($dir_path) foreach ($students_arr as $userid) { $user_address = $this->get_user_address_data($userid); $text = sprintf("%s\n%s\n%s %s %s", "{$user_address->firstname} {$user_address->lastname}", "{$user_address->address}", "{$user_address->city} ,", "{$user_address->state}", "{$user_address->zip}"); $pdf->Add_Label($text); } // end foreach $now = time(); $path = $this->labels_path . "/" . $now . "_merged.pdf"; $pdf->Output($path, 'F'); } // end if count($students_arr)>0 return $now . "_merged.pdf"; }
function create_label($courseid, $userid) { $user_address = $this->get_user_address_data($userid); $pdf = new PDF_Label('L7163'); $pdf->AddPage(); $text = sprintf("%s\n%s\n%s\n%s", "{$user_address->firstname} {$user_address->lastname}", "{$user_address->address}", "{$user_address->state}/" . $user_address->city . "", "{$user_address->zip}"); $pdf->Add_Label($text); $dir_path = $this->cert_path . "/{$userid}"; if (!is_dir($dir_path)) { if (!mkdir($dir_path)) { die('Could not write to disk'); } // end if !mkdir($dir_path) } // end if !is_dir($dir_path) $path = $dir_path . "/label.pdf"; $pdf->Output($path, 'F'); }
$pdf = new PDF_Label('5160'); $pdf->Open(); $pdf->AddPage(); $pdf->Set_Font_Size(10); // Print labels... $labelQ = "SELECT d.cardNo, count(o.cardNo), \n\t\tCASE WHEN SUBSTR(address,-1) = '\n' THEN SUBSTR(address, 1, LENGTH(address)-1) ELSE address END AS address, \n\t\tcity, state, \n\t\tCASE WHEN LENGTH(zip)>5 THEN CONCAT(SUBSTR(zip,1,5), '-', SUBSTR(zip,5,4)) ELSE zip END AS zip \n\tFROM details AS d\n\tINNER JOIN owners AS o\n\tON d.cardNo = o.cardNo\n\tWHERE address IS NOT NULL AND address <> '' AND address <> 'n/a'\n\t\tAND city IS NOT NULL AND city <> ''\n\t\tAND state IS NOT NULL AND state <> ''\n\t\tAND zip IS NOT NULL AND zip <> '' AND zip <> 0\n\t\tAND d.noMail = false\n\t\tAND o.memType IN (1, 2, 7)\n\tGROUP BY cardNo\n\tORDER BY zip ASC"; $labelR = mysqli_query($DBS['comet'], $labelQ); if (!$labelR) { printf('Error: %s, Query: %s', mysqli_error($DBS['comet']), $labelQ); exit; } else { while (list($cardNo, $count, $address, $city, $state, $zip) = mysqli_fetch_row($labelR)) { $detailQ = "SELECT CONCAT(firstName, ' ', lastName) AS name FROM owners WHERE cardNo = {$cardNo} AND personNum = 1"; $detailR = mysqli_query($DBS['comet'], $detailQ); if (!$detailR) { printf('Error: %s, Query: %s', mysqli_error($DBS['comet']), $detailQ); exit; } list($name) = mysqli_fetch_row($detailR); if ($count != 1) { for ($i = 2; $i <= $count; $i++) { $detailQ = "SELECT CONCAT(' & ', firstName, ' ', lastName) AS name FROM owners WHERE cardNo = {$cardNo} AND personNum = {$i}"; $detailR = mysqli_query($DBS['comet'], $detailQ); list($newName) = mysqli_fetch_row($detailR); $name .= $newName; } } $pdf->Add_Label(sprintf("%s\n%s\n%s, %s, %s", substr($name, 0, 37), $address, $city, $state, $zip)); } $pdf->Output(); }
function update_users_addresses() { $certificates = array(); $query = "select * from mdl_certificates order by userid desc"; $result = $this->db->query($query); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $certificate = new stdClass(); foreach ($row as $key => $value) { $certificate->{$key} = $value; } $certificates[] = $certificate; } $pdf2 = new PDF_Label('L7163'); /* echo "<pre>"; print_r($certificates); echo "</pre><br>"; */ $i = 0; echo "Total Certificates found: " . count($certificates); $pdf = new mPDF('utf-8', 'A4-P'); foreach ($certificates as $certificate) { $user_address_block = $this->get_user_address_block($certificate->userid); echo "<br>-----------------------------------<br>"; echo "User ID: " . $certificate->userid . "<br>"; echo $user_address_block; $pdf2 = new PDF_Label('L7163'); $pdf2->AddPage(); $user_address = $this->get_user_address_data($certificate->userid); $text = sprintf("%s\n%s\n%s\n%s\n%s", "{$user_address->firstname} {$user_address->lastname}", "Phone: {$user_address->phone1}", "Email: {$user_address->email}", "{$user_address->address}", "{$user_address->city}, {$user_address->state}, {$user_address->zip}"); //$text = sprintf("%s\n%s\n%s\n%s", $user_address_block); $pdf2->Add_Label($text); $dir_path = $this->cert_path . "/{$certificate->userid}"; if (!is_dir($dir_path)) { if (!mkdir($dir_path)) { die('Could not write to disk'); } // end if !mkdir($dir_path) } // end if !is_dir($dir_path) $path = $dir_path . "/label.pdf"; $pdf2->Output($path, 'F'); $i++; /* * $pdf->WriteHTML($user_address_block); $dir_path = $this->cert_path . "/$certificate->userid"; if (!is_dir($dir_path)) { if (!mkdir($dir_path)) { die('Could not write to disk'); } // end if !mkdir($dir_path) } // end if !is_dir($dir_path) $path = $dir_path . "/label.pdf"; echo "Label location: ".$path."<br>"; $pdf->Output($path, 'F'); $pdf->Close(); echo "<br>Address label for User ($certificate->userid) was created"; echo "<br>-----------------------------------<br>"; $i++; } // end foreach * */ } // end foreach echo "<br>Total Labels created: " . $i . "<br>"; }