function print_circ_list($abt_cb, $data) { global $msg, $charset; $data = $charset != "uft-8" ? pmb_utf8_encode($data) : $data; $serialcirc_circ_pdf_page = "\t\n\t\t<page backtop='2mm' backbottom='2mm' backleft='2mm' backright='5mm' >\t\n\t\t\t<table cellspacing='5'>\n\t\t \t<tr>\n\t\t\t\t\t<td style='width:540'>!!tableau_left!!</td>\n\t\t\t\t\t<td style='width:540'>!!tableau_rigth!!</td>\n\t\t \t</tr>\n\t\t\t</table>\n\t\t</page>\n\t\t\t"; $serialcirc_circ_pdf_diffusion = "\t\t\t\n\t\t\t<table class='listcirc' style='width:100%; border: solid 1px black; background: #E7E7E7; text-align: center; font-size: 8pt;' cellspacing='0'>\n\t \t\t<tr>\n\t \t\t\t<td colspan='4'style='height:30'><strong>!!periodique!!</strong></td>\n\t \t\t</tr>\n\t \t\t<tr>\n\t \t\t\t<td align='left' style='height:30'>DATE/N <br/> <br/></td>\n\t \t\t\t<td colspan='3' align='left'>DEPART DOC <br/> <br/></td>\n\t \t\t</tr>\n\t \t\t<tr>\n\t \t\t\t<td>CIRCUIT DE CONSULTATION</td>\n\t \t\t\t<td>DATE DE RECEPTION</td>\n\t \t\t\t<td>A FAIRE PASSE LE</td>\n\t \t\t\t<td style='width: 120'>VISA</td>\n\t \t\t</tr>\n\t \t\t!!destinataires!!\n\t \t\t<tr>\n\t \t\t\t<td colspan='4' style='height:20'>MERCI DE BIEN VOULOIR RESPECTER LES DELAIS DE CONSULTATION</td>\n\t \t\t</tr>\n\t\t\t</table>\t\t\n\t\t"; $serialcirc_circ_pdf_diff = "\n\t\t\t\t\t<tr>\n\t\t \t\t\t<td style='width:70'>!!destinataire!!</td>\n\t\t \t\t\t<td style='width:70'></td>\n\t\t \t\t\t<td style='width:70'></td>\n\t\t \t\t\t<td style='width:70'></td>\n\t\t \t\t</tr>"; $all_tpl = ""; $pair = 0; $abt_cb_list = array(); foreach ($abt_cb as $circ_cb) { $abt_cb_list[] = $circ_cb + 0; } $count_values = array_count_values($abt_cb_list); foreach ($data as $abt) { for ($count = 0; $count < $count_values[$abt["abt_id"]]; $count++) { $tpl = $serialcirc_circ_pdf_diffusion; $tpl = str_replace("!!periodique!!", strtoupper($abt["tit1"]), $tpl); $all_tpl_diff = ""; foreach ($abt["diff"] as $diff) { $tpl_diff = $serialcirc_circ_pdf_diff; if ($diff["is_group"]) { $group = explode(" - ", $diff["group_name"]); if (count($group) == 2) { $destinataire = strtoupper($group[0]) . "<br/>( " . strtoupper($group[1]) . " )"; } else { $destinataire = strtoupper($diff["group_name"]); } if (count($diff["group"])) { foreach ($diff["group"] as $elt_group) { if ($elt_group["is_responsable"]) { $destinataire .= "<br/>" . strtoupper($elt_group['nom']); } } } } else { $destinataire = strtoupper($diff["nom"] . " " . $diff["prenom"]); } $tpl_diff = str_replace("!!destinataire!!", $destinataire, $tpl_diff); $all_tpl_diff .= $tpl_diff; } for ($i = count($abt["diff"]); $i < 7; $i++) { $tpl_diff = $serialcirc_circ_pdf_diff; $tpl_diff = str_replace("!!destinataire!!", "<br/> <br/> <br/>", $tpl_diff); $all_tpl_diff .= $tpl_diff; } $tpl = str_replace("!!destinataires!!", $all_tpl_diff, $tpl); if (!$pair) { $pair = 1; $tpl_page = $serialcirc_circ_pdf_page; $tpl_page = str_replace("!!tableau_left!!", $tpl, $tpl_page); } else { $pair = 0; $tpl_page = str_replace("!!tableau_rigth!!", $tpl, $tpl_page); $all_tpl .= $tpl_page; } } } $tpl_page = str_replace("!!tableau_rigth!!", "", $tpl_page); if ($pair) { $all_tpl .= $tpl_page; } $style = "\t\t\n\t\t<style type='text/css'>\n\t\ttable.listcirc {\n\t\t\tborder-width: 5px;\n\t\t\tborder-spacing: 0px;\n\t\t\tborder-style: outset;\n\t\t\tborder-color: gray;\n\t\t\tborder-collapse: separate;\n\t\t\tbackground-color: rgb(255, 250, 250);\n\t\t}\n\t\ttable.listcirc th {\n\t\t\tborder-width: 1px;\n\t\t\tpadding: 4px;\n\t\t\tmargin:0px;\n\t\t\tborder-style: solid;\n\t\t\tborder-color: gray;\n\t\t\tbackground-color: white;\n\t\t\t-moz-border-radius: ;\n\t\t}\n\t\ttable.listcirc td {\n\t\t\tborder-width: 1px;\n\t\t\tpadding: 4px;\n\t\t\tmargin:0px;\n\t\t\tborder-style: solid;\n\t\t\tborder-color: gray;\n\t\t\tbackground-color: white;\n\t\t\t-moz-border-radius: ;\n\t\t}\n\t\t</style>\n\t"; // print $style.$all_tpl;exit; $html2pdf = new HTML2PDF('L', 'A4', 'fr'); $html2pdf->WriteHTML($style . $all_tpl); $html2pdf->Output('diffusion.pdf', 'D'); }
function do_import() { global $dbh, $msg, $charset; $erreur = 0; $userfile_name = $_FILES['f_fichier']['name']; $userfile_temp = $_FILES['f_fichier']['tmp_name']; $userfile_moved = basename($userfile_temp); $userfile_name = preg_replace("/ |'|\\|\"|\\//m", "_", $userfile_name); // création if (move_uploaded_file($userfile_temp, './temp/' . $userfile_moved)) { $fic = 1; } if (!$fic) { $erreur = $erreur + 10; } else { $fp = fopen('./temp/' . $userfile_moved, "r"); $contenu = fread($fp, filesize('./temp/' . $userfile_moved)); if (!$fp || $contenu == "") { $erreur = $erreur + 100; } fclose($fp); } //récupération et affectation des lignes $input_main_tmp = ''; $input_sub_tmp = ''; $input_locations_tmp = ''; $input_charset_tmp = ''; $input_cours = ''; $tmpLignes = explode("\n", $contenu); foreach ($tmpLignes as $ligne) { if (preg_match('`^\\#main\\#=(.+)`', $ligne, $out)) { $cours = 'input_main'; $input_main_tmp = $out[1]; } elseif (preg_match('`^\\#sub\\#=(.+)`', $ligne, $out)) { $cours = 'input_sub'; $input_sub_tmp = $out[1]; } elseif (preg_match('`^\\#locations\\#=(.+)`', $ligne, $out)) { $cours = 'input_locations'; $input_locations_tmp = $out[1]; } elseif (preg_match('`^\\#charset\\#=(.+)`', $ligne, $out)) { $cours = 'input_charset'; $input_charset_tmp = $out[1]; } else { switch ($cours) { case 'input_main': $input_main_tmp .= "\n" . $ligne; break; case 'input_sub': $input_sub_tmp .= "\n" . $ligne; break; case 'input_locations': $input_locations_tmp .= "\n" . $ligne; break; case 'input_charset': $input_charset_tmp .= "\n" . $ligne; break; default: $erreur = 5; break; } } } //on recrée les données $input_main = unserialize($input_main_tmp); $input_sub = unserialize($input_sub_tmp); $input_locations_tmp = unserialize($input_locations_tmp); $input_locations = array(); if (is_array($input_locations_tmp) && count($input_locations_tmp)) { foreach ($input_locations_tmp as $value) { $input_locations[$value["id_location"]] = $value["lib_location"]; } } $input_charset = $input_charset_tmp; //on vérifie if (!count($input_main) || !count($input_sub) || !trim($input_charset)) { $erreur = 5; } if (!$erreur) { //valeurs à connaitre $doctype = new marc_list('doctype'); $locations = array(); $res = pmb_mysql_query("SELECT idlocation, location_libelle FROM docs_location ORDER BY 1"); while ($row = pmb_mysql_fetch_object($res)) { $locations[$row->idlocation] = $row->location_libelle; } //gestion de l'encodage fichier/PMB $fonction_convert = ""; if ($input_charset == 'iso-8859-1' && $charset == 'utf-8') { $input_main = pmb_utf8_encode($input_main); $input_sub = pmb_utf8_encode($input_sub); $input_locations = pmb_utf8_encode($input_locations); } elseif ($input_charset == 'utf-8' && $charset == 'iso-8859-1') { $input_main = pmb_utf8_decode($input_main); $input_sub = pmb_utf8_decode($input_sub); $input_locations = pmb_utf8_decode($input_locations); } //Ajout dans notice_tpl $requete = "INSERT INTO notice_tpl SET "; foreach ($input_main as $key => $value) { if ($key) { $requete .= ", "; } $requete .= $value["field"] . "='" . addslashes($value["value"]) . "'"; } pmb_mysql_query($requete); $id_tpl = mysql_insert_id(); if ($id_tpl) { //Ajouts dans notice_tpl_code $array_errors = array(); foreach ($input_sub as $sub) { $ok_import = true; $array_error_row = array(); if (isset($id_loc_cours)) { unset($id_loc_cours); } if (isset($typdoc_cours)) { unset($typdoc_cours); } //création requête $requete = "INSERT INTO notice_tplcode SET num_notpl=" . $id_tpl; foreach ($sub as $value) { $requete .= ", " . $value["field"] . "='" . addslashes($value["value"]) . "'"; if ($value["field"] == "notplcode_localisation") { $id_loc_cours = $value["value"]; } if ($value["field"] == "notplcode_typdoc") { $typdoc_cours = $value["value"]; } if ($value["field"] == "nottplcode_code") { $array_error_row["tpl_code"] = $value["value"]; } } $array_error_row["typdoc"] = $typdoc_cours; $array_error_row["location"] = $input_locations[$id_loc_cours] . " (" . $id_loc_cours . ")"; //vérification localisation et type de document if (!isset($id_loc_cours) || !isset($typdoc_cours)) { $ok_import = false; $array_error_row["error"] = $msg["notice_tpl_import_error_missing_info"]; } elseif ($id_loc_cours || $typdoc_cours) { if ($id_loc_cours) { if (!isset($locations[$id_loc_cours]) || $locations[$id_loc_cours] != $input_locations[$id_loc_cours]) { $array_error_row["error"] = $msg["notice_tpl_import_error_missing_location"]; $ok_import = false; } } if ($typdoc_cours) { if (!isset($doctype->table[$typdoc_cours])) { $array_error_row["error"] = $msg["notice_tpl_import_error_missing_typdoc"]; $ok_import = false; } } } //ajout requête if ($ok_import) { pmb_mysql_query($requete); } else { $array_errors[] = $array_error_row; } } //Affichage des templates en erreur if (count($array_errors)) { print "<h1>" . $msg['notice_tpl_import_invalide'] . "</h1>"; foreach ($array_errors as $error) { echo "<b>" . $msg["notice_tpl_import_error_error"] . "</b> : " . $error["error"] . "<br>"; echo "<b>" . $msg["notice_tpl_import_error_typdoc"] . "</b> : " . $error["typdoc"] . "<br>"; echo "<b>" . $msg["notice_tpl_import_error_location"] . "</b> : " . $error["location"] . "<br>"; echo "<b>" . $msg["notice_tpl_import_error_tplcode"] . "</b> : <br>" . nl2br(htmlentities($error["tpl_code"])) . "<br>"; echo "<hr><br>"; } } print "<form class='form-{$current_module}' name=\"dummy\" method=\"post\" action=\"./edit.php?categ=tpl&sub=notice\" >\n\t\t\t\t<input type='submit' class='bouton' name=\"id_form\" value=\"Ok\" />\n\t\t\t\t</form>"; if (!count($array_errors)) { print "<script type=\"text/javascript\">document.dummy.submit();</script>"; } } else { print "<h1>" . $msg['notice_tpl_import_invalide'] . "</h1>\n\t\t\t\tError code = 7"; print $this->show_import_form(); } } else { print "<h1>" . $msg['notice_tpl_import_invalide'] . "</h1>\n\t\t\tError code = {$erreur}"; print $this->show_import_form(); } print "</div>"; //On efface le fichier temporaire if ($userfile_name) { unlink('./temp/' . $userfile_moved); } }
function pmb_utf8_array_encode($elem) { global $charset; if ($charset != "utf-8") { return pmb_utf8_encode($elem); } else { return $elem; } }
// © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net) // +-------------------------------------------------+ // $Id: serials_simple_circ_suite.php,v 1.2.4.2 2015-09-22 13:17:41 ngantier Exp $ $base_path = ".."; $class_path = "{$base_path}/classes"; $base_noheader = 1; require_once "{$base_path}/includes/init.inc.php"; require_once "{$class_path}/fpdf.class.php"; require_once "{$class_path}/ufpdf.class.php"; require_once "{$class_path}/fpdf_etiquette.class.php"; require_once "{$class_path}/simple_circ.class.php"; switch ($action) { case "add_circ_cb": $simple_circ = new simple_circ($start_date, $end_date, $circ_cb); $data = $simple_circ->get_data(); print json_encode($charset != "uft-8" ? pmb_utf8_encode($data) : $data); exit; break; case "print_list": $simple_circ = new simple_circ($start_date, $end_date, $abt_cb); print_circ_list($abt_cb, $simple_circ->get_data()); exit; break; default: $simple_circ = new simple_circ($start_date, $end_date, $circ_cb); break; } $data = $simple_circ->get_data(); // Démarrage et configuration du pdf $nom_classe = $fpdf . "_Etiquette"; $pdf = new $nom_classe($label_grid_nb_per_row, $label_grid_nb_per_col, $page_orientation, $unit, $page_format);