3 * For the first (by ID) 20 users in each Patron group and the first 3 in
6 * 1. create 3 regular circs w/ varying (stock) rules and 3 overdue
9 * 2. create 2 regular title holds and one frozen title hold. If the user
10 * is in a Staff group, also create one copy-level hold.
15 * NOTE: The fine generator and hold targeter should be run after this is
16 * loaded to creating overdue billings and target copies for holds.
21 DECLARE recipient actor.usr%ROWTYPE;
22 DECLARE copy asset.copy%ROWTYPE;
23 DECLARE bre biblio.record_entry%ROWTYPE;
24 DECLARE user_count INTEGER;
25 DECLARE requestor INTEGER;
28 copy := evergreen.next_copy(0);
29 bre := evergreen.next_bib(0);
31 FOR grp IN SELECT id FROM permission.grp_tree WHERE id > 1 ORDER BY id LOOP
33 IF 2 IN (SELECT id FROM permission.grp_ancestors(grp)) THEN
40 FOR recipient IN SELECT * FROM actor.usr
41 WHERE NOT deleted AND profile = grp
42 ORDER BY id LIMIT user_count LOOP
44 -- find a suitable circulator/requestor for these transactions
45 SELECT INTO requestor id
47 WHERE home_ou = recipient.home_ou AND
48 profile = 5 AND -- Circulators
52 -- regular circs --------------------------------
54 copy := evergreen.next_copy(copy.id);
55 EXIT WHEN copy IS NULL;
56 PERFORM evergreen.populate_circ(
57 recipient.id, requestor, copy.id, copy.circ_lib,
58 'default', 'default', 'default', FALSE
61 copy := evergreen.next_copy(copy.id);
62 EXIT WHEN copy IS NULL;
63 PERFORM evergreen.populate_circ(
64 recipient.id, requestor, copy.id, copy.circ_lib,
65 '1_hour_2_renew', 'default', 'overdue_min', FALSE
68 copy := evergreen.next_copy(copy.id);
69 EXIT WHEN copy IS NULL;
70 PERFORM evergreen.populate_circ(
71 recipient.id, requestor, copy.id, copy.circ_lib,
72 '7_days_0_renew', 'default', 'overdue_max', FALSE
75 -- overdue circs ----------------------------------
77 copy := evergreen.next_copy(copy.id);
78 EXIT WHEN copy IS NULL;
79 PERFORM evergreen.populate_circ(
80 recipient.id, requestor, copy.id, copy.circ_lib,
81 'default', 'default', 'default', TRUE
84 copy := evergreen.next_copy(copy.id);
85 EXIT WHEN copy IS NULL;
86 PERFORM evergreen.populate_circ(
87 recipient.id, requestor, copy.id, copy.circ_lib,
88 '1_hour_2_renew', 'default', 'overdue_min', TRUE
91 copy := evergreen.next_copy(copy.id);
92 EXIT WHEN copy IS NULL;
93 PERFORM evergreen.populate_circ(
94 recipient.id, requestor, copy.id, copy.circ_lib,
95 '7_days_0_renew', 'default', 'overdue_max', TRUE
98 -- holds ------------------------------------------
101 bre := evergreen.next_bib(bre.id);
102 EXIT WHEN bre IS NULL;
103 PERFORM evergreen.populate_hold(
104 'T', bre.id, recipient.id, recipient.id,
105 recipient.home_ou, FALSE, NULL
108 -- title hold, circulator-placed
109 bre := evergreen.next_bib(bre.id);
110 EXIT WHEN bre IS NULL;
111 PERFORM evergreen.populate_hold(
112 'T', bre.id, recipient.id, requestor,
113 recipient.home_ou, FALSE, NULL
117 bre := evergreen.next_bib(bre.id);
118 EXIT WHEN bre IS NULL;
119 PERFORM evergreen.populate_hold(
120 'T', bre.id, recipient.id, recipient.id,
122 TRUE, NOW() + '3 months'::INTERVAL
125 -- Staff accounts get a copy-level hold
126 IF 3 IN (SELECT id FROM permission.grp_ancestors(grp)) THEN
127 copy := evergreen.next_copy(copy.id);
128 EXIT WHEN copy IS NULL;
129 PERFORM evergreen.populate_hold(
130 'C', copy.id, recipient.id, recipient.id,
131 recipient.home_ou, FALSE, NULL