2 // Link to printing single document with bulk report template file.
3 // Ex. label_cell(print_document_link($myrow['order_no'], _("Print")), $type);
4 // or display_note(print_document_link($order_no, _("Print this order")));
5 // You only need full parameter list for invoices/credit notes
7 function print_document_link($doc_no, $link_text, $link=true, $type_no)
10 include_once($path_to_root . "/includes/types.inc");
12 $url = $path_to_root.'/reporting/prn_redirect.php?';
16 case systypes::sales_order() :
18 // from, to, currency, bank acc, email, quote, comments
23 'PARAM_3' => get_first_bank_account(),
28 case systypes::cust_dispatch() :
30 // from, to, email, comments
37 case 10 : // Sales Invoice
38 case 11 : // Customer Credit Note
40 // from, to, currency, bank acc, email, paylink, comments, type
45 'PARAM_3' => get_first_bank_account(),
49 'PARAM_7' => $type_no);
53 // from, to, currency, bank acc, email, comments
58 'PARAM_3' => get_first_bank_account(),
62 // default: $ar = array();
65 return print_link($link_text, $rep, $ar);
68 // Universal link to any kind of report.
70 function print_link($link_text, $rep, $pars = array(), $dir = '')
72 global $path_to_root, $pdf_debug;
74 $url = $dir == '' ? $path_to_root.'/reporting/prn_redirect.php?' : $dir;
76 foreach($pars as $par => $val) {
77 $pars[$par] = "$par=".urlencode($val);
79 $pars[] = 'REP_ID='.urlencode($rep);
80 $url .= implode ('&', $pars);
81 $class = $pdf_debug ? '' : "class='printlink'";
82 $pars = access_string($link_text);
83 return "<a $class target='_blank' href='$url'$pars[1]>$pars[0]</a>";
86 function get_first_bank_account()
88 $sql = "SELECT ".TB_PREF."bank_accounts.account_code FROM ".TB_PREF."bank_accounts, ".TB_PREF."company
89 WHERE bank_curr_code=curr_default LIMIT 0, 1";
90 $result = db_query($sql);
91 $row = db_fetch_row($result);