asterisk2billing.org
http://forum.asterisk2billing.org/

FG_var_card.inc: how to assign a default value
http://forum.asterisk2billing.org/viewtopic.php?f=18&t=3790
Page 1 of 1

Author:  pl3512 [ Wed Jun 04, 2008 5:03 pm ]
Post subject:  FG_var_card.inc: how to assign a default value

I try to assign a default value for VAT by putting a value in the third parameter in AddEditElement. However, it does not get displayed when to go create a new customer. Does any know why?

$HD_Form -> AddEditElement (gettext("VAT"),
"vat",
"",
"INPUT",
"size=10 maxlength=6",
"12",
gettext("Insert the number for the VAT"),
"" , "", "", "", "", "", "NO-NULL" , gettext("VAT to add on the invoice of this customer. it should be a decimal value '21' this will be for 21% of VAT!"));

Author:  stavros [ Wed Jun 04, 2008 6:09 pm ]
Post subject: 

That's a good question. You've got me stumped for the moment.

Author:  asiby [ Sat Jun 14, 2008 7:46 am ]
Post subject: 

Here is our you would add 21 as default value for 21% of VAT.

Code:
$HD_Form -> AddEditElement (gettext("VAT"),
"vat",
"",
"INPUT",
"size=10 maxlength=6 value='21'",
"12",
gettext("Insert the number for the VAT"),
"" , "", "", "", "", "", "NO-NULL" , gettext("VAT to add on the invoice of this customer. it should be a decimal value '21' this will be for 21% of VAT!"));


You can make it fancier by reading the default value from the configuration file (a2billing.conf). I will assume that the constant DEFAULT_VAT will be created in Class.A2billing.php in the same fashion the other constants are set using config options.

Code:
$default_vat = DEFAULT_VAT

$HD_Form -> AddEditElement (gettext("VAT"),
"vat",
"",
"INPUT",
"size=10 maxlength=6 value='{$default_vat}'",
"12",
gettext("Insert the number for the VAT"),
"" , "", "", "", "", "", "NO-NULL" , gettext("VAT to add on the invoice of this customer. it should be a decimal value '21' this will be for 21% of VAT!"));


Cheers

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/