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");
24 $page_security = 'SA_ORDERLINEX_EDIT';
25 add_access_extensions();
27 $_SESSION['page_title'] = _($help_context = "Item schedule");
31 page($_SESSION['page_title'], false, false, "", $js);
33 //---------------------------------------------------------------------------------------------
35 div_start('item_schedule');
39 start_table(TABLESTYLE_NOBORDER);
42 if (!isset($_POST['stock_id'])) {
43 if (isset($_GET['stock_id']))
45 $_POST['stock_id'] = $_GET['stock_id'];
48 $_POST['stock_id'] = get_global_stock_item();
52 if (list_updated('stock_id') || in_ajax()) $Ajax->activate('item_schedule') ;
53 else update_queue_quantities() && update_qoh_for_item();
56 //if (!@$_GET['popup'])
61 $stock_id = $_POST['stock_id'];
62 stock_costable_items_list_cells(_("Item:"), 'stock_id', $stock_id);
67 if(isset($stock_id)) echo '<input type="hidden" name="last_stock_id" value="'.$stock_id.'">';
69 if(isset($_POST['Update'])) {
70 $Ajax->activate('item_schedule');
71 // Restore the parameters
72 $params = new ScheduleParameters($_SESSION['schedule_parameters']);
73 $params->setMode('update');
76 $params = in_ajax() && $stock_id == @$_POST['last_stock_id'] ? new ScheduleParameters($_POST) : null;
77 // save parameters form update
78 $_SESSION['schedule_parameters'] = $_POST;
80 $scheduler = new ItemScheduler($stock_id, 'DEF', $params);
83 start_table(TABLESTYLE);
84 $th = $scheduler->tableHeader();
88 $scheduler->generateTable();
93 if($scheduler->needsUpdate()) {
94 submit_center_first('Update', _("Update"), '', 'default', false);
95 submit_center_last('Cancel', _("Cancel"), '', 'cancel', false);
104 <style type='text/css'>
109 tr.partial td:nth-child(5) {
130 border: 2px solid black;
132 tr.tDnD_whileDrag :nth-child(4), tr.tDnD_whileDrag :nth-child(5) {
134 background: transparent;
137 <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
138 <script src="js/jquery.tablednd.0.8.min.js"></script>
139 <script text="text/javascript">
141 /** add table DnD as behavior **/
142 function onDragStart (table, row) {
146 function findRowPosition(table, row) {
148 function addInput(form, name, value) {
149 $(form).append('<input type="hidden" name="'+name+'" value="'+value+'">')
151 function addInputs(form, name, values) {
152 for(index = 0; index < values.length; index++) {
153 addInput(form, name+'['+index+']', values[index])
156 function onDrop(table, row) {
157 var row_ids = $.map(table.tBodies[0].rows, function(r) { return r.id} )
159 var form = $(table).closest('form')[0]
161 addInput(form, 'row_id', row.id)
162 addInputs(form, 'row_order', row_ids )
164 JsHttpRequest.request(this, form);
169 '#item_schedule table': function (e) {
170 $(e).tableDnD({onDragStart: onDragStart, onDrop: onDrop})
173 Behaviour.register(inserts);