From 28c9f74a6c41e329990e825ca25cfc15fb0ad37a Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 5 Mar 2002 20:48:42 +0000 Subject: [PATCH] scripts to manage parameters tables --- admin/aqbookfund.pl | 256 +++++++++++++++++++++++++++++++++ admin/aqbudget.pl | 260 ++++++++++++++++++++++++++++++++++ admin/branches.pl | 280 +++++++++++++++++++++++++++++++++++++ admin/categorie.pl | 275 ++++++++++++++++++++++++++++++++++++ admin/categoryitem.pl | 276 ++++++++++++++++++++++++++++++++++++ admin/currency.pl | 254 +++++++++++++++++++++++++++++++++ admin/itemtypes.pl | 278 ++++++++++++++++++++++++++++++++++++ admin/printers.pl | 245 ++++++++++++++++++++++++++++++++ admin/stopwords.pl | 234 +++++++++++++++++++++++++++++++ admin/systempreferences.pl | 245 ++++++++++++++++++++++++++++++++ 10 files changed, 2603 insertions(+) create mode 100755 admin/aqbookfund.pl create mode 100755 admin/aqbudget.pl create mode 100755 admin/branches.pl create mode 100755 admin/categorie.pl create mode 100644 admin/categoryitem.pl create mode 100755 admin/currency.pl create mode 100755 admin/itemtypes.pl create mode 100755 admin/printers.pl create mode 100755 admin/stopwords.pl create mode 100755 admin/systempreferences.pl diff --git a/admin/aqbookfund.pl b/admin/aqbookfund.pl new file mode 100755 index 0000000000..e9cd150714 --- /dev/null +++ b/admin/aqbookfund.pl @@ -0,0 +1,256 @@ +#!/usr/bin/perl + +#script to administer the aqbudget table +#written 20/02/2002 by paul.poulain@free.fr +# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) + +# ALGO : +# this script use an $op to know what to do. +# if $op is empty or none of the above values, +# - the default screen is build (with all records, or filtered datas). +# - the user can clic on add, modify or delete record. +# if $op=add_form +# - if primkey exists, this is a modification,so we read the $primkey record +# - builds the add/modify form +# if $op=add_validate +# - the user has just send datas, so we create/modify the record +# if $op=delete_form +# - we show the record having primkey=$primkey and ask for deletion validation form +# if $op=delete_confirm +# - we delete the record having primkey=$primkey + +use strict; +use C4::Output; +use CGI; +use C4::Search; +use C4::Database; + +sub StringSearch { + my ($env,$searchstring,$type)=@_; + my $dbh = &C4Connect; + $searchstring=~ s/\'/\\\'/g; + my @data=split(' ',$searchstring); + my $count=@data; + my $query="Select aqbudget.bookfundid,startdate,enddate,budgetamount,bookfundname from aqbudget,aqbookfund where aqbudget.bookfundid=aqbookfund.bookfundid and (aqbudget.bookfundid like \"$data[0]%\") order by bookfundid"; + my $sth=$dbh->prepare($query); + $sth->execute; + my @results; + my $cnt=0; + while (my $data=$sth->fetchrow_hashref){ + push(@results,$data); + $cnt ++; + } + # $sth->execute; + $sth->finish; + $dbh->disconnect; + return ($cnt,\@results); +} + +my $input = new CGI; +my $searchfield=$input->param('searchfield'); +my $offset=$input->param('offset'); +my $script_name="/cgi-bin/koha/admin/aqbookfund.pl"; +my $bookfundid=$input->param('bookfundid'); +my $pagesize=20; +my $op = $input->param('op'); +$searchfield=~ s/\,//g; +print $input->header; + +#start the page and read in includes +print startpage(); +print startmenu('admin'); + +################## ADD_FORM ################################## +# called by default. Used to create form to add or modify a record +if ($op eq 'add_form') { + #---- if primkey exists, it's a modify action, so read values to modify... + my $data; + if ($bookfundid) { + my $dbh = &C4Connect; + my $sth=$dbh->prepare("select bookfundid,bookfundname,bookfundgroup from aqbookfund where bookfundid='$bookfundid'"); + $sth->execute; + $data=$sth->fetchrow_hashref; + $sth->finish; + } + print < + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNotNull(f,noalert) { + if (f.value.length ==0) { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function toUC(f) { + var x=f.value.toUpperCase(); + f.value=x; + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNum(v,maybenull) { + var n = new Number(v.value); + if (isNaN(n)) { + return false; + } + if (maybenull==0 && v.value=='') { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isDate(f) { + var t = Date.parse(f.value); + if (isNaN(t)) { + return false; + } + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function Check(f) { + var ok=1; + var _alertString=""; + var alertString2; + if (f.bookfundid.value.length==0) { + _alertString += "- bookfundid missing\\n"; + } + if (f.bookfundname.value.length==0) { + _alertString += "- bookfundname missing\\n"; + } + if (_alertString.length==0) { + document.Aform.submit(); + } else { + alertString2 = "Form not submitted because of the following problem(s)\\n"; + alertString2 += "------------------------------------------------------------------------------------\\n\\n"; + alertString2 += _alertString; + alert(alertString2); + } + } + +printend +;#/ + if ($bookfundid) { + print "

Modify book fund

"; + } else { + print "

Add book fund

"; + } + print "
"; + print ""; + print ""; + print ""; + if ($bookfundid) { + print ""; + } else { + print ""; + } + print ""; + print ""; + print ""; +print "
Book fund$bookfundid
Book fund
Name 
Group
 
"; + print "
"; +; + # END $OP eq ADD_FORM +################## ADD_VALIDATE ################################## +# called by add_form, used to insert/modify data in DB +} elsif ($op eq 'add_validate') { + my $dbh=C4Connect; + my $query = "replace aqbookfund (bookfundid,bookfundname,bookfundgroup) values ("; + $query.= $dbh->quote($input->param('bookfundid')).","; + $query.= $dbh->quote($input->param('bookfundname')).","; + $query.= $dbh->quote($input->param('bookfundgroup')).")"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + print "data recorded"; + print "
"; + print ""; + print "
"; + # END $OP eq ADD_VALIDATE +################## DELETE_CONFIRM ################################## +# called by default form, used to confirm deletion of data in DB +} elsif ($op eq 'delete_confirm') { + my $dbh = &C4Connect; +# my $sth=$dbh->prepare("select count(*) as total from categoryitem where itemtype='$itemtype'"); +# $sth->execute; +# my $total = $sth->fetchrow_hashref; +# $sth->finish; + my $sth=$dbh->prepare("select bookfundid,bookfundname,bookfundgroup from aqbookfund where bookfundid='$bookfundid'"); + $sth->execute; + my $data=$sth->fetchrow_hashref; + $sth->finish; + print mktablehdr; + print mktablerow(2,'#99cc33',bold('Book fund'),bold("$bookfundid"),'/images/background-mem.gif'); + print "
"; + print "Name$data->{'bookfundname'}"; + print "Group$data->{'bookfundgroup'}"; +# if ($total->{'total'} >0) { +# print "This record is used $total->{'total'} times. Deletion not possible"; +# print "
"; +# } else { + print "CONFIRM DELETION"; + print "
"; +# } + # END $OP eq DELETE_CONFIRM +################## DELETE_CONFIRMED ################################## +# called by delete_confirm, used to effectively confirm deletion of data in DB +} elsif ($op eq 'delete_confirmed') { + my $dbh=C4Connect; + my $bookfundid=uc($input->param('bookfundid')); + my $query = "delete from aqbookfund where bookfundid='$bookfundid'"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + print "data deleted"; + print "
"; + print ""; + print "
"; + # END $OP eq DELETE_CONFIRMED +################## DEFAULT ################################## +} else { # DEFAULT + my @inputs=(["text","searchfield",$searchfield], + ["reset","reset","clr"]); + print mkheadr(2,'bookfund admin'); + print mkformnotable("$script_name",@inputs); + print <$searchfield

"; + } + print mktablehdr; + print mktablerow(6,'#99cc33',bold('Book fund'),bold('Start date'),bold('End date'),bold('Budget amount'), + ' ',' ','/images/background-mem.gif'); + my $env; + my ($count,$results)=StringSearch($env,$searchfield,'web'); + my $toggle="white"; + for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){ + #find out stats + # my ($od,$issue,$fines)=categdata2($env,$results->[$i]{'borrowernumber'}); + # $fines=$fines+0; + if ($toggle eq 'white'){ + $toggle="#ffffcc"; + } else { + $toggle="white"; + } + print mktablerow(6,$toggle,$results->[$i]{'bookfundid'}, + $results->[$i]{'bookfundname'},$results->[$i]{'bookfundgroup'}, + mklink("$script_name?op=add_form&bookfundid=".$results->[$i]{'bookfundid'},'Edit'), + mklink("$script_name?op=delete_confirm&bookfundid=".$results->[$i]{'bookfundid'},'Delete','')); + } + print mktableft; + print "

"; + print ""; + if ($offset>0) { + my $prevpage = $offset-$pagesize; + print mklink("$script_name?offset=".$prevpage,'<< Prev'); + } + print "      "; + if ($offset+$pagesize<$count) { + my $nextpage =$offset+$pagesize; + print mklink("$script_name?offset=".$nextpage,'Next >>'); + } + print "

