TEMPLATES 8.52 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
DIRECTIVE SUMMARY

       GET Evaluate and print a variable or value.

               [%   GET variable %]    # 'GET' keyword is optional

               [%       variable %]
               [%       hash.key %]
               [%         list.n %]
               [%     code(args) %]
               [% obj.meth(args) %]
               [%  "value: $var" %]

       SET Assign a values to variables.

               [% SET variable = value %]    # 'SET' also optional

               [%     variable = other_variable
                      variable = 'literal text @ $100'
                      variable = "interpolated text: $var"
                      list     = [ val, val, val, val, ... ]
                      list     = [ val..val ]
                      hash     = { var => val, var => val, ... }
               %]

       DEFAULT
           Like SET above, but variables are only set if currently unset (i.e. have no true value).

               [% DEFAULT variable = value %]

       INSERT
           Insert a file without any processing performed on the contents.

               [% INSERT legalese.txt %]

       INCLUDE
           Process another template file or block and include the output.  Variables are localised.

               [% INCLUDE template %]
               [% INCLUDE template  var = val, ... %]

       PROCESS
           As INCLUDE above, but without localising variables.

               [% PROCESS template %]
               [% PROCESS template  var = val, ... %]

       WRAPPER
           Process the enclosed block WRAPPER ... END block then INCLUDE the named template, passing the block output in the 'content' variable.

               [% WRAPPER template %]
                  content...
               [% END %]

       BLOCK
           Define a named template block for subsequent INCLUDE, PROCESS, etc.,

               [% BLOCK template %]
                  content
               [% END %]

       FOREACH
           Repeat the enclosed FOREACH ... END block for each value in the list.

               [% FOREACH variable = [ val, val, val ] %]    # either
               [% FOREACH variable = list %]                 # or
               [% FOREACH list %]                            # or
                  content...
                  [% variable %]
               [% END %]

       WHILE
           Enclosed WHILE ... END block is processed while condition is true.

               [% WHILE condition %]
                  content
               [% END %]

       IF / UNLESS / ELSIF / ELSE
           Enclosed block is processed if the condition is true / false.

               [% IF condition %]
                  content
               [% ELSIF condition %]
                    content
               [% ELSE %]
                    content
               [% END %]

               [% UNLESS condition %]
                  content
               [% # ELSIF/ELSE as per IF, above %]
                  content
               [% END %]

       SWITCH / CASE
           Multi-way switch/case statement.

               [% SWITCH variable %]
               [% CASE val1 %]
                  content
               [% CASE [ val2, val3 ] %]
                  content
               [% CASE %]         # or [% CASE DEFAULT %]
                  content
               [% END %]

       MACRO
           Define a named macro.

               [% MACRO name <directive> %]
               [% MACRO name(arg1, arg2) <directive> %]
               ...
               [% name %]
               [% name(val1, val2) %]

       FILTER
           Process enclosed FILTER ... END block then pipe through a filter.

               [% FILTER name %]                       # either
               [% FILTER name( params ) %]             # or
               [% FILTER alias = name( params ) %]     # or
                  content
               [% END %]

       USE Load a "plugin" module, or any regular Perl module if LOAD_PERL option is set.

               [% USE name %]                          # either
               [% USE name( params ) %]                # or
               [% USE var = name( params ) %]          # or
               ...
               [% name.method %]
               [% var.method %]

       TRY / THROW / CATCH / FINAL
           Exception handling.

               [% TRY %]
                    content
                  [% THROW type info %]
               [% CATCH type %]
                    catch content
                  [% error.type %] [% error.info %]
               [% CATCH %] # or [% CATCH DEFAULT %]
                    content
               [% FINAL %]
                  this block is always processed
               [% END %]

       NEXT
           Jump straight to the next item in a FOREACH/WHILE loop.

               [% NEXT %]

       LAST
           Break out of FOREACH/WHILE loop.

               [% LAST %]

       RETURN
           Stop processing current template and return to including templates.

               [% RETURN %]

       STOP
           Stop processing all templates and return to caller.

               [% STOP %]

       TAGS
           Define new tag style or characters (default: [% %]).

               [% TAGS html %]
               [% TAGS <!-- --> %]

       COMMENTS
           Ignored and deleted.

               [% # this is a comment to the end of line
                  foo = 'bar'
               %]

               [%# placing the '#' immediately inside the directive
                   tag comments out the entire directive
               %]
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329



VARIABLE FUNCTIONS:
	api_variable_new($name,$type)
		$name - variable name
		$type - variable type, ONLY 'float' is currently supported!

	api_variable_add($name,$value)
		Add $value to variable named with $name

	api_variable_subtract($name,$value)
		Add $value to variable named with $name

	api_variable_get($name)
		Return the value of the variable
		'float' - formatted %.2f , 2 decimal places

	api_variable_getraw($name)
		Return raw value of the variable

	api_bitwise_and($var1,$var2,$var3... $varN)
		Bitwise all arguments



CONSTANTS:
	WiaflosString
		Generated by Wiaflos string

	StartDate
		Start date of report, or "-" if there is no start date

	EndDate
		End date of report, or "CURRENT" if there is no end date



FLAGS:
	API_RPT_BALANCE_BF
		Bitwise constant, this is a flag and will signify the backend to return a balance brought forward psuedo transaction

	API_RPT_INCLUDE_YEAREND
		Include yearend transactions , this is a flag and will signify the backend to return the hidden yearend transactions




FUNCTIONS:

	api_account_balances
		Return a complex account balance structure
			{'AccountBalances}{[ACCOUNT_NUMBER]} => hash of hashes {
					Number - Account Number
					Name - Account Name

					DebitBalance - Debit balance for entire period
					CreditBalance - Credit balance or entire period
					Balance - Debit & credit or entire period

					CreditAmount - Total of all credits for period
					DebitAmount - Total of all debits for period
					ReportWriterCategoryCode - Report writer category code

					Children - Link to children accounts

					If REPORT_BALANCE_BF is specified:
						OpeningDebitBalance
						OpeningCreditBalance
						OpeningBalance
						ClosingBalance
			}
			{'ReportWriterCategoryToAccounts'}{CATEGORY_CODE} => array of accounts above


	api_gl_transactions
		Return list of transactions
			{'Transactions'} = array of hashes {
				ID
				TransactionDate
				Reference
				Entries = array of hashes {
					ID
					GLAccountID
					GLAccountName
					GLAccountNumber
					Amount
					Reference
				}
			}


	api_account_entries
		Return account entries
			{'Account'} = hash {
				ID
				Number
				ParentGLAccountID
				Name
				FinCatCode
				FinCatDescription
				RwCatCode
				RwCatDescription
			}
			{'Entries'} = array (
				ID
				GLTransactionID
				Reference
				Amount
				Balance
				TransactionDate
				TransactionReference
			)



	api_inventory_stock_balances
		Return stock balances.

		{'StockItemBalances'}->{[ITEM_CODE]}->{[ITEM_SERIAL]} = {
			TotalQuantity - Total quantity of all items with this serial
			TotalValue - Total value of all items with this serial
		}

		{'StockBalances'}->{[ITEM_CODE]} = {
			TotalQuantity - Quantity of all items with this stock code
			TotalValue - Value of all items with this stock code
		}

		{'TotalValue'} = Total floating point stock value
		


	api_format_amount($amount,$options)
		Format $amount according to the $options below:
		API_FMT_REVERSE - bitwise option, reverse the amount before formatting (ie. multiply by -1)
		API_FMT_NEGBRACKET - bitwise option, put negatives in brackets


	api_dump($variable)
		Dump to server console