onDrop send data to backend.
authorMaxime Bourget <bmx007@gmail.com>
Sat, 1 Jun 2013 10:46:47 +0000 (11:46 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Sat, 1 Jun 2013 10:46:47 +0000 (11:46 +0100)
haxe/ItemScheduler.hx
item_schedule.php

index b86ab861e03cf2b8f8b3ba292896c56944eaa71d..be596ac4d121b87f0f547ed3e59984c3c4dbf2fd 100644 (file)
@@ -127,7 +127,8 @@ class ItemScheduler {
        }
 
        function formatOrder(order : Dynamic, left : Int, date : Date) {
-                       var attributes = ['id = "order_'+order.id+'"'];
+                       var row_id = 'order_'+order.id;
+                       var attributes = ['id = "'+row_id+'"'];
                        var classes = [];
                        var before : Int = left + order.quantity;
                        /* We have basically 3 different cases;
@@ -159,7 +160,7 @@ class ItemScheduler {
                        var cells : Array <Dynamic> = [
                                order.order_id
                                , '<a href="/modules/order_line_extra/order_lines_view.php?customer_id='+Std.string(order.debtor_no)+'">'+order.deliver_to+'</a>'
-                               ,order.quantity
+                       ,'<input type="text" name="'+row_id+'[quantity]" value="'+order.quantity+'">'
                                ,before
                                ,left
                                ,order.from_stk_loc
@@ -184,7 +185,7 @@ class ItemScheduler {
                var cells : Array<Dynamic> = [
                        array.get('order_id')
                        ,array.get('deliver_to')
-                       ,quantity
+                       ,'<input type="text" name="quantity">'+quantity+'</input>'
                        ,quantity_available-quantity
                        ,quantity_available
                        ,array.get('from_stk_loc')
index 8fb4247993b8c33589b038d0cf3df6a5462ad9bf..7276bdc5f970d7c2985c90121994348a63e4cc50 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,11 @@ else {
        $_POST['stock_id'] = get_global_stock_item();
        }
 }
+
 if (list_updated('stock_id')) 
        $Ajax->activate('item_schedule');
+if (in_ajax())
+       $Ajax->activate('item_schedule');
 
 //if (!@$_GET['popup'])
        start_form();
@@ -65,7 +70,6 @@ end_table(1);
 
 $scheduler = new ItemScheduler($stock_id, 'DEF');
 
-div_start('item_schedule');
 start_table(TABLESTYLE);
 $th = $scheduler->tableHeader();
 
@@ -74,7 +78,6 @@ table_header($th);
 $scheduler->generateTable();
 
 end_table();
-div_end();
 
 
 submit_center_first('Update', _("Update"), '', 'default', false);
@@ -83,6 +86,7 @@ submit_center_last('Cancel', _("Cancel"), '', 'cancel', false);
 
 
 end_form();
+div_end();
 end_page();
 ?>
 <style type='text/css'>
@@ -127,10 +131,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);
                
        }