View | Details | Raw Unified | Return to bug 9809
Collapse All | Expand All

(-)a/C4/Reserves.pm (-94 / +1 lines)
Lines 239-259 sub AddReserve { Link Here
239
            );
239
            );
240
        }
240
        }
241
    }
241
    }
242
243
    #}
244
    ($const eq "o" || $const eq "e") or return;   # FIXME: why not have a useful return value?
245
    $query = qq{
246
        INSERT INTO reserveconstraints
247
            (borrowernumber,biblionumber,reservedate,biblioitemnumber)
248
        VALUES
249
            (?,?,?,?)
250
    };
251
    $sth = $dbh->prepare($query);    # keep prepare outside the loop!
252
    foreach (@$bibitems) {
253
        $sth->execute($borrowernumber, $biblionumber, $resdate, $_);
254
    }
255
        
256
    return $reserve_id;
257
}
242
}
258
243
259
=head2 GetReserve
244
=head2 GetReserve
Lines 331-380 sub GetReservesFromBiblionumber { Link Here
331
        push( @params, $itemnumber );
316
        push( @params, $itemnumber );
332
    }
317
    }
333
    $query .= "ORDER BY priority";
318
    $query .= "ORDER BY priority";
334
    my $sth = $dbh->prepare($query);
319
    return $dbh->selectall_arrayref( $query, { Slice => {} }, @params );
335
    $sth->execute( @params );
336
    my @results;
337
    my $i = 0;
338
    while ( my $data = $sth->fetchrow_hashref ) {
339
340
        # FIXME - What is this doing? How do constraints work?
341
        if ($data->{constrainttype} eq 'o') {
342
            $query = '
343
                SELECT biblioitemnumber
344
                FROM  reserveconstraints
345
                WHERE  biblionumber   = ?
346
                AND   borrowernumber = ?
347
                AND   reservedate    = ?
348
            ';
349
            my $csth = $dbh->prepare($query);
350
            $csth->execute($data->{biblionumber}, $data->{borrowernumber}, $data->{reservedate});
351
            my @bibitemno;
352
            while ( my $bibitemnos = $csth->fetchrow_array ) {
353
                push( @bibitemno, $bibitemnos );    # FIXME: inefficient: use fetchall_arrayref
354
            }
355
            my $count = scalar @bibitemno;
356
357
            # if we have two or more different specific itemtypes
358
            # reserved by same person on same day
359
            my $bdata;
360
            if ( $count > 1 ) {
361
                $bdata = GetBiblioItemData( $bibitemno[$i] );   # FIXME: This doesn't make sense.
362
                $i++; #  $i can increase each pass, but the next @bibitemno might be smaller?
363
            }
364
            else {
365
                # Look up the book we just found.
366
                $bdata = GetBiblioItemData( $bibitemno[0] );
367
            }
368
            # Add the results of this latest search to the current
369
            # results.
370
            # FIXME - An 'each' would probably be more efficient.
371
            foreach my $key ( keys %$bdata ) {
372
                $data->{$key} = $bdata->{$key};
373
            }
374
        }
375
        push @results, $data;
376
    }
377
    return \@results;
378
}
320
}
379
321
380
=head2 GetReservesFromItemnumber
322
=head2 GetReservesFromItemnumber
Lines 1970-2010 sub _Findgroupreserve { Link Here
1970
        push( @results, $data )
1912
        push( @results, $data )
1971
          unless any{ $data->{borrowernumber} eq $_ } @$ignore_borrowers ;
1913
          unless any{ $data->{borrowernumber} eq $_ } @$ignore_borrowers ;
1972
    }
1914
    }
1973
    return @results if @results;
1974
1975
    my $query = qq{
1976
        SELECT reserves.biblionumber               AS biblionumber,
1977
               reserves.borrowernumber             AS borrowernumber,
1978
               reserves.reservedate                AS reservedate,
1979
               reserves.waitingdate                AS waitingdate,
1980
               reserves.branchcode                 AS branchcode,
1981
               reserves.cancellationdate           AS cancellationdate,
1982
               reserves.found                      AS found,
1983
               reserves.reservenotes               AS reservenotes,
1984
               reserves.priority                   AS priority,
1985
               reserves.timestamp                  AS timestamp,
1986
               reserveconstraints.biblioitemnumber AS biblioitemnumber,
1987
               reserves.itemnumber                 AS itemnumber,
1988
               reserves.reserve_id                 AS reserve_id
1989
        FROM reserves
1990
          LEFT JOIN reserveconstraints ON reserves.biblionumber = reserveconstraints.biblionumber
1991
        WHERE reserves.biblionumber = ?
1992
          AND ( ( reserveconstraints.biblioitemnumber = ?
1993
          AND reserves.borrowernumber = reserveconstraints.borrowernumber
1994
          AND reserves.reservedate    = reserveconstraints.reservedate )
1995
          OR  reserves.constrainttype='a' )
1996
          AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?)
