Merged stable branch up to 2.3.10
[fa-stable.git] / purchasing / inquiry / po_search_completed.php
1 <?php
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 $page_security = 'SA_SUPPTRANSVIEW';
13 $path_to_root="../..";
14 include($path_to_root . "/includes/db_pager.inc");
15 include($path_to_root . "/includes/session.inc");
16
17 include($path_to_root . "/purchasing/includes/purchasing_ui.inc");
18 include_once($path_to_root . "/reporting/includes/reporting.inc");
19 $js = "";
20 if ($use_popup_windows)
21         $js .= get_js_open_window(900, 500);
22 if ($use_date_picker)
23         $js .= get_js_date_picker();
24 page(_($help_context = "Search Purchase Orders"), false, false, "", $js);
25
26 if (isset($_GET['order_number']))
27 {
28         $order_number = $_GET['order_number'];
29 }
30
31 //-----------------------------------------------------------------------------------
32 // Ajax updates
33 //
34 if (get_post('SearchOrders')) 
35 {
36         $Ajax->activate('orders_tbl');
37 } elseif (get_post('_order_number_changed')) 
38 {
39         $disable = get_post('order_number') !== '';
40
41         $Ajax->addDisable(true, 'OrdersAfterDate', $disable);
42         $Ajax->addDisable(true, 'OrdersToDate', $disable);
43         $Ajax->addDisable(true, 'StockLocation', $disable);
44         $Ajax->addDisable(true, '_SelectStockFromList_edit', $disable);
45         $Ajax->addDisable(true, 'SelectStockFromList', $disable);
46
47         if ($disable) {
48                 $Ajax->addFocus(true, 'order_number');
49         } else
50                 $Ajax->addFocus(true, 'OrdersAfterDate');
51
52         $Ajax->activate('orders_tbl');
53 }
54 //---------------------------------------------------------------------------------------------
55
56 start_form();
57
58 start_table(TABLESTYLE_NOBORDER);
59 start_row();
60 ref_cells(_("#:"), 'order_number', '',null, '', true);
61
62 date_cells(_("from:"), 'OrdersAfterDate', '', null, -30);
63 date_cells(_("to:"), 'OrdersToDate');
64
65 locations_list_cells(_("into location:"), 'StockLocation', null, true);
66 end_row();
67 end_table();
68
69 start_table(TABLESTYLE_NOBORDER);
70 start_row();
71
72 stock_items_list_cells(_("for item:"), 'SelectStockFromList', null, true);
73
74 submit_cells('SearchOrders', _("Search"),'',_('Select documents'), 'default');
75 end_row();
76 end_table(1);
77 //---------------------------------------------------------------------------------------------
78 if (isset($_POST['order_number']))
79 {
80         $order_number = $_POST['order_number'];
81 }
82
83 if (isset($_POST['SelectStockFromList']) &&     ($_POST['SelectStockFromList'] != "") &&
84         ($_POST['SelectStockFromList'] != ALL_TEXT))
85 {
86         $selected_stock_item = $_POST['SelectStockFromList'];
87 }
88 else
89 {
90         unset($selected_stock_item);
91 }
92
93 //---------------------------------------------------------------------------------------------
94 function trans_view($trans)
95 {
96         return get_trans_view_str(ST_PURCHORDER, $trans["order_no"]);
97 }
98
99 function edit_link($row) 
100 {
101   return pager_link( _("Edit"),
102         "/purchasing/po_entry_items.php?" . SID 
103         . "ModifyOrderNumber=" . $row["order_no"], ICON_EDIT);
104 }
105
106 function prt_link($row)
107 {
108         return print_document_link($row['order_no'], _("Print"), true, 18, ICON_PRINT);
109 }
110
111 //---------------------------------------------------------------------------------------------
112
113 $sql = get_sql_for_po_search_completed();
114
115 $cols = array(
116                 _("#") => array('fun'=>'trans_view', 'ord'=>''), 
117                 _("Reference"), 
118                 _("Supplier") => array('ord'=>''),
119                 _("Location"),
120                 _("Supplier's Reference"), 
121                 _("Order Date") => array('name'=>'ord_date', 'type'=>'date', 'ord'=>'desc'),
122                 _("Currency") => array('align'=>'center'), 
123                 _("Order Total") => 'amount',
124                 array('insert'=>true, 'fun'=>'edit_link'),
125                 array('insert'=>true, 'fun'=>'prt_link'),
126 );
127
128 if (get_post('StockLocation') != $all_items) {
129         $cols[_("Location")] = 'skip';
130 }
131 //---------------------------------------------------------------------------------------------------
132
133 $table =& new_db_pager('orders_tbl', $sql, $cols);
134
135 $table->width = "80%";
136
137 display_db_pager($table);
138
139 end_form();
140 end_page();
141 ?>