[Koha-cvs] CVS: koha/acqui suggestion-select.pl,NONE,1.1 addorder.pl,1.19,1.20 basket.pl,1.18,1.19 newbiblio.pl,1.18,1.19 order.pl,1.11,1.12

Paul POULAIN tipaul at users.sourceforge.net
Thu Jul 15 11:41:06 CEST 2004


Update of /cvsroot/koha/koha/acqui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29334/acqui

Modified Files:
	addorder.pl basket.pl newbiblio.pl order.pl 
Added Files:
	suggestion-select.pl 
Log Message:
Acquisition & Suggestion :
* acquisition rewritte : create a aqbasket table to deal with "bookseller order header".
* add "close basket" feature : a closed basket can't be modified
* suggestion feature : manage suggestions in acquisition (after suggestion filled in OPAC)

--- NEW FILE ---
#!/usr/bin/perl
use strict;
require Exporter;
use CGI;
use HTML::Template;

use C4::Auth;       # get_template_and_user
use C4::Interface::CGI::Output;
use C4::Suggestions;

my $input = new CGI;

my $basketid = $input->param('basket');
my $supplierid = $input->param('id');

my $title = $input->param('title');
my $author = $input->param('author');
my $note = $input->param('note');
my $copyrightdate =$input->param('copyrightdate');
my $publishercode = $input->param('publishercode');
my $volumedesc = $input->param('volumedesc');
my $publicationyear = $input->param('publicationyear');
my $place = $input->param('place');
my $isbn = $input->param('isbn');
my $status = $input->param('status');
my $suggestedbyme = $input->param('suggestedbyme');
my $op = $input->param('op');
$op = 'else' unless $op;

my $dbh = C4::Context->dbh;
my ($template, $borrowernumber, $cookie)
    = get_template_and_user({template_name => "acqui/suggestion-select.tmpl",
			     type => "intranet",
			     query => $input,
			     authnotrequired => 1,
			     flagsrequired => {borrow => 1},
			 });

my $suggestions_loop= &searchsuggestion($borrowernumber,$author,$title,$publishercode,$status,$suggestedbyme);
$template->param(suggestions_loop => $suggestions_loop,
				title => $title,
				author => $author,
				publishercode => $publishercode,
				status => $status,
				suggestedbyme => $suggestedbyme,
				basket => $basketid,
				supplierid => $supplierid,
				"op_$op" => 1,
);
output_html_with_http_headers $input, $cookie, $template->output;

Index: addorder.pl
===================================================================
RCS file: /cvsroot/koha/koha/acqui/addorder.pl,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** addorder.pl	13 Jul 2004 12:53:00 -0000	1.19
--- addorder.pl	15 Jul 2004 09:41:03 -0000	1.20
***************
*** 27,30 ****
--- 27,31 ----
  use C4::Output;
  use C4::Acquisition;
+ use C4::Suggestions;
  use C4::Biblio;
  use C4::Output;
***************
*** 46,50 ****
  			     });
  
! my $existing=$input->param('existing');
  my $title=$input->param('title');
  my $author=$input->param('author');
--- 47,55 ----
  			     });
  
! # get CGI parameters
! my $ordnum=$input->param('ordnum');
! my $basketno=$input->param('basketno');
! my $booksellerid = $input->param('booksellerid');
! my $existing=$input->param('existing'); # existing biblio, (not basket or order)
  my $title=$input->param('title');
  my $author=$input->param('author');
***************
*** 52,75 ****
  my $isbn=$input->param('ISBN');
  my $itemtype=$input->param('format');
- my $ordnum=$input->param('ordnum');
- my $basketno=$input->param('basket');
  my $quantity=$input->param('quantity');
  my $listprice=$input->param('list_price');
- my $series=$input->param('Series');
  if ($listprice eq ''){
!   $listprice=0;
  }
! my $supplier=$input->param('supplier');
  my $notes=$input->param('notes');
  my $bookfund=$input->param('bookfund');
  my $sort1=$input->param('sort1');
  my $sort2=$input->param('sort2');
- my $who=$loggedinuser;
- my $bibnum;
- my $bibitemnum;
  my $rrp=$input->param('rrp');
  my $ecost=$input->param('ecost');
  my $gst=$input->param('GST');