"; + print "
"; +} #---- END $OP eq DEFAULT +print endmenu('admin'); +print endpage(); diff --git a/admin/aqbudget.pl b/admin/aqbudget.pl new file mode 100755 index 0000000000..8a9bc118cf --- /dev/null +++ b/admin/aqbudget.pl @@ -0,0 +1,260 @@ +#!/usr/bin/perl + +#script to administer the aqbudget table +#written 20/02/2002 by paul.poulain@free.fr +# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) + +# ALGO : +# this script use an $op to know what to do. +# if $op is empty or none of the above values, +# - the default screen is build (with all records, or filtered datas). +# - the user can clic on add, modify or delete record. +# if $op=add_form +# - if primkey exists, this is a modification,so we read the $primkey record +# - builds the add/modify form +# if $op=add_validate +# - the user has just send datas, so we create/modify the record +# if $op=delete_form +# - we show the record having primkey=$primkey and ask for deletion validation form +# if $op=delete_confirm +# - we delete the record having primkey=$primkey + +use strict; +use C4::Output; +use CGI; +use C4::Search; +use C4::Database; + +sub StringSearch { + my ($env,$searchstring,$type)=@_; + my $dbh = &C4Connect; + $searchstring=~ s/\'/\\\'/g; + my @data=split(' ',$searchstring); + my $count=@data; + my $query="Select aqbudget.bookfundid,startdate,enddate,budgetamount,bookfundname from aqbudget,aqbookfund where aqbudget.bookfundid=aqbookfund.bookfundid and (aqbudget.bookfundid like \"$data[0]%\") order by bookfundid"; + my $sth=$dbh->prepare($query); + $sth->execute; + my @results; + my $cnt=0; + while (my $data=$sth->fetchrow_hashref){ + push(@results,$data); + $cnt ++; + } + # $sth->execute; + $sth->finish; + $dbh->disconnect; + return ($cnt,\@results); +} + +my $input = new CGI; +my $searchfield=$input->param('searchfield'); +my $offset=$input->param('offset'); +my $script_name="/cgi-bin/koha/admin/aqbudget.pl"; +my $bookfundid=$input->param('bookfundid'); +my $pagesize=20; +my $op = $input->param('op'); +$searchfield=~ s/\,//g; +print $input->header; + +#start the page and read in includes +print startpage(); +print startmenu('admin'); + +################## ADD_FORM ################################## +# called by default. Used to create form to add or modify a record +if ($op eq 'add_form') { + #---- if primkey exists, it's a modify action, so read values to modify... + my $data; + if ($bookfundid) { + my $dbh = &C4Connect; + my $sth=$dbh->prepare("select bookfundid,startdate,enddate,budgetamount,bookfundname from aqbudget,aqbookfund where aqbudget.bookfundid=aqbookfund.bookfundid and bookfundid='$bookfundid'"); + $sth->execute; + $data=$sth->fetchrow_hashref; + $sth->finish; + } + print < + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNotNull(f,noalert) { + if (f.value.length ==0) { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function toUC(f) { + var x=f.value.toUpperCase(); + f.value=x; + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNum(v,maybenull) { + var n = new Number(v.value); + if (isNaN(n)) { + return false; + } + if (maybenull==0 && v.value=='') { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isDate(f) { + var t = Date.parse(f.value); + if (isNaN(t)) { + return false; + } + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function Check(f) { + var ok=1; + var _alertString=""; + var alertString2; + if (f.bookfundid.value.length==0) { + _alertString += "- bookfundid missing\\n"; + } + if (!(isNotNull(window.document.Aform.budgetamount,1))) { + _alertString += "- Budget missing\\n"; + } + if (_alertString.length==0) { + document.Aform.submit(); + } else { + alertString2 = "Form not submitted because of the following problem(s)\\n"; + alertString2 += "------------------------------------------------------------------------------------\\n\\n"; + alertString2 += _alertString; + alert(alertString2); + } + } + +printend +;#/ + if ($bookfundid) { + print "

Modify budget

"; + } else { + print "

Add budget

"; + } + print "
"; + print ""; + print ""; + print ""; + if ($bookfundid) { + print ""; + } else { + print ""; + } + print ""; + print ""; + print ""; + print ""; +print "
Book fund$bookfundid
Book fund
Start date 
End date
Budget amount
 
"; + print "
"; +; + # END $OP eq ADD_FORM +################## ADD_VALIDATE ################################## +# called by add_form, used to insert/modify data in DB +} elsif ($op eq 'add_validate') { + my $dbh=C4Connect; + my $query = "replace aqbudget (bookfundid,startdate,enddate,budgetamount) values ("; + $query.= $dbh->quote($input->param('bookfundid')).","; + $query.= $dbh->quote($input->param('startdate')).","; + $query.= $dbh->quote($input->param('enddate')).","; + $query.= $dbh->quote($input->param('budgetamount')).")"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + print "data recorded"; + print "
"; + print ""; + print "
"; + # END $OP eq ADD_VALIDATE +################## DELETE_CONFIRM ################################## +# called by default form, used to confirm deletion of data in DB +} elsif ($op eq 'delete_confirm') { + my $dbh = &C4Connect; +# my $sth=$dbh->prepare("select count(*) as total from categoryitem where itemtype='$itemtype'"); +# $sth->execute; +# my $total = $sth->fetchrow_hashref; +# $sth->finish; + my $sth=$dbh->prepare("select bookfundid,startdate,enddate,budgetamount from aqbudget where bookfundid='$bookfundid'"); + $sth->execute; + my $data=$sth->fetchrow_hashref; + $sth->finish; + print mktablehdr; + print mktablerow(2,'#99cc33',bold('Book fund'),bold("$bookfundid"),'/images/background-mem.gif'); + print "
"; + print "Start date$data->{'startdate'}"; + print "End date$data->{'enddate'}"; + print "budgetamount$data->{'budgetamount'}"; +# if ($total->{'total'} >0) { +# print "This record is used $total->{'total'} times. Deletion not possible"; +# print "
"; +# } else { + print "CONFIRM DELETION"; + print "
"; +# } + # END $OP eq DELETE_CONFIRM +################## DELETE_CONFIRMED ################################## +# called by delete_confirm, used to effectively confirm deletion of data in DB +} elsif ($op eq 'delete_confirmed') { + my $dbh=C4Connect; + my $bookfundid=uc($input->param('bookfundid')); + my $query = "delete from aqbudget where bookfundid='$bookfundid'"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + print "data deleted"; + print "
"; + print ""; + print "
"; + # END $OP eq DELETE_CONFIRMED +################## DEFAULT ################################## +} else { # DEFAULT + my @inputs=(["text","searchfield",$searchfield], + ["reset","reset","clr"]); + print mkheadr(2,'bookfund admin'); + print mkformnotable("$script_name",@inputs); + print <$searchfield

"; + } + print mktablehdr; + print mktablerow(6,'#99cc33',bold('Book fund'),bold('Start date'),bold('End date'),bold('Budget amount'), + ' ',' ','/images/background-mem.gif'); + my $env; + my ($count,$results)=StringSearch($env,$searchfield,'web'); + my $toggle="white"; + for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){ + #find out stats + # my ($od,$issue,$fines)=categdata2($env,$results->[$i]{'borrowernumber'}); + # $fines=$fines+0; + if ($toggle eq 'white'){ + $toggle="#ffffcc"; + } else { + $toggle="white"; + } + print mktablerow(6,$toggle,$results->[$i]{'bookfundid'}.' ('.$results->[$i]{'bookfundname'}.')', + $results->[$i]{'startdate'},$results->[$i]{'enddate'}, + $results->[$i]{'budgetamount'}, + mklink("$script_name?op=add_form&bookfundid=".$results->[$i]{'bookfundid'},'Edit'), + mklink("$script_name?op=delete_confirm&bookfundid=".$results->[$i]{'bookfundid'},'Delete','')); + } + print mktableft; + print "

"; + print ""; + if ($offset>0) { + my $prevpage = $offset-$pagesize; + print mklink("$script_name?offset=".$prevpage,'<< Prev'); + } + print "      "; + if ($offset+$pagesize<$count) { + my $nextpage =$offset+$pagesize; + print mklink("$script_name?offset=".$nextpage,'Next >>'); + } + print "

"; + print "
"; +} #---- END $OP eq DEFAULT +print endmenu('admin'); +print endpage(); diff --git a/admin/branches.pl b/admin/branches.pl new file mode 100755 index 0000000000..d8bee7e164 --- /dev/null +++ b/admin/branches.pl @@ -0,0 +1,280 @@ +#!/usr/bin/perl + +#script to administer the aqbudget table +#written 20/02/2002 by paul.poulain@free.fr +# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) + +# ALGO : +# this script use an $op to know what to do. +# if $op is empty or none of the above values, +# - the default screen is build (with all records, or filtered datas). +# - the user can clic on add, modify or delete record. +# if $op=add_form +# - if primkey exists, this is a modification,so we read the $primkey record +# - builds the add/modify form +# if $op=add_validate +# - the user has just send datas, so we create/modify the record +# if $op=delete_form +# - we show the record having primkey=$primkey and ask for deletion validation form +# if $op=delete_confirm +# - we delete the record having primkey=$primkey + +use strict; +use C4::Output; +use CGI; +use C4::Search; +use C4::Database; + +sub StringSearch { + my ($env,$searchstring,$type)=@_; + my $dbh = &C4Connect; + $searchstring=~ s/\'/\\\'/g; + my @data=split(' ',$searchstring); + my $count=@data; + my $query="Select branchcode,branchname,branchaddress1,branchaddress2,branchaddress3,branchphone,branchfax,branchemail,issuing from branches where (branchcode like \"$data[0]%\") order by branchcode"; + my $sth=$dbh->prepare($query); + $sth->execute; + my @results; + my $cnt=0; + while (my $data=$sth->fetchrow_hashref){ + push(@results,$data); + $cnt ++; + } + # $sth->execute; + $sth->finish; + $dbh->disconnect; + return ($cnt,\@results); +} + +my $input = new CGI; +my $searchfield=$input->param('searchfield'); +my $pkfield="branchcode"; +my $reqsel="select branchcode,branchname,branchaddress1,branchaddress2,branchaddress3,branchphone,branchfax,branchemail,issuing from branches where branchcode='$searchfield'"; +my $reqdel="delete from branches where branchcode='$searchfield'"; +#my $branchcode=$input->param('branchcode'); +my $offset=$input->param('offset'); +my $script_name="/cgi-bin/koha/admin/branches.pl"; + +my $pagesize=20; +my $op = $input->param('op'); +$searchfield=~ s/\,//g; +print $input->header; + +#start the page and read in includes +print startpage(); +print startmenu('admin'); + +################## ADD_FORM ################################## +# called by default. Used to create form to add or modify a record +if ($op eq 'add_form') { + #---- if primkey exists, it's a modify action, so read values to modify... + my $data; + if ($searchfield) { + my $dbh = &C4Connect; + my $sth=$dbh->prepare("select branchcode,branchname,branchaddress1,branchaddress2,branchaddress3,branchphone,branchfax,branchemail,issuing from branches where branchcode='$searchfield'"); + $sth->execute; + $data=$sth->fetchrow_hashref; + $sth->finish; + } + print < + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNotNull(f,noalert) { + if (f.value.length ==0) { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function toUC(f) { + var x=f.value.toUpperCase(); + f.value=x; + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNum(v,maybenull) { + var n = new Number(v.value); + if (isNaN(n)) { + return false; + } + if (maybenull==0 && v.value=='') { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isDate(f) { + var t = Date.parse(f.value); + if (isNaN(t)) { + return false; + } + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function Check(f) { + var ok=1; + var _alertString=""; + var alertString2; + if (f.searchfield.value.length==0) { + _alertString += "- branch code missing\\n"; + } + if (f.branchname.value.length==0) { + _alertString += "- branch name missing\\n"; + } + if (_alertString.length==0) { + document.Aform.submit(); + } else { + alertString2 = "Form not submitted because of the following problem(s)\\n"; + alertString2 += "------------------------------------------------------------------------------------\\n\\n"; + alertString2 += _alertString; + alert(alertString2); + } + } + +printend +;#/ + if ($searchfield) { + print "

Modify branch

"; + } else { + print "

Add branch

"; + } + print "
"; + print ""; + print ""; + if ($searchfield) { + print ""; + } else { + print ""; + } + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "
Branch code$searchfield
Branch code
Name 
Adress
 
 
Phone
Fax
E-mail
Issuing
 
"; + print "
"; +; + # END $OP eq ADD_FORM +################## ADD_VALIDATE ################################## +# called by add_form, used to insert/modify data in DB +} elsif ($op eq 'add_validate') { + my $dbh=C4Connect; + my $query = "replace branches (branchcode,branchname,branchaddress1,branchaddress2,branchaddress3,branchphone,branchfax,branchemail,issuing) values ("; + $query.= $dbh->quote($input->param('branchcode')).","; + $query.= $dbh->quote($input->param('branchname')).","; + $query.= $dbh->quote($input->param('branchaddress1')).","; + $query.= $dbh->quote($input->param('branchaddress2')).","; + $query.= $dbh->quote($input->param('branchaddress3')).","; + $query.= $dbh->quote($input->param('branchphone')).","; + $query.= $dbh->quote($input->param('branchfax')).","; + $query.= $dbh->quote($input->param('branchemail')).","; + $query.= $dbh->quote($input->param('issuing')).")"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + print "data recorded"; + print "
"; + print ""; + print "
"; + # END $OP eq ADD_VALIDATE +################## DELETE_CONFIRM ################################## +# called by default form, used to confirm deletion of data in DB +} elsif ($op eq 'delete_confirm') { + my $dbh = &C4Connect; + my $sth=$dbh->prepare("select count(*) as total from borrowers where branchcode='$searchfield'"); + $sth->execute; + my $total = $sth->fetchrow_hashref; + $sth->finish; + print "$reqsel"; + my $sth=$dbh->prepare($reqsel); + $sth->execute; + my $data=$sth->fetchrow_hashref; + $sth->finish; + print mktablehdr; + print mktablerow(2,'#99cc33',bold('Branch code'),bold("$searchfield"),'/images/background-mem.gif'); + print "
"; + print "Branch code$data->{'branchcode'}"; + print "  name$data->{'branchname'}"; + print "  adress$data->{'branchaddress1'}"; + print " $data->{'branchaddress2'}"; + print " $data->{'branchaddress3'}"; + print " phone$data->{'branchphone'}"; + print "  fax$data->{'branchfax'}"; + print "  e-mail$data->{'branchemail'}"; + print "  issuing$data->{'issuing'}"; + if ($total->{'total'} >0) { + print "This record is used $total->{'total'} times. Deletion not possible"; + print "
"; + } else { + print "CONFIRM DELETION"; + print "
"; + } + # END $OP eq DELETE_CONFIRM +################## DELETE_CONFIRMED ################################## +# called by delete_confirm, used to effectively confirm deletion of data in DB +} elsif ($op eq 'delete_confirmed') { + my $dbh=C4Connect; +# my $searchfield=$input->param('branchcode'); + my $sth=$dbh->prepare($reqdel); + $sth->execute; + $sth->finish; + print "data deleted"; + print "
"; + print ""; + print "
"; + # END $OP eq DELETE_CONFIRMED +################## DEFAULT ################################## +} else { # DEFAULT + my @inputs=(["text","searchfield",$searchfield], + ["reset","reset","clr"]); + print mkheadr(2,'branches admin'); + print mkformnotable("$script_name",@inputs); + print <$searchfield

"; + } + print mktablehdr; + print mktablerow(9,'#99cc33',bold('Branch code'),bold('name'),bold('adress'), + bold('phone'),bold('fax'),bold('mail'),bold('issuing'), + ' ',' ','/images/background-mem.gif'); + my $env; + my ($count,$results)=StringSearch($env,$searchfield,'web'); + my $toggle="white"; + for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){ + #find out stats + # my ($od,$issue,$fines)=categdata2($env,$results->[$i]{'borrowernumber'}); + # $fines=$fines+0; + if ($toggle eq 'white'){ + $toggle="#ffffcc"; + } else { + $toggle="white"; + } + print mktablerow(9,$toggle,$results->[$i]{'branchcode'},$results->[$i]{'branchname'}, + $results->[$i]{'branchaddress1'}.$results->[$i]{'branchaddress2'}.$results->[$i]{'branchaddress3'}, + $results->[$i]{'branchphone'},,$results->[$i]{'branchfax'},,$results->[$i]{'branchmail'},,$results->[$i]{'issuing'}, + mklink("$script_name?op=add_form&searchfield=".$results->[$i]{'branchcode'},'Edit'), + mklink("$script_name?op=delete_confirm&searchfield=".$results->[$i]{'branchcode'},'Delete','')); + } + print mktableft; + print "

"; + print ""; + if ($offset>0) { + my $prevpage = $offset-$pagesize; + print mklink("$script_name?offset=".$prevpage,'<< Prev'); + } + print "      "; + if ($offset+$pagesize<$count) { + my $nextpage =$offset+$pagesize; + print mklink("$script_name?offset=".$nextpage,'Next >>'); + } + print "

"; + print "
"; +} #---- END $OP eq DEFAULT +print endmenu('admin'); +print endpage(); diff --git a/admin/categorie.pl b/admin/categorie.pl new file mode 100755 index 0000000000..08dab8513c --- /dev/null +++ b/admin/categorie.pl @@ -0,0 +1,275 @@ +#!/usr/bin/perl + +#script to administer the categories table +#written 20/02/2002 by paul.poulain@free.fr + +# ALGO : +# this script use an $op to know what to do. +# if $op is empty or none of the above values, +# - the default screen is build (with all records, or filtered datas). +# - the user can clic on add, modify or delete record. +# if $op=add_form +# - if primkey exists, this is a modification,so we read the $primkey record +# - builds the add/modify form +# if $op=add_validate +# - the user has just send datas, so we create/modify the record +# if $op=delete_form +# - we show the record having primkey=$primkey and ask for deletion validation form +# if $op=delete_confirm +# - we delete the record having primkey=$primkey + +use strict; +use C4::Output; +use CGI; +use C4::Search; +use C4::Database; + +sub StringSearch { + my ($env,$searchstring,$type)=@_; + my $dbh = &C4Connect; + $searchstring=~ s/\'/\\\'/g; + my @data=split(' ',$searchstring); + my $count=@data; + my $query="Select * from categories where (description like \"$data[0]%\")"; + my $sth=$dbh->prepare($query); + $sth->execute; + my @results; + my $cnt=0; + while (my $data=$sth->fetchrow_hashref){ + push(@results,$data); + $cnt ++; + } + # $sth->execute; + $sth->finish; + $dbh->disconnect; + return ($cnt,\@results); +} + +my $input = new CGI; +my $searchfield=$input->param('description'); +my $script_name="/cgi-bin/koha/admin/categorie.pl"; +my $categorycode=$input->param('categorycode'); +my $op = $input->param('op'); +$searchfield=~ s/\,//g; +print $input->header; +#start the page and read in includes +print startpage(); +print startmenu('admin'); + +################## ADD_FORM ################################## +# called by default. Used to create form to add or modify a record +if ($op eq 'add_form') { + #---- if primkey exists, it's a modify action, so read values to modify... + my $data; + if ($categorycode) { + my $dbh = &C4Connect; + my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,finetype,bulk,enrolmentfee,issuelimit,reservefee,overduenoticerequired from categories where categorycode='$categorycode'"); + $sth->execute; + $data=$sth->fetchrow_hashref; + $sth->finish; + } + print < + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNotNull(f,noalert) { + if (f.value.length ==0) { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function toUC(f) { + var x=f.value.toUpperCase(); + f.value=x; + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNum(v,maybenull) { + var n = new Number(v.value); + if (isNaN(n)) { + return false; + } + if (maybenull==0 && v.value=='') { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isDate(f) { + var t = Date.parse(f.value); + if (isNaN(t)) { + return false; + } + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function Check(f) { + var ok=1; + var _alertString=""; + var alertString2; + if (f.categorycode.value.length==0) { + _alertString += "- categorycode missing\\n"; + } +// alert(window.document.Aform.description.value); + if (!(isNotNull(window.document.Aform.description,1))) { + _alertString += "- description missing\\n"; + } + if (!isNum(f.upperagelimit,0)) { + _alertString += "- upperagelimit is not a number\\n"; + } + if (_alertString.length==0) { + document.Aform.submit(); + } else { + alertString2 = "Form not submitted because of the following problem(s)\\n"; + alertString2 += "------------------------------------------------------------------------------------\\n\\n"; + alertString2 += _alertString; + alert(alertString2); + } + } + +printend +;#/ + if ($categorycode) { + print "

Modify category

"; + } else { + print "

Add category

"; + } + print "
"; + print ""; + print ""; + print ""; + if ($categorycode) { + print ""; + } else { + print ""; + } + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; +print "
Category code$categorycode
Category code
Description 
Enrolment period
Upperage limit
Date of birth Required (14/02/2002)
Fine type
Bulk
Enrolment fee
Overdue notice required
Issue limit
Reserve fee
 
"; + print "
"; +; + # END $OP eq ADD_FORM +################## ADD_VALIDATE ################################## +# called by add_form, used to insert/modify data in DB +} elsif ($op eq 'add_validate') { + my $dbh=C4Connect; + my $query = "replace categories (categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,finetype,bulk,enrolmentfee,issuelimit,reservefee,overduenoticerequired) values ("; + $query.= $dbh->quote($input->param('categorycode')).","; + $query.= $dbh->quote($input->param('description')).","; + $query.= $dbh->quote($input->param('enrolmentperiod')).","; + $query.= $dbh->quote($input->param('upperagelimit')).","; + $query.= $dbh->quote($input->param('dateofbirthrequired')).","; + $query.= $dbh->quote($input->param('finetype')).","; + $query.= $dbh->quote($input->param('bulk')).","; + $query.= $dbh->quote($input->param('enrolmentfee')).","; + $query.= $dbh->quote($input->param('issuelimit')).","; + $query.= $dbh->quote($input->param('reservefee')).","; + $query.= $dbh->quote($input->param('overduenoticerequired')).")"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + print "data recorded"; + print "
"; + print ""; + print "
"; + # END $OP eq ADD_VALIDATE +################## DELETE_CONFIRM ################################## +# called by default form, used to confirm deletion of data in DB +} elsif ($op eq 'delete_confirm') { + my $dbh = &C4Connect; + my $sth=$dbh->prepare("select count(*) as total from categoryitem where categorycode='$categorycode'"); + $sth->execute; + my $total = $sth->fetchrow_hashref; + print "TOTAL : $categorycode : $total->{'total'}
"; + $sth->finish; + my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,finetype,bulk,enrolmentfee,issuelimit,reservefee,overduenoticerequired from categories where categorycode='$categorycode'"); + $sth->execute; + my $data=$sth->fetchrow_hashref; + $sth->finish; + print mktablehdr; + print mktablerow(2,'#99cc33',bold('Category code'),bold("$categorycode"),'/images/background-mem.gif'); + print "
"; + print "Description$data->{'description'}"; + print "Enrolment period$data->{'enrolmentperiod'}"; + print "Upperage limit$data->{'upperagelimit'}"; + print "Date of birth Required$data->{'dateofbirthrequired'}"; + print "Fine type$data->{'finetype'}"; + print "Bulk$data->{'bulk'}"; + print "Enrolment fee$data->{'enrolmentfee'}"; + print "Overdue notice required$data->{'overduenoticerequired'}"; + print "Issue limit$data->{'issuelimit'}"; + print "Reserve fee$data->{'reservefee'}"; + if ($total->{'total'} >0) { + print "This record is used $total->{'total'} times. Deletion not possible"; + print "
"; + } else { + print "CONFIRM DELETION"; + print "
"; + } + # END $OP eq DELETE_CONFIRM +################## DELETE_CONFIRMED ################################## +# called by delete_confirm, used to effectively confirm deletion of data in DB +} elsif ($op eq 'delete_confirmed') { + my $dbh=C4Connect; + my $categorycode=uc($input->param('categorycode')); + my $query = "delete from categories where categorycode='$categorycode'"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + print "data deleted"; + print "
"; + print ""; + print "
"; + # END $OP eq DELETE_CONFIRMED +} else { # DEFAULT + my @inputs=(["text","description",$searchfield], + ["reset","reset","clr"]); + print mkheadr(2,'Category admin'); + print mkformnotable("$script_name",@inputs); + print <"; + } + print mktablehdr; + print mktablerow(13,'#99cc33',bold('Category'),bold('Description'),bold('Enrolment'),bold('age max') + ,bold('birth needed'),bold('Fine'),bold('Bulk'),bold('fee'),bold('overdue'),bold('Issue limit'),bold('Reserve'),' ',' ','/images/background-mem.gif'); + my $env; + my ($count,$results)=StringSearch($env,$searchfield,'web'); + my $toggle="white"; + for (my $i=0; $i < $count; $i++){ + #find out stats + # my ($od,$issue,$fines)=categdata2($env,$results->[$i]{'borrowernumber'}); + # $fines=$fines+0; + if ($toggle eq 'white'){ + $toggle="#ffffcc"; + } else { + $toggle="white"; + } + print mktablerow(13,$toggle,$results->[$i]{'categorycode'}, + $results->[$i]{'description'},$results->[$i]{'enrolmentperiod'}, + $results->[$i]{'upperagelimit'},$results->[$i]{'dateofbirthrequired'},$results->[$i]{'finetype'}, + $results->[$i]{'bulk'},$results->[$i]{'enrolmentfee'},$results->[$i]{'overduenoticerequired'},$results->[$i]{'issuelimit'},$results->[$i]{'reservefee'},mklink("$script_name?op=add_form&categorycode=".$results->[$i]{'categorycode'},'Edit'), + mklink("$script_name?op=delete_confirm&categorycode=".$results->[$i]{'categorycode'},'Delete')); + } + print mktableft; +print < + +
+ +printend + ; +} #---- END $OP eq DEFAULT +print endmenu('categorie'); +print endpage(); diff --git a/admin/categoryitem.pl b/admin/categoryitem.pl new file mode 100644 index 0000000000..cc7f39c710 --- /dev/null +++ b/admin/categoryitem.pl @@ -0,0 +1,276 @@ +#!/usr/bin/perl + +#script to administer the categories table +#written 20/02/2002 by paul.poulain@free.fr +# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) + +# ALGO : +# this script use an $op to know what to do. +# if $op is empty or none of the above values, +# - the default screen is build (with all records, or filtered datas). +# - the user can clic on add, modify or delete record. +# if $op=add_form +# - if primkey exists, this is a modification,so we read the $primkey record +# - builds the add/modify form +# if $op=add_validate +# - the user has just send datas, so we create/modify the record +# if $op=delete_form +# - we show the record having primkey=$primkey and ask for deletion validation form +# if $op=delete_confirm +# - we delete the record having primkey=$primkey + +use strict; +use C4::Output; +use CGI; +use C4::Search; +use C4::Database; + +sub StringSearch { + my ($env,$searchstring,$type)=@_; + my $dbh = &C4Connect; + $searchstring=~ s/\'/\\\'/g; + my @data=split(' ',$searchstring); + my $count=@data; + my $query="Select * from categories where (description like \"$data[0]%\")"; + my $sth=$dbh->prepare($query); + $sth->execute; + my @results; + my $cnt=0; + while (my $data=$sth->fetchrow_hashref){ + push(@results,$data); + $cnt ++; + } + # $sth->execute; + $sth->finish; + $dbh->disconnect; + return ($cnt,\@results); +} + +my $input = new CGI; +my $searchfield=$input->param('description'); +my $script_name="/cgi-bin/koha/admin/categorie.pl"; +my $categorycode=$input->param('categorycode'); +my $op = $input->param('op'); +$searchfield=~ s/\,//g; +print $input->header; +#start the page and read in includes +print startpage(); +print startmenu('admin'); + +################## ADD_FORM ################################## +# called by default. Used to create form to add or modify a record +if ($op eq 'add_form') { + #---- if primkey exists, it's a modify action, so read values to modify... + my $data; + if ($categorycode) { + my $dbh = &C4Connect; + my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,finetype,bulk,enrolmentfee,issuelimit,reservefee,overduenoticerequired from categories where categorycode='$categorycode'"); + $sth->execute; + $data=$sth->fetchrow_hashref; + $sth->finish; + } + print < + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNotNull(f,noalert) { + if (f.value.length ==0) { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function toUC(f) { + var x=f.value.toUpperCase(); + f.value=x; + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNum(v,maybenull) { + var n = new Number(v.value); + if (isNaN(n)) { + return false; + } + if (maybenull==0 && v.value=='') { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isDate(f) { + var t = Date.parse(f.value); + if (isNaN(t)) { + return false; + } + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function Check(f) { + var ok=1; + var _alertString=""; + var alertString2; + if (f.categorycode.value.length==0) { + _alertString += "- categorycode missing\\n"; + } +// alert(window.document.Aform.description.value); + if (!(isNotNull(window.document.Aform.description,1))) { + _alertString += "- description missing\\n"; + } + if (!isNum(f.upperagelimit,0)) { + _alertString += "- upperagelimit is not a number\\n"; + } + if (_alertString.length==0) { + document.Aform.submit(); + } else { + alertString2 = "Form not submitted because of the following problem(s)\\n"; + alertString2 += "------------------------------------------------------------------------------------\\n\\n"; + alertString2 += _alertString; + alert(alertString2); + } + } + +printend +;#/ + if ($categorycode) { + print "

Modify category

"; + } else { + print "

Add category

"; + } + print "
"; + print ""; + print ""; + print ""; + if ($categorycode) { + print ""; + } else { + print ""; + } + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; +print "
Category code$categorycode
Category code
Description 
Enrolment period
Upperage limit
Date of birth Required (14/02/2002)
Fine type
Bulk
Enrolment fee
Overdue notice required
Issue limit
Reserve fee
 
"; + print "
"; +; + # END $OP eq ADD_FORM +################## ADD_VALIDATE ################################## +# called by add_form, used to insert/modify data in DB +} elsif ($op eq 'add_validate') { + my $dbh=C4Connect; + my $query = "replace categories (categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,finetype,bulk,enrolmentfee,issuelimit,reservefee,overduenoticerequired) values ("; + $query.= $dbh->quote($input->param('categorycode')).","; + $query.= $dbh->quote($input->param('description')).","; + $query.= $dbh->quote($input->param('enrolmentperiod')).","; + $query.= $dbh->quote($input->param('upperagelimit')).","; + $query.= $dbh->quote($input->param('dateofbirthrequired')).","; + $query.= $dbh->quote($input->param('finetype')).","; + $query.= $dbh->quote($input->param('bulk')).","; + $query.= $dbh->quote($input->param('enrolmentfee')).","; + $query.= $dbh->quote($input->param('issuelimit')).","; + $query.= $dbh->quote($input->param('reservefee')).","; + $query.= $dbh->quote($input->param('overduenoticerequired')).")"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + print "data recorded"; + print "
"; + print ""; + print "
"; + # END $OP eq ADD_VALIDATE +################## DELETE_CONFIRM ################################## +# called by default form, used to confirm deletion of data in DB +} elsif ($op eq 'delete_confirm') { + my $dbh = &C4Connect; + my $sth=$dbh->prepare("select count(*) as total from categoryitem where categorycode='$categorycode'"); + $sth->execute; + my $total = $sth->fetchrow_hashref; + print "TOTAL : $categorycode : $total->{'total'}
"; + $sth->finish; + my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,finetype,bulk,enrolmentfee,issuelimit,reservefee,overduenoticerequired from categories where categorycode='$categorycode'"); + $sth->execute; + my $data=$sth->fetchrow_hashref; + $sth->finish; + print mktablehdr; + print mktablerow(2,'#99cc33',bold('Category code'),bold("$categorycode"),'/images/background-mem.gif'); + print "
"; + print "Description$data->{'description'}"; + print "Enrolment period$data->{'enrolmentperiod'}"; + print "Upperage limit$data->{'upperagelimit'}"; + print "Date of birth Required$data->{'dateofbirthrequired'}"; + print "Fine type$data->{'finetype'}"; + print "Bulk$data->{'bulk'}"; + print "Enrolment fee$data->{'enrolmentfee'}"; + print "Overdue notice required$data->{'overduenoticerequired'}"; + print "Issue limit$data->{'issuelimit'}"; + print "Reserve fee$data->{'reservefee'}"; + if ($total->{'total'} >0) { + print "This record is used $total->{'total'} times. Deletion not possible"; + print "
"; + } else { + print "CONFIRM DELETION"; + print "
"; + } + # END $OP eq DELETE_CONFIRM +################## DELETE_CONFIRMED ################################## +# called by delete_confirm, used to effectively confirm deletion of data in DB +} elsif ($op eq 'delete_confirmed') { + my $dbh=C4Connect; + my $categorycode=uc($input->param('categorycode')); + my $query = "delete from categories where categorycode='$categorycode'"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + print "data deleted"; + print "
"; + print ""; + print "
"; + # END $OP eq DELETE_CONFIRMED +} else { # DEFAULT + my @inputs=(["text","description",$searchfield], + ["reset","reset","clr"]); + print mkheadr(2,'Category admin'); + print mkformnotable("$script_name",@inputs); + print <"; + } + print mktablehdr; + print mktablerow(13,'#99cc33',bold('Category'),bold('Description'),bold('Enrolment'),bold('age max') + ,bold('birth needed'),bold('Fine'),bold('Bulk'),bold('fee'),bold('overdue'),bold('Issue limit'),bold('Reserve'),' ',' ','/images/background-mem.gif'); + my $env; + my ($count,$results)=StringSearch($env,$searchfield,'web'); + my $toggle="white"; + for (my $i=0; $i < $count; $i++){ + #find out stats + # my ($od,$issue,$fines)=categdata2($env,$results->[$i]{'borrowernumber'}); + # $fines=$fines+0; + if ($toggle eq 'white'){ + $toggle="#ffffcc"; + } else { + $toggle="white"; + } + print mktablerow(13,$toggle,$results->[$i]{'categorycode'}, + $results->[$i]{'description'},$results->[$i]{'enrolmentperiod'}, + $results->[$i]{'upperagelimit'},$results->[$i]{'dateofbirthrequired'},$results->[$i]{'finetype'}, + $results->[$i]{'bulk'},$results->[$i]{'enrolmentfee'},$results->[$i]{'overduenoticerequired'},$results->[$i]{'issuelimit'},$results->[$i]{'reservefee'},mklink("$script_name?op=add_form&categorycode=".$results->[$i]{'categorycode'},'Edit'), + mklink("$script_name?op=delete_confirm&categorycode=".$results->[$i]{'categorycode'},'Delete')); + } + print mktableft; +print < + +
+ +printend + ; +} #---- END $OP eq DEFAULT +print endmenu('categorie'); +print endpage(); diff --git a/admin/currency.pl b/admin/currency.pl new file mode 100755 index 0000000000..3f3fca5169 --- /dev/null +++ b/admin/currency.pl @@ -0,0 +1,254 @@ +#!/usr/bin/perl + +#script to administer the aqbudget table +#written 20/02/2002 by paul.poulain@free.fr +# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) + +# ALGO : +# this script use an $op to know what to do. +# if $op is empty or none of the above values, +# - the default screen is build (with all records, or filtered datas). +# - the user can clic on add, modify or delete record. +# if $op=add_form +# - if primkey exists, this is a modification,so we read the $primkey record +# - builds the add/modify form +# if $op=add_validate +# - the user has just send datas, so we create/modify the record +# if $op=delete_form +# - we show the record having primkey=$primkey and ask for deletion validation form +# if $op=delete_confirm +# - we delete the record having primkey=$primkey + +use strict; +use C4::Output; +use CGI; +use C4::Search; +use C4::Database; + +sub StringSearch { + my ($env,$searchstring,$type)=@_; + my $dbh = &C4Connect; + $searchstring=~ s/\'/\\\'/g; + my @data=split(' ',$searchstring); + my $count=@data; + my $query="Select currency,rate from currency where (currency like \"$data[0]%\") order by currency"; + my $sth=$dbh->prepare($query); + $sth->execute; + my @results; + my $cnt=0; + while (my $data=$sth->fetchrow_hashref){ + push(@results,$data); + $cnt ++; + } + # $sth->execute; + $sth->finish; + $dbh->disconnect; + return ($cnt,\@results); +} + +my $input = new CGI; +my $searchfield=$input->param('searchfield'); +my $pkfield="currency"; +my $reqsel="select currency,rate from currency where $pkfield='$searchfield'"; +my $reqdel="delete from currency where $pkfield='$searchfield'"; +#my $branchcode=$input->param('branchcode'); +my $offset=$input->param('offset'); +my $script_name="/cgi-bin/koha/admin/currency.pl"; + +my $pagesize=20; +my $op = $input->param('op'); +$searchfield=~ s/\,//g; +print $input->header; + +#start the page and read in includes +print startpage(); +print startmenu('admin'); + +################## ADD_FORM ################################## +# called by default. Used to create form to add or modify a record +if ($op eq 'add_form') { + #---- if primkey exists, it's a modify action, so read values to modify... + my $data; + if ($searchfield) { + my $dbh = &C4Connect; + my $sth=$dbh->prepare("select currency,rate from currency where currency='$searchfield'"); + $sth->execute; + $data=$sth->fetchrow_hashref; + $sth->finish; + } + print < + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNotNull(f,noalert) { + if (f.value.length ==0) { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function toUC(f) { + var x=f.value.toUpperCase(); + f.value=x; + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNum(v,maybenull) { + var n = new Number(v.value); + if (isNaN(n)) { + return false; + } + if (maybenull==0 && v.value=='') { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isDate(f) { + var t = Date.parse(f.value); + if (isNaN(t)) { + return false; + } + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function Check(f) { + var ok=1; + var _alertString=""; + var alertString2; + if (f.currency.value.length==0) { + _alertString += "- currency missing\\n"; + } + if (!isNum(f.rate)) { + _alertString += "- Rate not numeric\\n"; + } + if (_alertString.length==0) { + document.Aform.submit(); + } else { + alertString2 = "Form not submitted because of the following problem(s)\\n"; + alertString2 += "------------------------------------------------------------------------------------\\n\\n"; + alertString2 += _alertString; + alert(alertString2); + } + } + +printend +;#/ + if ($searchfield) { + print "

