This topic is locked
[SOLVED]

 Auto with the next invoice number

6/11/2015 7:13:36 AM
PHPRunner General questions
C
carrie3800332 author

Can sommeone help me in this issue..

I am creating a form in PHPRunner 6.1

I inline add Record need to Auto with the next invoice number, but users are free to modify this field data,

Programs are Events is Add page→Before record added or process record values or before display or

only add to this field properties→ Custom ~all not brought out in invoice number

any help

Thanks!
This is code which create invoice number:
global $conn,$year,$month,$invoice_no;

if ($values["invoice_date"] !="")

{

$year = YEAR($values["invoice_date"]);

$month=MONTH($values["invoice_date"]);

$values["invoice_no"]=strtoupper($values["invoice_no"]);

$values["invoice_date"]=now();

$str = "select max(invoice_no) from invoice_m where year(invoice_date)='".$year."' and month(invoice_date)='".$month."' ";

while($data = db_fetch_array($rs))

{

$values["invoice_no"] = $invoice_no+1;

}

};

return true;

Admin 6/11/2015

This code is not going to work, there are no YEAR or MONTH functions in PHP.
Check this article that explains how to get month and year from the date value:

http://stackoverflow.com/questions/3605899/php-how-to-get-year-month-day-from-time-string

C
carrie3800332 author 6/12/2015

Thank you replay,

I have changed the code

Programs are Events is Add page → Before record added or process record values or before display or

only add to this field properties → Custom ~all not brought out in invoice number
This is code which create invoice number:
global $conn,$year,$month,$invoice_no;

$values["invoice_no"]=strtoupper($values["invoice_no"]);

$values["invoice_date"]=now();

if ($values["invoice_date"] !="")

{

$year = $values["invoice_date"]->format('Y');

$month=$values["invoice_date"]->format('m');
$str = "select max(invoice_no) from invoice_m where year(invoice_date)='".$year."' and month(invoice_date)='".$month."' ";

while($data = db_fetch_array($rs))

{

$values["invoice_no"] = $invoice_no+1;

}

};

return true;
code even directly test → "select max(invoice_no) from invoice_m where year(invoice_date)='2015' and month(invoice_date)='03' ";

global $conn,$year,$month,$invoice_no;

$values["invoice_no"]=strtoupper($values["invoice_no"]);

$values["invoice_date"]=now();

if ($values["invoice_date"] !="")

{

$year = $values["invoice_date"]->format('Y');

$month=$values["invoice_date"]->format('m');

echo "Input: $year";

$str = "select max(invoice_no) from invoice_m where year(invoice_date)='2015' and month(invoice_date)='03' ";

while($data = db_fetch_array($rs))

{

$values["invoice_no"] = $invoice_no+1;

}

};

return true;

Admin 6/12/2015

This code still makes zero sense. You can only apply format() function to DateTime object. Use code sample from the first answer under http://stackoverflow.com/questions/3605899/php-how-to-get-year-month-day-from-time-string