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

(-)a/admin/smart-rules.pl (+6 lines)
Lines 417-422 elsif ($op eq "add-branch-cat") { Link Here
417
    $patron_maxonsiteissueqty = strip_non_numeric($patron_maxonsiteissueqty);
417
    $patron_maxonsiteissueqty = strip_non_numeric($patron_maxonsiteissueqty);
418
    my $max_holds = $input->param('max_holds');
418
    my $max_holds = $input->param('max_holds');
419
    $max_holds = strip_non_numeric($max_holds);
419
    $max_holds = strip_non_numeric($max_holds);
420
    my $has_priority = $input->param('has_priority');
421
    $has_priority = $has_priority ? 1 : 0;
420
422
421
    if ($branch eq "*") {
423
    if ($branch eq "*") {
422
        if ($categorycode eq "*") {
424
        if ($categorycode eq "*") {
Lines 432-437 elsif ($op eq "add-branch-cat") { Link Here
432
                }
434
                }
433
            );
435
            );
434
        } else {
436
        } else {
437
435
            Koha::CirculationRules->set_rules(
438
            Koha::CirculationRules->set_rules(
436
                {
439
                {
437
                    categorycode => $categorycode,
440
                    categorycode => $categorycode,
Lines 440-445 elsif ($op eq "add-branch-cat") { Link Here
440
                        max_holds         => $max_holds,
443
                        max_holds         => $max_holds,
441
                        patron_maxissueqty       => $patron_maxissueqty,
444
                        patron_maxissueqty       => $patron_maxissueqty,
442
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
445
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
446
                        has_priority      => $has_priority,
443
                    }
447
                    }
444
                }
448
                }
445
            );
449
            );
Lines 453-458 elsif ($op eq "add-branch-cat") { Link Here
453
                    max_holds         => $max_holds,
457
                    max_holds         => $max_holds,
454
                    patron_maxissueqty       => $patron_maxissueqty,
458
                    patron_maxissueqty       => $patron_maxissueqty,
455
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
459
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
460
                    has_priority      => $has_priority,
456
                }
461
                }
457
            }
462
            }
458
        );
463
        );
Lines 465-470 elsif ($op eq "add-branch-cat") { Link Here
465
                    max_holds         => $max_holds,
470
                    max_holds         => $max_holds,
466
                    patron_maxissueqty       => $patron_maxissueqty,
471
                    patron_maxissueqty       => $patron_maxissueqty,
467
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
472
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
473
                    has_priority      => $has_priority,
468
                }
474
                }
469
            }
475
            }
470
        );
476
        );
(-)a/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.sql (+5 lines)
Line 0 Link Here
1
ALTER TABLE default_borrower_circ_rules ADD has_priority INT(1) DEFAULT 0;
2
ALTER TABLE default_borrower_circ_rules DROP foreign key borrower_borrower_circ_rules_ibfk_1;
3
ALTER TABLE default_borrower_circ_rules DROP primary key;
4
ALTER TABLE default_borrower_circ_rules ADD primary key(categorycode, has_priority);
5
ALTER TABLE default_borrower_circ_rules ADD CONSTRAINT borrower_borrower_circ_rules_ibfk_1 FOREIGN KEY (categorycode) REFERENCES categories (categorycode) ON DELETE CASCADE ON UPDATE CASCADE;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (+129 lines)
Lines 1281-1286 Link Here
1281
                                [% SET holdallowed = CirculationRules.Search( branchcode, undef, i.itemtype, 'holdallowed' ) %]
1281
                                [% SET holdallowed = CirculationRules.Search( branchcode, undef, i.itemtype, 'holdallowed' ) %]
