koha-cvs
[Top][All Lists]
Advanced

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

[Koha-cvs] koha admin/aqbookfund.pl admin/aqbudget.pl admi...


From: Tumer Garip
Subject: [Koha-cvs] koha admin/aqbookfund.pl admin/aqbudget.pl admi...
Date: Wed, 27 Sep 2006 21:19:22 +0000

CVSROOT:        /sources/koha
Module name:    koha
Changes by:     Tumer Garip <tgarip1957>        06/09/27 21:19:22

Modified files:
        admin          : aqbookfund.pl aqbudget.pl issuingrules.pl 
                         koha-electronic.pl koha_attr.pl 
        authorities    : authorities.pl blinddetail-linker.pl 
        bookshelves    : addbookbybiblionumber.pl shelves.pl 
        catalogue      : ISBDdetail.pl 
        cataloguing    : addbiblio.pl addbooks.pl additem.pl 
                         isbnsearch.pl 
        circ           : rescirculation.pl 
        .              : logout.pl mainpage.pl 
        members        : boraccount.pl mancredit.pl maninvoice.pl 
                         memberentry.pl moremember.pl pay.pl 
        serials        : acqui-search-result.pl acqui-search.pl 
                         distributedto.pl lateissues.pl printlist.pl 
                         serial-issues.pl serials-home.pl 
                         serials-receive.pl subscription-add.pl 
                         subscription-renew.pl viewalerts.pl 
        tools          : exceptionHolidays.pl holidays.pl import.pl 
                         printerConfig.pl tools-home.pl 

Log message:
        Finalized XML version for intranet

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/admin/aqbookfund.pl?cvsroot=koha&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/koha/admin/aqbudget.pl?cvsroot=koha&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/koha/admin/issuingrules.pl?cvsroot=koha&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/koha/admin/koha-electronic.pl?cvsroot=koha&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/admin/koha_attr.pl?cvsroot=koha&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/authorities/authorities.pl?cvsroot=koha&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/koha/authorities/blinddetail-linker.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/bookshelves/addbookbybiblionumber.pl?cvsroot=koha&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/koha/bookshelves/shelves.pl?cvsroot=koha&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/koha/catalogue/ISBDdetail.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/addbiblio.pl?cvsroot=koha&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/addbooks.pl?cvsroot=koha&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/additem.pl?cvsroot=koha&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/isbnsearch.pl?cvsroot=koha&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/koha/circ/rescirculation.pl?cvsroot=koha&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/logout.pl?cvsroot=koha&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/koha/mainpage.pl?cvsroot=koha&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/koha/members/boraccount.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/members/mancredit.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/members/maninvoice.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/members/memberentry.pl?cvsroot=koha&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/koha/members/moremember.pl?cvsroot=koha&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/koha/members/pay.pl?cvsroot=koha&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/koha/serials/acqui-search-result.pl?cvsroot=koha&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/koha/serials/acqui-search.pl?cvsroot=koha&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/koha/serials/distributedto.pl?cvsroot=koha&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/koha/serials/lateissues.pl?cvsroot=koha&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/koha/serials/printlist.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/serials/serial-issues.pl?cvsroot=koha&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/koha/serials/serials-home.pl?cvsroot=koha&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/koha/serials/serials-receive.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/serials/subscription-add.pl?cvsroot=koha&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/koha/serials/subscription-renew.pl?cvsroot=koha&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/koha/serials/viewalerts.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/tools/exceptionHolidays.pl?cvsroot=koha&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/tools/holidays.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/tools/import.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/tools/printerConfig.pl?cvsroot=koha&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/tools/tools-home.pl?cvsroot=koha&r1=1.1&r2=1.2

Patches:
Index: admin/aqbookfund.pl
===================================================================
RCS file: /sources/koha/koha/admin/aqbookfund.pl,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- admin/aqbookfund.pl 11 Sep 2006 17:41:54 -0000      1.31
+++ admin/aqbookfund.pl 27 Sep 2006 21:19:21 -0000      1.32
@@ -1,24 +1,6 @@
 #!/usr/bin/perl
 
-#script to administer the aqbudget table
 #written 20/02/2002 by address@hidden
-# 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
-
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -37,111 +19,89 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
+
+=head1 NAME
+
+aqbookfund.pl
+
+=head1 DESCRIPTION
+
+script to administer the aqbudget table.
+
+=head1 CGI PARAMETERS
+
+=over 4
+
+=item op
+this script use an C<$op> to know what to do.
+C<op> can be equal to:
+* empty or none of the above values, then
+    - the default screen is build (with all records, or filtered datas).
+       - the   user can clic on add, modify or delete record.
+* add_form, then
+       - if primkey exists, this is a modification,so we read the $primkey 
record
+       - builds the add/modify form
+* add_validate, then
+       - the user has just send datas, so we create/modify the record
+* delete_form, then
+       - we show the record having primkey=$primkey and ask for deletion 
validation form
+* delete_confirm, then
+    - we delete the record having primkey=$primkey
+
+=cut
+
 use strict;
 use CGI;
+use C4::Output;
+use List::Util qw/min/;
 use C4::Auth;
-use C4::Context;
-use C4::Acquisition;
 use C4::Koha;
+use C4::Context;
+use C4::Bookfund;
 use C4::Interface::CGI::Output;
 use C4::Search;
 use C4::Date;
 
-
-sub StringSearch  {
-       my ($env,$searchstring,%branches)address@hidden;
-       my $dbh = C4::Context->dbh;
-       $searchstring=~ s/\'/\\\'/g;
-       my @data=split(' ',$searchstring) if ($searchstring ne "");
-       my address@hidden;
-       my $strsth= "select bookfundid,bookfundname,bookfundgroup,branchcode 
from aqbookfund where 1 ";
-       $strsth.=" AND bookfundname like ? " if ($searchstring ne "");
-       if (%branches){
-               $strsth.= "AND (aqbookfund.branchcode is null " ;
-               foreach my $branchcode (keys %branches){
-                       $strsth .= "or aqbookfund.branchcode = 
'".$branchcode."' "; 
-               }
-               $strsth .= ") ";
-       }
-       $strsth.= "order by aqbookfund.bookfundid";
-#      warn "chaine de recherche : ".$strsth;
-       
-       my $sth=$dbh->prepare($strsth);
-       if ($searchstring){
-               $sth->execute("%$data[0]%");
-       } else {
-               $sth->execute;
-       }
-       my @results;
-       while (my $data=$sth->fetchrow_hashref){
-               push(@results,$data);
-#              warn "id ".$data->{bookfundid}." name ".$data->{bookfundname}." 
branchcode ".$data->{branchcode};
-       }
-       #  $sth->execute;
-       $sth->finish;
-       return (scalar(@results),address@hidden);
-}
-
+my $dbh = C4::Context->dbh;
 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;
+my $pagesize = 10;
+my $op = $input->param('op') || '';
 
 my ($template, $borrowernumber, $cookie)
