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 = "../..";
14 include_once($path_to_root . "/includes/session.inc");
15 include_once($path_to_root . "/includes/ui/ui_lists.inc");
16 include_once($path_to_root . "/includes/ui/ui_globals.inc");
17 include_once($path_to_root . "/includes/ui/ui_input.inc");
18 include_once($path_to_root . "/reporting/includes/reporting.inc");
20 //include_once("includes/item_scheduler.inc");
21 include_once("hincludes/lib/php/Boot.class.php");
22 include_once("includes/db_order_lines.inc");
23 include_once("includes/picking.inc");
24 include_once("config.php");
26 $page_security = 'SA_ORDERLINEX_SCHEDULE';
27 add_access_extensions();
29 $_SESSION['page_title'] = _($help_context = "Item schedule");
33 page($_SESSION['page_title'], false, false, "", $js);
35 //---------------------------------------------------------------------------------------------
37 div_start('item_schedule');
41 start_table(TABLESTYLE_NOBORDER);
44 if (!isset($_POST['stock_id'])) {
45 if (isset($_GET['stock_id']))
47 $_POST['stock_id'] = $_GET['stock_id'];
50 $_POST['stock_id'] = get_global_stock_item();
54 if (list_updated('stock_id') || in_ajax()) $Ajax->activate('item_schedule') ;
55 //else update_queue_quantities() && update_qoh_for_item();
58 //if (!@$_GET['popup'])
63 $stock_id = $_POST['stock_id'];
64 stock_costable_items_list_cells(_("Item:"), 'stock_id', $stock_id);
69 if(isset($stock_id)) echo '<input type="hidden" name="last_stock_id" value="'.$stock_id.'">';
71 if(isset($_POST['Update'])) {
72 $Ajax->activate('item_schedule');
73 // Restore the parameters
74 $params = new ScheduleParameters($_SESSION['schedule_parameters']);
75 $params->setMode('update');
77 else if(isset($_POST['Cancel'])) {
78 $Ajax->activate('item_schedule');
79 $params = new ScheduleParameters($_SESSION['schedule_parameters']);
80 $params->setMode('cancel');
83 $params = in_ajax() && $stock_id == @$_POST['last_stock_id'] ? new ScheduleParameters($_POST) : null;
84 // save parameters form update
85 $_SESSION['schedule_parameters'] = $_POST;
87 $scheduler = new ItemScheduler($stock_id, OrderXtraConfig::$default_location, $params);
90 start_table(TABLESTYLE);
91 $th = $scheduler->tableHeader();
95 $scheduler->generateTable();
100 if($scheduler->needsUpdate()) {
101 submit_center_first('Update', _("Update"), '', 'default', false);
102 submit_center_last('Cancel', _("Cancel"), '', 'cancel', false);
111 <style type='text/css'>
116 tr.partial td:nth-child(5) {
144 tr.expired td:nth-child(7) {
151 border: 2px solid black;
153 tr.tDnD_whileDrag :nth-child(4), tr.tDnD_whileDrag :nth-child(5) {
155 background: transparent;
163 tr.partial span.pickable {
167 background: transparent;
170 <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
171 <script src="js/jquery.tablednd.0.8.min.js"></script>
172 <script text="text/javascript">
173 /** add table DnD as behavior **/
174 function onDragStart (table, row) {
178 function findRowPosition(table, row) {
180 function addInput(form, name, value) {
181 $(form).append('<input type="hidden" name="'+name+'" value="'+value+'">')
183 function addInputs(form, name, values) {
184 for(index = 0; index < values.length; index++) {
185 addInput(form, name+'['+index+']', values[index])
188 function onDrop(table, row) {
189 var row_ids = $.map(table.tBodies[0].rows, function(r) { return r.id} )
191 var form = $(table).closest('form')[0]
193 addInput(form, 'row_id', row.id)
194 addInputs(form, 'row_order', row_ids )
196 JsHttpRequest.request(this, form);
200 function onPick(element) {
201 /* horible hack but it works */
202 /* in the way it call an Ajax request */
203 var row = $(element).closest('tr')[0];
204 var table = $(element).closest('table')[0];
210 '#item_schedule table': function (e) {
211 $(e).tableDnD({onDragStart: onDragStart, onDrop: onDrop})
214 Behaviour.register(inserts);