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");
17 include($path_to_root . "/purchasing/includes/purchasing_ui.inc");
18 include_once($path_to_root . "/reporting/includes/reporting.inc");
21 if ($SysPrefs->use_popup_windows)
22 $js .= get_js_open_window(900, 500);
23 if (user_use_date_picker())
24 $js .= get_js_date_picker();
25 page(_($help_context = "Search Outstanding Purchase Orders"), false, false, "", $js);
27 if (isset($_GET['order_number']))
29 $_POST['order_number'] = $_GET['order_number'];
31 //-----------------------------------------------------------------------------------
34 if (get_post('SearchOrders'))
36 $Ajax->activate('orders_tbl');
37 } elseif (get_post('_order_number_changed'))
39 $disable = get_post('order_number') !== '';
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);
48 $Ajax->addFocus(true, 'order_number');
50 $Ajax->addFocus(true, 'OrdersAfterDate');
52 $Ajax->activate('orders_tbl');
56 //---------------------------------------------------------------------------------------------
60 start_table(TABLESTYLE_NOBORDER);
62 ref_cells(_("#:"), 'order_number', '',null, '', true);
64 date_cells(_("from:"), 'OrdersAfterDate', '', null, -user_transaction_days());
65 date_cells(_("to:"), 'OrdersToDate');
67 locations_list_cells(_("Location:"), 'StockLocation', null, true);
71 start_table(TABLESTYLE_NOBORDER);
74 stock_items_list_cells(_("Item:"), 'SelectStockFromList', null, true);
76 supplier_list_cells(_("Select a supplier: "), 'supplier_id', null, true, true);
78 submit_cells('SearchOrders', _("Search"),'',_('Select documents'), 'default');
81 //---------------------------------------------------------------------------------------------
82 function trans_view($trans)
84 return get_trans_view_str(ST_PURCHORDER, $trans["order_no"]);
87 function edit_link($row)
89 return trans_editor_link(ST_PURCHORDER, $row["order_no"]);
92 function prt_link($row)
94 return print_document_link($row['order_no'], _("Print"), true, ST_PURCHORDER, ICON_PRINT);
97 function receive_link($row)
99 return pager_link( _("Receive"),
100 "/purchasing/po_receive_items.php?PONumber=" . $row["order_no"], ICON_RECEIVE);
103 function check_overdue($row)
105 return $row['OverDue']==1;
107 //---------------------------------------------------------------------------------------------
109 //figure out the sql required from the inputs available
110 $sql = get_sql_for_po_search(get_post('OrdersAfterDate'), get_post('OrdersToDate'), get_post('supplier_id'), get_post('StockLocation'),
111 $_POST['order_number'], get_post('SelectStockFromList'));
113 //$result = db_query($sql,"No orders were returned");
115 /*show a table of the orders returned by the sql */
117 _("#") => array('fun'=>'trans_view', 'ord'=>''),
119 _("Supplier") => array('ord'=>''),
121 _("Supplier's Reference"),
122 _("Order Date") => array('name'=>'ord_date', 'type'=>'date', 'ord'=>'desc'),
123 _("Currency") => array('align'=>'center'),
124 _("Order Total") => 'amount',
125 array('insert'=>true, 'fun'=>'edit_link'),
126 array('insert'=>true, 'fun'=>'prt_link'),
127 array('insert'=>true, 'fun'=>'receive_link')
130 if (get_post('StockLocation') != ALL_TEXT) {
131 $cols[_("Location")] = 'skip';
134 $table =& new_db_pager('orders_tbl', $sql, $cols);
135 $table->set_marker('check_overdue', _("Marked orders have overdue items."));
137 $table->width = "80%";
139 display_db_pager($table);