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

(-)a/C4/Reserves.pm (-56 / +2 lines)
Lines 242-258 sub AddReserve { Link Here
242
242
243
    #}
243
    #}
244
    ($const eq "o" || $const eq "e") or return;   # FIXME: why not have a useful return value?
244
    ($const eq "o" || $const eq "e") or return;   # FIXME: why not have a useful return value?
245
    $query = qq{
245
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;
246
    return $reserve_id;
257
}
247
}
258
248
Lines 334-377 sub GetReservesFromBiblionumber { Link Here
334
    my $sth = $dbh->prepare($query);
324
    my $sth = $dbh->prepare($query);
335
    $sth->execute( @params );
325
    $sth->execute( @params );
336
    my @results;
326
    my @results;
337
    my $i = 0;
338
    while ( my $data = $sth->fetchrow_hashref ) {
327
    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;
328
        push @results, $data;
376
    }
329
    }
377
    return \@results;
330
    return \@results;
Lines 1999-2021 sub _Findgroupreserve { Link Here
1999
               reserves.reservenotes               AS reservenotes,
1952
               reserves.reservenotes               AS reservenotes,
2000
               reserves.priority                   AS priority,
1953
               reserves.priority                   AS priority,
2001
               reserves.timestamp                  AS timestamp,
1954
               reserves.timestamp                  AS timestamp,
2002
               reserveconstraints.biblioitemnumber AS biblioitemnumber,
2003
               reserves.itemnumber                 AS itemnumber,
1955
               reserves.itemnumber                 AS itemnumber,
2004
               reserves.reserve_id                 AS reserve_id
1956
               reserves.reserve_id                 AS reserve_id
2005
        FROM reserves
1957
        FROM reserves
2006
          LEFT JOIN reserveconstraints ON reserves.biblionumber = reserveconstraints.biblionumber
2007
        WHERE reserves.biblionumber = ?
1958
        WHERE reserves.biblionumber = ?
2008
          AND ( ( reserveconstraints.biblioitemnumber = ?
2009
          AND reserves.borrowernumber = reserveconstraints.borrowernumber
2010
          AND reserves.reservedate    = reserveconstraints.reservedate )
2011
          OR  reserves.constrainttype='a' )
2012
          AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?)
1959
          AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?)
2013
          AND reserves.reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY)
1960
          AND reserves.reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY)
2014
          AND suspend = 0
1961
          AND suspend = 0
2015
          ORDER BY priority
1962
          ORDER BY priority
2016
    };
1963
    };
2017
    $sth = $dbh->prepare($query);
1964
    $sth = $dbh->prepare($query);
2018
    $sth->execute( $biblio, $bibitem, $itemnumber, $lookahead||0);
1965
    $sth->execute( $biblio, $itemnumber, $lookahead||0);
2019
    @results = ();
1966
    @results = ();
2020
    while ( my $data = $sth->fetchrow_hashref ) {
1967
    while ( my $data = $sth->fetchrow_hashref ) {
2021
        push( @results, $data )
1968
        push( @results, $data )
2022
- 

Return to bug 9809