From: Maxime Bourget Date: Sun, 9 Jun 2013 10:29:23 +0000 (+0100) Subject: Filter uncheked item. X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=af8da11e817547a7293e8bf4a297dd0a7140497a;p=order_line_extra.git Filter uncheked item. Don't update or split unchecked items. --- diff --git a/includes/order_lines.inc b/includes/order_lines.inc index 4473ef0..0d2b511 100644 --- a/includes/order_lines.inc +++ b/includes/order_lines.inc @@ -27,6 +27,18 @@ function extract_cell($td) { } } +/* remove unchecked data so each + * funcion doesn't to check what's been checked or not. + */ +function filter_data(&$data) { + if(!isset($data['detail'])) return; + $new_details = array(); + foreach(@$data['detail'] as $detail_id => $values) { + if(@$values['check'] === 'on') $new_details[$detail_id]=$values; + } + $data['detail'] = $new_details; +} + function post_to_detail_ids() { $detail_ids = array(); foreach($_POST['detail'] as $detail_id => $values) { @@ -46,7 +58,8 @@ begin_transaction(); $date_fields = array('hold_until_date', 'required_date', 'expiry_date', 'priority'); foreach($_POST['detail'] as $detail_id => $values) { $set = array(); - if($comment = $values['comment']) array_push($set, " comment='$comment' "); + $comment=$values['comment']; + array_push($set, " comment='$comment' "); // erase comment if needed. foreach($date_fields as $date_field) { if(isset($values[$date_field])) { $input_date = trim($values[$date_field]); diff --git a/order_lines_view.php b/order_lines_view.php index dd504de..1eb0c0c 100644 --- a/order_lines_view.php +++ b/order_lines_view.php @@ -25,6 +25,7 @@ add_access_extensions(); $_SESSION['page_title'] = _($help_context = "Edit lines extra parameters"); // Process POST +filter_data($_POST); update_extra_order_details(); split_order_details(); @@ -57,7 +58,7 @@ else { } customer_list_cells(_("Select a customer: "), 'customer_id', $customer_id, true, true); -if($customer_id !== null) { +if($customer_id != null) { if(!isset($_POST['item_like'])) { if(isset($_GET['item_like'])) { $item_like = $_GET['item_like'];