3 // Put this on the page only once an outside a form, e.g. print_hidden_script(systypes::sales_order());
4 // If you have both invoices and credit notes on the same page use 10 or 11. Is doesn't matter which.
6 function print_hidden_script($type_no)
9 include_once($path_to_root . "/includes/types.inc");
14 case systypes::sales_order() :
15 $action = "$path_to_root/reporting/rep109.php";
17 'PARAM_0' => 0, // from - these values are updated in print_document_link()
19 'PARAM_2' => "", // currency
20 'PARAM_3' => get_first_bank_account(), // bank account
21 'PARAM_4' => 0, // email
22 'PARAM_5' => 0, // quote
23 'PARAM_6' => ""); // comments
25 case systypes::cust_dispatch() :
26 $action = "$path_to_root/reporting/rep110.php";
28 'PARAM_0' => 0, // from - these values are updated in print_document_link()
30 'PARAM_2' => 0, // email
31 'PARAM_3' => ""); // comments
33 case 10 : // Sales Invoice
34 case 11 : // Customer Credit Note
35 $action = "$path_to_root/reporting/rep107.php";
37 'PARAM_0' => 0, // from - these values are updated in print_document_link()
39 'PARAM_2' => "", // currency
40 'PARAM_3' => get_first_bank_account(), // bank account
41 'PARAM_4' => 0, // email
42 'PARAM_5' => "", // paylink
43 'PARAM_6' => "", // comments
44 'PARAM_7' => 0); // IV or CN
47 $action = "$path_to_root/reporting/rep209.php";
49 'PARAM_0' => 0, // from - these values are updated in print_document_link()
51 'PARAM_2' => "", // currency
52 'PARAM_3' => get_first_bank_account(), // bank account
53 'PARAM_4' => 0, // email
54 'PARAM_5' => ""); // comments
57 $st = "<form method='post' name='pdf_form' action='$action'>";
58 foreach ($ar as $key => $value)
60 $st .= "<input type='hidden' name='$key' value='$value' />";
63 $st .= "<script type='text/javascript'>
65 function printDocument(docno, typeno) {
66 document.pdf_form.PARAM_0.value = document.pdf_form.PARAM_1.value = docno;
67 if (typeno == 10 || typeno == 11)
68 document.pdf_form.PARAM_7.value = typeno;
69 window.open('','REP_WINDOW','toolbar=no,scrollbar=no,resizable=yes,menubar=no');
70 document.pdf_form.target='REP_WINDOW';
71 document.pdf_form.submit();
79 // Ex. label_cell(print_document_link($myrow['order_no'], _("Print")));
80 // or display_note(print_document_link($order_no, _("Print this order")));
82 // button("button", _("Print this order"), print_document_link($order_no, "", false))";
83 // or if a button inside a TD
84 // button_cell("button", _("Print this order"), print_document_link($order_no, "", false))";
86 // You only need full parameter list for invoices/credit notes
88 function print_document_link($doc_no, $link_text, $link=true, $type_no=0)
91 return "<a href=\"javascript:printDocument('$doc_no', '$type_no');\">$link_text</a>";
93 return "javascript:printDocument('$doc_no', '$type_no');";
96 function get_first_bank_account()
98 $sql = "SELECT ".TB_PREF."bank_accounts.account_code FROM ".TB_PREF."bank_accounts, ".TB_PREF."company
99 WHERE bank_curr_code=curr_default LIMIT 0, 1";
100 $result = db_query($sql);
101 $row = db_fetch_row($result);