Fixed entering direct sales documents with date in the past [0000036].
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sat, 16 Aug 2008 22:08:36 +0000 (22:08 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sat, 16 Aug 2008 22:08:36 +0000 (22:08 +0000)
sales/customer_delivery.php
sales/includes/cart_class.inc

index 6d30256e82f9f78cabb8eaab075f28426de84620..4b6726efa1e21690c87a22a4ecfec0f60827db7f 100644 (file)
@@ -88,6 +88,7 @@ if (isset($_GET['OrderNumber']) && $_GET['OrderNumber'] > 0) {
        $ord->order_no = key($ord->trans_no);
        $ord->trans_no = 0;
        $ord->reference = references::get_next(13);
+       $ord->document_date = Today();
        $_SESSION['Items'] = $ord;
        copy_from_cart();
 
index 38ffeba76be1147b2bb0dc9bff49cb59e741dfdf..46427af4cdc6492269df93ab7f7f61f22ace203e 100644 (file)
@@ -84,7 +84,6 @@ class cart
                                                $line = &$this->line_items[$line_no];
                                                $line->qty_dispatched = $line->quantity - $line->qty_done;
                                        }
-                                       $this->document_date = Today();
                                }
                                } else {        // derivative transaction
                                        read_sales_trans($type, $trans_no, $this);
@@ -155,17 +154,28 @@ class cart
                        $src->reference = 'auto';
 
                        $src->write(1);
-
                        $type = $this->trans_type;
                        $ref = $this->reference;
+                       $date = $this->document_date;
                        // re-read document
                        $this->read($src->trans_type, key($src->trans_no), true);
+                       $this->document_date = $date;
                        $this->reference = $ref;
                        $this->trans_type = $type;
                        $this->src_docs= $this->trans_no;
                        $this->trans_no = 0;
                        $this->order_no= $this->trans_type==13 ? key($src->trans_no) : $src->order_no;
                }
+// if we want to save old or derivative document first decode html entities
+// from text fields. For new documents this is not needed.
+               if ($this->trans_no || $this->trans_type != 30) {
+                       $this->reference = @html_entity_decode($this->reference);
+                       $this->Comments = @html_entity_decode($this->Comments);
+                       foreach($this->line_items as $lineno => $line) {
+                               $this->line_items[$lineno]->stock_id = @html_entity_decode($line->stock_id);
+                               $this->line_items[$lineno]->description = @html_entity_decode($line->description);
+                       }
+               }
                switch($this->trans_type) {
                        case 10:
                                return write_sales_invoice($this);