Friday, 14 October 2011

formlink magic

# {{
# #vardefine: CUSTOMER|{{ #show: {{{Project1|}}} | ?Customer | link=none }} }} {{
# #vardefine: REGARDING|{{ #show: {{{Project1|}}} | ?Regarding | link=none }} }} {{
# #vardefine: ADDRESS|{{ #show: {{ #var: CUSTOMER }} | ?Invoice address }} }} {{
# #vardefine: CURRENCY|{{ #show: {{ #var: REGARDING }} | ?Currency }} }} {{
# #vardefine: TOTALAMOUNT|42.42 }} {{
# #vardefine: INVOICEDATE|{{ #time: Y-m-d|{{CURRENTTIMESTAMP}} {{TZ offset}} }} }}
# {{ #ifeq: {{ #var: ADDRESS }} | n/a | Invoice address not available - invoice generation impossible. |
#
# {{ #formlink: Invoice | Create invoice | link | Invoice[InvoiceNumber]={{ #explode: {{PAGENAME}}| |2 }}&Invoice[Project1]={{{Project1|}}}{{
# #if: {{ #var: ADDRESS }} |&Invoice[InvoiceAddress]={{ #urlencode: {{ #var: ADDRESS }} }} }}{{
# #if: {{ #var: CURRENCY }} |&Invoice[Currency]={{ #var: CURRENCY }} }}{{
# #if: {{ #var: TOTALAMOUNT }} |&Invoice[TotalAmount]={{ #var: TOTALAMOUNT }} }}{{
# #if: {{ #var: INVOICEDATE }}


{{ #if: {{ #forargs: ProjectNumber|param|value | {{ #ifexist: {{ #var: value }} | | {{ #vardefineecho: INVALIDPROJECTS|{{ #var: INVALIDPROJECTS }} {{ #var: value }} }} }} }}
| Error: The following projects are non-existent: {{ #var: INVALIDPROJECTS }} |
{{
#vardefine: CUSTOMER|{{ #show: {{{ProjectNumber1|}}} | ?Customer | link=none }} }} {{
#vardefine: REGARDING|{{ #show: {{{ProjectNumber1|}}} | ?Regarding | link=none }} }} {{
#vardefine: ADDRESS|{{ #show: {{ #var: CUSTOMER }} | ?Invoice address }} }} {{
#vardefine: CURRENCY|{{ #show: {{ #var: REGARDING }} | ?Currency }} }} {{
#vardefine: TOTALAMOUNT|42.42 }} {{
#vardefine: INVOICEDATE|{{ #time: Y-m-d|{{CURRENTTIMESTAMP}} {{TZ offset}} }} }}
{{ #ifeq: {{ #var: ADDRESS }} | n/a | Invoice address not available - invoice generation impossible. |

{{ #formlink: Invoice | Create invoice | post button | Invoice[InvoiceNumber]={{ #explode: {{PAGENAME}}| |2 }}{{
#if: {{ #var: ADDRESS }} |&Invoice[InvoiceAddress]={{ #var: ADDRESS }} }}{{
#if: {{ #var: CURRENCY }} |&Invoice[Currency]={{ #var: CURRENCY }} }}{{
#if: {{ #var: TOTALAMOUNT }} |&Invoice[TotalAmount]={{ #var: TOTALAMOUNT }} }}{{
#if: {{ #var: INVOICEDATE }} |&Invoice[InvoiceDate]={{ #var: INVOICEDATE }} }}{{
#forargs: ProjectNumber|param|value |&Invoice[ProjectNumber{{ #var: param }}]={{ #var: value }} }}{{
#vardefine: i | 1 }}{{ #while: |{{{ProjectNumber{{ #var: i }}|}}}
|&Invoice[ProjectName{{ #var: i }}]={{ #show: {{{ProjectNumber{{ #var: i }} }}} | ?Project name }}{{
#vardefine: i | {{ #expr: {{ #var: i }} + 1 }} }} }}
}}

with the following data:

}}

Invoice address{{ #tag:pre|{{ #var: ADDRESS }} }}
Currency{{ #var: CURRENCY }}
Total amount{{ #var: TOTALAMOUNT }}
Invoice date{{ #var: INVOICEDATE }}

{{ #forargs: ProjectNumber|param|value
|
=== Project {{ #var: param }} ===
Project number:{{ #var: value }}
Project name:{{ #show: {{ #var: value }} | ?Project name }}
}}

}}

Post a Comment