+# vim:noet:ts=4
export LDFLAGS += -L . -L$(TMP) -L $(OPENSRF_LIBS)
export CFLAGS += -pipe -g -Wall -O2 -fPIC -I$(LIBXML2_HEADERS) -I$(APACHE2_HEADERS) -I$(APR_HEADERS) \
install: perl-install web-install server-xul string-templates-install xsl-install c_apps-install circ_rules-install offline-install storage-bootstrap cgi-bootstrap
-web-install: webcore-install autojs-install mod_xmlent-install offline-install
+web-install: webcore-install autojs-install mod_xmlent-install offline-install reporter-install
circ_rules-install:
@echo $@
reporter-install:
@echo $@
-# @echo "Installing Reporter templates to $(REPORTERDIR) and example configs to $(ETCDIR)"
-# cp reporter/report_base.example.xml $(ETCDIR)/reporter.example.xml
-# cp reporter/tables.example.xml $(ETCDIR)
-# cp reporter/widgets.example.xml $(ETCDIR)
-# mkdir -p $(REPORTERDIR)
-# cp -r reporter/templates/* $(REPORTERDIR)
+ @echo "Installing Reporter email templates to $(REPORTERDIR) and example configs to $(ETCDIR)"
+ cp reporter/clark-kent.pl $(BINDIR)
+ cp reporter/report-fail $(DATADIR)
+ cp reporter/report-success $(DATADIR)
+ mkdir -p $(REPORTERDIR)
# -----------------------------------------------------------------------------------
offline-install:
+++ /dev/null
-DROP SCHEMA reporter CASCADE;
-
-CREATE SCHEMA reporter;
-
-BEGIN;
-
-CREATE OR REPLACE VIEW reporter.date_series AS
- SELECT CAST('1900/01/01' AS DATE) + x AS date,
- CAST('1900/01/01' AS DATE) + x AS date_label
- FROM GENERATE_SERIES(
- 0,
- CAST( EXTRACT( 'days' FROM CAST( NOW() - CAST( '1900/01/01' AS DATE ) AS INTERVAL ) ) AS INT )
- ) AS g(x);
-
-CREATE OR REPLACE VIEW reporter.date_hour_series AS
- SELECT CAST(date + CAST(h || ' hours' AS INTERVAL) AS TIMESTAMP WITH TIME ZONE) AS date_hour,
- CAST(date + CAST(h || ' hours' AS INTERVAL) AS TIMESTAMP WITH TIME ZONE) AS date_hour_label
- FROM reporter.date_series,
- GENERATE_SERIES(0,23) g(h);
-
-
-
-CREATE TABLE reporter.date_dim AS
- SELECT
- EXTRACT('year' FROM date_label)::INT AS year,
- EXTRACT('month' FROM date_label)::INT AS month,
- EXTRACT('day' FROM date_label)::INT AS day
- FROM
- (SELECT '1900-01-01'::date + g.x AS date_label
- FROM GENERATE_SERIES(0, EXTRACT('days' FROM NOW() + '10 years'::INTERVAL - '1900-01-01'::TIMESTAMP WITH TIME ZONE)::INT) g(x)) as y
- ORDER BY 1,2,3;
-
-
-CREATE TABLE reporter.time_dim AS
- SELECT
- a.x AS hour,
- b.x AS minute,
- c.x AS second
- FROM
- GENERATE_SERIES(0, 23) as a(x),
- GENERATE_SERIES(0, 59) as b(x),
- GENERATE_SERIES(0, 59) as c(x)
- order by 1,2,3;
-
-
-CREATE TABLE reporter.stage2 (
- id serial primary key,
- stage1 text not null,
- params text not null,
- owner int not null,
- pub bool not null
- default false,
- create_date timestamp with time zone not null
- default now(),
- edit_date timestamp with time zone not null
- default now()
-);
-
-CREATE OR REPLACE FUNCTION reporter.force_edit_date_update () RETURNS TRIGGER AS $$
- BEGIN
- NEW.edit_date = NOW();
- RETURN NEW;
- END;
-$$ LANGUAGE PLPGSQL;
-
-CREATE TRIGGER force_edit_date_update_trig
- BEFORE UPDATE ON reporter.stage2
- FOR EACH ROW
- EXECUTE PROCEDURE reporter.force_edit_date_update ();
-
-CREATE TABLE reporter.stage3 (
- id serial primary key,
- stage2 int not null
- references reporter.stage2 (id)
- on delete restrict
- deferrable
- initially deferred,
- params text not null,
- owner int not null,
- disable bool not null
- default false,
- pub bool not null
- default false,
- create_date timestamp with time zone not null
- default now(),
- runtime timestamp with time zone default now(),
- recurrence interval
-);
-
-CREATE TABLE reporter.output (
- id serial primary key,
- stage3 int not null
- references reporter.stage3 (id)
- on delete restrict
- deferrable
- initially deferred,
- queue_time timestamp with time zone not null default now(),
- run_time timestamp with time zone,
- run_pid int,
- query text,
- error text,
- error_time timestamp with time zone,
- complete_time timestamp with time zone,
- state text check (state in ('wait','running','complete','error'))
-);
-
-COMMIT;
-
--- /dev/null
+To: {TO}
+From: {FROM}
+Reply-To: {REPLY_TO}
+Subject: Report failed: "{REPORT_NAME}"
+
+Your report, named [{REPORT_NAME}], scheduled to run at {RUN_TIME},
+has failed with the following error message:
+
+ {ERROR_TEXT}
+
+The SQL command attempted was:
+
+ {SQL}
+
+If you are unsure of the meaning of this message, please contact your
+ILS adminstrator or support staff and give them both the error message
+and the SQL command.
+
--- /dev/null
+To: {TO}
+From: {FROM}
+Reply-To: {REPLY_TO}
+Subject: Report finished: "{REPORT_NAME}"
+
+At {RUN_TIME} the report "{REPORT_NAME}" finished running with a complete
+time of {COMPLETE_TIME}.
+
+You can view the report at the following URL:
+{OUTPUT_URL}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<reporter xmlns:xi="http://www.w3.org/2001/XInclude">
-
- <setup>
- <files>
- <output_base>/openils/var/web/reporter/</output_base>
- <!-- <chart_logo>/openils/var/web/opac/images/small_logo.gif</chart_logo> -->
- </files>
- <database>
- <driver>Pg</driver>
- <host>127.0.0.1</host>
- <port>5433</port>
- <name>develooper</name>
- <user>postgres</user>
- <password/>
- </database>
- </setup>
-
- <xi:include href="tables.example.xml">
- This file sucks in table definitions
- </xi:include>
- <xi:include href="widgets.example.xml">
- This file sucks in widget definitions
- </xi:include>
-
-</reporter>
+++ /dev/null
-To: {TO}
-From: {FROM}
-Reply-To: {REPLY_TO}
-Subject: Report failed: "{REPORT_NAME}"
-
-Your report, named [{REPORT_NAME}], scheduled to run at {RUN_TIME},
-has failed with the following error message:
-
- {ERROR_TEXT}
-
-The SQL command attempted was:
-
- {SQL}
-
-If you are unsure of the meaning of this message, please contact your
-ILS adminstrator or support staff and give them both the error message
-and the SQL command.
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<reporter xmlns:xi="http://www.w3.org/2001/XInclude">
- <report
- type="stage1"
- name="Silly"
- fact-table="silly.fact">
- <description>Silly Report base</description>
- <dims>
- <dim include="silly_word_dim"/>
- <dim include="silly_sayer_dim"/>
- </dims>
- </report>
-</reporter>
-
+++ /dev/null
-To: {TO}
-From: {FROM}
-Reply-To: {REPLY_TO}
-Subject: Report finished: "{REPORT_NAME}"
-
-At {RUN_TIME} the report "{REPORT_NAME}" finished running with a complete
-time of {COMPLETE_TIME}.
-
-You can view the report at the following URL:
-{OUTPUT_URL}
+++ /dev/null
-#!/usr/bin/perl
-use strict; use warnings;
-use XML::LibXML;
-use OpenSRF::Utils qw/:datetime/;
-use DateTime;
-use DateTime::Duration;
-use DateTime::Format::ISO8601;
-
-my $dt_parser = DateTime::Format::ISO8601->new;
-my $log = 'OpenSRF::Utils::Logger';
-
-
-my %chunkmap =
- ( doy => '%j',
- woy => '%U',
- month => '%m',
- year => '%Y',
- );
-
-
-my $parser = XML::LibXML->new;
-my $doc = $parser->parse_file($ARGV[0]);
-$parser->process_xincludes($doc);
-
-print "BEGIN;\n\n";
-for my $table ($doc->findnodes('/reporter/tables/table')) {
- my $tname = $table->getElementsByTagName('tablename')->string_value;
-
- (my $pkey_name = $tname) =~ s/\./_/gso;
- $pkey_name .= '_pkey';
- warn "$tname\n";
-
- my (@primary,@other,@indexed);
- for my $field ($table->findnodes('fields/field')) {
- my $fname = $field->getAttribute('name');
- my $fdatatype = $field->getAttribute('create-type') || $field->getAttribute('datatype');
- warn "\t$fname\n";
-
- if ($field->getAttribute('indexed')) {
- my $itype = $field->getAttribute('index-type') || 'BTREE';
- push @indexed, [$fname, $itype];
- }
-
- if ($field->getAttribute('primary')) {
- push @primary, [$fname, $fdatatype];
- } else {
- push @other, [$fname, $fdatatype];
- }
- }
-
- warn "\n";
- print "DROP TABLE $tname CASCADE;\n";
- print "CREATE TABLE $tname (\n\t".
- join(",\n\t", map { join("\t", @$_) } (@primary, @other))."\n".
- do {
- @primary ?
- ",\tCONSTRAINT $pkey_name PRIMARY KEY (".
- join(", ", map { $$_[0] } @primary). ")\n" :
- ''
- }.
- ");\n";
-
- print "\n";
-
- if ($table->getAttribute('partition')) {
- my ($part) = $table->getElementsByTagName('partition')->get_nodelist;
- my ($field) = $part->getElementsByTagName('field')->get_nodelist;
- my ($chunk) = $part->getElementsByTagName('chunk')->get_nodelist;
- my ($start) = $part->getElementsByTagName('start')->get_nodelist;
- my ($end) = $part->getElementsByTagName('end')->get_nodelist;
-
- $field = $field->textContent;
- $chunk = $chunk->textContent;
- $start = $dt_parser->parse_datetime( $start->textContent );
- $end = $dt_parser->parse_datetime( $end->textContent );
-
-
- while ( $start->epoch < $end->epoch ) {
-
- my $chunk_end = $start->clone;
- $chunk_end->add( DateTime::Duration->new( $chunk => 1 ) );
- $chunk_end->subtract( DateTime::Duration->new( seconds => 1 ) );
-
- my $tpart = $start->epoch;
-
- my $where = "BETWEEN '".$start->strftime('%FT%T%z').
- "' AND '".$chunk_end->strftime('%FT%T%z')."'";
-
- print "CREATE TABLE ${tname}_${chunk}_$tpart () INHERITS ($tname);\n";
- print "ALTER TABLE ${tname}_${chunk}_$tpart\n".
- "\tADD CONSTRAINT \"${tname}_${chunk}_${tpart}_test\"\n".
- "\tCHECK ($field $where);\n";
- print "CREATE RULE \"${tname}_${chunk}_${tpart}_ins_rule\" AS\n\tON INSERT TO ".
- "$tname \n\tWHERE NEW.$field $where".
- "\n\tDO INSTEAD INSERT INTO ${tname}_${chunk}_$tpart VALUES (NEW.*);\n";
- for my $i (@indexed) {
- print "CREATE INDEX \"${tname}_${chunk}_${tpart}_$$i[0]_idx\" ".
- "ON ${tname}_${chunk}_$tpart USING $$i[1] ($$i[0]);\n";
- }
- print "\n";
- $start->add( DateTime::Duration->new( $chunk => 1 ) );
- }
- } else {
- for my $i (@indexed) {
- print "CREATE INDEX \"${tname}_$$i[0]_idx\" ON $tname USING $$i[1] ($$i[0]);\n";
- }
- }
- print "\n";
-
-}
-print "COMMIT;\n";
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<tables>
-
- <table id="wide-circulation" partition="false" fact-table="true">
- <label>Circulation</label>
- <description>Base table for creating circulation reports</description>
- <tablename>stats.fleshed_circulation</tablename>
-
- <fields>
- <field
- name="id"
- primary="true"
- create-type="serial"
- datatype="int">
- <label>ID</label>
- <description>Circulation ID</description>
- </field>
- <field
- name="circ_lib"
- datatype="int"
- indexed="true">
- <label>Circulator</label>
- <description>ID of the Circulating Library</description>
- </field>
- <field
- name="checkin_lib"
- datatype="int"
- indexed="true">
- <label>Checkin Library</label>
- <description>ID of the Checkin Library</description>
- </field>
- <field
- name="owning_lib"
- datatype="int"
- indexed="true">
- <label>Owner</label>
- <description>ID of the Owning Library</description>
- </field>
- <field
- name="start_date_day"
- datatype="date">
- <label>Start Date</label>
- <description>Date of the copy's cataloging</description>
- </field>
- <field
- name="start_date_hour"
- datatype="timestamptz">
- <label>Start Date and Hour</label>
- <description>Date and Hour of the circulation start</description>
- </field>
- <field
- name="due_date_day"
- datatype="date"
- indexed="true" >
- <label>Due Date</label>
- <description>Day the circulation is due</description>
- </field>
- <field
- name="due_date_hour"
- datatype="timestamptz"
- indexed="true" >
- <label>Due Date and Hour</label>
- <description>Day and Hour the circulation is due</description>
- </field>
- <field
- name="due_date"
- datatype="timestamptz"
- indexed="true"
- default="now()">
- <label>Due Date</label>
- <description>Timestamp of the circulation due date</description>
- </field>
- <field
- name="xact_start"
- datatype="timestamptz"
- indexed="true"
- default="now()">
- <label>Start Time</label>
- <description>Timestamp of the circulation start</description>
- </field>
- <field
- name="xact_finish"
- datatype="timestamptz"
- indexed="true"
- default="now()">
- <label>Finish Time</label>
- <description>Timestamp of the circulation end</description>
- </field>
- <field
- name="finish_date_day"
- datatype="date">
- <label>Finsh Date</label>
- <description>Date of the circulation end</description>
- </field>
- <field
- name="finish_date_hour"
- datatype="timestamptz">
- <label>Finish Date and Hour</label>
- <description>Date and Hour of the circulation end</description>
- </field>
- <field
- name="item_lang"
- datatype="text">
- <label>Language</label>
- <description>MARC Item Language</description>
- </field>
- <field
- name="item_form"
- datatype="text">
- <label>Form</label>
- <description>MARC Item Form of Material</description>
- </field>
- <field
- name="item_type"
- datatype="text">
- <label>Type</label>
- <description>MARC Item Type</description>
- </field>
- <field
- name="call_number_label"
- transform-group="call_number"
- widget-family="string-input"
- datatype="text">
- <label>Call Number</label>
- <description>Copy Call Number Label</description>
- </field>
- </fields>
-
- <links>
- <link
- field="start_date_day"
- table="generic_day_series"
- id="circ_start_day"
- key="date"
- type="has_a"/>
- <link
- field="start_date_hour"
- table="generic_hour_series"
- id="circ_start_hour"
- key="date_hour"
- type="has_a"/>
- <link
- field="finish_date_day"
- table="generic_day_series"
- id="circ_finish_day"
- key="date"
- type="has_a"/>
- <link
- field="finish_date_hour"
- table="generic_hour_series"
- id="circ_finish_hour"
- key="date_hour"
- type="has_a"/>
- <link
- field="due_date_day"
- table="generic_day_series"
- id="circ_due_date_day"
- key="date"
- type="has_a"/>
- <link
- field="due_date_hour"
- table="generic_hour_series"
- id="circ_due_date_hour"
- key="date_hour"
- type="has_a"/>
- <link
- field="checkin_lib"
- table="org_unit"
- id="circ_checkin_lib"
- key="id"
- type="has_a"/>
- <link
- field="owning_lib"
- table="org_unit"
- id="circ_owning_lib"
- key="id"
- type="has_a"/>
- <link
- field="item_lang"
- table="marc_lang_map"
- id="circ_language"
- key="code"
- type="has_a"/>
- <link
- field="item_form"
- table="marc_form_map"
- id="circ_item_form"
- key="code"
- type="has_a"/>
- <link
- field="item_type"
- table="marc_type_map"
- id="circ_item_type"
- key="code"
- type="has_a"/>
- <link
- field="circ_lib"
- table="org_unit"
- id="circ_circ_lib"
- key="id"
- type="has_a"/>
- </links>
-
- </table>
-
- <table id="wide-copy" partition="false" fact-table="true">
- <label>Copies</label>
- <description>Base table for creating snapshot reports on copy information</description>
- <tablename>stats.fleshed_copy</tablename>
-
- <fields>
- <field
- name="id"
- primary="true"
- create-type="serial"
- datatype="int">
- <label>ID</label>
- <description>Copy ID</description>
- </field>
- <field
- name="barcode"
- widget-family="string-input"
- datatype="text">
- <label>Barcode</label>
- <description>Copy Barcode</description>
- </field>
- <field
- name="owning_lib"
- datatype="int"
- indexed="true">
- <label>Owner</label>
- <description>ID of the Owning Library</description>
- </field>
- <field
- name="circ_lib"
- datatype="int"
- indexed="true">
- <label>Circulator</label>
- <description>ID of the Circulating Library</description>
- </field>
- <field
- name="create_date_day"
- datatype="date">
- <label>Create Date</label>
- <description>Date of the copy's cataloging</description>
- </field>
- <field
- name="create_date_hour"
- datatype="timestamptz">
- <label>Create Date and Hour</label>
- <description>Date and Hour of the copy's cataloging</description>
- </field>
- <field
- name="create_date"
- datatype="timestamptz"
- indexed="true"
- default="now()">
- <label>Create Date</label>
- <description>Timestamp of the copy's cataloging</description>
- </field>
- <field
- name="edit_date"
- datatype="timestamptz"
- indexed="true"
- default="now()">
- <label>Edit Date</label>
- <description>Timestamp of the copy's last edit</description>
- </field>
- <field
- name="edit_date_day"
- datatype="date">
- <label>Edit Date</label>
- <description>Date of the copy's last edit</description>
- </field>
- <field
- name="edit_date_hour"
- datatype="timestamptz">
- <label>Edit Date and Hour</label>
- <description>Date and Hour of the copy's last edit</description>
- </field>
- <field
- name="item_lang"
- datatype="text">
- <label>Language</label>
- <description>MARC Item Language</description>
- </field>
- <field
- name="item_form"
- datatype="text">
- <label>Form</label>
- <description>MARC Item Form of Material</description>
- </field>
- <field
- name="item_type"
- datatype="text">
- <label>Type</label>
- <description>MARC Item Type</description>
- </field>
- <field
- name="call_number_label"
- transform-group="call_number"
- widget-family="string-input"
- datatype="text">
- <label>Call Number</label>
- <description>Copy Call Number Label</description>
- </field>
- </fields>
-
- <links>
- <link
- field="create_date_day"
- table="generic_day_series"
- id="copy_create_day"
- key="date"
- type="has_a"/>
- <link
- field="create_date_hour"
- table="generic_hour_series"
- id="copy_create_hour"
- key="date_hour"
- type="has_a"/>
- <link
- field="edit_date_day"
- table="generic_day_series"
- id="copy_edit_day"
- key="date"
- type="has_a"/>
- <link
- field="edit_date_hour"
- table="generic_hour_series"
- id="copy_edit_hour"
- key="date_hour"
- type="has_a"/>
- <link
- field="owning_lib"
- table="org_unit"
- id="copy_owning_lib"
- key="id"
- type="has_a"/>
- <link
- field="item_lang"
- table="marc_lang_map"
- id="copy_language"
- key="code"
- type="has_a"/>
- <link
- field="item_form"
- table="marc_form_map"
- id="copy_item_form"
- key="code"
- type="has_a"/>
- <link
- field="item_type"
- table="marc_type_map"
- id="copy_item_type"
- key="code"
- type="has_a"/>
- <link
- field="circ_lib"
- table="org_unit"
- id="copy_circ_lib"
- key="id"
- type="has_a"/>
- </links>
-
- </table>
-
- <table id="wide-call-number" partition="false" fact-table="true">
- <label>Call Numbers/Volumes</label>
- <description>Base table for creating snapshot reports on call number/volume information</description>
- <tablename>stats.fleshed_call_number</tablename>
-
- <fields>
- <field
- name="id"
- primary="true"
- create-type="serial"
- datatype="int">
- <label>ID</label>
- <description>Call Number ID</description>
- </field>
- <field
- name="owning_lib"
- datatype="int"
- indexed="true">
- <label>Owner</label>
- <description>ID of the Owning Library</description>
- </field>
- <field
- name="create_date_day"
- datatype="date">
- <label>Create Date</label>
- <description>Date of the call number's cataloging</description>
- </field>
- <field
- name="create_date_hour"
- datatype="timestamptz">
- <label>Create Date and Hour</label>
- <description>Date and Hour of the call number's cataloging</description>
- </field>
- <field
- name="create_date"
- datatype="timestamptz"
- indexed="true"
- default="now()">
- <label>Create Date</label>
- <description>Timestamp of the call number's cataloging</description>
- </field>
- <field
- name="edit_date"
- datatype="timestamptz"
- indexed="true"
- default="now()">
- <label>Edit Date</label>
- <description>Timestamp of the call number's last edit</description>
- </field>
- <field
- name="edit_date_day"
- datatype="date">
- <label>Edit Date</label>
- <description>Date of the call number's last edit</description>
- </field>
- <field
- name="edit_date_hour"
- datatype="timestamptz">
- <label>Edit Date and Hour</label>
- <description>Date and Hour of the call number's last edit</description>
- </field>
- <field
- name="item_lang"
- datatype="text">
- <label>Language</label>
- <description>MARC Item Language</description>
- </field>
- <field
- name="item_form"
- datatype="text">
- <label>Form</label>
- <description>MARC Item Form of Material</description>
- </field>
- <field
- name="item_type"
- datatype="text">
- <label>Type</label>
- <description>MARC Item Type</description>
- </field>
- <field
- name="label"
- transform-group="call_number"
- widget-family="string-input"
- datatype="text">
- <label>Call Number</label>
- <description>Call Number Label</description>
- </field>
- </fields>
-
- <links>
- <link
- field="create_date_day"
- table="generic_day_series"
- id="call_number_create_day"
- key="date"
- type="has_a"/>
- <link
- field="create_date_hour"
- table="generic_hour_series"
- id="call_number_create_hour"
- key="date_hour"
- type="has_a"/>
- <link
- field="edit_date_day"
- table="generic_day_series"
- id="call_number_edit_day"
- key="date"
- type="has_a"/>
- <link
- field="edit_date_hour"
- table="generic_hour_series"
- id="call_number_edit_hour"
- key="date_hour"
- type="has_a"/>
- <link
- field="owning_lib"
- table="org_unit"
- id="call_number_owning_lib"
- key="id"
- type="has_a"/>
- <link
- field="item_lang"
- table="marc_lang_map"
- id="call_number_language"
- key="code"
- type="has_a"/>
- <link
- field="item_form"
- table="marc_form_map"
- id="call_number_item_form"
- key="code"
- type="has_a"/>
- <link
- field="item_type"
- table="marc_type_map"
- id="call_number_item_type"
- key="code"
- type="has_a"/>
- </links>
-
- </table>
-
- <table id="org_unit" partition="false" fact-table="false">
- <label>Organizational Units</label>
- <description>Table containing library hierarchy definition</description>
- <tablename>actor.org_unit</tablename>
-
- <fields>
- <field
- name="id"
- primary="true"
- filterable='true'
- widget-family="lib-choose"
- create-type="serial"
- datatype="int">
- <label>Unique Library</label>
- <description>Globally Unique Library Identifier</description>
- </field>
- <field
- name="name"
- widget-family="string-choose"
- datatype="text">
- <label>Library Name</label>
- <description>Friendly Library Name</description>
- </field>
- <field
- name="shortname"
- widget-family="string-choose"
- datatype="text">
- <label>Short Name</label>
- <description>Library Short (Policy) Name</description>
- </field>
- </fields>
- </table>
-
- <table id="marc_lang_map" partition="false" fact-table="false">
- <label>MARC Language Codes</label>
- <description>Table mapping MARC three character codes to language names</description>
- <tablename>config.language_map</tablename>
-
- <fields>
- <field
- name="code"
- primary='true'
- datatype="text">
- <label>Code</label>
- <description>MARC Language Code</description>
- </field>
- <field
- name="value"
- widget-family="string-choose"
- datatype="text">
- <label>Language Name</label>
- <description>Name associated with the MARC code</description>
- </field>
- </fields>
- </table>
-
- <table id="generic_day_series" partition="false" fact-table="false">
- <label>Constant day series</label>
- <description>View providing a day series starting at 1900 and ending at 'now'</description>
- <tablename>reporter.date_series</tablename>
-
- <fields>
- <field
- name="date"
- primary='true'
- filterable='true'
- hidden='false'
- datatype="timestamptz">
- <label>Date</label>
- <description>Date</description>
- </field>
- </fields>
- </table>
-
- <table id="generic_hour_series" partition="false" fact-table="false">
- <label>Constant hour series</label>
- <description>View providing a hour series starting at 1900 and ending at 'now'</description>
- <tablename>reporter.date_hour_series</tablename>
-
- <fields>
- <field
- name="date_hour"
- primary='true'
- filterable='true'
- hidden='false'
- datatype="timestamptz">
- <label>Date and Hour</label>
- <description>Date and Hour</description>
- </field>
- </fields>
- </table>
-
- <table id="marc_form_map" partition="false" fact-table="false">
- <label>MARC Item Form Codes</label>
- <description>Table mapping MARC three character codes to Item Form names</description>
- <tablename>config.item_form_map</tablename>
-
- <fields>
- <field
- name="code"
- primary='true'
- datatype="text">
- <label>Code</label>
- <description>MARC Item Form Code</description>
- </field>
- <field
- name="value"
- widget-family="string-choose"
- datatype="text">
- <label>Item Form Name</label>
- <description>Name associated with the MARC code</description>
- </field>
- </fields>
- </table>
-
- <table id="marc_type_map" partition="false" fact-table="false">
- <label>MARC Item Type Codes</label>
- <description>Table mapping MARC three character codes to Item Type names</description>
- <tablename>config.item_type_map</tablename>
-
- <fields>
- <field
- name="code"
- primary='true'
- datatype="text">
- <label>Code</label>
- <description>MARC Item Type Code</description>
- </field>
- <field
- name="value"
- widget-family="string-choose"
- datatype="text">
- <label>Item Type Name</label>
- <description>Name associated with the MARC code</description>
- </field>
- </fields>
- </table>
-
- <!--
-
- <table id="silly.fact" partition="true" fact-table="false">
- <label>Silly Fact table</label>
- <description>Base table for creating reports on silly words</description>
- <tablename>stats.silly_fact</tablename>
-
- <partition>
- <field>said_when</field>
- --><!-- Valid options: years, months, weeks, days, hours, minutes, seconds --><!--
- <chunk>months</chunk>
- <start>2005-09-01</start>
- <end>2005-12-31</end>
- </partition>
-
- <fields>
- <field
- name="id"
- primary="true"
- create-type="serial"
- datatype="int">
- <label>Silly entry id</label>
- <description>Silly entry id</description>
- </field>
- <field
- name="silly_word_dim"
- datatype="int"
- indexed="true">
- <label>Silly word dim</label>
- <description>Silly word entry dimension link</description>
- </field>
- <field
- name="silly_sayer_dim"
- datatype="int"
- indexed="true">
- <label>Silly sayer dim</label>
- <description>Silly sayer entry dimension link</description>
- </field>
- <field
- name="said_when"
- datatype="timestamptz"
- core="true"
- indexed="true"
- default="now()">
- <label>Silly word timestamp</label>
- <description>Silly word entry timestamp</description>
- </field>
- </fields>
- <links>
- <link
- field="silly_word_dim"
- table="silly.word_dim"
- key="id"
- type="has_a"/>
- <link
- field="silly_sayer_dim"
- table="silly.sayer_dim"
- key="id"
- type="has_a"/>
- </links>
- </table>
-
- <table id="silly.word_dim">
- <label>Silly word list</label>
- <description>Silly word list</description>
- <tablename>stats.words</tablename>
- <fields>
- <field
- name="id"
- primary="true"
- create-type="serial"
- datatype="int">
- <label>Silly word id</label>
- </field>
- <field
- name="word"
- datatype="text"
- indexed="true"
- index-type="BTREE">
- <label>Silly word</label>
- </field>
- </fields>
- </table>
-
- <table id="silly.sayer_dim">
- <label>Silly word sayer list</label>
- <description>Silly word sayer list</description>
- <tablename>stats.silly_sayers</tablename>
- <fields>
- <field
- name="id"
- primary="true"
- create-type="serial"
- datatype="int">
- <label>Silly person id</label>
- </field>
- <field
- name="sayer"
- widget-family="string-choose"
- datatype="text"
- indexed="true"
- index-type="BTREE">
- <label>Silly person</label>
- </field>
- </fields>
- </table>
-
- -->
-
-</tables>
-
+++ /dev/null
-[%
-
-PROCESS inputs;
-PROCESS class_manip;
-PROCESS widget_manip;
-PROCESS logic_header.ttk;
-
-pagetype = CGI.param('detail');
-
-%] <style> table {border-collapse:collapse;}</style> [%
-
-SWITCH pagetype;
- CASE 'myreports';
- INCLUDE header.ttk title="Reporter Dashboard -- My Recent Reports";
- INCLUDE navbar.ttk + my_reports;
- CASE 'mytemplates';
- INCLUDE header.ttk title="Reporter Dashboard -- My Recent Templates";
- INCLUDE navbar.ttk + my_templates;
- CASE 'othersreports';
- INCLUDE header.ttk title="Reporter Dashboard -- Others Recent Public Reports";
- INCLUDE navbar.ttk + public_reports;
- CASE 'otherstemplates';
- INCLUDE header.ttk title="Reporter Dashboard -- Others Recent Public Templates";
- INCLUDE navbar.ttk + public_templates;
- CASE 'facttables';
- INCLUDE header.ttk title="Reporter Dashboard -- Core Fact Tables";
- INCLUDE navbar.ttk + fact_tables;
- CASE;
- INCLUDE header.ttk title="Reporter Dashboard";
- INCLUDE navbar.ttk + summary;
-END;
-
-PROCESS logout.ttk;
-
-BLOCK summary;
- WRAPPER html/table border=0 width='100%';
- WRAPPER html/row;
- INCLUDE html/cell
- width='50%'
- content=link(content='My Recent Reports',href='dashboard?detail=myreports')
- align='center'
- style='border-bottom:1px solid black';
- INCLUDE html/cell
- content=link(content='Others Recent Public Reports',href='dashboard?detail=othersreports')
- align='center'
- style='border-bottom:1px solid black';
- END;
- WRAPPER html/row;
- WRAPPER html/cell valign='top' style='height:200px';
- INCLUDE my_reports limit=5;
- END;
- WRAPPER html/cell valign='top';
- INCLUDE public_reports limit=5;
- END;
- END;
- WRAPPER html/row;
- INCLUDE html/cell
- content=link(content='My Recent Templates',href='dashboard?detail=mytemplates')
- align='center'
- style='border-bottom:1px solid black';
- INCLUDE html/cell
- content=link(content='Others Recent Public Templates',href='dashboard?detail=otherstemplates')
- align='center'
- style='border-bottom:1px solid black';
- END;
- WRAPPER html/row;
- WRAPPER html/cell valign='top' style='height:200px';
- INCLUDE my_templates limit=5;
- END;
- WRAPPER html/cell valign='top';
- INCLUDE public_templates limit=5;
- END;
- END;
- WRAPPER html/row;
- INCLUDE html/cell
- colspan=2
- align='center'
- content=link(content='Core Fact Tables',href='dashboard?detail=facttables')
- style='border-bottom:1px solid black';
- END;
- WRAPPER html/row;
- WRAPPER html/cell colspan=2 valign='top';
- INCLUDE fact_tables;
- END;
- END;
- END;
-END;
-
-BLOCK my_reports;
- q = "SELECT * FROM reporter.stage3 WHERE owner = " _ user.id() _
- " ORDER BY runtime DESC";
- IF limit > 0;
- q = q _ ' LIMIT ' _ limit;
- END;
-
- logme(q);
-
- INCLUDE show_reports;
-
-END;
-
-BLOCK public_reports;
- q = "SELECT * FROM reporter.stage3 WHERE pub is true" _
- " and owner != " _ user.id() _ " ORDER BY runtime DESC";
- IF limit > 0;
- q = q _ ' LIMIT ' _ limit;
- END;
-
- logme(q);
-
- INCLUDE show_reports;
-
-END;
-
-BLOCK show_reports;
- WRAPPER html/table width='100%';
- WRAPPER html/row;
- INCLUDE html/cell content='Public' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Report Name' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Created at' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Scheduled Run Time<br>Last Run Time' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Recurrence' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Runs' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- END;
- FOR report = DBI.query(q);
- rid = report.id;
- bg='lightblue';
- IF loop.count % 2;
- bg='white';
- END;
- run_q = 'SELECT * FROM reporter.output WHERE stage3 = ? ORDER BY queue_time LIMIT 1';
- run_count_q = 'SELECT count(*) as count FROM reporter.output WHERE stage3 = ?';
-
- s = DBI.prepare(run_count_q);
- run_count = s.execute(rid);
-
- s = DBI.prepare(run_q);
- run = s.execute(rid);
-
- WRAPPER html/row;
- p = utils.JSON2perl( report.params );
- INCLUDE html/cell content=(report.pub ? 'Y' : 'N') col=bg style='border:solid gray 1px;' align='center';
- INCLUDE html/cell content=link(content=p.reportname,href="stage3?id=$rid") col=bg style='border:solid gray 1px;';
- INCLUDE html/cell nowrap='nowrap' content=report.create_date.chunk(19).0 col=bg style='border:solid gray 1px;';
- INCLUDE html/cell
- nowrap='nowrap'
- content=report.runtime.chunk(19).0 _ '<br>' _ run.get.run_time.chunk(19).0
- col=bg
- style='border:solid gray 1px;';
- INCLUDE html/cell content=report.recurrence col=bg style='border:solid gray 1px;';
- INCLUDE html/cell content=run_count.get.count col=bg style='border:solid gray 1px;';
- END;
- END;
- END;
-END;
-
-BLOCK my_templates;
- q = "SELECT * FROM reporter.stage2 WHERE " _
- " owner = " _ user.id() _ " ORDER BY create_date DESC";
- IF limit > 0;
- q = q _ ' LIMIT ' _ limit;
- END;
-
- logme(q);
-
- INCLUDE show_templates;
-
-END;
-
-BLOCK public_templates;
- q = "SELECT * FROM reporter.stage2 WHERE pub is true" _
- " and owner != " _ user.id() _ " ORDER BY create_date DESC";
- IF limit > 0;
- q = q _ ' LIMIT ' _ limit;
- END;
-
- logme(q);
-
- INCLUDE show_templates;
-
-END;
-
-BLOCK show_templates;
- WRAPPER html/table width='100%' class='withborder';
- WRAPPER html/row;
- INCLUDE html/cell content='Public' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Template Name' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Created at' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- END;
- FOR template = DBI.query(q);
- tid = template.id;
- bg='lightblue';
- IF loop.count % 2;
- bg='white';
- END;
- WRAPPER html/row;
- p = utils.JSON2perl( template.params );
- INCLUDE html/cell content=(template.pub ? 'Y' : 'N') col=bg style='border:solid gray 1px;' align='center';
- INCLUDE html/cell content=link(content=p.templatename,href="stage2?id=$tid") col=bg style='border:solid gray 1px;';
- INCLUDE html/cell content=template.create_date.chunk(10).0 col=bg style='border:solid gray 1px;';
- END;
- END;
- END;
-END;
-
-BLOCK fact_tables;
- WRAPPER html/table width='100%' class='withborder';
- WRAPPER html/row;
- INCLUDE html/cell content='Fact table' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Description' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- END;
-
- fact_table_xpath = "/reporter/tables/table[@fact-table='true']";
- FOR tab = config.findnodes(fact_table_xpath);
- tid = tab.findvalue('@id');
- bg='lightblue';
- IF loop.count % 2;
- bg='white';
- END;
- WRAPPER html/row;
- p = utils.JSON2perl( template.params );
- INCLUDE html/cell
- col=bg
- content=link(content=tab.findvalue('label'),href="stage1?id=$tid") style='border:solid gray 1px;';
- INCLUDE html/cell content=tab.findvalue('description') style='border:solid gray 1px;';
- END;
- END;
- END;
-END;
-
-%]
+++ /dev/null
-[%
-
-PROCESS inputs;
-
-BLOCK class_table;
- WRAPPER html/table width='100%' style='border-top: 1px solid black';
- WRAPPER html/row;
- WRAPPER html/cell align="right" width="30%";
- %]<b>Name:</b>[%
- END;
- WRAPPER html/cell;
- classname.findvalue('label');
- END;
- END;
- WRAPPER html/row;
- WRAPPER html/cell align="right";
- %]<b>Description:</b>[%
- END;
- WRAPPER html/cell;
- classname.findvalue('description');
- END;
- END;
- IF classname.findvalue('@fact-table') == 'true' AND CGI.param('create_stage2') != 1;
- WRAPPER html/row;
- WRAPPER html/cell align="right";
- %]<b>Actions:</b>[%
- END;
- WRAPPER html/cell;
- IF CGI.param('detail');
- %]<a href="?detail=0&id=[% fact_table %]">No Details</a>[%
- ELSE;
- %]<a href="?detail=1&id=[% fact_table %]">Details</a>[%
- END;
- %]|<a href="?create_stage2=1&id=[% fact_table %]">New Report Template</a>[%
- END;
- END;
- WRAPPER html/row;
- INCLUDE html/cell align="right" valign='top' content='<b>Report Templates:</b>';
- WRAPPER html/cell;
- q = 'select * from reporter.stage2 ' _
- 'where pub is true or owner = ' _ DBI.quote(user.id());
- FOR r = DBI.query(q);
- INCLUDE anchor
- href="stage2?id=" _ r.id
- content=utils.JSON2perl(r.params).templatename;
- '<br>';
- END;
- END;
- END;
- END;
-
- INCLUDE class_detail IF CGI.param('detail') == 1;
- END;
-END;
-
-
-
-
-
-
-BLOCK class_fields;
- FOR f = classname.findnodes('fields/field');
- WRAPPER html/row;
- WRAPPER html/cell align="right";
- f.findvalue('label');
- END;
- WRAPPER html/cell;
- %] ([%
- IF f.findvalue('description');
- f.findvalue('description');
- %] -- [%
- END;
- f.findvalue('@name')%]::[%f.findvalue('@datatype') %])[%
- END;
- END;
- END;
-END;
-
-
-
-
-
-
-BLOCK class_detail;
-
- INCLUDE class_fields;
-
- IF classname.findvalue('@fact-table') == 'true' AND nosub != 1;
- WRAPPER html/row;
- WRAPPER html/cell align="right";
- %]<b>Report Dimensions<br>and Attributes:</b>[%
- END;
- WRAPPER html/cell;
- incs = classname.findnodes('links/link/@field');
-
- FOR dim = incs;
- link_xpath = '/reporter/tables/table[@id="' _ fact_table _'"]'_
- '/links/link[@field="' _ dim.value() _ '"]/@table';
- logme(link_xpath);
-
- dim_table = config.findvalue(link_xpath);
-
- dim_xpath = '/reporter/tables/table[@id="' _ dim_table _ '"]';
- logme(dim_xpath);
-
- dim_def = config.findnodes(dim_xpath);
-
- INCLUDE class_table classname = dim_def;
- END;
- END;
- END;
- END;
-END;
-
-%]
-
+++ /dev/null
-[%
-
-PROCESS inputs;
-PROCESS class_manip;
-PROCESS widget_manip;
-PROCESS logic_header.ttk;
-
-pagetype = CGI.param('detail');
-templates = DBI.tie('reporter.stage2', 'id')
-reports = DBI.tie('reporter.stage3', 'id')
-outputs = DBI.tie('reporter.output', 'id')
-
-
-%] <style> table {border-collapse:collapse;}</style> [%
-
-SWITCH pagetype;
- CASE 'myreports';
- INCLUDE header.ttk title="Reporter Dashboard -- Scheduled Reports";
- INCLUDE navbar.ttk + my_scheduled_reports;
- CASE 'mycompletereports';
- INCLUDE header.ttk title="Reporter Dashboard -- Active Reports";
- INCLUDE navbar.ttk + my_completed_reports;
- CASE 'report_template_tree';
- INCLUDE header.ttk title="Reporter Dashboard -- Schedule a report";
- INCLUDE navbar.ttk + report_template_tree;
- CASE;
- INCLUDE header.ttk title="Reporter Dashboard";
- INCLUDE navbar.ttk + summary;
-END;
-
-PROCESS logout.ttk;
-
-BLOCK summary;
- WRAPPER html/table border=0 width='100%';
- WRAPPER html/row;
- INCLUDE html/cell
- content=link(content='Active reports',href='dashboard?detail=mycompletereports')
- align='center'
- style='border-bottom:1px solid black';
- END;
- WRAPPER html/row;
- WRAPPER html/cell valign='top' style='height:200px';
- INCLUDE my_completed_reports limit=5;
- END;
- END;
- WRAPPER html/row;
- INCLUDE html/cell
- content=link(content='Manage scheduled reports',href='dashboard?detail=myreports')
- align='center'
- style='border-bottom:1px solid black';
- END;
- WRAPPER html/row;
- WRAPPER html/cell valign='top' style='height:200px';
- INCLUDE my_scheduled_reports limit=5;
- END;
- END;
- WRAPPER html/row;
- INCLUDE html/cell
- colspan=2
- align='center'
- content=link(content='Schedule a new report',href='dashboard?detail=report_template_tree')
- style='border-bottom:1px solid black';
- END;
- WRAPPER html/row;
- WRAPPER html/cell colspan=2 valign='top';
- INCLUDE report_template_tree;
- '<br/><br/><br/>';
- END;
- END;
- END;
-END;
-
-BLOCK my_completed_reports;
- q = "SELECT o.* FROM reporter.stage3 s JOIN reporter.output o ON (o.stage3 = s.id) WHERE s.owner = " _ user.id() _
- " ORDER BY COALESCE(o.complete_time, o.error_time, o.run_time, o.queue_time) DESC";
- IF limit > 0;
- q = q _ ' LIMIT ' _ limit;
- END;
-
- logme(q);
-
- INCLUDE show_complete_reports;
-
-END;
-
-BLOCK my_scheduled_reports;
- q = "SELECT * FROM reporter.stage3 WHERE owner = " _ user.id() _
- " AND runtime > now() ORDER BY runtime";
- IF limit > 0;
- q = q _ ' LIMIT ' _ limit;
- END;
-
- logme(q);
-
- INCLUDE show_reports;
-
-END;
-
-BLOCK show_complete_reports;
- WRAPPER html/table width='100%' class='sortable' id='show_complete_reports';
- WRAPPER html/row;
- INCLUDE html/cell content='Status' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Base Template' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Report Defintion' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Last Action Time' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- END;
- FOR output = DBI.query(q);
- rid = output.stage3;
-
- bg='lightblue';
- IF loop.count % 2;
- bg='white';
- END;
-
- report = reports.$rid;
-
- tid = report.stage2;
- template = templates.$tid;
-
- p = utils.JSON2perl( report.params );
- t = utils.JSON2perl( template.params );
-
- state = '<span style="font-weight: bold; background-color: lightgray">Waiting in line...</span>';
-
- IF output.state == 'complete';
- state = '<span style="font-weight: bold; background-color: lightgreen">Complete</span>';
- runtime = output.complete_time;
- ELSIF output.state == 'error';
- state = '<span style="font-weight: bold; background-color: lightred">ERROR</span>';
- runtime = output.error_time;
- ELSIF output.state == 'running';
- state = '<span style="font-weight: bold; background-color: lightblue">Running</span>';
- runtime = output.run_time;
- END;
-
- name_link = link(content=p.reportname,href="stage3?id=$rid#$output.id");
- #name_link = t.templatename _ ' :: ' _ name_link;
-
- WRAPPER html/row;
- INCLUDE html/cell
- width='5%'
- nowrap='nowrap'
- content=state
- col=bg
- style='padding:5px; border:solid gray 1px;';
- INCLUDE html/cell
- content=t.templatename
- col=bg
- style='border:solid gray 1px;';
- INCLUDE html/cell
- content=name_link
- col=bg
- style='border:solid gray 1px;';
- INCLUDE html/cell
- nowrap='nowrap'
- content=runtime.chunk(16).0
- col=bg
- style='border:solid gray 1px;';
- END;
- END;
- END;
-END;
-
-
-BLOCK show_reports;
- WRAPPER html/table width='100%' class='sortable' id='show_reports';
- WRAPPER html/row;
- INCLUDE html/cell content='Runs' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Public' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Base Template' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Report Definition' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- #INCLUDE html/cell content='Create date' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Scheduled Run Time' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- END;
- FOR report = DBI.query(q);
- rid = report.id;
- bg='lightblue';
- IF loop.count % 2;
- bg='white';
- END;
- run_q = 'SELECT * FROM reporter.output WHERE stage3 = ? ORDER BY queue_time LIMIT 1';
- run_count_q = 'SELECT count(*) as count FROM reporter.output WHERE stage3 = ?';
-
- s = DBI.prepare(run_count_q);
- run_count = s.execute(rid);
-
- s = DBI.prepare(run_q);
- run = s.execute(rid);
-
- WRAPPER html/row;
-
- tid = report.stage2;
- template = templates.$tid;
-
- p = utils.JSON2perl( report.params );
- t = utils.JSON2perl( template.params );
-
-
- rtime = report.runtime.chunk(16).0;
- IF report.disable;
- rtime = rtime _ '<br/>(Disabled)';
- END;
-
- name_link = link(content=p.reportname,href="stage3?id=$rid");
- #name_link = t.templatename _ ' :: ' _ name_link;
-
- INCLUDE html/cell content=run_count.get.count col=bg style='text-align: center; border:solid gray 1px;';
- INCLUDE html/cell content=(report.pub ? 'Y' : 'N') col=bg style='border:solid gray 1px;' align='center';
- INCLUDE html/cell content=t.templatename col=bg style='border:solid gray 1px;';
- INCLUDE html/cell content=name_link col=bg style='border:solid gray 1px;';
- #INCLUDE html/cell nowrap='nowrap' content=report.create_date.chunk(16).0 col=bg style='border:solid gray 1px;';
- INCLUDE html/cell
- nowrap='nowrap'
- content=rtime
- col=bg
- style='text-align: center; border:solid gray 1px;';
- END;
- END;
- END;
-END;
-
-BLOCK my_templates;
- q = "SELECT * FROM reporter.stage2 WHERE " _
- " owner = " _ user.id() _ " ORDER BY create_date DESC";
- IF limit > 0;
- q = q _ ' LIMIT ' _ limit;
- END;
-
- logme(q);
-
- INCLUDE show_templates;
-
-END;
-
-BLOCK public_templates;
- q = "SELECT * FROM reporter.stage2 WHERE pub is true" _
- " and owner != " _ user.id() _ " ORDER BY create_date DESC";
- IF limit > 0;
- q = q _ ' LIMIT ' _ limit;
- END;
-
- logme(q);
-
- INCLUDE show_templates;
-
-END;
-
-BLOCK show_templates;
- WRAPPER html/table width='100%' class='withborder';
- WRAPPER html/row;
- INCLUDE html/cell content='Public' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Template Name' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- INCLUDE html/cell content='Created at' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
- END;
- FOR template = DBI.query(q);
- tid = template.id;
- bg='lightblue';
- IF loop.count % 2;
- bg='white';
- END;
- WRAPPER html/row;
- p = utils.JSON2perl( template.params );
- INCLUDE html/cell content=(template.pub ? 'Y' : 'N') col=bg style='border:solid gray 1px;' align='center';
- INCLUDE html/cell content=link(content=p.templatename,href="stage2?id=$tid") col=bg style='border:solid gray 1px;';
- INCLUDE html/cell content=template.create_date.chunk(10).0 col=bg style='border:solid gray 1px;';
- END;
- END;
- END;
-END;
-
-BLOCK report_template_tree;
-
- fact_table_xpath = "/reporter/tables/table[@fact-table='true']";
-
- FOR tab = config.findnodes(fact_table_xpath);
- counter = loop.count
- tid = tab.findvalue('@id');
- tname = tab.findvalue('label');
- tdesc = tab.findvalue('description');
- "<div id='fact_tree_$counter'/>";
- content=link(content=tab.findvalue('label'),href="stage1?id=$tid") style='border:solid gray 1px;';
- "<script language='javascript'>
- var tree_$counter = new SlimTree(document.getElementById('fact_tree_$counter'),'tree_$counter');
- tree_" _ counter _ ".addNode($counter,-1,'$tname','stage1?create_stage2=1&id=$tid','$tdesc');
- </script>";
-
- q = "SELECT * FROM reporter.stage2 WHERE (pub is true" _
- " or owner = " _ user.id() _ ") and stage1 = '$tid' ORDER BY create_date DESC";
-
- FOR template = DBI.query(q);
- p = utils.JSON2perl( template.params );
- s2id = template.id;
- "<script language='javascript'>
- tree_" _ counter _ ".addNode(
- $template.id,
- $counter,
- '$p.templatename',
- 'stage2?action=run&id=$s2id',
- '$p.templatename'
- );
- </script>";
-
- q3 = "SELECT * FROM reporter.stage3 WHERE (pub is true" _
- " or owner = " _ user.id() _ ") and stage2 = '$s2id' ORDER BY create_date DESC";
- FOR report = DBI.query(q3);
- p = utils.JSON2perl( report.params );
- s3id = report.id;
- "<script language='javascript'>
- tree_" _ counter _ ".addNode(
- 'r_$report.id',
- $template.id,
- '$p.reportname',
- 'stage2?action=edit&id=$s2id&report=$s3id',
- '$p.reportname'
- );
- </script>";
- END;
-
- END;
- END;
-END;
-
-%]
+++ /dev/null
-
-<!-- Maybe put some other stuff here -->
-
+++ /dev/null
-
-<head>
-
- <!-- Load our JS libs -->
- <script language='javascript' src='/opac/common/js/Cookies.js'> </script>
- <script language='javascript' src='/opac/common/js/md5.js'> </script>
- <script language='javascript' src='/opac/common/js/config.js'> </script>
- <script language='javascript' src='/opac/common/js/utils.js'> </script>
- <script language='javascript' src='/opac/common/js/opac_utils.js'> </script>
- <script language='javascript' src='/opac/common/js/JSON_v1.js'> </script>
- <script language='javascript' src='/opac/common/js/RemoteRequest.js'> </script>
- <script language="javascript" src="/opac/common/js/slimtree.js"></script>
- <script language="javascript">
- stpicopen = '/opac/images/slimtree/folder.gif';
- stpicclose = '/opac/images/slimtree/folderopen.gif';
- stpicblank = '/opac/images/slimtree/page.gif';
- stpicline = '/opac/images/slimtree/line.gif';
- stpicjoin = '/opac/images/slimtree/join.gif';
- stpicjoinb = '/opac/images/slimtree/joinbottom.gif';
-
- stimgopen = elem('img',{src:stpicopen,border:0});
- stimgclose = elem('img',{src:stpicclose,border:0});
- stimgblank = elem('img',{src:stpicblank,border:0});
- stimgline = elem('img',{src:stpicline,border:0});
- stimgjoin = elem('img',{src:stpicjoin,border:0, style:'display:inline;'});
-
- </script>
-
- <title>[% title %]</title>
-
- <style>
- .navbar { border-bottom: 1px solid gray; padding-right: 20px; padding-left: 5px; }
- </style>
-
- <script language="javascript">
-
-addEvent(window, "load", sortables_init);
-
-var SORT_COLUMN_INDEX;
-
-function sortables_init() {
- // Find all tables with class sortable and make them sortable
- if (!document.getElementsByTagName) return;
- tbls = document.getElementsByTagName("table");
- for (ti=0;ti<tbls.length;ti++) {
- thisTbl = tbls[ti];
- if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && (thisTbl.id)) {
- //initTable(thisTbl.id);
- ts_makeSortable(thisTbl);
- }
- }
-}
-
-function ts_makeSortable(table) {
- if (table.rows && table.rows.length > 0) {
- var firstRow = table.rows[0];
- }
- if (!firstRow) return;
-
- // We have a first row: assume it's the header, and make its contents clickable links
- for (var i=0;i<firstRow.cells.length;i++) {
- var cell = firstRow.cells[i];
- var txt = ts_getInnerText(cell);
- cell.innerHTML = '<a href="#" class="sortheader" onclick="ts_resortTable(this);return false;">'+txt+'<span class="sortarrow"> </span></a>';
- }
-}
-
-function ts_getInnerText(el) {
- if (typeof el == "string") return el;
- if (typeof el == "undefined") { return el };
- if (el.innerText) return el.innerText; //Not needed but it is faster
- var str = "";
-
- var cs = el.childNodes;
- var l = cs.length;
- for (var i = 0; i < l; i++) {
- switch (cs[i].nodeType) {
- case 1: //ELEMENT_NODE
- str += ts_getInnerText(cs[i]);
- break;
- case 3: //TEXT_NODE
- str += cs[i].nodeValue;
- break;
- }
- }
- return str;
-}
-
-function ts_resortTable(lnk) {
- // get the span
- var span;
- for (var ci=0;ci<lnk.childNodes.length;ci++) {
- if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci];
- }
- var spantext = ts_getInnerText(span);
- var td = lnk.parentNode;
- var column = td.cellIndex;
- var table = getParent(td,'TABLE');
-
- // Work out a type for the column
- if (table.rows.length <= 1) return;
- var itm = ts_getInnerText(table.rows[1].cells[column]);
- sortfn = ts_sort_caseinsensitive;
- if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d\d\d$/)) sortfn = ts_sort_date;
- if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d$/)) sortfn = ts_sort_date;
- if (itm.match(/^[£$]/)) sortfn = ts_sort_currency;
- if (itm.match(/^[\d\.]+$/)) sortfn = ts_sort_numeric;
- SORT_COLUMN_INDEX = column;
- var firstRow = new Array();
- var newRows = new Array();
- for (i=0;i<table.rows[0].length;i++) { firstRow[i] = table.rows[0][i]; }
- for (j=1;j<table.rows.length;j++) { newRows[j-1] = table.rows[j]; }
-
- newRows.sort(sortfn);
-
- if (span.getAttribute("sortdir") == 'down') {
- ARROW = ' ↑';
- newRows.reverse();
- span.setAttribute('sortdir','up');
- } else {
- ARROW = ' ↓';
- span.setAttribute('sortdir','down');
- }
-
- // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
- // don't do sortbottom rows
- for (i=0;i<newRows.length;i++) { if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) table.tBodies[0].appendChild(newRows[i]);}
- // do sortbottom rows only
- for (i=0;i<newRows.length;i++) { if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) table.tBodies[0].appendChild(newRows[i]);}
-
- // Delete any other arrows there may be showing
- var allspans = document.getElementsByTagName("span");
- for (var ci=0;ci<allspans.length;ci++) {
- if (allspans[ci].className == 'sortarrow') {
- if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us?
- allspans[ci].innerHTML = ' ';
- }
- }
- }
-
- span.innerHTML = ARROW;
-}
-
-function getParent(el, pTagName) {
- if (el == null) return null;
- else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) // Gecko bug, supposed to be uppercase
- return el;
- else
- return getParent(el.parentNode, pTagName);
-}
-function ts_sort_date(a,b) {
- // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
- aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
- bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
- if (aa.length == 10) {
- dt1 = aa.substr(6,4)+aa.substr(3,2)+aa.substr(0,2);
- } else {
- yr = aa.substr(6,2);
- if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
- dt1 = yr+aa.substr(3,2)+aa.substr(0,2);
- }
- if (bb.length == 10) {
- dt2 = bb.substr(6,4)+bb.substr(3,2)+bb.substr(0,2);
- } else {
- yr = bb.substr(6,2);
- if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
- dt2 = yr+bb.substr(3,2)+bb.substr(0,2);
- }
- if (dt1==dt2) return 0;
- if (dt1<dt2) return -1;
- return 1;
-}
-
-function ts_sort_currency(a,b) {
- aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
- bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
- return parseFloat(aa) - parseFloat(bb);
-}
-
-function ts_sort_numeric(a,b) {
- aa = parseFloat(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));
- if (isNaN(aa)) aa = 0;
- bb = parseFloat(ts_getInnerText(b.cells[SORT_COLUMN_INDEX]));
- if (isNaN(bb)) bb = 0;
- return aa-bb;
-}
-
-function ts_sort_caseinsensitive(a,b) {
- aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
- bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
- if (aa==bb) return 0;
- if (aa<bb) return -1;
- return 1;
-}
-
-function ts_sort_default(a,b) {
- aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
- bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
- if (aa==bb) return 0;
- if (aa<bb) return -1;
- return 1;
-}
-
-
-function addEvent(elm, evType, fn, useCapture)
-// addEvent and removeEvent
-// cross-browser event handling for IE5+, NS6 and Mozilla
-// By Scott Andrew
-{
- if (elm.addEventListener){
- elm.addEventListener(evType, fn, useCapture);
- return true;
- } else if (elm.attachEvent){
- var r = elm.attachEvent("on"+evType, fn);
- return r;
- } else {
- alert("Handler could not be removed");
- }
-}
- </script>
- [% content %]
-</head>
-
+++ /dev/null
-[%
-
- #---------------------------------------------------------------------------------
- #html/body: <body>...</body> element for HTML pages
- #
- # ARGS:
- #
- # content # body content
- #---------------------------------------------------------------------------------
-
- "<body";
-
- IF onload; " onload='$onload'"; END;
- IF onclick; " onclick='$onclick'"; END;
- IF style; " style='$style'"; END;
- IF class; " class='$class'"; END;
- IF id; " id='$id'"; END;
-
- ">";
-
- content;
-
- "</body>";
-
-%]
+++ /dev/null
-[%# html/cell: an empty and orphaned HTML table cell, <td> . . . </td>
- # ARGS:
- # col # background colour (default: none)
- # align # horizontal alignment (default: none)
- # valign # vertical alignment (default: none)
- # colspan # span multiple columns (defualt: none)
- # rowspan # span multiple rows (defualt: none)
- # content # box content
--%]
-
-<td
- [%- IF width %] width="[% width %]"[% END %]
- [%- IF col %] bgcolor="[% col %]"[% END %]
- [%- IF colspan %] colspan="[% colspan %]"[% END %]
- [%- IF rowspan %] rowspan="[% rowspan %]"[% END %]
- [%- IF align %] align="[% align %]"[% END %]
- [%- IF padding %] padding="[% padding %]"[% END %]
- [%- IF class %] class="[% class %]"[% END %]
- [%- IF id %] id="[% id %]"[% END %]
- [%- IF valign %] valign="[% valign %]"[% END %]
- [%- IF nowrap %] nowrap="[% nowrap %]"[% END %]
- [%- IF style %] style="[% style %]"[% END %]>
-[%- content -%]
-</td>
-
+++ /dev/null
-<center>[% content %]</center>
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
-[% USE x = Unicode %]
-
-<html>
-[% content; %]
-</html>
+++ /dev/null
-[%# row: an empty and orphaned HTML table row, <tr> . . . </tr>
- # ARGS:
- # col # background colour (default: none)
- # valign # vertical alignment (default: none)
- # align # horizontal alignment (default: none)
- # content # box content
--%]
-
-<tr
- [%- IF col %] bgcolor="[% col %]"[% END %]
- [%- IF id %] id="[% id %]"[% END %]
- [%- IF align %] align="[% align %]"[% END %]
- [%- IF class %] class="[% class %]"[% END %]
- [%- IF valign %] valign="[% valign %]"[% END %]>
-[%- content -%]
-</tr>
-
+++ /dev/null
-[%# table: an empty HTML table <table> . . . </table>
- # ARGS:
- # border # border width (default: 0)
- # col # background colour (default: none)
- # width # width of box (default: none, grow to fit content)
- # pad # cellpadding (default: none)
- # cellspace # cellspacing (default: none)
- # content # box content
--%]
-<table border="[% border or 0 %]"
- [%- IF col %] bgcolor="[% col %]"[% END %]
- [%- IF width %] width="[% width %]"[% END %]
- [%- IF pad.defined %] cellpadding="[% pad %]"[% END %]
- [%- IF class %] class="[% class %]"[% END %]
- [%- IF style %] style="[% style %]"[% END %]
- [%- IF id %] id="[% id %]"[% END %]
- [%- IF cellspace.defined %] cellspacing="[% cellspace %]"[% END %]>
-[%- content -%]
-</table>
+++ /dev/null
-[%# html/cell: an empty and orphaned HTML table cell, <th> . . . </th>
- # ARGS:
- # col # background colour (default: none)
- # align # horizontal alignment (default: none)
- # valign # vertical alignment (default: none)
- # colspan # span multiple columns (defualt: none)
- # rowspan # span multiple rows (defualt: none)
- # content # box content
--%]
-
-<th
- [%- IF width %] width="[% width %]"[% END %]
- [%- IF col %] bgcolor="[% col %]"[% END %]
- [%- IF colspan %] colspan="[% colspan %]"[% END %]
- [%- IF rowspan %] rowspan="[% rowspan %]"[% END %]
- [%- IF align %] align="[% align %]"[% END %]
- [%- IF padding %] padding="[% padding %]"[% END %]
- [%- IF class %] class="[% class %]"[% END %]
- [%- IF id %] id="[% id %]"[% END %]
- [%- IF valign %] valign="[% valign %]"[% END %]
- [%- IF nowrap %] nowrap="[% nowrap %]"[% END %]
- [%- IF style %] style="[% style %]"[% END %]>
-[%- content -%]
-</th>
-
+++ /dev/null
-[%
-
-BLOCK form;
- '<form ';
-
- IF name;
- 'name="' _ name _ '" ';
- END;
-
- IF id;
- 'id="' _ id _ '" ';
- END;
-
- IF onsubmit;
- 'onsubmit="' _ onsubmit _ '" ';
- END;
-
- IF action;
- 'action="' _ action _ '" ';
- END;
-
- IF method;
- 'method="' _ method _ '" ';
- END;
-
- '>' _ content _ '</form>';
-END;
-
-BLOCK text;
- %]<INPUT TYPE="text" NAME="[%
- name;
- %]" VALUE="[%
- value;
- %]" [%
- IF size;
- %]SIZE="[% size %]" [%
- END;
- IF max;
- %]MAXLENGTH="[% max %]" [%
- END;
- %]>[%
-END;
-
-BLOCK textarea;
- %]<TEXTAREA NAME="[% name %]">[% value %]</TEXTAREA>[%
-END;
-
-BLOCK select;
- %]<select id="[% id %]" name="[% name %]" onchange="[% onchange %]" size="[% size %]"[% IF multi %] multiple="multiple" [% END %]>[%
- content;
- %]</select>[%
-END;
-
-BLOCK option;
- %]<option id="[% id %]" value="[% value %]"[% IF selected %] selected="selected" [% END %]>[%
- IF content;
- content;
- ELSE;
- value;
- END;
- %]</option>[%
-END;
-
-BLOCK hidden;
- %]<INPUT TYPE="hidden" NAME="[% name %]" VALUE="[% value %]">[%
-END;
-
-BLOCK radio;
- %]<INPUT TYPE="radio" NAME="[% name %]" VALUE="[% value %]" [% IF checked %]CHECKED[% END %]>[%
-END;
-
-BLOCK checkbox;
- %]<INPUT TYPE="checkbox" NAME="[% name %]" VALUE="[% value %]" [% IF onclick %]onclick="[% onclick %]"[% END %] [% IF checked %]CHECKED[% END %]>[%
-END;
-
-BLOCK submit;
- %]<INPUT TYPE="submit" onclick="[% onclick %]" NAME="[% name %]" VALUE="[% value %]">[%
-END;
-
-BLOCK button;
- %]<button NAME="[% name %]" VALUE="[% value %]" onclick="[% onclick %]">[% content %]</button>[%
-END;
-
-MACRO link INCLUDE anchor;
-
-BLOCK anchor;
- %]<a
- href="[%href%]"
- title="[%title%]"
- class="[%class%]"
- target="[%target%]"
- onclick="[%onclick%]"
- alt="[%alt%]">[%content%]</a>[%
-END;
-
-%]
-
+++ /dev/null
-<style>
-* { font-family: sans-serif;
- font-size: 10pt;
-}
-</style>
-[%
-
-PROCESS utils;
-
-BLOCK logme_block;
- "\n\t<!-- " _ x _ " -->\n";
-END;
-
-MACRO logme(a) PROCESS logme_block x = a.list.join(', ');
-
-USE CGI;
-USE DBI;
-USE WebSession;
-USE utils = WebUtils;
-USE config = XML.LibXML(config_xml, expand_xinclude => 1);
-
-
-dir = '/reporter/setup/files/' _ stage_dir;
-dir = config.findvalue(dir);
-
-dbdriver = config.findvalue('/reporter/setup/database/driver');
-dbname = config.findvalue('/reporter/setup/database/name');
-dbhost = config.findvalue('/reporter/setup/database/host');
-dbport = config.findvalue('/reporter/setup/database/port') || '5432';
-d_u = config.findvalue('/reporter/setup/database/user');
-d_p = config.findvalue('/reporter/setup/database/password');
-
-dsn = "dbi:" _ dbdriver _ ":dbname=" _ dbname _';host=' _ dbhost _ ';port=' _ dbport;
-
-logme([dsn,d_u,d_p]);
-
-DBI.connect(dsn,d_u,d_p,pg_enable_utf8=1);
-
-stage2_insert = 'INSERT INTO reporter.stage2 (stage1, params, owner, pub)' _
- ' VALUES ( ?,?,?,? )';
-
-stage3_insert = 'INSERT INTO reporter.stage3 (stage2, params, owner, pub, runtime, recurrence)' _
- ' VALUES ( ?,?,?,?,?,? )';
-%]
+++ /dev/null
-<html>
-
- [% INCLUDE header.ttk title="Login" %]
-
- <body onload='initPage();'>
-
- <script language='javascript'>
-
- function initPage() {
- document.getElementById("reports_login_username").focus();
- document.getElementById("reports_login_username").onkeypress = checkInputClicks;
- document.getElementById("reports_login_password").onkeypress = checkInputClicks;
- }
-
- function checkInputClicks(evt) {
- if(userPressedEnter(evt)) doLogin();
- }
-
-
- function doLogin() {
-
- var uname = document.getElementById("reports_login_username").value;
- var passwd = document.getElementById("reports_login_password").value;
-
- var init_request = new RemoteRequest(
- "open-ils.auth",
- "open-ils.auth.authenticate.init", uname );
-
- init_request.send(true);
- var seed = init_request.getResultObject();
-
- if( ! seed || seed == '0') {
- alert( "Error Communicating with Authentication Server" );
- return null;
- }
-
- var auth_request = new RemoteRequest(
- "open-ils.auth", "open-ils.auth.authenticate.complete",
- {
- username : uname,
- password : hex_md5(seed + hex_md5(passwd)),
- type : "staff"
- });
-
- auth_request.send(true);
- var auth_result = auth_request.getResultObject().payload.authtoken;
-
- if(auth_result == '0' || auth_result == null || auth_result.length == 0) {
- alert("Login failed");
- return false;
- }
-
- cookieManager.write(COOKIE_SES, auth_result, '+1d');
- location.href = location.href;
-
- }
-
- </script>
-
- <br/>
- <center>
- <h3> Reports Login </h3>
- <table style='padding: 4px; border: 2px solid #E0E0E0;'>
- <tr>
- <td >Username: </td>
- <td ><input type='text' id='reports_login_username'/></td>
- </tr>
- <tr>
- <td >Password: </td>
- <td ><input type='password' id='reports_login_password'/></td>
- <tr>
- </tr>
- <td><input type='submit' value='Login' onclick='doLogin();'/></td>
- </tr>
- </table>
- </center>
-
- </body>
-
- [% INCLUDE footer.ttk %]
-
-</html>
-
-
-
-
+++ /dev/null
-<script language='javascript'>
-
- function doLogout() {
-
- var ses = cookieManager.read(COOKIE_SES);
-
- if(ses) {
- var req = new RemoteRequest(
- "open-ils.auth",
- "open-ils.auth.session.remove", ses );
- req.send(true);
- }
-
- cookieManager.remove(COOKIE_SES);
- location.href = location.href.replace( /(\?.*$)/, "" );
-
-}
-
-</script>
-
-
+++ /dev/null
-<span class='navbar'>
- <a href='javascript:void(0);' onclick='doLogout();'>Logout</a> |
- <a href='dashboard'>Dashboard</a>
- [% IF links.list.size > 0;
- ' | ';
- links.list.join(' | ');
- END; %]
-</span>
-
-<br>
-<br>
-
+++ /dev/null
-<script language="javascript">
-
-function show_hide_params (sel) {
- var span = document.getElementById('hide-param:' + sel.name);
- if (sel.options[sel.selectedIndex].textContent.match(/\(*\)/)) {
- span.style.visibility = 'visible';
- } else {
- span.style.visibility = 'hidden';
- }
-
- return true;
-}
-
-function field_add_remove (x) {
- var field = x.name;
- if (x.checked) {
- Widget.Select.addOption('output_order',field, outputs[field]);
- Widget.Select.addOption('pivot_col',field, outputs[field]);
- } else {
- Widget.Select.removeOption('output_order',field);
- Widget.Select.removeOption('pivot_col',field);
- }
- return true;
-}
-
-
-if ( typeof Widget == "undefined" ) Widget = {};
-
-if ( typeof Widget.Select == "undefined" ) Widget.Select = {};
-
-Widget.Select.VERSION = '0.01';
-
-
-Widget.Select.selectAll = function (source){
- if (typeof(source) != 'object') source = document.getElementById(source);
- var l = source.options.length;
- for (var j=0; j<l; j++){
- source.options[j].selected = true;
- }
-}
-
-
-Widget.Select.selectNone = function(source){
- if (typeof(source) != 'object') source = document.getElementById(source);
- var l = source.options.length;
- for (var j=0; j<l; j++){
- source.options[j].selected = false;
- }
-}
-
-
-Widget.Select.invertSelection = function(source){
- if (typeof(source) != 'object') source = document.getElementById(source);
- var l = source.options.length;
- for (var j=0; j<l; j++){
- source.options[j].selected = ! source.options[j].selected;
- }
-}
-
-Widget.Select._moveOption = function(e, source, s_idx, target){
- var opt = new Option(
- e.text, e.value);
- opt.selected = e.selected;
- target.options[target.options.length] = opt;
- source.options[s_idx] = null;
-}
-
-
-Widget.Select.moveSelectedOptionsUp = function(source){
- if (typeof(source) != 'object') source = document.getElementById(source);
- var l = source.options.length;
- for (var j=0; j<l; j++){
-
- var e = source.options[0];
- if (e.selected){
- Widget.Select._moveOption(e, source, 0, source, l);
- continue;
- }
-
-
- while (j<l-1){
- var f= source.options[1];
- if (!f.selected) break;
- Widget.Select._moveOption(f, source, 1, source, l);
- j++;
- }
-
- Widget.Select._moveOption(e, source, 0, source, l);
- }
-
-}
-
-
-Widget.Select.moveSelectedOptionsDown = function(source){
- if (typeof(source) != 'object') source = document.getElementById(source);
- var l = source.options.length;
- var skip=0;
- for (var j=0; j<l; j++){
- var e = source.options[0];
- if (skip == 0){
- if (e.selected){
- for (var i=1;i<l-j; i++){
- var f = source.options[i];
- if (! f.selected){
- Widget.Select._moveOption(f, source, i, source, l);
- j++;
- break;
- }
- skip++;
-
- }
-
- }
- }else{
- skip--;
- }
-
- Widget.Select._moveOption(e, source, 0, source, l);
-
- }
-
-}
-
-
-
-Widget.Select.moveSelectedOptionsTo = function(source, target){
- if (typeof(source) != 'object') source = document.getElementById(source);
- if (typeof(target) != 'object') target = document.getElementById(target);
- for (var i=0; i<source.options.length; i++){
- var e = source.options[i];
- if(e.selected){
- Widget.Select._moveOption(e,source, i, target, target.options.length);
- i--;
- }
- }
-}
-
-
-
-
-
-
-Widget.Select.addOption = function (target,val,l) {
- if (typeof(target) != 'object') target = document.getElementById(target);
- target.options[target.options.length] = new Option( l, val );
-}
-
-Widget.Select.removeOption = function (target, val) {
- if (typeof(target) != 'object') target = document.getElementById(target);
- var l = target.options.length;
- for ( var i = 0; i<l; i++) {
- if (target.options[i].value == val) {
- target.options[i] = null;
- break;
- }
- }
-}
-
-
-
-</script>
+++ /dev/null
-[%
-
-PROCESS inputs;
-PROCESS class_manip;
-PROCESS widget_manip;
-PROCESS logic_header.ttk;
-INCLUDE logout.ttk;
-
-WRAPPER html/html;
- INCLUDE header.ttk + navbar.ttk title="Basic Report Types";
- WRAPPER html/body html.body.onload=
- "if (document.getElementById('templatename')) {" _
- "document.getElementById('templatename').focus();" _
- "document.getElementById('templatename').select();}";
- IF !CGI.param('id');
- INCLUDE all_stage1;
- ELSE;
- INCLUDE one_stage1;
- END;
- END;
- INCLUDE footer.ttk;
-END;
-
-
-
-
-#=============================================================================
-
-
-BLOCK one_stage1;
- table_xpath =
- '/reporter/tables/table[@id="' _
- CGI.param('id') _ '"]';
- table = config.findnodes(table_xpath);
-
- fact_table = table.findvalue('@id');
- logme(fact_table);
-
- INCLUDE class_table classname=table;
-
- INCLUDE stage2_new IF CGI.param('create_stage2') == 1;
-
-END;
-
-
-
-
-BLOCK all_stage1;
- '<ul>';
-
- FOR tab = config.findnodes("/reporter/tables/table[@fact-table='true']");
-
- fact_table = tab.findvalue("@id");
- logme("Fact Table is $fact_table");
-
- '<li>';
-
- INCLUDE class_table classname=tab;
-
- IF loop.count != loop.size;
- '<hr>';
- END;
- END;
- '</ul>';
-END;
-
-
-
-
-
-BLOCK stage2_new;
- col_xpath = "/reporter/tables/table[@id='" _ fact_table _ "']/fields/field[@core='true']";
- logme(col_xpath);
-
- %]<br/><form id="stage2_new" name="stage2_new" action="stage2" method="POST" onsubmit="return require_name(this)">
- <script language="javascript">
- function require_name (f) {
- if (!f.elements['templatename'].value) {
- alert("Template Name is required!");
- return false;
- }
- return true;
- }
- </script>
- <input type="hidden" name="action" value="save">
- <input type="hidden" name="stage1" value="[% CGI.param('id') %]">
- <center>
- <b>Template name </b> <input type="text" name="templatename" id="templatename" size="40" ><br/><br><br>
- </center>
- <b>Select Filter Widgets and Output Dimensions</b><br>[%
-
-
- WRAPPER html/table width="100%" style='border-top: 1px solid black';
- WRAPPER html/row;
- WRAPPER html/cell colspan=2 align='left' style="padding-left: 30px; border: solid black 1px; background: lightgray;";
- # hidden input here ...
- table = config.findnodes("/reporter/tables/table[@id='$fact_table']");
- INCLUDE hidden name="filter" value=fact_table;
- table.findvalue('label');
- ' Core Columns';
- END;
- END;
- #WRAPPER html/row;
- # INCLUDE html/cell content='<b>Attribute</b>' align='right';
- # INCLUDE html/cell content='<b>Widget</b>' align='center';
- #END;
- INCLUDE widget_selector tableid=fact_table columns=config.findnodes(col_xpath) force=1;
- END;
-
- dim_xpath = "/reporter/tables/table[@id='$fact_table']/links/link";
- FOR dim_link = config.findnodes(dim_xpath);
- dim_table = dim_link.findvalue('@table');
- link_id = dim_link.findvalue('@id');
- dimension = config.findnodes("/reporter/tables/table[@id='$dim_table']");
-
- '<br/><br/>';
-
- WRAPPER html/table width="100%" style='border-top: 1px solid black';
- WRAPPER html/row;
- WRAPPER html/cell align='left' width="33%" style="padding-left: 30px; border: solid black 1px; background: lightgray;";
-
- link_label_xpath = '../../fields/field[@name="' _ dim_link.findvalue('@field') _ '"]/label';
- dim_link.findvalue(link_label_xpath);
-
- ' -- ';
- dimension.findvalue('label');
- ' Dimension';
-
- END;
- WRAPPER html/cell align='left' style="padding-left: 30px; border: solid black 1px; background: white;";
- # checkbox input here ...
- INCLUDE checkbox name="filter" value=link_id checked=1;
- 'Allow these columns to be used in Report Output';
- END;
- END;
- INCLUDE widget_selector tableid=link_id;
- END;
- END;
-
- %]
- <input type="checkbox" name="publictemplate" value="t">Public template<br><br>
- [%
- INCLUDE submit name='button' value='Save';
-
- '</form>';
-
-END;
-
-%]
-
+++ /dev/null
-[%
-
-WRAPPER html/html;
- WRAPPER header.ttk + navbar.ttk title="Report Templates";
- PROCESS inputs;
- PROCESS class_manip;
- PROCESS widget_manip;
- INCLUDE logout.ttk;
- END;
-
- WRAPPER html/body;
-
- PROCESS logic_header.ttk;
- PROCESS select_sorter.js;
-
- templates = DBI.tie('reporter.stage2', 'id')
- reports = DBI.tie('reporter.stage3', 'id')
- tmpl = {};
-
-
- IF CGI.param('id');
- tid = CGI.param('id');
- tmpl = templates.$tid;
- END;
-
- IF CGI.param('action') == 'save';
- PROCESS save_stage2;
- ELSIF CGI.param('action') == 'edit';
- rid = CGI.param('report');
- r = reports.$rid;
- report = utils.JSON2perl( r.params );
- PROCESS run_stage2;
- ELSIF CGI.param('action') == 'run';
- PROCESS run_stage2;
- ELSE;
- PROCESS view_stage2;
- END;
- END;
- INCLUDE footer.ttk;
-END;
-
-
-
-
-BLOCK save_stage2;
- stage1 = CGI.param('stage1');
- pub = CGI.param('publictemplate') OR 'f';
- owner = user.id();
-
- p_obj = {};
- FOR p = CGI.param();
-
- logme([p,CGI.param(p)]);
-
- parts = p.split(':');
- p1 = parts.0;
- p2 = parts.1;
- p3 = parts.2;
- p4 = parts.3;
-
- IF p4
- AND (CGI.param("$p1").list.grep("^$p2$").size > 0)
- AND (CGI.param("$p1:$p2").list.grep("^$p3$").size > 0)
- AND (CGI.param("$p1:$p2:$p3").list.grep("^$p4$").size > 0);
-
- p_obj.$p1.$p2.$p3.$p4 = CGI.param(p);
-
- ELSIF p2
- AND (CGI.param("$p1").list.grep(p2).size > 0);
- p_obj.dims.$p2 = 1;
- ELSIF p1 != 'filter';
- p_obj.$p1 = CGI.param(p);
- END;
-
- END;
-
- params = utils.perl2JSON( p_obj );
-
- logme([stage1, params, owner, pub]);
-
- q = DBI.prepare( stage2_insert );
- CALL q.execute(stage1, params, owner, pub);
-
- FOR new_s2 = DBI.query("SELECT * FROM reporter.stage2_id_seq;");
- tid = new_s2.last_value;
- INCLUDE view_stage2 tmpl = templates.$tid;
- END;
-END;
-
-
-
-
-BLOCK edit_stage2;
-
-END;
-
-
-
-
-
-BLOCK view_stage2;
- logme(tmpl.params);
- params = utils.JSON2perl( tmpl.params );
-
- WRAPPER html/table border=0 width='100%';
- WRAPPER html/row;
- WRAPPER html/cell colspan=5 align='center';
- s1_name_xpath = '/reporter/tables/table[@id="' _ params.stage1 _ '"]/label';
- INCLUDE anchor
- content=config.findvalue( s1_name_xpath )
- href="stage1?id=" _ params.stage1;
- ' :: ' _ params.templatename _ '<br>';
- INCLUDE anchor
- content="Create a report from this template"
- href=CGI.url('-path', 1) _ '?action=run&id=' _ tmpl.id;
- END;
- END;
-
- WRAPPER html/row;
- INCLUDE html/cell colspan=4 content="<b>Filterable Attributes:</b>";
- END;
-
- core_table = params.stage1;
-
- tables = params.filter.keys;
- tables.unshift(core_table);
- tables = tables.unique;
-
- FOR t = tables;
- logme(['table id or link id', t]);
-
- f_table = INCLUDE find_table_id id=t;
-
- table = config.findnodes( "/reporter/tables/table[@id='$f_table']");
- WRAPPER html/row;
- INCLUDE html/cell;
- WRAPPER html/cell colspan=4 align='left';
-
- IF t != f_table;
- link_xpath = '//*[@id="' _ t _ '"]';
- dim_link = config.findnodes(link_xpath);
-
- link_label_xpath =
- '../../fields/field[@name="' _
- dim_link.findvalue('@field') _ '"]/label';
- dim_link.findvalue(link_label_xpath);
-
- ' -- ';
- END;
-
- table.findvalue( 'label' );
- END;
- END;
-
- FOR f_field = params.filter.$t.keys;
- logme([f_table,f_field]);
- FOR f_fam = params.filter.$t.$f_field.keys;
- logme([f_table,f_field,f_fam]);
- f_widget = params.filter.$t.$f_field.$f_fam;
- logme([f_table,f_field,f_fam,f_widget]);
-
- WRAPPER html/row;
- field = table.findnodes( "fields/field[@name='$f_field']" );
- fam = config.findnodes( "/reporter/widgets/widget-family[@name='$f_fam']" );
- widget = fam.findnodes( "widget[@name='$f_widget']" );
-
- INCLUDE html/cell colspan=2;
- INCLUDE html/cell align='right' content=field.findvalue( 'label' );
- INCLUDE html/cell align='center' content=fam.findvalue( 'label' );
- INCLUDE html/cell align='left' content=widget.findvalue( 'label' );
- END;
- END;
- END;
- END;
-
- WRAPPER html/row;
- INCLUDE html/cell colspan=5 content="<br>";
- END;
-
- WRAPPER html/row;
- INCLUDE html/cell colspan=5 content="<b>Attributes Available for Output</b>";
- END;
-
- tables = params.dims.keys;
- tables.unshift(core_table);
- tables = tables.unique;
-
- FOR t = tables;
-
- f_table = INCLUDE find_table_id id=t;
-
- table = config.findnodes( "/reporter/tables/table[@id='$f_table']");
- tname = table.findvalue( "label" );
- tdesc = table.findvalue( "desription" );
-
- #NEXT IF table.findvalue('@fact-table') == 'true';
-
- WRAPPER html/row;
- INCLUDE html/cell;
- WRAPPER html/cell colspan=4 align='left';
- IF t != f_table;
- link_xpath = '//*[@id="' _ t _ '"]';
- dim_link = config.findnodes(link_xpath);
-
- link_label_xpath =
- '../../fields/field[@name="' _
- dim_link.findvalue('@field') _ '"]/label';
- dim_link.findvalue(link_label_xpath);
-
- ' -- ';
- END;
- tname;
- END;
- END;
-
-
- FOR field = table.findnodes('fields/field[not(@primary) or @primary != "true"]');
- link_test = 'links/link[@field="' _ field.findvalue('@name') _ '" and (not(@hidden) or @hidden!="false")]';
- logme(['view_stage2 -> link_test',link_test]);
- NEXT IF table.findnodes( link_test );
-
- fname = field.findvalue( "label" );
- fdesc = field.findvalue( "desription" );
-
- WRAPPER html/row;
-
- INCLUDE html/cell colspan=2;
- INCLUDE html/cell align='right' content=fname;
- INCLUDE html/cell colspan=2 align='center' content=fdesc;
- END;
- END;
- END;
-
- END;
-END;
-
-
-BLOCK run_stage2;
- logme(tmpl.params);
- params = utils.JSON2perl( tmpl.params );
-
- %]
- <script language="javascript">
- var outputs = {};
- var filters = {};
- function send_it (f) {
- var bad_filters = [];
- for (var i in filters) {
- if (!f.elements[i].value) {
- bad_filters.push(filters[i]);
- }
- }
- if (bad_filters.length) {
- var fstring = '';
- for (var i in bad_filters)
- fstring = fstring + "\n\t" + bad_filters[i];
-
- alert('You must choose a value for these filters or settings:\n' + fstring);
- return false;
- }
-
- Widget.Select.selectAll('output_order');
- return true;
- }
- </script>
- <br/>
- [%
-
- WRAPPER html/table width="100%";
- WRAPPER html/row;
- WRAPPER html/cell align='center';
- s1_name_xpath = '/reporter/tables/table[@id="' _ params.stage1 _ '"]/label';
- INCLUDE anchor
- content=config.findvalue( s1_name_xpath )
- href="stage1?id=" _ params.stage1;
- ' :: ' _ params.templatename;
- END;
- END;
- END;
-
- '<br/><br/><div id="output_order_div"';
-
- WRAPPER form id="stage3_new" name="stage3_new" action="stage3" onsubmit="return send_it(this);" method="POST";
- INCLUDE hidden name='stage2' value=CGI.param('id');
-
- '<br/><center><b>Report Name:</b>';
- rname = '';
- IF report;
- rname = report.reportname _ ' (COPY)';
- END;
- INCLUDE text name='reportname' size="50" value=rname;
- '</center><br/><br/>';
- '<script language="javascript">filters["reportname"] = "Report Name";</script>';
-
- WRAPPER html/table id='order_table' width="100%";
- WRAPPER html/row style="border-top: solid black 2px;";
- INCLUDE html/cell colspan=2 content='<b>Output and Sort Order</b>' style="border-top: solid black 2px;";
- INCLUDE html/cell colspan=2 content='<b>Output Formats</b>' align="center" style="border-top: solid black 2px;";
- END;
- WRAPPER html/row;
- WRAPPER html/cell rowspan=3 width="25%";
- WRAPPER select multi=1 size=5 id='output_order' name='output_order';
- FOR column = report.output_order;
- parts = column.split(':');
- xpath = '/reporter/tables/table[@id="' _ parts.1 _ '"]/fields/field[@name="' _ parts.2 _ '"]';
- IF parts.1 != params.stage1;
- xpath = '//*[@id="' _ parts.1 _ '"]/@table';
- name = config.findvalue(xpath);
- xpath = '/reporter/tables/table[@id="' _ name _ '"]/fields/field[@name="' _ parts.2 _ '"]';
- END;
- node = config.findnodes(xpath);
- IF node.findvalue('@primary') == 'true' && parts.1 == params.stage1;
- INCLUDE option value=column content='Per group count -- ' _ node.findvalue('description');
- ELSE;
- INCLUDE option value=column content=node.findvalue('description');
- END;
- END;
- END;
- END;
- WRAPPER html/cell;
- INCLUDE anchor href='javascript:void(0);' content='Up' onclick="Widget.Select.moveSelectedOptionsUp('output_order')";
- END;
-
- WRAPPER html/cell align="right";
- checked = 'checked';
- IF report.output_format.grep('csv') == 0;
- checked = '';
- END;
- INCLUDE checkbox name='output_format' value='csv';
- END;
- INCLUDE html/cell content="CSV" align="left";
- END;
- WRAPPER html/row;
- WRAPPER html/cell;
- INCLUDE anchor href='javascript:void(0);' content='Down' onclick="Widget.Select.moveSelectedOptionsDown('output_order')";
- END;
-
- WRAPPER html/cell align="right";
- checked = 'checked';
- IF report.output_format.grep('excel') == 0;
- checked = '';
- END;
- INCLUDE checkbox name='output_format' value='excel';
- END;
- INCLUDE html/cell content="Excel" align="left";
- END;
- WRAPPER html/row;
- INCLUDE html/cell;
- WRAPPER html/cell align="right" valign='top';
- checked = 'checked';
- IF report.output_format.grep('html') == 0;
- checked = '';
- END;
- INCLUDE checkbox name='output_format' value='html';
- END;
- WRAPPER html/cell align="left";
- 'HTML<br/>';
- WRAPPER html/table;
- WRAPPER html/row + html/cell colspan=2;
- "<i>Graph types</i>";
- END;
- WRAPPER html/row;
- WRAPPER html/cell;
- checked = 'checked';
- IF report.output_format.grep('bar') == 0;
- checked = '';
- END;
- INCLUDE checkbox name='html_graph_type' value='bar';
- END;
- INCLUDE html/cell content='Bar';
- END;
- WRAPPER html/row;
- WRAPPER html/cell;
- checked = 'checked';
- IF report.output_format.grep('pie') == 0;
- checked = '';
- END;
- INCLUDE checkbox name='html_graph_type' value='pie';
- END;
- INCLUDE html/cell content='Pie';
- END;
- WRAPPER html/row;
- WRAPPER html/cell;
- checked = '';
- IF report.output_format.grep('line');
- checked = 'checked';
- END;
- INCLUDE checkbox name='html_graph_type' value='line';
- END;
- INCLUDE html/cell content='Line';
- END;
- END;
- END;
- END;
- END;
-
- checked = 0;
-
- '<br/><br/><b>Pivot Column:</b> ';
- WRAPPER select id='pivot_col' name='pivot_col';
- INCLUDE option value='' content='No Pivot';
- FOR column = report.output_order;
- parts = column.split(':');
- xpath = '/reporter/tables/table[@id="' _ parts.1 _ '"]/fields/field[@name="' _ parts.2 _ '"]/description';
- IF parts.1 != params.stage1;
- xpath = '//*[@id="' _ parts.1 _ '"]/@table';
- name = config.findvalue(xpath);
- xpath = '/reporter/tables/table[@id="' _ name _ '"]/fields/field[@name="' _ parts.2 _ '"]/description';
- END;
- selected = 0;
- IF column == report.pivot_col;
- selected = 1;
- END;
- INCLUDE option value=column content=config.findvalue(xpath);
- END;
- END;
- '<br/><br/></div>';
-
- WRAPPER html/table border=0 width='100%';
- WRAPPER html/row;
- INCLUDE html/cell colspan=4 content="<b>Filterable Attributes</b><br/><br/>" style="border-top: solid black 2px;";
- END;
-
- core_table = params.stage1;
-
- tables = params.filter.keys;
- tables.unshift(core_table) IF tables.grep("^$core_table$");
- tables = tables.unique;
-
- FOR t = tables;
- NEXT UNLESS params.filter.$t.keys;
- f_table = INCLUDE find_table_id id=t;
- table = config.findnodes( "/reporter/tables/table[@id='$f_table']");
-
- table_label = table.findvalue( 'label' );
-
- WRAPPER html/row;
- WRAPPER html/cell colspan=3 align='center' style="border: solid black 1px; background: lightgray;";
- IF t != f_table;
- link_xpath = '//*[@id="' _ t _ '"]';
- dim_link = config.findnodes(link_xpath);
-
- link_label_xpath =
- '../../fields/field[@name="' _
- dim_link.findvalue('@field') _ '"]/label';
-
- table_label = table_label _ ' -- ' _ dim_link.findvalue(link_label_xpath);
- END;
- table_label;
- END;
- END;
-
- FOR f_field = params.filter.$t.keys;
- logme([f_table,f_field]);
- FOR f_fam = params.filter.$t.$f_field.keys;
- logme([f_table,f_field,f_fam]);
- f_widget = params.filter.$t.$f_field.$f_fam;
- logme([f_table,f_field,f_fam,f_widget]);
-
- WRAPPER html/row;
- field = table.findnodes( "fields/field[@name='$f_field']" );
- fam = config.findnodes( "/reporter/widgets/widget-family[@name='$f_fam']" );
- widget = fam.findnodes( "widget[@name='$f_widget']" );
-
- w_file = 'widgets/' _ fam.findvalue('@name') _ '.' _ widget.findvalue('@name');
- INCLUDE html/cell align='left' style="padding-left: 50px;" content=field.findvalue( 'label' );
-
- WRAPPER html/cell align='left';
- TRY;
- classname = table.findvalue('@id');
- fieldname = field.findvalue('@name');
- widgetname = widget.findvalue('@name');
- famname = fam.findvalue('@name');
- table_alias = t;
-
- input_prefix = "filter:$t:$fieldname:$famname:$widgetname";
- current_value = report.filter.$t.$fieldname.$famname.$widgetname;
- logme(current_value);
-
- PROCESS $w_file widget_family=fam;
- PROCESS editor;
- CATCH;
- %]ARG!! Couldn't render widget [% $w_file %] ([% error.info %])!!![%
- END;
- END;
- END;
- END;
- END;
- END;
-
- WRAPPER html/row;
- INCLUDE html/cell colspan=4 content="<br>";
- END;
-
- WRAPPER html/row;
- INCLUDE html/cell colspan=4 content="<b>Attributes Available for Output</b><br/><br/>" style="border-top: solid black 2px;";
- END;
-
- table = config.findnodes( "/reporter/tables/table[@id='$core_table']" );
- classname = table.findvalue( "@id" );
- tname = table.findvalue( "label" );
- tdesc = table.findvalue( "desription" );
-
- WRAPPER html/row;
- INCLUDE html/cell colspan=4 align='center' content=tname style="border: solid black 1px; background: lightgray;";
- END;
-
- pkey_field = table.findnodes('fields/field[@primary = "true"]');
- pid = pkey_field.findvalue('@name');
- plabel = pkey_field.findvalue('label');
-
- WRAPPER html/row;
- WRAPPER html/cell align='left' style="padding-left: 50px;";
- INCLUDE checkbox
- checked=(
- !report || report.output.$classname.$pid == 'include'
- ? 'checked'
- : ''
- )
- name="output:$classname:$pid"
- value="include"
- onclick="field_add_remove(this)";
- INCLUDE hidden name="xform:type:$classname:$pid" value="count_dist";
- %]
- <script language="javascript">
- outputs['[% "output:$classname:$pid" %]'] = '[% "Per group count of $plabel" %]';
- [% IF !report %]
- Widget.Select.addOption(
- 'output_order',
- '[% "output:$classname:$pid" %]',
- '[% "Per group count of $plabel" %]'
- );
- [% END %]
- </script>
- [%
- "Per group count of $plabel<br/><br/>";
- END;
- INCLUDE html/cell align='center';
- END;
-
-
- tables = params.dims.keys;
- tables.unshift(core_table);
- tables = tables.unique;
-
- core_done = 0;
-
- FOR f_table = tables;
- noheader = 0;
- noheader = 1 IF f_table == core_table;
- INCLUDE show_filter_atts;
- WRAPPER html/row;
- INCLUDE html/cell colspan=4 content="<br/><br/>";
- END;
- END;
- END;
-
- %]
- <div id='output_home'/>
- <script>
- document.getElementById('output_home').appendChild(
- document.getElementById('output_order_div')
- );
- </script>
- [%
-
- INCLUDE checkbox name="publicreport" value="t" checked=(report.publicreport == 't' ? 'checked' : '');
- 'Public Report<br>';
- INCLUDE submit name="action" value="Run Now";
- INCLUDE submit name="action" value="Schedule";
-
- END;
-END;
-
-BLOCK show_filter_atts;
- t = f_table;
- f_table = INCLUDE find_table_id id=t;
- table = config.findnodes( "/reporter/tables/table[@id='$f_table']");
- classname = table.findvalue( "@id" );
- tname = table.findvalue( "label" );
- tdesc = table.findvalue( "desription" );
-
- IF ! noheader;
- WRAPPER html/row;
- WRAPPER html/cell colspan=4 align='center' style="border: solid black 1px; background: lightgray;";
- IF t != f_table;
- link_xpath = '//*[@id="' _ t _ '"]';
- dim_link = config.findnodes(link_xpath);
-
- link_label_xpath =
- '../../fields/field[@name="' _
- dim_link.findvalue('@field') _ '"]/label';
- dim_link.findvalue(link_label_xpath);
-
- ' -- ';
- END;
- tname;
- END;
- END;
- END;
-
- fields_xpath = 'fields/field[(not(@primary) or @primary != "true") or @hidden="false"]';
-
-
- count = 1;
-
- FOR field = table.findnodes(fields_xpath);
- link_test = '../../links/link[@field="' _ field.findvalue('@name') _ '" and (not(@hidden) or @hidden!="false")]';
- link_test = 'links/link[@field="' _ field.findvalue('@name') _ '" and (not(@hidden) or @hidden!="false")]';
- logme(['show_filter_atts -> link_test', t, link_test]);
- NEXT IF table.findnodes( link_test );
-
- fname = field.findvalue( "label" );
- fid = field.findvalue( "@name" );
-
- bg_color = 'white';
- IF count % 2;
- bg_color = 'lightcyan';
- END;
-
- WRAPPER html/row;
-
- WRAPPER html/cell align='left' col=bg_color style="padding-left: 50px;";
- INCLUDE checkbox
- name="output:$t:$fid"
- value="include"
- onclick="field_add_remove(this)"
- checked=(report.output.$t.$fid == 'include' ? 'checked' : '');
- %]
- <script language="javascript">
- outputs['[% "output:$t:$fid" %]'] = '[% fname %]';
- </script>
- [%
-
- fname;
- END;
- INCLUDE html/cell align='right' content='Output Transformation:' col=bg_color;
- WRAPPER html/cell align='left' col=bg_color style="padding-left: 50px;";
-
- dtype = field.findvalue('@transform-group');
- IF !dtype;
- dtype = field.findvalue('@datatype');
- END;
-
- WRAPPER select id="xform:type:$t:$fid" name="xform:type:$t:$fid" onchange="show_hide_params(this)";
- INCLUDE option value='' content='None' selected=(report.xform.type.$t.$fid == '' ? 1 : 0);
- FOR xform = dtype_xform_map.$dtype;
- xform_label = dtype_xforms.$xform.label;
- IF dtype_xforms.$xform.param;
- xform_label = "$xform_label (*)";
- END;
- INCLUDE option value=xform content=xform_label selected=(report.xform.type.$t.$fid == xform ? 1 : 0);
- END;
- END;
-
- %]
-
- <br/>
- <span id="hide-param:xform:type:[% t %]:[% fid %]" [% 'style="visibility: hidden;"' IF !report.xform.param.$t.$fid %] >
- <small><super>*</super>Output Tranformation Parameter: </small>
- [% INCLUDE text name="xform:param:$t:$fid" value=report.xform.param.$t.$fid %]
- </span>
-
- [%
- END;
- END;
- count = count + 1;
- END;
-END;
-%]
+++ /dev/null
-[%
-
-USE date;
-USE start = DateTime(now = 1);
-USE two_digits = format('%02d');
-
-PROCESS inputs;
-PROCESS class_manip;
-PROCESS widget_manip;
-PROCESS logic_header.ttk;
-INCLUDE logout.ttk;
-
-templates = DBI.tie('reporter.stage2', 'id')
-reports = DBI.tie('reporter.stage3', 'id')
-output = DBI.tie('reporter.output', 'id')
-rpt = {};
-tmpl = {};
-
-
-IF CGI.param('output');
- oid = CGI.param('output');
- out = output.$oid;
-
- rid = out.stage3;
- rpt = reports.$rid;
-
- tid = rpt.stage2;
- tmpl = templates.$tid;
-END;
-
-IF CGI.param('id');
- rid = CGI.param('id');
- rpt = reports.$rid;
- tid = rpt.stage2;
- tmpl = templates.$tid;
-END;
-
-
-WRAPPER html/html;
- INCLUDE header.ttk + navbar.ttk title="Reports";
- WRAPPER html/body;
- IF CGI.param('action') == 'Schedule';
- PROCESS schedule_stage3;
- ELSIF CGI.param('action') == 'enable_stage3';
- PROCESS enable;
- ELSIF CGI.param('action') == 'disable_stage3';
- PROCESS disable;
- ELSIF CGI.param('action') == 'Reschedule';
- PROCESS resched;
- ELSIF CGI.param('action') == 'Save';
- PROCESS save_stage3;
- ELSIF CGI.param('action') == 'delete_stage3';
- PROCESS delete_stage3;
- ELSIF CGI.param('action') == 'delete_output';
- PROCESS delete_output;
- ELSIF CGI.param('action') == 'rerun';
- PROCESS rerun;
- ELSIF CGI.param('action') == 'Run Now';
- PROCESS save_stage3;
- ELSIF CGI.param('id');
- PROCESS view_stage3;
- ELSE;
- PROCESS list_stage3s;
- END;
- END;
- INCLUDE footer.ttk;
-END;
-
-
-BLOCK schedule_stage3;
- WRAPPER form method='POST';
- 'Run Date:';
- INCLUDE text name='runtime' value= start.year _ '-' _ two_digits(start.month) _ '-' _ two_digits(start.day);
- '<br>';
-
- 'Optional Recurrence:';
- INCLUDE text name='recurrence-count' value='0';
- WRAPPER select name='recurrence-interval';
- INCLUDE option value='days' content='Day(s)';
- INCLUDE option value='weeks' content='Week(s)';
- INCLUDE option value='months' content='Month(s)';
- END;
-
- FOR p = CGI.param();
- NEXT IF p == 'action';
- NEXT IF p == 'runtime';
- FOR pval = CGI.param(p);
- INCLUDE hidden name=p value=pval;
- END;
- END;
- '<br>';
- INCLUDE submit name='action' value='Save';
- END;
-END;
-
-BLOCK list_stage3s;
-END;
-
-
-BLOCK save_stage3;
- stage2 = CGI.param('stage2');
- runtime = CGI.param('runtime') OR 'now';
- pub = CGI.param('publicreport') OR 'f';
- owner = user.id();
-
- p_obj = {};
- FOR p = CGI.param();
-
- logme([p,CGI.param(p)]);
-
- parts = p.split(':');
- p1 = parts.0;
- p2 = parts.1;
- p3 = parts.2;
- p4 = parts.3;
- p5 = parts.4;
- p6 = parts.5;
-
- IF p6;
-
- IF p_obj.$p1.$p2.$p3.$p4.$p5.$p6.defined;
- IF p_obj.$p1.$p2.$p3.$p4.$p5.$p6.size > 1;
- p_obj.$p1.$p2.$p3.$p4.$p5.$p6.push(CGI.param(p));
- ELSE;
- tmp = [ p_obj.$p1.$p2.$p3.$p4.$p5.$p6, CGI.param(p) ];
- p_obj.$p1.$p2.$p3.$p4.$p5.$p6 = tmp;
- END;
- ELSE;
- p_obj.$p1.$p2.$p3.$p4.$p5.$p6 = CGI.param(p);
- END;
-
- ELSIF p5;
-
- IF p_obj.$p1.$p2.$p3.$p4.$p5.defined;
- IF p_obj.$p1.$p2.$p3.$p4.$p5.size > 1;
- p_obj.$p1.$p2.$p3.$p4.$p5.push(CGI.param(p));
- ELSE;
- tmp = [ p_obj.$p1.$p2.$p3.$p4.$p5, CGI.param(p) ];
- p_obj.$p1.$p2.$p3.$p4.$p5 = tmp;
- END;
- ELSE;
- p_obj.$p1.$p2.$p3.$p4.$p5 = CGI.param(p);
- END;
-
- ELSIF p4;
-
- IF p_obj.$p1.$p2.$p3.$p4.defined;
- IF p_obj.$p1.$p2.$p3.$p4.size > 1;
- p_obj.$p1.$p2.$p3.$p4.push(CGI.param(p));
- ELSE;
- tmp = [ p_obj.$p1.$p2.$p3.$p4, CGI.param(p) ];
- p_obj.$p1.$p2.$p3.$p4 = tmp;
- END;
- ELSE;
- p_obj.$p1.$p2.$p3.$p4 = CGI.param(p);
- END;
-
- ELSIF p3;
-
- IF p_obj.$p1.$p2.$p3.defined;
- IF p_obj.$p1.$p2.$p3.size > 1;
- p_obj.$p1.$p2.$p3.push(CGI.param(p));
- ELSE;
- tmp = [ p_obj.$p1.$p2.$p3, CGI.param(p) ];
- p_obj.$p1.$p2.$p3 = tmp;
- END;
- ELSE;
- p_obj.$p1.$p2.$p3 = CGI.param(p);
- END;
-
- ELSIF p2;
-
- IF p_obj.$p1.$p2.defined;
- IF p_obj.$p1.$p2.size > 1;
- p_obj.$p1.$p2.push(CGI.param(p));
- ELSE;
- tmp = [ p_obj.$p1.$p2, CGI.param(p) ];
- p_obj.$p1.$p2 = tmp;
- END;
- ELSE;
- p_obj.$p1.$p2 = CGI.param(p);
- END;
-
- ELSE;
-
- p_obj.$p = CGI.param(p);
-
- END;
- END;
-
- params = utils.perl2JSON( p_obj );
-
- recurrence = '0 sec';
- IF CGI.param('recurrence-count') > 0;
- recurrence = CGI.param('recurrence-count') _ ' ' _ CGI.param('recurrence-interval');
- END;
-
- logme([stage2, params, owner, pub]);
-
- q = DBI.prepare( stage3_insert );
- CALL q.execute(stage2, params, owner, pub, runtime, recurrence);
-
- FOR new_s3 = DBI.query("SELECT * FROM reporter.stage3_id_seq;");
- rid = new_s3.last_value;
- rpt = reports.$rid;
- tid = rpt.stage2;
- tmpl = templates.$tid;
- INCLUDE view_stage3;
- END;
-END;
-
-BLOCK delete_stage3;
- q = DBI.prepare( 'DELETE FROM reporter.stage3 WHERE id = ?' );
- CALL q.execute(rpt.id);
-END;
-
-BLOCK delete_output;
- q = DBI.prepare( 'DELETE FROM reporter.output WHERE id = ?' );
- CALL q.execute(out.id);
- INCLUDE view_stage3;
-END;
-
-BLOCK enable;
- q = DBI.prepare( 'UPDATE reporter.stage3 SET disable = FALSE WHERE id = ?' );
- CALL q.execute(CGI.param('id'));
- INCLUDE view_stage3;
-END;
-
-BLOCK disable;
- q = DBI.prepare( 'UPDATE reporter.stage3 SET disable = TRUE WHERE id = ?' );
- CALL q.execute(CGI.param('id'));
- INCLUDE view_stage3;
-END;
-
-BLOCK resched;
- q = DBI.prepare( 'UPDATE reporter.stage3 SET runtime = ? WHERE id = ?' );
- CALL q.execute(CGI.param('newtime'), CGI.param('id'));
- INCLUDE view_stage3;
-END;
-
-BLOCK rerun;
- q = DBI.prepare( 'UPDATE reporter.stage3 SET rerun = TRUE WHERE id = ?' );
- CALL q.execute(rpt.id);
- INCLUDE view_stage3;
-END;
-
-BLOCK view_stage3;
- logme(rpt.params);
- params = utils.JSON2perl( rpt.params );
- s2_params = utils.JSON2perl( tmpl.params );
-
-
- WRAPPER html/center;
- WRAPPER html/table style="border-collapse:collapse";
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Report Name</b>" style="border:solid gray 1px;";
- INCLUDE html/cell content=params.reportname style="border:solid gray 1px;";
- END;
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Based on Template</b>" style="border:solid gray 1px;";
- INCLUDE html/cell content=s2_params.templatename style="border:solid gray 1px;";
- END;
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Creation Time</b>" style="border:solid gray 1px;";
- INCLUDE html/cell content=rpt.create_date.chunk(19).0 style="border:solid gray 1px;";
- END;
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Scheduled Run Time</b>" style="border:solid gray 1px;";
- IF user.id == rpt.owner;
- WRAPPER html/cell style="border:solid gray 1px;";
- WRAPPER form method="post";
- INCLUDE hidden name="id" value=rpt.id;
- INCLUDE text name="newtime" value=rpt.runtime.chunk(19).0;
- INCLUDE submit name="action" value="Reschedule";
- END;
- END;
- ELSE;
- INCLUDE html/cell content=rpt.runtime style="border:solid gray 1px;";
- END;
- END;
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Recurrence Interval</b>" style="border:solid gray 1px;";
- INCLUDE html/cell content=rpt.recurrence style="border:solid gray 1px;";
- END;
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Selection Criteria</b>" style="border:solid gray 1px; vertical-align: top;";
- WRAPPER html/cell style="border:solid gray 1px;";
- WRAPPER html/table width="100%" style="border-collapse:collapse;";
- FOR t = params.filter.keys;
- FOR c = params.filter.$t.keys;
- FOR wf = params.filter.$t.$c.keys;
- FOR w = params.filter.$t.$c.$wf.keys;
- WRAPPER html/row;
- xpath = '/reporter/tables/table[@id="' _ t _ '" and @fact-table="true"]';
- table = config.findnodes(xpath);
- IF !table;
- xpath = '/reporter/tables/table[@id=//link[@id="' _ t _ '"]/@table]';
- table = config.findnodes(xpath);
- END;
-
- INCLUDE html/cell
- content = table.findvalue('label')
- style="border:solid gray 1px; top; font-weight:bold;";
-
- xpath = 'fields/field[@name="' _ c _ '"]/label';
- INCLUDE html/cell
- content = table.findvalue(xpath)
- style="border:solid gray 1px; font-weight:bold;";
-
- WRAPPER html/cell
- style="border:solid gray 1px; vertical-align: top;";
- w_file = 'widgets/' _ wf _ '.' _ w;
- current_value = params.filter.$t.$c.$wf.$w;
- PROCESS $w_file;
- PROCESS display;
- END;
- END;
- END;
- END;
- END;
- END;
- END;
- END;
- END;
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Output Attributes</b>" style="border:solid gray 1px; vertical-align: top;";
- WRAPPER html/cell style="border:solid gray 1px;";
- FOR t = params.output.keys;
- FOR c = params.output.$t.keys;
- xpath = '/reporter/tables/table[@id="' _ t _ '" and @fact-table="true"]';
- table = config.findnodes(xpath);
- IF !table;
- xpath = '/reporter/tables/table[@id=//link[@id="' _ t _ '"]/@table]';
- table = config.findnodes(xpath);
- END;
-
- xpath = 'fields/field[@name="' _ c _ '"]/label';
- table.findvalue('label') _ ' -- ' _ table.findvalue(xpath) _ '<br/>';
-
- END;
- END;
- END;
- END;
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Actions</b>" style="border:solid gray 1px;";
- WRAPPER html/cell style="border:solid gray 1px;";
- INCLUDE anchor content='Refresh' href=CGI.url('-path', 1) _ '?id=' _ rpt.id;
- ' ';
- INCLUDE anchor content='Clone and Edit' href='stage2?action=edit&id=' _ rpt.stage2 _ '&report=' _ rpt.id;
- ' ';
- IF user.id == rpt.owner;
- INCLUDE anchor content='Run again' href=CGI.url('-path', 1) _ '?action=rerun&id=' _ rpt.id;
- ' ';
- IF rpt.disable;
- INCLUDE anchor content='Enable' href=CGI.url('-path', 1) _ '?action=enable_stage3&id=' _ rpt.id;
- ELSE;
- INCLUDE anchor content='Disable' href=CGI.url('-path', 1) _ '?action=disable_stage3&id=' _ rpt.id;
- END;
- ' ';
- INCLUDE anchor content='Delete' href=CGI.url('-path', 1) _ '?action=delete_stage3&id=' _ rpt.id;
- ' ';
- END;
- END;
- END;
- END;
- END;
-
- '<br><br>';
-
- type_map = { 'csv' => 'csv', 'excel' => 'xls', 'html' => 'html' };
-
- WRAPPER html/center;
- '<b>Report Runs:</b>';
- run_q = DBI.prepare("SELECT * FROM reporter.output WHERE stage3 = ? ORDER BY queue_time DESC");
- FOR run = run_q.execute(rpt.id);
- "<a name='$run.id'>";
- WRAPPER html/table style="border-collapse:collapse";
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Current State</b>" style="border:solid gray 1px;" width="20%";
- WRAPPER html/cell style="border:solid gray 1px;";
- run.state;
- IF run.state == 'complete';
- '<br>';
- FOR f = params.output_format.list;
- h = tmpl.stage1 _ '/' _ tmpl.id _
- '/' _ rpt.id _ '/' _ run.id _
- '/report-data.' _ type_map.$f;
- link(content=f, href=h);
- IF !loop.last;
- ' | ';
- END;
- END;
- END;
- END;
- END;
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Queue Time</b>" style="border:solid gray 1px;";
- INCLUDE html/cell content=run.queue_time style="border:solid gray 1px;";
- END;
- IF run.run_time;
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Run Time</b>" style="border:solid gray 1px;";
- INCLUDE html/cell content=run.run_time style="border:solid gray 1px;";
- END;
- END;
- IF run.complete_time;
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Complete Time</b>" style="border:solid gray 1px;";
- INCLUDE html/cell content=run.complete_time style="border:solid gray 1px;";
- END;
- END;
- IF run.query;
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Query</b>" style="border:solid gray 1px;";
- INCLUDE html/cell content=run.query style="border:solid gray 1px;";
- END;
- END;
- IF run.error;
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Error</b>" style="border:solid gray 1px;";
- INCLUDE html/cell content=run.error style="border:solid gray 1px;";
- END;
- END;
- IF run.error_time;
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Error Time</b>" style="border:solid gray 1px;";
- INCLUDE html/cell content=run.error_time style="border:solid gray 1px;";
- END;
- END;
- IF run.complete_time || run.error_time;
- WRAPPER html/row;
- INCLUDE html/cell content="<b>Actions</b>" style="border:solid gray 1px;";
- WRAPPER html/cell style="border:solid gray 1px;";
- IF user.id == rpt.owner;
- INCLUDE anchor content='Delete' href=CGI.url('-path', 1) _ '?action=delete_output&output=' _ run.id;
- ' ';
- END;
- END;
- END;
- END;
- END;
- '</a><br><br>';
- END;
- END;
-END;
-
-%]
+++ /dev/null
-[%
-
-BLOCK find_table_id;
- xpath = '//*[@id="' _ id _ '"]';
- node = config.findnodes(xpath);
- IF node;
- t = node.findvalue('@table');
- IF t;
- xpath = '//*[@id="' _ t _ '"]';
- node = config.findnodes(xpath);
- END;
- node.findvalue('@id');
- ELSE;
- logme(['arrrrrgggg!!!',id]);
- END;
-END;
-
-%]
+++ /dev/null
-[%
-
-PROCESS inputs;
-PROCESS utils;
-
-BLOCK widget_selector;
-
- logme("widget_selector called for table $tableid");
-
- linkid = tableid;
- tableid = INCLUDE find_table_id id=tableid;
-
- choose_base_cols = 0;
-
- # if we got some columns, use them. if not, get all non-primary columns
- IF ! columns;
- columns = [];
- choose_base_cols = 1;
- columns_xpath =
- '/reporter/tables/table[@id="' _ tableid _
- '"]/fields/field[(not(@primary) or @primary!="true") or @filterable="true"]';
- FOR c = config.findnodes(columns_xpath);
- link_text_xpath = '../../links/link[@field="' _ c.findvalue('@name') _ '" and (not(@hidden) or @hidden!="false")]';
- NEXT IF c.findnodes(link_text_xpath);
- columns.push(c);
- END;
- logme("widget_selector had to grab columns for table $tableid linked from $linkid");
- END;
-
- column_input_type="checkbox";
- IF force && ! choose_base_cols;
- column_input_type="hidden";
- END;
-
- FOR column = columns;
- column_name=column.findvalue('@name');
-
- WRAPPER html/row;
- WRAPPER html/cell valign='top' align='right';
- # checkbox for column filter here ...
- INCLUDE $column_input_type
- name="filter:$linkid"
- value=column_name
- checked=0;
- column.findvalue('label');
- END;
- WRAPPER html/cell;
-
- col_widget_fams_xpath =
- '/reporter/widgets/widget-family[@datatype="' _
- column.findvalue('@datatype') _ '"]';
-
- IF column.findnodes('@widget-family');
- col_widget_fams_xpath =
- '/reporter/widgets/widget-family[@name="' _
- column.findvalue('@widget-family') _ '"]';
- END;
-
- logme("finding widget families using $col_widget_fams_xpath");
-
- widget_fams = config.findnodes(col_widget_fams_xpath);
-
- '<UL>';
- FOR fam = widget_fams;
-
- fam_input = 'radio';
- IF loop.size == 1;
- fam_input = 'hidden';
- END;
-
- checked = 0;
- IF loop.count == 1;
- checked = 1;
- END;
-
- fam_name = fam.findvalue('@name');
- # radio for widget family here ...
- '<LI>';
- INCLUDE $fam_input
- name="filter:$linkid:$column_name"
- value= fam_name;
- fam.findvalue('label');
- '<UL>';
-
- FOR widget = fam.findnodes('widget');
-
- fam_input = 'radio';
- IF loop.size == 1;
- fam_input = 'hidden';
- END;
-
- checked = 0;
- IF loop.count == 1;
- checked = 1;
- END;
-
- widget_name = widget.findvalue('@name');
- # radio for widget here ...
- '<LI>';
- INCLUDE $fam_input
- name="filter:$linkid:$column_name:$fam_name"
- value= widget_name;
- widget.findvalue('label');
- '</LI>';
- END;
- '</UL>';
- '</LI>';
- END;
- '</UL>';
- END;
- END;
- END;
-END;
-
-%]
-
+++ /dev/null
-[%
-
-PROCESS inputs;
-
-BLOCK editor;
-WRAPPER select name=input_prefix _ ":target";
- count = 1;
- def = 1;
- IF current_value.target;
- def = current_value.target;
- END;
- WHILE count < 37;
- INCLUDE option value=count selected=(count == def ? 1 : 0);
- count = count + 1;
- END;
-END;
-
-' months before runtime<br/>Compared to ';
-
-WRAPPER select name=input_prefix _ ":compare";
- count = 1;
- def = 12;
- IF current_value.compare;
- def = current_value.compare;
- END;
- WHILE count < 37;
- INCLUDE option value=count selected=(count == def ? 1 : 0);
- count = count + 1;
- END;
-END;
-' months before target';
-END;
-
-BLOCK display;
-current_value.compare _' months before runtime compared to ' _ current_value.compare _ ' months before target';
-END;
-
-%]
+++ /dev/null
-[%
-
-PROCESS inputs;
-
-BLOCK editor;
-root = 'SELECT * FROM ' _ table.findvalue('tablename') _ ' WHERE parent_ou IS NULL ORDER BY name;';
-q = 'SELECT * FROM ' _ table.findvalue('tablename') _ ' WHERE parent_ou = ? ORDER BY name;';
-
-org_unit_type = DBI.tie('actor.org_unit_type', 'id')
-
-%]
-
-<script language="javascript">
- filters["[% input_prefix %]"] = "[% table_label _ ' -- ' _ field.findvalue('label') %]";
-
- var hier_[% table_alias %] = [];
-
- function change_hier_[% table_alias %] ( sel ) {
- for (var i in hier_[% table_alias %]) {
- if (hier_[% table_alias %][i] == sel.options[sel.selectedIndex].id) {
- return true;
- }
- }
- sel.selectedIndex = null;
- return false;
- }
-</script>
-
-[%
-
-WRAPPER select id=input_prefix name=input_prefix onchange='change_hier_' _ table_alias _ '(this);';
- depth = 0;
- INCLUDE option value='' content='Select One';
- INCLUDE option value='' content='----------';
- FOR f = DBI.query(root);
- INCLUDE option value=f.id content=f.name;
- INCLUDE next_level parent_ou = f.id depth;
- END;
-END;
-END;
-
-
-BLOCK next_level;
- depth = depth + 1;
- x = depth;
- s = DBI.prepare(q);
- FOR f = s.execute(parent_ou);
- ou_t = f.ou_type;
-
- logme(["can_have_vols for ou_t", ,org_unit_type.$ou_t.can_have_vols]);
-
- IF org_unit_type.$ou_t.can_have_vols == 1;
- %]
- <script language="javascript">
- hier_[% table_alias %].push("dr_[% f.id %]");
- </script>
- [%
- END;
-
- x = depth;
- val = '';
- WHILE x > 0;
- val = val _ ' ';
- x = x - 1;
- END;
-
- selected = '';
- IF current_value == f.id;
- selected = 'selected';
- END;
-
- INCLUDE option value=f.id content=f.name content=val _ f.name id='dr_' _ f.id;
- INCLUDE next_level parent_ou = f.id;
- END;
-END;
-
-BLOCK display;
-org_units = DBI.tie('actor.org_unit', 'id')
-ou = org_units.$current_value;
-ou.name;
-END;
-%]
+++ /dev/null
-[%
-
-PROCESS inputs;
-
-BLOCK editor;
-root = 'SELECT * FROM ' _ table.findvalue('tablename') _ ' WHERE parent_ou IS NULL ORDER BY name;';
-q = 'SELECT * FROM ' _ table.findvalue('tablename') _ ' WHERE parent_ou = ? ORDER BY name;';
-
-org_unit_type = DBI.tie('actor.org_unit_type', 'id')
-
-%]
-
-<script language="javascript">
- filters["[% input_prefix %]"] = "[% table_label _ ' -- ' _ field.findvalue('label') %]";
-
- var multihier_[% table_alias %] = [];
-
- function change_multihier_[% table_alias %] ( sel ) {
- for (var i = 0; i < sel.options.length; i++) {
- if (sel.options[i].selected) {
- sel.options[i].selected = false;
- for (var j in multihier_[% table_alias %]) {
- if (multihier_[% table_alias %][j] == sel.options[i].id) {
- sel.options[i].selected = true
- continue;
- }
- }
- }
- }
- }
-</script>
-
-[%
-
-WRAPPER select name=input_prefix multi="multi" onchange='change_multihier_' _ table_alias _ '(this);';
- depth = 0;
- FOR f = DBI.query(root);
- sel = 0;
- FOR v = current_value;
- sel = 1 IF v == f.id;
- LAST;
- END;
- INCLUDE option value=f.id content=f.name selected=sel;
- INCLUDE next_level parent_ou = f.id;
- END;
-END;
-END;
-
-BLOCK next_level;
- depth = depth + 1;
- x = depth;
- s = DBI.prepare(q);
- FOR f = s.execute(parent_ou);
- ou_t = f.ou_type;
-
- logme(["can_have_vols for ou_t", ,org_unit_type.$ou_t.can_have_vols]);
-
- IF org_unit_type.$ou_t.can_have_vols == 1;
- %]
- <script language="javascript">
- multihier_[% table_alias %].push("mh_[% f.id %]");
- </script>
- [%
- END;
-
- x = depth;
- val = '';
- WHILE x > 0;
- val = val _ ' ';
- x = x - 1;
- END;
-
- selected = '';
- FOR v = current_value;
- IF v == f.id;
- selected = 'selected';
- LAST;
- END;
- END;
- INCLUDE option value=f.id content=val _ f.name id='mh_' _ f.id;
- INCLUDE next_level parent_ou = f.id;
- END;
-END;
-
-BLOCK display;
- org_units = DBI.tie('actor.org_unit', 'id');
- list = [];
- FOR o = current_value;
- list.push(org_units.$o.name);
- END;
- list.join('<br/>');
-END;
-%]
+++ /dev/null
-[%
-
-PROCESS inputs;
-
-BLOCK editor;
-WRAPPER select name=input_prefix;
- count = 1;
- def = 1;
- IF current_value;
- def = current_value;
- END;
- WHILE count < 366;
- INCLUDE option value=count selected=(count == def ? 1 : 0);
- count = count + 1;
- END;
-END;
-' days before runtime';
-END;
-
-BLOCK display;
-current_value _ ' days before runtime';
-END
-%]
+++ /dev/null
-[%
-
-PROCESS inputs;
-
-BLOCK editor;
-
-WRAPPER select name=input_prefix;
- count = 1;
- IF current_value;
- def = current_value;
- END;
- WHILE count < 37;
- INCLUDE option value=count selected=(count == def ? 1 : 0);
- count = count + 1;
- END;
-END;
-' months before runtime';
-END;
-
-BLOCK display;
-current_value _ ' months before runtime';
-END;
-
-%]
+++ /dev/null
-[%
-
-PROCESS inputs;
-
-BLOCK editor;
-WRAPPER select name=input_prefix;
- count = 1;
- WHILE count < 37;
- INCLUDE option value=count;
- count = count + 1;
- END;
-END;
-' (calendar) quarters before runtime';
-END;
-
-BLOCK display;
-current_value _ ' (calendar) quarters before runtime';
-END;
-%]
+++ /dev/null
-[%
-
-PROCESS inputs;
-
-BLOCK editor;
-WRAPPER select name=input_prefix;
- count = 1;
- IF current_value;
- def = current_value;
- END;
- WHILE count < 53;
- INCLUDE option value=count selected=(count == def ? 1 : 0);
- count = count + 1;
- END;
-END;
-' weeks before runtime';
-END;
-
-BLOCK display;
-current_value _ ' weeks before runtime';
-END;
-%]
+++ /dev/null
-[%
-
-PROCESS inputs;
-
-BLOCK editor;
-WRAPPER select name=input_prefix;
- count = 1;
- IF current_value;
- def = current_value;
- END;
- WHILE count < 37;
- INCLUDE option value=count selected=(count == def ? 1 : 0);
- count = count + 1;
- END;
-END;
-' years before runtime';
-END;
-
-BLOCK display;
-current_value _ ' years before runtime';
-END;
-%]
+++ /dev/null
-[%
-
-USE date;
-USE start = DateTime(now = 1);
-USE end = DateTime(now = 1);
-
-PROCESS inputs;
-
-BLOCK editor;
-WRAPPER html/table ;
- WRAPPER html/row;
- INCLUDE html/cell colspan=6 align='center' content='Start time';
- END;
-
- WRAPPER html/row;
- INCLUDE html/cell content='Year';
- INCLUDE html/cell content='Month';
- INCLUDE html/cell content='Day';
- INCLUDE html/cell content='Hour';
- INCLUDE html/cell content='Minute';
- INCLUDE html/cell content='Second';
- END;
-
- WRAPPER html/row;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':start-year' size=4 value=start.year;
- END;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':start-month' size=4 value=start.month;
- END;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':start-day' size=4 value=start.day;
- END;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':start-hour' size=4 value=start.hour;
- END;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':start-minute' size=4 value=start.minute;
- END;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':start-second' size=4 value=start.second;
- END;
- END;
-
- WRAPPER html/row;
- INCLUDE html/cell colspan=6 align='center' content='End time';
- END;
-
- WRAPPER html/row;
- INCLUDE html/cell content='Year';
- INCLUDE html/cell content='Month';
- INCLUDE html/cell content='Day';
- INCLUDE html/cell content='Hour';
- INCLUDE html/cell content='Minute';
- INCLUDE html/cell content='Second';
- END;
-
- WRAPPER html/row;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':end-year' size=4 value=end.year;
- END;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':end-month' size=4 value=end.month;
- END;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':end-day' size=4 value=end.day;
- END;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':end-hour' size=4 value=end.hour;
- END;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':end-minute' size=4 value=end.minute;
- END;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':end-second' size=4 value=end.second;
- END;
- END;
-END;
-
-END;
-
-BLOCK display;
-END;
-
-%]
+++ /dev/null
-[%
-
-USE date;
-USE start = DateTime(now = 1);
-
-PROCESS inputs;
-
-BLOCK editor;
-WRAPPER html/table ;
- WRAPPER html/row;
- INCLUDE html/cell content='Year';
- INCLUDE html/cell content='Month';
- INCLUDE html/cell content='Day';
- END;
-
- y = (current_value.year ? current_value.year : start.year);
- m = (current_value.month ? current_value.month : start.month);
- d = (current_value.day ? current_value.day : start.day);
-
- WRAPPER html/row;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':year' size=4 value=y;
- END;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':month' size=4 value=m;
- END;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':day' size=4 value=d;
- END;
- END;
-
-END;
-END;
-
-BLOCK display;
-current_value.year _ '-' _ current_value.month _ '-' _ current_value.day;
-END;
-
-%]
+++ /dev/null
-[%
-
-USE date;
-USE start = DateTime(now = 1);
-USE end = DateTime(now = 1);
-
-PROCESS inputs;
-
-BLOCK editor;
-
-WRAPPER html/table ;
-
- WRAPPER html/row;
- INCLUDE html/cell content='Year';
- INCLUDE html/cell content='Month';
- END;
-
- WRAPPER html/row;
- WRAPPER html/cell;
- v = start.year;
- f = 'start-year';
- IF current_value.$f;
- v = current_value.$f;
- END;
- INCLUDE text name=input_prefix _ ':start-year' size=4 value=v;
- END;
- WRAPPER html/cell;
- v = start.month;
- f = 'start-month';
- IF current_value.$f;
- v = current_value.$f;
- END;
- INCLUDE text name=input_prefix _ ':start-month' size=4 value=v;
- END;
- END;
-
-END;
-END;
-
-BLOCK display;
-f = 'start-year';
-current_value.$f _ '-';
-f = 'start-month';
-current_value.$f;
-END;
-%]
+++ /dev/null
-[%
-
-USE date;
-USE start = DateTime(now = 1);
-USE end = DateTime(now = 1);
-
-PROCESS inputs;
-
-BLOCK editor;
-
-WRAPPER html/table ;
- WRAPPER html/row;
- INCLUDE html/cell colspan=2 align='center' content='Start time';
- END;
-
- WRAPPER html/row;
- INCLUDE html/cell content='Year';
- INCLUDE html/cell content='Month';
- END;
-
- syl = 'start-year';
- sml = 'start-month';
- eyl = 'end-year';
- eml = 'end-month';
-
- sy = (current_value.$syl ? current_value.$syl : start.year);
- sm = (current_value.$sml ? current_value.$sml : start.month);
- ey = (current_value.$eyl ? current_value.$eyl : end.year);
- em = (current_value.$eml ? current_value.$eml : end.month);
-
- WRAPPER html/row;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':start-year' size=4 value=sy;
- END;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':start-month' size=4 value=sm;
- END;
- END;
-
- WRAPPER html/row;
- INCLUDE html/cell colspan=2 align='center' content='End time';
- END;
-
- WRAPPER html/row;
- INCLUDE html/cell content='Year';
- INCLUDE html/cell content='Month';
- END;
-
- WRAPPER html/row;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':end-year' size=4 value=ey;
- END;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':end-month' size=4 value=em;
- END;
- END;
-END;
-END;
-
-BLOCK display;
- syl = 'start-year';
- sml = 'start-month';
- eyl = 'end-year';
- eml = 'end-month';
-
- sy = (current_value.$syl ? current_value.$syl : start.year);
- sm = (current_value.$sml ? current_value.$sml : start.month);
- ey = (current_value.$eyl ? current_value.$eyl : end.year);
- em = (current_value.$eml ? current_value.$eml : end.month);
-
- sy _ '-' _ sm _ ' through ' _ ey _ '-' _ em;
-
-END;
-
-%]
+++ /dev/null
-[%
-
-USE date;
-USE start = DateTime(now = 1);
-
-PROCESS inputs;
-
-BLOCK editor;
-
-WRAPPER html/table ;
-
- WRAPPER html/row;
- INCLUDE html/cell content='Year';
- INCLUDE html/cell content='Quarter';
- END;
-
- WRAPPER html/row;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':year' size=4 value=start.year;
- END;
- WRAPPER html/cell;
- WRAPPER select name=input_prefix _ ':quarter';
- FOR i IN [1,2,3,4];
- INCLUDE option value=i;
- END;
- END;
- END;
- WRAPPER html/cell;
- 'For ';
- INCLUDE text name=input_prefix _ ':quarter-count' value=2;
- ' quarters';
- END;
- END;
-
-END;
-
-END;
-
-BLOCK display;
-'Year: ' _ current_value.year _ ', Quarter: ' _ current_value.quarter;
-END;
-
-%]
+++ /dev/null
-[%
-
-USE date;
-USE start = DateTime(now = 1);
-
-PROCESS inputs;
-
-BLOCK editor;
-
-WRAPPER html/table;
-
- WRAPPER html/row;
- WRAPPER html/cell;
- 'Year: ';
- INCLUDE name=input_prefix _ ':year' text size=4 value=(current_value.year ? current_value.year : start.year);
- END;
- END;
-
- WRAPPER html/row;
- WRAPPER html/cell;
- 'Start week of year: ';
- WRAPPER select name=input_prefix _ ':start';
- count = 1;
- WHILE count < 53;
- selected = 0;
- IF count == current_value.start;
- selected = 1;
- END;
- INCLUDE option value=count;
- count = count + 1;
- END;
- END;
- END;
- END;
-
- WRAPPER html/row;
- WRAPPER html/cell;
- 'End week of year: ';
- WRAPPER select name=input_prefix _ ':end';
- count = 1;
- WHILE count < 53;
- selected = 0;
- IF count == current_value.end;
- selected = 1;
- END;
- INCLUDE option value=count;
- count = count + 1;
- END;
- END;
- END;
- END;
-END;
-END;
-
-BLOCK display;
-current_value.year _ ', weeks ' _ current_value.start _ ' through ' _ current_value.end;
-END;
-
-%]
+++ /dev/null
-[%
-
-USE date;
-USE start = DateTime(now = 1);
-
-PROCESS inputs;
-
-BLOCK editor;
-WRAPPER html/table ;
-
- WRAPPER html/row;
- INCLUDE html/cell content='Year';
- END;
-
- WRAPPER html/row;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':year' size=4 value=(current_value.year ? current_value.year : start.year);
- END;
- WRAPPER html/cell;
- 'For ';
- ycl = 'year-count';
- INCLUDE text name=input_prefix _ ':year-count' value=(current_value.$ycl ? current_value.$ycl : 2);
- ' years';
- END;
- END;
-
-END;
-END;
-
-BLOCK display;
-ycl = 'year-count';
-current_value.year _ ' through ' _ current_value.year + current_value.$ycl;
-END;
-
-%]
+++ /dev/null
-[%
-
-USE date;
-USE start = DateTime(now = 1);
-
-PROCESS inputs;
-
-BLOCK editor;
-WRAPPER html/table ;
-
- WRAPPER html/row;
- INCLUDE html/cell content='Year';
- INCLUDE html/cell content='Quarter';
- END;
-
- WRAPPER html/row;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix _ ':year' size=4 value=start.year;
- END;
- WRAPPER html/cell;
- WRAPPER select name=input_prefix _ ':quarter';
- FOR i IN [1,2,3,4];
- INCLUDE option value=i;
- END;
- END;
- END;
- END;
-
-END;
-END;
-
-BLOCK display;
-'Year: ' _ current_value.year _ ', Quarter: ' _ current_value.quarter;
-END;
-
-%]
+++ /dev/null
-[%
-
-PROCESS inputs;
-
-USE date;
-USE start = DateTime(now = 1);
-
-BLOCK editor;
-
-'Year: ';
-INCLUDE name=input_prefix _ ':year' text size=4 value=start.year;
-
-
-'<br/>Week of year: ';
-WRAPPER select name=input_prefix _ ':week';
- count = 1;
- WHILE count < 54;
- selected = 0;
- IF count == current_value.week;
- selected = 1;
- END;
- INCLUDE option value=count;
- count = count + 1;
- END;
-END;
-END;
-
-BLOCK display;
-'Year: ' _ current_value.year _ ', Week: ' _ current_value.week;
-END;
-
-%]
+++ /dev/null
-[%
-
-USE date;
-USE start = DateTime(now = 1);
-
-PROCESS inputs;
-
-BLOCK editor;
-
-WRAPPER html/table ;
-
- WRAPPER html/row;
- INCLUDE html/cell content='Year';
- END;
-
- WRAPPER html/row;
- WRAPPER html/cell;
- INCLUDE text name=input_prefix size=4 value=(current_value ? current_value : start.year);
- END;
- END;
-
-END;
-END;
-
-BLOCK display;
-current_value;
-END;
-
-%]
+++ /dev/null
-[%
-
-PROCESS inputs;
-
-BLOCK editor;
-q = 'SELECT * FROM ' _ table.findvalue('tablename') _ ' ORDER BY ' _ fieldname _ ';';
-
-'<script language="javascript">filters["' _ input_prefix _ '"] = "' _ table_label _ ' -- ' _ field.findvalue('label') _ '";</script>';
-
-WRAPPER select name=input_prefix;
- INCLUDE option value='' content='Select One';
- INCLUDE option value='' content='----------';
- FOR f = DBI.query(q);
- selected == 0;
- IF f.$fieldname == current_value;
- selected = 1;
- END;
- INCLUDE option value=f.$fieldname;
- END;
-END;
-END;
-
-BLOCK display;
-current_value;
-END;
-
-%]
+++ /dev/null
-[%
-
-PROCESS inputs;
-
-BLOCK editor;
-q = 'SELECT DISTINCT ' _ fieldname _ ' FROM ' _ table.findvalue('tablename') _ ' ORDER BY ' _ fieldname _ ';';
-
-'<script language="javascript">filters["' _ input_prefix _ '"] = "' _ table_label _ ' -- ' _ field.findvalue('label') _ '";</script>';
-
-WRAPPER select name=input_prefix multi=1 size=10;
- FOR f = DBI.query(q);
- selected = 0;
- FOR v = current_value;
- IF v == f.$fieldname;
- selected = 1;
- LAST;
- END;
- END;
- INCLUDE option value=f.$fieldname;
- END;
-END;
-END;
-
-BLOCK display;
-current_value;
-END;
-
-%]
+++ /dev/null
-[%
-PROCESS inputs;
-BLOCK editor;
-INCLUDE text name=input_prefix size=20 value=current_value;
-END;
-
-BLOCK display;
-current_value;
-END;
-
-%]
+++ /dev/null
-[%
-PROCESS inputs;
-
-BLOCK editor;
-INCLUDE text name=input_prefix size=20 value=current_value;
-END;
-
-BLOCK display;
-current_value;
-END;
-
-%]
+++ /dev/null
-[%
-PROCESS inputs;
-
-BLOCK editor;
-INCLUDE textarea name=input_prefix value=current_value;
-END;
-
-BLOCK display;
-current_value;
-END;
-
-%]
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<widgets>
-
- <!-- String selection from user input -->
- <widget-family name="string-input" datatype="text">
- <label>String matching from user input</label>
-
- <widget name="exact">
- <label>Exactly match a user supplied string</label>
- <description>
- This widget filters a column based on an exact string
- match.
- </description>
- </widget>
-
- <widget name="multistring">
- <label>Exactly match one of several user supplied strings</label>
- <description>
- This widget filters a column based on an set of strings.
- </description>
- </widget>
-
- <widget name="initial-substring">
- <label>Match the begining of a string from user input</label>
- <description>
- This widget filters a column based on an initial substring
- match.
- </description>
- </widget>
- </widget-family>
-
-
- <!-- String selection from in-database data -->
- <widget-family name="string-choose" datatype="text">
- <label>String filter from known data</label>
-
- <widget name="dropdown">
- <label>Exactly match a string chosen from a dropdown</label>
- <description>
- This widget filters a column based on an exact string match.
- </description>
- </widget>
-
- <widget name="multiselect">
- <label>Match multiple strings chosen from a multiselect box</label>
- <description>
- This widget filters a column based on multiple strings.
- </description>
- </widget>
- </widget-family>
-
- <!-- Comparative time range selection -->
- <widget-family name="comparative-timerange" datatype="timestamptz">
- <label>Comparative time-range widgets</label>
-
- <widget name="month">
- <label>Compare runtime relative time months</label>
- <description>
- This widget allows the user to pick an arbitrary time range
- on which to report.
- </description>
- <filter-code type="perl">
- $full_col = "CAST(DATE_TRUNC('month', $full_col) AS DATE)";
- $where_clause =
- "$full_col IN ( CAST(DATE_TRUNC('month', NOW() - CAST( ? || ' month' AS INTERVAL )) AS DATE), ".
- " CAST(DATE_TRUNC('month', NOW() - CAST( ? || ' month' AS INTERVAL )) AS DATE))";
- push @$bind_list, $$val{target}, $$val{target} + $$val{compare};
- </filter-code>
- </widget>
- </widget-family>
-
- <!-- Specific time range selection family -->
- <widget-family name="specific-timerange" datatype="timestamptz">
- <label>Specific time-range widgets</label>
-
- <!--
- <widget name="any">
- <label>User defined time range</label>
- <description>
- This widget allows the user to pick an arbitrary time range
- on which to report.
- </description>
- </widget>
- -->
-
- <widget name="day">
- <label>Choose a specific date</label>
- <description>
- This widget allows the user to pick a specific date on which
- to report.
- </description>
- <filter-code type="perl">
- $full_col = "DATE_TRUNC('day', $full_col)";
- $where_clause = "$full_col = CAST(? AS DATE)";
- push @$bind_list, sprintf('%d/%02d/%02d', @$val{qw/year month day/});
- </filter-code>
- </widget>
-
- <widget name="week">
- <label>Choose a specific week of the year</label>
- <description>
- This widget allows the user to pick a specific week of the year
- on which to report.
- </description>
- <filter-code type="perl">
- $where_clause =
- "( EXTRACT('year' FROM $full_col) = ? ".
- " AND EXTRACT('week' FROM $full_col) = ? )";
- push @$bind_list, $$val{year}, $$val{week};
- </filter-code>
- </widget>
-
- <widget name="multiweek">
- <label>Choose a range of weeks of the year</label>
- <description>
- This widget allows the user to pick a range of weeks of the year
- on which to report.
- </description>
- <filter-code type="perl">
- $where_clause =
- "( EXTRACT('year' FROM $full_col) = ? ".
- " AND EXTRACT('week' FROM $full_col) ".
- "BETWEEN ? AND ? )";
- push @$bind_list, $$val{year}, $$val{start}, $$val{end};
- </filter-code>
- </widget>
-
- <widget name="month">
- <label>Choose a specific year and month</label>
- <description>
- This widget allows the user to pick a specific year and month
- on which to report.
- </description>
- <filter-code type="perl">
- $where_clause =
- "( EXTRACT('year' FROM $full_col) = ? ".
- " AND EXTRACT('month' FROM $full_col) = ? )";
- push @$bind_list, $$val{'start-year'}, $$val{'start-month'};
- </filter-code>
- </widget>
-
- <widget name="multimonth">
- <label>Choose a range of months</label>
- <description>
- This widget allows the user to pick a range of month on which to
- report.
- </description>
- <filter-code type="perl">
- $where_clause =
- "DATE_TRUNC('month', $full_col) ".
- "BETWEEN CAST(? AS DATE) AND CAST(? AS DATE)";
- push @$bind_list,
- sprintf('%d/%02d/01', @$val{qw/start-year start-month/}),
- sprintf('%d/%02d/01', @$val{qw/end-year end-month/});
- </filter-code>
- </widget>
-
- <!--
- <widget name="quarter">
- <label>Choose a specific year and quarter</label>
- <description>
- This widget allows the user to pick a specific year and
- quarter on which to report.
- </description>
- </widget>
-
- <widget name="multiquarter">
- <label>Choose a range of quarters</label>
- <description>
- This widget allows the user to pick a range of quarter on which
- to report.
- </description>
- </widget>
- -->
-
- <widget name="year">
- <label>Choose a specific year</label>
- <description>
- This widget allows the user to pick a specific year on which to
- report.
- </description>
- <filter-code type="perl">
- $where_clause = "EXTRACT('year' FROM $full_col) = ?";
- push @$bind_list, $val;
- </filter-code>
- </widget>
-
- <widget name="multiyear">
- <label>Choose a range of years</label>
- <description>
- This widget allows the user to pick a range of years on which to
- report.
- </description>
- <filter-code type="perl">
- $where_clause = "EXTRACT('year' FROM $full_col) BETWEEN ? AND ?";
- push @$bind_list, $$val{year}, $$val{year} + $$val{year-count};
- </filter-code>
- </widget>
- </widget-family>
-
- <!-- Specific time range selection family -->
- <widget-family name="relative-timerange" datatype="timestamptz">
- <label>Relative time-range widgets</label>
-
- <widget name="day">
- <label>Choose a date relative to the report runtime</label>
- <description>
- This widget allows the user to pick a date relative to the
- report runtime on which to report.
- </description>
- <filter-code type="perl">
- $where_clause =
- "CAST($full_col AS DATE) = ".
- "CAST((NOW() - CAST(? || ' day' AS INTERVAL)) AS DATE)";
- push @$bind_list, $val;
- </filter-code>
- </widget>
-
- <widget name="week">
- <label>Choose a week (sun-sat) relative to the report runtime</label>
- <description>
- This widget allows the user to pick a week (sun-sat) relative
- to the report runtime on which to report.
- </description>
- <filter-code type="perl">
- $where_clause =
- "( CAST(DATE_TRUNC('week', $full_col) AS DATE) = ".
- " CAST(DATE_TRUNC('week', NOW() - CAST(? || ' weeks' AS INTERVAL) ) AS DATE) ";
- push @$bind_list, $val;
- </filter-code>
- </widget>
-
- <widget name="month">
- <label>Choose a month relative to the report runtime</label>
- <description>
- This widget allows the user to pick a month relative to the
- report runtime on which to report.
- </description>
- <filter-code type="perl">
- $where_clause =
- "CAST(DATE_TRUNC('month', $full_col) AS DATE) = ".
- "CAST(DATE_TRUNC('month', NOW()) - CAST(? || ' months' AS INTERVAL) AS DATE)";
- push @$bind_list, $val;
- </filter-code>
- </widget>
-
- <!--
- <widget name="quarter">
- <label>Choose a quarter relative to the report runtime</label>
- <description>
- This widget allows the user to pick a quarter relative to the
- report runtime on which to report.
- </description>
- </widget>
- -->
-
- <widget name="year">
- <label>Choose a year relative to the report runtime</label>
- <description>
- This widget allows the user to pick a year relative to the
- report runtime on which to report.
- </description>
- <filter-code type="perl">
- $where_clause =
- "CAST(DATE_TRUNC('year', $full_col) AS DATE)= ".
- "CAST(DATE_TRUNC('year', NOW()) - CAST(? || ' years' AS INTERVAL) AS DATE)";
- push @$bind_list, $val;
- </filter-code>
- </widget>
- </widget-family>
-
- <!-- Library selection from in-database data - special to OpenILS -->
- <widget-family name="lib-choose" datatype="text">
- <label>String filter from known data</label>
-
- <widget name="dropdown">
- <label>Exactly match a Library chosen from a dropdown</label>
- <description>
- This widget filters on an exact Library Name match.
- </description>
- </widget>
-
- <widget name="multiselect">
- <label>Match multiple Libraries chosen from a multiselect box</label>
- <description>
- This widget filters based on multiple Library names.
- </description>
- </widget>
- </widget-family>
- </widgets>
-