1997
          AND reserves.reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY)
1998
          AND suspend = 0
1999
          ORDER BY priority
2000
    };
2001
    $sth = $dbh->prepare($query);
2002
    $sth->execute( $biblio, $bibitem, $itemnumber, $lookahead||0);
2003
    @results = ();
2004
    while ( my $data = $sth->fetchrow_hashref ) {
2005
        push( @results, $data )
2006
          unless any{ $data->{borrowernumber} eq $_ } @$ignore_borrowers ;
2007
    }
2008
    return @results;
1915
    return @results;
2009
}
1916
}
2010
1917
(-)a/installer/data/mysql/atomicupdate/bug_9809-drop_table_reserveconstraints.sql (+1 lines)
Line 0 Link Here
1
DROP TABLE IF EXISTS reserveconstraints;
(-)a/installer/data/mysql/kohastructure.sql (-13 lines)
Lines 1829-1847 CREATE TABLE reports_dictionary ( -- definitions (or snippets of SQL) stored for Link Here
1829
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1829
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1830
1830
1831
--
1831
--
1832
-- Table structure for table `reserveconstraints`
1833
--
1834
1835
DROP TABLE IF EXISTS `reserveconstraints`;
1836
CREATE TABLE `reserveconstraints` (
1837
  `borrowernumber` int(11) NOT NULL default 0,
1838
  `reservedate` date default NULL,
1839
  `biblionumber` int(11) NOT NULL default 0,
1840
  `biblioitemnumber` int(11) default NULL,
1841
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
1842
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1843
1844
--
1845
-- Table structure for table `reserves`
1832
-- Table structure for table `reserves`
1846
--
1833
--
1847
1834
(-)a/reserve/placerequest.pl (-11 lines)
Lines 38-48 my $input = CGI->new(); Link Here
38
checkauth($input, 0, { reserveforothers => 'place_holds' }, 'intranet');
38
checkauth($input, 0, { reserveforothers => 'place_holds' }, 'intranet');
39
39
40
my @bibitems=$input->param('biblioitem');
40
my @bibitems=$input->param('biblioitem');
41
# FIXME I think reqbib does not exist anymore, it's used in line 82, to AddReserve of contraint type 'o'
42
#       I bet it's a 2.x feature, reserving a given biblioitem, that is useless in Koha 3.0
43
#       we can remove this line, the AddReserve of constrainttype 'o',
44
#       and probably remove the reserveconstraint table as well, I never could fill anything in this table.
45
my @reqbib=$input->param('reqbib'); 
46
my $biblionumber=$input->param('biblionumber');
41
my $biblionumber=$input->param('biblionumber');
47
my $borrowernumber=$input->param('borrowernumber');
42
my $borrowernumber=$input->param('borrowernumber');
48
my $notes=$input->param('notes');
43
my $notes=$input->param('notes');
Lines 115-126 if ($type eq 'str8' && $borrower){ Link Here
115
            if ($input->param('request') eq 'any'){
110
            if ($input->param('request') eq 'any'){
116
                # place a request on 1st available
111
                # place a request on 1st available
117
                AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem,$found);
112
                AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem,$found);
118
            } elsif ($reqbib[0] ne ''){
119
                # FIXME : elsif probably never reached, (see top of the script)
120
                # place a request on a given item
121
                AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'o',\@reqbib,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem, $found);
122
            } else {
123
                AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem, $found);
124
            }
113
            }
125
        }
114
        }
126
    }
115
    }
(-)a/serials/routing-preview.pl (-3 / +1 lines)
Lines 79-85 if($ok){ Link Here
79
				$count--;
79
				$count--;
80
			}
80
			}
81
		}
81
		}
82
		my $const = 'o';
83
		my $notes;
82
		my $notes;
84
		my $title = $subs->{'bibliotitle'};
83
		my $title = $subs->{'bibliotitle'};
85
        for my $routing ( @routinglist ) {
84
        for my $routing ( @routinglist ) {
Lines 95-101 if($ok){ Link Here
95
                    branchcode     => $branch
94
                    branchcode     => $branch
96
                });
95
                });
97
            } else {
96
            } else {
98
                AddReserve($branch,$routing->{borrowernumber},$biblio,$const,\@bibitems,$routing->{ranking}, undef, undef, $notes,$title);
97
                AddReserve($branch,$routing->{borrowernumber},$biblio,undef,\@bibitems,$routing->{ranking}, undef, undef, $notes,$title);
99
        }
98
        }
100
    }
99
    }
101
	}
100
	}
102
- 

Return to bug 9809