Loading...
 

Pages

The top level wiki page

Copy to clipboard
! Monthly Statistics {DIV(class="monthly-stats")} {CUSTOMSEARCH(tpl="themes/templates/monthly_statistics_search_form.tpl" searchfadediv="customsearch_0_results" recalllastsearch="0" searchonload="1" requireinput="0" forcesortmode="0" searchfadediv="customsearch_0_form" customsearchjs="1")} {filter field=tracker_id content="3"} {facet name="tracker_field_projectCompany" operator="or" count="200" order="_term_asc" min="0"} {pagination max="300"} {tablesorter server="n" sortable="y" sortList="[0,0]" tsortcolumns="type:n|type:digit|type:digit|type:digit|type:digit|type:digit|type:digit|type:digit" tsfilters="y" tstotals="type:none|type:col;formula:sum;filter:visible;label:Totals|type:col;formula:sum;filter:visible;label:Totals|type:col;formula:sum;filter:visible;label:Totals|type:col;formula:sum;filter:visible;label:Totals|type:col;formula:sum;filter:visible;label:Totals|type:col;formula:sum;filter:visible;label:Totals|type:col;formula:sum;filter:visible;label:Totals"} {output template="themes/templates/monthly_statistics_list.tpl"} {CUSTOMSEARCH} {DIV}

monthly_statistics_search_form.tpl

Copy to clipboard
{literal} {/literal}

monthly_statistics_list.tpl

Copy to clipboard
{* PluginCusrtomSearch send the request data in the AJAX call in a JSON encoded parameter called "adddata" *} {$adddata = $smarty.request.adddata|json_decode:true} {* a couple of handy debug blocks to see what's being send trom the server *} {if isset($adddata.date.value)} {* date range is sent as two unix timestamps "xxxxxx,yyyyyy" *} {$projectDate = ','|explode:$smarty.request.adddata.date.value} {$projectDate = '{filter range="tracker_field_projectDate" from="'|cat:$projectDate[0]|cat:'" to="'|cat:$projectDate[1]|cat:'"}'} {/if} {foreach $facets['tracker_field_projectCompanyName'].options as $id => $name} {* facet labels get sent in the form "Label Text (count)" so use a regular expression here to split it into an array *} {$r = preg_match('/(.*)\((\d+)\)/', $name, $m)} {wikiplugin _name='list'}{literal} {filter field="tracker_id" content="3"} {filter field="tracker_field_projectCompanyName" content="{/literal}{$id}{literal}"} {pagination max="1"} {facet name="tracker_field_projectCurrentStatus" operator="or"} {facet name="tracker_field_projectPriorityLevel" operator="or"} {/literal}{$projectDate}{literal} {output template="themes/templates/monthly_statistics_inner_row.tpl"} {ALTERNATE()}{ALTERNATE} {FORMAT(name="distributorName")}{/literal}{$m[1]}{literal}{FORMAT} {FORMAT(name="projectCount")}{/literal}{$m[2]}{literal}{FORMAT} {/literal}{/wikiplugin} {/foreach}
{tr}Company Name{/tr} {tr}New Projects{/tr} {tr}Live Projects{/tr} {tr}High Priority Status{/tr} {tr}Medium Priority Status{/tr} {tr}Low Priority Status{/tr} {tr}Ordered PP{/tr} {tr}Ordered MP{/tr}
{/literal}{$m[1]}{literal}0000000
{tr}Company Name{/tr} {tr}New Projects{/tr} {tr}Live Projects{/tr} {tr}High Priority Status{/tr} {tr}Medium Priority Status{/tr} {tr}Low Priority Status{/tr} {tr}Ordered PP{/tr} {tr}Ordered MP{/tr}

{$c = preg_replace('/[^\(]*\((\d+)\)/', '$1', $facets.tracker_field_projectCurrentStatus.options.live)} {$c = preg_replace('/[^\(]*\((\d+)\)/', '$1', $facets.tracker_field_projectPriorityLevel.options.High)} {$c = preg_replace('/[^\(]*\((\d+)\)/', '$1', $facets.tracker_field_projectPriorityLevel.options.Medium)} {$c = preg_replace('/[^\(]*\((\d+)\)/', '$1', $facets.tracker_field_projectPriorityLevel.options.Low)} {$c = preg_replace('/[^\(]*\((\d+)\)/', '$1', $facets.tracker_field_projectCurrentStatus.options.orderedforpreproduction)} {$c = preg_replace('/[^\(]*\((\d+)\)/', '$1', $facets.tracker_field_projectCurrentStatus.options.orderedmassproduction)}

monthly_statistics_inner_row.tpl

Copy to clipboard
{$row = $results[0]}
{$row.distributorName} {$row.projectCount}{($c) ? $c : 0}{($c) ? $c : 0}{($c) ? $c : 0}{($c) ? $c : 0}{($c) ? $c : 0}{($c) ? $c : 0}

Finally the JavaScript Bit

Copy to clipboard
$(document).ready( function() { // set up month selector dropdown $("#daterange-presets").change(function () { var val = $(this).val(), $from = $("#date_from_dptxt"), $to = $("#date_to_dptxt"), now = new Date(), year = now.getFullYear(); if (val === "year") { $from.datepicker("setDate", "1/05/" + year).change(); $to.datepicker("setDate", now).change(); } else { val = parseInt(val); $from.datepicker("setDate", "1/" + val + "/" + year).change(); if (val === 12) { val = 0; year++; } $to.datepicker("setDate", "1/" + (val + 1) + "/" + year).change(); } $("table#wpcs-0").find("th:first-child").trigger("sort"); $csForm.submit(); }); });


List Slides