Templating...

This commit is contained in:
wolfpac444 2003-04-04 21:56:44 +00:00
parent 90b872afc8
commit d5cf2dfbb1
2 changed files with 166 additions and 57 deletions

View file

@ -41,6 +41,9 @@ use CGI;
use C4::Context;
use C4::Output;
use C4::Search;
use HTML::Template;
use C4::Auth;
use C4::Interface::CGI::Output;
sub StringSearch {
my ($env,$searchstring,$type)=@_;
@ -80,7 +83,8 @@ my ($template, $loggedinuser, $cookie)
$template->param(script_name => $script_name,
categorycode => $categorycode);
categorycode => $categorycode,
searchfield => $searchfield);
################## ADD_FORM ##################################
@ -108,7 +112,6 @@ if ($op eq 'add_form') {
overduenoticerequired => $data->{'overduenoticerequired'},
issuelimit => $data->{'issuelimit'},
reservefee => $data->{'reservefee'});
}
# END $OP eq ADD_FORM
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
@ -147,26 +150,22 @@ if ($op eq 'add_form') {
$sth2->execute;
my $data=$sth2->fetchrow_hashref;
$sth2->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>Age 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>";
$template->param(totalgtzero => 1);
}
$template->param(description => $data->{'description'},
enrolmentperiod => $data->{'enrolmentperiod'},
upperagelimit => $data->{'upperagelimit'},
dateofbirthrequired => $data->{'dateofbirthrequired'},
finetype => $data->{'finetype'},
bulk => $data->{'bulk'},
enrolmentfee => $data->{'enrolmentfee'},
overduenoticerequired => $data->{'overduenoticerequired'},
issuelimit => $data->{'issuelimit'},
reservefee => $data->{'reservefee'});
# END $OP eq DELETE_CONFIRM
################## DELETE_CONFIRMED ##################################
# called by delete_confirm, used to effectively confirm deletion of data in DB
@ -177,44 +176,27 @@ if ($op eq 'add_form') {
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'),'&nbsp;','&nbsp;','/images/background-mem.gif');
$template->param(else => 1);
my $env;
my @loop;
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'));
my %row = (categorycode => $results->[$i]{'categorycode'},
description => $results->[$i]{'description'},
enrolmentperiod => $results->[$i]{'enrolmentperiod'},
upperagelimit => $results->[$i]{'upperagelimit'},
dateofbirthrequired => $results->[$i]{'dateofbirthrequired'},
finetype => $results->[$i]{'finetype'},
bulk => $results->[$i]{'bulk'},
enrolmentfee => $results->[$i]{'enrolmentfee'},
overduenoticerequired => $results->[$i]{'overduenoticerequired'},
issuelimit => $results->[$i]{'issuelimit'},
reservefee => $results->[$i]{'reservefee'} );
push @loop, \%row;
}
$template->param(loop => \@loop);

View file

