3 # script to administer the systempref table
4 # written 20/02/2002 by paul.poulain@free.fr
5 # This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
7 # Copyright 2000-2002 Katipo Communications
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA 02111-1307 USA
24 =head1 systempreferences.pl
27 this script use an $op to know what to do.
28 if $op is empty or none of the above values,
29 - the default screen is build (with all records, or filtered datas).
30 - the user can clic on add, modify or delete record.
32 - if primkey exists, this is a modification,so we read the $primkey record
33 - builds the add/modify form
35 - the user has just send datas, so we create/modify the record
37 - we show the record having primkey=$primkey and ask for deletion validation form
39 - we delete the record having primkey=$primkey
48 use C4::Languages qw(getTranslatedLanguages);
54 # use Smart::Comments;
57 # FIXME, shouldnt we store this stuff in the systempreferences table?
61 $tabsysprefs{acquisitions}="Acquisitions";
62 $tabsysprefs{gist}="Acquisitions";
63 $tabsysprefs{emailPurchaseSuggestions}="Acquisitions";
66 $tabsysprefs{singleBranchMode}="Admin";
67 $tabsysprefs{staffClientBaseURL}="Admin";
68 $tabsysprefs{Version}="Admin";
69 $tabsysprefs{OpacMaintenance}="Admin";
70 $tabsysprefs{FrameworksLoaded}="Admin";
71 $tabsysprefs{libraryAddress}="Admin";
72 $tabsysprefs{delimiter}="Admin";
73 $tabsysprefs{IndependantBranches}="Admin";
74 $tabsysprefs{insecure}="Admin";
75 $tabsysprefs{KohaAdmin}="Admin";
76 $tabsysprefs{KohaAdminEmailAddress}="Admin";
77 $tabsysprefs{MIME}="Admin";
78 $tabsysprefs{timeout}="Admin";
79 $tabsysprefs{Intranet_includes}="Admin";
80 $tabsysprefs{AutoLocation}="Admin";
81 $tabsysprefs{DebugLevel}="Admin";
82 $tabsysprefs{SessionStorage}="Admin";
83 $tabsysprefs{noItemTypeImages}="Admin";
84 $tabsysprefs{OPACBaseURL}="Admin";
85 $tabsysprefs{GranularPermissions}="Admin";
88 $tabsysprefs{authoritysep}="Authorities";
89 $tabsysprefs{AuthDisplayHierarchy}="Authorities";
90 $tabsysprefs{dontmerge}="Authorities";
91 $tabsysprefs{BiblioAddsAuthorities}="Authorities";
93 $tabsysprefs{advancedMARCEditor}="Cataloguing";
94 $tabsysprefs{autoBarcode}="Cataloguing";
95 $tabsysprefs{hide_marc}="Cataloguing";
96 $tabsysprefs{IntranetBiblioDefaultView} = "Cataloguing";
97 $tabsysprefs{ISBD}="Cataloguing";
98 $tabsysprefs{itemcallnumber}="Cataloguing";
99 $tabsysprefs{LabelMARCView}="Cataloguing";
100 $tabsysprefs{marc}="Cataloguing";
101 $tabsysprefs{marcflavour}="Cataloguing";
102 $tabsysprefs{MARCOrgCode}="Cataloguing";
103 $tabsysprefs{z3950AuthorAuthFields}="Cataloguing";
104 $tabsysprefs{z3950NormalizeAuthor}="Cataloguing";
105 $tabsysprefs{Stemming}="Cataloguing";
106 $tabsysprefs{WeightFields}="Cataloguing";
107 $tabsysprefs{NoZebra}="Cataloguing";
108 $tabsysprefs{NoZebraIndexes}="Cataloguing";
109 $tabsysprefs{ReceiveBackIssues}="Cataloguing";
110 $tabsysprefs{DefaultClassificationSource}="Cataloguing";
111 $tabsysprefs{RoutingSerials}="Cataloguing";
112 $tabsysprefs{'item-level_itypes'}="Cataloguing";
115 $tabsysprefs{maxoutstanding}="Circulation";
116 $tabsysprefs{maxreserves}="Circulation";
117 $tabsysprefs{noissuescharge}="Circulation";
118 $tabsysprefs{IssuingInProcess}="Circulation";
119 $tabsysprefs{patronimages}="Circulation";
120 $tabsysprefs{printcirculationslips}="Circulation";
121 $tabsysprefs{ReturnBeforeExpiry}="Circulation";
122 $tabsysprefs{SpecifyDueDate}="Circulation";
123 $tabsysprefs{AutomaticItemReturn}="Circulation";
124 $tabsysprefs{ReservesMaxPickUpDelay}="Circulation";
125 $tabsysprefs{TransfersMaxDaysWarning}="Circulation";
126 $tabsysprefs{useDaysMode}="Circulation";
127 $tabsysprefs{ReservesNeedReturns}="Circulation";
128 $tabsysprefs{CircAutocompl}="Circulation";
129 $tabsysprefs{canreservefromotherbranches}="Circulation";
130 $tabsysprefs{finesMode}="Circulation";
131 $tabsysprefs{emailLibrarianWhenHoldIsPlaced}="Circulation";
132 $tabsysprefs{globalDueDate}="Circulation";
133 $tabsysprefs{holdCancelLength}="Circulation";
134 $tabsysprefs{itemBarcodeInputFilter}="Circulation";
135 $tabsysprefs{noOPACHolds}="Circulation";
136 $tabsysprefs{WebBasedSelfCheck}="Circulation";
137 $tabsysprefs{CircControl}="Circulation";
138 $tabsysprefs{finesCalendar}="Circulation";
139 $tabsysprefs{previousIssuesDefaultSortOrder}="Circulation";
140 $tabsysprefs{todaysIssuesDefaultSortOrder}="Circulation";
141 $tabsysprefs{HomeOrHoldingBranch}="Circulation";
144 $tabsysprefs{TemplateEncoding}="StaffClient";
145 $tabsysprefs{template}="StaffClient";
146 $tabsysprefs{intranetstylesheet}="StaffClient";
147 $tabsysprefs{IntranetNav}="StaffClient";
148 $tabsysprefs{intranetcolorstylesheet}="StaffClient";
149 $tabsysprefs{intranetuserjs}="StaffClient";
150 $tabsysprefs{yuipath}="StaffClient";
151 $tabsysprefs{IntranetmainUserblock}="StaffClient";
154 $tabsysprefs{autoMemberNum}="Patrons";
155 $tabsysprefs{checkdigit}="Patrons";
156 $tabsysprefs{intranetreadinghistory}="Patrons";
157 $tabsysprefs{NotifyBorrowerDeparture}="Patrons";
158 $tabsysprefs{memberofinstitution}="Patrons";
159 $tabsysprefs{ReadingHistory}="Patrons";
160 $tabsysprefs{BorrowerMandatoryField}="Patrons";
161 $tabsysprefs{borrowerRelationship}="Patrons";
162 $tabsysprefs{BorrowersTitles}="Patrons";
163 $tabsysprefs{patronimages}="Patrons";
164 $tabsysprefs{MinPasswordLength}="Patrons";
165 $tabsysprefs{uppercasesurnames}="Patrons";
166 $tabsysprefs{NoReturnSetLost}="Patrons";
167 $tabsysprefs{MaxFine}="Patrons";
168 $tabsysprefs{NotifyBorrowerDeparture}="Patrons";
169 $tabsysprefs{PatronsPerPage}="Patrons";
172 $tabsysprefs{FRBRizeEditions}="FRBR";
173 $tabsysprefs{XISBN}="FRBR";
174 $tabsysprefs{OCLCAffiliateID}="FRBR";
175 $tabsysprefs{XISBNDailyLimit}="FRBR";
176 $tabsysprefs{PINESISBN}="FRBR";
177 $tabsysprefs{ThingISBN}="FRBR";
178 $tabsysprefs{OPACFRBRizeEditions}="FRBR";
181 $tabsysprefs{dateformat}="I18N/L10N";
182 $tabsysprefs{opaclanguages}="I18N/L10N";
183 $tabsysprefs{opacthemes}="I18N/L10N";
184 $tabsysprefs{language}="I18N/L10N";
187 $tabsysprefs{defaultSortField}="Searching";
188 $tabsysprefs{defaultSortOrder}="Searching";
189 $tabsysprefs{maxItemsInSearchResults}="Searching";
190 $tabsysprefs{numSearchResults}="Searching";
191 $tabsysprefs{OPACdefaultSortField}="Searching";
192 $tabsysprefs{OPACdefaultSortOrder}="Searching";
193 $tabsysprefs{OPACItemsResultsDisplay}="Searching";
194 $tabsysprefs{OPACnumSearchResults}="Searching";
195 $tabsysprefs{QueryFuzzy}="Searching";
196 $tabsysprefs{QueryStemming}="Searching";
197 $tabsysprefs{QueryWeightFields}="Searching";
198 $tabsysprefs{expandedSearchOption}="Searching";
199 $tabsysprefs{sortbynonfiling}="Searching";
200 $tabsysprefs{QueryAutoTruncate}="Searching";
201 $tabsysprefs{QueryRemoveStopwords}="Searching";
204 $tabsysprefs{AmazonContent}="Amazon";
205 $tabsysprefs{AWSAccessKeyID}="Amazon";
206 $tabsysprefs{AmazonLocale}="Amazon";
207 $tabsysprefs{AmazonAssocTag}="Amazon";
208 $tabsysprefs{AmazonSimilarItems}="Amazon";
209 $tabsysprefs{OPACAmazonContent}="Amazon";
210 $tabsysprefs{OPACAmazonSimilarItems}="Amazon";
213 $tabsysprefs{BiblioDefaultView}="OPAC";
214 $tabsysprefs{LibraryName}="OPAC";
215 $tabsysprefs{opaccolorstylesheet}="OPAC";
216 $tabsysprefs{opaccredits}="OPAC";
217 $tabsysprefs{opaclargeimage}="OPAC";
218 $tabsysprefs{opaclayoutstylesheet}="OPAC";
219 $tabsysprefs{OpacNav}="OPAC";
220 $tabsysprefs{opacsmallimage}="OPAC";
221 $tabsysprefs{opacstylesheet}="OPAC";
222 $tabsysprefs{opacthemes}="OPAC";
223 $tabsysprefs{opacuserjs}="OPAC";
224 $tabsysprefs{SubscriptionHistory}="OPAC";
225 $tabsysprefs{opacheader}="OPAC";
227 $tabsysprefs{hideBiblioNumber}="OPAC";
228 $tabsysprefs{noOPACUserLogin}="OPAC";
229 $tabsysprefs{OPACDisplayExtendedSubInfo}="OPAC";
230 $tabsysprefs{OpacMainUserBlock}="OPAC";
231 $tabsysprefs{OPACSubscriptionDisplay}="OPAC";
232 $tabsysprefs{OPACURLOpenInNewWindow}="OPAC";
233 $tabsysprefs{OPACUserCSS}="OPAC";
234 $tabsysprefs{OPACHighlightedWords}="OPAC";
235 $tabsysprefs{OPACViewOthersSuggestions}="OPAC";
236 $tabsysprefs{URLLinkText}="OPAC";
237 $tabsysprefs{OPACShelfBrowser}="OPAC";
240 $tabsysprefs{SearchMyLibraryFirst}="OPAC";
241 $tabsysprefs{Disable_Dictionary}="OPAC";
242 $tabsysprefs{hidelostitems}="OPAC";
243 $tabsysprefs{opacbookbag}="OPAC";
244 $tabsysprefs{opaclanguagesdisplay}="OPAC";
245 $tabsysprefs{OpacPasswordChange}="OPAC";
246 $tabsysprefs{opacreadinghistory}="OPAC";
247 $tabsysprefs{virtualshelves}="OPAC";
248 $tabsysprefs{RequestOnOpac}="OPAC";
249 $tabsysprefs{reviewson}="OPAC";
250 $tabsysprefs{OpacTopissues}="OPAC";
251 $tabsysprefs{OpacAuthorities}="OPAC";
252 $tabsysprefs{OpacCloud}="OPAC";
253 $tabsysprefs{opacuserlogin}="OPAC";
254 $tabsysprefs{AnonSuggestions}="OPAC";
255 $tabsysprefs{suggestion}="OPAC";
256 $tabsysprefs{OpacTopissue}="OPAC";
257 $tabsysprefs{OpacBrowser}="OPAC";
258 $tabsysprefs{kohaspsuggest} = "OPAC";
259 $tabsysprefs{OpacRenewalAllowed} = "OPAC";
262 $tabsysprefs{CataloguingLog} = "Logs";
263 $tabsysprefs{BorrowersLog} = "Logs";
264 $tabsysprefs{SubscriptionLog} = "Logs";
265 $tabsysprefs{IssueLog} = "Logs";
266 $tabsysprefs{ReturnLog} = "Logs";
267 $tabsysprefs{LetterLog} = "Logs";
268 $tabsysprefs{FinesLog} = "Logs";
271 $tabsysprefs{'OAI-PMH'} = "OAI-PMH";
272 $tabsysprefs{'OAI-PMH:archiveID'} = "OAI-PMH";
273 $tabsysprefs{'OAI-PMH:MaxCount'} = "OAI-PMH";
274 $tabsysprefs{'OAI-PMH:Set'} = "OAI-PMH";
275 $tabsysprefs{'OAI-PMH:Subset'} = "OAI-PMH";
279 my ($searchstring,$type)=@_;
280 my $dbh = C4::Context->dbh;
281 $searchstring=~ s/\'/\\\'/g;
282 my @data=split(' ',$searchstring);
287 # used for doing a plain-old sys-pref search
288 if ($type eq 'all' ){
289 my $sth=$dbh->prepare("SELECT * FROM systempreferences
290 WHERE variable LIKE ? OR explanation LIKE ?
292 $sth->execute("%$searchstring%", "%$searchstring%");
293 while (my $data=$sth->fetchrow_hashref){
294 $data->{value} =~ s/</</g;
295 $data->{value} =~ s/>/>/g;
296 $data->{value}=substr($data->{value},0,100)."..." if length($data->{value}) >100;
297 push(@results,$data);
303 foreach my $syspref (sort { lc $a cmp lc $b } keys %tabsysprefs){
304 if ($tabsysprefs{$syspref} eq $type){
305 my $sth=$dbh->prepare("Select variable,value,explanation,type,options from systempreferences where (variable like ?) order by variable");
306 $sth->execute($syspref);
307 while (my $data=$sth->fetchrow_hashref){
308 $data->{value} =~ s/</</g;
309 $data->{value} =~ s/>/>/g;
310 $data->{value}=substr($data->{value},0,100)."..." if length($data->{value}) >100;
311 push(@results,$data);
318 my $strsth ="Select variable,value,explanation,type,options from systempreferences where variable not in (";
319 foreach my $syspref (keys %tabsysprefs){
320 $strsth .= $dbh->quote($syspref).",";
323 $strsth .= " order by variable";
324 my $sth=$dbh->prepare($strsth);
326 while (my $data=$sth->fetchrow_hashref){
327 $data->{value}=substr($data->{value},0,100);
328 push(@results,$data);
333 return ($cnt,\@results);
337 my $searchfield = $input->param('searchfield');
338 my $Tvalue = $input->param('Tvalue');
339 my $offset = $input->param('offset');
340 my $script_name="/cgi-bin/koha/admin/systempreferences.pl";
342 my ($template, $borrowernumber, $cookie)
343 = get_template_and_user({template_name => "admin/systempreferences.tmpl",
346 authnotrequired => 0,
347 flagsrequired => {parameters => 1},
351 my $op = $input->param('op');
352 $searchfield=~ s/\,//g;
355 $template->param(script_name => $script_name,
356 $op => 1); # we show only the TMPL_VAR names $op
358 $template->param(script_name => $script_name,
359 else => 1); # we show only the TMPL_VAR names $op
362 if ($op eq 'update_and_reedit') {
363 foreach ($input->param) {
366 if (my $currentorder=$input->param('currentorder')) {
367 my @currentorder=split /\|/, $currentorder;
369 foreach my $param ($input->param) {
370 if ($param=~m#up-(\d+).x#) {
371 my $temp=$currentorder[$1];
372 $currentorder[$1]=$currentorder[$1-1];
373 $currentorder[$1-1]=$temp;
376 } elsif ($param=~m#down-(\d+).x#) {
377 my $temp=$currentorder[$1];
378 $currentorder[$1]=$currentorder[$1+1];
379 $currentorder[$1+1]=$temp;
384 $value=join ' ', @currentorder;
387 $template->param(script_name => $script_name,
388 $op => 1); # we show only the TMPL_VAR names $op
392 $template->param(script_name => $script_name,
393 else => 1); # we show only the TMPL_VAR names $op
396 my $dbh = C4::Context->dbh;
397 my $query="select * from systempreferences where variable=?";
398 my $sth=$dbh->prepare($query);
399 $sth->execute($input->param('variable'));
401 unless (C4::Context->config('demo') eq 1) {
402 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
403 $sth->execute($value, $input->param('explanation'), $input->param('variable'), $input->param('preftype'), $input->param('prefoptions'));
405 warn "logaction !! mod ";
406 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
409 unless (C4::Context->config('demo') eq 1) {
410 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation) values (?,?,?,?,?)");
411 $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
413 warn "logaction !! add ";
414 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $input->param('value') );
421 ################## ADD_FORM ##################################
422 # called by default. Used to create form to add or modify a record
424 if ($op eq 'add_form') {
425 #---- if primkey exists, it's a modify action, so read values to modify...
428 my $dbh = C4::Context->dbh;
429 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
430 $sth->execute($searchfield);
431 $data=$sth->fetchrow_hashref;
433 $template->param(modify => 1);
434 # save tab to return to if user cancels edit
435 $template->param(return_tab => $tabsysprefs{$searchfield});
439 foreach my $option (split(/\|/, $data->{'options'})) {
441 $option eq $data->{'value'} and $selected=1;
442 push @options, { option => $option, selected => $selected };
444 if ($data->{'type'} eq 'Choice') {
445 $template->param('type-choice' => 1);
446 } elsif ($data->{'type'} eq 'YesNo') {
447 $template->param('type-yesno' => 1);
448 $data->{'value'}=C4::Context->boolean_preference($data->{'variable'});
449 ($data->{'value'} eq '1') ? ($template->param('value-yes'=>1)) : ($template->param('value-no'=>1));
450 } elsif ($data->{'type'} eq 'Integer') {
451 $template->param('type-free' => 1);
452 $template->param('fieldlength' => $data->{'options'});
453 } elsif ($data->{'type'} eq 'Textarea') {
454 $template->param('type-textarea' => 1);
455 $data->{options} =~ /(.*)\|(.*)/;
456 $template->param('cols' => $1, 'rows' => $2);;
457 } elsif ($data->{'type'} eq 'Float') {
458 $template->param('type-free' => 1);
459 $template->param('fieldlength' => $data->{'options'});
460 } elsif ($data->{'type'} eq 'Themes') {
461 $template->param('type-choice' => 1);
463 ($data->{'variable'}=~m#opac#i) ? ($type='opac') : ($type='intranet');
465 my $currently_selected_themes;
467 foreach my $theme (split /\s+/, $data->{'value'}) {
468 push @options, { option => $theme, counter => $counter };
469 $currently_selected_themes->{$theme}=1;
472 foreach my $theme (getallthemes($type)) {
474 next if $currently_selected_themes->{$theme};
475 push @options, { option => $theme, counter => $counter };
478 } elsif ($data->{'type'} eq 'ClassSources') {
479 $template->param('type-choice' => 1);
482 my $sources = GetClassSources();
484 foreach my $cn_source (sort keys %$sources) {
485 if ($cn_source eq $data->{'value'}) {
486 push @options, { option => $cn_source, counter => $counter, selected => 1 };
488 push @options, { option => $cn_source, counter => $counter };
492 } elsif ($data->{'type'} eq 'Languages') {
493 my $currently_selected_languages;
494 foreach my $language (split /\s+/, $data->{'value'}) {
495 $currently_selected_languages->{$language}=1;
498 my $lang = $template->param('lang');
501 if ($data->{'variable'} =~ /opac/) {
504 $theme = C4::Context->preference('opacthemes');
507 # this is the staff client
508 $interface = 'intranet';
509 $theme = C4::Context->preference('template');
511 my $languages_loop = getTranslatedLanguages($interface,$theme,$lang,$currently_selected_languages);
513 $template->param('languages_loop' => $languages_loop);
514 $template->param('type-langselector' => 1);
516 $template->param('type-free' => 1);
517 $template->param('fieldlength' => $data->{'options'}>0?$data->{'options'}:60);
519 $template->param(explanation => $data->{'explanation'},
520 value => $data->{'value'},
521 type => $data->{'type'},
522 options => \@options,
523 preftype => $data->{'type'},
524 prefoptions => $data->{'options'},
525 searchfield => $searchfield);
527 ################## ADD_VALIDATE ##################################
528 # called by add_form, used to insert/modify data in DB
529 } elsif ($op eq 'add_validate') {
530 my $dbh = C4::Context->dbh;
531 my $sth=$dbh->prepare("select * from systempreferences where variable=?");
532 $sth->execute($input->param('variable'));
533 # to handle multiple values
535 # handle multiple value strings (separated by ',')
536 my $params = $input->Vars;
537 my @values = split("\0",$params->{'value'}) if $params->{'value'};
538 for my $vl (@values) {
543 unless (C4::Context->config('demo') eq 1) {
544 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
545 $sth->execute($value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'), $input->param('variable'));
547 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
550 unless (C4::Context->config('demo') eq 1) {
551 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation,type,options) values (?,?,?,?,?)");
552 $sth->execute($input->param('variable'), $value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
554 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $value );
558 print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=systempreferences.pl?tab=".$tabsysprefs{$input->param('variable')}."\"></html>";
560 ################## DELETE_CONFIRM ##################################
561 # called by default form, used to confirm deletion of data in DB
562 } elsif ($op eq 'delete_confirm') {
563 my $dbh = C4::Context->dbh;
564 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
565 $sth->execute($searchfield);
566 my $data=$sth->fetchrow_hashref;
568 $template->param(searchfield => $searchfield,
569 Tvalue => $data->{'value'},
572 # END $OP eq DELETE_CONFIRM
573 ################## DELETE_CONFIRMED ##################################
574 # called by delete_confirm, used to effectively confirm deletion of data in DB
575 } elsif ($op eq 'delete_confirmed') {
576 my $dbh = C4::Context->dbh;
577 my $sth=$dbh->prepare("delete from systempreferences where variable=?");
578 $sth->execute($searchfield);
579 my $logstring = $searchfield . " | " . $Tvalue ;
580 logaction('SYSTEMPREFERENCE','DELETE',undef,$logstring);
583 # END $OP eq DELETE_CONFIRMED
584 ################## DEFAULT ##################################
586 #Adding tab management for system preferences
587 my $tab=$input->param('tab');
588 $template->param($tab => 1);
589 my ($count,$results)=StringSearch($searchfield,$tab);
592 for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
598 my %row_data; # get a fresh hash for the row data
599 $row_data{variable} = $results->[$i]{'variable'};
600 $row_data{value} = $results->[$i]{'value'};
601 $row_data{yes} = 1 if ($results->[$i]{'value'} == 1);
602 $row_data{yesno} = 1 if ($results->[$i]{'type'} eq 'YesNo');
603 $row_data{explanation} = $results->[$i]{'explanation'};
604 $row_data{toggle} = $toggle;
605 $row_data{edit} = "$script_name?op=add_form&searchfield=".$results->[$i]{'variable'};
606 $row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'variable'};
607 push(@loop_data, \%row_data);
609 $tab=($tab?$tab:"Local Use");
610 $template->param(loop => \@loop_data, $tab => 1);
612 my $prevpage = $offset-$pagesize;
613 $template->param("<a href=$script_name?offset=".$prevpage.'<< Prev</a>');
615 if ($offset+$pagesize<$count) {
616 my $nextpage =$offset+$pagesize;
617 $template->param("a href=$script_name?offset=".$nextpage.'Next >></a>');
619 $template->param( tab => $tab,
621 } #---- END $OP eq DEFAULT
622 output_html_with_http_headers $input, $cookie, $template->output;