[Koha-cvs] koha export/marc.pl koha-tmpl/intranet-tmpl/def... [rel_2_2]

Henri-Damien LAURENT laurenthdl at alinto.com
Fri Dec 16 14:04:03 CET 2005


CVSROOT:	/cvsroot/koha
Module name:	koha
Branch: 	rel_2_2
Changes by:	Henri-Damien LAURENT <hdl at savannah.gnu.org>	05/12/16 13:04:03

Modified files:
	export         : marc.pl 
	koha-tmpl/intranet-tmpl/default/en/export: marc.tmpl 

Log message:
	Adding some export features :
	Itemtypes
	Itemcallnumber
	branch
	And biblionumber and not bibid selection

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha/export/marc.pl.diff?only_with_tag=rel_2_2&tr1=1.4.2.1&tr2=1.4.2.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/koha-tmpl/intranet-tmpl/default/en/export/marc.tmpl.diff?only_with_tag=rel_2_2&tr1=1.6.4.1&tr2=1.6.4.2&r1=text&r2=text

Patches:
Index: koha/export/marc.pl
diff -u koha/export/marc.pl:1.4.2.1 koha/export/marc.pl:1.4.2.2
--- koha/export/marc.pl:1.4.2.1	Thu Apr  7 10:10:52 2005
+++ koha/export/marc.pl	Fri Dec 16 13:04:03 2005
@@ -8,29 +8,93 @@
 use C4::Output;  # contains gettemplate
 use C4::Biblio;
 use CGI;
-use C4::Auth;
+use C4::Koha;
 
 my $query = new CGI;
 my $op=$query->param("op");