- my $orderexists=$input->param('orderexists');
  my $budget=$input->param('budget');
  my $cost=$input->param('cost');
--- 57,74 ----
  my $isbn=$input->param('ISBN');
  my $itemtype=$input->param('format');
  my $quantity=$input->param('quantity');
  my $listprice=$input->param('list_price');
  if ($listprice eq ''){
! 	$listprice=0;
  }
! my $series=$input->param('Series');
! # my $supplier=$input->param('supplier');
  my $notes=$input->param('notes');
  my $bookfund=$input->param('bookfund');
  my $sort1=$input->param('sort1');
  my $sort2=$input->param('sort2');
  my $rrp=$input->param('rrp');
  my $ecost=$input->param('ecost');
  my $gst=$input->param('GST');
  my $budget=$input->param('budget');
  my $cost=$input->param('cost');
***************
*** 77,80 ****
--- 76,87 ----
  my $invoice=$input->param('invoice');
  my $publishercode = $input->param('publishercode');
+ my $suggestionid= $input->param('suggestionid');
+ 
+ # create, modify or delete biblio
+ # create if $quantity>=0 and $existing='no'
+ # modify if $quantity>=0 and $existing='yes'
+ # delete if $quantity has been se to 0 by the librarian
+ my $bibnum;
+ my $bibitemnum;
  if ($quantity ne '0'){
  	#check to see if biblio exists
***************
*** 94,113 ****
  				newsubtitle($bibnum,$title);
  			}
  	} else {
  		$bibnum=$input->param('biblio');
  		$bibitemnum=$input->param('bibitemnum');
  		my $oldtype=$input->param('oldtype');
! 		if ($bibitemnum eq '' || $itemtype ne $oldtype){
! 			$bibitemnum= &newbiblioitem({ biblionumber => $bibnum,
! 									itemtype => $itemtype?$itemtype:"",
! 									isbn => $isbn?$isbn:"" ,
! 									publishercode => $publishercode?$publishercode:"",
! 									});
! 		} else {
! 			&modbibitem({biblioitemnumber => $bibitemnum,
! 							isbn            => $isbn,
! 							publishercode   => $publishercode,
! 			});
! 		}
  		&modbiblio({
  			biblionumber  => $bibnum,
--- 101,116 ----
  				newsubtitle($bibnum,$title);
  			}
+ 		# change suggestion status if applicable
+ 		if ($suggestionid) {
+ 			changestatus($suggestionid,'ORDERED');
+ 		}
  	} else {
  		$bibnum=$input->param('biblio');
  		$bibitemnum=$input->param('bibitemnum');
  		my $oldtype=$input->param('oldtype');
! 		&modbibitem({biblioitemnumber => $bibitemnum,
! 						isbn            => $isbn,
! 						publishercode   => $publishercode,
! 		});
  		&modbiblio({
  			biblionumber  => $bibnum,
***************
*** 118,125 ****
  			);
  	}
! 	if ($orderexists ne '') {
! 		modorder($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$sub,$invoice,$sort1,$sort2);
  	}else {
! 		neworder($bibnum,$title,$ordnum,$basketno,$quantity,$listprice,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$sub,$invoice,$sort1,$sort2);
  	}
  } else {
--- 121,128 ----
  			);
  	}
! 	if ($ordnum) {
! 		modorder($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$booksellerid,$loggedinuser,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$sub,$invoice,$sort1,$sort2);
  	}else {
! 		$basketno=neworder($basketno,$bibnum,$title,$quantity,$listprice,$booksellerid,$loggedinuser,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$sub,$invoice,$sort1,$sort2);
  	}
  } else {
***************
*** 127,130 ****
  	delorder($bibnum,$ordnum);
  }
- 
  print $input->redirect("basket.pl?basket=$basketno");
--- 130,132 ----

Index: basket.pl
===================================================================
RCS file: /cvsroot/koha/koha/acqui/basket.pl,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** basket.pl	13 Jul 2004 12:53:00 -0000	1.18
--- basket.pl	15 Jul 2004 09:41:03 -0000	1.19
***************
*** 24,30 ****
  # Suite 330, Boston, MA  02111-1307 USA
  
  use C4::Auth;
