2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 // Link to printing single document with bulk report template file.
13 // Ex. label_cell(print_document_link($myrow['order_no'], _("Print")), $type);
14 // or display_note(print_document_link($order_no, _("Print this order")));
15 // You only need full parameter list for invoices/credit notes
17 function print_document_link($doc_no, $link_text, $link=true, $type_no,
18 $icon=false, $class='printlink', $id='', $email=0, $extra=0)
20 global $path_to_root, $def_print_orientation;
21 include_once($path_to_root . "/includes/types.inc");
23 $url = $path_to_root.'/reporting/prn_redirect.php?';
24 $def_orientation = (isset($def_print_orientation) && $def_print_orientation == 1 ? 1 : 0);
29 // from, to, currency, email, comments, orientation
36 'PARAM_5' => $def_orientation);
40 // from, to, currency, email, quote, comments, orientation
48 'PARAM_6' => $def_orientation);
50 case ST_CUSTDELIVERY :
52 // from, to, email, packing slip, comments, orientation
59 'PARAM_5' => $def_orientation);
61 case ST_SALESINVOICE : // Sales Invoice
62 case ST_CUSTCREDIT : // Customer Credit Note
63 $rep = $type_no==ST_CUSTCREDIT ? 113 : 107;
64 // from, to, currency, email, paylink, comments, orientation
72 'PARAM_6' => $def_orientation);
76 // from, to, currency, email, comments, orientation
83 'PARAM_5' => $def_orientation);
87 // from, to, currency, email, comments, orientation
93 'PARAM_4' => $def_orientation);
97 // from, to, currency, email, comments, orientation
100 'PARAM_1' => $doc_no,
104 'PARAM_5' => $def_orientation);
108 // from, to, email, comments, orientation
110 'PARAM_0' => $doc_no,
111 'PARAM_1' => $doc_no,
114 'PARAM_4' => $def_orientation);
116 // default: $ar = array();
119 return print_link($link_text, $rep, $ar, "", $icon, $class, $id);
122 // Universal link to any kind of report.
124 function print_link($link_text, $rep, $pars = array(), $dir = '',
125 $icon=false, $class='printlink', $id='')
127 global $path_to_root, $pdf_debug;
129 $url = $dir == '' ? $path_to_root.'/reporting/prn_redirect.php?' : $dir;
131 $id = default_focus($id);
132 foreach($pars as $par => $val) {
133 $pars[$par] = "$par=".urlencode($val);
135 $pars[] = 'REP_ID='.urlencode($rep);
136 $url .= implode ('&', $pars);
139 $class = $pdf_debug ? '' : " class='$class'";
142 $pars = access_string($link_text);
143 if (user_graphic_links() && $icon)
144 $pars[0] = set_icon($icon, $pars[0]);
145 return "<a target='_blank' href='$url'$id$class $pars[1]>$pars[0]</a>";