Fixed recurrent invoices messages, new recurrent invoices now show no last date.
authorJanusz Dobrowolski <janusz@frontaccouting.eu>
Mon, 9 May 2011 14:33:29 +0000 (16:33 +0200)
committerJanusz Dobrowolski <janusz@frontaccouting.eu>
Mon, 9 May 2011 14:33:29 +0000 (16:33 +0200)
sales/create_recurrent_invoices.php
sales/includes/db/recurrent_invoices_db.inc
sales/manage/recurrent_invoices.php

index dcc9cffe44c4c11b3ab491cf18ac1707894b55ff..20a6367c2c34211ba2a9c8d965ad20b4fd2e343d 100644 (file)
@@ -78,14 +78,14 @@ if (isset($_GET['recurrent']))
                }
                else 
                        $min = $max = 0;
-               display_notification(sprintf(_("%s recurrent invoice(s) created, # $min - # $max."), count($invs)));
+               display_notification(sprintf(_("%s recurrent invoice(s) created, # %s - # %s."), count($invs), $min, $max));
                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);
-                       display_note(print_link(_("&Print Recurrent Invoices # $min - # $max"), 107, $ar), 0, 1);
-                       $ar['PARAM_3'] = 1; 
-                       display_note(print_link(_("&Email Recurrent Invoices # $min - # $max"), 107, $ar), 0, 1);
+                       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);
                }
        }
        else
@@ -104,11 +104,18 @@ while ($myrow = db_fetch($result))
 {
        $begin = sql2date($myrow["begin"]);
        $end = sql2date($myrow["end"]);
-       $last_sent = sql2date($myrow["last_sent"]);
-       if ($myrow['monthly'] > 0)
-               $due_date = begin_month($last_sent);
-       else
-               $due_date = $last_sent;
+
+       if ($myrow["last_sent"] == '0000-00-00')
+       {
+               $last_sent = '';
+               $due_date = $myrow["begin"];
+       } else {
+               $last_sent = sql2date($myrow["last_sent"]);
+               if ($myrow['monthly'] > 0)
+                       $due_date = begin_month($last_sent);
+               else
+                       $due_date = $last_sent;
+       }
        $due_date = add_months($due_date, $myrow['monthly']);
        $due_date = add_days($due_date, $myrow['days']);
        $overdue = date1_greater_date2($today, $due_date) && date1_greater_date2($today, $begin)
index 4ff6854973bfa79bd7168ff33e382767bb6b7a11..0d4dd98b8388bbf3052972204623e4c0cb32c85e 100644 (file)
@@ -17,7 +17,7 @@ function add_recurrent_invoice($description, $order_no, $debtor_no, $group_no, $
                group_no, days, monthly, begin, end, last_sent) VALUES (".db_escape($description) . ", "
                .db_escape($order_no).", ".db_escape($debtor_no).", "
                .db_escape($group_no).", ".$days.", ".$monthly.", '"
-               .date2sql($begin)."', '".date2sql($end)."', '".date2sql(Add_Years($begin, -5))."')";
+               .date2sql($begin)."', '".date2sql($end)."', '0000-00-00')";
        db_query($sql,"The recurrent invoice could not be added");
 }
 
index 785c2a44d0203d4c8ed32fc12a79a07cce7f6089..836fcab0b1934b5b5f1fc028ca9773ddd56a59bc 100644 (file)
@@ -89,7 +89,7 @@ while ($myrow = db_fetch($result))
 {
        $begin = sql2date($myrow["begin"]);
        $end = sql2date($myrow["end"]);
-       $last_sent = sql2date($myrow["last_sent"]);
+       $last_sent = $myrow["last_sent"] == '0000-00-00' ? '' : sql2date($myrow["last_sent"]);
        
        alt_table_row_color($k);