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