Modify currency

"; + } else { + print "

Add currency

"; + } + print "
"; + print ""; + print ""; + if ($searchfield) { + print ""; + } else { + print ""; + } + print ""; + print ""; + print "
Currency$searchfield
Currency
Rate 
 
"; + print "
"; +; + # END $OP eq ADD_FORM +################## ADD_VALIDATE ################################## +# called by add_form, used to insert/modify data in DB +} elsif ($op eq 'add_validate') { + my $dbh=C4Connect; + my $query = "replace currency (currency,rate) values ("; + $query.= $dbh->quote($input->param('currency')).","; + $query.= $dbh->quote($input->param('rate')).")"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + print "data recorded"; + print "
"; + print ""; + print "
"; + # END $OP eq ADD_VALIDATE +################## DELETE_CONFIRM ################################## +# called by default form, used to confirm deletion of data in DB +} elsif ($op eq 'delete_confirm') { + my $dbh = &C4Connect; + my $sth=$dbh->prepare("select count(*) as total from aqbooksellers where currency='$searchfield'"); + $sth->execute; + my $total = $sth->fetchrow_hashref; + $sth->finish; + my $sth=$dbh->prepare($reqsel); + $sth->execute; + my $data=$sth->fetchrow_hashref; + $sth->finish; + print mktablehdr; + print mktablerow(2,'#99cc33',bold('Currency'),bold("$searchfield"),'/images/background-mem.gif'); + print "
"; + print "Rate$data->{'rate'}"; + if ($total->{'total'} >0) { + print "This record is used $total->{'total'} times. Deletion not possible"; + print "
"; + } else { + print "CONFIRM DELETION"; + print "
"; + } + # END $OP eq DELETE_CONFIRM +################## DELETE_CONFIRMED ################################## +# called by delete_confirm, used to effectively confirm deletion of data in DB +} elsif ($op eq 'delete_confirmed') { + my $dbh=C4Connect; +# my $searchfield=$input->param('branchcode'); + my $sth=$dbh->prepare($reqdel); + $sth->execute; + $sth->finish; + print "data deleted"; + print "
"; + print ""; + print "
"; + # END $OP eq DELETE_CONFIRMED +################## DEFAULT ################################## +} else { # DEFAULT + my @inputs=(["text","searchfield",$searchfield], + ["reset","reset","clr"]); + print mkheadr(2,'Currencies admin'); + print mkformnotable("$script_name",@inputs); + print <$searchfield

