Koha-devel
Threads by month
- ----- 2026 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
March 2002
- 11 participants
- 69 discussions
12 Mar '02
Update of /cvsroot/koha/koha/circ
In directory usw-pr-cvs1:/tmp/cvs-serv25121
Modified Files:
circulation.pl
Added Files:
branchtransfers.pl
Log Message:
Branchtransfers.pl provides a form for entering barcodes and selecting a
destination branch.
New rows are entered into the branchtransfers table for each item
"transfered".
--- NEW FILE ---
#!/usr/bin/perl
#written 11/3/2002 by Finlay
#script to execute branch transfers of books
use strict;
use CGI;
use C4::Circulation::Circ2;
use C4::Search;
use C4::Output;
my %env;
my $headerbackgroundcolor='#99cc33';
my $circbackgroundcolor='#ffffcc';
my $circbackgroundcolor='white';
my $linecolor1='#ffffcc';
my $linecolor2='white';
my $backgroundimage="/images/background-mem.gif";
my $query=new CGI;
my $branches=getbranches(\%env);
my $tobranchcd=$query->param('tobranchcd');
my $frbranchcd='';
$env{'tobranchcd'}=$tobranchcd;
my $tobranchoptions;
foreach (keys %$branches) {
(next) unless ($_);
(next) if (/^TR$/);
my $selected='';
($selected='selected') if ($_ eq $tobranchcd);
$tobranchoptions.="<option value=$_ $selected>$branches->{$_}->{'branchname'}\n";
}
# collect the stack of books already transfered so they can printed...
my %transfereditems;
my $ritext = '';
my %frbranchcds;
my %tobranchcds;
foreach ($query->param){
(next) unless (/bc-(\d*)/);
my $counter=$1;
(next) if ($counter>20);
my $barcode=$query->param("bc-$counter");
my $frbcd=$query->param("fb-$counter");
my $tobcd=$query->param("tb-$counter");
$counter++;
$transfereditems{$counter}=$barcode;
$frbranchcds{$counter}=$frbcd;
$tobranchcds{$counter}=$tobcd;
$ritext.="<input type=hidden name=bc-$counter value=$barcode>\n";
$ritext.="<input type=hidden name=fb-$counter value=$frbcd>\n";
$ritext.="<input type=hidden name=tb-$counter value=$tobcd>\n";
}
#if the barcode has been entered action that and write a message and onto the top of the stack...
my $iteminformation;
my @messages;
my $todaysdate;
if (my $barcode=$query->param('barcode')) {
my $iteminformation = getiteminformation(\%env,0, $barcode);
my $fail=0;
if (not $iteminformation) {
$fail=1;
@messages = ("There is no book with barcode: $barcode ", @messages);
}
$frbranchcd = $iteminformation->{'holdingbranch'};
%env->{'frbranchcd'} = $frbranchcd;
if ($frbranchcd eq $tobranchcd) {
$fail=1;
@messages = ("You can't transfer the book to the branch it is already at!", @messages);
}
# should add some more tests ... like is the book already out, maybe it cant be moved....
if (not $fail) {
my ($transfered, $message) = transferbook(\%env, $iteminformation, $barcode);
if (not $transfered) {@messages = ($message, @messages);}
else {
$ritext.="<input type=hidden name=bc-0 value=$barcode>\n";
$ritext.="<input type=hidden name=fb-0 value=$frbranchcd>\n";
$ritext.="<input type=hidden name=tb-0 value=$tobranchcd>\n";
$transfereditems{0}=$barcode;
$frbranchcds{0}=$frbranchcd;
$tobranchcds{0}=$tobranchcd;
@messages = ("Book: $barcode has been transfered", @messages);
}
}
}
my $entrytext= << "EOF";
<form method=post action=/cgi-bin/koha/circ/branchtransfers.pl>
<table border=0 cellpadding=5 cellspacing=0 bgcolor=#dddddd >
<tr><td colspan=2 bgcolor=$headerbackgroundcolor align=center background=$backgroundimage>
<font color=black><b>Select Branch</b></font></td></tr>
<tr><td>Destination Branch:</td><td>
<select name=tobranchcd> $tobranchoptions </select>
</td></tr>
</table><table border=0 cellpadding=5 cellspacing=0 bgcolor=#dddddd >
<tr><td colspan=2 bgcolor=$headerbackgroundcolor align=center background=$backgroundimage>
<font color=black><b>Enter Book Barcode</b></font></td></tr>
<tr><td>Item Barcode:</td><td><input name=barcode size=10></td></tr>
</table>
<input type=hidden name=tobranchcd value=$tobranchcd>
$ritext
EOF
my $messagetable;
if (@messages) {
my $messagetext='';
foreach (@messages) {
$messagetext.="$_<p>\n";
}
$messagetable = << "EOF";
<table border=0 cellpadding=5 cellspacing=0 bgcolor='#dddddd'>
<tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage><font color=black>Messages</font></th></tr>
<tr><td> $messagetext </td></tr></table>
EOF
}
print $query->header;
print startpage;
print startmenu('circulation');
print "<h3>Branch Transfers</h3>";
print $messagetable if (@messages);
print $entrytext;
if (%transfereditems) {
print << "EOF";
<p>
<table border=0 cellpadding=5 cellspacing=0 bgcolor=#dddddd>
<tr><th colspan=6 bgcolor=$headerbackgroundcolor background=$backgroundimage><font color=black>Transfered Items</font></th></tr>
<tr><th>Bar Code</th><th>Title</th><th>Author</th><th>Type</th><th>From</th><th>To</th></tr>
EOF
my $color='';
foreach (keys %transfereditems) {
($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
my $barcode=$transfereditems{$_};
my $frbcd=$frbranchcds{$_};
my $tobcd=$tobranchcds{$_};
my ($iteminformation) = getiteminformation(\%env, 0, $barcode);
print << "EOF";
<tr><td bgcolor=$color align=center>
<a href=/cgi-bin/koha/detail.pl?bib=$iteminformation->{'biblionumber'}
&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$barcode</a></td>
<td bgcolor=$color>$iteminformation->{'title'}</td>
<td bgcolor=$color>$iteminformation->{'author'}</td>
<td bgcolor=$color align=center>$iteminformation->{'itemtype'}</td>
<td bgcolor=$color align=center>$branches->{$frbcd}->{'branchname'}</td>
<td bgcolor=$color align=center>$branches->{$tobcd}->{'branchname'}</td>
</tr>\n
EOF
}
print "</table>\n";
}
print endmenu('circulation');
print endpage;
############################################################################
#
# this is the database query that will go into C4::Circuation::Circ2
#
use DBI;
use C4::Database;
sub transferbook {
my ($env, $iteminformation, $barcode) = @_;
my $messages;
my $dbh=&C4Connect;
#new entry in branchtransfers....
my $sth = $dbh->prepare("insert into branchtransfers (itemnumber, frombranch, datearrived, tobranch) values($iteminformation->{'itemnumber'}, '$env->{'frbranchcd'}', now(), '$env->{'tobranchcd'}')");
$sth->execute || return (0,"database error: $sth->errstr");
$sth->finish;
#update holdingbranch in items .....
$sth = $dbh->prepare("update items set holdingbranch='$env->{'tobranchcd'}' where items.itemnumber=$iteminformation->{'itemnumber'}");
$sth->execute || return (0,"database error: $sth->errstr");
$sth->execute;
$sth->finish;
$dbh->disconnect;
return (1, $messages);
}
Index: circulation.pl
===================================================================
RCS file: /cvsroot/koha/koha/circ/circulation.pl,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** circulation.pl 17 Aug 2001 07:54:38 -0000 1.20
--- circulation.pl 12 Mar 2002 21:04:32 -0000 1.21
***************
*** 263,267 ****
$barcodeentrytext.= "<input type=hidden name=bn-0 value=$borrower->{'borrowernumber'}>\n";
my @datearr = localtime(time());
! my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]);
my $itemtable=<<"EOF";
<table border=0 cellpadding=5 cellspacing=0 bgcolor=#dddddd>
--- 263,268 ----
$barcodeentrytext.= "<input type=hidden name=bn-0 value=$borrower->{'borrowernumber'}>\n";
my @datearr = localtime(time());
! my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.
! sprintf ("%0.2d", $datearr[3]);
my $itemtable=<<"EOF";
<table border=0 cellpadding=5 cellspacing=0 bgcolor=#dddddd>
***************
*** 465,470 ****
<FONT SIZE=2 face="arial, helvetica">
<a href=circulation.pl?borrnumber=$borrowernumber&module=issues&branch=$branch&printer=$printer&print>Next Borrower</a> ||
! <a href=circulation.pl?module=returns&branch=$branch&printer=$printer>Returns</a></font><p>
!
</p>
--- 466,471 ----
<FONT SIZE=2 face="arial, helvetica">
<a href=circulation.pl?borrnumber=$borrowernumber&module=issues&branch=$branch&printer=$printer&print>Next Borrower</a> ||
! <a href=circulation.pl?module=returns&branch=$branch&printer=$printer>Returns</a> ||
! <a href=branchtransfers.pl>Transfer Book</a></font><p>
</p>
***************
*** 669,673 ****
$dd="<font color=red>$dd</font>\n";
}
! $previssues.="<tr><td bgcolor=$color align=center>$dd</td><td bgcolor=$color align=center><a href=/cgi-bin/koha/detail.pl?bib=$bookissue->{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$bookissue->{'barcode'}</a></td><td bgcolor=$color>$bookissue->{'title'}</td><td bgcolor=$color>$bookissue->{'author'}</td><td bgcolor=$color align=center>$bookissue->{'dewey'} $bookissue->{'subclass'}</td></tr>\n";
}
my $todaysissues='';
--- 670,674 ----
$dd="<font color=red>$dd</font>\n";
}
! $previssues.="<tr><td bgcolor=$color align=center>$dd</td><td bgcolor=$color align=center><a href=/cgi-bin/koha/detail.pl?bib=$bookissue->{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$bookissue->{'barcode'}</a></td><td bgcolor=$color>$bookissue->{'title'}</td><td bgcolor=$color>$bookissue->{'author'}</td><td bgcolor=$color align=center>$bookissue->{'dewey'} $bookissue->{'subclass'}</td></tr>\n";
}
my $todaysissues='';
1
0
jmulford(a)legionaries.org wrote:
>Friends down under and all over,
>
>I've been "observing" the list for several months from Rome, Italy and would
>like to ask a few specific questions, hoping that the answers will convince
>our Systems Engineer to choose KOHA over AMICUS.
>
>Here goes:
>
>1. Is the MARC and z39.50 support up to par for a major installation? I've
>seen activity in the list but would like to know the current status and
>future targets for these features.
>
Be careful, there are a lot of MARC standards. In France, we use
UNIMARC. koha, for instance, claimed to be MARC21 compliant. there are
only a few diffs between MARC standards, but there are.
In France, we use UNIMARC, and I will modify if there is a need to do so
the marcimport and marcexport scripts to be UNIMARC and MARC21
compliant. This is a must-have for me.
I think the ISO-2709 standard is our common meeting point, but I'm not
really aware about that.
>2. Can KOHA confidently handle our 100,000+ multi-language volumes, with a
>growth rate of 10,000 a year? How far do you think KOHA can go, or is the
>sky the limit? Do you recommend MySQL or another DBase?
>
Nothing to add to katipo responses. MySQL is the BEST DB at selection.
It may have some perfs problems on heavy update/insert traffic, but a
soft like koha has really more SELECT than INSERT/UPDATE.
>6. Anyone at Katipo looking for a FREE fortnight in Rome - with a little
>KOHA customization on the side, of course? Offers are welcome. Seriously!
>(Chris, Rachel, Simon, ... You can answer off list if you prefer.)
>
If this happends, it could be an idea to organize a "koha meeting" in
europe (maybe a "hard-coding meeting ???"), as I'm in France (Marseille,
not too far from Italy)
Note there is a point you haven't asked for : italian version of koha.
I've investigated to find how to build a french version, it's not hard.
You just have to follow README in translate directory. Note we are on
the way to modify the tools used for koha, so, the translation method
may differ. It won't be done in the next weeks anyway (after MARC
compliance I think and propose)
--
Paul
1
0
Hi James.
On Mon, Mar 11, 2002 at 11:30:24PM +0100, jmulford(a)legionaries.org said:
> Friends down under and all over,
>
> I've been "observing" the list for several months from Rome, Italy and would
> like to ask a few specific questions, hoping that the answers will convince
> our Systems Engineer to choose KOHA over AMICUS.
>
> Here goes:
>
> 1. Is the MARC and z39.50 support up to par for a major installation? I've
> seen activity in the list but would like to know the current status and
> future targets for these features.
As Steve points out, it's not ready for primetime yet. Having said
that, it's not a lack of will that has prevented it going in, more a
lack of spare time (or money, with which you seem to be able to turn
other programmers time into spare time of your own :-). So my guess
would be that if you had a few dollars to throw at the problem, the MARC
and z39.50 support could be added in pretty quickly.
> 2. Can KOHA confidently handle our 100,000+ multi-language volumes, with a
> growth rate of 10,000 a year? How far do you think KOHA can go, or is the
> sky the limit? Do you recommend MySQL or another DBase?
Horowhenua has about 86K items (74K biblio entries), running on a dual
PIII 1000Mhz Athlon, 1.5Gb disk and a single IDE disk drive, and it just
coasts along. I suspect that if you take whatever hardware Amicus needs
for your requirements (I'm guessing Quad Zeon or Sparc, 4-8Gb RAM, fast
SCSI disk array), then Koha would fairly rip along. Fundamentally, Koha
is limited by how fast your SQL engine can run - the more RAM and faster
disks you give it, the faster it'll go.
As for whether we recommend MySQL or something else, the SQL in Koha is,
as much as possible, server independant - it all runs through the perl
DBI libraries, which in principle mean that you can use MySQL,
PostgreSQL, Oracle, Sybase, MSSQL, or even (cough) Access. In reality,
there are probably a few bits of SQL that are somewhat MySQL specific
(generally optimisations to use indices more efficiently), but it
wouldn't be a difficult job to port it to another DBI supported engine.
Having said that, we've no particular plans to change - if it's good
enough for NASA, it's good enough for us :-). We did actually start the
project in 1999 with PostgreSQL, but had to drop it when we tickled bugs
in the query optimiser that caused queries in PGSQL to take as long in
minutes as MySQL took in seconds. These bugs were acknowledged by the
PGSQL developers at the time, but our timeline didn't really give us an
opportunity to wait for the fixes, so we trucked on with MySQL. Since
then, I assume the bugs are fixed in PGSQL, but lots of the reasons for
choosing PGSQL over MySQL are now moot - MySQL has had a lot of the
useful features of PGSQL added to it over the last couple of years.
> 3. Does anyone have experience migrating from ALEPH or AMICUS to KOHA? I
> know it seems like a downgrade, but I love the opensource spirit and the
> full customization. Besides, I'm the University Administrator (Bursor) and
> the price is VERY attractive too!
We'd prefer to see it as gaining the true and righteous path, rather
than a downgrade :-). Having said that, although we do have some
experience with Aleph, we've never converted one from the other. OTOH,
if you can get the data out of it easily, in a sensible format, then a
conversion shouldn't be too problematic.
> 4. Any knowledge of other people in Italy (or nearby) using KOHA who might
> be able to lend us a hand?
No idea, but then, nobody is obliged to tell us if they use it, and a
google for some of the terms in the opac shows it popping up in some of
the most unlikely places.
> 5. Any news about porting KOHA over to Windows NT/2000/XP? (POST- Jan. 24,
> 2002: Andrew Hooper ahooper(a)microsoft.com <mailto:ahooper@microsoft.com> )
I don't know where this has got to - Perl, Apache and MySQL work pretty
well on Win32 now, we've just never bothered to sit down and spend the
few days it'd probably take to get it all working together -
unfortunately, we don't all get educational discounts for MS code, and
we don't have a customer clamouring for it, so there's been no
particular incentive to shell out the shekels for MS licenses :-(.
> 6. Anyone at Katipo looking for a FREE fortnight in Rome - with a little
> KOHA customization on the side, of course? Offers are welcome. Seriously!
> (Chris, Rachel, Simon, ... You can answer off list if you prefer.)
Well, you'd need to take that up with Rachel, but we do have programmers
that could make the trip, we've even one who speaks Italian :-). If the
Regina Apostolorum University was happy to spend an amount of money that
was larger than *free*, but *significantly* less than I imagine an
Amicus or Aleph install costs, then I'm sure we could get you all the
features you're after included, without any difficulty.
Cheers
Si
> James Mulford
> Director of Finance & Development
>
> Regina Apostolorum University
> Via degli Aldobrandeschi 190
> Roma, 00163
>
> Tel: (+39) 06.66.52.78.00
> Fax: (+39) 06.66.52.78.92
> Videoconference: (+39) 06.6652.7962
> www.upra.org <http://www.upra.org>
>
> =========================================================
>
> At 19.19 25/05/01 +0200, you wrote:
> >Friends,
> >
> >Greetings from Rome, Italy! This is my first post to the list. I'm a member
> >of a consortium of 16 Universities in Rome with all our libraries
> containing
> >a little over 2,000,000 volumes. Most have been using Aleph300 for the past
> >10 years and are seriously considering switching to AMICUS (used by British
> >Library, Australian & Canadian National Systems, etc.) but I recently came
> >across the Koha Proyect and have been impressed. ...
>
> James Mulford
> Director of Finance & Development
> Regina Apostolorum University >
>
> _______________________________________________
> Koha mailing list
> Koha(a)lists.katipo.co.nz
> http://lists.katipo.co.nz/mailman/listinfo/koha
--
Simon Blake simon(a)katipo.co.nz
Katipo Communications +64 21 402 004
1
0
On Mon, 11 Mar 2002 jmulford(a)legionaries.org wrote:
> Friends down under and all over,
>
> I've been "observing" the list for several months from Rome, Italy and would
> like to ask a few specific questions, hoping that the answers will convince
> our Systems Engineer to choose KOHA over AMICUS.
>
> Here goes:
>
> 1. Is the MARC and z39.50 support up to par for a major installation? I've
> seen activity in the list but would like to know the current status and
> future targets for these features.
No. MARC still needs work. I've stalled on this development work, but
hope to get started again soon (when my new laptop arrives).
Steve.
1
0
Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv13280/C4
Modified Files:
Accounts2.pm
Log Message:
Fix for manual invoices
Index: Accounts2.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Accounts2.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** Accounts2.pm 15 May 2001 23:05:43 -0000 1.8
--- Accounts2.pm 11 Mar 2002 03:36:41 -0000 1.9
***************
*** 10,13 ****
--- 10,14 ----
use C4::Stats;
use C4::Search;
+ use C4::Circulation::Circ2;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
***************
*** 209,222 ****
sub manualinvoice{
! my ($bornum,$itemnum,$desc,$type,$amount)=@_;
my $dbh=C4Connect;
my $insert;
$itemnum=~ s/ //g;
my $accountno=getnextacctno('',$bornum,$dbh);
my $amountleft=$amount;
! if ($type eq 'C' || $type eq 'BAY' || $type eq 'WORK'){
my $amount2=$amount*-1;
! $amountleft=fixcredit('',$bornum,$amount2);
}
if ($type eq 'N'){
--- 210,225 ----
sub manualinvoice{
! my ($bornum,$itemnum,$desc,$type,$amount,$user)=@_;
my $dbh=C4Connect;
my $insert;
$itemnum=~ s/ //g;
+ my %env;
my $accountno=getnextacctno('',$bornum,$dbh);
my $amountleft=$amount;
! if ($type eq 'CS' || $type eq 'CB' || $type eq 'CW'
! || $type eq 'CF' || $type eq 'CL'){
my $amount2=$amount*-1;
! $amountleft=fixcredit(\%env,$bornum,$amount2,$itemnum,$type,$user);
}
if ($type eq 'N'){
***************
*** 235,243 ****
$sth->finish;
$desc.=" ".$itemnum;
$insert="insert into accountlines (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber)
! values ($bornum,$accountno,now(),'$amount','$desc','$type','$amountleft','$data->{'itemnumber'}')";
} else {
$insert="insert into accountlines (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding)
! values ($bornum,$accountno,now(),'$amount','$desc','$type','$amountleft')";
}
--- 238,248 ----
$sth->finish;
$desc.=" ".$itemnum;
+ $desc=$dbh->quote($desc);
$insert="insert into accountlines (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber)
! values ($bornum,$accountno,now(),'$amount',$desc,'$type','$amountleft','$data->{'itemnumber'}')";
} else {
+ $desc=$dbh->quote($desc);
$insert="insert into accountlines (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding)
! values ($bornum,$accountno,now(),'$amount',$desc,'$type','$amountleft')";
}
***************
*** 251,261 ****
sub fixcredit{
#here we update both the accountoffsets and the account lines
! my ($env,$bornumber,$data)=@_;
my $dbh=C4Connect;
my $updquery = "";
my $newamtos = 0;
my $accdata = "";
- # my $branch=$env->{'branchcode'};
my $amountleft = $data;
# begin transaction
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
--- 256,303 ----
sub fixcredit{
#here we update both the accountoffsets and the account lines
! my ($env,$bornumber,$data,$barcode,$type,$user)=@_;
my $dbh=C4Connect;
my $updquery = "";
my $newamtos = 0;
my $accdata = "";
my $amountleft = $data;
+ if ($barcode ne ''){
+ my $item=getiteminformation($env,'',$barcode);
+ my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
+ my $query="Select * from accountlines where (borrowernumber='$bornumber'
+ and itemnumber='$item->{'itemnumber'}' and amountoutstanding > 0)";
+ if ($type eq 'CL'){
+ $query.=" and (accounttype = 'L' or accounttype = 'Rep')";
+ } elsif ($type eq 'CF'){
+ $query.=" and (accounttype = 'F' or accounttype = 'FU' or
+ accounttype='Res' or accounttype='Rent')";
+ } elsif ($type eq 'CB'){
+ $query.=" and accounttype='A'";
+ }
+ # print $query;
+ my $sth=$dbh->prepare($query);
+ $sth->execute;
+ $accdata=$sth->fetchrow_hashref;
+ $sth->finish;
+ if ($accdata->{'amountoutstanding'} < $amountleft) {
+ $newamtos = 0;
+ $amountleft = $amountleft - $accdata->{'amountoutstanding'};
+ } else {
+ $newamtos = $accdata->{'amountoutstanding'} - $amountleft;
+ $amountleft = 0;
+ }
+ my $thisacct = $accdata->{accountno};
+ my $updquery = "update accountlines set amountoutstanding= '$newamtos'
+ where (borrowernumber = '$bornumber') and (accountno='$thisacct')";
+ my $usth = $dbh->prepare($updquery);
+ $usth->execute;
+ $usth->finish;
+ $updquery = "insert into accountoffsets
+ (borrowernumber, accountno, offsetaccount, offsetamount)
+ values ($bornumber,$accdata->{'accountno'},$nextaccntno,$newamtos)";
+ my $usth = $dbh->prepare($updquery);
+ $usth->execute;
+ $usth->finish;
+ }
# begin transaction
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
***************
*** 291,295 ****
--- 333,342 ----
$sth->finish;
$dbh->disconnect;
+ $env->{'branch'}=$user;
+ $type="Credit ".$type;
+ UpdateStats($env,$user,$type,$data,$user,'','',$bornumber);
+ $amountleft*=-1;
return($amountleft);
+
}
1
0
I try to install axkit to see what it is exactly, but I failed.
Does someone already tried ?
Error on make :
apache_request.c:521: warning: assignment makes pointer from integer
without a cast
apache_request.c:524: `ap_day_snames' undeclared (first use in this
function)
apache_request.c:524: dereferencing pointer to incomplete type
apache_request.c:525: dereferencing pointer to incomplete type
apache_request.c:525: `ap_month_snames' undeclared (first use in this
function)
apache_request.c:525: dereferencing pointer to incomplete type
apache_request.c:526: dereferencing pointer to incomplete type
apache_request.c:527: dereferencing pointer to incomplete type
apache_request.c:527: dereferencing pointer to incomplete type
apache_request.c:527: dereferencing pointer to incomplete type
apache_request.c:527: warning: return makes pointer from integer without
a cast
apache_request.c: At top level:
apache_request.c:530: parse error before `*'
apache_request.c: In function `ApacheRequest_expires':
apache_request.c:532: request for member `r' in something not a
structure or union
apache_request.c:532: `time_str' undeclared (first use in this function)
make[2]: *** [apache_request.o] Erreur 1
make[2]: Quitte le répertoire `/home/paul/AxKit-1.5/libapreq-0.31_03/c'
make[1]: *** [subdirs] Erreur 2
make[1]: Quitte le répertoire `/home/paul/AxKit-1.5/libapreq-0.31_03'
make: *** [subdirs] Erreur 2
I'm on Athlon 1500+, Mandrake 8.1, httpd and httpd_perl and apache-devel
package installed.
--
Paul
2
1
The bibliosubjects table contains all the subjects used for a biblio.
It's used in the search process.
In the create biblio process, there is a subject field, in which we
store all the subjects.
I think it would be useful to have a table where we could store all the
differents subjects that are used in the DB.
It could be an reference table. I don't know the word in english, but in
french, it's called "thesaurus" if i don't mind.
In the author section, the same kind of table should be created too : a
table referencing how to spell an author name : any manner you wrote an
author, it must be "findable". In the biblio, an author must be entered
in a standard form, this table helping. I wrote a message about that in
the user ml a few weeks ago.
--
Paul
3
3
CVS: koha/admin aqbookfund.pl,NONE,1.1 aqbudget.pl,NONE,1.1 branches.pl,NONE,1.1 categorie.pl,NONE,1.1 categoryitem.pl,NONE,1.1 currency.pl,NONE,1.1 itemtypes.pl,NONE,1.1 printers.pl,NONE,1.1 stopwords.pl,NONE,1.1 systempreferences.pl,NONE,1.1
by Paul POULAIN 06 Mar '02
by Paul POULAIN 06 Mar '02
06 Mar '02
Update of /cvsroot/koha/koha/admin
In directory usw-pr-cvs1:/tmp/cvs-serv20545/admin
Added Files:
aqbookfund.pl aqbudget.pl branches.pl categorie.pl
categoryitem.pl currency.pl itemtypes.pl printers.pl
stopwords.pl systempreferences.pl
Log Message:
scripts to manage parameters tables
--- NEW FILE ---
#!/usr/bin/perl
#script to administer the aqbudget table
#written 20/02/2002 by paul.poulain(a)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 <<printend
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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);
}
}
</SCRIPT>
printend
;#/
if ($bookfundid) {
print "<h1>Modify book fund</h1>";
} else {
print "<h1>Add book fund</h1>";
}
print "<form action='$script_name' name=Aform method=post>";
print "<input type=hidden name=op value='add_validate'>";
print "<input type=hidden name=checked value=0>";
print "<table>";
if ($bookfundid) {
print "<tr><td>Book fund</td><td><input type=hidden name=bookfundid value=$bookfundid>$bookfundid</td></tr>";
} else {
print "<tr><td>Book fund</td><td><input type=text name=bookfundid size=5 maxlength=5 onBlur=toUC(this)></td></tr>";
}
print "<tr><td>Name</td><td><input type=text name=bookfundname size=40 maxlength=80 value='$data->{'bookfundname'}'> </td></tr>";
print "<tr><td>Group</td><td><input type=text name=bookfundgroup value='$data->{'bookfundgroup'}'></td></tr>";
print "<tr><td> </td><td><INPUT type=button value='OK' onClick='Check(this.form)'></td></tr>";
print "</table>";
print "</form>";
;
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 "<form action='$script_name' method=post><input type=hidden name=op value=delete_confirmed><input type=hidden name=bookfundid value='$bookfundid'>";
print "<tr><td>Name</td><td>$data->{'bookfundname'}</td></tr>";
print "<tr><td>Group</td><td>$data->{'bookfundgroup'}</td></tr>";
# if ($total->{'total'} >0) {
# print "<tr><td colspan=2 align=center><b>This record is used $total->{'total'} times. Deletion not possible</b></td></tr>";
# print "<tr><td colspan=2></form><form action='$script_name' method=post><input type=submit value=OK></form></td></tr>";
# } else {
print "<tr><td colspan=2 align=center>CONFIRM DELETION</td></tr>";
print "<tr><td><INPUT type=submit value='YES'></form></td><td><form action='$script_name' method=post><input type=submit value=NO></form></td></tr>";
# }
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 <<printend
printend
;
if ($searchfield ne '') {
print "You Searched for <b>$searchfield<b><p>";
}
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 "<form action='$script_name' method=post>";
print "<input type=hidden name=op value=add_form>";
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 "<br><input type=image src=\"/images/button-add-member.gif\" WIDTH=188 HEIGHT=44 ALT=\"Add budget\" BORDER=0 ></a><br>";
print "</form>";
} #---- END $OP eq DEFAULT
print endmenu('admin');
print endpage();
--- NEW FILE ---
#!/usr/bin/perl
#script to administer the aqbudget table
#written 20/02/2002 by paul.poulain(a)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 <<printend
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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);
}
}
</SCRIPT>
printend
;#/
if ($bookfundid) {
print "<h1>Modify budget</h1>";
} else {
print "<h1>Add budget</h1>";
}
print "<form action='$script_name' name=Aform method=post>";
print "<input type=hidden name=op value='add_validate'>";
print "<input type=hidden name=checked value=0>";
print "<table>";
if ($bookfundid) {
print "<tr><td>Book fund</td><td><input type=hidden name=bookfundid value=$bookfundid>$bookfundid</td></tr>";
} else {
print "<tr><td>Book fund</td><td><input type=text name=bookfundid size=5 maxlength=5 onBlur=toUC(this)></td></tr>";
}
print "<tr><td>Start date</td><td><input type=text name=startdate size=40 maxlength=80 value='$data->{'startdate'}'> </td></tr>";
print "<tr><td>End date</td><td><input type=text name=enddate value='$data->{'enddate'}'></td></tr>";
print "<tr><td>Budget amount</td><td><input type=text name=budgetamount value='$data->{'budgetamount'}'></td></tr>";
print "<tr><td> </td><td><INPUT type=button value='OK' onClick='Check(this.form)'></td></tr>";
print "</table>";
print "</form>";
;
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 "<form action='$script_name' method=post><input type=hidden name=op value=delete_confirmed><input type=hidden name=bookfundid value='$bookfundid'>";
print "<tr><td>Start date</td><td>$data->{'startdate'}</td></tr>";
print "<tr><td>End date</td><td>$data->{'enddate'}</td></tr>";
print "<tr><td>budgetamount</td><td>$data->{'budgetamount'}</td></tr>";
# if ($total->{'total'} >0) {
# print "<tr><td colspan=2 align=center><b>This record is used $total->{'total'} times. Deletion not possible</b></td></tr>";
# print "<tr><td colspan=2></form><form action='$script_name' method=post><input type=submit value=OK></form></td></tr>";
# } else {
print "<tr><td colspan=2 align=center>CONFIRM DELETION</td></tr>";
print "<tr><td><INPUT type=submit value='YES'></form></td><td><form action='$script_name' method=post><input type=submit value=NO></form></td></tr>";
# }
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 <<printend
printend
;
if ($searchfield ne '') {
print "You Searched for <b>$searchfield<b><p>";
}
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 "<form action='$script_name' method=post>";
print "<input type=hidden name=op value=add_form>";
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 "<br><input type=image src=\"/images/button-add-member.gif\" WIDTH=188 HEIGHT=44 ALT=\"Add budget\" BORDER=0 ></a><br>";
print "</form>";
} #---- END $OP eq DEFAULT
print endmenu('admin');
print endpage();
--- NEW FILE ---
#!/usr/bin/perl
#script to administer the aqbudget table
#written 20/02/2002 by paul.poulain(a)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 <<printend
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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);
}
}
</SCRIPT>
printend
;#/
if ($searchfield) {
print "<h1>Modify branch</h1>";
} else {
print "<h1>Add branch</h1>";
}
print "<form action='$script_name' name=Aform method=post>";
print "<input type=hidden name=op value='add_validate'>";
print "<table>";
if ($searchfield) {
print "<tr><td>Branch code</td><td><input type=hidden name=searchfield value=$searchfield>$searchfield</td></tr>";
} else {
print "<tr><td>Branch code</td><td><input type=text name=searchfield size=5 maxlength=5 onBlur=toUC(this)></td></tr>";
}
print "<tr><td>Name</td><td><input type=text name=branchname size=40 maxlength=80 value='$data->{'branchname'}'> </td></tr>";
print "<tr><td>Adress</td><td><input type=text name=branchaddress1 value='$data->{'branchaddress1'}'></td></tr>";
print "<tr><td> </td><td><input type=text name=branchaddress2 value='$data->{'branchaddress2'}'></td></tr>";
print "<tr><td> </td><td><input type=text name=branchaddress3 value='$data->{'branchaddress3'}'></td></tr>";
print "<tr><td>Phone</td><td><input type=text name=branchphone value='$data->{'branchphone'}'></td></tr>";
print "<tr><td>Fax</td><td><input type=text name=branchfax value='$data->{'branchfax'}'></td></tr>";
print "<tr><td>E-mail</td><td><input type=text name=branchemail value='$data->{'branchemail'}'></td></tr>";
print "<tr><td>Issuing</td><td><input type=text name=issuing value='$data->{'issuing'}'></td></tr>";
print "<tr><td> </td><td><INPUT type=button value='OK' onClick='Check(this.form)'></td></tr>";
print "</table>";
print "</form>";
;
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 "<form action='$script_name' method=post><input type=hidden name=op value=delete_confirmed><input type=hidden name=searchfield value='$searchfield'>";
print "<tr><td>Branch code</td><td>$data->{'branchcode'}</td></tr>";
print "<tr><td> name</td><td>$data->{'branchname'}</td></tr>";
print "<tr><td> adress</td><td>$data->{'branchaddress1'}</td></tr>";
print "<tr><td> </td><td>$data->{'branchaddress2'}</td></tr>";
print "<tr><td> </td><td>$data->{'branchaddress3'}</td></tr>";
print "<tr><td> phone</td><td>$data->{'branchphone'}</td></tr>";
print "<tr><td> fax</td><td>$data->{'branchfax'}</td></tr>";
print "<tr><td> e-mail</td><td>$data->{'branchemail'}</td></tr>";
print "<tr><td> issuing</td><td>$data->{'issuing'}</td></tr>";
if ($total->{'total'} >0) {
print "<tr><td colspan=2 align=center><b>This record is used $total->{'total'} times. Deletion not possible</b></td></tr>";
print "<tr><td colspan=2></form><form action='$script_name' method=post><input type=submit value=OK></form></td></tr>";
} else {
print "<tr><td colspan=2 align=center>CONFIRM DELETION</td></tr>";
print "<tr><td><INPUT type=submit value='YES'></form></td><td><form action='$script_name' method=post><input type=submit value=NO></form></td></tr>";
}
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 <<printend
printend
;
if ($searchfield ne '') {
print "You Searched for <b>$searchfield<b><p>";
}
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 "<form action='$script_name' method=post>";
print "<input type=hidden name=op value=add_form>";
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 "<br><input type=image src=\"/images/button-add-member.gif\" WIDTH=188 HEIGHT=44 ALT=\"Add budget\" BORDER=0 ></a><br>";
print "</form>";
} #---- END $OP eq DEFAULT
print endmenu('admin');
print endpage();
--- NEW FILE ---
#!/usr/bin/perl
#script to administer the categories table
#written 20/02/2002 by paul.poulain(a)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 <<printend
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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);
}
}
</SCRIPT>
printend
;#/
if ($categorycode) {
print "<h1>Modify category</h1>";
} else {
print "<h1>Add category</h1>";
}
print "<form action='$script_name' name=Aform method=post>";
print "<input type=hidden name=op value='add_validate'>";
print "<input type=hidden name=checked value=0>";
print "<table>";
if ($categorycode) {
print "<tr><td>Category code</td><td><input type=hidden name=categorycode value=$categorycode>$categorycode</td></tr>";
} else {
print "<tr><td>Category code</td><td><input type=text name=categorycode size=3 maxlength=2 onBlur=toUC(this)></td></tr>";
}
print "<tr><td>Description</td><td><input type=text name=description size=40 maxlength=80 value='$data->{'description'}'> </td></tr>";
print "<tr><td>Enrolment period</td><td><input type=text name=enrolmentperiod value='$data->{'enrolmentperiod'}'></td></tr>";
print "<tr><td>Upperage limit</td><td><input type=text name=upperagelimit value='$data->{'upperagelimit'}'></td></tr>";
print "<tr><td>Date of birth Required</td><td><input type=text name=dateofbirthrequired value='$data->{'dateofbirthrequired'}'> (14/02/2002)</td></tr>";
print "<tr><td>Fine type</td><td><input type=text name=finetype size=30 maxlength=30 value='$data->{'finetype'}'></td></tr>";
print "<tr><td>Bulk</td><td><input type=text name=bulk value='$data->{'bulk'}'></td></tr>";
print "<tr><td>Enrolment fee</td><td><input type=text name=enrolmentfee value='$data->{'enrolmentfee'}'></td></tr>";
print "<tr><td>Overdue notice required</td><td><input type=text name=overduenoticerequired value='$data->{'overduenoticerequired'}'></td></tr>";
print "<tr><td>Issue limit</td><td><input type=text name=issuelimit value='$data->{'issuelimit'}'></td></tr>";
print "<tr><td>Reserve fee</td><td><input type=text name=reservefee value='$data->{'reservefee'}'></td></tr>";
print "<tr><td> </td><td><INPUT type=button value='OK' onClick='Check(this.form)'></td></tr>";
print "</table>";
print "</form>";
;
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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'}<br>";
$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 "<form action='$script_name' method=post><input type=hidden name=op value=delete_confirmed><input type=hidden name=categorycode value='$categorycode'>";
print "<tr><td>Description</td><td>$data->{'description'}</td></tr>";
print "<tr><td>Enrolment period</td><td>$data->{'enrolmentperiod'}</td></tr>";
print "<tr><td>Upperage limit</td><td>$data->{'upperagelimit'}</td></tr>";
print "<tr><td>Date of birth Required</td><td>$data->{'dateofbirthrequired'}</td></tr>";
print "<tr><td>Fine type</td><td>$data->{'finetype'}</td></tr>";
print "<tr><td>Bulk</td><td>$data->{'bulk'}</td></tr>";
print "<tr><td>Enrolment fee</td><td>$data->{'enrolmentfee'}</td></tr>";
print "<tr><td>Overdue notice required</td><td>$data->{'overduenoticerequired'}</td></tr>";
print "<tr><td>Issue limit</td><td>$data->{'issuelimit'}</td></tr>";
print "<tr><td>Reserve fee</td><td>$data->{'reservefee'}</td></tr>";
if ($total->{'total'} >0) {
print "<tr><td colspan=2 align=center><b>This record is used $total->{'total'} times. Deletion not possible</b></td></tr>";
print "<tr><td colspan=2></form><form action='$script_name' method=post><input type=submit value=OK></form></td></tr>";
} else {
print "<tr><td colspan=2 align=center>CONFIRM DELETION</td></tr>";
print "<tr><td><INPUT type=submit value='YES'></form></td><td><form action='$script_name' method=post><input type=submit value=NO></form></td></tr>";
}
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 <<printend
printend
;
if ($searchfield ne '') {
print "You Searched for $searchfield<p>";
}
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
<form action='$script_name' method=post>
<input type=hidden name=op value=add_form>
<input type=image src="/images/button-add-member.gif" WIDTH=188 HEIGHT=44 ALT="Add Category" BORDER=0 ></a><br>
</form>
printend
;
} #---- END $OP eq DEFAULT
print endmenu('categorie');
print endpage();
--- NEW FILE ---
#!/usr/bin/perl
#script to administer the categories table
#written 20/02/2002 by paul.poulain(a)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 <<printend
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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);
}
}
</SCRIPT>
printend
;#/
if ($categorycode) {
print "<h1>Modify category</h1>";
} else {
print "<h1>Add category</h1>";
}
print "<form action='$script_name' name=Aform method=post>";
print "<input type=hidden name=op value='add_validate'>";
print "<input type=hidden name=checked value=0>";
print "<table>";
if ($categorycode) {
print "<tr><td>Category code</td><td><input type=hidden name=categorycode value=$categorycode>$categorycode</td></tr>";
} else {
print "<tr><td>Category code</td><td><input type=text name=categorycode size=3 maxlength=2 onBlur=toUC(this)></td></tr>";
}
print "<tr><td>Description</td><td><input type=text name=description size=40 maxlength=80 value='$data->{'description'}'> </td></tr>";
print "<tr><td>Enrolment period</td><td><input type=text name=enrolmentperiod value='$data->{'enrolmentperiod'}'></td></tr>";
print "<tr><td>Upperage limit</td><td><input type=text name=upperagelimit value='$data->{'upperagelimit'}'></td></tr>";
print "<tr><td>Date of birth Required</td><td><input type=text name=dateofbirthrequired value='$data->{'dateofbirthrequired'}'> (14/02/2002)</td></tr>";
print "<tr><td>Fine type</td><td><input type=text name=finetype size=30 maxlength=30 value='$data->{'finetype'}'></td></tr>";
print "<tr><td>Bulk</td><td><input type=text name=bulk value='$data->{'bulk'}'></td></tr>";
print "<tr><td>Enrolment fee</td><td><input type=text name=enrolmentfee value='$data->{'enrolmentfee'}'></td></tr>";
print "<tr><td>Overdue notice required</td><td><input type=text name=overduenoticerequired value='$data->{'overduenoticerequired'}'></td></tr>";
print "<tr><td>Issue limit</td><td><input type=text name=issuelimit value='$data->{'issuelimit'}'></td></tr>";
print "<tr><td>Reserve fee</td><td><input type=text name=reservefee value='$data->{'reservefee'}'></td></tr>";
print "<tr><td> </td><td><INPUT type=button value='OK' onClick='Check(this.form)'></td></tr>";
print "</table>";
print "</form>";
;
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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'}<br>";
$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 "<form action='$script_name' method=post><input type=hidden name=op value=delete_confirmed><input type=hidden name=categorycode value='$categorycode'>";
print "<tr><td>Description</td><td>$data->{'description'}</td></tr>";
print "<tr><td>Enrolment period</td><td>$data->{'enrolmentperiod'}</td></tr>";
print "<tr><td>Upperage limit</td><td>$data->{'upperagelimit'}</td></tr>";
print "<tr><td>Date of birth Required</td><td>$data->{'dateofbirthrequired'}</td></tr>";
print "<tr><td>Fine type</td><td>$data->{'finetype'}</td></tr>";
print "<tr><td>Bulk</td><td>$data->{'bulk'}</td></tr>";
print "<tr><td>Enrolment fee</td><td>$data->{'enrolmentfee'}</td></tr>";
print "<tr><td>Overdue notice required</td><td>$data->{'overduenoticerequired'}</td></tr>";
print "<tr><td>Issue limit</td><td>$data->{'issuelimit'}</td></tr>";
print "<tr><td>Reserve fee</td><td>$data->{'reservefee'}</td></tr>";
if ($total->{'total'} >0) {
print "<tr><td colspan=2 align=center><b>This record is used $total->{'total'} times. Deletion not possible</b></td></tr>";
print "<tr><td colspan=2></form><form action='$script_name' method=post><input type=submit value=OK></form></td></tr>";
} else {
print "<tr><td colspan=2 align=center>CONFIRM DELETION</td></tr>";
print "<tr><td><INPUT type=submit value='YES'></form></td><td><form action='$script_name' method=post><input type=submit value=NO></form></td></tr>";
}
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 <<printend
printend
;
if ($searchfield ne '') {
print "You Searched for $searchfield<p>";
}
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
<form action='$script_name' method=post>
<input type=hidden name=op value=add_form>
<input type=image src="/images/button-add-member.gif" WIDTH=188 HEIGHT=44 ALT="Add Category" BORDER=0 ></a><br>
</form>
printend
;
} #---- END $OP eq DEFAULT
print endmenu('categorie');
print endpage();
--- NEW FILE ---
#!/usr/bin/perl
#script to administer the aqbudget table
#written 20/02/2002 by paul.poulain(a)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 <<printend
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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);
}
}
</SCRIPT>
printend
;#/
if ($searchfield) {
print "<h1>Modify currency</h1>";
} else {
print "<h1>Add currency</h1>";
}
print "<form action='$script_name' name=Aform method=post>";
print "<input type=hidden name=op value='add_validate'>";
print "<table>";
if ($searchfield) {
print "<tr><td>Currency</td><td><input type=hidden name=currency value=$searchfield>$searchfield</td></tr>";
} else {
print "<tr><td>Currency</td><td><input type=text name=currency size=5 maxlength=5 onBlur=toUC(this)></td></tr>";
}
print "<tr><td>Rate</td><td><input type=text name=rate size=10 maxlength=10 value='$data->{'rate'}'> </td></tr>";
print "<tr><td> </td><td><INPUT type=button value='OK' onClick='Check(this.form)'></td></tr>";
print "</table>";
print "</form>";
;
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 "<form action='$script_name' method=post><input type=hidden name=op value=delete_confirmed><input type=hidden name=searchfield value='$searchfield'>";
print "<tr><td>Rate</td><td>$data->{'rate'}</td></tr>";
if ($total->{'total'} >0) {
print "<tr><td colspan=2 align=center><b>This record is used $total->{'total'} times. Deletion not possible</b></td></tr>";
print "<tr><td colspan=2></form><form action='$script_name' method=post><input type=submit value=OK></form></td></tr>";
} else {
print "<tr><td colspan=2 align=center>CONFIRM DELETION</td></tr>";
print "<tr><td><INPUT type=submit value='YES'></form></td><td><form action='$script_name' method=post><input type=submit value=NO></form></td></tr>";
}
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 <<printend
printend
;
if ($searchfield ne '') {
print "You Searched for <b>$searchfield<b><p>";
}
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 "<form action='$script_name' method=post>";
print "<input type=hidden name=op value=add_form>";
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 "<br><input type=image src=\"/images/button-add-member.gif\" WIDTH=188 HEIGHT=44 ALT=\"Add budget\" BORDER=0 ></a><br>";
print "</form>";
} #---- END $OP eq DEFAULT
print endmenu('admin');
print endpage();
--- NEW FILE ---
#!/usr/bin/perl
#script to administer the categories table
#written 20/02/2002 by paul.poulain(a)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 <<printend
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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);
}
}
</SCRIPT>
printend
;#/
if ($itemtype) {
print "<h1>Modify item type</h1>";
} else {
print "<h1>Add item type</h1>";
}
print "<form action='$script_name' name=Aform method=post>";
print "<input type=hidden name=op value='add_validate'>";
print "<input type=hidden name=checked value=0>";
print "<table>";
if ($itemtype) {
print "<tr><td>Item type</td><td><input type=hidden name=itemtype value=$itemtype>$itemtype</td></tr>";
} else {
print "<tr><td>Item type</td><td><input type=text name=itemtype size=5 maxlength=3 onBlur=toUC(this)></td></tr>";
}
print "<tr><td>Description</td><td><input type=text name=description size=40 maxlength=80 value='$data->{'description'}'> </td></tr>";
print "<tr><td>loan length</td><td><input type=text name=loanlength value='$data->{'loanlength'}'></td></tr>";
if ($data->{'renewalsallowed'} eq 1) {
print "<tr><td>Renewals allowed</td><td><input type=checkbox name=renewalsallowed checked value=1></td></tr>";
} else {
print "<tr><td>Renewals allowed</td><td><input type=checkbox name=renewalsallowed value=1></td></tr>";
}
# print "<tr><td>Renewals allowed</td><td><input type=text name=renewalsallowed value='$data->{'renewalsallowed'}'></td></tr>";
print "<tr><td>Rental charge</td><td><input type=text name=rentalcharge value='$data->{'rentalcharge'}'></td></tr>";
print "<tr><td> </td><td><INPUT type=button value='OK' onClick='Check(this.form)'></td></tr>";
print "</table>";
print "</form>";
;
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 "<form action='$script_name' method=post><input type=hidden name=op value=delete_confirmed><input type=hidden name=itemtype value='$itemtype'>";
print "<tr><td>Description</td><td>$data->{'description'}</td></tr>";
print "<tr><td>Loan length</td><td>$data->{'loanlength'}</td></tr>";
print "<tr><td>Renewals allowed</td><td>$data->{'renewalsallowed'}</td></tr>";
print "<tr><td>Rental charge</td><td>$data->{'rentalcharge'}</td></tr>";
if ($total->{'total'} >0) {
print "<tr><td colspan=2 align=center><b>This record is used $total->{'total'} times. Deletion not possible</b></td></tr>";
print "<tr><td colspan=2></form><form action='$script_name' method=post><input type=submit value=OK></form></td></tr>";
} else {
print "<tr><td colspan=2 align=center>CONFIRM DELETION</td></tr>";
print "<tr><td><INPUT type=submit value='YES'></form></td><td><form action='$script_name' method=post><input type=submit value=NO></form></td></tr>";
}
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 <<printend
printend
;
if ($searchfield ne '') {
print "You Searched for <b>$searchfield<b><p>";
}
print mktablehdr;
print mktablerow(7,'#99cc33',bold('Code'),bold('Description'),bold('loan<br>length'),bold('Renewals<br>allowed')
,bold('Rental<br>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 "<form action='$script_name' method=post>";
print "<input type=hidden name=op value=add_form>";
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 "<br><input type=image src=\"/images/button-add-member.gif\" WIDTH=188 HEIGHT=44 ALT=\"Add itemtype\" BORDER=0 ></a><br>";
print "</form>";
} #---- END $OP eq DEFAULT
print endmenu('admin');
print endpage();
--- NEW FILE ---
#!/usr/bin/perl
#script to administer the aqbudget table
#written 20/02/2002 by paul.poulain(a)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 <<printend
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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);
}
}
</SCRIPT>
printend
;#/
if ($searchfield) {
print "<h1>Modify printer</h1>";
} else {
print "<h1>Add printer</h1>";
}
print "<form action='$script_name' name=Aform method=post>";
print "<input type=hidden name=op value='add_validate'>";
print "<table>";
if ($searchfield) {
print "<tr><td>Printer</td><td><input type=hidden name=printername value='$searchfield'>$searchfield</td></tr>";
} else {
print "<tr><td>Printer</td><td><input type=text name=printername size=50 maxlength=50></td></tr>";
}
print "<tr><td>Queue</td><td><input type=text name=printqueue size=50 maxlength=50 value='$data->{'printqueue'}'> </td></tr>";
print "<tr><td>Type</td><td><input type=text name=printtype size=50 maxlength=50 value='$data->{'printtype'}'> </td></tr>";
print "<tr><td> </td><td><INPUT type=button value='OK' onClick='Check(this.form)'></td></tr>";
print "</table>";
print "</form>";
;
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 "<form action='$script_name' method=post><input type=hidden name=op value=delete_confirmed><input type=hidden name=searchfield value='$searchfield'>";
print "<tr><td>Queue</td><td>$data->{'printqueue'}</td></tr>";
print "<tr><td>Type</td><td>$data->{'printtype'}</td></tr>";
print "<tr><td colspan=2 align=center>CONFIRM DELETION</td></tr>";
print "<tr><td><INPUT type=submit value='YES'></form></td><td><form action='$script_name' method=post><input type=submit value=NO></form></td></tr>";
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 <<printend
printend
;
if ($searchfield ne '') {
print "You Searched for <b>$searchfield<b><p>";
}
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 "<form action='$script_name' method=post>";
print "<input type=hidden name=op value=add_form>";
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 "<br><input type=image src=\"/images/button-add-member.gif\" WIDTH=188 HEIGHT=44 ALT=\"Add budget\" BORDER=0 ></a><br>";
print "</form>";
} #---- END $OP eq DEFAULT
print endmenu('admin');
print endpage();
--- NEW FILE ---
#!/usr/bin/perl
#script to administer the stopwords table
#written 20/02/2002 by paul.poulain(a)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 <<printend
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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);
}
}
</SCRIPT>
printend
;#/
if ($searchfield) {
print "<h1>Modify word</h1>";
} else {
print "<h1>Add word</h1>";
}
print "<form action='$script_name' name=Aform method=post>";
print "<input type=hidden name=op value='add_validate'>";
print "<table>";
if ($searchfield) {
print "<tr><td>Word</td><td><input type=hidden name=word value='$searchfield'>$searchfield</td></tr>";
} else {
print "<tr><td>Word</td><td><input type=text name=word size=255 maxlength=255></td></tr>";
}
print "<tr><td> </td><td><INPUT type=button value='OK' onClick='Check(this.form)'></td></tr>";
print "</table>";
print "</form>";
;
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 "<form action='$script_name' method=post><input type=hidden name=op value=delete_confirmed><input type=hidden name=searchfield value='$searchfield'>";
print "<tr><td colspan=2 align=center>CONFIRM DELETION</td></tr>";
print "<tr><td><INPUT type=submit value='YES'></form></td><td><form action='$script_name' method=post><input type=submit value=NO></form></td></tr>";
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 <<printend
printend
;
if ($searchfield ne '') {
print "You Searched for <b>$searchfield<b><p>";
}
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 "<form action='$script_name' method=post>";
print "<input type=hidden name=op value=add_form>";
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 "<br><input type=image src=\"/images/button-add-member.gif\" WIDTH=188 HEIGHT=44 ALT=\"Add budget\" BORDER=0 ></a><br>";
print "</form>";
} #---- END $OP eq DEFAULT
print endmenu('admin');
print endpage();
--- NEW FILE ---
#!/usr/bin/perl
#script to administer the systempref table
#written 20/02/2002 by paul.poulain(a)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 <<printend
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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);
}
}
</SCRIPT>
printend
;#/
if ($searchfield) {
print "<h1>Modify pref</h1>";
} else {
print "<h1>Add pref</h1>";
}
print "<form action='$script_name' name=Aform method=post>";
print "<input type=hidden name=op value='add_validate'>";
print "<table>";
if ($searchfield) {
print "<tr><td>Variable</td><td><input type=hidden name=variable value='$searchfield'>$searchfield</td></tr>";
} else {
print "<tr><td>Variable</td><td><input type=text name=variable size=255 maxlength=255></td></tr>";
}
print "<tr><td>Value</td><td><input type=text name=value value='$data->{'value'}'></td></tr>";
print "<tr><td> </td><td><INPUT type=button value='OK' onClick='Check(this.form)'></td></tr>";
print "</table>";
print "</form>";
;
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 "<tr><td>Value</td><td>$data->{'value'}</td></tr>";
print "<form action='$script_name' method=post><input type=hidden name=op value=delete_confirmed><input type=hidden name=searchfield value='$searchfield'>";
print "<tr><td colspan=2 align=center>CONFIRM DELETION</td></tr>";
print "<tr><td><INPUT type=submit value='YES'></form></td><td><form action='$script_name' method=post><input type=submit value=NO></form></td></tr>";
# 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 "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# 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 <<printend
<b>Hints :</b>
2 variables are useful in this table :
<li><i>acquisitions</i>, which value may be "simple" or "normal"</li>
<li><i>autoMemberNum</i> which may be 1 or 0</li>
<br><br>
printend
;
if ($searchfield ne '') {
print "You Searched for <b>$searchfield<b><p>";
}
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 "<form action='$script_name' method=post>";
print "<input type=hidden name=op value=add_form>";
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 "<br><input type=image src=\"/images/button-add-member.gif\" WIDTH=188 HEIGHT=44 ALT=\"Add budget\" BORDER=0 ></a><br>";
print "</form>";
} #---- END $OP eq DEFAULT
print endmenu('admin');
print endpage();
3
2
Update of /cvsroot/koha/koha/admin
In directory usw-pr-cvs1:/tmp/cvs-serv13077/admin
Log Message:
Directory /cvsroot/koha/koha/admin added to the repository
1
0
3
3