koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/admin charges.pl,NONE,1.1 updatecharges.pl,NONE,1.1


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha/admin charges.pl,NONE,1.1 updatecharges.pl,NONE,1.1
Date: Mon, 06 Oct 2003 06:40:51 -0700

Update of /cvsroot/koha/koha/admin
In directory sc8-pr-cvs1:/tmp/cvs-serv2863/admin

Added Files:
        charges.pl updatecharges.pl 
Log Message:
moving & templating charges to admin part of Koha

--- NEW FILE ---
#!/usr/bin/perl

# Copyright 2000-2002 Katipo Communications
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA  02111-1307 USA

use strict;
use CGI;
use C4::Context;
use C4::Output;
use C4::Database;
use C4::Auth;
use C4::Output;
use C4::Interface::CGI::Output;
use HTML::Template;

my $input = new CGI;

my $flagsrequired;
$flagsrequired->{circulation}=1;
my ($template, $loggedinuser, $cookie)
    = get_template_and_user({template_name => "parameters/charges.tmpl",
                             query => $input,
                             type => "intranet",
                             authnotrequired => 0,
                             flagsrequired => {parameters => 1},
                              debug => 1,
                             });

my $type=$input->param('type');

my $dbh = C4::Context->dbh;
my $query="Select description,categorycode from categories";
my $sth=$dbh->prepare($query);
$sth->execute;
 my @trow3;
my @title_loop;
my $i=0;
while (my $data=$sth->fetchrow_hashref){
        my %row = (in_title => $data->{'description'});
        push @title_loop,\%row;
        $trow3[$i]=$data->{'categorycode'};
        $i++;
}
$sth->finish;
$query="Select description,itemtype from itemtypes";
$sth=$dbh->prepare($query);
$sth->execute;
$i=0;
my $toggle="white";
my @row_loop;
while (my $data=$sth->fetchrow_hashref){
        my @trow2;
        my @cell_loop;
        if ( $toggle eq 'white' ) {
                $toggle = '#ffffcc';
        } else {
                $toggle = 'white';
        }
        for ($i=0;$i<9;$i++){
                $query="select * from categoryitem where categorycode=? and 
itemtype=?";
                my $sth2=$dbh->prepare($query);
                $sth2->execute($trow3[$i],$data->{'itemtype'});
                my $dat=$sth2->fetchrow_hashref;
                $sth2->finish;
                my $fine=$dat->{'fine'}+0;
#               $trow2[$i]="<input type=text 
name=\"$trow3[$i].$data->{'itemtype'}\" 
value=\"$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}\" size=6>";
                my %row = (inputname=> "$trow3[$i].$data->{'itemtype'}",
                                                inputvalue => 
"$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}",
                                                toggle => $toggle,
                                                );
                push @cell_loop,\%row;
        }
        my %row = (categorycode => $data->{description},
                                        cell =>address@hidden);
        push @row_loop, \%row;
}

$sth->finish;
$template->param(title => address@hidden,
                                                row => address@hidden);
output_html_with_http_headers $input, $cookie, $template->output;

--- NEW FILE ---
#!/usr/bin/perl

# $Id: updatecharges.pl,v 1.1 2003/10/06 13:40:49 tipaul Exp $

#script to update charges for overdue in database
#updates categoryitem
# is called by charges.pl
# written 1/1/2000 by address@hidden


# Copyright 2000-2002 Katipo Communications
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA  02111-1307 USA

use strict;
use CGI;
use C4::Context;
use C4::Output;

my $input = new CGI;

my $dbh = C4::Context->dbh;
my @names=$input->param();

foreach my $key (@names){
        $key =~ /(.*)\.(.*)/;
        my $bor=$1;
        my $cat=$2;
        my $data=$input->param($key);
        my @dat=split(',',$data);
        my $sth_search = $dbh->prepare("select count(*) as total from 
categoryitem where categorycode=? and itemtype=?");
        my $sth_insert = $dbh->prepare("insert into categoryitem 
(categorycode,itemtype,fine,firstremind,chargeperiod) values (?,?,?,?,?)");
        my $sth_update=$dbh->prepare("Update categoryitem set 
fine=?,firstremind=?,chargeperiod=? where categorycode=? and itemtype=?");
        $sth_search->execute($bor,$cat);
        my $res = $sth_search->fetchrow_hashref();
        if ($res->{total}) {
                $sth_update->execute($dat[0],$dat[1],$dat[2],$bor,$cat);
        } else {
                $sth_insert->execute($bor,$cat,$dat[0],$dat[1],$dat[2]);
        }
}
print $input->redirect("/cgi-bin/koha/admin/charges.pl");




reply via email to

[Prev in Thread] Current Thread [Next in Thread]