This topic is locked

Invoice number

1/7/2014 3:58:06 AM
Invoice template support forum
F
futo author

Hello,
Can sommeone help me in this issue..
Are in invoice template possible make to count again invoice numbers from 1.
This is code which create invoice number.:
// code generates a new invoice's number

$rs = CustomQuery("select max(".AddFieldWrappers("invoice_number").") as max_number from ".AddTableWrappers("invoices"));

$data = db_fetch_array($rs);

if ($data) {

$values['invoice_number'] = $data['max_number'] + 1;

}
I have in invuseres table field named Curent_year. Is it possible change script from above so that count again from 1 if its in invuserrs table changed year from 2013 to 2014.
Thanks
PHP Runner 6.2

admin 1/7/2014

There is a 'date' field in invoices table. You can modify the SQL query in question to find the highest invoice number among current year invoices only.
Something like this:

select ... from ... where year(date)=year(now())
F
futo author 1/16/2014



There is a 'date' field in invoices table. You can modify the SQL query in question to find the highest invoice number among current year invoices only.
Something like this:

select ... from ... where year(date)=year(now())



// code generates a new invoice's number

$rs = CustomQuery("select max(".AddFieldWrappers("invoice_number").") as max_number from ".AddTableWrappers("invoices"))where year(date)=year(now());

$data = db_fetch_array($rs);

if ($data) {

$values['invoice_number'] = $data['max_number'] + 1;

}
something like this....