! use C4::Catalogue;
! use C4::Biblio;
  use C4::Output;
  use CGI;
--- 24,31 ----
  # Suite 330, Boston, MA  02111-1307 USA
  
+ use strict;
  use C4::Auth;
! use C4::Koha;
! # use C4::Biblio;
  use C4::Output;
  use CGI;
***************
*** 32,40 ****
  use C4::Database;
  use HTML::Template;
  use C4::Date;
- use strict;
  
  my $query =new CGI;
! my $basket=$query ->param('basket');
  my ($template, $loggedinuser, $cookie)
      = get_template_and_user({template_name => "acqui/basket.tmpl",
--- 33,42 ----
  use C4::Database;
  use HTML::Template;
+ use C4::Acquisition;
  use C4::Date;
  
  my $query =new CGI;
! my $basketno = $query ->param('basket');
! my $supplierid = $query->param('id');
  my ($template, $loggedinuser, $cookie)
      = get_template_and_user({template_name => "acqui/basket.tmpl",
***************
*** 46,58 ****
  			     });
  my ($count, at results);
- if ($basket eq ''){
- 	$basket=newbasket();
- 	$results[0]->{'booksellerid'}=$query->param('id');
- 	$results[0]->{'authorisedby'} = $loggedinuser;
- } else {
- 	($count, at results)=basket($basket);
- }
  
! my ($count2, at booksellers)=bookseller($results[0]->{'booksellerid'});
  
  my $line_total; # total of each line
--- 48,59 ----
  			     });
  my ($count, at results);
  
! my ($count2, at booksellers)=bookseller($supplierid);
! 
! my $basket = getbasket($basketno);
! # if new basket, pre-fill infos
! $basket->{creationdate} = "" unless ($basket->{creationdate});
! $basket->{authorisedby} = $loggedinuser unless ($basket->{authorisedby});
! ($count, at results)=getbasketcontent($basketno);
  
  my $line_total; # total of each line
***************
*** 81,85 ****
  	$line{isbn} = $results[$i]->{'isbn'};
  	$line{booksellerid} = $results[$i]->{'booksellerid'};
! 	$line{basket}=$basket;
  	$line{title} = $results[$i]->{'title'};
  	$line{author} = $results[$i]->{'author'};
--- 82,86 ----
  	$line{isbn} = $results[$i]->{'isbn'};
  	$line{booksellerid} = $results[$i]->{'booksellerid'};
! 	$line{basketno}=$basketno;
  	$line{title} = $results[$i]->{'title'};
  	$line{author} = $results[$i]->{'author'};
***************
*** 97,105 ****
  $grand_total=$sub_total+$gist;
  
