Date saves properly.
authorMaxime Bourget <bmx007@gmail.com>
Fri, 7 Jun 2013 08:59:53 +0000 (09:59 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Fri, 7 Jun 2013 08:59:53 +0000 (09:59 +0100)
includes/order_lines.inc
order_lines_view.php

index d17022263c86f66a4052aa8485eb25f989999b91..d94c4dea7e35d4e5c19eb2559e9935fe427b5277 100644 (file)
@@ -34,29 +34,33 @@ function update_extra_order_details() {
 
 begin_transaction();
        // update in database all field
+       $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' ");
-               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' ");
+               foreach($date_fields as $date_field) {
+                       if(isset($values[$date_field])) {
+                               $input_date = trim($values[$date_field]);
+                               if($input_date == "")  {
+                                       array_push($set," $date_field = NULL");
+                               } else {
+                                       $date = date2sql($input_date);
+                                       array_push($set," $date_field='$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;
                        }
                }
-       
+commit_transaction();
+
        }
 
        display_notification('Order details updated');
@@ -75,13 +79,13 @@ function view_link($dummy, $order_no)
 
 function item_link($dummy, $stock_id)
 {
-  return pager_link( _($stock_id),
+       return pager_link( _($stock_id),
        "/modules/order_line_extra/item_schedule.php?stock_id=" .$stock_id);
 }
 
 function order_link($row)
 {
-  return pager_link( _("Sales Order"),
+       return pager_link( _("Sales Order"),
        "/sales/sales_order_entry.php?NewQuoteToSalesOrder=" .$row['order_no'], ICON_DOC);
 }
 
@@ -91,7 +95,7 @@ function customer_link($row) {
 
 function customer_link2($name, $id) {
        return pager_link(_($name), "/modules/order_line_extra/order_lines_view.php?customer_id=${id}");
-       
+
 }
 
 function aggregate_comment($row) {
@@ -119,9 +123,9 @@ function available_quantity($row, $available) {
        return "<span class='$class'>$available<span>";
 }
 
-function input_date_details($row, $date) {
+function input_date_details($row, $field_name, $date) {
 $row_id = $row['id'];
-       $name = compute_input_name($row, 'required_date');
+       $name = compute_input_name($row, $field_name);
 
 $_POST[$name] = sql2date($date);
 
@@ -135,6 +139,22 @@ $_POST[$name] = sql2date($date);
 ";
 }
 
+function input_priority_date_details($row, $date) {
+       return input_date_details($row, 'priority', $date);
+}
+
+function input_hold_until_date_details($row, $date) {
+       return input_date_details($row, 'hold_until_date', $date);
+}
+
+function input_required_date_details($row, $date) {
+       return input_date_details($row, 'required_date', $date);
+}
+
+function input_expiry_date_details($row, $date) {
+       return input_date_details($row, 'expiry_date', $date);
+}
+
 function input_comment_details($row, $comment) {
 $row_id = $row['id'];
        return "
index 227a15c5d5eab4b86d25fddcd59ebbb1c3635493..c96c3e63f807c59afd090d2e2410679caf5cb615 100644 (file)
@@ -76,10 +76,10 @@ if($customer_id) {
                ,_("Quantity") => array('type' => 'qty', 'dec' => 0)
                ,_("Available") => array('fun' => 'available_quantity', 'dec' => 0, 'ord' => '')
                ,_("Before") => 'skip'
-               ,_("Priority") => array('fun' => 'input_date_details', 'ord' => '')
-               ,_("Hold Until") => array('fun' => 'input_date_details', 'ord' => '')
-               ,_("Require By") => array('fun' => 'input_date_details', 'ord' => '')
-               ,_("Expiry Date") => array('fun' => 'input_date_details', 'ord' => '')
+               ,_("Priority") => array('fun' => 'input_priority_date_details', 'ord' => '')
+               ,_("Hold Until") => array('fun' => 'input_hold_until_date_details', 'ord' => '')
+               ,_("Require By") => array('fun' => 'input_required_date_details', 'ord' => '')
+               ,_("Expiry Date") => array('fun' => 'input_expiry_date_details', 'ord' => '')
        ,_("Comment") => array('fun' => 'input_comment_details', 'ord' => '')
        );
 }