Remove trace.
[order_line_extra.git] / item_schedule.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/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");
19
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
24 $page_security = 'SA_ORDERLINEX_EDIT';
25 add_access_extensions();
26
27 $_SESSION['page_title'] = _($help_context = "Item schedule");
28
29
30 $js = "";
31 page($_SESSION['page_title'], false, false, "", $js);
32
33 //---------------------------------------------------------------------------------------------
34
35 div_start('item_schedule');
36 start_form();
37
38
39 start_table(TABLESTYLE_NOBORDER);
40 start_row();
41
42 if (!isset($_POST['stock_id'])) {
43 if (isset($_GET['stock_id']))
44 {
45         $_POST['stock_id'] = $_GET['stock_id'];
46 }
47 else {
48         $_POST['stock_id'] = get_global_stock_item();
49         }
50 }
51
52 if (list_updated('stock_id') || in_ajax()) $Ajax->activate('item_schedule');
53
54 //if (!@$_GET['popup'])
55 //      start_form();
56
57
58
59 $stock_id = $_POST['stock_id'];
60         stock_costable_items_list_cells(_("Item:"), 'stock_id', $stock_id);
61
62
63 end_row();
64 end_table(1);
65 if(isset($stock_id)) echo '<input type="hidden" name="last_stock_id" value="'.$stock_id.'">';
66
67 if(isset($_POST['Update'])) {
68         $Ajax->activate('item_schedule');
69         // Restore the parameters
70         $params = new ScheduleParameters($_SESSION['schedule_parameters']);
71         $params->setMode('update');
72 }
73 else {
74         $params = in_ajax() && $stock_id == @$_POST['last_stock_id'] ? new ScheduleParameters($_POST) : null;
75         // save parameters form update
76         $_SESSION['schedule_parameters'] = $_POST;
77 }
78 $scheduler = new ItemScheduler($stock_id, 'DEF', $params);
79 $scheduler->action();
80
81 start_table(TABLESTYLE);
82 $th = $scheduler->tableHeader();
83
84 table_header($th);
85
86 $scheduler->generateTable();
87
88 end_table();
89
90
91 if($scheduler->needsUpdate()) {
92          submit_center_first('Update', _("Update"), '', 'default', false);
93         submit_center_last('Cancel', _("Cancel"), '', 'cancel', false);
94 }
95
96
97
98 end_form();
99 div_end();
100 end_page();
101 ?>
102 <style type='text/css'>
103 tr.partial {
104         color: darkred;
105 }
106
107 tr.partial  td:nth-child(5) {
108         background: pink;
109 }
110
111 tr.location {
112         font-weight: normal;
113                 background: #8f8;
114 }
115 tr.on_time {
116 }
117
118 tr.late {
119                 background: #fc8;
120 }
121
122 tr.soldout {
123                 background: pink;
124 }
125
126 tr.tDnD_whileDrag {
127         background: #ccc;
128         border: 2px solid black;
129 }
130 tr.tDnD_whileDrag :nth-child(4), tr.tDnD_whileDrag :nth-child(5) {
131         color: transparent;
132         background: transparent;
133 }
134 </style>
135 <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
136 <script src="js/jquery.tablednd.0.8.min.js"></script>
137 <script text="text/javascript">
138         console.log('hello')
139         /**  add table DnD as behavior **/
140         function onDragStart (table, row) {
141         console.log(table)
142                 console.log(row)
143         }
144         function findRowPosition(table, row) {
145         }
146         function addInput(form, name, value) {
147                 $(form).append('<input type="hidden" name="'+name+'" value="'+value+'">')
148                         }
149         function addInputs(form, name, values) {
150                 for(index = 0; index < values.length; index++) {
151                                 addInput(form, name+'['+index+']', values[index])
152                                 }
153                         }
154         function onDrop(table, row) {
155                 var row_ids = $.map(table.tBodies[0].rows, function(r) { return r.id} )
156                 var row_id = row.id
157                 var form = $(table).closest('form')[0]
158                 
159                 addInput(form, 'row_id', row.id)
160                 addInputs(form, 'row_order', row_ids )
161                 
162                 JsHttpRequest.request(this, form);
163                 
164         }
165
166         var inserts = {
167                 '#item_schedule table': function (e) { 
168                         $(e).tableDnD({onDragStart: onDragStart, onDrop: onDrop})
169                 }
170         }
171 Behaviour.register(inserts);
172 </script>