! $template->param(basket => $basket,
! 				authorisedby => $results[0]->{'authorisedby'},
! 				entrydate => format_date($results[0]->{'entrydate'}),
! 				id=> $results[0]->{'booksellerid'},
  				name => $booksellers[0]->{'name'},
  				books_loop => \@books_loop,
  				count =>$count,
--- 98,108 ----
  $grand_total=$sub_total+$gist;
  
! $template->param(basketno => $basketno,
! 				creationdate => $basket->{creationdate},
! 				authorisedby => $basket->{authorisedby},
! 				authorisedbyname => $basket->{authorisedbyname},
! 				booksellerid=> $booksellers[0]->{'id'},
  				name => $booksellers[0]->{'name'},
+ 				entrydate => format_date($results[0]->{'entrydate'}),
  				books_loop => \@books_loop,
  				count =>$count,

Index: newbiblio.pl
===================================================================
RCS file: /cvsroot/koha/koha/acqui/newbiblio.pl,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** newbiblio.pl	13 Jul 2004 12:53:00 -0000	1.18
--- newbiblio.pl	15 Jul 2004 09:41:03 -0000	1.19
***************
*** 25,54 ****
  use CGI;
  use C4::Context;
  use C4::Acquisition;
  use C4::Search;
- use C4::Auth;
  use C4::Output;
  use C4::Interface::CGI::Output;
- use C4::Database;
  use HTML::Template;
  
  my $input=new CGI;
! my $id=$input->param('id');
  my $title=$input->param('title');
  my $author=$input->param('author');
  my $copyright=$input->param('copyright');
! my ($count, at booksellers)=bookseller($id);
  my $ordnum=$input->param('ordnum');
  my $biblio=$input->param('biblio');
! my $basket=$input->param('basket');
  my $data;
  my $new;
  my $dbh = C4::Context->dbh;
! if ($ordnum eq ''){
  	$new='yes';
! 	$ordnum=newordernum;
  	if ($biblio) {
  			$data=bibdata($biblio);
  	}
  	if ($data->{'title'} eq ''){
  		$data->{'title'}=$title;
--- 25,59 ----
  use CGI;
  use C4::Context;
+ use C4::Database;
+ use C4::Auth;
  use C4::Acquisition;
+ use C4::Suggestions;
  use C4::Search;
  use C4::Output;
  use C4::Interface::CGI::Output;
  use HTML::Template;
  
  my $input=new CGI;
! my $booksellerid=$input->param('booksellerid');
  my $title=$input->param('title');
  my $author=$input->param('author');
  my $copyright=$input->param('copyright');
! my ($count, at booksellers)=bookseller($booksellerid);
  my $ordnum=$input->param('ordnum');
  my $biblio=$input->param('biblio');
! my $basketno=$input->param('basketno');
! my $suggestionid = $input->param('suggestionid');
  my $data;
  my $new;
  my $dbh = C4::Context->dbh;
! if ($ordnum eq ''){ # create order
  	$new='yes';
! # 	$ordnum=newordernum;
  	if ($biblio) {
  			$data=bibdata($biblio);
  	}
+ 	if ($suggestionid) { # get suggestion fields if applicable.
+ 		$data = getsuggestion($suggestionid);
+ 	}
  	if ($data->{'title'} eq ''){
  		$data->{'title'}=$title;
***************
*** 56,60 ****
  		$data->{'copyrightdate'}=$copyright;
  	}
! }else {
  	$data=getsingleorder($ordnum);
  	$biblio=$data->{'biblionumber'};
--- 61,65 ----
  		$data->{'copyrightdate'}=$copyright;
  	}
! }else { #modify order
  	$data=getsingleorder($ordnum);
  	$biblio=$data->{'biblionumber'};
***************
*** 69,73 ****
  			     });
  
! #my ($count2,$currencies)=getcurrencies;
  my ($count,$rates)=getcurrencies();
  my @loop_currency = ();
--- 74,79 ----
  			     });
  
! 
! # get currencies (for change rates calcs if needed
  my ($count,$rates)=getcurrencies();
  my @loop_currency = ();
***************
*** 79,93 ****
  }
  
  my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
  $sth->execute;
  my  @itemtype;
  my %itemtypes;
- push @itemtype, "";
- $itemtypes{''} = "Please choose";
  while (my ($value,$lib) = $sth->fetchrow_array) {
  	push @itemtype, $value;
  	$itemtypes{$value}=$lib;
  }
- 
  my $CGIitemtype=CGI::scrolling_list( -name     => 'format',
  			-values   => \@itemtype,
--- 85,97 ----
  }
  
+ # build itemtype list
  my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
  $sth->execute;
  my  @itemtype;
  my %itemtypes;
  while (my ($value,$lib) = $sth->fetchrow_array) {
  	push @itemtype, $value;
  	$itemtypes{$value}=$lib;
  }
  my $CGIitemtype=CGI::scrolling_list( -name     => 'format',
  			-values   => \@itemtype,
***************
*** 98,101 ****
--- 102,106 ----
  $sth->finish;
  
+ # build branches list
  my @branches;
  my @select_branch;
***************
*** 113,128 ****
  			-multiple => 0 );
  
! my $auto_barcode = C4::Context->boolean_preference("autoBarcode") || 0;
! 	# See whether barcodes should be automatically allocated.
! 	# Defaults to 0, meaning "no".
! my $barcode;
! if ($auto_barcode eq '1') {
! 	$sth=$dbh->prepare("Select max(barcode) from items");
! 	$sth->execute;
! 	my $data=$sth->fetchrow_hashref;
! 	$barcode = $data->{'barcode'}+1;
! 	$sth->finish;
! }
! 
  my @bookfund;
  my @select_bookfund;
