Adding a variable to a retPlan "entries" database (expenses,income,assets,invests)
1) Create the variable in the mysql table
in retPlanInit.inc, find the appropriate sql="create table ... " statement and add the desired variable.
You will have to regenerate the retplan mysql database.
Hint: for temporary work, you can add a variable (using phpVarAdmin) to an existing table in the retPlan database
Note: Keep Track of Its Exact Name!
2) In retPlan_xxxx.inc (where xxx is one of expenses, income, assets, or invest), make the following changes
a) In the ::::: add xxx:::: section (use to display the add a single xxx form)
Add a
with an statement.
The name (and id) attributes of this should be structured as name="xxxVarname"
(and id="ixxxVarname").
Example:
Note that the id could be used in a statement (otherwise, it is not currently used).
Also note tha the name does NOT have to be the same as the mysql varname (that you will be saving
these values to)
Hint: you can use the following "onChange" functions within the statement
onChange="checkIsNumber(this)" -- if entered value is not a number, an alert error message is displayed
onChange="checkIsNameString(this)" -- check for a 1-word name with alphanumerics (and _) characters only
onChange="checkAllowed(this,'v1,v2,...')" -- check if entered values is v1, or v2, or ...
b) In the "add bulk xxx " section (used to display the bulk entries table, and csv entry area)
In the "bulkEntriesTable_table_xxx" table, add a
varname
in a reasonable spot -- keep track of this spot, you will need to match locations in 4.b.ii below
The varname can be descripitve
c) in the section
Find the "specify xxx entries, and add a variable to the Format: .
The varname can be descriptive.
It really SHOULD be in the same spot (relative to other variables) as the
specified in (b) above!
d) In the section
Insert a value in each of the example rows. BE SURE it is in the same column (in the same
comma seperated position) as used in (c) above!
f) Optionally: add a description in the :::: description of xxx :: section in retPlan_help.inc
(i.e; add a new ).
3) In retPlan_util.inc
a) In the displayxxxEntriesTablefunction -- this is used to "view" the current xxx entries
i) Find "columns of the xxx table" section ($hdrs. lines follow it)
Add $hdrs.= line, containing varname(it doesn't have to be the actual variable name)
ii) Below the "// add row for this xxx", add a
$aline.=' $avv['VARNAMEM']> --
be sure it is in the same position as (in i) above).
AND VARNAMEM MUST BE AN UPPERCASE OF THE NAME USED IN STEP 1 (that is: the name of the mysql variable).
For example $avv['INFADJUST']
Note: you don't have to use this $avv['VARNAMEM'] -- you can display (in the ) anything
(i.e.; you can display a modification of the value of $avv['VARNAMEM']
b) In the exportEntries function
Find the `if $atable='xxx'` section
a) To the hlist, add the name of the variable -- this MUST be the mysql variable (specified in 1)
The order MUST match the order of this variable that you specified in 2b
b) To the hdrline, add the variable name (or short description). This is used as a comment in
export files, so should (but doesn't have to be) correctly aligned
c) In the addAnxxx function
i) Add a $amyVar=trim(extractRequestVar('xxxVarname',defval))
where xxxVarname MUST be the name="xxxVarname" specified in (2a).
If you were clever in what you allow in the statement in 2a, you can modify the $amyVar variable.
ii) Add a $bamyVar=mysqli_real_escape_string($link,$amyVar);
Note: of course, instead of $amyVar (and $bamyVar), you should use a more descriptive (and unique) variable name
for this new variable.
iii) In the sql="replace into ... " line, insert the VARNAMEM of the mysql variable (as specified in (1a))
iv) In the same location on the next line, add a `,'$bamyVar'`
That is, include `$bamyVar` in the csv on between the (...) on the next line -- and it MUST be in the
same relative location as the VARNAMEM you just inserted in the "replace into" lie
d) In the addBulkxxx function
i) As with 3c : change the replace into line (add the variable name),
ii) In the
IF (COUNT($ALINE2) '
where
avarname can be different than the variable name.
the "n" MUST match the location in defvals.
BE SURE THIS IS IN THE SAME SPOT as the added in 2.b above
Hint: add one to the existing defval[n] of the v0 preceding this new entry
As with 2a, you can specify several useful onChange= attributes in the .
But be sure to escape ` characters:
Example: onChange="checkAllowed(this,\'0,1\')"
iv) In all v0+ .. lines following this new entry, update (by 1) the defval[n]'s
v) The last v0, with the "defvals.slice(m)" -- add one to m (this allows the description to have commas)
Thus: you are adding a column in the bulk table, and it must be in the same location (the same in the )
as the column descriptor specified in 2b. And, the default value must match the spot in the defval array.