Forums: Invoice number - Forums

Jump to content

Page 1 of 1

Invoice number

#1 User is offline   futo 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 80
  • Joined: 17-December 07

Posted 07 January 2014 - 08:58 AM

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
0

#2 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 15495
  • Joined: 03-February 03

Posted 07 January 2014 - 11:27 PM

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())

Best regards,
Sergey Kornilov
0

#3 User is offline   futo 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 80
  • Joined: 17-December 07

Posted 16 January 2014 - 11:31 AM

View Postadmin, on 07 January 2014 - 11:27 PM, said:

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....
0

Page 1 of 1


Fast Reply