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