Hi All,
Phpmaker v2020.
I am having a bit of problem getting if statements to work in a php report.
I am using the Custom Templates in the CustomTemplatebody of the Summary Report. I report on transactions and if an indicator is set, produce a second line with extra information.
I have records returned from a Mysql DBView which I am reporting on. I am dumping both the dbvalue and display values to see what is going on. The body look like this.
phpMaker CustomerTemplateBody
{{{TransactionID}}} {{{approvedDate}}} {{{runLabel}}} {{{amount}}} {{{divCalc}}} {{: {{{dbvalue divCalc}}} }}{{if {{{dbvalue divCalc}}} == “1” }}
Rate: {{{payPerShare}}} Payment Date: {{{datePaid}}} Bank Account: {{{BankAccFormatted}}} Name: {{{BankAccName}}} {{/if}}When compiled it produces a lump of code that looks like this.
{{include tmpl=~getTemplate("#tpx1_1_2_individualStatements_28REG00729_TransactionID")/}} {{include tmpl=~getTemplate("#tpx1_1_2_individualStatements_28REG00729_approvedDate")/}} {{include tmpl=~getTemplate("#tpx1_1_2_individualStatements_28REG00729_runLabel")/}} {{include tmpl=~getTemplate("#tpx1_1_2_individualStatements_28REG00729_amount")/}} {{include tmpl=~getTemplate("#tpx1_1_2_individualStatements_28REG00729_divCalc")/}} {{: divCalc }} {{if divCalc == "1" }} Rate: {{include tmpl=~getTemplate("#tpx1_1_2_individualStatements_28REG00729_payPerShare")/}} Payment Date: {{include tmpl=~getTemplate("#tpx1_1_2_individualStatements_28REG00729_datePaid")/}} Bank Account: {{include tmpl=~getTemplate("#tpx1_1_2_individualStatements_28REG00729_BankAccFormatted")/}} Name: {{include tmpl=~getTemplate("#tpx1_1_2_individualStatements_28REG00729_BankAccName")/}} {{/if}} \ \ divCalc is the variable that I am tracking to decide weather to print the second line of information or not. Basically if it is "1" then print, if not then don't. The problem I have is the if statement only allows dbvalue to be used in the if statement. But when printing the value of that variable, both the display and dbvalue, only the display value changes with the next record. dbvalue seems to maintain the same value loaded form the first record. When I remove the "dbvalue" attribute in the if statement I get a rendering error in the browser.Changed code
{{{TransactionID}}} {{{approvedDate}}} {{{runLabel}}} {{{amount}}} {{{divCalc}}} {{: {{{dbvalue divCalc}}} }}{{if {{{divCalc}}} == “1” }}
Rate: {{{payPerShare}}} Payment Date: {{{datePaid}}} Bank Account: {{{BankAccFormatted}}} Name: {{{BankAccName}}} {{/if}}Compiled code
{{include tmpl=~getTemplate("#tpx1_1_1_individualStatements_28REG00729_TransactionID")/}} {{include tmpl=~getTemplate("#tpx1_1_1_individualStatements_28REG00729_approvedDate")/}} {{include tmpl=~getTemplate("#tpx1_1_1_individualStatements_28REG00729_runLabel")/}} {{include tmpl=~getTemplate("#tpx1_1_1_individualStatements_28REG00729_amount")/}} {{include tmpl=~getTemplate("#tpx1_1_1_individualStatements_28REG00729_divCalc")/}} {{: divCalc }} {{if {{include tmpl=~getTemplate("#tpx1_1_1_individualStatements_28REG00729_divCalc")/}} == "1" }} Rate: {{include tmpl=~getTemplate("#tpx1_1_1_individualStatements_28REG00729_payPerShare")/}} Payment Date: {{include tmpl=~getTemplate("#tpx1_1_1_individualStatements_28REG00729_datePaid")/}} Bank Account: {{include tmpl=~getTemplate("#tpx1_1_1_individualStatements_28REG00729_BankAccFormatted")/}} Name: {{include tmpl=~getTemplate("#tpx1_1_1_individualStatements_28REG00729_BankAccName")/}} {{/if}}The display value and dbvalue for divCalc do not seem to be the same (which they should but dbvalue divCalc seems to be stuck at the first record) so the if statement produces a negative when the report is produced and no extra line displayed where it should.
Has any one come across this before and worked out a way around it?
TIA
Steve.