Merge branch 'branches/default' of hg::ssh://itronics@frontaccounting.hg.sourceforge...
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Fri, 15 Mar 2013 18:55:25 +0000 (19:55 +0100)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Fri, 15 Mar 2013 18:55:25 +0000 (19:55 +0100)
includes/db/sql_functions.inc
purchasing/includes/po_class.inc
purchasing/po_entry_items.php
sales/create_recurrent_invoices.php
sales/includes/cart_class.inc
sales/includes/db/cust_trans_db.inc
sales/inquiry/sales_orders_view.php
sales/sales_order_entry.php

index 85a25137df35b6b0997766b38bd4781421366f18..febc3af824e4f1246be0f9659a7a6aced26616ab 100644 (file)
@@ -55,7 +55,7 @@ function cancel_transaction()
 //
 function update_record_status($id, $status, $table, $key) {
        $sql = "UPDATE ".TB_PREF.$table." SET inactive = "
-               . db_escape($status)." WHERE $key=".db_escape($id);
+               . ((int)$status)." WHERE $key=".db_escape($id);
                
        db_query($sql, "Can't update record status");
 }
index b767e9ea9261f66e9ee64245c4f9067bae4bd475..a7b9db37c70775b207c20fce5ac2d8996b1e1773 100644 (file)
@@ -55,7 +55,7 @@ class purch_order
        
        function add_to_order($line_no, $stock_id, $qty, $item_descr, $price, $uom, $req_del_date, $qty_inv, $qty_recd)
        {
-               if ($qty != 0 && isset($qty))
+               if (isset($qty) && $qty != 0)
                {
                        $this->line_items[$line_no] = new po_line_details($line_no, $stock_id, $item_descr, $qty, $price, $uom, 
                                $req_del_date, $qty_inv, $qty_recd);
index a2c3d5f7f423af75e47bef2c119d062e7b199cf0..1f0bfedd7cd416db42b2e84e95b938e0c50f617c 100644 (file)
@@ -437,7 +437,8 @@ function handle_commit_order()
                        //Direct GRN
                        if ($cart->trans_type == ST_SUPPRECEIVE)
                                $cart->reference = $ref;
-                       $cart->Comments = $cart->reference; //grn does not hold supp_ref
+                       if ($cart->trans_type != ST_SUPPINVOICE)        
+                               $cart->Comments = $cart->reference; //grn does not hold supp_ref
                        foreach($cart->line_items as $key => $line)
                                $cart->line_items[$key]->receive_qty = $line->quantity;
                        $grn_no = add_grn($cart);
index 15b71d8ec840ecf0552caa11466a99aec9046f7c..0db31150c409ca2d00228c16bafc1e53ae3d8a95 100644 (file)
@@ -39,7 +39,9 @@ function create_recurrent_invoices($customer_id, $branch_id, $order_no, $tmpl_no
 
        $doc->due_date = get_invoice_duedate($doc->payment, $doc->document_date);
        $doc->reference = $Refs->get_next($doc->trans_type);
-       $doc->Comments = sprintf(_("Recurrent Invoice covers period %s - %s."), $from, add_days($to, -1));
+       if ($doc->Comments != "")
+               $doc->Comments .= "\n";
+       $doc->Comments .= sprintf(_("Recurrent Invoice covers period %s - %s."), $from, add_days($to, -1));
 
        foreach ($doc->line_items as $line_no=>$item) {
                $line = &$doc->line_items[$line_no];
@@ -109,7 +111,7 @@ if ($id != -1)
                if (count($invs) > 0)
                {
                        $ar = array('PARAM_0' => $min."-".ST_SALESINVOICE,      'PARAM_1' => $max."-".ST_SALESINVOICE, 'PARAM_2' => "",
-                               'PARAM_3' => 0, 'PARAM_4' => 0, 'PARAM_5' => "", 'PARAM_6' => ST_SALESINVOICE);
+                               'PARAM_3' => 0, 'PARAM_4' => 0, 'PARAM_5' => "", 'PARAM_6' => $def_print_orientation);
                        display_note(print_link(sprintf(_("&Print Recurrent Invoices # %s - # %s"), $min, $max), 107, $ar), 0, 1);
                        $ar['PARAM_3'] = 1; // email
                        display_note(print_link(sprintf(_("&Email Recurrent Invoices # %s - # %s"), $min, $max), 107, $ar), 0, 1);
index 6a014d5aba85425fbc9f5df77e3ef5b0461a165e..4b01809feba94a838edcec70a395ef0c93241c61 100644 (file)
@@ -104,6 +104,9 @@ class cart
 
                $this->trans_type = $type;
                $this->reference = $Refs->get_next($this->trans_type);
+               if ($type == ST_CUSTCREDIT)
+                   $this->src_date = $this->document_date;
+
                $this->document_date = new_doc_date();
 
                for($line_no = 0; $line_no < count($this->line_items); $line_no++) {
@@ -124,9 +127,6 @@ class cart
                        $this->due_date = get_invoice_duedate($this->payment, $this->document_date);
                }
 
-               if ($type == ST_CUSTCREDIT)
-                   $this->src_date = $this->document_date;
-
                $this->src_docs = $this->trans_no;
                $this->trans_no = 0;
        }
index 52f05b0f30b2ce014b6589778257f27dcec7fdb4..4f92807a468ea3a831f2e8cad3f7921ff8c17be2 100644 (file)
@@ -103,7 +103,7 @@ function write_customer_trans($trans_type, $trans_no, $debtor_no, $BranchNo,
                ov_freight=".db_escape($Freight).", ov_freight_tax=$FreightTax, rate=$rate,
                ship_via=".db_escape($ship_via).", alloc=$AllocAmt,
                dimension_id=".db_escape($dimension_id).", dimension2_id=".db_escape($dimension2_id).",
-               payment_terms=".db_escape($payment_terms)."
+               payment_terms=".db_escape($payment_terms, true)."
                WHERE trans_no=".db_escape($trans_no)." AND type=".db_escape($trans_type);
        }
        db_query($sql, "The debtor transaction record could not be inserted");
index f59be9c028bb5de375939bc49421bd8c3b1dbdb1..da43c0f518f4e863ad707b84973c0a04d7438015 100644 (file)
@@ -286,17 +286,17 @@ else
                _("Currency") => array('align'=>'center')
        );
 if ($_POST['order_view_mode'] == 'OutstandingOnly') {\r
-       //array_substitute($cols, 3, 1, _("Cust Order Ref"));\r
+       //array_substitute($cols, 4, 1, _("Cust Order Ref"));\r
        array_append($cols, array(\r
                array('insert'=>true, 'fun'=>'dispatch_link'),\r
                array('insert'=>true, 'fun'=>'edit_link')));\r
 
 } elseif ($_POST['order_view_mode'] == 'InvoiceTemplates') {
-       array_substitute($cols, 3, 1, _("Description"));
+       array_substitute($cols, 4, 1, _("Description"));
        array_append($cols, array( array('insert'=>true, 'fun'=>'invoice_link')));
 
 } else if ($_POST['order_view_mode'] == 'DeliveryTemplates') {
-       array_substitute($cols, 3, 1, _("Description"));
+       array_substitute($cols, 4, 1, _("Description"));
        array_append($cols, array(
                        array('insert'=>true, 'fun'=>'delivery_link'))
        );
index 50cc4470c5cd731199ee9b2a851f5742d6e048bb..da9b9ce9a275b94a72ae8c3a1534eeaec92d6ae3 100644 (file)
@@ -62,12 +62,12 @@ if ($use_date_picker) {
 if (isset($_GET['NewDelivery']) && is_numeric($_GET['NewDelivery'])) {
 
        $_SESSION['page_title'] = _($help_context = "Direct Sales Delivery");
-       create_cart(ST_CUSTDELIVERY, 0);
+       create_cart(ST_CUSTDELIVERY, $_GET['NewDelivery']);
 
 } elseif (isset($_GET['NewInvoice']) && is_numeric($_GET['NewInvoice'])) {
 
        $_SESSION['page_title'] = _($help_context = "Direct Sales Invoice");
-       create_cart(ST_SALESINVOICE, 0);
+       create_cart(ST_SALESINVOICE, $_GET['NewInvoice']);
 
 } elseif (isset($_GET['ModifyOrderNumber']) && is_numeric($_GET['ModifyOrderNumber'])) {