示例#1
0
 function build_print_diffusion($expl_id, $start_diff_id)
 {
     global $serialcirc_circ_pdf_diffusion, $charset, $serialcirc_circ_pdf_diffusion_destinataire;
     global $msg;
     if (!$start_diff_id) {
         foreach ($this->info_expl[$expl_id]['serialcirc_diff']->diffusion as $diff_id => $diffusion) {
             $start_diff_id = $diff_id;
             break;
         }
     }
     if (!$this->info_expl[$expl_id]) {
         return false;
     }
     $req = "UPDATE serialcirc_expl SET num_serialcirc_expl_serialcirc_diff=" . $start_diff_id . ",\n\t\tserialcirc_expl_state_circ=1,\n\t\tserialcirc_expl_start_date=CURDATE()\n\t\twhere num_serialcirc_expl_id= {$expl_id}";
     mysql_query($req);
     $req = "select date_format(CURDATE(), '" . $msg["format_date"] . "') as print_date";
     $result = mysql_query($req);
     $obj = mysql_fetch_object($result);
     $print_date = $obj->print_date;
     $tpl = $serialcirc_circ_pdf_diffusion;
     $tpl = str_replace("!!expl_cb!!", htmlentities($this->info_expl[$expl_id]['expl_cb'], ENT_QUOTES, $charset), $tpl);
     $tpl = str_replace("!!date!!", htmlentities($this->info_expl[$expl_id]['mention_date'], ENT_QUOTES, $charset), $tpl);
     $tpl = str_replace("!!periodique!!", htmlentities($this->info_expl[$expl_id]['serial_title'], ENT_QUOTES, $charset), $tpl);
     $tpl = str_replace("!!numero!!", htmlentities($this->info_expl[$expl_id]['numero'], ENT_QUOTES, $charset), $tpl);
     $tpl = str_replace("!!print_date!!", htmlentities($print_date, ENT_QUOTES, $charset), $tpl);
     //	$tpl=str_replace("!!abonnement!!", htmlentities($this->info_expl[$expl_id]['serialcirc_diff']->abt_name,ENT_QUOTES,$charset), $tpl);
     if ($start_diff_id) {
         $found = 0;
     } else {
         $found = 1;
     }
     foreach ($this->info_expl[$expl_id]['serialcirc_diff']->diffusion as $diff_id => $diffusion) {
         if ($start_diff_id && !$found) {
             if ($start_diff_id == $diff_id) {
                 $found = 1;
             }
         }
         if ($found) {
             $diff_list[] = $diff_id;
             if ($diffusion["empr_type"] == SERIALCIRC_EMPR_TYPE_group) {
                 $name = $diffusion["empr_name"];
                 foreach ($diffusion['group'] as $empr_group) {
                     $empr_list[$empr_group["num_empr"]] = $diff_id;
                     if ($empr_group["duration"]) {
                         $empr_days[$empr_group["num_empr"]] = $empr_group["duration"];
                     } else {
                         $empr_days[$empr_group["num_empr"]] = $this->info_expl[$expl_id]['serialcirc_diff']->duration;
                     }
                     if ($diffusion['type_diff'] == 1 && !$empr_group["responsable"]) {
                         // groupe marguerite: on n'imprimera pas ce lecteur sauf le responsable
                         //$empr_no_display[$empr_group["num_empr"]]=1;
                     }
                 }
             } else {
                 $name = $this->info_expl[$expl_id]['serialcirc_diff']->empr_info[$diffusion["num_empr"]]["empr_libelle"];
                 $empr_list[$diffusion["num_empr"]] = $diff_id;
                 if ($diffusion["duration"]) {
                     $empr_days[$diffusion["num_empr"]] = $diffusion["duration"];
                 } else {
                     $empr_days[$diffusion["num_empr"]] = $this->info_expl[$expl_id]['serialcirc_diff']->duration;
                 }
             }
             if ($this->info_expl[$expl_id]['serialcirc_diff']->circ_type == SERIALCIRC_TYPE_star) {
                 // on n'imprime que le suivant dans la liste
                 break;
             }
         }
     }
     $this->gen_circ($empr_list, $empr_days, $expl_id);
     $gen_tpl = new serialcirc_print_fields($this->info_expl[$expl_id]['num_serialcirc']);
     $header_list = $gen_tpl->get_header_list();
     $nb_col = count($header_list);
     $width_col = (int) (100 / $nb_col);
     foreach ($header_list as $titre) {
         $th .= "<th style='width: {$width_col}%; text-align: left'>" . htmlentities($titre, ENT_QUOTES, $charset) . "</th>";
     }
     $tpl = str_replace("!!th!!", $th, $tpl);
     $tr_list = "";
     foreach ($empr_list as $empr_id => $diff_id) {
         if ($empr_no_display[$empr_id]) {
             continue;
         }
         $data['empr_id'] = $empr_id;
         $data_fields = $gen_tpl->get_line($data);
         $td_list = "";
         foreach ($data_fields as $field) {
             $td_list .= "<td style='width: {$width_col}%; text-align: left'>" . htmlentities($field, ENT_QUOTES, $charset) . "</td>";
         }
         $tr_list .= "<tr>" . $td_list . "</tr>";
     }
     $tpl = str_replace("!!table_contens!!", $tr_list, $tpl);
     if ($this->info_expl[$expl_id]['serialcirc_diff']->no_ret_circ) {
         //pas de retour sur site, suppression de la circulation.
         $this->delete_diffusion($expl_id);
     }
     return $tpl;
 }
 function up_order_circdiffprint($id_serialcirc, $tablo)
 {
     global $dbh;
     $fields = new serialcirc_print_fields($id_serialcirc);
     $fields->up_order($tablo);
 }