@ -1,4 +1,4 @@
<TMPL_INCLUDE NAME="admin-top.tmpl">
<TMPL_INCLUDE NAME="parameters-top.inc">
<TMPL_IF NAME=add_form>
<script>
@ -168,12 +168,139 @@
<TMPL_IF NAME=delete_confirm>
TOTAL : <TMPL_VAR NAME=categorycode> : <TMPL_VAR NAME=total><br>
<table border=0 cellspacing=0 cellpadding=5>
<tr bgcolor='#99cc33'>
<td background='/images/background-mem.gif'>
<b>Category code</b>
</td>
<td background='/images/background-mem.gif'>
<TMPL_VAR NAME=categorycode>
</td>
</tr>
<form action='<TMPL_VAR NAME=script_name>' method=post>
<input type=hidden name=op value=delete_confirmed>
<input type=hidden name=categorycode value=<TMPL_VAR NAME=categorycode>>
<tr>
<td>Description</td>
<td><TMPL_VAR NAME=description></td>
</tr>
<tr>
<td>Enrolment period</td>
<td><TMPL_VAR NAME=enrolmentperiod></td>
</tr>
<tr>
<td>Upperage limit</td>
<td><TMPL_VAR NAME=upperagelimit></td>
</tr>
<tr>
<td>Age Required</td>
<td><TMPL_VAR NAME=dateofbirthrequired></td>
</tr>
<tr>
<td>Fine type</td>
<td><TMPL_VAR NAME=finetype></td>
</tr>
<tr>
<td>Bulk</td>
<td><TMPL_VAR NAME=bulk></td>
</tr>
<tr>
<td>Enrolment fee</td>
<td><TMPL_VAR NAME=enrolmentfee></td>
</tr>
<tr>
<td>Overdue notice required</td>
<td><TMPL_VAR NAME=overduenoticerequired></td>
</tr>
<tr>
<td>Issue limit</td>
<td><TMPL_VAR NAME=isssuelimit></td>
</tr>
<tr>
<td>Reserve fee</td>
<td><TMPL_VAR NAME=reservefee></td>
</tr>
<TMPL_IF NAME=totalgtzero>
<tr>
<td colspan=2 align=center><b>This record is used <TMPL_VAR NAME=total> times. Deletion not possible</b></td>
</tr>
<tr>
<td colspan=2>
</form><form action='<TMPL_VAR NAME=script_name>' method=post>
<input type=submit value=OK>
</form>
</td>
</tr>
<TMPL_ELSE>
<tr>
<td colspan=2 align=center>CONFIRM DELETION</td>
</tr>
<tr>
<td><INPUT type=submit value='YES'></form></td>
<td><form action='<TMPL_VAR NAME=script_name>' method=post><input type=submit value==NO></form></td>
</tr>
</TMPL_IF>
</TMPL_IF>
<TMPL_IF NAME=delete_confirmed>
data deleted
<form action='<TMPL_VAR NAME=script_name>' method=post>
<input type=submit value=OK>
</form>
</TMPL_IF>
<TMPL_IF NAME=else>
<h2>Category admin</h2>
<TMPL_IF NAME=searchfield>
You Searched for <TMPL_VAR NAME=searchfield>
</TMPL_IF>
<form action='<TMP_VAR NAME=script_name>' method=post>
<input type=text name=description value=<TMPL_VAR NAME=searchfield>>
<input type=reset name=reset value="clr">
</form>
<table border=0 cellspacing=0 cellpadding=5>
<tr bgcolor='#99cc33'>
<td background='/images/background-mem.gif'><b>Category</b></td>
<td background='/images/background-mem.gif'><b>Description</b></td>
<td background='/images/background-mem.gif'><b>Enrolment</b></td>
<td background='/images/background-mem.gif'><b>Upper Age Limit</b></td>
<td background='/images/background-mem.gif'><b>Age Required</b></td>
<td background='/images/background-mem.gif'><b>Fine</b></td>
<td background='/images/background-mem.gif'><b>Bulk</b></td>
<td background='/images/background-mem.gif'><b>Fee</b></td>
<td background='/images/background-mem.gif'><b>Overdue</b></td>
<td background='/images/background-mem.gif'><b>Issue Limit</b></td>
<td background='/images/background-mem.gif'><b>Reserve</b></td>
<td background='/images/background-mem.gif'> </td>
<td background='/images/background-mem.gif'> </td>
</tr>
<TMPL_LOOP NAME=loop>
<tr bgcolor="white">
<td><TMPL_VAR NAME=categorycode></td>
<td><TMPL_VAR NAME=description></td>
<td><TMPL_VAR NAME=enrolmentperiod></td>
<td><TMPL_VAR NAME=upperagelimit></td>
<td><TMPL_VAR NAME=dateofbirthrequired></td>
<td><TMPL_VAR NAME=finetype></td>
<td><TMPL_VAR NAME=bulk></td>
<td><TMPL_VAR NAME=enrolmentfee></td>
<td><TMPL_VAR NAME=overduenoticerequired></td>
<td><TMPL_VAR NAME=issuelimit></td>
<td><TMPL_VAR NAME=reservefee></td>
<td><a href="<TMPL_VAR NAME=script_name>?op=add_form&categorycode=<TMPL_VAR NAME=categorycode>">Edit</a></td>
<td><a href="<TMPL_VAR NAME=script_name>?op=delete_confirm&categorycode=<TMPL_VAR NAME=categorycode>">Delete</a></td>
</tr>
</TMPL_LOOP>
</table>
<form action=<TMPL_VAR NAME=script_name> method=post>
<p><form action='<TMPL_VAR NAME=script_name>' method=post>
<input type=hidden name=op value=add_form>
<input type=image src="/images/button-add-new.gif" WIDTH=188 HEIGHT=44 ALT="Add Category" BORDER=0 ></a><br>
</form>
</BODY>
</HTML>
</form></p>
</TMPL_IF>
<TMPL_INCLUDE NAME="parameters-bottom.inc">