--- 118,122 ----
  			-multiple => 0 );
  
! # build bookfund list
  my @bookfund;
  my @select_bookfund;
***************
*** 140,148 ****
  			-multiple => 0 );
  
  $template->param( existing => $biblio,
  						title => $title,
  						ordnum => $ordnum,
! 						basket => $basket,
! 						id => $id,
  						biblio => $biblio,
  						biblioitemnumber => $data->{'biblioitemnumber'},
--- 134,144 ----
  			-multiple => 0 );
  
+ # fill template
  $template->param( existing => $biblio,
  						title => $title,
  						ordnum => $ordnum,
! 						basketno => $basketno,
! 						booksellerid => $booksellerid,
! 						suggestionid => $suggestionid,
  						biblio => $biblio,
  						biblioitemnumber => $data->{'biblioitemnumber'},
***************
*** 172,176 ****
  						sort1 => $data->{'sort1'},
  						sort2 => $data->{'sort2'},
- 						barcode => $data->{'barcode'},
  						publishercode => $data->{'publishercode'});
  
--- 168,171 ----

Index: order.pl
===================================================================
RCS file: /cvsroot/koha/koha/acqui/order.pl,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** order.pl	13 Jul 2004 12:53:00 -0000	1.11
--- order.pl	15 Jul 2004 09:41:03 -0000	1.12
***************
*** 48,52 ****
  my ($count, at suppliers)=bookseller($supplier);
  
! my $colour='#EEEEEE';
  my $toggle=0;
  my @loop_suppliers;
--- 48,59 ----
  my ($count, at suppliers)=bookseller($supplier);
  
! # check if we have to "close" a basket before building page
! my $op = $query->param('op');
! my $basket = $query->param('basket');
! if ($op eq 'close') {
! 	closebasket($basket);
! }
! 
! #build reult page
  my $toggle=0;
  my @loop_suppliers;
***************
*** 55,70 ****
  	my %line;
  	if ($toggle==0){
! 		$line{color}='#EEEEEE';
  		$toggle=1;
  	} else {
! 		$line{color}='white';
  		$toggle=0;
  	}
! 	$line{id} =$suppliers[$i]->{'id'};
  	$line{name} = $suppliers[$i]->{'name'};
  	$line{active} = $suppliers[$i]->{'active'};
- 	$line{total} = $orders->[0]->{'count(*)'};
- 	$line{authorisedby} = $orders->[0]->{'authorisedby'};
- 	$line{entrydate} = $orders->[0]->{'entrydate'};
  	my @loop_basket;
  	for (my $i2=0;$i2<$ordcount;$i2++){
--- 62,74 ----
  	my %line;
  	if ($toggle==0){
! 		$line{even}=1;
  		$toggle=1;
  	} else {
! 		$line{even}=0;
  		$toggle=0;
  	}
! 	$line{supplierid} =$suppliers[$i]->{'id'};
  	$line{name} = $suppliers[$i]->{'name'};
  	$line{active} = $suppliers[$i]->{'active'};
  	my @loop_basket;
  	for (my $i2=0;$i2<$ordcount;$i2++){
***************
*** 73,77 ****
  		$inner_line{total} =$orders->[$i2]->{'count(*)'};
  		$inner_line{authorisedby} = $orders->[$i2]->{'authorisedby'};
! 		$inner_line{entrydate} = format_date($orders->[$i2]->{'entrydate'});
  		push @loop_basket, \%inner_line;
  	}
--- 77,82 ----
  		$inner_line{total} =$orders->[$i2]->{'count(*)'};
  		$inner_line{authorisedby} = $orders->[$i2]->{'authorisedby'};
! 		$inner_line{creationdate} = format_date($orders->[$i2]->{'creationdate'});
! 		$inner_line{closedate} = format_date($orders->[$i2]->{'closedate'});
  		push @loop_basket, \%inner_line;
  	}





More information about the Koha-cvs mailing list