The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
formating HTML / Printer-friendly - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Modules / Other (https://forums.formtools.org/forumdisplay.php?fid=8)
+--- Forum: Modules (https://forums.formtools.org/forumdisplay.php?fid=16)
+--- Thread: formating HTML / Printer-friendly (/showthread.php?tid=1447)



formating HTML / Printer-friendly - rnog - Jul 9th, 2011

Hi,


I find this application so interesting that I am preparing a site to manage audit results.

I had placed a question in the past about the possibility of form tools perform basic calculations, but I have already exceeded this question using JavaScript in the form.

I go back to contact with some doubts, questions and a bug (I think):

1 - question about the html export
my goal is to use this function to create the audit report (pdf printer). This report, in addition of presenting the results of each audit, also presents a chart that analyzes 3 results. I prepared the export template to create a graph (using the google graph api). So far so good.
My doubt is that I need the script that creates the chart, get in database values corresponding to 3 specific columns. For more than I read the Smarty template documentation I can’t write the code to perform this. (I hope it was explicit enough)

my example:
Code:
<html>
<head>
  <title>{$export_group_name}</title>

  {* escape the CSS so it doesn't confuse Smarty *}
  {literal}
  <style type="text/css">
  body { margin: 0px; }
  table, td, tr, div, span {
    font-family: verdana; font-size: 8pt;
  }
  table { empty-cells: show }
  #nav_row { background-color: #efefef; padding: 10px; }
  #export_group_name { color: #336699; font-weight:bold }
  .print_table { border: 1px solid #dddddd; }
  .print_table th {
    border: 1px solid #cccccc;
    background-color: #efefef;
    text-align: left;
  }
  .print_table td { border: 1px solid #cccccc; }
  .one_item { margin-bottom: 15px; }
  .page_break { page-break-after: always; }
  </style>

  <style type="text/css" media="print">
  .no_print { display: none }
  </style>
  

  
  <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
    
      
      google.load('visualization', '1', {'packages':['corechart']});
      
      
      google.setOnLoadCallback(drawChart);
      
      
      function drawChart() {

      
      var data = new google.visualization.DataTable();
      data.addColumn('string', 'Periodo');
      data.addColumn('number', 'A1');
      data.addColumn('number', 'A2');
      data.addColumn('number', 'A3');
        data.addRows(3);
        data.setValue(0, 0, 'Grupo A');
        data.setValue(0, 1, 100);
        data.setValue(0, 2, 100);
        data.setValue(0, 3, 100);
        data.setValue(1, 0, 'Grupo B');
        data.setValue(1, 1, 100);
        data.setValue(1, 2, 100);
        data.setValue(1, 3, 100);
        data.setValue(2, 0, 'Grupo C');
        data.setValue(2, 1, 100);
        data.setValue(2, 2, 100);
        data.setValue(2, 3, 100);
      
      var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
      chart.draw(data, {width: 400, height: 240, vAxis: {maxValue: 10}});
    }
    </script>
  
{/literal}
  
</head>
<body>

<div id="nav_row" class="no_print">

  <span style="float:right">
    {* if there's more than one export type in this group, display the types in a dropdown *}
    {if $export_types|@count > 1}
      <select name="export_type_id" onchange="window.location='{$same_page}?export_group_id={$export_group_id}&export_group_{$export_group_id}_results={$export_group_results}&export_type_id=' + this.value">
      {foreach from=$export_types item=export_type}
        <option value="{$export_type.export_type_id}" {if $export_type.export_type_id == $export_type_id}selected{/if}>{eval var=$export_type.export_type_name}</option>
      {/foreach}
      </select>
    {/if}
    <input type="button" onclick="window.close()" value="{$LANG.word_close|upper}" />
    <input type="button" onclick="window.print()" value="{$LANG.word_print|upper}" />
  </span>

  <span id="export_group_name">{eval var=$export_group_name}</span>
</div>

  
<div style="padding: 15px">
  {$export_type_smarty_template}
</div>

</body>
</html>

I want to replace the data.setvalue of "100" for the value of a particular column of the database. Is it possible to help me?


2 - A simpler question. The link at the top of page for updates is very useful, but I would that only appear with the administrator user. It is possible to hide this link for final customer accounts?


3 - What seems to be a bug. Whenever I want to add a new export type to export group (eg html - print) the link takes me the page to create new group and not to a new export type.

Thanks in advance

Rui



RE: formating HTML / Printer-friendly - Ben - Jul 13th, 2011

Hi Rui,

Interesting! I'm just playing around with the Google Chart Tools myself right now.

Quote:I want to replace the data.setvalue of "100" for the value of a particular column of the database. Is it possible to help me?

I won't fib, this is very complicated to explain over the forums - this is a sit-down-in-person sort of a problem. But here's a few tips.

The list of column name and submission data is only passed to the Export Type Smarty template not the Export Group Smarty template. So if you need to access that information, your javascript code will either need to be executed in that section, or dynamically pull that value from the markup generated by the Export Type template on page load. Since the existing code you pasted is told to execute when the page is loaded, I'd be tempted to give the column name <td>'s generated by the Export Type template an ID/Class which you could access on load. Similarly, if your goal is to graph the data that's outputted to the page, the JS code would parse the entire table and populate the Google DataTable accordingly.

That's how I would tackle it. It would make the page load slightly slower since there'd be a lot of DOM parsing on page load, but it wouldn't require you to duplicate any Smarty Loops to output the required javascript as well as the actual page data.

Quote:2 - A simpler question. The link at the top of page for updates is very useful, but I would that only appear with the administrator user. It is possible to hide this link for final customer accounts?

Good question...! No, this can't be done with 2.0.x, but you *can* with 2.1.0. The latest version of the module was written to support 2.1.0 and it includes the option to map Export Groups to specific client accounts. Thus, you could create a second "HTML/Printer Friendly" Export Group containing only a single Export Type and assign that to the user. Bit of a hack, but it would work. Also, 2.1.0 is still in Beta and has a few remaining issues to iron out. It should be the main build in a couple of months or so.

Alternatively, I suppose you could check to see what the account ID is directly in the template... let me know if you're interested in this and I'll look through the code.

Quote:3 - What seems to be a bug. Whenever I want to add a new export type to export group (eg html - print) the link takes me the page to create new group and not to a new export type.

That does sound like a bug! What version of the module + browser + OS are you using?

- Ben



RE: formating HTML / Printer-friendly - Angelsdemons - Mar 9th, 2012

(Jul 13th, 2011, 9:47 AM)Ben Wrote: Hi Rui,

Interesting! I'm just playing around with the Google Chart Tools myself right now.

Quote:I want to replace the data.setvalue of "100" for the value of a particular column of the database. Is it possible to help me?

I won't fib, this is very complicated to explain over the forums - this is a sit-down-in-person sort of a problem. But here's a few tips.

The list of column name and submission data is only passed to the Export Type Smarty template not the Export Group Smarty template. So if you need to access that information, your javascript code will either need to be executed in that section, or dynamically pull that value from the markup generated by the Export Type template on page load. Since the existing code you pasted is told to execute when the page is loaded, I'd be tempted to give the column name <td>'s generated by the Export Type template an ID/Class which you could access on load. Similarly, if your goal is to graph the data that's outputted to the page, the JS code would parse the entire table and populate the Google DataTable accordingly.

That's how I would tackle it. It would make the page load slightly slower since there'd be a lot of DOM parsing on page load, but it wouldn't require you to duplicate any Smarty Loops to output the required javascript as well as the actual page data.

Quote:2 - A simpler question. The link at the top of page for updates is very useful, but I would that only appear with the administrator user. It is possible to hide this link for final customer accounts?

Good question...! No, this can't be done with 2.0.x, but you *can* with 2.1.0. The latest version of the module was written to support 2.1.0 and it includes the option to map Export Groups to specific client accounts. Thus, you could create a second "HTML/Printer Friendly" Export Group containing only a single Export Type and assign that to the user. Bit of a hack, but it would work. Also, 2.1.0 is still in Beta and has a few remaining issues to iron out. It should be the main build in a couple of months or so.

Alternatively, I suppose you could check to see what the account ID is directly in the template... let me know if you're interested in this and I'll look through the code.

Quote:3 - What seems to be a bug. Whenever I want to add a new export type to export group (eg html - print) the link takes me the page to create new group and not to a new export type.

That does sound like a bug! What version of the module + browser + OS are you using?

- Ben


Thank you for finally solved my problem!