+my $dbh=C4::Context->dbh;
+
 if ($op eq "export") {
 	print $query->header('Content-Type: text/marc');
 	my $start_bib = $query->param("start_bib");
 	my $end_bib = $query->param("end_bib");
-	my $dbh=C4::Context->dbh;
-	my $sth;
+	my $format = $query->param("format");
+	my $branch = $query->param("branch");
+	my $start_callnumber = $query->param("start_callnumber");
+	my $end_callnumber = $query->param("end_callnumber");
+	my $limit = $query->param("limit");
+	my $strsth;
+	$strsth="select bibid from marc_biblio ";
 	if ($start_bib && $end_bib) {
-		$sth=$dbh->prepare("select bibid from marc_biblio where bibid >=? and bibid <=? order by bibid");
-		$sth->execute($start_bib,$end_bib);
-	} else {
-		$sth=$dbh->prepare("select bibid from marc_biblio order by bibid");
-		$sth->execute();
+		$strsth.=" where biblionumber>=$start_bib and biblionumber<=$end_bib ";
+	}elsif ($format) {
+		if ($strsth=~/ where/){
+			$strsth=~s/ where (.*)/,biblioitems where biblioitems.biblionumber=marc_biblio.biblionumber and biblioitems.itemtype=\'$format\' and $1/;
+		}else {
+			$strsth.=",biblioitems where biblioitems.biblionumber=marc_biblio.biblionumber and biblioitems.itemtype=\'$format\'";
+		}
+	} elsif ($branch) {
+		if ($strsth=~/ where/){
+			$strsth=~s/ where (.*)/,items where items.biblionumber=marc_biblio.biblionumber and items.homebranch=\'$branch\' and $1/;
+		}else {
+			$strsth.=",items where items.biblionumber=marc_biblio.biblionumber and items.homebranch=\'$branch\'";
+		}
+	} elsif ($start_callnumber && $end_callnumber) {
+		$start_callnumber=~s/\*/\%/g;
+		$start_callnumber=~s/\?/\_/g;
+		$end_callnumber=~s/\*/\%/g;
+		$end_callnumber=~s/\?/\_/g;
+		if ($strsth=~/,items/){
+			$strsth.=" and items.itemcallnumber between \'$start_callnumber\' and \'$end_callnumber\'";
+		} else {
+			if ($strsth=~/ where/){
+				$strsth=~s/ where (.*)/,items where items.biblionumber=marc_biblio.biblionumber and items.itemcallnumber between \'$start_callnumber\' and \'$end_callnumber\' and $1/;
+			}else {
+				$strsth=~",items where items.biblionumber=marc_biblio.biblionumber and items.itemcallnumber between \'$start_callnumber\' and \'$end_callnumber\' ";
+			}
+		}
 	}
-	while (my ($bibid) = $sth->fetchrow) {
+	$strsth.=" order by marc_biblio.biblionumber ";
+	$strsth.= "LIMIT 0,$limit " if ($limit);
+	warn "requête marc.pl : ".$strsth;
+	my $req=$dbh->prepare($strsth);
+	$req->execute;
+	while (my ($bibid) = $req->fetchrow) {
 		my $record = MARCgetbiblio($dbh,$bibid);
 
 		print $record->as_usmarc();
 	}
 } else {
+	my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
+	$sth->execute;
+	my  @itemtype;
+	my %itemtypes;
+	push @itemtype, "";
+	$itemtypes{''} = "";
+	while (my ($value,$lib) = $sth->fetchrow_array) {
+			push @itemtype, $value;
+			$itemtypes{$value}=$lib;
+	}
+	
+	my $CGIitemtype=CGI::scrolling_list( -name     => 'format',
+							-values   => \@itemtype,
+							-default  => '',
+							-labels   => \%itemtypes,
+							-size     => 1,
+							-multiple => 0 );
+	$sth->finish;
+	
+	my $branches = getallbranches;
+	my @branchloop;
+	foreach my $thisbranch (keys %$branches) {
+# 			my $selected = 1 if $thisbranch eq $branch;
+			my %row =(value => $thisbranch,
+# 									selected => $selected,
+									branchname => $branches->{$thisbranch}->{'branchname'},
+							);
+			push @branchloop, \%row;
+	}
+	
 	my ($template, $loggedinuser, $cookie)
 	= get_template_and_user({template_name => "export/marc.tmpl",
 					query => $query,
@@ -39,6 +103,7 @@
 					flagsrequired => {parameters => 1, management => 1, tools => 1},
 					debug => 1,
 					});
+	$template->param(branchloop=>\@branchloop,CGIitemtype=>$CGIitemtype);
 	output_html_with_http_headers $query, $cookie, $template->output;
 }
 
Index: koha/koha-tmpl/intranet-tmpl/default/en/export/marc.tmpl
diff -u koha/koha-tmpl/intranet-tmpl/default/en/export/marc.tmpl:1.6.4.1 koha/koha-tmpl/intranet-tmpl/default/en/export/marc.tmpl:1.6.4.2
--- koha/koha-tmpl/intranet-tmpl/default/en/export/marc.tmpl:1.6.4.1	Thu Feb 17 12:48:31 2005
+++ koha/koha-tmpl/intranet-tmpl/default/en/export/marc.tmpl	Fri Dec 16 13:04:03 2005
@@ -7,9 +7,20 @@
 		<form method="post">
 			<p>from biblio number : <input type="text" name="start_bib">
 			to biblio number : <input type="text" name="end_bib"></p>
-			<input type="hidden" name="op" value="export">
-			<p>(leave blank to export every biblio)</p>
+			<p>Document type : <!--TMPL_VAR Name="CGIitemtype"--></p>
+			<p>Branch :  <select name="branch">
+			<option value="">Default</option>
+                        <!-- TMPL_LOOP name="branchloop" -->
+                                <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name
+="branchname" --></option>
+                        <!-- /TMPL_LOOP -->
+                        </select>
+</p>
+			<p>from itemcallnumber : <input type="text" name="start_callnumber">
+			to itemcallnumber : <input type="text" name="end_callnumber"></p>
+			<p>Limit to <input type="text" name="limit"> first biblio</p>
 			<p>Note : the items are NOT exported by this tool</p>
+			<input type="hidden" name="op" value="export">
 			<input type="submit" value="Export" class="button">
 		</form>
 	</div>





More information about the Koha-cvs mailing list