1282
                                [% SET hold_fulfillment_policy = CirculationRules.Search( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
1282
                                [% SET hold_fulfillment_policy = CirculationRules.Search( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
1283
                                [% SET returnbranch = CirculationRules.Search( branchcode, undef, i.itemtype, 'returnbranch' ) %]
1283
                                [% SET returnbranch = CirculationRules.Search( branchcode, undef, i.itemtype, 'returnbranch' ) %]
1284
                                        <tr>
1285
                                            <td>
1286
                                                <select>
1287
                                                    [% IF returnbranch == 'homebranch' %]
1288
                                                    <option value="homebranch" selected="selected">
1289
                                                    [% ELSE %]
1290
                                                    <option value="homebranch">
1291
                                                    [% END %]
1292
                                                        Item returns home
1293
                                                    </option>
1294
                                                    [% IF returnbranch == 'holdingbranch' %]
1295
                                                    <option value="holdingbranch" selected="selected">
1296
                                                    [% ELSE %]
1297
                                                    <option value="holdingbranch">
1298
                                                    [% END %]
1299
                                                        Item returns to issuing library
1300
                                                    </option>
1301
                                                    [% IF returnbranch == 'noreturn' %]
1302
                                                    <option value="noreturn" selected="selected">
1303
                                                    [% ELSE %]
1304
                                                    <option value="noreturn">
1305
                                                    [% END %]
1306
                                                        Item floats
1307
                                                    </option>
1308
                                                </select>
1309
                                            </td>
1310
                                            <td class="actions">
1311
                                                <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
1312
                                                <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch | html %]" id="unset"><i class="fa fa-undo"></i> Unset</a>
1313
                                            </td>
1314
                                        </tr>
1315
                                    </table>
1316
                                </form>
1317
                            </div>
1318
                            [% IF ( show_branch_cat_rule_form ) %]
1319
                            <div id="holds-policy-by-patron-category" class="container">
1320
                            <h3>[% IF humanbranch %]Checkout, hold policy by patron category for [% Branches.GetName( humanbranch ) | html %][% ELSE %]Default checkout, hold policy by patron category[% END %]</h3>
1321
                                <p>For this library, you can specify the maximum number of loans that
1322
                                    a patron of a given category can make, regardless of the item type.
1323
                                </p>
1324
                                <p>If the total amount loanable for a given patron category is left blank,
1325
                                   no limit applies, except possibly for a limit you define for a specific item type.
1326
                                </p>
1327
                                <p>
1328
                                    <b>Has priority: </b>If checked, the rule will override those for all branches. Else
1329
                                    it behaves like a default one: used if no rule existe for the coresponding branch.
1330
                                </p>
1331
                                <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
1332
                                    <input type="hidden" name="op" value="add-branch-cat" />
1333
                                    <input type="hidden" name="branch" value="[% current_branch | html %]"/>
1334
                                    <table>
1335
                                        <tr>
1336
                                            <th>Patron category</th>
1337
                                            <th>Total current checkouts allowed</th>
1338
                                            <th>Total current on-site checkouts allowed</th>
1339
                                            <th>Total holds allowed</th>
1340
                                            [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
1341
                                            <th>&nbsp;</th>
1342
                                        </tr>
1343
                                        [% FOREACH c IN categorycodes %]
1344
                                            [% NEXT UNLESS c %]
1345
                                            [% SET patron_maxissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxissueqty' ) %]
1346
                                            [% SET patron_maxonsiteissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %]
1347
                                            [% SET max_holds = CirculationRules.Search( branchcode, c, undef, 'max_holds' ) %]
1348
1349
                                            [% IF  ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %]
1350
                                            <tr>
1351
                                                <td>
1352
                                                    [% IF c == undef %]
1353
                                                        <em>Default</em>
1354
                                                    [% ELSE %]
1355
                                                        [% Categories.GetName(c) | html %]
1356
                                                    [% END %]
1357
                                                </td>
1358
                                                <td>
1359
                                                    [% IF patron_maxissueqty.defined && patron_maxissueqty != '' %]
1360
                                                        [% patron_maxissueqty | html %]
1361
                                                    [% ELSE %]
1362
                                                        <span>Unlimited</span>
1363
                                                    [% END %]
1364
                                                </td>
1365
                                                <td>
1366
                                                    [% IF patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' %]
1367
                                                        [% patron_maxonsiteissueqty | html %]
1368
                                                    [% ELSE %]
1369
                                                        <span>Unlimited</span>
1370
                                                    [% END %]
1371
                                                </td>
1372
                                                <td>
1373
                                                    [% IF max_holds.defined && max_holds != '' %]
1374
                                                        [% max_holds | html %]
1375
                                                    [% ELSE %]
1376
                                                        <span>Unlimited</span>
1377
                                                    [% END %]
1378
                                                </td>
1379
                                                [% UNLESS humanbranch %]
1380
                                                    <td>
1381
                                                        <input type="checkbox" [% IF branch_cat_rule_loo.has_priority %]checked[% END %] disabled/>
1382
                                                    </td>
1383
                                                [% END %]
1384
1385
                                                <td class="actions">
1386
                                                    <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=[% c | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
1387
                                                </td>
1388
                                            </tr>
1389
                                            [% END %]
1390
                                        [% END %]
1391
                                        <tr>
1392
                                            <td>
1393
                                                <select name="categorycode">
1394
                                                [% FOREACH patron_category IN patron_categories%]
1395
                                                    <option value="[% patron_category.categorycode | html %]">[% patron_category.description | html %]</option>
1396
                                                [% END %]
1397
                                                </select>
1398
                                            </td>
1399
                                            <td><input name="patron_maxissueqty" size="3" type="text" /></td>
1400
                                            <td><input name="patron_maxonsiteissueqty" size="3" type="text" /></td>
1401
                                            <td><input name="max_holds" size="3" type="text" /></td>
1402
                                            [% UNLESS humanbranch %]
1403
                                                <td>
1404
                                                    <input type="checkbox" name="has_priority"/>
1405
                                                </td>
1406
                                            [% END %]
1407
                                            <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
1408
                                        </tr>
1409
                                    </table>
1410
                                </form>
1411
                            </div>
1412
                            [% END %]
1284
1413
1285
                                [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
1414
                                [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
1286
                                    <tr>
1415
                                    <tr>
(-)a/t/db_dependent/Circulation/Branch.t (-1 / +24 lines)
Lines 232-238 Koha::CirculationRules->set_rules( Link Here
232
    }
232
    }
233
);
233
);
234
234
235
$query = q|
236
    INSERT INTO default_borrower_circ_rules
237
    (categorycode, maxissueqty, maxonsiteissueqty, has_priority)
238
    VALUES( ?, ?, ?, ? )
239
|;
240
$dbh->do($query, {}, $samplecat->{categorycode}, 3, 3, 0);
241
235
#Test GetBranchBorrowerCircRule
242
#Test GetBranchBorrowerCircRule
243
#
236
is_deeply(
244
is_deeply(
237
    GetBranchBorrowerCircRule(),
245
    GetBranchBorrowerCircRule(),
238
    { patron_maxissueqty => 4, patron_maxonsiteissueqty => 5 },
246
    { patron_maxissueqty => 4, patron_maxonsiteissueqty => 5 },
Lines 257-262 is_deeply( Link Here
257
"GetBranchBorrower with wrong parameters returns the patron_maxissueqty and patron_maxonsiteissueqty of default_circ_rules"
265
"GetBranchBorrower with wrong parameters returns the patron_maxissueqty and patron_maxonsiteissueqty of default_circ_rules"
258
);
266
);
259
267
268
$query = q|
269
    INSERT INTO default_borrower_circ_rules
270
    (categorycode, maxissueqty, maxonsiteissueqty, has_priority)
271
    VALUES( ?, ?, ?, ? )
272
|;
273
$dbh->do($query, {}, $samplecat->{categorycode}, 3, 3, 1);
274
275
is_deeply(
276
    GetBranchBorrowerCircRule(
277
        $samplebranch1->{branchcode},
278
        $samplecat->{categorycode}
279
    ),
280
    { maxissueqty => 3, maxonsiteissueqty => 3, has_priority => 1 },
281
    "GetBranchBorrower returns the rule having priority"
282
);
283
260
#Test GetBranchItemRule
284
#Test GetBranchItemRule
261
my @lazy_any = ( 'hold_fulfillment_policy' => 'any' );
285
my @lazy_any = ( 'hold_fulfillment_policy' => 'any' );
262
is_deeply(
286
is_deeply(
263
- 

Return to bug 8137