lock(distable) all fields.
authorMaxime Bourget <bmx007@gmail.com>
Sun, 9 Jun 2013 13:44:42 +0000 (14:44 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Sun, 9 Jun 2013 13:48:32 +0000 (14:48 +0100)
includes/order_lines.inc
order_lines_view.php

index 0d2b5118e671944eb5ee97eabc734a7812b52e1b..c8564edc02200e37f64adf55c2e814eab19ba566 100644 (file)
@@ -40,6 +40,7 @@ function filter_data(&$data) {
 }
 
 function post_to_detail_ids() {
+       if(!isset($_POST['detail'])) return;
        $detail_ids = array();
        foreach($_POST['detail'] as $detail_id => $values) {
                array_push($detail_ids, $detail_id);
@@ -52,6 +53,7 @@ function update_extra_order_details() {
        if(!isset($_POST['Update']) || $_POST['Update'] != 'Update')  return;
 
        $cart = post_to_detail_ids();
+       if($cart === null) return;
 begin_transaction();
        hook_db_prewrite($cart, 'order_xtra');
        // update in database all field
@@ -96,6 +98,7 @@ function split_order_details() {
        $splitter = new Splitter($_POST);
        begin_transaction();
        $cart = post_to_detail_ids();
+       if($cart === null) return;
        hook_db_prewrite($cart, 'order_xtra');
                if($splitter->splitAll()) display_warning("Items have been split.");
        hook_db_postwrite($cart, 'order_xtra');
index 1eb0c0c2ec732da0a03d38a8cbeaf238d5e396af..2c28ba401cf7d82e89da86e48cfea99bbec7bea5 100644 (file)
@@ -175,8 +175,30 @@ var inserts = {
        '#checkAll': function (e) {
                e.onchange = function()  {
                        $('.check_detail').prop('checked', e.checked)
+                       $('.check_detail').trigger('change');
                }
        }
+       ,'tr': function(e) {
+                       // find if there is a check detail box on link all input to it
+                       var tr = $(e);
+                       var check = tr.find('.check_detail');
+                       if(check.length != 1) return;
+                       check = check[0];
+                       var jcheck = $(check);
+                       var inputs = tr.find('input');
+                       inputs.each(function(index, input) {
+                               if(input === check) return;
+                               $(input).prop('disabled', true)
+                       })
+
+                       check.onchange = function() {
+                               inputs.each(function(index, input) {
+                                       var on = jcheck.prop('checked')
+                                       if(input == check) return;
+                                       $(input).prop('disabled', !on);
+                               })
+                       };
+               }
        }
 Behaviour.register(inserts);
 </script>