Save in database.
authorMaxime Bourget <bmx007@gmail.com>
Sun, 5 May 2013 21:37:21 +0000 (22:37 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Sun, 5 May 2013 21:37:21 +0000 (22:37 +0100)
includes/order_lines.inc
order_lines_view.php

index 050fa825c6a9b6828d70782b6ceb4fde114fc16e..71eebdd08be05be0d291d6a66417d2dd9414e5b8 100644 (file)
@@ -1,6 +1,40 @@
 <?php
 include_once($path_to_root."/includes/ui/ui_input.inc");
 
+function update_extra_order_details() {
+       if(!isset($_POST['Update']) || $_POST['Update'] != 'Update')  return;
+
+begin_transaction();
+       // update in database all field
+       foreach($_POST['detail'] as $detail_id => $values) {
+               $set = array();
+               if($comment = $values['comment'])  array_push($set, " comment='$comment' ");
+               if(isset($values['required_date'])) {
+                       $required_date = trim($values['required_date']);
+                       if($required_date == "")  {
+                               array_push($set," required_date = NULL");
+                       } else {
+                               $date = date2sql($required_date);
+                               array_push($set," required_date='$date' ");
+                       }
+               }
+
+               if(!empty($set))  {
+                       $sql = "UPDATE ".TB_PREF."sales_order_details  SET ".implode($set,', ')."  WHERE id = $detail_id ";
+                       
+                       if(!db_query($sql)) {
+                               display_error('Problem while updating order details. Try again');
+                               cancel_transaction();
+                               return;
+                       }
+               }
+       
+       }
+
+       display_notification('Order details updated');
+
+}
+
 function compute_input_name($row, $field) {
        $row_id = $row['id'];
        return "detail[$row_id][$field]";
index 99fb6d9b10321eea59dfadab8b9b5c16a5f5237a..34dae4783ac580e1dd86576d16fe8f4d743f976d 100644 (file)
@@ -23,6 +23,8 @@ add_access_extensions();
 
 $_SESSION['page_title'] = _($help_context = "Edit lines extra parameters");
 
+update_extra_order_details();
+
 $js = "";
 if ($use_popup_windows)
        $js .= get_js_open_window(900, 600);