7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha › Patrons › Merge patron records</title>
9 [% INCLUDE 'doc-head-close.inc' %]
13 background-color: #e6ffe6;
16 background-color: #ffe6e6;
29 border-right: 1px solid #EEE;
34 font-family: monospace;
48 <body id="pat_merge" class="pat">
49 [% INCLUDE 'header.inc' %]
50 [% INCLUDE 'patron-search.inc' %]
52 [% BLOCK display_names %]
54 [% CASE 'Accountline' %]account lines
55 [% CASE 'ArticleRequest' %]article requests
56 [% CASE 'BorrowerAttribute' %]extended patron attributes
57 [% CASE 'BorrowerDebarment' %]patron restrictions
58 [% CASE 'BorrowerFile' %]patrons files
59 [% CASE 'BorrowerModification' %]patron modification requests
60 [% CASE 'ClubEnrollment' %]club enrollments
61 [% CASE 'Issue' %]checkouts
62 [% CASE 'ItemsLastBorrower' %]marks as last borrower of item
63 [% CASE 'Linktracker' %]tracked link clicks
64 [% CASE 'Message' %]patron messages
65 [% CASE 'MessageQueue' %]patron notices
66 [% CASE 'OldIssue' %]previous checkouts
67 [% CASE 'OldReserve' %]filled holds
68 [% CASE 'Rating' %]ratings
69 [% CASE 'Reserve' %]current holds
70 [% CASE 'Review' %]reviews
71 [% CASE 'Statistic' %]statistics
72 [% CASE 'SearchHistory' %]historical searches
73 [% CASE 'Suggestion' %]purchase suggestions
74 [% CASE 'TagAll' %]tags
75 [% CASE 'Virtualshelfcontent' %]list items
76 [% CASE 'Virtualshelfshare' %]list shares
77 [% CASE 'Virtualshelve' %]lists
78 [% CASE %][% rs | html %]
82 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> › Merge patron records</div>
84 <div class="main container-fluid">
86 <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
87 <h3>Merge patron records</h3>
89 [% IF action == 'show' %]
90 [% IF patrons.count > 1 %]
91 [% IF ( patrons.count == 2 ) %]
92 <div id="toolbar" class="btn-toolbar">
93 <div class="btn-group">
94 <button class="btn btn-default" id="compare_patrons">
95 <i class="fa fa-arrows-h"></i> Compare patrons
101 <p>Select patron to keep. Data from the other patrons will be transferred to this patron record and the remaining patron records will be deleted.</p>
103 <form type="post" action="merge-patrons.pl" id="patron-merge-form">
104 <table id="patron-merge-table" class="datatable">
110 <th>Date of birth</th>
118 [% FOREACH p IN patrons %]
120 <td><input class="keeper" type="radio" name="keeper" value="[% p.id | html %]" data-borrowernumber="[% p.id | html %]" id="keeper_[% p.id | html %]" /></td>
122 <label for="keeper_[% p.id | html %]">
123 <strong>[% p.cardnumber | html %]</strong>
127 <a target="_blank" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% p.borrowernumber | uri %]">
128 [% INCLUDE 'patron-title.inc' patron = p %]
129 <i class="fa fa-window-restore"></i>
132 <td>[% p.dateofbirth | $KohaDates %]</td>
133 <td>[% Categories.GetName( p.categorycode ) | html %] ([% p.categorycode | html %])</td>
134 <td>[% Branches.GetName( p.branchcode ) | html %]</td>
135 <td>[% p.dateexpiry | $KohaDates %]</td>
140 <fieldset class="action">
141 [% FOREACH p IN patrons %]
142 <input type="hidden" name="id" value="[% p.id | html %]" />
144 <input type="hidden" name="action" value="merge" />
145 <input id="merge-patrons" type="submit" value="Merge patrons" />
149 <div class="dialog alert">Error: Two or more patrons need to be selected for merging</div>
152 [% ELSIF action == 'merge' %]
155 [% IF error == 'INVALID_KEEPER' %]
156 <div class="dialog alert">Merge failed! The patron to keep was invalid.</div>
158 <div class="dialog alert">Merge failed! The following error was reported: [% error | html %].</div>
160 [% ELSIF !results.merged.keys.size %]
161 <div class="dialog alert">No valid patrons to merge were found.</div>
164 Patron records merged into <a href="moremember.pl?borrowernumber=[% keeper.id | uri %]">[% INCLUDE 'patron-title.inc' patron = keeper %]</a>
167 [% FOREACH pair IN results.merged.pairs %]
168 [% SET patron = pair.value.patron %]
170 <h5>[% INCLUDE 'patron-title.inc' %]</h5>
172 [% FOREACH r IN pair.value.updated.pairs %]
173 [% SET name = r.key %]
174 [% SET count = r.value %]
177 <span>[% count | html %] [% PROCESS display_names rs = name %] transferred.</span>
178 [% IF name == 'Reserve' %]
179 <strong>It is advisable to check for and resolve duplicate holds due to merging.</strong>
188 <a class="btn btn-default" href="moremember.pl?borrowernumber=[% keeper.id | html %]">View patron record</a>
195 <div class="modal" id="compareModal" tabindex="-1" role="dialog" aria-labelledby="compareModalLabel">
196 <div class="modal-dialog modal-lg" role="document">
197 <div class="modal-content">
198 <div class="modal-header">
199 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
200 <h4 class="modal-title" id="compareModalLabel">Compare patrons for merging</h4>
202 <div class="modal-body">
203 <div class="compare">
205 <div><strong>Name:</strong></div>
206 <div><strong>Initials:</strong></div>
207 <div><strong>Other name:</strong></div>
208 <div><strong>Library:</strong></div>
209 <div><strong>Card number:</strong></div>
210 <div><strong>Category:</strong></div>
212 <div><strong>Address line 1:</strong></div>
213 <div><strong>Address line 2:</strong></div>
214 <div><strong>City:</strong></div>
215 <div><strong>State:</strong></div>
216 <div><strong>ZIP/Postal code:</strong></div>
217 <div><strong>Country:</strong></div>
219 <div><strong>Registration date:</strong></div>
220 <div><strong>Renewal date:</strong></div>
221 <div><strong>Expiration date:</strong></div>
222 <div><strong>Date of birth:</strong></div>
223 <div><strong>Restricted:</strong></div>
224 <div><strong>Primary email:</strong></div>
225 <div><strong>Secondary email:</strong></div>
226 <div><strong>Primary phone:</strong></div>
227 <div><strong>Secondary phone:</strong></div>
228 <div><strong>Other phone:</strong></div>
229 <div><strong>Gender:</strong></div>
230 <div><strong>Updated on:</strong></div>
231 <div><strong>Username:</strong></div>
234 [% FOREACH p IN patrons %]
235 <div id="col-[% p.borrowernumber | html %]-orig"class="col[% loop.index | html %]">
236 <!-- <pre> block is unindented to avoid unwanted whitespace -->
238 [% IF ( p.surname ) %][% p.surname | html %], [% p.firstname | html %][% ELSE %]-[% END %]
239 [% IF ( p.initials ) %][% p.initials | html %][% ELSE %]-[% END %]
240 [% IF ( p.othernames ) %][% p.othernames | html %][% ELSE %]-[% END %]
241 [% IF ( p.branchcode ) %][% p.branchcode | html %][% ELSE %]-[% END %]
242 [% IF ( p.cardnumber ) %][% p.cardnumber | html %][% ELSE %]-[% END %]
243 [% IF ( p.categorycode ) %][% p.categorycode | html %][% ELSE %]-[% END %]
245 [% IF ( p.address ) %][% p.address | html %][% ELSE %]-[% END %]
246 [% IF ( p.address2 ) %][% p.address2 | html %][% ELSE %]-[% END %]
247 [% IF ( p.city ) %][% p.city | html %][% ELSE %]-[% END %]
248 [% IF ( p.state ) %][% p.state | html %][% ELSE %]-[% END %]
249 [% IF ( p.zipcode ) %][% p.zipcode | html %][% ELSE %]-[% END %]
250 [% IF ( p.country ) %][% p.country | html %][% ELSE %]-[% END %]
252 [% IF ( p.dateenrolled ) %][% p.dateenrolled | html %][% ELSE %]-[% END %]
253 [% IF ( p.date_renewed ) %][% p.date_renewed | html %][% ELSE %]-[% END %]
254 [% IF ( p.dateexpiry ) %][% p.dateexpiry | html %][% ELSE %]-[% END %]
255 [% IF ( p.dateofbirth ) %][% p.dateofbirth | html %][% ELSE %]-[% END %]
256 [% IF ( p.debarred ) %][% p.debarred | html %][% ELSE %]-[% END %]
257 [% IF ( p.email ) %][% p.email | html %][% ELSE %]-[% END %]
258 [% IF ( p.emailpro ) %][% p.emailpro | html %][% ELSE %]-[% END %]
259 [% IF ( p.phone ) %][% p.phone | html %][% ELSE %]-[% END %]
260 [% IF ( p.phonepro ) %][% p.phonepro | html %][% ELSE %]-[% END %]
261 [% IF ( p.mobile ) %][% p.mobile | html %][% ELSE %]-[% END %]
262 [% IF ( p.sex ) %][% p.sex | html %][% ELSE %]-[% END %]
263 [% IF ( p.updated_on ) %][% p.updated_on | html %][% ELSE %]-[% END %]
264 [% IF ( p.userid ) %][% p.userid | html %][% ELSE %]-[% END %]
268 [% FOREACH p IN patrons %]
269 <div id="col-[% p.borrowernumber | html %]-diff" class="col[% ( loop.index + 2 ) | html %]"><pre></pre></div>
273 <div class="modal-footer">
274 <button type="button" class="btn btn-default" id="submit-merge-form"><i class="fa fa-compress" aria-hidden="true"></i> Merge patrons</button>
275 <button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-remove" aria-hidden="true"></i> Close</button>
277 </div> <!-- /.modal-content -->
278 </div> <!-- /.modal-dialog -->
279 </div> <!-- /#compareModal -->
281 [% MACRO jsinclude BLOCK %]
282 [% INCLUDE 'str/members-menu.inc' %]
283 [% Asset.js("js/members-menu.js") | $raw %]
284 [% Asset.js("lib/jsdiff/jsdiff.min.js") | $raw %]
286 $(document).ready(function() {
287 var controls = $("#merge-patrons, #compare_patrons");
288 controls.prop('disabled', true);
289 $('#patron-merge-table').on('change', 'input', function() {
290 if ( $('.keeper:checked').length > 0 ) {
291 controls.prop('disabled', false);
293 controls.prop('disabled', true);
297 $("#compare_patrons").on("click", function(e){
299 $("#compareModal").modal("show");
302 $("#compareModal").on("shown.bs.modal", function(){
303 /* Find which column is the basis for merging */
304 var col0 = $(".keeper:checked").data("borrowernumber");
305 var col1 = $(".keeper:not(:checked)").data("borrowernumber");
306 /* Get the original patron data for comparison */
307 var diff1 = $("#col-" + col0 + "-orig pre").text();
308 var diff2 = $("#col-" + col1 + "-orig pre").text();
310 var diffs = diffString(diff2, diff1);
311 /* Load the diff HTML in the empty columns */
312 $(".col2 pre, .col3 pre").html(diffs);
315 $("#submit-merge-form").on("click", function(){
316 $("#patron-merge-form").submit();
323 [% INCLUDE 'intranet-bottom.inc' %]