Load and display orders
[order_line_extra.git] / order_lines_view.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 $path_to_root = "../..";
13
14 include_once($path_to_root . "/includes/db_pager.inc");
15 include_once($path_to_root . "/includes/session.inc");
16 include_once($path_to_root . "/sales/includes/sales_ui.inc");
17 include_once($path_to_root . "/reporting/includes/reporting.inc");
18 $page_security = 'SA_ORDERLINEX_EDIT';
19 add_access_extensions();
20
21         $_POST['order_view_mode'] = "Quotations";
22         $_SESSION['page_title'] = _($help_context = "Edit lines extra parameters");
23
24 if (!@$_GET['popup'])
25 {
26         $js = "";
27         if ($use_popup_windows)
28                 $js .= get_js_open_window(900, 600);
29         if ($use_date_picker)
30                 $js .= get_js_date_picker();
31         page($_SESSION['page_title'], false, false, "", $js);
32 }
33
34 if (isset($_GET['selected_customer']))
35 {
36         $selected_customer = $_GET['selected_customer'];
37 }
38 elseif (isset($_POST['selected_customer']))
39 {
40         $selected_customer = $_POST['selected_customer'];
41 }
42 else
43         $selected_customer = -1;
44
45 //---------------------------------------------------------------------------------------------
46
47 if (isset($_POST['SelectStockFromList']) && ($_POST['SelectStockFromList'] != "") &&
48         ($_POST['SelectStockFromList'] != ALL_TEXT))
49 {
50         $selected_stock_item = $_POST['SelectStockFromList'];
51 }
52 else
53 {
54         unset($selected_stock_item);
55 }
56
57
58 if (!@$_GET['popup'])
59         start_form();
60
61 start_table(TABLESTYLE_NOBORDER);
62 start_row();
63 ref_cells(_("#:"), 'OrderNumber', '',null, '', true);
64 ref_cells(_("Ref"), 'OrderReference', '',null, '', true);
65 locations_list_cells(_("Location:"), 'StockLocation', null, true);
66
67 stock_items_list_cells(_("Item:"), 'SelectStockFromList', null, true);
68 if (!@$_GET['popup'])
69         customer_list_cells(_("Select a customer: "), 'customer_id', null, true);
70
71 submit_cells('SearchOrders', _("Search"),'',_('Select documents'), 'default');
72 hidden('order_view_mode', $_POST['order_view_mode']);
73
74 end_row();
75
76 end_table(1);
77 //---------------------------------------------------------------------------------------------
78 //      Orders inquiry table
79 //
80 $trans_type = ST_SALESORDER;
81 $sql = get_sql_for_sales_orders_view($selected_customer, $trans_type, $_POST['OrderNumber'], 'OutstandingOnly',
82         @$selected_stock_item, @$_POST['OrdersAfterDate'], @$_POST['OrdersToDate'], @$_POST['OrderReference'], $_POST['StockLocation'], $_POST['customer_id']);
83
84         $cols = array(
85                 _("Order #") => array('fun'=>'view_link'),
86                 _("Ref"),
87                 _("Customer"),
88                 _("Branch"), 
89                 _("Cust Order Ref"),
90                 _("Order Date") => 'date',
91                 _("Required By") =>array('type'=>'date', 'ord'=>''),
92                 _("Delivery To"), 
93                 _("Order Total") => array('type'=>'amount', 'ord'=>''),
94                 'Type' => 'skip',
95                 _("Currency") => array('align'=>'center')
96         );
97
98
99 $table =& new_db_pager('orders_tbl', $sql, $cols);
100
101 $table->width = "80%";
102
103 display_db_pager($table);
104 submit_center('Update', _("Update"), true, '', null);
105
106 if (!@$_GET['popup'])
107 {
108         end_form();
109         end_page();
110 }
111 ?>