From b4ce3dbfb7ead3bcf06d9286bb83fcd7a6e35624 Mon Sep 17 00:00:00 2001 From: toins Date: Tue, 4 Jul 2006 13:35:29 +0000 Subject: [PATCH] Head & rel_2_2 merged --- acqui/acqui-home.pl | 41 +++++++------------ acqui/histsearch.pl | 5 ++- acqui/lateorders.pl | 8 ++++ acqui/receive.pl | 77 +++++++++++++++++++++++++----------- acqui/recieveorder.pl | 80 ++++++++++++++++++++++++++++++++++++++ acqui/select-late.pl | 6 ++- acqui/suggestion-select.pl | 59 ++++++++++++++++++++++++++++ acqui/supplier.pl | 60 ++++++++++++++++++++++++++-- acqui/updatesupplier.pl | 4 +- 9 files changed, 284 insertions(+), 56 deletions(-) diff --git a/acqui/acqui-home.pl b/acqui/acqui-home.pl index 948362b0ea..2820c595d5 100755 --- a/acqui/acqui-home.pl +++ b/acqui/acqui-home.pl @@ -37,33 +37,20 @@ my $totspent = 0; my $totcomtd = 0; my $totavail = 0; my @loop_budget = (); -for ( my $i = 0 ; $i < $count ; $i++ ) { - - if ( $toggle eq 0 ) { - $toggle = 1; - } - else { - $toggle = 0; - } - my ( $spent, $comtd ) = bookfundbreakdown( $results[$i]->{'bookfundid'} ); - - my $avail = $results[$i]->{'budgetamount'} - ( $spent + $comtd ); - my %line; - $line{bookfundname} = $results[$i]->{'bookfundname'}; - $line{budgetamount} = $results[$i]->{'budgetamount'}; - $line{bookfundid} = $results[$i]->{'bookfundid'}; - $line{sdate} = $results[$i]->{'startdate'}; - $line{edate} = $results[$i]->{'enddate'}; - $line{aqbudgetid} = $results[$i]->{'aqbudgetid'}; - $line{spent} = sprintf( "%.2f", $spent ); - $line{comtd} = sprintf( "%.2f", $comtd ); - $line{avail} = sprintf( "%.2f", $avail ); - $line{'toggle'} = $toggle; - push @loop_budget, \%line; - $total += $results[$i]->{'budgetamount'}; - $totspent += $spent; - $totcomtd += $comtd; - $totavail += $avail; +for (my $i=0;$i<$count;$i++){ + my ($spent,$comtd)=bookfundbreakdown($results[$i]->{'bookfundid'}); + my $avail=$results[$i]->{'budgetamount'}-($spent+$comtd); + my %line; + $line{bookfundname} = $results[$i]->{'bookfundname'}; + $line{budgetamount} = $results[$i]->{'budgetamount'}; + $line{spent} = sprintf ("%.2f", $spent); + $line{comtd} = sprintf ("%.2f",$comtd); + $line{avail} = sprintf ("%.2f",$avail); + push @loop_budget, \%line; + $total+=$results[$i]->{'budgetamount'}; + $totspent+=$spent; + $totcomtd+=$comtd; + $totavail+=$avail; } #currencies diff --git a/acqui/histsearch.pl b/acqui/histsearch.pl index 3e7e0a44fc..5bdc8a61d8 100755 --- a/acqui/histsearch.pl +++ b/acqui/histsearch.pl @@ -34,6 +34,9 @@ $template->param(suggestions_loop => $order_loop, author => $author, name => $name, from_placed_on =>$from_placed_on, - to_placed_on =>$to_placed_on + to_placed_on =>$to_placed_on, + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/acqui/lateorders.pl b/acqui/lateorders.pl index 86bd232542..c7b171b0e1 100755 --- a/acqui/lateorders.pl +++ b/acqui/lateorders.pl @@ -40,6 +40,7 @@ my $CGIsupplier=CGI::scrolling_list( -name => 'supplierid', -default => $supplierid, -labels => \%supplierlist, -size => 1, + -tabindex=>'', -multiple => 0 ); $template->param(Supplier=>$supplierlist{$supplierid}) if ($supplierid); @@ -52,6 +53,12 @@ foreach my $thisbranch (sort keys %$branches) { ); push @branchloop, \%row; } +my $CGIbranch=CGI::scrolling_list( -name => 'branch', + -values => \@select_branches, + -labels => \%select_branches, + -size => 1, + -tabindex=>'', + -multiple => 0 ); my ($count, @lateorders) = getlateorders($delay,$supplierid,$branch); my $total; @@ -64,5 +71,6 @@ $template->param( CGIsupplier => $CGIsupplier, lateorders => \@lateorders, total=>$total, + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), ); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/acqui/receive.pl b/acqui/receive.pl index 0f09e30527..6f68c464ac 100755 --- a/acqui/receive.pl +++ b/acqui/receive.pl @@ -36,10 +36,11 @@ use strict; my $input=new CGI; my $supplierid=$input->param('supplierid'); my ($count,@booksellers)=bookseller($supplierid); -my $invoice=$input->param('invoice'); +my $invoice=$input->param('code') || ''; my $freight=$input->param('freight'); my $gst=$input->param('gst'); -my $date=localtime(time); +my $date=$input->param('datereceived'); +my $code=$input->param('code'); my ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "acqui/recieve.tmpl", @@ -50,21 +51,48 @@ my ($template, $loggedinuser, $cookie) debug => 1, }); -my @results; -($count,@results)=invoice($invoice); -if ($invoice eq ''){ - ($count,@results)=getallorders($supplierid); -} +my ($countlines,@parcelitems)=getparcelinformation($supplierid,$invoice,$date); my $totalprice=0; my $totalfreight=0; my $totalquantity=0; my $total; my $tototal; my $toggle; +my @loop_received = (); +for (my $i=0;$i<$countlines;$i++){ + $total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'}; #weird, are the freight fees counted by book? (pierre) + $parcelitems[$i]->{'unitprice'}+=0; + my %line; + if ($toggle==0){ + $line{color}='#EEEEEE'; + $toggle=1; + } else { + $line{color}='white'; + $toggle=0; + } + $line{basketno} = $parcelitems[$i]->{'basketno'}; + $line{isbn} = $parcelitems[$i]->{'isbn'}; + $line{ordernumber} = $parcelitems[$i]->{'ordernumber'}; + $line{biblionumber} = $parcelitems[$i]->{'biblionumber'}; + $line{invoice} = $invoice; + $line{gst} = $gst; + $line{title} = $parcelitems[$i]->{'title'}; + $line{author} = $parcelitems[$i]->{'author'}; + $line{unitprice} = $parcelitems[$i]->{'unitprice'}; + $line{ecost} = $parcelitems[$i]->{'ecost'}; + $line{quantityrecieved} = $parcelitems[$i]->{'quantityreceived'}; + $line{quantity} = $parcelitems[$i]->{'quantity'}; + $line{total} = $total; + $line{supplierid} = $supplierid; + push @loop_received, \%line; + $totalprice+=$parcelitems[$i]->{'unitprice'}; + $totalfreight+=$parcelitems[$i]->{'freight'}; + $totalquantity+=$parcelitems[$i]->{'quantityreceived'}; + $tototal+=$total; +} +my ($countpendings,@pendingorders)=getallorders($supplierid); my @loop_orders = (); -for (my$i=0;$i<$count;$i++){ - $total=($results[$i]->{'unitprice'} + $results[$i]->{'freight'}) * $results[$i]->{'quantityreceived'}; #weird, are the freight fees counted by book? (pierre) - $results[$i]->{'unitprice'}+=0; +for (my $i=0;$i<$countpendings;$i++){ my %line; if ($toggle==0){ $line{color}='#EEEEEE'; @@ -73,23 +101,21 @@ for (my$i=0;$i<$count;$i++){ $line{color}='white'; $toggle=0; } - $line{basketno} = $results[$i]->{'basketno'}; - $line{isbn} = $results[$i]->{'isbn'}; - $line{ordernumber} = $results[$i]->{'ordernumber'}; - $line{biblionumber} = $results[$i]->{'biblionumber'}; + $line{basketno} = $pendingorders[$i]->{'basketno'}; + $line{isbn} = $pendingorders[$i]->{'isbn'}; + $line{ordernumber} = $pendingorders[$i]->{'ordernumber'}; + $line{biblionumber} = $pendingorders[$i]->{'biblionumber'}; $line{invoice} = $invoice; $line{gst} = $gst; - $line{title} = ($results[$i]->{'truetitle'}?$results[$i]->{'truetitle'}:$results[$i]->{'suggestedtitle'}); - $line{author} = $results[$i]->{'author'}; - $line{unitprice} = $results[$i]->{'unitprice'}; - $line{quantityrecieved} = $results[$i]->{'quantityreceived'}; + $line{title} = $pendingorders[$i]->{'title'}; + $line{author} = $pendingorders[$i]->{'author'}; + $line{unitprice} = $pendingorders[$i]->{'unitprice'}; + $line{ecost} = $pendingorders[$i]->{'ecost'}; + $line{quantityrecieved} = $pendingorders[$i]->{'quantityreceived'}; + $line{quantity} = $pendingorders[$i]->{'quantity'}; $line{total} = $total; $line{supplierid} = $supplierid; push @loop_orders, \%line; - $totalprice+=$results[$i]->{'unitprice'}; - $totalfreight+=$results[$i]->{'freight'}; - $totalquantity+=$results[$i]->{'quantityreceived'}; - $tototal+=$total; } $totalfreight=$freight; @@ -102,7 +128,9 @@ $template->param(invoice => $invoice, gst => $gst, freight => $freight, invoice => $invoice, - count => $count, + countreceived => $countlines, + loop_received => \@loop_received, + countpending => $countpendings, loop_orders => \@loop_orders, totalprice => $totalprice, totalfreight => $totalfreight, @@ -110,5 +138,8 @@ $template->param(invoice => $invoice, tototal => $tototal, gst => $gst, grandtot => $tototal+$gst, + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/acqui/recieveorder.pl b/acqui/recieveorder.pl index 024c4f8d2f..bec87c2a9c 100755 --- a/acqui/recieveorder.pl +++ b/acqui/recieveorder.pl @@ -28,11 +28,19 @@ use C4::Auth; use C4::Output; use C4::Interface::CGI::Output; use C4::Database; +use C4::Date; use HTML::Template; use C4::Acquisition; my $input=new CGI; my $supplierid=$input->param('supplierid'); +my $order=$input->param('orderby') || "datereceived desc"; +my $startfrom=$input->param('startfrom'); +my $code=$input->param('filter'); +my $datefrom=$input->param('datefrom'); +my $dateto=$input->param('dateto'); +my $resultsperpage = $input->param('resultsperpage'); + my ($count,@booksellers)=bookseller($supplierid); my ($template, $loggedinuser, $cookie) @@ -44,9 +52,81 @@ my ($template, $loggedinuser, $cookie) debug => 1, }); + +$resultsperpage = 20 unless ($resultsperpage); +my ($count,@results)=getparcels($supplierid, $order, $code,$datefrom,$dateto); + +# multi page display gestion +$startfrom=0 unless ($startfrom); +if ($count>$resultsperpage){ + my $displaynext=0; + my $displayprev=$startfrom; + if(($count - ($startfrom+$resultsperpage)) > 0 ) { + $displaynext = 1; + } + + my @numbers = (); + if ($count>$resultsperpage) { + for (my $i=1; $i<$count/$resultsperpage+1; $i++) { + if ($i<16) { + my $highlight=0; + ($startfrom/$resultsperpage==($i-1)) && ($highlight=1); + push @numbers, { number => $i, + highlight => $highlight , +# searchdata=> "test", + startfrom => ($i-1)*$resultsperpage}; + } + } + } + + my $from = $startfrom*$resultsperpage+1; + my $to; + + if($count < (($startfrom+1)*$resultsperpage)) + { + $to = $count; + } else { + $to = (($startfrom+1)*$resultsperpage); + } + $template->param(numbers=>\@numbers, + displaynext=>$displaynext, + displayprev=>$displayprev, + nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count), + prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0) + ); +} +my @loopres; + +my $hilighted=0; +for (my $i=$startfrom;$i<=($startfrom+$resultsperpage-1<$count-1?$startfrom+$resultsperpage-1:$count-1);$i++){ +### startfrom: $startfrom +### resultsperpage: $resultsperpage +### count: $count +### code: $results[$i]->{booksellerinvoicenumber} +### datereceived: $results[$i]->{datereceived} + + my %cell; + $cell{number}=$i+1; + $cell{code}=$results[$i]->{booksellerinvoicenumber}; + $cell{nullcode}=$results[$i]->{booksellerinvoicenumber} eq "NULL"; + $cell{emptycode}=$results[$i]->{booksellerinvoicenumber} eq ''; + $cell{raw_datereceived}=$results[$i]->{datereceived}; + $cell{datereceived}=format_date($results[$i]->{datereceived}); + $cell{bibcount}=$results[$i]->{biblio}; + $cell{reccount}=$results[$i]->{itemsreceived}; + $cell{itemcount}=$results[$i]->{itemsexpected}; + $cell{hilighted} = $hilighted%2; + $hilighted++; + push @loopres, \%cell; +} +$template->param(searchresults=>\@loopres, count=>$count) if ($count); +$template->param(orderby=>$order, filter=>$code, datefrom=>$datefrom,dateto=>$dateto, resultsperpage=>$resultsperpage); $template->param( name => $booksellers[0]->{'name'}, supplierid => $supplierid, + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/acqui/select-late.pl b/acqui/select-late.pl index 1ae760f63c..8839a8c7fb 100755 --- a/acqui/select-late.pl +++ b/acqui/select-late.pl @@ -97,6 +97,10 @@ for (my $i=0; $i<$count; $i++) { } $template->param(loop_suppliers => \@loop_suppliers, supplier => $supplier, - count => $count); + count => $count, + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), + ); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/acqui/suggestion-select.pl b/acqui/suggestion-select.pl index f32cb73f42..14f2c581f0 100755 --- a/acqui/suggestion-select.pl +++ b/acqui/suggestion-select.pl @@ -7,6 +7,8 @@ use HTML::Template; use C4::Auth; # get_template_and_user use C4::Interface::CGI::Output; use C4::Suggestions; +use C4::Biblio; +use C4::SearchMarc; my $input = new CGI; @@ -22,6 +24,9 @@ my $volumedesc = $input->param('volumedesc'); my $publicationyear = $input->param('publicationyear'); my $place = $input->param('place'); my $isbn = $input->param('isbn'); +my $duplicateNumber = $input->param('duplicateNumber'); +my $suggestionid = $input->param('suggestionid'); + my $status = 'ACCEPTED'; my $suggestedbyme = -1; # search ALL suggestors my $op = $input->param('op'); @@ -36,7 +41,58 @@ my ($template, $borrowernumber, $cookie) flagsrequired => {acquisition => 1}, }); +if ($op eq 'connectDuplicate') { + connectSuggestionAndBiblio($suggestionid,$duplicateNumber); +} my $suggestions_loop= &searchsuggestion($borrowernumber,$author,$title,$publishercode,$status,$suggestedbyme); +foreach (@$suggestions_loop) { + unless ($_->{biblionumber}) { + my (@tags, @and_or, @excluding, @operator, @value, $offset,$length); + # search on biblio.title + if ($_->{title}) { + my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblio.title",""); + push @tags, "'".$tag.$subfield."'"; + push @and_or, "and"; + push @excluding, ""; + push @operator, "contains"; + push @value, $_->{title}; + } + if ($_->{author}) { + my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblio.author",""); + push @tags, "'".$tag.$subfield."'"; + push @and_or, "and"; + push @excluding, ""; + push @operator, "contains"; + push @value, $_->{author}; + } + # ... and on publicationyear. + if ($_->{publicationyear}) { + my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblioitems.publicationyear",""); + push @tags, "'".$tag.$subfield."'"; + push @and_or, "and"; + push @excluding, ""; + push @operator, "="; + push @value, $_->{publicationyear}; + } + # ... and on publisher. + if ($_->{publishercode}) { + my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblioitems.publishercode",""); + push @tags, "'".$tag.$subfield."'"; + push @and_or, "and"; + push @excluding, ""; + push @operator, "="; + push @value, $_->{publishercode}; + } + + my ($finalresult,$nbresult) = C4::SearchMarc::catalogsearch($dbh,\@tags,\@and_or,\@excluding,\@operator,\@value,0,10); + # there is at least 1 result => return the 1st one + if ($nbresult) { + # warn "$nbresult => ".@$finalresult[0]->{biblionumber},@$finalresult[0]->{bibid},@$finalresult[0]->{title}; +# warn "DUPLICATE ==>".@$finalresult[0]->{biblionumber},@$finalresult[0]->{bibid},@$finalresult[0]->{title}; + $_->{duplicateBiblionumber} = @$finalresult[0]->{biblionumber}; + } + } +} $template->param(suggestions_loop => $suggestions_loop, title => $title, author => $author, @@ -46,5 +102,8 @@ $template->param(suggestions_loop => $suggestions_loop, basketno => $basketno, supplierid => $supplierid, "op_$op" => 1, + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/acqui/supplier.pl b/acqui/supplier.pl index e7fb9b4068..0d8b16503d 100755 --- a/acqui/supplier.pl +++ b/acqui/supplier.pl @@ -35,6 +35,8 @@ use strict; my $query=new CGI; my $id=$query->param('supplierid'); +my $op=$query->param('op'); + my ($count,@booksellers)=bookseller($id); my ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "acqui/supplier.tmpl", @@ -77,13 +79,65 @@ $template->param(id => $id, contfax => $booksellers[0]->{'contfax'}, contemail => $booksellers[0]->{'contemail'}, contnotes => $booksellers[0]->{'contnotes'}, + notes => $booksellers[0]->{'notes'}, active => $booksellers[0]->{'active'}, specialty => $booksellers[0]->{'specialty'}, gstreg => $booksellers[0]->{'gstreg'}, listincgst => $booksellers[0]->{'listincgst'}, invoiceincgst => $booksellers[0]->{'invoiceincgst'}, discount => $booksellers[0]->{'discount'}, - loop_pricescurrency => \@loop_pricescurrency, - loop_invoicecurrency => \@loop_invoicecurrency,); - + invoiceprice=>$booksellers[0]->{'invoiceprice'}, + listprice=>$booksellers[0]->{'listprice'}, + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), + ); +}else{ + my ($count, $currencies) = &getcurrencies(); + my @loop_pricescurrency; + my @loop_invoicecurrency; + for (my $i=0;$i<$count;$i++) { + if ($booksellers[0]->{'listprice'} eq $currencies->[$i]->{'currency'}) { + push @loop_pricescurrency, { currency => "" }; + } else { + push @loop_pricescurrency, { currency => ""}; + } + if ($booksellers[0]->{'invoiceprice'} eq $currencies->[$i]->{'currency'}) { + push @loop_invoicecurrency, { currency => ""}; + } else { + push @loop_invoicecurrency, { currency => ""}; + } + } + $template->param(id => $id, + name => $booksellers[0]->{'name'}, + postal =>$booksellers[0]->{'postal'}, + address1 => $booksellers[0]->{'address1'}, + address2 => $booksellers[0]->{'address2'}, + address3 => $booksellers[0]->{'address3'}, + address4 => $booksellers[0]->{'address4'}, + phone =>$booksellers[0]->{'phone'}, + fax => $booksellers[0]->{'fax'}, + url => $booksellers[0]->{'url'}, + contact => $booksellers[0]->{'contact'}, + contpos => $booksellers[0]->{'contpos'}, + contphone => $booksellers[0]->{'contphone'}, + contaltphone => $booksellers[0]->{'contaltphone'}, + contfax => $booksellers[0]->{'contfax'}, + contemail => $booksellers[0]->{'contemail'}, + notes => $booksellers[0]->{'notes'}, + contnotes => $booksellers[0]->{'contnotes'}, + active => $booksellers[0]->{'active'}, + specialty => $booksellers[0]->{'specialty'}, + gstreg => $booksellers[0]->{'gstreg'}, + listincgst => $booksellers[0]->{'listincgst'}, + invoiceincgst => $booksellers[0]->{'invoiceincgst'}, + discount => $booksellers[0]->{'discount'}, + loop_pricescurrency => \@loop_pricescurrency, + loop_invoicecurrency => \@loop_invoicecurrency, + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), + enter=>1, + ); +} output_html_with_http_headers $query, $cookie, $template->output; diff --git a/acqui/updatesupplier.pl b/acqui/updatesupplier.pl index 43d3260fb6..26869f5c30 100755 --- a/acqui/updatesupplier.pl +++ b/acqui/updatesupplier.pl @@ -51,7 +51,9 @@ $data{'contphone'}=$input->param('contact_phone'); $data{'contaltphone'}=$input->param('contact_phone_2'); $data{'contfax'}=$input->param('contact_fax'); $data{'contemail'}=$input->param('company_email'); -$data{'contnotes'}=$input->param('notes'); +$data{'contnotes'}=$input->param('contact_notes'); +warn "".$data{'contnotes'}; +$data{'notes'}=$input->param('notes'); $data{'active'}=$input->param('status'); $data{'specialty'}=$input->param('publishers_imprints'); $data{'listprice'}=$input->param('list_currency'); -- 2.39.5