Added 2 functions in ui_input.inc, button and button_cell
[fa-stable.git] / reporting / includes / reporting.inc
1 <?php
2
3 // Put this on the page only once, e.g. print_hidden_script(systypes::sales_order());
4
5 function print_hidden_script($type_no)
6 {
7         global $path_to_root;
8         include_once($path_to_root . "/includes/types.inc");
9         $action = "";
10
11         switch ($type_no)
12         {
13                 case systypes::sales_order() :
14                         $action = "$path_to_root/reporting/rep109.php";
15                         $ar = array(
16                                 'PARAM_0' => 0,         // from - these values are updated in print_document_link()
17                                 'PARAM_1' => 0,         // to
18                                 'PARAM_2' => "",        // currency
19                                 'PARAM_3' => "",        // bank account
20                                 'PARAM_4' => 0,         // email
21                                 'PARAM_5' => 0,         // quote
22                                 'PARAM_6' => "");       // comments
23                         break;
24                 case systypes::cust_dispatch() :
25                         $action = "$path_to_root/reporting/rep110.php";
26                         $ar = array(
27                                 'PARAM_0' => 0,         // from - these values are updated in print_document_link()
28                                 'PARAM_1' => 0,         // to
29                                 'PARAM_2' => 0,         // email
30                                 'PARAM_3' => "");       // comments
31                         break;
32                 case 10 : // Sales Invoice
33                 case 11 : // Customer Credit Note
34                         $action = "$path_to_root/reporting/rep107.php";
35                         $ar = array(
36                                 'PARAM_0' => 0,         // from - these values are updated in print_document_link()
37                                 'PARAM_1' => 0,         // to
38                                 'PARAM_2' => "",        // currency
39                                 'PARAM_3' => "",        // bank account
40                                 'PARAM_4' => 0,         // email
41                                 'PARAM_5' => "",        // paylink
42                                 'PARAM_6' => "");       // comments
43                         break;
44                 case systypes::po() :
45                         $action = "$path_to_root/reporting/rep209.php";
46                         $ar = array(
47                                 'PARAM_0' => 0,         // from - these values are updated in print_document_link()
48                                 'PARAM_1' => 0,         // to
49                                 'PARAM_2' => "",        // currency
50                                 'PARAM_3' => "",        // bank account
51                                 'PARAM_4' => 0,         // email
52                                 'PARAM_5' => "");       // comments
53                         break;
54         }
55         $st = "<form method='post' name='pdf_form' action='$action'>";
56         foreach ($ar as $key => $value)
57         {
58                 $st .= "<input type='hidden' name='$key' value='$value' />";
59         }
60         $st .= "</form>\n";
61         $st .= "<script type='text/javascript'>
62 <!--
63 function printDocument(docno) {
64   document.pdf_form.PARAM_0.value = document.pdf_form.PARAM_1.value = docno;
65   window.open('','REP_WINDOW','toolbar=no,scrollbar=no,resizable=yes,menubar=no');
66   document.pdf_form.target='REP_WINDOW';
67   document.pdf_form.submit();
68 }
69 -->
70 </script>\n";
71
72         echo $st;
73 }
74
75 // Ex. label_cell(print_document_link($myrow['order_no'], _("Print")));
76 // or display_note(print_document_link($order_no, _("Print this order")));
77 // or if a button
78 // button("button", _("Print this order"), print_document_link($order_no, "", false))";
79 // or if a button inside a TD
80 // button_cell("button", _("Print this order"), print_document_link($order_no, "", false))";
81
82 function print_document_link($doc_no, $link_text, $link=true)
83 {
84         if ($link)
85                 return "<a href=\"javascript:printDocument('$doc_no');\">$link_text</a>";
86         else
87                 return "javascript:printDocument('$doc_no');";
88 }
89 ?>