1 line
6.4 KiB
Plaintext
1 line
6.4 KiB
Plaintext
{"Name":"z_if key value X show Y via custom Helpers","Active":true,"Notes":"example custom Helper if has tag X then show Y, else return something else like preset text\nexample custom Helper of how to correctly wrap output in a safestring as result of Helper if need to use CSS styling","Roles":124927,"AType":26,"IncludeWoItemDescendants":false,"Template":"<html>\n\n<body>\n\t<div class=\"reporttitle\" >\n\t<p>Use of Custom Helpers to display specific aspects if {{ayT 'Tags'}} have a specific value</p>\n\t<!-- See the specific Helpers in this report template, and the help documentation for additional details -->\n\t</div>\n\t<table>\n\t\t{{#each ayReportData}}\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<th colspan=\"2\">For {{ayT 'PurchaseOrderPONumber'}} {{ Serial }}</th> <!--th styles this as a heading column -->\n\t\t\t</tr>\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td>Using HTML5 mustache to display all {{ayT 'Tags'}} for this {{ayT 'PurchaseOrder'}}</td>\n\t\t\t\t<td>{{ Tags}}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>Using HTML5 mustache to display ONLY the 1st {{ayT 'Tag'}} for this {{ayT 'PurchaseOrder'}} {{ayT 'Tags'}}</td><!--td styles this as a data column -->\n\t\t\t\t<td>{{ Tags.[0]}} </td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>Custom Helper to display if has {{ayT 'Tag'}} 'gold':</td>\n\t\t\t\t<td>{{ isInTag Tags}}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>Custom Helper to display if has {{ayT 'Tag'}} 'brown':</td>\n\t\t\t\t<td>{{ isInTag2 Tags}}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>Custom Helper to display if has {{ayT 'Tag'}} 'green' will display using safestring call of the CSS styling fontgreen else displays safestring call of the CSS styling fontred:</td>\n\t\t\t\t<td>{{ isInTag3 Tags}}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>HTML5 use of #if to display PO's CustomFields.c1 value with CSS fontgreen applied to the text, else will display fontred if is is false, undefined, null, \"\", 0, or []</td>\n\t\t\t\t{{#if CustomFields.c1}} <td class='fontgreen' >{{CustomFields.c1}}</td> {{else}} <td class='fontred' >No value has been entered in Custom1 field for this PO</td> {{/if}}\n\t\t\t</tr>\n\t\t\t{{#each Items}}\n\t\t\t<tr>\n\t\t\t\t<td>HTML5 use of #each for each POitem - #if to display text in fontred if QuantyReceived is false, undefined, null, \"\", 0, or [], else display in fontgreen</td>\n\t\t\t\t{{#if QuantityReceived}}<td class='fontgreen' >{{ayT 'Part'}} {{PartNameViz}} {{ayT 'PurchaseOrderItemQuantityOrdered'}} = {{QuantityOrdered}}<br>{{ayT \"PurchaseOrderItemQuantityReceived\"}} value is {{QuantityReceived}}</td> {{else}} <td class='fontred' >{{ayT 'Part'}} {{PartNameViz}} {{ayT 'PurchaseOrderItemQuantityOrdered'}} = {{QuantityOrdered}}<br>{{ayT 'Part'}} {{PartNameViz}} {{QuantityReceived}} value is {{ayT \"PurchaseOrderItemQuantityReceived\"}}!</td> {{/if}}\n\t\t\t</tr>\n\t\t\t{{/each}}\n\t\t</tbody>\n\t\t{{/each}}\n\t</table>\n \n</body>\n\n</html>","Style":".singlePage\n{\npage-break-after: always;\n\n}\nbody {\n font-family: 'Helvetica', 'Helvetica Neue', Arial, sans-serif; \n}\n\n.reporttitle { \n margin-bottom: 20pt; \n font-weight: bold; \n font-size: 13pt; \n color: #9e9e9e;\n text-align: center;\n} \n\ntable { \n border-collapse: collapse;\n white-space: pre-wrap;\n width: 100%;\n table-layout: fixed; /* the # of columns set in the first row of the thead will be fixed and applied throughout table and rows */\n }\n\nth {\n border-bottom: solid 1pt #9e9e9e;\n height: 50px;\n font-size: 11pt; \n color: #9e9e9e;\n}\n\ntbody td {\n padding: 10px;\n word-wrap: break-word;\n font-size: 9pt;\n}\n\n\ntbody tr:nth-child(even) {\n background-color: #f8f8f8; /* MUST checkmark Print background in PDF Options for this to show */\n}\n\n\n.rightlean {\n text-align: right;\n}\n.leftlean {\n text-align: left;\n}\n.centerlean {\n text-align: center;\n}\n\n\n.fontgreen {\n color: green;\n}\n.fontblue {\n color: blue;\n}\n.fontred {\n color:red;\n}\n\n","JsPrerender":"async function ayPrepareData(ayData){ \n //this function (if present) is called with the report data \n //before the report is rendered\n //modify data as required here and return it to change the data before the report renders\n //see the help documentation for details\n\n await ayGetTranslations([\"Part\", \"PurchaseOrderItemQuantityReceived\", \"PurchaseOrderItemQuantityOrdered\", \"Tag\", \"Tags\", \"PurchaseOrderPONumber\", \"PurchaseOrder\" ]);\n\n return ayData;\n}","JsHelpers":"Handlebars.registerHelper('isInTag', function (Tags) \n{\n for (var i=0; i<Tags.length; i++) \n\t{\n if (Tags[i].match('gold'))\n\t\t{ \n return 'gold'; \n\t\t}\n }\n return 'THERE IS NO gold TEXT FOUND IN THE TAGS ARRAY FOR THIS PO';\n});\n\nHandlebars.registerHelper('isInTag2', function (Tags) \n{\n for (var i=0; i<Tags.length; i++) \n\t{\n if (Tags[i].match('brown'))\n\t\t{ \n\t\t\treturn 'THE TEXT brown IS FOUND IN THE TAGS ARRAY FOR THIS PO';\n\t\t}\n }\n return 'NOPE, THE TEXT \\'brown\\' is NOT FOUND IN THE TAGS ARRAY FOR THIS PO'; //note the use of \\ to be able to show special character '\n});\n\nHandlebars.registerHelper('isInTag3', function (Tags) \n{\n for (var i=0; i<Tags.length; i++) \n\t{\n if (Tags[i].match('green'))\n\t\t{ \n\t\t\treturn new Handlebars.SafeString(\"<p class='fontgreen' >\" + \"THE TEXT green IS IN FOUND IN THE TAGS ARRAY FOR THIS PO!! See how this shows in greenfont!\" +\"</p>\"); //if want to use CSS styling, be sure to wrap in a safestring\n\t\t}\n }\n return new Handlebars.SafeString(\"<p class='fontred' >\" + 'NOPE, THE TEXT green ISN\\'T IN THE TAGS ARRAY FOR THIS PO' +\"</p>\"); //if don't want to return any element at all, comment this else aspect out fully\n});\n","RenderType":0,"HeaderTemplate":"<span style=\"font-size:6pt; width: 96%;text-align:left; \"> Printed date: PDFDate</span>\n<span style=\"font-size:6pt;width: 96%; text-align: right; \">Page <span class=\"pageNumber\"></span> of <span class=\"totalPages\"></span> </span>","FooterTemplate":"<span> </span>","DisplayHeaderFooter":true,"PaperFormat":10,"Landscape":false,"MarginOptionsBottom":"15mm","MarginOptionsLeft":"10mm","MarginOptionsRight":"10mm","MarginOptionsTop":"15mm","PageRanges":null,"PreferCSSPageSize":false,"PrintBackground":true,"Scale":1.00000} |