"; + } + print mktablehdr; + print mktablerow(4,'#99cc33',bold('Currency'),bold('Rate'), + ' ',' ','/images/background-mem.gif'); + my $env; + my ($count,$results)=StringSearch($env,$searchfield,'web'); + my $toggle="white"; + for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){ + #find out stats + # my ($od,$issue,$fines)=categdata2($env,$results->[$i]{'borrowernumber'}); + # $fines=$fines+0; + if ($toggle eq 'white'){ + $toggle="#ffffcc"; + } else { + $toggle="white"; + } + print mktablerow(4,$toggle,$results->[$i]{'currency'},$results->[$i]{'rate'}, + mklink("$script_name?op=add_form&searchfield=".$results->[$i]{'currency'},'Edit'), + mklink("$script_name?op=delete_confirm&searchfield=".$results->[$i]{'currency'},'Delete','')); + } + print mktableft; + print "

"; + print ""; + if ($offset>0) { + my $prevpage = $offset-$pagesize; + print mklink("$script_name?offset=".$prevpage,'<< Prev'); + } + print "      "; + if ($offset+$pagesize<$count) { + my $nextpage =$offset+$pagesize; + print mklink("$script_name?offset=".$nextpage,'Next >>'); + } + print "

"; + print "
"; +} #---- END $OP eq DEFAULT +print endmenu('admin'); +print endpage(); diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl new file mode 100755 index 0000000000..4983518426 --- /dev/null +++ b/admin/itemtypes.pl @@ -0,0 +1,278 @@ +#!/usr/bin/perl + +#script to administer the categories table +#written 20/02/2002 by paul.poulain@free.fr +# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) + +# ALGO : +# this script use an $op to know what to do. +# if $op is empty or none of the above values, +# - the default screen is build (with all records, or filtered datas). +# - the user can clic on add, modify or delete record. +# if $op=add_form +# - if primkey exists, this is a modification,so we read the $primkey record +# - builds the add/modify form +# if $op=add_validate +# - the user has just send datas, so we create/modify the record +# if $op=delete_form +# - we show the record having primkey=$primkey and ask for deletion validation form +# if $op=delete_confirm +# - we delete the record having primkey=$primkey + +use strict; +use C4::Output; +use CGI; +use C4::Search; +use C4::Database; + +sub StringSearch { + my ($env,$searchstring,$type)=@_; + my $dbh = &C4Connect; + $searchstring=~ s/\'/\\\'/g; + my @data=split(' ',$searchstring); + my $count=@data; + my $query="Select * from itemtypes where (description like \"$data[0]%\") order by itemtype"; + my $sth=$dbh->prepare($query); + $sth->execute; + my @results; + my $cnt=0; + while (my $data=$sth->fetchrow_hashref){ + push(@results,$data); + $cnt ++; + } + # $sth->execute; + $sth->finish; + $dbh->disconnect; + return ($cnt,\@results); +} + +my $input = new CGI; +my $searchfield=$input->param('description'); +my $offset=$input->param('offset'); +my $script_name="/cgi-bin/koha/admin/itemtypes.pl"; +my $itemtype=$input->param('itemtype'); +my $pagesize=20; +my $op = $input->param('op'); +$searchfield=~ s/\,//g; +print $input->header; + +#start the page and read in includes +print startpage(); +print startmenu('admin'); + +################## ADD_FORM ################################## +# called by default. Used to create form to add or modify a record +if ($op eq 'add_form') { + #---- if primkey exists, it's a modify action, so read values to modify... + my $data; + if ($itemtype) { + my $dbh = &C4Connect; + my $sth=$dbh->prepare("select itemtype,description,loanlength,renewalsallowed,rentalcharge from itemtypes where itemtype='$itemtype'"); + $sth->execute; + $data=$sth->fetchrow_hashref; + $sth->finish; + } + print < + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNotNull(f,noalert) { + if (f.value.length ==0) { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function toUC(f) { + var x=f.value.toUpperCase(); + f.value=x; + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNum(v,maybenull) { + var n = new Number(v.value); + if (isNaN(n)) { + return false; + } + if (maybenull==0 && v.value=='') { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isDate(f) { + var t = Date.parse(f.value); + if (isNaN(t)) { + return false; + } + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function Check(f) { + var ok=1; + var _alertString=""; + var alertString2; + if (f.itemtype.value.length==0) { + _alertString += "- itemtype missing\\n"; + } + if (!(isNotNull(window.document.Aform.description,1))) { + _alertString += "- description missing\\n"; + } + if (!isNum(f.loanlength,0)) { + _alertString += "- loan length is not a number\\n"; + } + if (!isNum(f.rentalcharge,0)) { + _alertString += "- loan length is not a number\\n"; + } + if (_alertString.length==0) { + document.Aform.submit(); + } else { + alertString2 = "Form not submitted because of the following problem(s)\\n"; + alertString2 += "------------------------------------------------------------------------------------\\n\\n"; + alertString2 += _alertString; + alert(alertString2); + } + } + +printend +;#/ + if ($itemtype) { + print "

Modify item type

"; + } else { + print "

Add item type

"; + } + print "
"; + print ""; + print ""; + print ""; + if ($itemtype) { + print ""; + } else { + print ""; + } + print ""; + print ""; + if ($data->{'renewalsallowed'} eq 1) { + print ""; + } else { + print ""; + } +# print ""; + print ""; + print ""; +print "
Item type$itemtype
Item type
Description 
loan length
Renewals allowed
Renewals allowed
Renewals allowed
Rental charge
 
"; + print "
"; +; + # END $OP eq ADD_FORM +################## ADD_VALIDATE ################################## +# called by add_form, used to insert/modify data in DB +} elsif ($op eq 'add_validate') { + my $dbh=C4Connect; + my $query = "replace itemtypes (itemtype,description,loanlength,renewalsallowed,rentalcharge) values ("; + $query.= $dbh->quote($input->param('itemtype')).","; + $query.= $dbh->quote($input->param('description')).","; + $query.= $dbh->quote($input->param('loanlength')).","; + if ($input->param('renewalsallowed') ne 1) { + $query.= "0,"; + } else { + $query.= "1,"; + } + $query.= $dbh->quote($input->param('rentalcharge')).")"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + print "data recorded"; + print "
"; + print ""; + print "
"; + # END $OP eq ADD_VALIDATE +################## DELETE_CONFIRM ################################## +# called by default form, used to confirm deletion of data in DB +} elsif ($op eq 'delete_confirm') { + my $dbh = &C4Connect; + my $sth=$dbh->prepare("select count(*) as total from categoryitem where itemtype='$itemtype'"); + $sth->execute; + my $total = $sth->fetchrow_hashref; + $sth->finish; + my $sth=$dbh->prepare("select itemtype,description,loanlength,renewalsallowed,rentalcharge from itemtypes where itemtype='$itemtype'"); + $sth->execute; + my $data=$sth->fetchrow_hashref; + $sth->finish; + print mktablehdr; + print mktablerow(2,'#99cc33',bold('Item type'),bold("$itemtype"),'/images/background-mem.gif'); + print "
"; + print "Description$data->{'description'}"; + print "Loan length$data->{'loanlength'}"; + print "Renewals allowed$data->{'renewalsallowed'}"; + print "Rental charge$data->{'rentalcharge'}"; + if ($total->{'total'} >0) { + print "This record is used $total->{'total'} times. Deletion not possible"; + print "
"; + } else { + print "CONFIRM DELETION"; + print "
"; + } + # END $OP eq DELETE_CONFIRM +################## DELETE_CONFIRMED ################################## +# called by delete_confirm, used to effectively confirm deletion of data in DB +} elsif ($op eq 'delete_confirmed') { + my $dbh=C4Connect; + my $itemtype=uc($input->param('itemtype')); + my $query = "delete from itemtypes where itemtype='$itemtype'"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + print "data deleted"; + print "
"; + print ""; + print "
"; + # END $OP eq DELETE_CONFIRMED +################## DEFAULT ################################## +} else { # DEFAULT + my @inputs=(["text","description",$searchfield], + ["reset","reset","clr"]); + print mkheadr(2,'Item types admin'); + print mkformnotable("$script_name",@inputs); + print <$searchfield

"; + } + print mktablehdr; + print mktablerow(7,'#99cc33',bold('Code'),bold('Description'),bold('loan
length'),bold('Renewals
allowed') + ,bold('Rental
charge'),' ',' ','/images/background-mem.gif'); + my $env; + my ($count,$results)=StringSearch($env,$searchfield,'web'); + my $toggle="white"; + for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){ + #find out stats + # my ($od,$issue,$fines)=categdata2($env,$results->[$i]{'borrowernumber'}); + # $fines=$fines+0; + if ($toggle eq 'white'){ + $toggle="#ffffcc"; + } else { + $toggle="white"; + } + print mktablerow(7,$toggle,$results->[$i]{'itemtype'}, + $results->[$i]{'description'},$results->[$i]{'loanlength'}, + $results->[$i]{'renewalsallowed'}==1?'Yes':'No',$results->[$i]{'rentalcharge'}, + mklink("$script_name?op=add_form&itemtype=".$results->[$i]{'itemtype'},'Edit'), + mklink("$script_name?op=delete_confirm&itemtype=".$results->[$i]{'itemtype'},'Delete','')); + } + print mktableft; + print "

"; + print ""; + if ($offset>0) { + my $prevpage = $offset-$pagesize; + print mklink("$script_name?offset=".$prevpage,'<< Prev'); + } + print "      "; + if ($offset+$pagesize<$count) { + my $nextpage =$offset+$pagesize; + print mklink("$script_name?offset=".$nextpage,'Next >>'); + } + print "

"; + print "
"; +} #---- END $OP eq DEFAULT +print endmenu('admin'); +print endpage(); diff --git a/admin/printers.pl b/admin/printers.pl new file mode 100755 index 0000000000..92c92574f2 --- /dev/null +++ b/admin/printers.pl @@ -0,0 +1,245 @@ +#!/usr/bin/perl + +#script to administer the aqbudget table +#written 20/02/2002 by paul.poulain@free.fr +# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) + +# ALGO : +# this script use an $op to know what to do. +# if $op is empty or none of the above values, +# - the default screen is build (with all records, or filtered datas). +# - the user can clic on add, modify or delete record. +# if $op=add_form +# - if primkey exists, this is a modification,so we read the $primkey record +# - builds the add/modify form +# if $op=add_validate +# - the user has just send datas, so we create/modify the record +# if $op=delete_form +# - we show the record having primkey=$primkey and ask for deletion validation form +# if $op=delete_confirm +# - we delete the record having primkey=$primkey + +use strict; +use C4::Output; +use CGI; +use C4::Search; +use C4::Database; + +sub StringSearch { + my ($env,$searchstring,$type)=@_; + my $dbh = &C4Connect; + $searchstring=~ s/\'/\\\'/g; + my @data=split(' ',$searchstring); + my $count=@data; + my $query="Select printername,printqueue,printtype from printers where (printername like \"$data[0]%\") order by printername"; + my $sth=$dbh->prepare($query); + $sth->execute; + my @results; + my $cnt=0; + while (my $data=$sth->fetchrow_hashref){ + push(@results,$data); + $cnt ++; + } + # $sth->execute; + $sth->finish; + $dbh->disconnect; + return ($cnt,\@results); +} + +my $input = new CGI; +my $searchfield=$input->param('searchfield'); +my $pkfield="printername"; +my $reqsel="select printername,printqueue,printtype from printers where $pkfield='$searchfield'"; +my $reqdel="delete from printers where $pkfield='$searchfield'"; +#my $branchcode=$input->param('branchcode'); +my $offset=$input->param('offset'); +my $script_name="/cgi-bin/koha/admin/printers.pl"; + +my $pagesize=20; +my $op = $input->param('op'); +$searchfield=~ s/\,//g; +print $input->header; + +#start the page and read in includes +print startpage(); +print startmenu('admin'); + +################## ADD_FORM ################################## +# called by default. Used to create form to add or modify a record +if ($op eq 'add_form') { + #---- if primkey exists, it's a modify action, so read values to modify... + my $data; + if ($searchfield) { + my $dbh = &C4Connect; + my $sth=$dbh->prepare("select printername,printqueue,printtype from printers where printername='$searchfield'"); + $sth->execute; + $data=$sth->fetchrow_hashref; + $sth->finish; + } + print < + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNotNull(f,noalert) { + if (f.value.length ==0) { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function toUC(f) { + var x=f.value.toUpperCase(); + f.value=x; + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNum(v,maybenull) { + var n = new Number(v.value); + if (isNaN(n)) { + return false; + } + if (maybenull==0 && v.value=='') { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isDate(f) { + var t = Date.parse(f.value); + if (isNaN(t)) { + return false; + } + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function Check(f) { + var ok=1; + var _alertString=""; + var alertString2; + if (f.printername.value.length==0) { + _alertString += "- printer name missing\\n"; + } + if (f.printqueue.value.length==0) { + _alertString += "- Queue missing\\n"; + } + if (_alertString.length==0) { + document.Aform.submit(); + } else { + alertString2 = "Form not submitted because of the following problem(s)\\n"; + alertString2 += "------------------------------------------------------------------------------------\\n\\n"; + alertString2 += _alertString; + alert(alertString2); + } + } + +printend +;#/ + if ($searchfield) { + print "

Modify printer

"; + } else { + print "

Add printer

"; + } + print "
"; + print ""; + print ""; + if ($searchfield) { + print ""; + } else { + print ""; + } + print ""; + print ""; + print ""; + print "
Printer$searchfield
Printer
Queue 
Type 
 
"; + print "
"; +; + # END $OP eq ADD_FORM +################## ADD_VALIDATE ################################## +# called by add_form, used to insert/modify data in DB +} elsif ($op eq 'add_validate') { + my $dbh=C4Connect; + my $query = "replace printers (printername,printqueue,printtype) values ("; + $query.= $dbh->quote($input->param('printername')).","; + $query.= $dbh->quote($input->param('printqueue')).","; + $query.= $dbh->quote($input->param('printtype')).")"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + print "data recorded"; + print "
"; + print ""; + print "
"; + # END $OP eq ADD_VALIDATE +################## DELETE_CONFIRM ################################## +# called by default form, used to confirm deletion of data in DB +} elsif ($op eq 'delete_confirm') { + my $dbh = &C4Connect; + my $sth=$dbh->prepare($reqsel); + $sth->execute; + my $data=$sth->fetchrow_hashref; + $sth->finish; + print mktablehdr; + print mktablerow(2,'#99cc33',bold('Printer'),bold("$searchfield"),'/images/background-mem.gif'); + print "
"; + print "Queue$data->{'printqueue'}"; + print "Type$data->{'printtype'}"; + print "CONFIRM DELETION"; + print "
"; + # END $OP eq DELETE_CONFIRM +################## DELETE_CONFIRMED ################################## +# called by delete_confirm, used to effectively confirm deletion of data in DB +} elsif ($op eq 'delete_confirmed') { + my $dbh=C4Connect; +# my $searchfield=$input->param('branchcode'); + my $sth=$dbh->prepare($reqdel); + $sth->execute; + $sth->finish; + print "data deleted"; + print "
"; + print ""; + print "
"; + # END $OP eq DELETE_CONFIRMED +################## DEFAULT ################################## +} else { # DEFAULT + my @inputs=(["text","searchfield",$searchfield], + ["reset","reset","clr"]); + print mkheadr(2,'Currencies admin'); + print mkformnotable("$script_name",@inputs); + print <$searchfield

"; + } + print mktablehdr; + print mktablerow(5,'#99cc33',bold('Name'),bold('Queue'),bold('Type'), + ' ',' ','/images/background-mem.gif'); + my $env; + my ($count,$results)=StringSearch($env,$searchfield,'web'); + my $toggle="white"; + for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){ + if ($toggle eq 'white'){ + $toggle="#ffffcc"; + } else { + $toggle="white"; + } + print mktablerow(5,$toggle,$results->[$i]{'printername'},$results->[$i]{'printqueue'},$results->[$i]{'printtype'}, + mklink("$script_name?op=add_form&searchfield=".$results->[$i]{'printername'},'Edit'), + mklink("$script_name?op=delete_confirm&searchfield=".$results->[$i]{'printername'},'Delete','')); + } + print mktableft; + print "

"; + print ""; + if ($offset>0) { + my $prevpage = $offset-$pagesize; + print mklink("$script_name?offset=".$prevpage,'<< Prev'); + } + print "      "; + if ($offset+$pagesize<$count) { + my $nextpage =$offset+$pagesize; + print mklink("$script_name?offset=".$nextpage,'Next >>'); + } + print "

"; + print "
"; +} #---- END $OP eq DEFAULT +print endmenu('admin'); +print endpage(); diff --git a/admin/stopwords.pl b/admin/stopwords.pl new file mode 100755 index 0000000000..705517a432 --- /dev/null +++ b/admin/stopwords.pl @@ -0,0 +1,234 @@ +#!/usr/bin/perl + +#script to administer the stopwords table +#written 20/02/2002 by paul.poulain@free.fr +# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) + +# ALGO : +# this script use an $op to know what to do. +# if $op is empty or none of the above values, +# - the default screen is build (with all records, or filtered datas). +# - the user can clic on add, modify or delete record. +# if $op=add_form +# - if primkey exists, this is a modification,so we read the $primkey record +# - builds the add/modify form +# if $op=add_validate +# - the user has just send datas, so we create/modify the record +# if $op=delete_form +# - we show the record having primkey=$primkey and ask for deletion validation form +# if $op=delete_confirm +# - we delete the record having primkey=$primkey + +use strict; +use C4::Output; +use CGI; +use C4::Search; +use C4::Database; + +sub StringSearch { + my ($env,$searchstring,$type)=@_; + my $dbh = &C4Connect; + $searchstring=~ s/\'/\\\'/g; + my @data=split(' ',$searchstring); + my $count=@data; + my $query="Select word from stopwords where (word like \"$data[0]%\") order by word"; + my $sth=$dbh->prepare($query); + $sth->execute; + my @results; + my $cnt=0; + while (my $data=$sth->fetchrow_hashref){ + push(@results,$data); + $cnt ++; + } + # $sth->execute; + $sth->finish; + $dbh->disconnect; + return ($cnt,\@results); +} + +my $input = new CGI; +my $searchfield=$input->param('searchfield'); +my $pkfield="word"; +my $reqsel="select word from stopwords where $pkfield='$searchfield'"; +my $reqdel="delete from stopwords where $pkfield='$searchfield'"; +my $offset=$input->param('offset'); +my $script_name="/cgi-bin/koha/admin/stopwords.pl"; + +my $pagesize=20; +my $op = $input->param('op'); +$searchfield=~ s/\,//g; +print $input->header; + +#start the page and read in includes +print startpage(); +print startmenu('admin'); + +################## ADD_FORM ################################## +# called by default. Used to create form to add or modify a record +if ($op eq 'add_form') { + #---- if primkey exists, it's a modify action, so read values to modify... + my $data; + if ($searchfield) { + my $dbh = &C4Connect; + my $sth=$dbh->prepare("select word from stopwords where word='$searchfield'"); + $sth->execute; + $data=$sth->fetchrow_hashref; + $sth->finish; + } + print < + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNotNull(f,noalert) { + if (f.value.length ==0) { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function toUC(f) { + var x=f.value.toUpperCase(); + f.value=x; + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNum(v,maybenull) { + var n = new Number(v.value); + if (isNaN(n)) { + return false; + } + if (maybenull==0 && v.value=='') { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isDate(f) { + var t = Date.parse(f.value); + if (isNaN(t)) { + return false; + } + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function Check(f) { + var ok=1; + var _alertString=""; + var alertString2; + if (f.word.value.length==0) { + _alertString += "- word missing\\n"; + } + if (_alertString.length==0) { + document.Aform.submit(); + } else { + alertString2 = "Form not submitted because of the following problem(s)\\n"; + alertString2 += "------------------------------------------------------------------------------------\\n\\n"; + alertString2 += _alertString; + alert(alertString2); + } + } + +printend +;#/ + if ($searchfield) { + print "

Modify word

"; + } else { + print "

Add word

"; + } + print "
"; + print ""; + print ""; + if ($searchfield) { + print ""; + } else { + print ""; + } + print ""; + print "
Word$searchfield
Word
 
"; + print "
"; +; + # END $OP eq ADD_FORM +################## ADD_VALIDATE ################################## +# called by add_form, used to insert/modify data in DB +} elsif ($op eq 'add_validate') { + my $dbh=C4Connect; + my $query = "replace stopwords (word) values ("; + $query.= $dbh->quote($input->param('word')).")"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + print "data recorded"; + print "
"; + print ""; + print "
"; + # END $OP eq ADD_VALIDATE +################## DELETE_CONFIRM ################################## +# called by default form, used to confirm deletion of data in DB +} elsif ($op eq 'delete_confirm') { + my $dbh = &C4Connect; + my $sth=$dbh->prepare($reqsel); + $sth->execute; + my $data=$sth->fetchrow_hashref; + $sth->finish; + print mktablehdr; + print mktablerow(2,'#99cc33',bold('Word'),bold("$searchfield"),'/images/background-mem.gif'); + print "
"; + print "CONFIRM DELETION"; + print "
"; + # END $OP eq DELETE_CONFIRM +################## DELETE_CONFIRMED ################################## +# called by delete_confirm, used to effectively confirm deletion of data in DB +} elsif ($op eq 'delete_confirmed') { + my $dbh=C4Connect; +# my $searchfield=$input->param('branchcode'); + my $sth=$dbh->prepare($reqdel); + $sth->execute; + $sth->finish; + print "data deleted"; + print "
"; + print ""; + print "
"; + # END $OP eq DELETE_CONFIRMED +################## DEFAULT ################################## +} else { # DEFAULT + my @inputs=(["text","searchfield",$searchfield], + ["reset","reset","clr"]); + print mkheadr(2,'Currencies admin'); + print mkformnotable("$script_name",@inputs); + print <$searchfield

"; + } + print mktablehdr; + print mktablerow(2,'#99cc33',bold('Word'), + ' ',' ','/images/background-mem.gif'); + my $env; + my ($count,$results)=StringSearch($env,$searchfield,'web'); + my $toggle="white"; + for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){ + if ($toggle eq 'white'){ + $toggle="#ffffcc"; + } else { + $toggle="white"; + } + print mktablerow(2,$toggle,$results->[$i]{'word'}, + mklink("$script_name?op=delete_confirm&searchfield=".$results->[$i]{'word'},'Delete','')); + } + print mktableft; + print "

"; + print ""; + if ($offset>0) { + my $prevpage = $offset-$pagesize; + print mklink("$script_name?offset=".$prevpage,'<< Prev'); + } + print "      "; + if ($offset+$pagesize<$count) { + my $nextpage =$offset+$pagesize; + print mklink("$script_name?offset=".$nextpage,'Next >>'); + } + print "

"; + print "
"; +} #---- END $OP eq DEFAULT +print endmenu('admin'); +print endpage(); diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl new file mode 100755 index 0000000000..05c739ad94 --- /dev/null +++ b/admin/systempreferences.pl @@ -0,0 +1,245 @@ +#!/usr/bin/perl + +#script to administer the systempref table +#written 20/02/2002 by paul.poulain@free.fr +# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) + +# ALGO : +# this script use an $op to know what to do. +# if $op is empty or none of the above values, +# - the default screen is build (with all records, or filtered datas). +# - the user can clic on add, modify or delete record. +# if $op=add_form +# - if primkey exists, this is a modification,so we read the $primkey record +# - builds the add/modify form +# if $op=add_validate +# - the user has just send datas, so we create/modify the record +# if $op=delete_form +# - we show the record having primkey=$primkey and ask for deletion validation form +# if $op=delete_confirm +# - we delete the record having primkey=$primkey + +use strict; +use C4::Output; +use CGI; +use C4::Search; +use C4::Database; + +sub StringSearch { + my ($env,$searchstring,$type)=@_; + my $dbh = &C4Connect; + $searchstring=~ s/\'/\\\'/g; + my @data=split(' ',$searchstring); + my $count=@data; + my $query="Select variable,value from systempreferences where (variable like \"$data[0]%\") order by variable"; + my $sth=$dbh->prepare($query); + $sth->execute; + my @results; + my $cnt=0; + while (my $data=$sth->fetchrow_hashref){ + push(@results,$data); + $cnt ++; + } + # $sth->execute; + $sth->finish; + $dbh->disconnect; + return ($cnt,\@results); +} + +my $input = new CGI; +my $searchfield=$input->param('searchfield'); +my $pkfield="variable"; +my $reqsel="select variable,value from systempreferences where $pkfield='$searchfield'"; +my $reqdel="delete from systempreferences where $pkfield='$searchfield'"; +my $offset=$input->param('offset'); +my $script_name="/cgi-bin/koha/admin/systempreferences.pl"; + +my $pagesize=20; +my $op = $input->param('op'); +$searchfield=~ s/\,//g; +print $input->header; + +#start the page and read in includes +print startpage(); +print startmenu('admin'); + +################## ADD_FORM ################################## +# called by default. Used to create form to add or modify a record +if ($op eq 'add_form') { + #---- if primkey exists, it's a modify action, so read values to modify... + my $data; + if ($searchfield) { + my $dbh = &C4Connect; + my $sth=$dbh->prepare("select variable,value from systempreferences where variable='$searchfield'"); + $sth->execute; + $data=$sth->fetchrow_hashref; + $sth->finish; + } + print < + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNotNull(f,noalert) { + if (f.value.length ==0) { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function toUC(f) { + var x=f.value.toUpperCase(); + f.value=x; + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNum(v,maybenull) { + var n = new Number(v.value); + if (isNaN(n)) { + return false; + } + if (maybenull==0 && v.value=='') { + return false; + } + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isDate(f) { + var t = Date.parse(f.value); + if (isNaN(t)) { + return false; + } + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function Check(f) { + var ok=1; + var _alertString=""; + var alertString2; + if (f.variable.value.length==0) { + _alertString += "- variable missing\\n"; + } + if (f.value.value.length==0) { + _alertString += "- value missing\\n"; + } + if (_alertString.length==0) { + document.Aform.submit(); + } else { + alertString2 = "Form not submitted because of the following problem(s)\\n"; + alertString2 += "------------------------------------------------------------------------------------\\n\\n"; + alertString2 += _alertString; + alert(alertString2); + } + } + +printend +;#/ + if ($searchfield) { + print "

Modify pref

"; + } else { + print "

Add pref

"; + } + print "
"; + print ""; + print ""; + if ($searchfield) { + print ""; + } else { + print ""; + } + print ""; + print ""; + print "
Variable$searchfield
Variable
Value
 
"; + print "
"; +; + # END $OP eq ADD_FORM +################## ADD_VALIDATE ################################## +# called by add_form, used to insert/modify data in DB +} elsif ($op eq 'add_validate') { + my $dbh=C4Connect; + my $query = "replace systempreferences (variable,value) values ("; + $query.= $dbh->quote($input->param('variable')).","; + $query.= $dbh->quote($input->param('value')).")"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + print "data recorded"; + print "
"; + print ""; + print "
"; + # END $OP eq ADD_VALIDATE +################## DELETE_CONFIRM ################################## +# called by default form, used to confirm deletion of data in DB +} elsif ($op eq 'delete_confirm') { + my $dbh = &C4Connect; + my $sth=$dbh->prepare($reqsel); + $sth->execute; + my $data=$sth->fetchrow_hashref; + $sth->finish; + print mktablehdr; + print mktablerow(2,'#99cc33',bold('Variable'),bold("$searchfield"),'/images/background-mem.gif'); + print "Value$data->{'value'}"; + print "
"; + print "CONFIRM DELETION"; + print "
"; + # END $OP eq DELETE_CONFIRM +################## DELETE_CONFIRMED ################################## +# called by delete_confirm, used to effectively confirm deletion of data in DB +} elsif ($op eq 'delete_confirmed') { + my $dbh=C4Connect; +# my $searchfield=$input->param('branchcode'); + my $sth=$dbh->prepare($reqdel); + $sth->execute; + $sth->finish; + print "data deleted"; + print "
"; + print ""; + print "
"; + # END $OP eq DELETE_CONFIRMED +################## DEFAULT ################################## +} else { # DEFAULT + my @inputs=(["text","searchfield",$searchfield], + ["reset","reset","clr"]); + print mkheadr(2,'System preferences admin'); + print mkformnotable("$script_name",@inputs); + print <Hints :
+2 variables are useful in this table : +
  • acquisitions, which value may be "simple" or "normal"
  • +
  • autoMemberNum which may be 1 or 0
  • +

    +printend + ; + if ($searchfield ne '') { + print "You Searched for $searchfield

    "; + } + print mktablehdr; + print mktablerow(4,'#99cc33',bold('Variable'),bold('Value'), + ' ',' ','/images/background-mem.gif'); + my $env; + my ($count,$results)=StringSearch($env,$searchfield,'web'); + my $toggle="white"; + for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){ + if ($toggle eq 'white'){ + $toggle="#ffffcc"; + } else { + $toggle="white"; + } + print mktablerow(4,$toggle,$results->[$i]{'variable'},$results->[$i]{'value'}, + mklink("$script_name?op=add_form&searchfield=".$results->[$i]{'variable'},'Edit'), + mklink("$script_name?op=delete_confirm&searchfield=".$results->[$i]{'variable'},'Delete','')); + } + print mktableft; + print "

    "; + print ""; + if ($offset>0) { + my $prevpage = $offset-$pagesize; + print mklink("$script_name?offset=".$prevpage,'<< Prev'); + } + print "      "; + if ($offset+$pagesize<$count) { + my $nextpage =$offset+$pagesize; + print mklink("$script_name?offset=".$nextpage,'Next >>'); + } + print "

    "; + print "
    "; +} #---- END $OP eq DEFAULT +print endmenu('admin'); +print endpage(); -- 2.39.5