lock(distable) all fields.
[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
19 include_once("includes/order_lines.inc");
20 include_once("includes/splitter.inc");
21
22 $page_security = 'SA_ORDERLINEX_EDIT';
23 add_access_extensions();
24
25 $_SESSION['page_title'] = _($help_context = "Edit lines extra parameters");
26
27 // Process POST
28 filter_data($_POST);
29 update_extra_order_details();
30 split_order_details();
31
32
33 $js = "";
34 if ($use_popup_windows)
35         $js .= get_js_open_window(900, 600);
36 if ($use_date_picker)
37         $js .= get_js_date_picker();
38 page($_SESSION['page_title'], false, false, "", $js);
39
40 //---------------------------------------------------------------------------------------------
41
42 start_form();
43
44 start_table(TABLESTYLE_NOBORDER);
45 start_row();
46
47
48 if(!isset($_POST['customer_id'])) {
49         if(isset($_GET['customer_id'])) {
50                 $customer_id = $_GET['customer_id'];
51                 $_POST['customer_id'] = $customer_id;
52         }
53 else $customer_id = null;
54
55 }
56 else {
57         $customer_id = $_POST['customer_id'];
58 }
59 customer_list_cells(_("Select a customer: "), 'customer_id', $customer_id, true, true);
60
61 if($customer_id != null) {
62         if(!isset($_POST['item_like'])) {
63                 if(isset($_GET['item_like'])) {
64                         $item_like = $_GET['item_like'];
65                         $_POST['item_like'] = $item_like;
66                 }
67                 else $item_like = null;
68         }
69         else $item_like = $_POST['item_like'];
70         text_cells_ex('Filter Item', 'item_like', 50, null, $item_like,
71                         null, null, null, true );
72 }
73
74
75
76
77
78 //submit_cells('SearchOrders', _("Search"),'',_('Select documents'), 'default');
79
80 end_row();
81
82 end_table(1);
83
84 //---------------------------------------------------------------------------------------------
85 //      Orders inquiry table
86 //
87 if($customer_id) {
88         $sql = get_order_details_extra($customer_id, 'DEF', $item_like);
89         $cols = array(
90                 'detail_id' => 'skip'
91                 ,       _("Order #") => array('fun'=>'view_link', 'ord' => '')
92                 ,_("Item Code") => array('ord' => '', 'fun' => 'item_link')
93                 ,_("Quantity") => array('type' => 'qty', 'dec' => 0)
94                 ,_("Available") => array('fun' => 'available_quantity', 'dec' => 0, 'ord' => '')
95                 ,_("Before") => 'skip'
96                 ,_("Priority") => array('type' => 'time', 'ord' => '')
97                 ,_("Hold Until") => array('fun' => 'input_hold_until_date_details', 'ord' => '')
98                 ,_("Require By") => array('fun' => 'input_required_date_details', 'ord' => '')
99                 ,_("Expiry Date") => array('fun' => 'input_expiry_date_details', 'ord' => '')
100                 ,_("Comment") => array('fun' => 'input_comment_details', 'ord' => '')
101                 ,'<input id="checkAll" type="checkbox">' => array('fun' => 'input_check_details')
102         );
103 }
104 else {
105         $sql = get_order_summary('DEF');
106         $cols = array(
107         'customer id' => 'skip',
108 _("Customer") => array('ord' => '', 'fun' => 'customer_link'),
109 _("Branch") => array('ord' => ''),
110 _("Delivery Date") => array('ord' => '', 'type' => 'date'),
111 _("Quantity") => array('ord' => '', 'type' => 'qty', 'dec' => 0),
112 _("Amount") => array('ord' => '', 'type' => 'amount'),
113 _("Avail. Q") => array('ord' => '', 'type' => 'qty', 'dec' => 0),
114 _("Avail. A") => array('ord' => '', 'type' => 'amount', 'dec' => 0),
115 _("required date") => array('ord' => '', 'type' => 'date'),
116 _("Comments") => array('ord' => '', 'fun' => 'aggregate_comment'),
117 _("comment 2 ") =>  'skip'
118         );
119 }
120
121
122 $table =& new_db_pager('orders_tbl', $sql, $cols);
123
124 $table->width = "80%";
125
126 display_db_pager($table);
127
128 function display_split_area() {
129 start_table(TABLESTYLE_NOBORDER);
130 qty_cells('Before', 'start_offset', -5);
131 date_cells('Start', 'start_date');
132 date_cells('End', 'end_date');
133 qty_cells('After', 'end_offset', 2);
134 qty_cells('Max', 'max_quantity', 6);
135 submit_cells('Split', 'Split');
136 end_table();
137
138 }
139 display_split_area();
140
141
142 br(1);
143 submit_center_first('Update', _("Update"), '', 'default', false);
144 submit_center_last('Cancel', _("Cancel"), '', 'cancel', false);
145
146         end_form();
147         end_page();
148 ?>
149 <style>
150 span.tooltip{ display:none;}
151 span.tooltip {
152       position: absolute;
153                         right: -0px;
154                         top: 20px;
155       width: 200px;
156       color: rgb(113, 157, 171);
157       background: rgb(255, 255, 255);
158       border: 1px solid rgb(113, 157, 171);
159 }
160
161 :hover > span.tooltip, span.tooltip:hover {
162         display: inline;
163 }
164 span.before-tooltip {
165         color: #800;
166         font-style: italic;
167         position: relative;
168 }
169
170 </style>
171 <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
172 <script text="text/javascript">
173
174 var inserts = {
175         '#checkAll': function (e) {
176                 e.onchange = function()  {
177                         $('.check_detail').prop('checked', e.checked)
178                         $('.check_detail').trigger('change');
179                 }
180         }
181         ,'tr': function(e) {
182                         // find if there is a check detail box on link all input to it
183                         var tr = $(e);
184                         var check = tr.find('.check_detail');
185                         if(check.length != 1) return;
186                         check = check[0];
187                         var jcheck = $(check);
188                         var inputs = tr.find('input');
189                         inputs.each(function(index, input) {
190                                 if(input === check) return;
191                                 $(input).prop('disabled', true)
192                         })
193
194                         check.onchange = function() {
195                                 inputs.each(function(index, input) {
196                                         var on = jcheck.prop('checked')
197                                         if(input == check) return;
198                                         $(input).prop('disabled', !on);
199                                 })
200                         };
201                 }
202         }
203 Behaviour.register(inserts);
204 </script>