CGI-OptimalQuery
view release on metacpan or search on metacpan
lib/CGI/OptimalQuery.pm view on Meta::CPAN
=item B<< useAjax => 1 >>
Reload the data using ajax. Defaults to 1 unless not specified and usePopups is set to 0.
=item B<< NewButton => "<a href=record.pl class=OQnewBut>new</a>" >>
=item B<< editButtonLabel => 'edit' >>
=item B<< editLink => '/link/to/record' >>
OptimalQuery will automatically create an edit and new button if this is defined. When creating the link, OptimalQuery appends "?id=$$rec{U_ID};act=new;on_update=OQrefresh" or "?id=$$rec{U_ID};act=load;on_update=OQrefresh" to the link so the record m...
=item B<< htmlFooter => "<h1>this is a footer</h1>" >>
=item B<< htmlHeader => "<h1>this is a header</h1>" >>
=item B<< httpHeader => CGI::header('text/html') >>
override httpHeader content. If you prefer to not have InteractiveQuery send the header, set this value to empty string.
=item B<< mutateRecord => sub { } >>
mutateRecord => sub {
my $rec = shift;
# add html links to the person record
# if user selected the NAME field
if (exists $$rec{NAME}) {
$$rec{NAME} = "<A HREF=/PersonRecord?id=$$rec{ID}>".
CGI::escapeHTML($$rec{NAME})."</A>";
}
}
=item B<< noEscapeCol => ['NAME'] >>
if certain columns should not be HTML escaped, let OptimalQuery know by adding them to this array.
=item B<< OQdataLCol => sub { } >>
=item B<< OQdataRCol => sub { } >>
Specify custom code to print the first or last column element. This is most often used to generate an view/edit button. If these callbacks are used, the editLink, and buildEditLink are ignored.
OQdataLCol => sub {
my ($rec) = @_;
return "<button onclick=\"OQopwin('/ViewRecord?id=$$rec{U_ID};on_update=OQrefresh';\">".
"view</button>";
}
=item B<< OQdocBottom => "bottom of the document (outside form)" >>
=item B<< OQdocTop => "top of the doc (outside form)" >>
=item B<< OQformBottom => "bottom of form" >>
=item B<< OQformTop => "top of form" >>
=item B<< usePopups => 1|0 >>
use popups when opening a record form using the built in buttons The default is 1. If this is set to 1, useAjax default is 1.
=item B<< WindowHeight => INT >>
=item B<< WindowWidth => INT >>
Specify popup window width, height.
=item B<< OQscript => " some javascript code (see examples below) " >>
OQscript gives you unlimited power to alter the output of optimal query by allowing you to enter javascript code that is executed client side
For example to add a new command button:
OQscript => "
var e = document.getElementById('OQcmds');
e.innerHTML = '".CGI::OptimalQuery::escape_js(q|<button type=button onclick="window.alert('hello there');">hello</button>|)."' + e.innerHTML;
=back
=head1 SAVED SEARCHES
InteractiveQuery can optionally save searches to a database so users can revisit them latter. To do this, saved searches are tied to a unique user id. Developers should tell OptimalQuery the user id by defining 'savedSearchUserID' in their %CONFIG.
$config{savedSearchUserID} = $user_id;
Saved Searches are stored in a table in the database pointed to by the database handle defined in $config{dbh}. The following table must exist before using saved searches.
-- For mysql:
CREATE TABLE oq_saved_search (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
user_id INT UNSIGNED,
FOREIGN KEY fk_oqsavedsearch_userid (user_id)
REFERENCES XYZ(id) ON DELETE CASCADE,
uri VARCHAR(100) NOT NULL,
oq_title VARCHAR(1000) NOT NULL,
user_title VARCHAR(1000) NOT NULL,
params TEXT,
-- 0:disabled, 1:added, 2:removed, 4:present
alert_mask INT UNSIGNED NOT NULL DEFAULT 0,
alert_interval_min INT UNSIGNED,
alert_dow VARCHAR(7),
alert_start_hour INT UNSIGNED,
alert_end_hour INT UNSIGNED,
alert_last_dt DATETIME,
alert_err TEXT,
alert_uids LONGTEXT,
is_default TINYINT(1) NOT NULL DEFAULT 0,
CONSTRAINT unq_oq_saved_search UNIQUE (user_id,uri,oq_title,user_title)
);
-- For Oracle:
CREATE TABLE oq_saved_search (
id NUMBER PRIMARY KEY,
user_id NUMBER NOT NULL REFERENCES XYZ(id) ON DELETE CASCADE,
uri VARCHAR2(100) NOT NULL,
oq_title VARCHAR2(1000) NOT NULL,
user_title VARCHAR2(1000) NOT NULL,
params CLOB,
-- 0:disabled, 1:added, 2:removed, 4:present
alert_mask NUMBER DEFAULT 0 NOT NULL,
alert_interval_min NUMBER,
alert_dow VARCHAR2(7),
alert_start_hour NUMBER,
alert_end_hour NUMBER,
alert_last_dt DATE,
( run in 1.046 second using v1.01-cache-2.11-cpan-364913b4093 )