From 96cc502af2f6cb78db0dbbe5e14ea72d4e651c60 Mon Sep 17 00:00:00 2001 From: doxulting Date: Fri, 30 Jul 2004 14:12:07 +0000 Subject: [PATCH] perl files of the serial modul --- bull/receipt.pl | 133 ++++++++++++ bull/statecollection.pl | 124 +++++++++++ bull/subscription-add-help.pl | 20 ++ bull/subscription-add.pl | 82 ++++++++ bull/subscription-bib-search.pl | 357 ++++++++++++++++++++++++++++++++ bull/subscription-detail.pl | 181 ++++++++++++++++ bull/subscription-watch.pl | 20 ++ bull/subscription.pl | 20 ++ 8 files changed, 937 insertions(+) create mode 100755 bull/receipt.pl create mode 100755 bull/statecollection.pl create mode 100755 bull/subscription-add-help.pl create mode 100755 bull/subscription-add.pl create mode 100755 bull/subscription-bib-search.pl create mode 100755 bull/subscription-detail.pl create mode 100755 bull/subscription-watch.pl create mode 100755 bull/subscription.pl diff --git a/bull/receipt.pl b/bull/receipt.pl new file mode 100755 index 0000000000..b7a0fd7cee --- /dev/null +++ b/bull/receipt.pl @@ -0,0 +1,133 @@ +#!/usr/bin/perl + +use strict; +use CGI; +use C4::Auth; +use C4::Output; +use C4::Interface::CGI::Output; +use C4::Context; +use HTML::Template; + +my $query = new CGI; + +my $op = $query->param('op'); +my $search = $query->param('titleorissn'); +my $startfrom=$query->param('startfrom'); + +if ($op eq 'search') +{ + my $total; + my $results; + my $dbh = C4::Context->dbh; + my @marclist = $query->param('marclist'); + my @and_or = $query->param('and_or'); + my @excluding = $query->param('excluding'); + my @operator = $query->param('operator'); + my @value = $query->param('value'); + + my $resultsperpage= $query->param('resultsperpage'); + $resultsperpage = 19 if(!defined $resultsperpage); + + + + my $sth = $dbh->prepare("select subscriptionid, perioid from subscription"); + $sth->execute(); + my @finalsolution; + while (my $first_step = $sth->fetchrow_hashref) + { + my $sth2 = $dbh->prepare("select b3.title from biblioitems b2, biblio b3 where b3.biblionumber = ? and b2.biblionumber = b3.biblionumber and (b2.issn = ? or b3.title like ?)"); + $sth2->execute($first_step->{'perioid'},$search, "%$search%"); + my @answear; + @answear = $sth2->fetchrow_array; + $total = scalar @answear; + if ($total >= 1) + { + $first_step->{'serial'} = $answear[0]; + push @finalsolution ,$first_step; + } + } +my ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "bull/receipt-search-result.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + }); + $template->param(subtable => \@finalsolution, total => $total + ,); + + my $displaynext=0; + my $displayprev=$startfrom; + if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){ + $displaynext = 1; + } + + my @field_data = (); + + + for(my $i = 0 ; $i <= $#marclist ; $i++) + { + push @field_data, { term => "marclist", val=>$marclist[$i] }; + push @field_data, { term => "and_or", val=>$and_or[$i] }; + push @field_data, { term => "excluding", val=>$excluding[$i] }; + push @field_data, { term => "operator", val=>$operator[$i] }; + push @field_data, { term => "value", val=>$value[$i] }; + } + + my @numbers = (); + + if ($total>$resultsperpage) + { + for (my $i=1; $i<$total/$resultsperpage+1; $i++) + { + if ($i<16) + { + my $highlight=0; + ($startfrom==($i-1)) && ($highlight=1); + push @numbers, { number => $i, + highlight => $highlight , + searchdata=> \@field_data, + startfrom => ($i-1)}; + } + } + } + + my $from = $startfrom*$resultsperpage+1; + my $to; + + if($total < (($startfrom+1)*$resultsperpage)) + { + $to = $total; + } else { + $to = (($startfrom+1)*$resultsperpage); + } + $results = \@finalsolution; + $template->param(result => $results) if $results; + $template->param( + startfrom=> $startfrom, + displaynext=> $displaynext, + displayprev=> $displayprev, + resultsperpage => $resultsperpage, + startfromnext => $startfrom+1, + startfromprev => $startfrom-1, + searchdata=>\@field_data, + total=>$total, + from=>$from, + to=>$to, + numbers=>\@numbers, + ); +output_html_with_http_headers $query, $cookie, $template->output; + +} +else{ +my ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "bull/receipt.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + }); +output_html_with_http_headers $query, $cookie, $template->output; +} diff --git a/bull/statecollection.pl b/bull/statecollection.pl new file mode 100755 index 0000000000..c10858e696 --- /dev/null +++ b/bull/statecollection.pl @@ -0,0 +1,124 @@ +#!/usr/bin/perl + +use strict; +use CGI; +use C4::Auth; +use C4::Output; +use C4::Interface::CGI::Output; +use C4::Context; +use C4::Bull; +use HTML::Template; + +my $query = new CGI; +my $op = $query->param('op'); +my $dbh = C4::Context->dbh; +my $sid = $query->param('subsid'); +my $ser = $query->param('serial'); +warn "$ser la valeur du nom du formulaire"; +if ($op eq 'modsubscriptionhistory') +{ + my $auser = $query->param('user'); + my $status = $query->param('status'); + my $waited = $query->param('waited'); + my $begin = $query->param('begin'); + my $end = $query->param('end'); + my $arrived = $query->param('arrived'); + my $gapped = $query->param('gapped'); + my $opac = $query->param('opac'); + my $intra = $query->param('intra'); + + my $sth=$dbh->prepare("update subscriptionhistory set startdate=?, enddate=?,missinglist=?, recievedlist=?, opacnote=?, librariannote=? where subscriptionid = ?"); + $sth->execute($begin, $end, $gapped, $arrived, $opac, $intra, $sid); + + if ($status != 1) + { + if ($status == 2) + { + $sth = $dbh->prepare("select recievedlist from subscriptionhistory where subscriptionid = ?"); + $sth->execute($sid); + my $received = $sth->fetchrow; + $sth = $dbh->prepare("select * from subscription where subscriptionid = ? "); + $sth->execute($sid); + my $val = $sth->fetchrow_hashref; + $sth = $dbh->prepare("update serial set serialseq = ? where subscriptionid = ? and status = 1"); + my ($temp, $X, $Y, $Z, $Xpos, $Ypos, $Zpos) = Get_Next_Seq($val->{'numberingmethod'},$val->{'seqnum1'},$val->{'freq1'}, $val->{'step1'}, $val->{'seqtype1'}, $val->{'seqnum2'}, $val->{'freq2'}, $val->{'step2'}, $val->{'seqtype2'}, $val->{'seqnum3'}, $val->{'freq3'}, $val->{'step3'}, $val->{'seqtype3'}, $val->{'pos1'}, $val->{'pos2'}, $val->{'pos3'}); + $sth->execute($temp, $sid); + $sth = $dbh->prepare("update subscription set seqnum1=?, seqnum2=?,seqnum3=?,pos1=?,pos2=?,pos3=? where subscriptionid = ?"); + $sth->execute($X, $Y, $Z, $Xpos, $Ypos, $Zpos, $sid); + $sth = $dbh->prepare("update subscriptionhistory set recievedlist=? where subscriptionid = ?"); + if (length($received) > 2) + { + $sth->execute("$received,$waited", $sid); + } + else + { + $sth->execute($waited, $sid); + } + + } + elsif ($status == 3) + { + $sth = $dbh->prepare("select missinglist from subscriptionhistory where subscriptionid = ?"); + $sth->execute($sid); + my $missing = $sth->fetchrow; + $sth = $dbh->prepare("select * from subscription where subscriptionid = ? "); + $sth->execute($sid); + my $val = $sth->fetchrow_hashref; + $sth = $dbh->prepare("update serial set status = 2 where subscriptionid = ? and status = 1"); + $sth->execute($sid); + $sth = $dbh->prepare("insert into serial (serialseq,subscriptionid,biblionumber,status, planneddate) values (?,?,?,?,?)"); + my ($temp, $X, $Y, $Z, $Xpos, $Ypos, $Zpos) = Get_Next_Seq($val->{'numberingmethod'},$val->{'seqnum1'},$val->{'freq1'}, $val->{'step1'}, $val->{'seqtype1'}, $val->{'seqnum2'}, $val->{'freq2'}, $val->{'step2'}, $val->{'seqtype2'}, $val->{'seqnum3'}, $val->{'freq3'}, $val->{'step3'}, $val->{'seqtype3'}, $val->{'pos1'}, $val->{'pos2'}, $val->{'pos3'}); + $sth->execute($temp, $sid, $val->{'biblionumber'}, 1, 0); + $sth = $dbh->prepare("update subscription set seqnum1=?, seqnum2=?,seqnum3=?,pos1=?,pos2=?,pos3=? where subscriptionid = ?"); + $sth->execute($X, $Y, $Z, $Xpos, $Ypos, $Zpos, $sid); + $sth = $dbh->prepare("update subscriptionhistory set missinglist=? where subscriptionid = ?"); + if (length($missing) > 2) + { + $sth->execute("$missing,$waited", $sid); + } + else + { + $sth->execute($waited, $sid); + } + + } + else + { + warn ("Error vous avez fait None dans le formulaire receipt\n"); + } + } + + $sth->finish; +} +my $sth=$dbh->prepare("select serialseq, status, planneddate from serial where subscriptionid = ? and status = ?"); +$sth->execute($sid, 1); +my $sol = $sth->fetchrow_hashref; +my $sth=$dbh->prepare("select * from subscriptionhistory where subscriptionid = ?"); +$sth->execute($sid); +my $solhistory = $sth->fetchrow_hashref; +my ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "bull/statecollection.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + }); + + my ($user, $cookie, $sessionID, $flags) + = checkauth($query, 0, {catalogue => 1}, "intranet"); + + $template->param( + user => $user, + serial => $ser, + status => $sol->{'status'}, + waited => $sol->{'serialseq'}, + begin => $solhistory->{'startdate'}, + end => $solhistory->{'enddate'}, + arrived => $solhistory->{'recievedlist'}, + gapped => $solhistory->{'missinglist'}, + opac => $solhistory->{'opacnote'}, + intra => $solhistory->{'librariannote'}, + sid => $sid, + ); +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/bull/subscription-add-help.pl b/bull/subscription-add-help.pl new file mode 100755 index 0000000000..33dd67e4f3 --- /dev/null +++ b/bull/subscription-add-help.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl + +use strict; +use CGI; +use C4::Auth; +use C4::Output; +use C4::Interface::CGI::Output; +use C4::Context; +use HTML::Template; + +my $query = new CGI; +my ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "bull/subscription-add-help.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + }); +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/bull/subscription-add.pl b/bull/subscription-add.pl new file mode 100755 index 0000000000..b6d53765b3 --- /dev/null +++ b/bull/subscription-add.pl @@ -0,0 +1,82 @@ +#!/usr/bin/perl + +use strict; +use CGI; +use C4::Auth; +use C4::Output; +use C4::Interface::CGI::Output; +use C4::Context; +use HTML::Template; +use C4::Bull; + +my $query = new CGI; +my $op = $query->param('op'); +my $dbh = C4::Context->dbh; +if ($op eq 'addsubscription') +{ + my $auser = $query->param('user'); + my $supplier = $query->param('supplier'); + my $cost = $query->param('cost'); + my $budget = $query->param('budget'); + my $begin = $query->param('begin'); + my $frequency = $query->param('frequency'); + my $dow = $query->param('arrival'); + my $numberlength = $query->param('numberlength'); + my $weeklength = $query->param('weeklength'); + my $monthlength = $query->param('monthlength'); + my $X = $query->param('X'); + my $Xstate = $query->param('Xstate'); + my $Xfreq = $query->param('Xfreq'); + my $Xstep = $query->param('Xstep'); + my $Y = $query->param('Y'); + my $Ystate = $query->param('Ystate'); + my $Yfreq = $query->param('Yfreq'); + my $Ystep = $query->param('Ystep'); + my $Z = $query->param('Z'); + my $Zstate = $query->param('Zstate'); + my $Zfreq = $query->param('Zfreq'); + my $Zstep = $query->param('Zstep'); + my $sequence = $query->param('sequence'); + my $arrivalplanified = $query->param('arrivalplanified'); + my $status = 1; + my $perioid = $query->param('biblioid'); + my $notes = $query->param('notes'); + + my $sth=$dbh->prepare("insert into subscription (librarian, aqbooksellerid,cost,aqbudgetid,startdate, periodicity,dow,numberlength,weeklength,monthlength,seqnum1,startseqnum1,seqtype1,freq1,step1,seqnum2,startseqnum2,seqtype2,freq2, step2, seqnum3,startseqnum3,seqtype3, freq3, step3,numberingmethod, arrivalplanified, status, perioid, notes, pos1, pos2, pos3) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, 0, 0, 0)"); + $sth->execute($auser,$supplier,$cost,$budget,$begin,$frequency,$dow,$numberlength,$weeklength,$monthlength,$X,$X,$Xstate,$Xfreq, $Xstep,$Y,$Y,$Ystate,$Yfreq, $Ystep,$Z,$Z,$Zstate,$Zfreq, $Zstep, $sequence, $arrivalplanified, $status, $perioid, $notes); + $sth = $dbh->prepare("select subscriptionid from subscription where perioid = ? and numberingmethod = ?"); + $sth->execute($perioid, $sequence); + my $subid = $sth->fetchrow; + + $sth = $dbh->prepare("insert into subscriptionhistory (biblioid, subscriptionid, startdate, enddate, missinglist, recievedlist, opacnote, librariannote) values (?,?,?,?,?,?,?,?)"); + $sth->execute($perioid, $subid, $begin, 0, "", "", 0, $notes); + $sth = $dbh->prepare("insert into serial (biblionumber, subscriptionid, serialseq, status, planneddate) values (?,?,?,?,?)"); + + $sth->execute($perioid, $subid, Initialize_Sequence($sequence, $X, $Xstate, $Xfreq, $Xstep, $Y, $Ystate, $Yfreq, $Ystep, $Z, $Zstate, $Zfreq, $Zstep), $status, C4::Bull::Find_Next_Date()); +# biblionumber, +# subscriptionid, +# startdate, enddate, +# missinglist, +# recievedlist, +# opacnote, +# librariannote + $sth->finish; + + + +} +my ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "bull/subscription-add.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + }); + + my ($user, $cookie, $sessionID, $flags) + = checkauth($query, 0, {catalogue => 1}, "intranet"); + $template->param( + user => $user, + ); +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/bull/subscription-bib-search.pl b/bull/subscription-bib-search.pl new file mode 100755 index 0000000000..6a9cdc80ff --- /dev/null +++ b/bull/subscription-bib-search.pl @@ -0,0 +1,357 @@ +#!/usr/bin/perl +# WARNING: 4-character tab stops here + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use strict; +require Exporter; +use CGI; +use C4::Auth; +use HTML::Template; +use C4::Context; +use C4::Search; +use C4::Auth; +use C4::Output; +use C4::Interface::CGI::Output; +use C4::Biblio; +use C4::SearchMarc; +use C4::Catalogue; +use C4::Koha; # XXX subfield_is_koha_internal_p + +# Creates the list of active tags using the active MARC configuration +sub create_marclist { + my $dbh = C4::Context->dbh; + my $tagslib = &MARCgettagslib($dbh,1); + my @marcarray; + push @marcarray,""; + my $widest_menu_item_width = 0; + for (my $pass = 1; $pass <= 2; $pass += 1) + { + for (my $tabloop = 0; $tabloop<=9;$tabloop++) + { + my $separator_inserted_p = 0; # FIXME... should not use!! + foreach my $tag (sort(keys (%{$tagslib}))) + { + foreach my $subfield (sort(keys %{$tagslib->{$tag}})) + { + next if subfield_is_koha_internal_p($subfield); + next unless ($tagslib->{$tag}->{$subfield}->{tab} eq $tabloop); + my $menu_item = "$tag$subfield - $tagslib->{$tag}->{$subfield}->{lib}"; + if ($pass == 1) + { + $widest_menu_item_width = length $menu_item if($widest_menu_item_width < length $menu_item); + } else { + if (!$separator_inserted_p) + { + my $w = int(($widest_menu_item_width - 3 + 0.5)/2); + my $s = ('-' x ($w * 4/5)); + push @marcarray, "$s $tabloop $s"; + $separator_inserted_p = 1; + } + push @marcarray, $menu_item; + } + } + } + } + } + return \@marcarray; +} + +# Creates a scrolling list with the associated default value. +# Using more than one scrolling list in a CGI assigns the same default value to all the +# scrolling lists on the page !?!? That's why this function was written. +sub create_scrolling_list { + my ($params) = @_; + my $scrollist = sprintf("\n"; + + return $scrollist; +} + +my $query=new CGI; +my $type=$query->param('type'); +my $op = $query->param('op'); +my $dbh = C4::Context->dbh; + +my $startfrom=$query->param('startfrom'); +$startfrom=0 if(!defined $startfrom); +my ($template, $loggedinuser, $cookie); +my $resultsperpage; + +if ($op eq "do_search") { + my @marclist = $query->param('marclist'); + my @and_or = $query->param('and_or'); + my @excluding = $query->param('excluding'); + my @operator = $query->param('operator'); + my @value = $query->param('value'); + + $resultsperpage= $query->param('resultsperpage'); + $resultsperpage = 19 if(!defined $resultsperpage); + my $orderby = $query->param('orderby'); + + # builds tag and subfield arrays + my @tags; + + foreach my $marc (@marclist) { + if ($marc) { + my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,$marc); + if ($tag) { + push @tags,$dbh->quote("$tag$subfield"); + } else { + push @tags, $dbh->quote(substr($marc,0,4)); + } + } else { + push @tags, ""; + } + } + findseealso($dbh,\@tags); + +# my $sth2 = $dbh->prepare("select b3.serial from biblioitems b2, biblio b3 where b3.biblionumber = ? and b2.biblionumber = b3.biblionumber and (b2.issn = ? or b3.serial like ?)"); + + + my ($results,$total) = catalogsearch($dbh, \@tags,\@and_or, + \@excluding, \@operator, \@value, + $startfrom*$resultsperpage, $resultsperpage,$orderby); + + ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "bull/result.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + flagsrequired => {catalogue => 1}, + debug => 1, + }); + + # multi page display gestion + my $displaynext=0; + my $displayprev=$startfrom; + if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){ + $displaynext = 1; + } + + my @field_data = (); + + + for(my $i = 0 ; $i <= $#marclist ; $i++) + { + push @field_data, { term => "marclist", val=>$marclist[$i] }; + push @field_data, { term => "and_or", val=>$and_or[$i] }; + push @field_data, { term => "excluding", val=>$excluding[$i] }; + push @field_data, { term => "operator", val=>$operator[$i] }; + push @field_data, { term => "value", val=>$value[$i] }; + } + + my @numbers = (); + + if ($total>$resultsperpage) + { + for (my $i=1; $i<$total/$resultsperpage+1; $i++) + { + if ($i<16) + { + my $highlight=0; + ($startfrom==($i-1)) && ($highlight=1); + push @numbers, { number => $i, + highlight => $highlight , + searchdata=> \@field_data, + startfrom => ($i-1)}; + } + } + } + + my $from = $startfrom*$resultsperpage+1; + my $to; + + if($total < (($startfrom+1)*$resultsperpage)) + { + $to = $total; + } else { + $to = (($startfrom+1)*$resultsperpage); + } + $template->param(result => $results, + startfrom=> $startfrom, + displaynext=> $displaynext, + displayprev=> $displayprev, + resultsperpage => $resultsperpage, + startfromnext => $startfrom+1, + startfromprev => $startfrom-1, + searchdata=>\@field_data, + total=>$total, + from=>$from, + to=>$to, + numbers=>\@numbers, + ); + +} elsif ($op eq "AddStatement") { + + ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "bull/search.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + }); + + # Gets the entered information + my @marcfields = $query->param('marclist'); + my @and_or = $query->param('and_or'); + my @excluding = $query->param('excluding'); + my @operator = $query->param('operator'); + my @value = $query->param('value'); + + my @statements = (); + + # List of the marc tags to display + my $marcarray = create_marclist(); + + my $nbstatements = $query->param('nbstatements'); + $nbstatements = 1 if(!defined $nbstatements); + + for(my $i = 0 ; $i < $nbstatements ; $i++) + { + my %fields = (); + + # Recreates the old scrolling lists with the previously selected values + my $marclist = create_scrolling_list({name=>"marclist", + values=> $marcarray, + size=> 1, + default=>$marcfields[$i], + onChange => "sql_update()"} + ); + + $fields{'marclist'} = $marclist; + $fields{'first'} = 1 if($i == 0); + + # Restores the and/or parameters (no need to test the 'and' for activation because it's the default value) + $fields{'or'} = 1 if($and_or[$i] eq "or"); + + #Restores the "not" parameters + $fields{'not'} = 1 if($excluding[$i]); + + #Restores the operators (most common operators first); + if($operator[$i] eq "=") { $fields{'eq'} = 1; } + elsif($operator[$i] eq "contains") { $fields{'contains'} = 1; } + elsif($operator[$i] eq "start") { $fields{'start'} = 1; } + elsif($operator[$i] eq ">") { $fields{'gt'} = 1; } #greater than + elsif($operator[$i] eq ">=") { $fields{'ge'} = 1; } #greater or equal + elsif($operator[$i] eq "<") { $fields{'lt'} = 1; } #lower than + elsif($operator[$i] eq "<=") { $fields{'le'} = 1; } #lower or equal + + #Restores the value + $fields{'value'} = $value[$i]; + + push @statements, \%fields; + } + $nbstatements++; + + # The new scrolling list + my $marclist = create_scrolling_list({name=>"marclist", + values=> $marcarray, + size=>1, + onChange => "sql_update()"}); + push @statements, {"marclist" => $marclist }; + + $template->param("statements" => \@statements, + "nbstatements" => $nbstatements); + +} +else { + ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "bull/search.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + }); + #$template->param(loggedinuser => $loggedinuser); + + my $marcarray = create_marclist(); + + my $marclist = CGI::scrolling_list(-name=>"marclist", + -values=> $marcarray, + -size=>1, + -multiple=>0, + -onChange => "sql_update()", + ); + + my @statements = (); + + # Considering initial search with 3 criterias + push @statements, { "marclist" => $marclist, "first" => 1 }; + push @statements, { "marclist" => $marclist, "first" => 0 }; + push @statements, { "marclist" => $marclist, "first" => 0 }; + 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 => 'value', + -values => \@itemtype, + -labels => \%itemtypes, + -size => 1, + -multiple => 0 ); + $sth->finish; + + my @branches; + my @select_branch; + my %select_branches; + my ($count2,@branches)=branches(); + push @select_branch, ""; + $select_branches{''} = ""; + for (my $i=0;$i<$count2;$i++){ + push @select_branch, $branches[$i]->{'branchcode'};# + $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'}; + } + my $CGIbranch=CGI::scrolling_list( -name => 'value', + -values => \@select_branch, + -labels => \%select_branches, + -size => 1, + -multiple => 0 ); + $sth->finish; + + + $template->param("statements" => \@statements, + "nbstatements" => 3, + CGIitemtype => $CGIitemtype, + CGIbranch => $CGIbranch, + ); +} + + +# Print the page +output_html_with_http_headers $query, $cookie, $template->output; + +# Local Variables: +# tab-width: 4 +# End: diff --git a/bull/subscription-detail.pl b/bull/subscription-detail.pl new file mode 100755 index 0000000000..23442221d4 --- /dev/null +++ b/bull/subscription-detail.pl @@ -0,0 +1,181 @@ +#!/usr/bin/perl + +use strict; +use CGI; +use C4::Auth; +use C4::Output; +use C4::Interface::CGI::Output; +use C4::Context; +use HTML::Template; + +my $query = new CGI; +my $op = $query->param('op'); +my $dbh = C4::Context->dbh; +my $sth; +my $id; +my ($template, $loggedinuser, $cookie, $subs); + +if ($op eq 'modsubscription') +{ + + +# if ($op eq 'addsubscription') +# { + my $id = $query->param('suscr'); + my $auser = $query->param('user'); + my $cost = $query->param('cost'); + my $supplier = $query->param('supplier'); + my $budget = $query->param('budget'); #stocker le id pas le number + my $begin = $query->param('begin'); + my $frequency = $query->param('frequency'); + my $dow = $query->param('arrival'); + my $numberlength = $query->param('numberlength'); + my $weeklength = $query->param('weeklength'); + my $monthlength = $query->param('monthlength'); + my $X = $query->param('X'); + my $Xstate = $query->param('Xstate'); + my $Xfreq = $query->param('Xfreq'); + my $Xstep = $query->param('Xstep'); + my $Y = $query->param('Y'); + my $Ystate = $query->param('Ystate'); + my $Yfreq = $query->param('Yfreq'); + my $Ystep = $query->param('Ystep'); + my $Z = $query->param('Z'); + my $Zstate = $query->param('Zstate'); + my $Zfreq = $query->param('Zfreq'); + my $Zstep = $query->param('Zstep'); + my $sequence = $query->param('sequence'); + my $arrivalplanified = $query->param('arrivalplanified'); + my $status = 1; + my $perioid = $query->param('biblioid'); + my $notes = $query->param('notes'); + + + my $sth=$dbh->prepare("update subscription set librarian=?, aqbooksellerid=?,cost=?,aqbudgetid=?,startdate=?, periodicity=?,dow=?,numberlength=?,weeklength=?,monthlength=?,seqnum1=?,startseqnum1=?,seqtype1=?,freq1=?,step1=?,seqnum2=?,startseqnum2=?,seqtype2=?,freq2=?, step2=?, seqnum3=?,startseqnum3=?,seqtype3=?, freq3=?, step3=?,numberingmethod=?, arrivalplanified=?, status=?, perioid=?, notes=? where subscriptionid = ?"); + $sth->execute($auser,$supplier,$cost,$budget,$begin,$frequency,$dow,$numberlength,$weeklength,$monthlength,$X,$X,$Xstate,$Xfreq, $Xstep,$Y,$Y,$Ystate,$Yfreq, $Ystep,$Z,$Z,$Zstate,$Zfreq, $Zstep, $sequence, $arrivalplanified, $status, $perioid, $notes, $id); + $sth->finish; + ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "bull/subscription-detail.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + }); + +# } + my ($user, $cookie, $sessionID, $flags) + = checkauth($query, 0, {catalogue => 1}, "intranet"); + $template->param( + user => $auser, ,librarian => $auser, + aqbooksellerid => $supplier, + cost => $cost, + aqbudgetid => $budget, + startdate => $begin, + frequency => $frequency, + arrival => $dow, + numberlength => $numberlength, + weeklength => $weeklength, + monthlength => $monthlength, + seqnum1 => $X, + startseqnum1 => $X, + seqtype1 => $Xstate, + freq1 => $Xfreq, + step1 => $Xstep, + seqnum2 => $Y, + startseqnum2 => $Y, + seqtype2 => $Ystate, + freq2 => $Yfreq, + step2 => $Ystep, + seqnum3 => $Z, + startseqnum3 => $Z, + seqtype3 => $Zstate, + freq3 => $Zfreq, + step3 => $Zstep, + sequence => $sequence, + arrivalplanified => $arrivalplanified, + status => $status, + biblioid => $perioid, + notes => $notes, + suscr => $id,); + + + $template->param( + "frequency$frequency" => 1, + "Xstate$Xstate" => 1, + "Ystate$Ystate" => 1, + "Zstate$Zstate" => 1, + "arrival$dow" => 1, + ); + + } + else + { + $sth = $dbh->prepare('select * from subscription where subscriptionid = ?'); + $id = $query->param('suscr'); + $sth->execute($id); + $subs = $sth->fetchrow_hashref; + $sth->finish; + +($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "bull/subscription-detail.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + }); + +# } + my ($user, $cookie, $sessionID, $flags) + = checkauth($query, 0, {catalogue => 1}, "intranet"); + $template->param( + user => $user, + ); + $template->param(librarian => $subs->{'librarian'}, + aqbooksellerid => $subs->{'aqbooksellerid'}, + cost => $subs->{'cost'}, + aqbudgetid => $subs->{'aqbudgetid'}, + startdate => $subs->{'startdate'}, + frequency => $subs->{'periodicity'}, + arrival => $subs->{'dow'}, + numberlength => $subs->{'numberlength'}, + weeklength => $subs->{'weeklength'}, + monthlength => $subs->{'monthlength'}, + seqnum1 => $subs->{'seqnum1'}, + startseqnum1 => $subs->{'startseqnum1'}, + seqtype1 => $subs->{'seqtype1'}, + freq1 => $subs->{'freq1'}, + step1 => $subs->{'step1'}, + seqnum2 => $subs->{'seqnum2'}, + startseqnum2 => $subs->{'startseqnum2'}, + seqtype2 => $subs->{'seqtype2'}, + freq2 => $subs->{'freq2'}, + step2 => $subs->{'step2'}, + seqnum3 => $subs->{'seqnum3'}, + startseqnum3 => $subs->{'startseqnum3'}, + seqtype3 => $subs->{'seqtype3'}, + freq3 => $subs->{'freq3'}, + step3 => $subs->{'step3'}, + sequence => $subs->{'numberingmethod'}, + arrivalplanified => $subs->{'arrivalplanified'}, + status => $subs->{'status'}, + biblioid => $subs->{'perioid'}, + notes => $subs->{'notes'}, + suscr => $id, +); + + $template->param( + + "frequency$subs->{'periodicity'}" => 1, + "Xstate$subs->{'seqtype1'}" => 1, + "Ystate$subs->{'seqtype2'}" => 1, + "Zstate$subs->{'seqtype3'}" => 1, + "arrival$subs->{'dow'}" => 1, + ); + +} +# } +# my $sth=$dbh->prepare("insert into subscription (librarian, aqbooksellerid,cost,aqbudgetid,startdate, periodicity,dow,numberlength,weeklength,monthlength,seqnum1,startseqnum1,seqtype1,freq1,step1,seqnum2,startseqnum2,seqtype2,freq2, step2, seqnum3,startseqnum3,seqtype3, freq3, step3,numberingmethod, arrivalplanified, status, perioid, notes) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/bull/subscription-watch.pl b/bull/subscription-watch.pl new file mode 100755 index 0000000000..02e7f341c4 --- /dev/null +++ b/bull/subscription-watch.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl + +use strict; +use CGI; +use C4::Auth; +use C4::Output; +use C4::Interface::CGI::Output; +use C4::Context; +use HTML::Template; + +my $query = new CGI; +my ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "bull/subscription-watch.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + }); +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/bull/subscription.pl b/bull/subscription.pl new file mode 100755 index 0000000000..03c23b9c27 --- /dev/null +++ b/bull/subscription.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl + +use strict; +use CGI; +use C4::Auth; +use C4::Output; +use C4::Interface::CGI::Output; +use C4::Context; +use HTML::Template; + +my $query = new CGI; +my ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "bull/subscription.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + }); +output_html_with_http_headers $query, $cookie, $template->output; -- 2.39.5