Parse POST data.
[order_line_extra.git] / item_schedule.php
index 8fb4247993b8c33589b038d0cf3df6a5462ad9bf..4de176c997cd0776f596f6d1d1a743d9fac0e809 100644 (file)
@@ -31,11 +31,13 @@ page($_SESSION['page_title'], false, false, "", $js);
 
 //---------------------------------------------------------------------------------------------
 
+div_start('item_schedule');
 start_form();
 
 start_table(TABLESTYLE_NOBORDER);
 start_row();
 
+echo date('h:i:s <br>',time());
 ?>GET<?php
 print_r($_GET);
 ?>POST<?php
@@ -50,8 +52,8 @@ else {
        $_POST['stock_id'] = get_global_stock_item();
        }
 }
-if (list_updated('stock_id')) 
-       $Ajax->activate('item_schedule');
+
+if (list_updated('stock_id') || in_ajax()) $Ajax->activate('item_schedule');
 
 //if (!@$_GET['popup'])
        start_form();
@@ -60,12 +62,13 @@ if (list_updated('stock_id'))
 $stock_id = $_POST['stock_id'];
        stock_costable_items_list_cells(_("Item:"), 'stock_id', $stock_id);
 
+
 end_row();
 end_table(1);
 
-$scheduler = new ItemScheduler($stock_id, 'DEF');
+$params = in_ajax() ? new ScheduleParameters($_POST) : null;
+$scheduler = new ItemScheduler($stock_id, 'DEF', $params);
 
-div_start('item_schedule');
 start_table(TABLESTYLE);
 $th = $scheduler->tableHeader();
 
@@ -74,7 +77,6 @@ table_header($th);
 $scheduler->generateTable();
 
 end_table();
-div_end();
 
 
 submit_center_first('Update', _("Update"), '', 'default', false);
@@ -83,6 +85,7 @@ submit_center_last('Cancel', _("Cancel"), '', 'cancel', false);
 
 
 end_form();
+div_end();
 end_page();
 ?>
 <style type='text/css'>
@@ -127,10 +130,24 @@ tr.tDnD_whileDrag :nth-child(4), tr.tDnD_whileDrag :nth-child(5) {
        console.log(table)
                console.log(row)
        }
+       function findRowPosition(table, row) {
+       }
+       function addInput(form, name, value) {
+               $(form).append('<input type="hidden" name="'+name+'" value="'+value+'">')
+                       }
+       function addInputs(form, name, values) {
+               for(index = 0; index < values.length; index++) {
+                               addInput(form, name+'['+index+']', values[index])
+                               }
+                       }
        function onDrop(table, row) {
                var row_ids = $.map(table.tBodies[0].rows, function(r) { return r.id} )
                var row_id = row.id
                var form = $(table).closest('form')[0]
+               
+               addInput(form, 'row_id', row.id)
+               addInputs(form, 'row_order', row_ids )
+               
                JsHttpRequest.request(this, form);
                
        }