From: Maxime Bourget Date: Sun, 9 Jun 2013 13:44:42 +0000 (+0100) Subject: lock(distable) all fields. X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=de576b1ca7e1032b17a43034dc187e8a3f9c6390;p=order_line_extra.git lock(distable) all fields. --- diff --git a/includes/order_lines.inc b/includes/order_lines.inc index 0d2b511..c8564ed 100644 --- a/includes/order_lines.inc +++ b/includes/order_lines.inc @@ -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'); diff --git a/order_lines_view.php b/order_lines_view.php index 1eb0c0c..2c28ba4 100644 --- a/order_lines_view.php +++ b/order_lines_view.php @@ -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);