-    = get_template_and_user({template_name => "admin/aqbookfund.tmpl",
+    = get_template_and_user(
+        {template_name => "admin/aqbookfund.tmpl",
                             query => $input,
                             type => "intranet",
                             authnotrequired => 0,
                             flagsrequired => {parameters => 1, management => 
1},
                             debug => 1,
-                            });
+        }
+    );
 
 if ($op) {
-$template->param(script_name => $script_name,
-               $op              => 1); # we show only the TMPL_VAR names $op
-} else {
-$template->param(script_name => $script_name,
+    $template->param(
+        script_name => $script_name,
+        $op => 1,
+    ); # we show only the TMPL_VAR names $op
+}
+else {
+    $template->param(script_name => $script_name,
                else              => 1); # we show only the TMPL_VAR names $op
 }
 $template->param(action => $script_name);
 
-
-my @select_branch;
-my %select_branches;
-my ($branches)=GetBranches();
-
-push @select_branch,"";
-$select_branches{""}="";
-
-my $homebranch=C4::Context->userenv->{branch};
-foreach my $brnch (keys %$branches){
-       push @select_branch, $branches->{$brnch}->{'branchcode'};#
-       $select_branches{$branches->{$brnch}->{'branchcode'}} = 
$branches->{$brnch}->{'branchname'};
-}
-
-my $CGIbranch=CGI::scrolling_list( -name     => 'branchcode',
-                       -values   => address@hidden,
-                       -labels   => \%select_branches,
-                       -size     => 1,
-                       -multiple => 0 );
-$template->param(CGIbranch => $CGIbranch);
+my $branches = GetBranches;
 
 ################## 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;
+       my $dataaqbookfund;
        my $header;
        if ($bookfundid) {
-               my $dbh = C4::Context->dbh;
-               my $sth=$dbh->prepare("select 
bookfundid,bookfundname,bookfundgroup from aqbookfund where bookfundid=?");
-               $sth->execute($bookfundid);
-               $data=$sth->fetchrow_hashref;
-               $sth->finish;
+       $dataaqbookfund = GetBookFund($bookfundid);
            }
        if ($bookfundid) {
            $header = "Modify book fund";
@@ -151,112 +111,176 @@
            $template->param('header-is-add-p' => 1);
        }
        $template->param('use-header-flags-p' => 1);
-       $template->param(header => $header); # NOTE deprecated
+       $template->param(header => $header); 
        my $add_or_modify=0;
        if ($bookfundid) {
            $add_or_modify=1;
        }
        $template->param(add_or_modify => $add_or_modify);
        $template->param(bookfundid =>$bookfundid);
-       $template->param(bookfundname =>$data->{'bookfundname'});
+       $template->param(bookfundname =>$dataaqbookfund->{'bookfundname'});
+warn $dataaqbookfund->{'bookfundname'};
+        my @branchloop;
+        foreach my $branchcode (sort keys %{$branches}) {
+            my $row = {
+                branchcode => $branchcode,
+                branchname => $branches->{$branchcode}->{branchname},
+            };
+
+            if ( $bookfundid    && $dataaqbookfund->{branchcode} eq 
$branchcode) {
+                $row->{selected} = 1;
+            }
+
+            push @branchloop, $row;
+        }
+
+        $template->param(branches => address@hidden);
+
+} # END $OP eq ADD_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 = C4::Context->dbh;
-       my $bookfundid=uc($input->param('bookfundid'));
-       my $sth=$dbh->prepare("delete from aqbookfund where bookfundid =?");
-       $sth->execute($bookfundid);
-       $sth->finish;
-       if ($input->param('branchcode') ne ""){
-               my $sth=$dbh->prepare("replace aqbookfund 
(bookfundid,bookfundname,branchcode) values (?,?,?)");
-               
$sth->execute($input->param('bookfundid'),$input->param('bookfundname'),$input->param('branchcode'));
-               $sth->finish;
-       } else {
-               my $sth=$dbh->prepare("replace aqbookfund 
(bookfundid,bookfundname) values (?,?)");
-               
$sth->execute($input->param('bookfundid'),$input->param('bookfundname'));
-               $sth->finish;
-       }
-       print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; 
URL=aqbookfund.pl\"></html>";
-       exit;
+elsif ($op eq 'add_validate') {
+       my $bookfundid = uc $input->param('bookfundid');
+
+    my $number = Countbookfund($bookfundid);
+
+    my $bookfund_already_exists = $number > 0 ? 1 : 0;
+
+    if ($bookfund_already_exists) {
+        my $bookfundname = $input->param('bookfundname');
+        my $branchcode = $input->param('branchcode') || undef;
                        
-                                                                               
# END $OP eq ADD_VALIDATE
+        ModBookFund($bookfundname,$branchcode,$bookfundid);
+    }
+    else {
+        NewBookFund(
+            $bookfundid,
+            $input->param('bookfundname'),
+            $input->param('branchcode')
+        );
+    }
+    $input->redirect('aqbookfund.pl');
+# 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 = C4::Context->dbh;
-       my $sth=$dbh->prepare("select bookfundid,bookfundname,bookfundgroup 
from aqbookfund where bookfundid=?");
-       $sth->execute($bookfundid);
-       my $data=$sth->fetchrow_hashref;
-       $sth->finish;
+
+elsif ($op eq 'delete_confirm') {
+    my $data = GetBookFund($bookfundid);
        $template->param(bookfundid => $bookfundid);
        $template->param(bookfundname => $data->{'bookfundname'});
-                                                                               
                        # END $OP eq DELETE_CONFIRM
+} # 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 = C4::Context->dbh;
-       my $bookfundid=uc($input->param('bookfundid'));
-       my $sth=$dbh->prepare("delete from aqbookfund where bookfundid=?");
-       $sth->execute($bookfundid);
-       $sth->finish;
-       $sth=$dbh->prepare("delete from aqbudget where bookfundid=?");
-       $sth->execute($bookfundid);
-       $sth->finish;
-                                                                               
                        # END $OP eq DELETE_CONFIRMED
+elsif ($op eq 'delete_confirmed') {
+    DelBookFund(uc($input->param('bookfundid')));
+
+}# END $OP eq DELETE_CONFIRMED
+
+
 ################## DEFAULT ##################################
-} else { # DEFAULT
+else { # DEFAULT
+    my ($query, $sth);
+
        $template->param(scriptname => $script_name);
-       if  ($searchfield ne '') {
-               $template->param(search => 1);
-               $template->param(searchfield => $searchfield);
-       }
-       my $env;
-       my ($count,$results)=StringSearch($env,$searchfield,%select_branches);
-       my $toggle="white";
-       my @loop_data =();
-       my $dbh = C4::Context->dbh;
-       for (my $i=$offset; $i < 
($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
-#              warn "i ".$i." offset".$offset." pagesize ".$pagesize." id 
".$results->[$i]{bookfundid}." name ".$results->[$i]{bookfundname}." branchcode 
".$results->[$i]{branchcode};
-               my %row_data;
-               $row_data{bookfundid} =$results->[$i]{'bookfundid'};
-               $row_data{bookfundname} = $results->[$i]{'bookfundname'};
-#              warn "".$results->[$i]{'bookfundid'}." 
".$results->[$i]{'bookfundname'}." ".$results->[$i]{'branchcode'};
-               $row_data{branchname} = 
$select_branches{$results->[$i]{'branchcode'}};
-               my $strsth2="Select aqbudgetid,startdate,enddate,budgetamount 
from aqbudget where aqbudget.bookfundid = ?";
-#              my $strsth2="Select 
aqbudgetid,startdate,enddate,budgetamount,branchcode from aqbudget where 
aqbudget.bookfundid = ?";
-#              if ($homebranch){
-#                      $strsth2 .= " AND ((aqbudget.branchcode is null) OR 
(aqbudget.branchcode='') OR (aqbudget.branchcode= 
".$dbh->quote($homebranch).")) " ;
-#              } else {
-#                      $strsth2 .= " AND (aqbudget.branchcode='') " if 
((C4::Context->userenv) && (C4::Context->userenv->{flags}>1));
-#              }
-               $strsth2 .= " order by aqbudgetid";
-#              warn "".$strsth2;
-               my $sth2 = $dbh->prepare($strsth2);
-               $sth2->execute($row_data{bookfundid});
-               my @budget_loop;
-#              while (my 
($aqbudgetid,$startdate,$enddate,$budgetamount,$branchcode) = $sth2->fetchrow) {
-               while (my ($aqbudgetid,$startdate,$enddate,$budgetamount) = 
$sth2->fetchrow) {
-                       my %budgetrow_data;
-                       $budgetrow_data{aqbudgetid} = $aqbudgetid;
-                       $budgetrow_data{startdate} = format_date($startdate);
-                       $budgetrow_data{enddate} = format_date($enddate);
-                       $budgetrow_data{budgetamount} = $budgetamount;
-#                      $budgetrow_data{branchcode} = $branchcode;
-                       push @budget_loop,\%budgetrow_data;
-               }
-               $row_data{budget} = address@hidden;
-               push @loop_data,\%row_data;
-       }
-       $template->param(max => 
(($count>$offset+$pagesize)?$offset+$pagesize:$count));
-       $template->param(min => ($offset?$offset:1));
-       $template->param(nbresults => $count);
-       $template->param(Next => ($count>$offset+$pagesize)) if 
($count>$offset+$pagesize);
-       $template->param(bookfund => address@hidden);
+
+    # filters
+    my @branchloop;
+    foreach my $branchcode (sort keys %{$branches}) {
+        my $row = {
+            code => $branchcode,
+            name => $branches->{$branchcode}->{branchname},
+        };
+
+        if (defined $input->param('filter_branchcode')
+            and $input->param('filter_branchcode') eq $branchcode) {
+            $row->{selected} = 1;
+        }
+
+        push @branchloop, $row;
+    }
+
+    my @bookfundids_loop;
+    my $sth = GetBookFundsId();
+
+    while (my $row = $sth->fetchrow_hashref) {
+        if (defined $input->param('filter_bookfundid') and 
$input->param('filter_bookfundid') eq $row->{bookfundid}){
+            $row->{selected} = 1;
+        }
+         push @bookfundids_loop, $row;
+     }
+
+    $template->param(
+        filter_bookfundids => address@hidden,
+        filter_branches => address@hidden,
+        filter_bookfundname => $input->param('filter_bookfundname') || undef,
+    );
+
+    # searching the bookfunds corresponding to our filtering rules
+    my @results = SearchBookFund(
+        $input->param('filter'),
+        $input->param('filter_bookfundid'),
+        $input->param('filter_bookfundname'),
+        $input->param('filter_branchcode'),
+    );
+
+    # does the book funds have budgets?
+    my @loop_id;
+    my $sth = GetBookFundsId();
+    while (my $row = $sth->fetchrow){
+        push @loop_id, $row;
+    }
+
+    my ($id,%nb_budgets_of);
+    foreach $id (@loop_id){
+        my $number = Countbookfund($id);
+        $nb_budgets_of{$id} = $number;
+    }
+
+    # pagination informations
+    my $page = $input->param('page') || 1;
+    my @loop;
+
+    my $first = ($page - 1) * $pagesize;
+
+    # if we are on the last page, the number of the last word to display
+    # must not exceed the length of the results array
+    my $last = min(
+        $first + $pagesize - 1,
+        scalar(@results) - 1,
+    );
+
+    my $toggle = 0;
+    foreach my $result (@results[$first .. $last]) {
+        push(
+            @loop,
+            {
+                %{$result},
+                toggle => $toggle++%2,
+                branchname =>
+                    $branches->{ $result->{branchcode} }->{branchname},
+                has_budgets => defined $nb_budgets_of{ $result->{bookfundid} },
+            }
+        );
+    }
+
+    $template->param(
+            bookfund => address@hidden,
+            pagination_bar => pagination_bar(
+                        $script_name,
+                        getnbpages(scalar @results, $pagesize),
+                        $page,
+                        'page'
+            )
+        );
 } #---- END $OP eq DEFAULT
-$template->param(intranetcolorstylesheet => 
C4::Context->preference("intranetcolorstylesheet"),
+$template->param(
+    intranetcolorstylesheet 
=>C4::Context->preference("intranetcolorstylesheet"),
                intranetstylesheet => 
C4::Context->preference("intranetstylesheet"),
                IntranetNav => C4::Context->preference("IntranetNav"),
                );
+
 output_html_with_http_headers $input, $cookie, $template->output;

Index: admin/aqbudget.pl
===================================================================
RCS file: /sources/koha/koha/admin/aqbudget.pl,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- admin/aqbudget.pl   1 Sep 2006 22:03:00 -0000       1.23
+++ admin/aqbudget.pl   27 Sep 2006 21:19:21 -0000      1.24
@@ -39,115 +39,196 @@
 
 use strict;
 use CGI;
+use List::Util qw/min/;
 use C4::Date;
 use C4::Auth;
+use C4::Acquisition;
 use C4::Context;
-use C4::Output;
 use C4::Interface::CGI::Output;
 use C4::Search;
-
-
-sub StringSearch  {
-       my ($env,$searchstring,$type)address@hidden;
-       my $dbh = C4::Context->dbh;
-       $searchstring=~ s/\'/\\\'/g;
-       my @data=split(' ',$searchstring);
-       my address@hidden;
-       my $sth=$dbh->prepare("Select 
aqbudgetid,bookfundid,startdate,enddate,budgetamount from aqbudget where 
(bookfundid like ?) order by bookfundid,aqbudgetid");
-       $sth->execute("$data[0]%");
-       my @results;
-       my $cnt=0;
-       while (my $data=$sth->fetchrow_hashref){
-       push(@results,$data);
-       $cnt ++;
-       }
-       #  $sth->execute;
-       $sth->finish;
-       return ($cnt,address@hidden);
-}
+use C4::Koha;
+use C4::Output;
 
 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 $aqbudgetid=$input->param('aqbudgetid');
-my $pagesize=20;
+my $pagesize = 20;
 my $op = $input->param('op');
-$searchfield=~ s/\,//g;
 
 my ($template, $borrowernumber, $cookie)
-    = get_template_and_user({template_name => "admin/aqbudget.tmpl",
+    = get_template_and_user(
+        {template_name => "admin/aqbudget.tmpl",
                             query => $input,
                             type => "intranet",
                             authnotrequired => 0,
                             flagsrequired => {parameters => 1},
                             debug => 1,
-                            });
+     }
+    );
+
+$template->param(
+    action => $script_name,
+    DHTMLcalendar_dateformat => get_date_format_string_for_DHTMLcalendar(),
+    script_name => $script_name,
+    $op || 'else' => 1,
+);
 
-if ($op) {
-$template->param(script_name => $script_name,
-                                               $op              => 1); # we 
show only the TMPL_VAR names $op
-} else {
-$template->param(script_name => $script_name,
-                                               else              => 1); # we 
show only the TMPL_VAR names $op
-}
+my $dbh = C4::Context->dbh;
+my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where 
borrowernumber = ?");
+$sthtemp->execute($borrowernumber);
+my ($flags, $homebranch)=$sthtemp->fetchrow;
 
-$template->param(action => $script_name);
 ################## ADD_FORM ##################################
 # called by default. Used to create form to add or  modify a record
 if ($op eq 'add_form') {
+    my ($query, $dataaqbudget, $dataaqbookfund, $sth);
+    my $dbh = C4::Context->dbh;
+
        #---- if primkey exists, it's a modify action, so read values to 
modify...
-       my $dataaqbudget;
-       my $dataaqbookfund;
        if ($aqbudgetid) {
-               my $dbh = C4::Context->dbh;
-               my $sth=$dbh->prepare("select 
aqbudgetid,bookfundname,aqbookfund.bookfundid,startdate,enddate,budgetamount 
from aqbudget,aqbookfund where aqbudgetid=? and 
aqbudget.bookfundid=aqbookfund.bookfundid");
+        $query = '
+SELECT aqbudgetid,
+       bookfundname,
+       aqbookfund.bookfundid,
+       startdate,
+       enddate,
+       budgetamount,
+       aqbudget.branchcode
+  FROM aqbudget
+    INNER JOIN aqbookfund ON aqbudget.bookfundid = aqbookfund.bookfundid
+  WHERE aqbudgetid = ?
+';
+        $sth=$dbh->prepare($query);
                $sth->execute($aqbudgetid);
                $dataaqbudget=$sth->fetchrow_hashref;
                $sth->finish;
        }
-       my $header;
-       if ($aqbudgetid) {
-               $header = "Modify budget";
-       } else {
-               $header = "Add budget";
+
+    $query = '
+SELECT aqbookfund.branchcode,
+       branches.branchname,
+       aqbookfund.bookfundname
+  FROM aqbookfund
+    LEFT JOIN branches ON aqbookfund.branchcode = branches.branchcode
+  WHERE bookfundid = ?
+';
+    $sth=$dbh->prepare($query);
+    $sth->execute(
+        defined $aqbudgetid ? $dataaqbudget->{bookfundid} : $bookfundid,
+    );
+    $dataaqbookfund=$sth->fetchrow_hashref;
+    $sth->finish;
+
+    if (defined $aqbudgetid) {
+        $template->param(
+            bookfundid => $dataaqbudget->{'bookfundid'},
+            bookfundname => $dataaqbudget->{'bookfundname'}
+        );
        }
-       $template->param(header => $header);
-       if ($aqbudgetid) {
-           $template->param(modify => 1);
-           $template->param(bookfundid => $dataaqbudget->{bookfundid});
-           $template->param(bookfundname => $dataaqbudget->{bookfundname});
-       } else {
-           $template->param(bookfundid => $bookfundid,
-                                                               adding => 1);
+    else {
+        $template->param(
+            bookfundid => $bookfundid,
+            bookfundname => $dataaqbookfund->{bookfundname},
+        );
        }
-       $template->param(dateformat => display_date_format(),
+
+    # Available branches
+    my @branches = ();
+
+    $query = '
+SELECT branchcode,
+       branchname
+  FROM branches
+  ORDER BY branchname
+';
+    $sth=$dbh->prepare($query);
+    $sth->execute();
+    while (my $row = $sth->fetchrow_hashref) {
+        my $branch = $row;
+
+        if (defined $dataaqbookfund->{branchcode}) {
+            $branch->{selected} =
+                $dataaqbookfund->{branchcode} eq $row->{branchcode} ? 1 : 0;
+        }
+        elsif (defined $aqbudgetid) {
+            $branch->{selected} =
+                $dataaqbudget->{branchcode} eq $row->{branchcode} ? 1 : 0;
+        }
+
+        push @branches, $branch;
+    }
+    $sth->finish;
+
+    $template->param(
+        dateformat => display_date_format(),
                                                        aqbudgetid => 
$dataaqbudget->{'aqbudgetid'},
                                                        startdate => 
format_date($dataaqbudget->{'startdate'}),
                                                        enddate => 
format_date($dataaqbudget->{'enddate'}),
-                                                       budgetamount => 
$dataaqbudget->{'budgetamount'}
+        budgetamount => $dataaqbudget->{'budgetamount'},
+        branches => address@hidden,
        );
+
+    if (defined $dataaqbookfund->{branchcode}) {
+        $template->param(
+            disable_branchselection => 1,
+            branch => $dataaqbookfund->{branchcode},
+        );
+    }
                                                                                
                        # 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 = C4::Context->dbh;
-       my $sth=$dbh->prepare("replace aqbudget 
(aqbudgetid,bookfundid,startdate,enddate,budgetamount) values (?,?,?,?,?)");
-       $sth->execute($input->param('aqbudgetid'),$input->param('bookfundid'),
+    my ($query, $sth);
+
+    if (defined $aqbudgetid) {
+        $query = '
+UPDATE aqbudget
+  SET bookfundid = ?,
+      startdate = ?,
+      enddate = ?,
+      budgetamount = ?,
+      branchcode = ?
+  WHERE aqbudgetid = ?
+';
+        $sth=$dbh->prepare($query);
+        $sth->execute(
+            $input->param('bookfundid'),
                                                
format_date_in_iso($input->param('startdate')),
                                                
format_date_in_iso($input->param('enddate')),
-                                               $input->param('budgetamount')
+            $input->param('budgetamount'),
+            $input->param('branch') || undef,
+            $aqbudgetid,
                                                );
        $sth->finish;
-        print $input->redirect("aqbookfund.pl");
-        exit;
+    }
+    else {
+        $query = '
+INSERT
+  INTO aqbudget
+  (bookfundid, startdate, enddate, budgetamount, branchcode)
+  VALUES
+  (?, ?, ?, ?, ?)
+';
+        $sth=$dbh->prepare($query);
+        $sth->execute(
+            $input->param('bookfundid'),
+            format_date_in_iso($input->param('startdate')),
+            format_date_in_iso($input->param('enddate')),
+            $input->param('budgetamount'),
+            $input->param('branch') || undef,
+        );
+        $sth->finish;
+    }
+
+    $input->redirect("aqbudget.pl");
+
 # 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 = C4::Context->dbh;
-       my $sth=$dbh->prepare("select 
aqbudgetid,bookfundid,startdate,enddate,budgetamount from aqbudget where 
aqbudgetid=?");
+       my $sth=$dbh->prepare("select 
aqbudgetid,bookfundid,startdate,enddate,budgetamount,branchcode from aqbudget 
where aqbudgetid=?");
        $sth->execute($aqbudgetid);
        my $data=$sth->fetchrow_hashref;
        $sth->finish;
@@ -170,54 +251,181 @@
                                                                                
                        # END $OP eq DELETE_CONFIRMED
 ################## DEFAULT ##################################
 } else { # DEFAULT
-       if  ($searchfield ne '') {
-               $template->param(search => 1);
-               $template->param(searchfield => $searchfield);
-       }
-       my $env;
-       my ($count,$results)=StringSearch($env,$searchfield,'web');
-       my $toggle="white";
-       my @loop_data =();
-       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;
-               my $dataaqbookfund;
-               my $dbh = C4::Context->dbh;
-               my $sth=$dbh->prepare("select bookfundid,bookfundname from 
aqbookfund where bookfundid=?");
-               $sth->execute($results->[$i]{'bookfundid'});
-               $dataaqbookfund=$sth->fetchrow_hashref;
+    my ($query, $sth);
+
+    # create a look-up table for bookfund names from bookfund ids,
+    # instead of having on query per budget
+    my %bookfundname_of = ();
+    $query = '
+SELECT bookfundid, bookfundname
+  FROM aqbookfund
+';
+    $sth=$dbh->prepare($query);
+    $sth->execute;
+    while (my $row = $sth->fetchrow_hashref) {
+        $bookfundname_of{ $row->{bookfundid} } = $row->{bookfundname};
+    }
                $sth->finish;
-               my @toggle = ();
-               my @bookfundid = ();
-               my @bookfundname = ();
-               my @startdate = ();
-               my @enddate = ();
-               my @budgetamount = ();
-               push(@toggle,$toggle);
-               push(@bookfundid,$results->[$i]{'bookfundid'});
-               push(@bookfundname,$dataaqbookfund->{'bookfundname'});
-               push(@startdate,format_date($results->[$i]{'startdate'}));
-               push(@enddate,format_date($results->[$i]{'enddate'}));
-               push(@budgetamount,$results->[$i]{'budgetamount'});
-               if ($toggle eq 'white'){
-                       $toggle="#ffffcc";
-               } else {
-                       $toggle="white";
-               }
-               while (@toggle and @bookfundid and @bookfundname and @startdate 
and @enddate and @budgetamount) { 
-          my %row_data;
-          $row_data{toggle} = shift @toggle;
-          $row_data{bookfundid} = shift @bookfundid;
-          $row_data{bookfundname} = shift @bookfundname;
-          $row_data{startdate} = shift @startdate;
-          $row_data{enddate} = shift @enddate;
-          $row_data{budgetamount} = shift @budgetamount;
-          push(@loop_data, \%row_data);
+
+    # filters
+    my $branches = GetBranches();
+    my @branchloop;
+    foreach my $branchcode (sort keys %{$branches}) {
+        my $row = {
+            code => $branchcode,
+            name => $branches->{$branchcode}->{branchname},
+        };
+
+        if (defined $input->param('filter_branchcode')
+            and $input->param('filter_branchcode') eq $branchcode) {
+            $row->{selected} = 1;
+        }
+
+        push @branchloop, $row;
+    }
+
+    my @bookfundids_loop;
+    $query = '
+SELECT bookfundid
+  FROM aqbookfund
+';
+    $sth = $dbh->prepare($query);
+    $sth->execute();
+    while (my $row = $sth->fetchrow_hashref) {
+        if (defined $input->param('filter_bookfundid')
+            and $input->param('filter_bookfundid') eq $row->{bookfundid}) {
+            $row->{selected} = 1;
+        }
+
+        push @bookfundids_loop, $row;
+    }
+    $sth->finish;
+
+    $template->param(
+        filter_bookfundids => address@hidden,
+        filter_branches => address@hidden,
+        filter_amount => $input->param('filter_amount') || undef,
+        filter_startdate => $input->param('filter_startdate') || undef,
+        filter_enddate => $input->param('filter_enddate') || undef,
+    );
+
+    my %sign_label_of = (
+        '=' => 'equal',
+        '>=' => 'superior',
+        '<=' => 'inferior',
+    );
+
+    foreach my $field (qw/startdate enddate amount/) {
+        my $param = 'filter_'.$field.'_sign';
+
+        foreach my $sign (keys %sign_label_of) {
+            if ($input->param($param) eq $sign) {
+                $template->param(
+                    $param.'_'.$sign_label_of{$sign}.'_selected' => 1,
+                );
+            }
        }
        }
-       $template->param(budget => address@hidden);
-} #---- END $OP eq DEFAULT
 
+    # Search all available budgets
+    $query = '
+SELECT aqbudgetid,
+       bookfundid,
+       startdate,
+       enddate,
+       budgetamount,
+       branchcode
+  FROM aqbudget
+  WHERE 1 = 1';
+
+    my @bindings;
+
+    if ($input->param('filter_bookfundid')) {
+        $query.= '
+    AND bookfundid = ?
+';
+        push @bindings, $input->param('filter_bookfundid');
+    }
+    if ($input->param('filter_branchcode')) {
+        $query.= '
+    AND branchcode = ?
+';
+        push @bindings, $input->param('filter_branchcode');
+    }
+    if ($input->param('filter_startdate')) {
+        $query.= '
+    AND startdate '.$input->param('filter_startdate_sign').' ?
+';
+        push @bindings, format_date_in_iso($input->param('filter_startdate'));
+    }
+    if ($input->param('filter_enddate')) {
+        $query.= '
+    AND enddate '.$input->param('filter_enddate_sign').' ?
+';
+        push @bindings, format_date_in_iso($input->param('filter_enddate'));
+    }
+    if ($input->param('filter_amount')) {
+        $query.= '
+    AND budgetamount '.$input->param('filter_amount_sign').' ?
+';
+        # the amount must be a quantity, with 2 digits after the decimal
+        # separator
+        $input->param('filter_amount') =~ m{(\d* (?:\.\d{,2})? )}xms;
+        my ($amount) = $1;
+        push @bindings, $amount;
+    }
+
+    $query.= '
+  ORDER BY bookfundid, aqbudgetid
+';
+    $sth = $dbh->prepare($query);
+    $sth->execute(@bindings);
+    my @results;
+    while (my $row = $sth->fetchrow_hashref){
+        push @results, $row;
+    }
+    $sth->finish;
+
+    # filter budgets depending on the pagination
+    my $page = $input->param('page') || 1;
+    my $first = ($page - 1) * $pagesize;
+
+    # if we are on the last page, the number of the last word to display
+    # must not exceed the length of the results array
+    my $last = min(
+        $first + $pagesize - 1,
+        scalar @results - 1,
+    );
+
+    my $toggle = 0;
+    my @loop;
+    foreach my $result (@results[$first .. $last]) {
+        push(
+            @loop,
+            {
+                %{$result},
+                toggle => $toggle++%2,
+                bookfundname => $bookfundname_of{ $result->{'bookfundid'} },
+                branchname => $branches->{ $result->{branchcode} 
}->{branchname},
+                startdate => format_date($result->{startdate}),
+                enddate => format_date($result->{enddate}),
+            }
+        );
+    }
+
+    $template->param(
+        budget => address@hidden,
+        pagination_bar => pagination_bar(
+            $script_name,
+            getnbpages(scalar @results, $pagesize),
+            $page,
+            'page'
+        )
+    );
+} #---- END $OP eq DEFAULT
+$template->param(intranetcolorstylesheet => 
C4::Context->preference("intranetcolorstylesheet"),
+               intranetstylesheet => 
C4::Context->preference("intranetstylesheet"),
+               IntranetNav => C4::Context->preference("IntranetNav"),
+               );
 output_html_with_http_headers $input, $cookie, $template->output;
 

Index: admin/issuingrules.pl
===================================================================
RCS file: /sources/koha/koha/admin/issuingrules.pl,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- admin/issuingrules.pl       1 Sep 2006 22:03:00 -0000       1.10
+++ admin/issuingrules.pl       27 Sep 2006 21:19:21 -0000      1.11
@@ -22,7 +22,6 @@
 use C4::Context;
 use C4::Output;
 use C4::Auth;
-use C4::Output;
 use C4::Koha;
 use C4::Interface::CGI::Output;
 
@@ -98,7 +97,7 @@
        }
 
 }
-my $branches = getbranches;
+my $branches = GetBranches;
 my @branchloop;
 foreach my $thisbranch (keys %$branches) {
        my $selected = 1 if $thisbranch eq $branch;

Index: admin/koha-electronic.pl
===================================================================
RCS file: /sources/koha/koha/admin/koha-electronic.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- admin/koha-electronic.pl    1 Sep 2006 22:03:00 -0000       1.1
+++ admin/koha-electronic.pl    27 Sep 2006 21:19:21 -0000      1.2
@@ -67,7 +67,7 @@
        my $href        = $cgi->param('href');
        my $section     = $cgi->param('section');
        add_opac_electronic($title, $edata, $lang,$image, $href,$section);
-       print $cgi->redirect('/cgi-bin/koha/admin/opac-electronic.pl');
+       print $cgi->redirect('/cgi-bin/koha/admin/koha-electronic.pl');
 
 } elsif ($op eq 'edit') {
 # warn "edit";
@@ -79,13 +79,13 @@
        my $href        = $cgi->param('href');
        my $section     = $cgi->param('section');
        upd_opac_electronic($id, $title, $edata, $lang,$image,$href,$section);
-       print $cgi->redirect('/cgi-bin/koha/admin/opac-electronic.pl');
+       print $cgi->redirect('/cgi-bin/koha/admin/koha-electronic.pl');
 
 } elsif ($op eq 'del') {
 # warn "del";
        my @ids = $cgi->param('ids');
        del_opac_electronic(join ",", @ids);
-       print $cgi->redirect('/cgi-bin/koha/admin/opac-electronic.pl');
+       print $cgi->redirect('/cgi-bin/koha/admin/koha-electronic.pl');
 
 } else { 
 # warn "else";

Index: admin/koha_attr.pl
===================================================================
RCS file: /sources/koha/koha/admin/koha_attr.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- admin/koha_attr.pl  1 Sep 2006 22:03:00 -0000       1.1
+++ admin/koha_attr.pl  27 Sep 2006 21:19:21 -0000      1.2
@@ -70,7 +70,7 @@
        #---- if primkey exists, it's a modify action, so read values to 
modify...
        my $data;
        if ($id) {
-               $sth=$dbh->prepare("select 
id,marctokoha,attr,liblibrarian,sorts,recordtype,tagfield,tagsubfield,opacshow,intrashow
 from koha_attr where id=? ");
+               $sth=$dbh->prepare("select 
id,kohafield,attr,extraattr,label,sorts,recordtype,tagfield,tagsubfield,opacshow,intrashow,facets_label
 from koha_attr where id=? ");
                $sth->execute($id);
                $data=$sth->fetchrow_hashref;
                $sth->finish;
@@ -116,19 +116,21 @@
                        );
        
        if ($searchfield) {
-               $template->param(action => "Modify tag",id=>$id ,searchfield => 
"<input type=\"hidden\" name=\"marctokoha\" value=\"$searchfield\" 
/>$searchfield");
+               $template->param(action => "Modify tag",id=>$id ,searchfield => 
"<input type=\"hidden\" name=\"kohafield\" value=\"$searchfield\" 
/>$searchfield");
                $template->param('heading-modify-tag-p' => 1);
        } else {
                $template->param(action => "Add tag",
-                                                               searchfield => 
"<input type=\"text\" name=\"marctokoha\" size=\"40\" maxlength=\"80\" />");
+                                                               searchfield => 
"<input type=\"text\" name=\"kohafield\" size=\"40\" maxlength=\"80\" />");
                $template->param('heading-add-tag-p' => 1);
        }
        $template->param('use-heading-flags-p' => 1);
-       $template->param(liblibrarian => $data->{'liblibrarian'},
+       $template->param(label => $data->{'label'},
                        attr=> $data->{'attr'},
+                       extraattr=>$data->{'extraattr'},
                        recordtype=>$recordlist,
                        tagfield=>$taglist,
                        tagsubfield=>$tagsublist,
+                       facets_label=>$data->{'facets_label'},
                        sorts => CGI::checkbox(-name=>'sorts',
                                                -checked=> 
$data->{'sorts'}?'checked':'',
                                                -value=> 1,
@@ -153,34 +155,36 @@
 } elsif ($op eq 'add_validate') {
 my $id       =$input->param('id');
 
-       $sth=$dbh->prepare("replace koha_attr  set 
id=?,marctokoha=?,attr=?,liblibrarian=?,sorts=?,recordtype=?,tagfield=?,tagsubfield=?
 ,opacshow=?,intrashow=? ");
+       $sth=$dbh->prepare("replace koha_attr  set 
id=?,kohafield=?,attr=?,extraattr=?,label=?,sorts=?,recordtype=?,tagfield=?,tagsubfield=?
 ,opacshow=?,intrashow=? ,facets_label=?");
 
        
-       my $marctokoha       =$input->param('marctokoha');
+       my $kohafield       =$input->param('kohafield');
        my $attr       =$input->param('attr');
-       my $liblibrarian  = $input->param('liblibrarian');
+       my $extraattr       =$input->param('extraattr');
+       my $label  = $input->param('label');
        my $sorts =$input->param('sorts');
        my $opacshow =$input->param('opacshow');
        my $intrashow =$input->param('intrashow');
        my $recordtype =$input->param('recordtype');
        my $tagfield =$input->param('tagfield');
        my $tagsubfield =$input->param('tagsubfield');
+       my $facets_label =$input->param('facets_label');
        unless (C4::Context->config('demo') eq 1) {
-               $sth->execute( 
$id,$marctokoha,$attr,$liblibrarian,$sorts?1:0,$recordtype,$tagfield,$tagsubfield,$opacshow?1:0,$intrashow?1:0);
+               $sth->execute( 
$id,$kohafield,$attr,$extraattr,$label,$sorts?1:0,$recordtype,$tagfield,$tagsubfield,$opacshow?1:0,$intrashow?1:0,$facets_label);
        }
        $sth->finish;
-       print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; 
URL=koha_attr.pl?searchfield=$marctokoha\"></html>";
+       print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; 
URL=koha_attr.pl?searchfield=$kohafield\"></html>";
 
        exit;
                                                                                
                        # END $OP eq ADD_VALIDATE
 ################## DELETE_CONFIRM ##################################
 # called by default form, used to confirm deletion of data in DB
 } elsif ($op eq 'delete_confirm') {
-       $sth=$dbh->prepare("select id,marctokoha,liblibrarian,recordtype from 
koha_attr where id=? ");
+       $sth=$dbh->prepare("select id,kohafield,label,recordtype from koha_attr 
where id=? ");
                $sth->execute($id);
        my $data=$sth->fetchrow_hashref;
        $sth->finish;
-       $template->param(liblibrarian => $data->{'liblibrarian'}."/". 
$data->{'recordtype'},id=>$data->{'id'},
+       $template->param(label => $data->{'label'}."/". 
$data->{'recordtype'},id=>$data->{'id'},
                                                        searchfield => 
$searchfield,
                                                        );
                                                                                
                        # END $OP eq DELETE_CONFIRM
@@ -202,7 +206,7 @@
        my $cnt=0;
        if ($dspchoice) {
                #here, user only wants used tags/subfields displayed
-               my $sth=$dbh->prepare("Select * from koha_attr where tagfield 
<>'' and marctokoha >= ? ");
+               my $sth=$dbh->prepare("Select * from koha_attr where tagfield 
<>'' and kohafield >= ? ");
                #could be ordoned by tab
                $sth->execute($searchfield);
 
@@ -225,17 +229,19 @@
                        }
                        my %row_data;  # get a fresh hash for the row data
                        $row_data{id} = $results[$i]->{'id'};
-                       $row_data{marctokoha} = $results[$i]->{'marctokoha'};
-                       $row_data{liblibrarian} = 
$results[$i]->{'liblibrarian'};
+                       $row_data{kohafield} = $results[$i]->{'kohafield'};
+                       $row_data{label} = $results[$i]->{'label'};
                        $row_data{sorts} = $results[$i]->{'sorts'};
                        $row_data{attr} = $results[$i]->{'attr'};
+                       $row_data{extraattr} = $results[$i]->{'extraattr'};
                        $row_data{recordtype} = $results[$i]->{'recordtype'};
                        $row_data{tagfield} = $results[$i]->{'tagfield'};
                        $row_data{tagsubfield} = $results[$i]->{'tagsubfield'};
                        $row_data{opacshow} = $results[$i]->{'opacshow'};
                        $row_data{intrashow} = $results[$i]->{'intrashow'};
-                       $row_data{edit} = 
"$script_name?op=add_form&amp;searchfield=".$results[$i]->{'marctokoha'}."&amp;id=".$results[$i]->{'id'};
-                       $row_data{delete} = 
"$script_name?op=delete_confirm&amp;searchfield=".$results[$i]->{'marctokoha'}."&amp;id=".$results[$i]->{'id'};
+                       $row_data{facets_label} = 
$results[$i]->{'facets_label'};
+                       $row_data{edit} = 
"$script_name?op=add_form&amp;searchfield=".$results[$i]->{'kohafield'}."&amp;id=".$results[$i]->{'id'};
+                       $row_data{delete} = 
"$script_name?op=delete_confirm&amp;searchfield=".$results[$i]->{'kohafield'}."&amp;id=".$results[$i]->{'id'};
                        $row_data{toggle} = $toggle;
                        push(@loop_data, \%row_data);
                        $i++;
@@ -257,15 +263,17 @@
                        }
                        my %row_data;  # get a fresh hash for the row data
                        $row_data{id} = $results[$i]->{'id'};
-                       $row_data{marctokoha} = $results[$i]->{marctokoha};
-                       $row_data{liblibrarian} = $results[$i]->{liblibrarian};
-                       $row_data{sorts} = $results[$i]->{sorts};
-                       $row_data{opacshow} = $results[$i]->{'opacshow'};
-                       $row_data{intrashow} = $results[$i]->{'intrashow'};
-                       $row_data{attr} = $results[$i]->{attr};
+                       $row_data{kohafield} = $results[$i]->{'kohafield'};
+                       $row_data{label} = $results[$i]->{'label'};
+                       $row_data{sorts} = $results[$i]->{'sorts'};
+                       $row_data{attr} = $results[$i]->{'attr'};
+                       $row_data{extraattr} = $results[$i]->{'extraattr'};
                        $row_data{recordtype} = $results[$i]->{'recordtype'};
                        $row_data{tagfield} = $results[$i]->{'tagfield'};
                        $row_data{tagsubfield} = $results[$i]->{'tagsubfield'};
+                       $row_data{opacshow} = $results[$i]->{'opacshow'};
+                       $row_data{intrashow} = $results[$i]->{'intrashow'};
+                       $row_data{facets_label} = 
$results[$i]->{'facets_label'};
                        $row_data{edit} = 
"$script_name?op=add_form&amp;searchfield=".$results[$i]->{marctokoha}."&amp;id=".$results[$i]->{'id'};
                        $row_data{delete} = 
"$script_name?op=delete_confirm&amp;searchfield=".$results[$i]->{marctokoha}."&amp;id=".$results[$i]->{'id'};
                        $row_data{toggle} = $toggle;
@@ -305,7 +313,7 @@
 #
 sub StringSearch  {
        my ($dbh,$searchstring)address@hidden;
-       my $sth=$dbh->prepare("Select * from koha_attr  where marctokoha >=?  
order by marctokoha");
+       my $sth=$dbh->prepare("Select * from koha_attr  where kohafield >=?  
order by kohafield");
        $sth->execute($searchstring);
        my @dataresults;
        while (my $data=$sth->fetchrow_hashref){

Index: authorities/authorities.pl
===================================================================
RCS file: /sources/koha/koha/authorities/authorities.pl,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- authorities/authorities.pl  11 Sep 2006 17:27:41 -0000      1.17
+++ authorities/authorities.pl  27 Sep 2006 21:19:21 -0000      1.18
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: authorities.pl,v 1.17 2006/09/11 17:27:41 tgarip1957 Exp $
+# $Id: authorities.pl,v 1.18 2006/09/27 21:19:21 tgarip1957 Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -162,6 +162,7 @@
     my $tag;
     my $i=0;
 my $id=100;
+my 
($authidtagfield,$authidtagsubfield)=MARCfind_marc_from_kohafield("authid","authorities");
        my $authorised_values_sth = $dbh->prepare("select authorised_value,lib
                from authorised_values
                where category=? order by lib");
@@ -191,6 +192,8 @@
                        my ($ind1,$ind2);
                        
                 if ($tag>9){
+                       next if ($tag eq $authidtagfield); #we do not want 
authid to duplicate
+
                        foreach my $data (@$author){
                                        $hiddenrequired=0;
                                        my @subfields_data;
@@ -232,7 +235,7 @@
                                        foreach my $subfield (sort( keys 
%{$tagslib->{$tag}})) {
                                                next if (length $subfield !=1);
                                                next if 
($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
-                                               next if 
((substr($tagslib->{$tag}->{$subfield}->{hidden},2,1) gt "1")  ); #check for 
visibility flag
+                                               next if 
((substr($tagslib->{$tag}->{$subfield}->{hidden},2,1) >1)  ); #check for 
visibility flag
                                                next if 
($definedsubfields{$tag.$subfield} );
                                                push(@subfields_data, 
&create_input($tag,$subfield,'',$i,$tabloop,$xmlhash,$authorised_values_sth,$id));
                                                
$definedsubfields{$tag.$subfield}=1;
@@ -253,6 +256,8 @@
                        
                        }#eachdata
                }else{ ## tag <10
+                       next if ($tag eq $authidtagfield); #we do not want 
authid to duplicate
+
                                if ($tag eq "000" || $tag eq "LDR"){
                                        my $subfield="@";
                                        next if 
($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
@@ -274,10 +279,11 @@
                                 foreach my $control (@$controlfields){
                                        my $subfield="@";
                                        next if 
($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
+                                       next if ($tagslib->{$tag} eq 
$authidtagfield);
                                        my @subfields_data;
                                        if ($control->{'tag'} eq $tag){
                                        $hiddenrequired=0;
-                                       $tagdefined{$tag}=1 ;
+                                               $tagdefined{$tag}=1;
                                         if 
($built{$tag}==1){$hiddenrequired=1;}
                                        my $value=$control->{'content'} ;
                                        $definedsubfields{$tag.'@'}=1;
@@ -285,17 +291,7 @@
                                        $i++;
                                        
                                           $built{$tag}=1;
-                                       if ($hiddenrequired && $#loop_data >=0 
&& $loop_data[$#loop_data]->{'tag'} eq $tag) {
-                                               my @hiddensubfields_data;
-                                               my %tag_data;
-                                               push(@hiddensubfields_data, 
&create_input('','','',$i,$tabloop,$xmlhash,$authorised_values_sth,$id));
-                                               $tag_data{tag} = '';
-                                               $tag_data{tag_lib} = '';
-                                               $tag_data{subfield_loop} = 
address@hidden;
-                                               $tag_data{fixedfield} = 1;
-                                               push (@loop_data, \%tag_data);
-                                               $i++;
-                                       }
+                                       ###hiddenrequired
                                        if ($#subfields_data >= 0) {
                                                my %tag_data;
                                                $tag_data{tag} = $tag;
@@ -319,8 +315,7 @@
                                                next if ($tagdefined{$tag} );
                                                next if (length $subfield !=1);
                                                next if 
($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
-                                               next if 
((substr($tagslib->{$tag}->{$subfield}->{hidden},2,1) gt "1")  ); #check for 
visibility flag
-                                               
+                                               next if 
((substr($tagslib->{$tag}->{$subfield}->{hidden},2,1) > 1) ); #check for 
visibility flag
                                                push(@subfields_data, 
&create_input($tag,$subfield,'',$i,$tabloop,$xmlhash,$authorised_values_sth,$id));
                                                $tagdefined{$tag.$subfield}=1;
                                                $i++;
@@ -348,7 +343,7 @@
                                                foreach my $subfield (sort( 
keys %{$tagslib->{$tag}})) {
                                                next if (length $subfield !=1);
                                                next if 
($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
-                                               next if 
((substr($tagslib->{$tag}->{$subfield}->{hidden},2,1) gt "1")  ); #check for 
visibility flag
+                                               next if 
((substr($tagslib->{$tag}->{$subfield}->{hidden},2,1) >1)  ); #check for 
visibility flag
                                                $addedfield=""; 
                                                push(@subfields_data, 
&create_input($tag,$subfield,'',$i,$tabloop,$xmlhash,$authorised_values_sth,$id));
                                                $i++;
@@ -373,7 +368,7 @@
                                my @subfields_data;
                                foreach my $subfield (sort(keys 
%{$tagslib->{$tag}})) {
                                        next if (length $subfield !=1);
-                                       next if 
((substr($tagslib->{$tag}->{$subfield}->{hidden},2,1) gt "1")  ); #check for 
visibility flag
+                                       next if 
((substr($tagslib->{$tag}->{$subfield}->{hidden},2,1) >1)  ); #check for 
visibility flag
                                        next if 
($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
                                        push(@subfields_data, 
&create_input($tag,$subfield,'',$i,$tabloop,$xmlhash,$authorised_values_sth,$id));
                                        $i++;
@@ -471,8 +466,8 @@
 $is_a_modif=0;
 if ($authid) {
        $is_a_modif=1;
-       ($oldauthnumtagfield,$oldauthnumtagsubfield) = 
MARCfind_marc_from_kohafield("auth_authid","authorities");
-       ($oldauthtypetagfield,$oldauthtypetagsubfield) = 
MARCfind_marc_from_kohafield("auth_authtypecode","authorities");
+       ($oldauthnumtagfield,$oldauthnumtagsubfield) = 
MARCfind_marc_from_kohafield("authid","authorities");
+       ($oldauthtypetagfield,$oldauthtypetagsubfield) = 
MARCfind_marc_from_kohafield("authtypecode","authorities");
 }
 
 
#------------------------------------------------------------------------------------------------------------------------------
@@ -492,11 +487,14 @@
 eval{
  $xml = 
MARChtml2xml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
      
 };
+
  if ($@){
 warn $@;
  $template->param(error             =>1,xmlerror=>1,);
 goto FINAL;
   };   # check for a duplicate
+###Authorities need the XML header unlike biblios
+$xml='<?xml version="1.0" encoding="UTF-8"?>'.$xml;
   my $xmlhash=XML_xml2hash_onerecord($xml);
        my ($duplicateauthid,$duplicateauthvalue) = 
C4::AuthoritiesMarc::FindDuplicateauth($xmlhash,$authtypecode) if ($op eq 
"add") && (!$is_a_modif);
 #warn "duplicate:$duplicateauthid,$duplicateauthvalue";        
@@ -505,9 +503,9 @@
        if (!$duplicateauthid or $confirm_not_duplicate) {
 # warn "noduplicate";
                if ($is_a_modif ) {     
-                       
$authid=AUTHmodauthority($dbh,$authid,$xmlhash,$authtypecode,1);                
+                       
$authid=AUTHmodauthority($dbh,$authid,$xmlhash,$authtypecode);
                } else {
-               ($authid) = 
AUTHaddauthority($dbh,$xmlhash,$authid,$authtypecode);
+               $authid = AUTHaddauthority($dbh,$xmlhash,'',$authtypecode);
 
                }
        # now, redirect to detail page
@@ -540,6 +538,7 @@
        my @ind_tag = $input->param('ind_tag');
        my @indicator = $input->param('indicator');
        my $xml = 
MARChtml2xml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
+       $xml='<?xml version="1.0" encoding="UTF-8"?>'.$xml;
        my $xmlhash=XML_xml2hash_onerecord($xml);
        # adding an empty field
        build_tabs ($template, $xmlhash, $dbh,$addedfield);

Index: authorities/blinddetail-linker.pl
===================================================================
RCS file: /sources/koha/koha/authorities/blinddetail-linker.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- authorities/blinddetail-linker.pl   6 Sep 2006 16:21:04 -0000       1.2
+++ authorities/blinddetail-linker.pl   27 Sep 2006 21:19:21 -0000      1.3
@@ -54,7 +54,7 @@
 my $authtypecode=$query->param('authtypecode');
  $authtypecode = &AUTHfind_authtypecode($dbh,$authid) if !$authtypecode;
 my $tagslib = &AUTHgettagslib($dbh,1,$authtypecode);
-my 
($linkidfield,$linkidsubfield)=MARCfind_marc_from_kohafield("auth_linkid","authorities");
+my 
($linkidfield,$linkidsubfield)=MARCfind_marc_from_kohafield("linkid","authorities");
 my $auth_type = AUTHgetauth_type($authtypecode);
 
 my $record =XMLgetauthorityhash($dbh,$authid);

Index: bookshelves/addbookbybiblionumber.pl
===================================================================
RCS file: /sources/koha/koha/bookshelves/addbookbybiblionumber.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- bookshelves/addbookbybiblionumber.pl        4 Jul 2006 14:36:51 -0000       
1.4
+++ bookshelves/addbookbybiblionumber.pl        27 Sep 2006 21:19:21 -0000      
1.5
@@ -2,7 +2,7 @@
 #script to provide bookshelf management
 # WARNING: This file uses 4-character tabs!
 #
-# $Header: /sources/koha/koha/bookshelves/addbookbybiblionumber.pl,v 1.4 
2006/07/04 14:36:51 toins Exp $
+# $Header: /sources/koha/koha/bookshelves/addbookbybiblionumber.pl,v 1.5 
2006/09/27 21:19:21 tgarip1957 Exp $
 #
 # Copyright 2000-2002 Katipo Communications
 #
@@ -25,12 +25,11 @@
 use C4::Search;
 use C4::Biblio;
 use CGI;
-use C4::Output;
 use C4::BookShelves;
 use C4::Circulation::Circ2;
 use C4::Auth;
 use C4::Interface::CGI::Output;
-use HTML::Template;
+
 
 my $env;
 my $query = new CGI;
@@ -85,6 +84,9 @@
        output_html_with_http_headers $query, $cookie, $template->output;
 }
 # $Log: addbookbybiblionumber.pl,v $
+# Revision 1.5  2006/09/27 21:19:21  tgarip1957
+# Finalized XML version for intranet
+#
 # Revision 1.4  2006/07/04 14:36:51  toins
 # Head & rel_2_2 merged
 #

Index: bookshelves/shelves.pl
===================================================================
RCS file: /sources/koha/koha/bookshelves/shelves.pl,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- bookshelves/shelves.pl      4 Jul 2006 14:36:51 -0000       1.9
+++ bookshelves/shelves.pl      27 Sep 2006 21:19:21 -0000      1.10
@@ -2,7 +2,7 @@
 #script to provide bookshelf management
 # WARNING: This file uses 4-character tabs!
 #
-# $Header: /sources/koha/koha/bookshelves/shelves.pl,v 1.9 2006/07/04 14:36:51 
toins Exp $
+# $Header: /sources/koha/koha/bookshelves/shelves.pl,v 1.10 2006/09/27 
21:19:21 tgarip1957 Exp $
 #
 # Copyright 2000-2002 Katipo Communications
 #
@@ -24,12 +24,11 @@
 use strict;
 use C4::Search;
 use CGI;
-use C4::Output;
 use C4::BookShelves;
 use C4::Circulation::Circ2;
 use C4::Auth;
 use C4::Interface::CGI::Output;
-use HTML::Template;
+
 
 my $env;
 my $query = new CGI;
@@ -194,6 +193,9 @@
 
 #
 # $Log: shelves.pl,v $
+# Revision 1.10  2006/09/27 21:19:21  tgarip1957
+# Finalized XML version for intranet
+#
 # Revision 1.9  2006/07/04 14:36:51  toins
 # Head & rel_2_2 merged
 #

Index: catalogue/ISBDdetail.pl
===================================================================
RCS file: /sources/koha/koha/catalogue/ISBDdetail.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- catalogue/ISBDdetail.pl     11 Sep 2006 17:41:54 -0000      1.3
+++ catalogue/ISBDdetail.pl     27 Sep 2006 21:19:21 -0000      1.4
@@ -37,30 +37,27 @@
 
 
 use strict;
-require Exporter;
+
 use C4::Auth;
 use C4::Context;
-use C4::Output;
+use C4::AuthoritiesMarc;
 use C4::Interface::CGI::Output;
 use CGI;
 use C4::Search;
-use MARC::Record;
 use C4::Biblio;
 use C4::Acquisition;
-use HTML::Template;
+use C4::Koha;
 
 my $query=new CGI;
 
 my $dbh=C4::Context->dbh;
 
-my $biblionumber=$query->param('bib');
-my $bibid = $query->param('bibid');
-$bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber) unless 
$bibid;
-$biblionumber = &MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid) unless 
$biblionumber;
-my $itemtype = &MARCfind_frameworkcode($dbh,$bibid);
+my $biblionumber=$query->param('biblionumber');
+
+my $itemtype = &MARCfind_frameworkcode($dbh,$biblionumber);
 my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
 
-my $record =MARCgetbiblio($dbh,$bibid);
+my $record =XMLgetbibliohash($dbh,$biblionumber);
 # open template
 my ($template, $loggedinuser, $cookie)
                = get_template_and_user({template_name => 
"catalogue/ISBDdetail.tmpl",
@@ -71,32 +68,29 @@
                             });
 
 my $ISBD = C4::Context->preference('ISBD');
-# my @blocs = split /\@/,$ISBD;
-# my @fields = $record->fields();
 my $res;
-# foreach my $bloc (@blocs) {
-#      $bloc =~ s/\n//g;
        my $bloc = $ISBD;
        my $blocres;
        foreach my $isbdfield (split /#/,$bloc) {
-#              $isbdfield= /(.?.?.?)/;
                $isbdfield =~ /(\d\d\d)\|(.*)\|(.*)\|(.*)/;
                my $fieldvalue=$1;
                my $textbefore=$2;
                my $analysestring=$3;
                my $textafter=$4;
-#              warn "==> $1 / $2 / $3 / $4";
-#              my $fieldvalue=substr($isbdfield,0,3);
                if ($fieldvalue>0) {
-       #               warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless 
$fieldvalue;
-#                      warn "FV : $fieldvalue";
                        my $hasputtextbefore=0;
-                       foreach my $field ($record->field($fieldvalue)) {
+                       
                                my $calculated = $analysestring;
-                               my $tag = $field->tag();
+                               my $tag = $fieldvalue;
                                if ($tag<10) {
+                               my 
$value=XML_readline_onerecord($record,"","",$tag);
+                               my $subfieldcode = "@";
+                                               my $subfieldvalue = 
get_authorised_value_desc($tag, $subf[$i][0], $value, '', $dbh);;
+                                               my $tagsubf = 
$tag.$subfieldcode;
+                                               $calculated =~ 
s/\{(.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue\{$1$tagsubf$2\}$2/g;
+                                       
                                } else {
-                                       my @subf = $field->subfields;
+                                       my @subf = 
XML_readline_withtags($record,"","",$tag);
                                        for my $i (0..$#subf) {
                                                my $subfieldcode = $subf[$i][0];
                                                my $subfieldvalue = 
get_authorised_value_desc($tag, $subf[$i][0], $subf[$i][1], '', $dbh);;
@@ -112,7 +106,7 @@
                                        $calculated =~ s/^( |;|:|\.|-)*//g;
                                        $blocres.=$calculated;
                                }
-                       }
+                       
                        $blocres .=$textafter if $hasputtextbefore;
                } else {
                        $blocres.=$isbdfield;

Index: cataloguing/addbiblio.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/addbiblio.pl,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- cataloguing/addbiblio.pl    11 Sep 2006 17:44:47 -0000      1.18
+++ cataloguing/addbiblio.pl    27 Sep 2006 21:19:21 -0000      1.19
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: addbiblio.pl,v 1.18 2006/09/11 17:44:47 tgarip1957 Exp $
+# $Id: addbiblio.pl,v 1.19 2006/09/27 21:19:21 tgarip1957 Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -116,7 +116,7 @@
                        }       
                $record->insert_fields_ordered($newfield);
                }
-       my $xml=  $record->as_xml_record();
+       my $xml=MARC::File::XML::record($record);
        $xml=Encode::encode('utf8',$xml);
        my $xmlhash=XML_xml2hash_onerecord($xml);
                return $xmlhash,$encoding;
@@ -246,6 +246,8 @@
        my $authorised_values_sth = $dbh->prepare("select authorised_value,lib
                from authorised_values
                where category=? order by lib");
+my ($biblionumtagfield,$biblionumtagsubfield) = 
&MARCfind_marc_from_kohafield($dbh,"biblionumber","biblios");
+
 my $biblio;
 my $controlfields;
 my $leader;
@@ -262,6 +264,7 @@
 
                my @loop_data = ();
        foreach my $tag (sort(keys (%{$tagslib}))) {
+       next if ($tag eq $biblionumtagfield);## Otherwise biblionumber will be 
duplicated on modifs if user has set visibility to true
                        my $indicator;
                                # if MARC::Record is not empty => use it as 
master loop, then add missing subfields that should be in the tab.
                                # if MARC::Record is empty => use tab as master 
loop.
@@ -272,19 +275,15 @@
                
                        my %tagdefined;
                        my %definedsubfields;
-                       my $hiddenrequired;
+                       
                        my ($ind1,$ind2);
                        
                 if ($tag>9){
                        foreach my $data (@$biblio){
-                                       $hiddenrequired=0;
                                        my @subfields_data;
                                        undef %definedsubfields;
                                 if ($data->{'tag'} eq $tag){
                                        $tagdefined{$tag}=1 ;
-                                          if ($built{$tag}==1){
-                                               $hiddenrequired=1;
-                                           }
                                            $ind1="  ";
                                              $ind2="  ";               
                                              foreach my $subfieldcode ( 
$data->{'subfield'}){
@@ -301,17 +300,7 @@
                                            $ind1=$data->{'ind1'};
                                            $ind2=      $data->{'ind2'};
                                          
-                                       if ($hiddenrequired && $#loop_data >=0 
&& $loop_data[$#loop_data]->{'tag'} eq $tag) {
-                                               my @hiddensubfields_data;
-                                               my %tag_data;
-                                               push(@hiddensubfields_data, 
&create_input('','','',$i,$tabloop,$xmlhash,$authorised_values_sth,$id));
-                                               $tag_data{tag} = '';
-                                               $tag_data{tag_lib} = '';
-                                               $tag_data{indicator} = '';
-                                               $tag_data{subfield_loop} = 
address@hidden;
-                                               push (@loop_data, \%tag_data);
-                                               $i++;
-                                       }
+                                       
                                        # now, loop again to add parameter 
subfield that are not in the MARC::Record
                                        
                                        foreach my $subfield (sort( keys 
%{$tagslib->{$tag}})) {
@@ -361,26 +350,14 @@
                                        next if 
($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
                                        my @subfields_data;
                                        if ($control->{'tag'} eq $tag){
-                                       $hiddenrequired=0;
                                        $tagdefined{$tag}=1 ;
-                                        if 
($built{$tag}==1){$hiddenrequired=1;}
                                        my $value=$control->{'content'} ;
                                        $definedsubfields{$tag.'@'}=1;
                                        push(@subfields_data, 
&create_input($tag,$subfield,$value,$i,$tabloop,$xmlhash,$authorised_values_sth,$id));
                                    
                                        $i++;
                                        
                                           $built{$tag}=1;
-                                       if ($hiddenrequired && $#loop_data >=0 
&& $loop_data[$#loop_data]->{'tag'} eq $tag) {
-                                               my @hiddensubfields_data;
-                                               my %tag_data;
-                                               push(@hiddensubfields_data, 
&create_input('','','',$i,$tabloop,$xmlhash,$authorised_values_sth,$id));
-                                               $tag_data{tag} = '';
-                                               $tag_data{tag_lib} = '';
-                                               $tag_data{subfield_loop} = 
address@hidden;
-                                               $tag_data{fixedfield} = 1;
-                                               push (@loop_data, \%tag_data);
-                                               $i++;
-                                       }
+                                       
                                        if ($#subfields_data >= 0) {
                                                my %tag_data;
                                                $tag_data{tag} = $tag;
@@ -528,7 +505,7 @@
 my $z3950 = $input->param('z3950');
 my $op = $input->param('op');
 my $duplicateok = $input->param('duplicateok');
-
+my $suggestionid=$input->param('suggestionid');
 my $frameworkcode = $input->param('frameworkcode');
 my $dbh = C4::Context->dbh;
 my $biblionumber;
@@ -575,7 +552,11 @@
 $frameworkcode=MARCfind_frameworkcode( $dbh, $biblionumber );
 ###########
 $tagslib = &MARCgettagslib($dbh,1,$frameworkcode);
-
+if ($suggestionid && !$biblionumber){
+my $data=GetSuggestion($suggestionid) ;
+$xml=$data->{xml};
+$xmlhash=XML_xml2hash_onerecord($xml);
+}
 my $encoding="";
 ($xmlhash,$encoding) = MARCfindbreeding($dbh,$breedingid,$oldbiblionumber) if 
($breedingid);
 

Index: cataloguing/addbooks.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/addbooks.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- cataloguing/addbooks.pl     11 Sep 2006 17:44:47 -0000      1.6
+++ cataloguing/addbooks.pl     27 Sep 2006 21:19:21 -0000      1.7
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: addbooks.pl,v 1.6 2006/09/11 17:44:47 tgarip1957 Exp $
+# $Id: addbooks.pl,v 1.7 2006/09/27 21:19:21 tgarip1957 Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #

Index: cataloguing/additem.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/additem.pl,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- cataloguing/additem.pl      11 Sep 2006 17:44:47 -0000      1.11
+++ cataloguing/additem.pl      27 Sep 2006 21:19:21 -0000      1.12
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: additem.pl,v 1.11 2006/09/11 17:44:47 tgarip1957 Exp $
+# $Id: additem.pl,v 1.12 2006/09/27 21:19:21 tgarip1957 Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #

Index: cataloguing/isbnsearch.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/isbnsearch.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- cataloguing/isbnsearch.pl   1 Sep 2006 22:28:34 -0000       1.4
+++ cataloguing/isbnsearch.pl   27 Sep 2006 21:19:21 -0000      1.5
@@ -37,6 +37,7 @@
 my $total;
 my $count;
 my @results;
+my $facets;
 my %search;
 my $toggle;
 my $marc_p = C4::Context->boolean_preference("marc");
@@ -66,7 +67,7 @@
 my @value;
 my @relation;
 my @and_or;
-my $order="title";
+my $order="title,1";
 if ($isbn){
 $search{'isbn'}=$isbn;
 push @kohafield, "isbn";
@@ -81,7 +82,7 @@
 if ($SQLorZEBRA eq "sql"){
 ($count, @results) =cataloguing_search(\%search,$num,$offset);
 }else{
-($count,@results) =ZEBRAsearch_kohafields(address@hidden,address@hidden, 
address@hidden,$order, address@hidden, 1,"",$offset, $num,"intranet");
+($count,$facets,@results) 
=ZEBRAsearch_kohafields(address@hidden,address@hidden, address@hidden,$order, 
address@hidden, 1,"",$offset, $num,"intranet");
 
 }
 my $grandtotal=$count;

Index: circ/rescirculation.pl
===================================================================
RCS file: /sources/koha/koha/circ/rescirculation.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- circ/rescirculation.pl      6 Sep 2006 16:21:04 -0000       1.1
+++ circ/rescirculation.pl      27 Sep 2006 21:19:22 -0000      1.2
@@ -26,17 +26,13 @@
 use strict;
 use CGI;
 use C4::Circulation::Circ3;
-#use C4::Search;
-use C4::Output;
-use C4::Print;
-use DBI;
 use C4::Auth;
 use C4::Interface::CGI::Output;
 use C4::Koha;
-#use HTML::Template;
 use C4::Date;
 use C4::Context;
 use C4::Members;
+use C4::Print;
 #
 # PARAMETERS READING
 #
@@ -50,9 +46,8 @@
        authnotrequired => 0,
        flagsrequired   => { circulate => 1 },
     });
-my $branches = getbranches();
+my $branches = GetBranches();
 my $printers = getprinters();
-#my $branch = getbranch($query, $branches);
 my $branch=C4::Context->preference("defaultBranch");
 my $printer = getprinter($query, $printers);
 

Index: logout.pl
===================================================================
RCS file: /sources/koha/koha/logout.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- logout.pl   10 Oct 2002 10:07:34 -0000      1.5
+++ logout.pl   27 Sep 2006 21:19:22 -0000      1.6
@@ -69,7 +69,7 @@
 
 # Should redirect to intranet home page after logging out
 
-print $query->redirect("userpage.pl");
+print $query->redirect("mainpage.pl");
 exit;
 
 

Index: mainpage.pl
===================================================================
RCS file: /sources/koha/koha/mainpage.pl,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- mainpage.pl 3 Mar 2006 17:02:22 -0000       1.11
+++ mainpage.pl 27 Sep 2006 21:19:22 -0000      1.12
@@ -1,25 +1,14 @@
 #!/usr/bin/perl
-use HTML::Template;
 use strict;
-require Exporter;
-use C4::Database;
-use C4::Output;  # contains gettemplate
 use C4::Interface::CGI::Output;
 use CGI;
 use C4::Auth;
-use C4::AuthoritiesMarc;
+use C4::Suggestions;
 use C4::Koha;
+use C4::BookShelves;
 use C4::NewsChannels;
-my $query = new CGI;
-my $authtypes = getauthtypes;
-my @authtypesloop;
-foreach my $thisauthtype (sort { $authtypes->{$a} <=> $authtypes->{$b} } keys 
%$authtypes) {
-       my %row =(value => $thisauthtype,
-                               authtypetext => 
$authtypes->{$thisauthtype}{'authtypetext'},
-                       );
-       push @authtypesloop, \%row;
-}
 
+my $query = new CGI;
 my ($template, $loggedinuser, $cookie)
     = get_template_and_user({template_name => "intranet-main.tmpl",
                             query => $query,
@@ -28,17 +17,25 @@
                             flagsrequired => {catalogue => 1, circulate => 1,
                                                        parameters => 1, 
borrowers => 1,
                                                        permissions =>1, 
reserveforothers=>1,
-                                                       borrow => 1, 
reserveforself => 1,
                                                        editcatalogue => 1, 
updatecharges => 1, },
                             debug => 1,
                             });
 
+my $lang = "koha";
+my $error=$query->param('error');
+$template->param(error        =>$error);
+my ($opac_news_count, $all_opac_news) = &get_opac_news(undef, $lang);
+# if ($opac_news_count > 4) {$template->param(more_opac_news => 1);}
+$template->param(opac_news        => $all_opac_news);
+$template->param(opac_news_count  => $opac_news_count);
+
 my $marc_p = C4::Context->boolean_preference("marc");
 $template->param(NOTMARC => !$marc_p);
-$template->param(authtypesloop => address@hidden);
+my $new_suggestions = &CountSuggestion("ASKED");
+$template->param(new_suggestions => $new_suggestions);
+
 
-my ($koha_news_count, $all_koha_news) = &get_opac_news(undef, 'koha');
-$template->param(koha_news        => $all_koha_news);
-$template->param(koha_news_count  => $koha_news_count);
+my $count_pending_request = CountShelfRequest(undef, "PENDING");
+$template->param(count_pending_request => $count_pending_request);
+output_html_with_http_headers $query, $cookie, $template->output();
 
-output_html_with_http_headers $query, $cookie, $template->output;

Index: members/boraccount.pl
===================================================================
RCS file: /sources/koha/koha/members/boraccount.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- members/boraccount.pl       22 Sep 2006 00:21:25 -0000      1.3
+++ members/boraccount.pl       27 Sep 2006 21:19:22 -0000      1.4
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: boraccount.pl,v 1.3 2006/09/22 00:21:25 tgarip1957 Exp $
+# $Id: boraccount.pl,v 1.4 2006/09/27 21:19:22 tgarip1957 Exp $
 
 #writen 11/1/2000 by address@hidden
 #script to display borrowers account details
@@ -29,11 +29,14 @@
 use C4::Interface::CGI::Output;
 use C4::Date;
 use CGI;
-use C4::Search;
 use C4::Members;
+use HTML::Template;
+
 my $input=new CGI;
 
 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
+#my %tmpldata = pathtotemplate ( template => 'boraccount.tmpl', theme => 
$theme );
+#my $template = HTML::Template->new(filename => $tmpldata{'path'}, 
die_on_bad_params => 0);
 my ($template, $loggedinuser, $cookie)
     = get_template_and_user({template_name => "members/boraccount.tmpl",
                             query => $input,
@@ -74,14 +77,11 @@
        $accts->[$i]{'amountoutstandingcredit'} = 1;
   }
   my %row = (   'date'              => format_date($accts->[$i]{'date'}),
-               'accountid' => $accts->[$i]{'accountid'},
-               'itemnum' => $accts->[$i]{'itemnumber'},
                'amountcredit' => $accts->[$i]{'amountcredit'},
                'amountoutstandingcredit' => 
$accts->[$i]{'amountoutstandingcredit'},
                'toggle' => $accts->[$i]{'toggle'},
                'description'       => $accts->[$i]{'description'},
                'amount'            => sprintf("%.2f",$accts->[$i]{'amount'}),
-               'accounttype'   =>$accts->[$i]{'accounttype'},
                'amountoutstanding' => 
sprintf("%.2f",$accts->[$i]{'amountoutstanding'}) );
                
   if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 
'FU'){

Index: members/mancredit.pl
===================================================================
RCS file: /sources/koha/koha/members/mancredit.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- members/mancredit.pl        22 Sep 2006 00:21:25 -0000      1.3
+++ members/mancredit.pl        27 Sep 2006 21:19:22 -0000      1.4
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-#wrriten 18/09/2005 by TG
+#wrriten 11/1/2000 by address@hidden
 #script to display borrowers account details
 
 
@@ -26,60 +26,37 @@
 use C4::Output;
 use C4::Interface::CGI::Output;
 use CGI;
-
-use C4::Search;
-use C4::Accounts2;
+use HTML::Template;
 use C4::Members;
+use C4::Accounts2;
 my $input=new CGI;
-  my $accounttype=$input->param('accounttype');
- my $accountid=$input->param('accountid');
-my $amount=$input->param('amount');
-my $itemnum=$input->param('itemnum');
-my $error=0;
+
+
 my $bornum=$input->param('bornum');
 #get borrower details
 my $data=borrdata('',$bornum);
-my $user=$data->{firstname}.",".$data->{surname}."-".$data->{cardnumber};
 my $add=$input->param('add');
-# $error=$input->param('error');
-my ($template, $loggedinuser, $cookie)
-       = get_template_and_user({template_name => "members/mancredit.tmpl",
+if ($add){
+  my $itemnum=$input->param('itemnum');
+  my $desc=$input->param('desc');
+  my $amount=$input->param('amount');
+  $amount = -$amount;
+  my $type=$input->param('type');
+  manualinvoice($bornum,$itemnum,$desc,$type,$amount);
+  print $input->redirect("/cgi-bin/koha/members/boraccount.pl?bornum=$bornum");
+} else {
+       my ($template, $loggedinuser, $cookie)
+       = get_template_and_user({template_name => "mancredit.tmpl",
                                        query => $input,
                                        type => "intranet",
                                        authnotrequired => 0,
                                        flagsrequired => {borrowers => 1},
                                        debug => 1,
                                        });
-       $template->param(user => $user);
        $template->param( bornum => $bornum);
-       $template->param( itemnum => $itemnum);
-       $template->param( amount => $amount);
-       $template->param( accounttype => $accounttype);
-       $template->param( accountid => $accountid);
-if ($add){
-if ($accounttype eq "F" || $accounttype eq "FU"){
-$accounttype="CF";
-}else{
-$accounttype="C".$accounttype;
-}
+       print $input->header(
+           -type => guesstype($template->output),
+           -cookie => $cookie
+       ),$template->output;
        
-  my $desc=$input->param('desc');
-  my $amount=$input->param('amount');
-  $amount = -$amount;
-my $loggeduser=$input->param('loggedinuser');
-my   
$error=manualcredit($bornum,$accountid,$desc,$accounttype,$amount,$loggeduser);
-       if ($error>0 ) {
-       $template->param( error => "1");
-       $template->param(user => $user);
-       $template->param( bornum => $bornum);
-       $template->param( itemnum => $itemnum);
-       $template->param( amount => $amount);
-       $template->param( accounttype => $accounttype);
-       $template->param( accountid => $accountid);
-       } else {
-       print 
$input->redirect("/cgi-bin/koha/members/boraccount.pl?bornum=$bornum");
-       }
 } 
-       
-
-output_html_with_http_headers $input, $cookie, $template->output;

Index: members/maninvoice.pl
===================================================================
RCS file: /sources/koha/koha/members/maninvoice.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- members/maninvoice.pl       22 Sep 2006 00:21:25 -0000      1.3
+++ members/maninvoice.pl       27 Sep 2006 21:19:22 -0000      1.4
@@ -26,28 +26,27 @@
 use C4::Output;
 use C4::Interface::CGI::Output;
 use CGI;
-use C4::Search;
-use C4::Accounts2;
 use C4::Members;
-
+use C4::Accounts2;
+use HTML::Template;
 
 my $input=new CGI;
 
 my $bornum=$input->param('bornum');
 #get borrower details
 my $data=borrdata('',$bornum);
-my $user=$data->{firstname}.",".$data->{surname}."-".$data->{cardnumber};
 my $add=$input->param('add');
 if ($add){
 #  print $input->header;
+  my $itemnum=$input->param('itemnum');
   my $desc=$input->param('desc');
   my $amount=$input->param('amount');
   my $type=$input->param('type');
-  manualinvoice($bornum,$desc,$type,$amount);
+  manualinvoice($bornum,$itemnum,$desc,$type,$amount);
   print $input->redirect("/cgi-bin/koha/members/boraccount.pl?bornum=$bornum");
 } else {
        my ($template, $loggedinuser, $cookie)
-       = get_template_and_user({template_name => "members/maninvoice.tmpl",
+       = get_template_and_user({template_name => "maninvoice.tmpl",
                                        query => $input,
                                        type => "intranet",
                                        authnotrequired => 0,
@@ -55,6 +54,9 @@
                                        debug => 1,
                                        });
        $template->param(bornum => $bornum);
-       $template->param(user => $user);
-       output_html_with_http_headers $input, $cookie, $template->output;
+       print $input->header(
+           -type => guesstype($template->output),
+           -cookie => $cookie
+       ),$template->output;
+
 }

Index: members/memberentry.pl
===================================================================
RCS file: /sources/koha/koha/members/memberentry.pl,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- members/memberentry.pl      21 Jul 2006 09:57:30 -0000      1.38
+++ members/memberentry.pl      27 Sep 2006 21:19:22 -0000      1.39
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# $Id: memberentry.pl,v 1.38 2006/07/21 09:57:30 toins Exp $
+# $Id: memberentry.pl,v 1.39 2006/09/27 21:19:22 tgarip1957 Exp $
 
 # Copyright 2006 SAN OUEST PROVENCE et Paul POULAIN
 #
@@ -24,14 +24,12 @@
 # external modules
 use Date::Calc qw/Today/;
 use CGI;
-use HTML::Template;
 use Date::Manip;
 use Digest::MD5 qw(md5_base64);
 
 # internal modules
 use C4::Auth;
 use C4::Context;
-use C4::Output;
 use C4::Interface::CGI::Output;
 use C4::Search;
 use C4::Members;

Index: members/moremember.pl
===================================================================
RCS file: /sources/koha/koha/members/moremember.pl,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- members/moremember.pl       4 Jul 2006 14:36:52 -0000       1.28
+++ members/moremember.pl       27 Sep 2006 21:19:22 -0000      1.29
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: moremember.pl,v 1.28 2006/07/04 14:36:52 toins Exp $
+# $Id: moremember.pl,v 1.29 2006/09/27 21:19:22 tgarip1957 Exp $
 
 # script to do a borrower enquiry/bring up borrower details etc
 # Displays all the details about a borrower
@@ -185,7 +185,7 @@
        #check item is not reserved
        my ($restype,$reserves)=CheckReserves($issue->[$i]{'itemnumber'});
        if ($restype){
-#              print "<TD><a 
href=/cgi-bin/koha/request.pl?bib=$issue->[$i]{'biblionumber'}>On Request - no 
renewals</a></td></tr>";
+#              print "<TD><a 
href=/cgi-bin/koha/reserve/request.pl?bib=$issue->[$i]{'biblionumber'}>On 
Request - no renewals</a></td></tr>";
                #  } elsif ($issue->[$i]->{'renewals'} > 0) {
                #      print "<TD>Previously Renewed - no renewals</td></tr>";
                        $row{'norenew'}=1;

Index: members/pay.pl
===================================================================
RCS file: /sources/koha/koha/members/pay.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- members/pay.pl      22 Sep 2006 00:21:25 -0000      1.5
+++ members/pay.pl      27 Sep 2006 21:19:22 -0000      1.6
@@ -1,11 +1,9 @@
 #!/usr/bin/perl
-# WARNING: Not enough context to figure out the correct tabstop size
-# WARNING: Assume that this file uses 4-character tabs
 
-# $Id: pay.pl,v 1.5 2006/09/22 00:21:25 tgarip1957 Exp $
+# $Id: pay.pl,v 1.6 2006/09/27 21:19:22 tgarip1957 Exp $
 
-#written 11/1/2000 by address@hidden
-#part of the koha library system, script to facilitate paying off fines
+# written 11/1/2000 by address@hidden
+# part of the koha library system, script to facilitate paying off fines
 
 
 # Copyright 2000-2002 Katipo Communications
@@ -28,80 +26,70 @@
 use strict;
 use C4::Context;
 use C4::Auth;
-use C4::Interface::CGI::Output;
+use C4::Output;
 use CGI;
-use C4::Search;
+use C4::Members;
 use C4::Accounts2;
 use C4::Stats;
-use C4::Members;
+use C4::Koha;
+use HTML::Template;
 
 my $input=new CGI;
-my ($template, $loggedinuser, $cookie)
-               = get_template_and_user ({ template_name => "members/pay.tmpl",
-                                          query => $input,
-                                          type => "intranet",
-                                          authnotrequired => 0,
-                                          flagsrequired => {borrowers => 1},
-                                          debug => 1,
-                                        });
 
+#print $input->header;
 my $bornum=$input->param('bornum');
 if ($bornum eq ''){
        $bornum=$input->param('bornum0');
 }
-#get borrower details
+# get borrower details
 my $data=borrdata('',$bornum);
-my $user=C4::Context->preference('defaultBranch');
-my $me=borrdata('',$loggedinuser);
-my $accountant=$me->{'firstname'}.' '.$me->{'surname'};
-#get account details
+my $user=$input->remote_user;
+
+# get account details
 my %bor;
 $bor{'borrowernumber'}=$bornum;
+my $branches = GetBranches();
+my $printers = getprinters();
+my $branch = getbranch($input, $branches);
 
 my @names=$input->param;
 my %inp;
 my $check=0;
-my $type;
-my $totalamount;
-my $totaldesc;
-my $totalaccounttype;
-
 for (my $i=0;$i<@names;$i++){
-       my$temp=$input->param($names[$i]);
+       my $temp=$input->param($names[$i]);
        if ($temp eq 'wo'){
-               $type="W";
-               $check=2;
+               $inp{$names[$i]}=$temp;
+               $check=1;
        }
-if ($temp eq 'yes'){
-               $type="Pay";
-               $check=2;
-       }
-       if ($temp eq 'yes' || $temp eq 'wo'){
-               
-               my $desc=$input->param($names[$i+7]);
-               my $accounttype=$input->param($names[$i+2]);
+       if ($temp eq 'yes'){
+               # For HLT
+               $user=~ s/Levin/L/i;
+               $user=~ s/Foxton/F/i;
+               $user=~ s/Shannon/S/i;
+               # FIXME : using array +4, +5, +6 is dirty. Should use arrays 
for each accountline
                my $amount=$input->param($names[$i+4]);
                my $bornum=$input->param($names[$i+5]);
                my $accountno=$input->param($names[$i+6]);
-               my $amounttopay=$input->param($names[$i+8]);
-
-               makepayment($bornum,$accountno,$amounttopay,$accountant, $type);
-               $totalamount=$totalamount+$amounttopay;
-               $totaldesc .="<br> ".$desc."-  Fee:".$amounttopay;
-               $totalaccounttype .="<br> ".$accounttype;
+               makepayment($bornum,$accountno,$amount,$user,$branch);
                $check=2;
        }
 }
-if ($type eq "Pay" || $type eq "W"){
-print 
$input->redirect("/cgi-bin/koha/members/payprint.pl?bornum=$bornum&accounttype=$totalaccounttype&amount=$totalamount&desc=$totaldesc");
-}
 my %env;
+    $user=~ s/Levin/L/i;
+    $user=~ s/Foxton/F/i;
+    $user=~ s/Shannon/S/i;
    
-
-$env{'branchcode'}=C4::Context->preference('defaultBranch');
+$env{'branchcode'}=$branch;
 my $total=$input->param('total');
 if ($check ==0){
-       
+       my($template, $loggedinuser, $cookie)
+               = get_template_and_user ({ template_name => "members/pay.tmpl",
+                                          query => $input,
+                                          type => "intranet",
+                                          authnotrequired => 0,
+                                          flagsrequired => {borrowers => 1},
+                                          debug => 1,
+                                        });
        if ($total ne ''){
                recordpayment(\%env,$bornum,$total);
        }
@@ -129,11 +117,12 @@
                                                        surname => 
$data->{'surname'},
                                                        bornum => $bornum,
                                                        loop_pay => 
address@hidden,
-                                                       total => 
sprintf("%.2f",$total),
-                                                       totalamountopay => 
sprintf("%.2f",$total));
-output_html_with_http_headers $input, $cookie, $template->output;
+                                                       total => 
sprintf("%.2f",$total));
+       print "Content-Type: text/html\n\n", $template->output;
 
 } else {
+#  my $quety=$input->query_string;
+#  print $input->redirect("/cgi-bin/koha/sec/writeoff.pl?$quety");
        my%inp;
        my @name=$input->param;
        for (my $i=0;$i<@name;$i++){
@@ -151,14 +140,33 @@
                $bornum=$input->param("bornum$value");
                my $itemno=$input->param("itemnumber$value");
                my $amount=$input->param("amount$value");
-               
+               my $accountno=$input->param("accountno$value");
+               writeoff($bornum,$accountno,$itemno,$accounttype,$amount);
        }
        $bornum=$input->param('bornum');
-       print $input->redirect("/cgi-bin/koha/members/pay.pl?bornum=$bornum");
+       print 
$input->redirect("/cgi-bin/koha/members/moremember.pl?bornum=$bornum");
 }
 
 
-
+sub writeoff{
+       my ($bornum,$accountnum,$itemnum,$accounttype,$amount)address@hidden;
+       my $user=$input->remote_user;
+       my $dbh = C4::Context->dbh;
+       my $env;
+       my $sth=$dbh->prepare("Update accountlines set amountoutstanding=0 
where accounttype='Res' and accountno=? and borrowernumber=?");
+        $sth->execute($accountnum,$bornum);
+       $sth->finish;
+       $sth=$dbh->prepare("select max(accountno) from accountlines");
+       $sth->execute;
+       my $account=$sth->fetchrow_hashref;
+       $sth->finish;
+       $account->{'max(accountno)'}++;
+       $sth=$dbh->prepare("insert into accountlines 
(borrowernumber,accountno,itemnumber,date,amount,description,accounttype)
+                                               values 
(?,?,?,now(),?,'Writeoff','W')");
+       $sth->execute($bornum,$account->{'max(accountno)'},$itemnum,$amount);
+       $sth->finish;
+       UpdateStats($env,$branch,'writeoff',$amount,'','','',$bornum);
+}
 
 # Local Variables:
 # tab-width: 4

Index: serials/acqui-search-result.pl
===================================================================
RCS file: /sources/koha/koha/serials/acqui-search-result.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- serials/acqui-search-result.pl      11 Sep 2006 17:41:55 -0000      1.6
+++ serials/acqui-search-result.pl      27 Sep 2006 21:19:22 -0000      1.7
@@ -20,7 +20,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: acqui-search-result.pl,v 1.6 2006/09/11 17:41:55 tgarip1957 Exp $
+# $Id: acqui-search-result.pl,v 1.7 2006/09/27 21:19:22 tgarip1957 Exp $
 
 =head1 NAME
 

Index: serials/acqui-search.pl
===================================================================
RCS file: /sources/koha/koha/serials/acqui-search.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- serials/acqui-search.pl     11 Sep 2006 17:41:55 -0000      1.6
+++ serials/acqui-search.pl     27 Sep 2006 21:19:22 -0000      1.7
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: acqui-search.pl,v 1.6 2006/09/11 17:41:55 tgarip1957 Exp $
+# $Id: acqui-search.pl,v 1.7 2006/09/27 21:19:22 tgarip1957 Exp $
 
 use strict;
 use CGI;

Index: serials/distributedto.pl
===================================================================
RCS file: /sources/koha/koha/serials/distributedto.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- serials/distributedto.pl    11 Sep 2006 17:41:55 -0000      1.4
+++ serials/distributedto.pl    27 Sep 2006 21:19:22 -0000      1.5
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: distributedto.pl,v 1.4 2006/09/11 17:41:55 tgarip1957 Exp $
+# $Id: distributedto.pl,v 1.5 2006/09/27 21:19:22 tgarip1957 Exp $
 
 =head1 NAME
 

Index: serials/lateissues.pl
===================================================================
RCS file: /sources/koha/koha/serials/lateissues.pl,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- serials/lateissues.pl       11 Sep 2006 17:41:55 -0000      1.9
+++ serials/lateissues.pl       27 Sep 2006 21:19:22 -0000      1.10
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: lateissues.pl,v 1.9 2006/09/11 17:41:55 tgarip1957 Exp $
+# $Id: lateissues.pl,v 1.10 2006/09/27 21:19:22 tgarip1957 Exp $
 
 =head1 NAME
 

Index: serials/printlist.pl
===================================================================
RCS file: /sources/koha/koha/serials/printlist.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- serials/printlist.pl        11 Sep 2006 17:41:55 -0000      1.3
+++ serials/printlist.pl        27 Sep 2006 21:19:22 -0000      1.4
@@ -18,7 +18,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 # 
-# $Id: printlist.pl,v 1.3 2006/09/11 17:41:55 tgarip1957 Exp $
+# $Id: printlist.pl,v 1.4 2006/09/27 21:19:22 tgarip1957 Exp $
 
 =head1 NAME
 

Index: serials/serial-issues.pl
===================================================================
RCS file: /sources/koha/koha/serials/serial-issues.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- serials/serial-issues.pl    11 Sep 2006 17:41:55 -0000      1.5
+++ serials/serial-issues.pl    27 Sep 2006 21:19:22 -0000      1.6
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: serial-issues.pl,v 1.5 2006/09/11 17:41:55 tgarip1957 Exp $
+# $Id: serial-issues.pl,v 1.6 2006/09/27 21:19:22 tgarip1957 Exp $
 
 =head1 NAME
 

Index: serials/serials-home.pl
===================================================================
RCS file: /sources/koha/koha/serials/serials-home.pl,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- serials/serials-home.pl     11 Sep 2006 17:41:55 -0000      1.7
+++ serials/serials-home.pl     27 Sep 2006 21:19:22 -0000      1.8
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: serials-home.pl,v 1.7 2006/09/11 17:41:55 tgarip1957 Exp $
+# $Id: serials-home.pl,v 1.8 2006/09/27 21:19:22 tgarip1957 Exp $
 
 =head1 NAME
 

Index: serials/serials-receive.pl
===================================================================
RCS file: /sources/koha/koha/serials/serials-receive.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- serials/serials-receive.pl  11 Sep 2006 17:41:55 -0000      1.2
+++ serials/serials-receive.pl  27 Sep 2006 21:19:22 -0000      1.3
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: serials-receive.pl,v 1.2 2006/09/11 17:41:55 tgarip1957 Exp $
+# $Id: serials-receive.pl,v 1.3 2006/09/27 21:19:22 tgarip1957 Exp $
 
 =head1 NAME
 

Index: serials/subscription-add.pl
===================================================================
RCS file: /sources/koha/koha/serials/subscription-add.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- serials/subscription-add.pl 11 Sep 2006 17:41:55 -0000      1.8
+++ serials/subscription-add.pl 27 Sep 2006 21:19:22 -0000      1.9
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: subscription-add.pl,v 1.8 2006/09/11 17:41:55 tgarip1957 Exp $
+# $Id: subscription-add.pl,v 1.9 2006/09/27 21:19:22 tgarip1957 Exp $
 
 =head1 NAME
 

Index: serials/subscription-renew.pl
===================================================================
RCS file: /sources/koha/koha/serials/subscription-renew.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- serials/subscription-renew.pl       11 Sep 2006 17:41:55 -0000      1.4
+++ serials/subscription-renew.pl       27 Sep 2006 21:19:22 -0000      1.5
@@ -18,7 +18,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: subscription-renew.pl,v 1.4 2006/09/11 17:41:55 tgarip1957 Exp $
+# $Id: subscription-renew.pl,v 1.5 2006/09/27 21:19:22 tgarip1957 Exp $
 
 =head1 NAME
 

Index: serials/viewalerts.pl
===================================================================
RCS file: /sources/koha/koha/serials/viewalerts.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- serials/viewalerts.pl       11 Sep 2006 17:41:55 -0000      1.3
+++ serials/viewalerts.pl       27 Sep 2006 21:19:22 -0000      1.4
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: viewalerts.pl,v 1.3 2006/09/11 17:41:55 tgarip1957 Exp $
+# $Id: viewalerts.pl,v 1.4 2006/09/27 21:19:22 tgarip1957 Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #

Index: tools/exceptionHolidays.pl
===================================================================
RCS file: /sources/koha/koha/tools/exceptionHolidays.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- tools/exceptionHolidays.pl  3 Mar 2006 16:35:21 -0000       1.1
+++ tools/exceptionHolidays.pl  27 Sep 2006 21:19:22 -0000      1.2
@@ -4,11 +4,9 @@
 use CGI;
 
 use C4::Auth;
-use C4::Output;
+
 use C4::Interface::CGI::Output;
-use C4::Database;
-use HTML::Template;
-use C4::Calendar;
+use C4::Calendar::Calendar;
 
 my $input = new CGI;
 my $dbh = C4::Context->dbh();
@@ -21,7 +19,7 @@
 my $title = $input->param('showTitle');
 my $description = $input->param('showDescription');
 
-my $calendar = C4::Calendar->new(branchcode => $branchcode);
+my $calendar = C4::Calendar::Calendar->new(branchcode => $branchcode);
 
 if ($input->param('showOperation') eq 'exception') {
        $calendar->insert_exception_holiday(day => $day,

Index: tools/holidays.pl
===================================================================
RCS file: /sources/koha/koha/tools/holidays.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- tools/holidays.pl   11 Sep 2006 17:41:56 -0000      1.2
+++ tools/holidays.pl   27 Sep 2006 21:19:22 -0000      1.3
@@ -11,7 +11,7 @@
 
 my $input = new CGI;
 my $branch = $input->param('branch');
-my $branch=C4::Context->preference('defaultbranch') unless $branch;
+$branch=C4::Context->preference('defaultBranch') unless $branch;
 my $dbh = C4::Context->dbh();
 
 # Set all the branches.
@@ -26,13 +26,12 @@
 if (!defined($branch)) {
        $branch =$listValues[4];
 }
-my $branchesList = CGI::scrolling_list(-name => 'branch',
+my $branchesList = CGI::scrolling_list(-name => 'branch', -id=>'branch',
                                               -values => address@hidden,
                                                   -labels => \%list,
                                                   -size => 1,
                                                                           
-default => [$branch],
                                                   -multiple => 0,
-                                                                          -id 
=> "branch",
                                                                           
-onChange => "changeBranch()");
 
 $branches->finish;

Index: tools/import.pl
===================================================================
RCS file: /sources/koha/koha/tools/import.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- tools/import.pl     11 Sep 2006 17:41:56 -0000      1.2
+++ tools/import.pl     27 Sep 2006 21:19:22 -0000      1.3
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: import.pl,v 1.2 2006/09/11 17:41:56 tgarip1957 Exp $
+# $Id: import.pl,v 1.3 2006/09/27 21:19:22 tgarip1957 Exp $
 
 # Script for handling import of MARC data into Koha db
 #   and Z39.50 lookups
@@ -95,8 +95,8 @@
 #---------------
 # log cleared, as marcimport is (almost) rewritten from scratch.
 # $Log: import.pl,v $
-# Revision 1.2  2006/09/11 17:41:56  tgarip1957
-# New XML API
+# Revision 1.3  2006/09/27 21:19:22  tgarip1957
+# Finalized XML version for intranet
 #
 # Revision 1.2.4.1  2005/04/07 10:10:52  tipaul
 # copying processz3950queue from 2.0 branch. The 2.2 version misses an 
important fix

Index: tools/printerConfig.pl
===================================================================
RCS file: /sources/koha/koha/tools/printerConfig.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- tools/printerConfig.pl      24 Feb 2006 11:52:38 -0000      1.1
+++ tools/printerConfig.pl      27 Sep 2006 21:19:22 -0000      1.2
@@ -27,7 +27,6 @@
 use C4::Context;
 use C4::Output;
 use C4::Auth;
-use HTML::Template;
 use PDF::API2;
 use PDF::API2::Page;
 use PDF::API2::PDF::Utils;

Index: tools/tools-home.pl
===================================================================
RCS file: /sources/koha/koha/tools/tools-home.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- tools/tools-home.pl 11 Aug 2006 16:33:01 -0000      1.1
+++ tools/tools-home.pl 27 Sep 2006 21:19:22 -0000      1.2
@@ -3,10 +3,8 @@
 use strict;
 use CGI;
 use C4::Auth;
-use C4::Output;
 use C4::Interface::CGI::Output;
-use C4::Database;
-use HTML::Template;
+
 
 my $query = new CGI;
 my ($template, $loggedinuser, $cookie)




reply via email to

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