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)
21 include_once($path_to_root . "/includes/types.inc");
23 $url = $path_to_root.'/reporting/prn_redirect.php?';
24 $def_orientation = (user_def_print_orientation() == 1 ? 1 : 0);
30 // from, to, currency, email, comments, orientation
37 'PARAM_5' => $def_orientation);
41 // from, to, currency, email, quote, comments, orientation
49 'PARAM_6' => $def_orientation);
51 case ST_CUSTDELIVERY :
53 // from, to, email, packing slip, comments, orientation
60 'PARAM_5' => $def_orientation);
62 case ST_SALESINVOICE : // Sales Invoice
63 case ST_CUSTCREDIT : // Customer Credit Note
64 $rep = $type_no==ST_CUSTCREDIT ? 113 : 107;
65 // from, to, currency, email, paylink, comments, orientation
73 'PARAM_6' => $rep == 107 ? '' : $def_orientation);
75 $ar['PARAM_7'] = $def_orientation;
79 // from, to, currency, email, comments, orientation
86 'PARAM_5' => $def_orientation);
90 // from, to, currency, comments, orientation
96 'PARAM_4' => $def_orientation);
100 // from, to, currency, email, comments, orientation
102 'PARAM_0' => $doc_no,
103 'PARAM_1' => $doc_no,
107 'PARAM_5' => $def_orientation);
111 // from, to, email, comments, orientation
113 'PARAM_0' => $doc_no,
114 'PARAM_1' => $doc_no,
117 'PARAM_4' => $def_orientation);
123 return print_link($link_text, $rep, $ar, "", $icon, $class, $id);
126 // Universal link to any kind of report.
128 function print_link($link_text, $rep, $pars = array(), $dir = '',
129 $icon=false, $class='printlink', $id='')
131 global $path_to_root, $SysPrefs;
133 $url = $dir == '' ? $path_to_root.'/reporting/prn_redirect.php?' : $dir;
135 $id = default_focus($id);
136 foreach($pars as $par => $val) {
137 $pars[$par] = "$par=".urlencode($val);
139 $pars[] = 'REP_ID='.urlencode($rep);
140 $url .= implode ('&', $pars);
143 $class = $SysPrefs->pdf_debug ? '' : " class='$class'";
146 $pars = access_string($link_text);
147 if (user_graphic_links() && $icon)
148 $pars[0] = set_icon($icon, $pars[0]);
149 return "<a target='_blank' href='$url'$id$class $pars[1]>$pars[0]</a>";
153 // Purpose: Function to parse a string into parameters
154 // Release Date: 2014-12-26
155 // Author: ApMuthu <apmuthu@usa.net>
157 $str = "PPFrt#2000 CID#6378465 TaxEx#2345-038 abcde ertrgdert COD#4253 jdegtd PIN#6473654";
158 $p = parse_notes_params($str);
159 echo print_r($p, true);
161 An example of usage will be in the reporting/rep110.php file at near the end just before the last $rep-Font(); statement:
164 $notes_params = parse_notes_params($branch['notes']);
165 if ($packing_slip == 0 && array_key_exists('CID', $notes_params)) {
167 $rep->TextCol(1, 7, "Old Customer# : " . $notes_params['CID'], - 2);
171 function parse_notes_params($str, $sep=" ", $delim="#") {
172 $str_params = explode($sep, $str);
173 $param_array=Array('notes' => '');
174 foreach ($str_params AS $str_param) {
175 $param_set=explode($delim, trim($str_param));
176 $key = (array_key_exists(0, $param_set) ? trim($param_set[0]) : '');
177 $val = (array_key_exists(1, $param_set) ? trim($param_set[1]) : '');
178 if (strlen($key) > 0 && strlen($val) > 0) {
179 $param_array[$key]=$val;
181 // stop at first missing parameter set
183 // Collect the rest into notes
184 $param_array['notes'] .= (" " . $str_param);
187 $param_array['notes'] = trim($param_array['notes']);