Note: there is a new and simpler invocing number solution - please refer to : this forum post
Update: Refer invoice_numbering_groups Separate invoice number ranges is now included in Simple Invoices 2010.2
after installing simpleinvoices and configuring it I loved it. I made some invoices and all went well but then I made a Quote and disaster stroke! basicly I had 2 invoices : number 1 and number 2 and a quote with number 3 on it. Where I live (belgium) u need corresponding numbers on invoices (1,2,3,4,etc), if a number is missing u can get fined for that! I needed to find a way to get seperate numbering for quotes and invoices.
Navigate to the file save.php in the directory /modules/invoices/
Open this file and navigate to line 32:
there u will find
add this line on row 34
What does this line do? If you navigate to the page 'manage invoice preferences' you'll see that each preference has a unique id. we are catching this id and assign it to $pref_idvar
Then scroll to line 40 where u find
Add the following code starting from line 41
$result = mysql_query("SELECT * FROM si_invoices WHERE preference_id = $pref_idvar");
$num_rows = mysql_num_rows($result);
mysql_query("UPDATE si_invoices SET custom_field1='$num_rows' WHERE id=$invoice_id")
or die(mysql_error());
Code Explanation: Start a query, select everything from table si_invoices where preference_id = $pref_idvar (remember). Then count all those rows and finaly upload that number to custom field1 where id= $invoice_id (wich is the id of the current invoice)
Then all u need to do is show the custom field on the template. (I'll put example here tonight)
here it is!
http://www.helpmijnpc.be/save.rar
Best regards, Jens
Discussion
awesome work Jens!
Cheers
Justin
Hello,
I've done the tweak in the save.php file but know I'don't know how to “show the custom field on the template”
currently I use two templates : one for the quotes, another for the invoices
Should I have only one ?
thanks
Catherine
Hi Catherine
below is an example from the default invoice template on how to show custom field 1 for invoices
<!-- Show the Invoice Custom Fields if valid --> { if $invoice.custom_field1 != null} <tr> <td nowrap class="">{$customFieldLabels.invoice_cf1}:</td> <td class="" align="right" colspan="3">{$invoice.custom_field1}</td> </tr> {/if}reply here or on the forum if you need further details
Cheers
Justin
Hello,
I think I've got it wrong. i thought this numbering would separate quotes from invoices sequence.
But in fact when I apply this now I still have in the header of my quote the incremental number (here 36) plus the number “1” I've typed in the custom field named “quote”.
QUOTE
N° 2009-36
Date 01-04-2009
QUOTE 1
Maybe I really got this really wrong !
catherine
Hey Catherine,
I haven't used this modification myself but assumed that it did infact seperate quotes and invoices numbering sequence
i don't think it'll change the invoice number that appears in the Manage Invoices page but if you put the correct custom field in your invoice template it should display the correct info on the invoice
let us know how you go
Cheers
Justin
hello,
even i edited save.php with similar code,the values are inserting properly in si_invoices but custom_filed1 is not getting update it's giving an error msg-No database selected.
hello,
even i edited save.php with similar code,the values are inserting properly in si_invoices but custom_filed1 is not getting update it's giving an error msg-No database selected.
This doesn't work for version 2010.1