Skip to content

Commit

Permalink
New XML API
Browse files Browse the repository at this point in the history
  • Loading branch information
tgarip1957 committed Sep 11, 2006
1 parent 67fdde9 commit 5b41a8e
Show file tree
Hide file tree
Showing 125 changed files with 9,244 additions and 5,573 deletions.
88 changes: 77 additions & 11 deletions admin/aqbookfund.pl
Expand Up @@ -41,22 +41,41 @@
use CGI;
use C4::Auth;
use C4::Context;
use C4::Output;
use C4::Acquisition;
use C4::Koha;
use C4::Interface::CGI::Output;
use C4::Search;
use C4::Date;


sub StringSearch {
my ($env,$searchstring,$type)=@_;
my ($env,$searchstring,%branches)=@_;
my $dbh = C4::Context->dbh;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my @data=split(' ',$searchstring) if ($searchstring ne "");
my $count=@data;
my $sth=$dbh->prepare("select bookfundid,bookfundname,bookfundgroup from aqbookfund where (bookfundname like ?) order by bookfundid");
$sth->execute("%$data[0]%");
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;
Expand Down Expand Up @@ -91,6 +110,26 @@ sub StringSearch {
$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 => \@select_branch,
-labels => \%select_branches,
-size => 1,
-multiple => 0 );
$template->param(CGIbranch => $CGIbranch);

################## ADD_FORM ##################################
# called by default. Used to create form to add or modify a record
if ($op eq 'add_form') {
Expand Down Expand Up @@ -130,9 +169,15 @@ sub StringSearch {
my $sth=$dbh->prepare("delete from aqbookfund where bookfundid =?");
$sth->execute($bookfundid);
$sth->finish;
my $sth=$dbh->prepare("replace aqbookfund (bookfundid,bookfundname) values (?,?)");
$sth->execute($input->param('bookfundid'),$input->param('bookfundname'));
$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;

Expand Down Expand Up @@ -168,29 +213,50 @@ sub StringSearch {
$template->param(searchfield => $searchfield);
}
my $env;
my ($count,$results)=StringSearch($env,$searchfield,'web');
my ($count,$results)=StringSearch($env,$searchfield,%select_branches);
my $toggle="white";
my @loop_data =();
my $dbh = C4::Context->dbh;
my $sth2 = $dbh->prepare("Select aqbudgetid,startdate,enddate,budgetamount from aqbudget where bookfundid = ? order by bookfundid");
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} = \@budget_loop;
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 => \@loop_data);
} #---- 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;
2 changes: 1 addition & 1 deletion admin/branches.pl
Expand Up @@ -29,7 +29,7 @@
# Fixed variables
my $linecolor1='#ffffcc';
my $linecolor2='white';
my $backgroundimage="/images/background-mem.gif";

my $script_name="/cgi-bin/koha/admin/branches.pl";
my $pagesize=20;

Expand Down
19 changes: 12 additions & 7 deletions catalogue/ISBDdetail.pl
Expand Up @@ -43,18 +43,24 @@ =head1 FUNCTIONS
use C4::Output;
use C4::Interface::CGI::Output;
use CGI;
use C4::Koha;
use C4::Search;
use MARC::Record;
use C4::Biblio;
use C4::Acquisition;
use HTML::Template;

my $query=new CGI;

my $dbh=C4::Context->dbh;

my $biblionumber=$query->param('biblionumber');
my $itemtype = &MARCfind_frameworkcode($dbh,$biblionumber);
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 $tagslib = &MARCgettagslib($dbh,1,$itemtype);

my $record =MARCgetbiblio($dbh,$biblionumber);
my $record =MARCgetbiblio($dbh,$bibid);
# open template
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "catalogue/ISBDdetail.tmpl",
Expand Down Expand Up @@ -129,13 +135,12 @@ ($$$$$)

#---- branch
if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
return getbranchdetail($value)->{branchname};
return getbranchname($value);
}

#---- itemtypes
if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
my $itemtypedef = getitemtypeinfo($itemtype);
return $itemtypedef->{description};
return ItemType($value);
}

#---- "true" authorized value
Expand Down
22 changes: 19 additions & 3 deletions catalogue/catalogue-search.pl
@@ -1,8 +1,7 @@
#!/usr/bin/perl
use strict;
require Exporter;

use CGI;
#use C4::Interface::CGI::KOHACGI;
use C4::Search;
use C4::Auth;
use C4::Interface::CGI::Output;
Expand All @@ -12,7 +11,7 @@

my $query = new CGI;
my $dbh = C4::Context->dbh;
$query->charset('UTF8');

my $op = $query->param('op'); #show the search form or execute the search

my $format=$query->param('MARC');
Expand All @@ -28,12 +27,29 @@
my $number_of_results=$query->param('number_of_results');
my $zoom=$query->param('zoom');
my $ascend=$query->param('asc');

my @marclist = $query->param('marclist');
# collect all the fields ...
my %search;
my @forminputs; #this is for the links to navigate among the results
my (@searchdesc, %hashdesc); #this is to show the description of the current search
my @fields = ('value', 'kohafield', 'and_or', 'relation','order','barcode','biblionumber','itemnumber','asc','from');

###Collect all the marclist values coming from old Koha MARCdetails
## Although we can not search on all marc fields- if any is matched in Zebra we can use it it
my $sth=$dbh->prepare("Select marctokoha from koha_attr where tagfield=? and tagsubfield=? and intrashow=1");
foreach my $marc (@marclist) {
if ($marc) {
$sth->execute(substr($marc,0,3),substr($marc,3,1));
if ((my $kohafield)=$sth->fetchrow){
push @kohafield,$kohafield;
push @and_or,"\@or";
push @value,@value[0] if @kohafield>1;
push @relation ,"\@attr 5=1";
}
}
}
#### Now normal search routine
foreach my $field (@fields) {
$search{$field} = $query->param($field);
if ($search{$field}) {
Expand Down
3 changes: 1 addition & 2 deletions catalogue/moredetail.pl
Expand Up @@ -26,15 +26,14 @@
use CGI;
use C4::Search;
use C4::Acquisition;
use C4::Output; # contains gettemplate
use C4::Auth;
use C4::Interface::CGI::Output;
use C4::Date;
use C4::Context;
use C4::Biblio;
use C4::Accounts2;
use C4::Circulation::Circ2;
use MARC::Record;

my $dbh=C4::Context->dbh;
my $query=new CGI;

Expand Down
34 changes: 0 additions & 34 deletions export/export.pl

This file was deleted.

0 comments on commit 5b41a8e

Please sign in to comment.