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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 712-718 sub CanBookBeIssued { Link Here
712
    if ( $borrower->{'dateexpiry'} eq '0000-00-00') {
712
    if ( $borrower->{'dateexpiry'} eq '0000-00-00') {
713
        $issuingimpossible{EXPIRED} = 1;
713
        $issuingimpossible{EXPIRED} = 1;
714
    } else {
714
    } else {
715
        my @expirydate=  split /-/,$borrower->{'dateexpiry'};
715
        my @expirydate=  split (/-/,$borrower->{'dateexpiry'});
716
        if($expirydate[0]==0 || $expirydate[1]==0|| $expirydate[2]==0 ||
716
        if($expirydate[0]==0 || $expirydate[1]==0|| $expirydate[2]==0 ||
717
            Date_to_Days(Today) > Date_to_Days( @expirydate )) {
717
            Date_to_Days(Today) > Date_to_Days( @expirydate )) {
718
            $issuingimpossible{EXPIRED} = 1;                                   
718
            $issuingimpossible{EXPIRED} = 1;                                   
(-)a/C4/Reserves.pm (+176 lines)
Lines 112-117 BEGIN { Link Here
112
        &ModReserveCancelAll
112
        &ModReserveCancelAll
113
        &ModReserveMinusPriority
113
        &ModReserveMinusPriority
114
        
114
        
115
        &CanBookBeReserved
116
        &CanItemBeReserved
115
        &CheckReserves
117
        &CheckReserves
116
        &CancelReserve
118
        &CancelReserve
117
119
Lines 326-331 sub GetReservesFromBorrowernumber { Link Here
326
}
328
}
327
#-------------------------------------------------------------------------------------
329
#-------------------------------------------------------------------------------------
328
330
331
=item CanBookBeReserved
332
333
$error = &CanBookBeReserved($borrowernumber, $biblionumber)
334
335
=cut
336
337
sub CanBookBeReserved{
338
    my ($borrowernumber, $biblionumber) = @_;
339
340
    my $dbh           = C4::Context->dbh;
341
    my $biblio        = GetBiblioData($biblionumber);
342
    my $borrower      = C4::Members::GetMember($borrowernumber);
343
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
344
    my $itype         = C4::Context->preference('item-level_itypes');
345
    my $reservesrights= 0;
346
    my $reservescount = 0;
347
    
348
    # we retrieve the user rights
349
    my @args;
350
    my $rightsquery = "SELECT categorycode, itemtype, branchcode, reservesallowed 
351
                       FROM issuingrules 
352
                       WHERE categorycode = ?";
353
    push @args,$borrower->{categorycode};
354
355
    if($controlbranch eq "ItemHomeLibrary"){
356
        $rightsquery .= " AND branchcode = '*'";
357
    }elsif($controlbranch eq "PatronLibrary"){
358
        $rightsquery .= " AND branchcode IN (?,'*')";
359
        push @args, $borrower->{branchcode};
360
    }
361
    
362
    if(not $itype){
363
        $rightsquery .= " AND itemtype IN (?,'*')";
364
        push @args, $biblio->{itemtype};
365
    }else{
366
        $rightsquery .= " AND itemtype = '*'";
367
    }
368
    
369
    $rightsquery .= " ORDER BY categorycode DESC, itemtype DESC, branchcode DESC";
370
    
371
    my $sthrights = $dbh->prepare($rightsquery);
372
    $sthrights->execute(@args);
373
    
374
    if(my $row = $sthrights->fetchrow_hashref()){
375
       $reservesrights = $row->{reservesallowed};
376
    }
377
    
378
    @args = ();
379
    # we count how many reserves the borrower have
380
    my $countquery = "SELECT count(*) as count
381
                      FROM reserves
382
                      LEFT JOIN items USING (itemnumber)
383
                      LEFT JOIN biblioitems ON (reserves.biblionumber=biblioitems.biblionumber)
384
                      LEFT JOIN borrowers USING (borrowernumber)
385
                      WHERE borrowernumber = ?
386
                    ";
387
    push @args, $borrowernumber;
388
    
389
    if(not $itype){
390
           $countquery .= "AND itemtype = ?";
391
           push @args, $biblio->{itemtype};
392
    }
393
    
394
    if($controlbranch eq "PatronLibrary"){
395
        $countquery .= " AND borrowers.branchcode = ? ";
396
        push @args, $borrower->{branchcode};
397
    }
398
    
399
    my $sthcount = $dbh->prepare($countquery);
400
    $sthcount->execute(@args);
401
    
402
    if(my $row = $sthcount->fetchrow_hashref()){
403
       $reservescount = $row->{count};
404
    }
405
    
406
    if($reservescount < $reservesrights){
407
        return 1;
408
    }else{
409
        return 0;
410
    }
411
    
412
}
413
414
=item CanItemBeReserved
415
416
$error = &CanItemBeReserved($borrowernumber, $itemnumber)
417
418
this function return 1 if an item can be issued by this borrower.
419
420
=cut
421
422
sub CanItemBeReserved{
423
    my ($borrowernumber, $itemnumber) = @_;
424
    
425
    my $dbh             = C4::Context->dbh;
426
    my $allowedreserves = 0;
427
            
428
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
429
    my $itype         = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype";
430
431
    # we retrieve borrowers and items informations #
432
    my $item     = GetItem($itemnumber);
433
    my $borrower = C4::Members::GetMember($borrowernumber);     
434
    
435
    # we retrieve user rights on this itemtype and branchcode
436
    my $sth = $dbh->prepare("SELECT categorycode, itemtype, branchcode, reservesallowed 
437
                             FROM issuingrules 
438
                             WHERE (categorycode in (?,'*') ) 
439
                             AND (itemtype IN (?,'*')) 
440
                             AND (branchcode IN (?,'*')) 
441
                             ORDER BY 
442
                               categorycode DESC, 
443
                               itemtype     DESC, 
444
                               branchcode   DESC;"
445
                           );
446
                           
447
    my $querycount ="SELECT 
448
                            count(*) as count
449
                            FROM reserves
450
                                LEFT JOIN items USING (itemnumber)
451
                                LEFT JOIN biblioitems ON (reserves.biblionumber=biblioitems.biblionumber)
452
                                LEFT JOIN borrowers USING (borrowernumber)
453
                            WHERE borrowernumber = ?
454
                                ";
455
    
456
    
457
    my $itemtype     = $item->{$itype};
458
    my $categorycode = $borrower->{categorycode};
459
    my $branchcode   = "";
460
    my $branchfield  = "reserves.branchcode";
461
    
462
    if( $controlbranch eq "ItemHomeLibrary" ){
463
        $branchfield = "items.homebranch";
464
        $branchcode = $item->{homebranch};
465
    }elsif( $controlbranch eq "PatronLibrary" ){
466
        $branchfield = "borrowers.branchcode";
467
        $branchcode = $borrower->{branchcode};
468
    }
469
    
470
    # we retrieve rights 
471
    $sth->execute($categorycode, $itemtype, $branchcode);
472
    if(my $rights = $sth->fetchrow_hashref()){
473
        $itemtype        = $rights->{itemtype};
474
        $allowedreserves = $rights->{reservesallowed}; 
475
    }else{
476
        $itemtype = '*';
477
    }
478
    
479
    # we retrieve count
480
    
481
    $querycount .= "AND $branchfield = ?";
482
    
483
    $querycount .= " AND $itype = ?" if ($itemtype ne "*");
484
    my $sthcount = $dbh->prepare($querycount);
485
    
486
    if($itemtype eq "*"){
487
        $sthcount->execute($borrowernumber, $branchcode);
488
    }else{
489
        $sthcount->execute($borrowernumber, $branchcode, $itemtype);
490
    }
491
    
492
    my $reservecount = "0";
493
    if(my $rowcount = $sthcount->fetchrow_hashref()){
494
        $reservecount = $rowcount->{count};
495
    }
496
    
497
    # we check if it's ok or not
498
    if( $reservecount < $allowedreserves ){
499
        return 1;
500
    }else{
501
        return 0;
502
    }
503
}
504
329
=item GetReserveCount
505
=item GetReserveCount
330
506
331
$number = &GetReserveCount($borrowernumber);
507
$number = &GetReserveCount($borrowernumber);
(-)a/admin/smart-rules.pl (-4 / +5 lines)
Lines 99-106 elsif ($op eq 'delete-branch-item') { Link Here
99
# save the values entered
99
# save the values entered
100
elsif ($op eq 'add') {
100
elsif ($op eq 'add') {
101
    my $sth_search = $dbh->prepare("SELECT COUNT(*) AS total FROM issuingrules WHERE branchcode=? AND categorycode=? AND itemtype=?");
101
    my $sth_search = $dbh->prepare("SELECT COUNT(*) AS total FROM issuingrules WHERE branchcode=? AND categorycode=? AND itemtype=?");
102
    my $sth_insert = $dbh->prepare("INSERT INTO issuingrules (branchcode, categorycode, itemtype, maxissueqty, renewalsallowed, issuelength, fine, firstremind, chargeperiod) VALUES(?,?,?,?,?,?,?,?,?)");
102
    my $sth_insert = $dbh->prepare("INSERT INTO issuingrules (branchcode, categorycode, itemtype, maxissueqty, renewalsallowed, reservesallowed, issuelength, fine, firstremind, chargeperiod) VALUES(?,?,?,?,?,?,?,?,?,?)");
103
    my $sth_update=$dbh->prepare("UPDATE issuingrules SET fine=?, firstremind=?, chargeperiod=?, maxissueqty=?, renewalsallowed=?, issuelength=? WHERE branchcode=? AND categorycode=? AND itemtype=?");
103
    my $sth_update=$dbh->prepare("UPDATE issuingrules SET fine=?, firstremind=?, chargeperiod=?, maxissueqty=?, renewalsallowed=?, reservesallowed=?, issuelength=? WHERE branchcode=? AND categorycode=? AND itemtype=?");
104
    
104
    
105
    my $br = $branch; # branch
105
    my $br = $branch; # branch
106
    my $bor  = $input->param('categorycode'); # borrower category
106
    my $bor  = $input->param('categorycode'); # borrower category
Lines 110-115 elsif ($op eq 'add') { Link Here
110
    my $chargeperiod = $input->param('chargeperiod');
110
    my $chargeperiod = $input->param('chargeperiod');
111
    my $maxissueqty  = $input->param('maxissueqty');
111
    my $maxissueqty  = $input->param('maxissueqty');
112
    my $renewalsallowed  = $input->param('renewalsallowed');
112
    my $renewalsallowed  = $input->param('renewalsallowed');
113
    my $reservesallowed  = $input->param('reservesallowed');
113
    $maxissueqty =~ s/\s//g;
114
    $maxissueqty =~ s/\s//g;
114
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
115
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
115
    my $issuelength  = $input->param('issuelength');
116
    my $issuelength  = $input->param('issuelength');
Lines 118-126 elsif ($op eq 'add') { Link Here
118
    $sth_search->execute($br,$bor,$cat);
119
    $sth_search->execute($br,$bor,$cat);
119
    my $res = $sth_search->fetchrow_hashref();
120
    my $res = $sth_search->fetchrow_hashref();
120
    if ($res->{total}) {
121
    if ($res->{total}) {
121
        $sth_update->execute($fine, $firstremind, $chargeperiod, $maxissueqty,$renewalsallowed,$issuelength,$br,$bor,$cat);
122
        $sth_update->execute($fine, $firstremind, $chargeperiod, $maxissueqty,$renewalsallowed,$reservesallowed,$issuelength,$br,$bor,$cat);
122
    } else {
123
    } else {
123
        $sth_insert->execute($br,$bor,$cat,$maxissueqty,$renewalsallowed,$issuelength,$fine,$firstremind,$chargeperiod);
124
        $sth_insert->execute($br,$bor,$cat,$maxissueqty,$renewalsallowed,$reservesallowed,$issuelength,$fine,$firstremind,$chargeperiod);
124
    }
125
    }
125
} 
126
} 
126
elsif ($op eq "set-branch-defaults") {
127
elsif ($op eq "set-branch-defaults") {
(-)a/installer/data/mysql/en/mandatory/sysprefs.sql (-1 / +1 lines)
Lines 56-62 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES Link Here
56
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MARCOrgCode','OSt','Define MARC Organization Code - http://www.loc.gov/marc/organizations/orgshome.html','','free');
56
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MARCOrgCode','OSt','Define MARC Organization Code - http://www.loc.gov/marc/organizations/orgshome.html','','free');
57
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MaxFine',9999,'Maximum fine a patron can have for a single late return','','Integer');
57
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MaxFine',9999,'Maximum fine a patron can have for a single late return','','Integer');
58
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxoutstanding',5,'maximum amount withstanding to be able make holds','','Integer');
58
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxoutstanding',5,'maximum amount withstanding to be able make holds','','Integer');
59
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxreserves',50,'Define maximum number of holds a patron can place','','Integer');
60
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('memberofinstitution',0,'If ON, patrons can be linked to institutions',NULL,'YesNo');
59
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('memberofinstitution',0,'If ON, patrons can be linked to institutions',NULL,'YesNo');
61
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MIME','EXCEL','Define the default application for exporting report data','EXCEL|OPENOFFICE.ORG','Choice');
60
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MIME','EXCEL','Define the default application for exporting report data','EXCEL|OPENOFFICE.ORG','Choice');
62
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('noissuescharge',5,'Define maximum amount withstanding before check outs are blocked','','Integer');
61
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('noissuescharge',5,'Define maximum amount withstanding before check outs are blocked','','Integer');
Lines 245-247 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('v Link Here
245
INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewLabeledMARC','0','Allow display of labeled MARC view of bibiographic records','','YesNo');
244
INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewLabeledMARC','0','Allow display of labeled MARC view of bibiographic records','','YesNo');
246
INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewMARC','1','Allow display of MARC view of bibiographic records','','YesNo');
245
INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewMARC','1','Allow display of MARC view of bibiographic records','','YesNo');
247
INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('FilterBeforeOverdueReport','0','Do not run overdue report until filter selected','','YesNo');
246
INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('FilterBeforeOverdueReport','0','Do not run overdue report until filter selected','','YesNo');
247
INSERT INTO systempreferences (variable,value, options, explanation, type) VALUES('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice');
(-)a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql (-1 / +1 lines)
Lines 57-63 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES Link Here
57
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MARCOrgCode', '0', 'Ce paramètre définit votre code organisme MARC. Utilisé en MARC21. Voir  - http://www.loc.gov/marc/organizations/orgshome.html', '', '');
57
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MARCOrgCode', '0', 'Ce paramètre définit votre code organisme MARC. Utilisé en MARC21. Voir  - http://www.loc.gov/marc/organizations/orgshome.html', '', '');
58
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MaxFine','9999','Amende maximum qu''un ahdérent peut avoir pour un retour en retard','','Integer');
58
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MaxFine','9999','Amende maximum qu''un ahdérent peut avoir pour un retour en retard','','Integer');
59
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxoutstanding', '5', 'Ce paramètre définit le montant maximal des dettes au dela duquel le lecteur ne peut plus faire de réservation', '', 'Integer');
59
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxoutstanding', '5', 'Ce paramètre définit le montant maximal des dettes au dela duquel le lecteur ne peut plus faire de réservation', '', 'Integer');
60
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxreserves', '2', 'Ce paramètre définit le nombre maximal de réservations qu''un lecteur peut faire.', '', 'Integer');
61
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('memberofinstitution', '0', 'Vos adhérents sont ils membres d''une institution ?', NULL, 'YesNo');
60
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('memberofinstitution', '0', 'Vos adhérents sont ils membres d''une institution ?', NULL, 'YesNo');
62
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MIME', 'OPENOFFICE.ORG', 'Ce paramètre définit l''application par défaut à ouvrir lorsqu''on télécharge un fichier (OpenOffice.org ou MS-Excel habituellement)', 'EXCEL|OPENOFFICE.ORG', 'Choice');
61
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MIME', 'OPENOFFICE.ORG', 'Ce paramètre définit l''application par défaut à ouvrir lorsqu''on télécharge un fichier (OpenOffice.org ou MS-Excel habituellement)', 'EXCEL|OPENOFFICE.ORG', 'Choice');
63
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('noissuescharge', '5', 'Ce paramètre définit le montant maximal des dettes au delà duquel le lecteur ne peut plus emprunter', '', 'Integer');
62
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('noissuescharge', '5', 'Ce paramètre définit le montant maximal des dettes au delà duquel le lecteur ne peut plus emprunter', '', 'Integer');
Lines 247-249 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('v Link Here
247
INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewLabeledMARC','0','Autoriser l''affichage MARC labellis des notices bibliographiques','','YesNo');
246
INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewLabeledMARC','0','Autoriser l''affichage MARC labellis des notices bibliographiques','','YesNo');
248
INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewMARC','1','Autoriser l''affichage de la vue MARC des notices bibliographiques','','YesNo');
247
INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewMARC','1','Autoriser l''affichage de la vue MARC des notices bibliographiques','','YesNo');
249
INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('FilterBeforeOverdueReport','0','Ne pas lancer le rapport sur les retards tant qu''il n''y a pas de filtre','','YesNo');
248
INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('FilterBeforeOverdueReport','0','Ne pas lancer le rapport sur les retards tant qu''il n''y a pas de filtre','','YesNo');
249
INSERT INTO systempreferences (variable,value, options, explanation, type) VALUES('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Site de controle pour les reservations','Choice');
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 1140-1145 CREATE TABLE `issuingrules` ( Link Here
1140
  `maxissueqty` int(4) default NULL,
1140
  `maxissueqty` int(4) default NULL,
1141
  `issuelength` int(4) default NULL,
1141
  `issuelength` int(4) default NULL,
1142
  `renewalsallowed` smallint(6) NOT NULL default "0",
1142
  `renewalsallowed` smallint(6) NOT NULL default "0",
1143
  `reservesallowed` smallint(6) NOT NULL default "0",
1143
  `branchcode` varchar(10) NOT NULL default '',
1144
  `branchcode` varchar(10) NOT NULL default '',
1144
  PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
1145
  PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
1145
  KEY `categorycode` (`categorycode`),
1146
  KEY `categorycode` (`categorycode`),
(-)a/installer/data/mysql/updatedatabase.pl (+16 lines)
Lines 2493-2498 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
2493
    print "Upgrade to $DBversion done (Moving allowed renewals from itemtypes to issuingrule)\n";
2493
    print "Upgrade to $DBversion done (Moving allowed renewals from itemtypes to issuingrule)\n";
2494
}
2494
}
2495
2495
2496
$DBversion = '3.01.00.040';
2497
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2498
    $dbh->do('ALTER TABLE issuingrules ADD COLUMN `reservesallowed` smallint(6) NOT NULL default "0" AFTER `renewalsallowed`;');
2499
    
2500
    my $maxreserves = C4::Context->preference('maxreserves');
2501
    $sth = $dbh->prepare('UPDATE issuingrules SET reservesallowed = ?;');
2502
    $sth->execute($maxreserves);
2503
    
2504
    $dbh->do('DELETE FROM systempreferences WHERE variable = "maxreserves";');
2505
2506
    $dbh->do("INSERT INTO systempreferences (variable,value, options, explanation, type) VALUES('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice')");
2507
    
2508
    SetVersion ($DBversion);
2509
    print "Upgrade to $DBversion done (Moving max allowed reserves from system preference to issuingrule)\n";
2510
}
2511
2496
=item DropAllForeignKeys($table)
2512
=item DropAllForeignKeys($table)
2497
2513
2498
  Drop all foreign keys of the table $table
2514
  Drop all foreign keys of the table $table
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tmpl (+3 lines)
Lines 69-74 $(document).ready(function() { Link Here
69
                <th>Fine Charging Interval</th>
69
                <th>Fine Charging Interval</th>
70
                <th>Current Checkouts Allowed</th>
70
                <th>Current Checkouts Allowed</th>
71
                <th>Renewals Allowed</th>
71
                <th>Renewals Allowed</th>
72
                <th>Reserves Allowed</th>
72
                <th>Loan Period</th><th>&nbsp;</th>
73
                <th>Loan Period</th><th>&nbsp;</th>
73
            </tr>
74
            </tr>
74
            <!-- TMPL_LOOP NAME="rules" -->
75
            <!-- TMPL_LOOP NAME="rules" -->
Lines 95-100 $(document).ready(function() { Link Here
95
                        <!-- /TMPL_IF -->
96
                        <!-- /TMPL_IF -->
96
                    </td>
97
                    </td>
97
					<td><!-- TMPL_IF NAME="renewalsallowed" --><!-- TMPL_VAR NAME="renewalsallowed" --> time(s)<!-- /TMPL_IF --></td>
98
					<td><!-- TMPL_IF NAME="renewalsallowed" --><!-- TMPL_VAR NAME="renewalsallowed" --> time(s)<!-- /TMPL_IF --></td>
99
					<td><!-- TMPL_IF NAME="reservesallowed" --><!-- TMPL_VAR NAME="reservesallowed" --> time(s)<!-- /TMPL_IF --></td>
98
                    <td><!-- TMPL_IF NAME="issuelength" --><!-- TMPL_VAR NAME="issuelength" --> day(s)<!-- /TMPL_IF --></td>
100
                    <td><!-- TMPL_IF NAME="issuelength" --><!-- TMPL_VAR NAME="issuelength" --> day(s)<!-- /TMPL_IF --></td>
99
                    <td>
101
                    <td>
100
                        <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=<!-- TMPL_VAR NAME="itemtype" -->&amp;categorycode=<!-- TMPL_VAR NAME="categorycode" -->&amp;branch=<!-- TMPL_VAR NAME="branch" -->">Delete</a>
102
                        <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=<!-- TMPL_VAR NAME="itemtype" -->&amp;categorycode=<!-- TMPL_VAR NAME="categorycode" -->&amp;branch=<!-- TMPL_VAR NAME="branch" -->">Delete</a>
Lines 123-128 $(document).ready(function() { Link Here
123
                    <td><input name="chargeperiod" size="2" /> day(s)</td>
125
                    <td><input name="chargeperiod" size="2" /> day(s)</td>
124
                    <td><input name="maxissueqty" size="3" /></td>
126
                    <td><input name="maxissueqty" size="3" /></td>
125
                    <td><input name="renewalsallowed" size="3" /></td>
127
                    <td><input name="renewalsallowed" size="3" /></td>
128
                    <td><input name="reservesallowed" size="3" /></td>
126
                    <td><input name="issuelength" size="3" /> day(s)</td>
129
                    <td><input name="issuelength" size="3" /> day(s)</td>
127
                    <td><input type="hidden" name="branch" value="<!-- TMPL_VAR NAME="branch" -->"/><input type="submit" value="Add" class="submit" /></td>
130
                    <td><input type="hidden" name="branch" value="<!-- TMPL_VAR NAME="branch" -->"/><input type="submit" value="Add" class="submit" /></td>
128
                </tr>
131
                </tr>
(-)a/opac/opac-reserve.pl (-9 / +11 lines)
Lines 32-39 use C4::Branch; # GetBranches Link Here
32
use C4::Debug;
32
use C4::Debug;
33
# use Data::Dumper;
33
# use Data::Dumper;
34
34
35
my $MAXIMUM_NUMBER_OF_RESERVES = C4::Context->preference("maxreserves");
36
37
my $query = new CGI;
35
my $query = new CGI;
38
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
36
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
39
    {
37
    {
Lines 190-200 if ( $query->param('place_reserve') ) { Link Here
190
188
191
        my $biblioData = $biblioDataHash{$biblioNum};
189
        my $biblioData = $biblioDataHash{$biblioNum};
192
        my $found;
190
        my $found;
191
        my $canreserve = 0;
193
        
192
        
194
        # If a specific item was selected and the pickup branch is the same as the
193
        # If a specific item was selected and the pickup branch is the same as the
195
        # holdingbranch, force the value $rank and $found.
194
        # holdingbranch, force the value $rank and $found.
196
        my $rank = $biblioData->{rank};
195
        my $rank = $biblioData->{rank};
197
        if ($itemNum ne ''){
196
        if ($itemNum ne ''){
197
            $canreserve = 1 if CanItemBeReserved($borrowernumber,$itemNum);
198
            $rank = '0' unless C4::Context->preference('ReservesNeedReturns');
198
            $rank = '0' unless C4::Context->preference('ReservesNeedReturns');
199
            my $item = GetItem($itemNum);
199
            my $item = GetItem($itemNum);
200
            if ( $item->{'holdingbranch'} eq $branch ){
200
            if ( $item->{'holdingbranch'} eq $branch ){
Lines 203-214 if ( $query->param('place_reserve') ) { Link Here
203
        }
203
        }
204
        else {
204
        else {
205
            # Inserts a null into the 'itemnumber' field of 'reserves' table.
205
            # Inserts a null into the 'itemnumber' field of 'reserves' table.
206
            $canreserve = 1 if CanBookBeReserved($borrowernumber,$biblioNum);
206
            $itemNum = undef;
207
            $itemNum = undef;
207
        }
208
        }
208
        
209
        
209
        # Here we actually do the reserveration. Stage 3.
210
        # Here we actually do the reserveration. Stage 3.
210
        AddReserve($branch, $borrowernumber, $biblioNum, 'a', [$biblioNum], $rank, $notes,
211
        AddReserve($branch, $borrowernumber, $biblioNum, 'a', [$biblioNum], $rank, $notes,
211
                   $biblioData->{'title'}, $itemNum, $found);
212
                   $biblioData->{'title'}, $itemNum, $found) if $canreserve;
212
    }
213
    }
213
214
214
    print $query->redirect("/cgi-bin/koha/opac-user.pl#opac-user-holds");
215
    print $query->redirect("/cgi-bin/koha/opac-user.pl#opac-user-holds");
Lines 253-263 if ( $borr->{debarred} && ($borr->{debarred} eq 1) ) { Link Here
253
254
254
my @reserves = GetReservesFromBorrowernumber( $borrowernumber );
255
my @reserves = GetReservesFromBorrowernumber( $borrowernumber );
255
$template->param( RESERVES => \@reserves );
256
$template->param( RESERVES => \@reserves );
256
if ( scalar(@reserves) >= $MAXIMUM_NUMBER_OF_RESERVES ) {
257
257
    $template->param( message => 1 );
258
258
    $noreserves = 1;
259
    $template->param( too_many_reserves => scalar(@reserves));
260
}
261
foreach my $res (@reserves) {
259
foreach my $res (@reserves) {
262
    foreach my $biblionumber (@biblionumbers) {
260
    foreach my $biblionumber (@biblionumbers) {
263
        if ( $res->{'biblionumber'} == $biblionumber && $res->{'borrowernumber'} == $borrowernumber) {
261
        if ( $res->{'biblionumber'} == $biblionumber && $res->{'borrowernumber'} == $borrowernumber) {
Lines 421-427 foreach my $biblioNum (@biblionumbers) { Link Here
421
            $policy_holdallowed = 0;
419
            $policy_holdallowed = 0;
422
        }
420
        }
423
421
424
        if (IsAvailableForItemLevelRequest($itemNum) and $policy_holdallowed) {
422
        if (IsAvailableForItemLevelRequest($itemNum) and $policy_holdallowed and CanItemBeReserved($borrowernumber,$itemNum)) {
425
            $itemLoopIter->{available} = 1;
423
            $itemLoopIter->{available} = 1;
426
            $numCopiesAvailable++;
424
            $numCopiesAvailable++;
427
        }
425
        }
Lines 447-452 foreach my $biblioNum (@biblionumbers) { Link Here
447
        $biblioLoopIter{holdable} = undef;
445
        $biblioLoopIter{holdable} = undef;
448
    }
446
    }
449
447
448
    if(not CanBookBeReserved($borrowernumber,$biblioNum)){
449
        $biblioLoopIter{holdable} = undef;
450
    }
451
    
450
    push @$biblioLoop, \%biblioLoopIter;
452
    push @$biblioLoop, \%biblioLoopIter;
451
}
453
}
452
454
(-)a/reserve/request.pl (-11 / +12 lines)
Lines 88-93 my $borrowerslist; Link Here
88
my $messageborrower;
88
my $messageborrower;
89
my $warnings;
89
my $warnings;
90
my $messages;
90
my $messages;
91
my $maxreserves;
91
92
92
my $date = C4::Dates->today('iso');
93
my $date = C4::Dates->today('iso');
93
94
Lines 115-138 if ($cardnumber) { Link Here
115
    my $diffbranch;
116
    my $diffbranch;
116
    my @getreservloop;
117
    my @getreservloop;
117
    my $count_reserv = 0;
118
    my $count_reserv = 0;
118
    my $maxreserves;
119
119
120
#   we check the reserves of the borrower, and if he can reserv a document
120
#   we check the reserves of the borrower, and if he can reserv a document
121
# FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
121
# FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
122
122
123
    
124
123
    my $number_reserves =
125
    my $number_reserves =
124
      GetReserveCount( $borrowerinfo->{'borrowernumber'} );
126
      GetReserveCount( $borrowerinfo->{'borrowernumber'} );
125
127
    
126
    if ( $number_reserves > C4::Context->preference('maxreserves') ) {
127
		$warnings = 1;
128
        $maxreserves = 1;
129
    }
130
131
    # we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
128
    # we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
132
    my $expiry_date = $borrowerinfo->{dateexpiry};
129
    my $expiry_date = $borrowerinfo->{dateexpiry};
133
    my $expiry = 0; # flag set if patron account has expired
130
    my $expiry = 0; # flag set if patron account has expired
134
    if ($expiry_date and $expiry_date ne '0000-00-00' and
131
    if ($expiry_date and $expiry_date ne '0000-00-00' and
135
            Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
132
            Date_to_Days(split (/-/,$date)) > Date_to_Days(split (/-/,$expiry_date))) {
136
		$messages = $expiry = 1;
133
		$messages = $expiry = 1;
137
    }
134
    }
138
     
135
     
Lines 157-163 if ($cardnumber) { Link Here
157
                borroweremailpro => $borrowerinfo->{'emailpro'},
154
                borroweremailpro => $borrowerinfo->{'emailpro'},
158
                borrowercategory => $borrowerinfo->{'category'},
155
                borrowercategory => $borrowerinfo->{'category'},
159
                borrowerreservs   => $count_reserv,
156
                borrowerreservs   => $count_reserv,
160
                maxreserves       => $maxreserves,
161
                expiry            => $expiry,
157
                expiry            => $expiry,
162
                diffbranch        => $diffbranch,
158
                diffbranch        => $diffbranch,
163
				messages => $messages,
159
				messages => $messages,
Lines 213-218 if ($multihold) { Link Here
213
my @biblioloop = ();
209
my @biblioloop = ();
214
foreach my $biblionumber (@biblionumbers) {
210
foreach my $biblionumber (@biblionumbers) {
215
211
212
    if ( not CanBookBeReserved($borrowerinfo->{borrowernumber}, $biblionumber) ) {
213
		$warnings = 1;
214
        $maxreserves = 1;
215
    }
216
216
    my %biblioloopiter = ();
217
    my %biblioloopiter = ();
217
218
218
    my $dat          = GetBiblioData($biblionumber);
219
    my $dat          = GetBiblioData($biblionumber);
Lines 399-405 foreach my $biblionumber (@biblionumbers) { Link Here
399
                $policy_holdallowed = 0;
400
                $policy_holdallowed = 0;
400
            }
401
            }
401
            
402
            
402
            if (IsAvailableForItemLevelRequest($itemnumber) and not $item->{cantreserve}) {
403
            if (IsAvailableForItemLevelRequest($itemnumber) and not $item->{cantreserve} and CanItemBeReserved($borrowerinfo->{borrowernumber}, $itemnumber) ) {
403
                if ( not $policy_holdallowed and C4::Context->preference( 'AllowHoldPolicyOverride' ) ) {
404
                if ( not $policy_holdallowed and C4::Context->preference( 'AllowHoldPolicyOverride' ) ) {
404
                    $item->{override} = 1;
405
                    $item->{override} = 1;
405
                    $num_override++;
406
                    $num_override++;
Lines 545-550 foreach my $biblionumber (@biblionumbers) { Link Here
545
546
546
$template->param( biblioloop => \@biblioloop );
547
$template->param( biblioloop => \@biblioloop );
547
$template->param( biblionumbers => $biblionumbers );
548
$template->param( biblionumbers => $biblionumbers );
549
$template->param( maxreserves => $maxreserves );
548
550
549
if ($multihold) {
551
if ($multihold) {
550
    $template->param( multi_hold => 1 );
552
    $template->param( multi_hold => 1 );
551
- 

Return to bug 3323