Filter uncheked item.
authorMaxime Bourget <bmx007@gmail.com>
Sun, 9 Jun 2013 10:29:23 +0000 (11:29 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Sun, 9 Jun 2013 10:31:51 +0000 (11:31 +0100)
Don't update or split unchecked items.

includes/order_lines.inc
order_lines_view.php

index 4473ef08d2274fc1a0b68fc2fdd34b9cc1eedbeb..0d2b5118e671944eb5ee97eabc734a7812b52e1b 100644 (file)
@@ -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]);
index dd504de106c116b1d18e53972b0bb352a6aac94d..1eb0c0c2ec732da0a03d38a8cbeaf238d5e396af 100644 (file)
@@ -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'];