Bug 27607: (QA follow-up) Make label match patron form: ZIP/Postal code
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / merge-patrons.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Branches %]
4 [% USE Categories %]
5 [% USE KohaDates %]
6 [% SET footerjs = 1 %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha &rsaquo; Patrons &rsaquo; Merge patron records</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 [% FILTER collapse %]
11     <style>
12         ins {
13             background-color: #e6ffe6;
14         }
15         del {
16             background-color: #ffe6e6;
17         }
18         .col0,
19         .col1 {
20             display: none;
21         }
22         .col3 ins,
23         .col2 del {
24             display: none;
25         }
26         #col-label,
27         .col2,
28         .col3 {
29             border-right: 1px solid #EEE;
30             flex-grow: 1;
31             margin-right:1em;
32         }
33         #col-label {
34             font-family: monospace;
35         }
36         #col-label div {
37             white-space: none;
38         }
39         .compare {
40             display: flex;
41         }
42         .modal-lg {
43             width: 90%;
44         }
45     </style>
46 [% END %]
47 </head>
48 <body id="pat_merge" class="pat">
49 [% INCLUDE 'header.inc' %]
50 [% INCLUDE 'patron-search.inc' %]
51
52 [% BLOCK display_names %]
53     [% SWITCH rs %]
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 %]
79     [% END %]
80 [% END %]
81
82 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> &rsaquo; Merge patron records</div>
83
84 <div class="main container-fluid">
85     <div class="row">
86         <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
87             <h3>Merge patron records</h3>
88
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
96                                 </button>
97                             </div>
98                         </div>
99                     [% END %]
100
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>
102
103                     <form type="post" action="merge-patrons.pl" id="patron-merge-form">
104                         <table id="patron-merge-table" class="datatable">
105                             <thead>
106                                 <tr>
107                                     <th>&nbsp;</th>
108                                     <th>Card</th>
109                                     <th>Name</th>
110                                     <th>Date of birth</th>
111                                     <th>Category</th>
112                                     <th>Library</th>
113                                     <th>Expires on</th>
114                                 </tr>
115                             </thead>
116
117                             <tbody>
118                                 [% FOREACH p IN patrons %]
119                                     <tr>
120                                         <td><input class="keeper" type="radio" name="keeper" value="[% p.id | html %]" data-borrowernumber="[% p.id | html %]" id="keeper_[% p.id | html %]" /></td>
121                                         <td>
122                                             <label for="keeper_[% p.id | html %]">
123                                                 <strong>[% p.cardnumber | html %]</strong>
124                                             </label>
125                                         </td>
126                                         <td>
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>
130                                             </a>
131                                         </td>
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>
136                                 [% END %]
137                             </tbody>
138                         </table>
139
140                         <fieldset class="action">
141                             [% FOREACH p IN patrons %]
142                                 <input type="hidden" name="id" value="[% p.id | html %]" />
143                             [% END %]
144                             <input type="hidden" name="action" value="merge" />
145                             <input id="merge-patrons" type="submit" value="Merge patrons" />
146                         </fieldset>
147
148                     [% ELSE %]
149                         <div class="dialog alert">Error: Two or more patrons need to be selected for merging</div>
150                     [% END %]
151                 </form>
152             [% ELSIF action == 'merge' %]
153                 <h4>Results</h4>
154                 [% IF error %]
155                     [% IF error == 'INVALID_KEEPER' %]
156                         <div class="dialog alert">Merge failed! The patron to keep was invalid.</div>
157                     [% ELSE %]
158                         <div class="dialog alert">Merge failed! The following error was reported: [% error | html %].</div>
159                     [% END %]
160                 [% ELSIF !results.merged.keys.size %]
161                     <div class="dialog alert">No valid patrons to merge were found.</div>
162                 [% ELSE %]
163                     <p>
164                         Patron records merged into <a href="moremember.pl?borrowernumber=[% keeper.id | uri %]">[% INCLUDE 'patron-title.inc' patron = keeper %]</a>
165                     </p>
166
167                     [% FOREACH pair IN results.merged.pairs %]
168                         [% SET patron = pair.value.patron %]
169
170                         <h5>[% INCLUDE 'patron-title.inc' %]</h5>
171
172                         [% FOREACH r IN pair.value.updated.pairs %]
173                             [% SET name = r.key %]
174                             [% SET count = r.value %]
175                             [% IF count %]
176                                 <p>
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>
180                                     [% END %]
181                                 </p>
182                             [% END %]
183                         [% END %]
184                     [% END %]
185                 [% END %]
186
187                 [% UNLESS error %]
188                     <a class="btn btn-default" href="moremember.pl?borrowernumber=[% keeper.id | html %]">View patron record</a>
189                 [% END %]
190             [% END %]
191         </div>
192     </div>
193
194     <!-- Modal -->
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">&times;</span></button>
200                     <h4 class="modal-title" id="compareModalLabel">Compare patrons for merging</h4>
201                 </div>
202                 <div class="modal-body">
203                     <div class="compare">
204                         <div id="col-label">
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>
211                             <br />
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>
218                             <br />
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>
232                         </div>
233
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 -->
237 <pre>
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 %]
244
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 %]
251
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 %]
265 </pre>
266                             </div>
267                         [% END %]
268                         [% FOREACH p IN patrons %]
269                             <div id="col-[% p.borrowernumber | html %]-diff" class="col[% ( loop.index + 2 ) | html %]"><pre></pre></div>
270                         [% END %]
271                     </div>
272                 </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>
276                 </div>
277             </div> <!-- /.modal-content -->
278         </div> <!-- /.modal-dialog -->
279     </div> <!-- /#compareModal -->
280
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 %]
285     <script>
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);
292             } else {
293                 controls.prop('disabled', true);
294             }
295         });
296
297         $("#compare_patrons").on("click", function(e){
298             e.preventDefault();
299             $("#compareModal").modal("show");
300         });
301
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();
309
310             var diffs = diffString(diff2, diff1);
311             /* Load the diff HTML in the empty columns */
312             $(".col2 pre, .col3 pre").html(diffs);
313         });
314
315         $("#submit-merge-form").on("click", function(){
316             $("#patron-merge-form").submit();
317         });
318     });
319
320     </script>
321 [% END %]
322
323 [% INCLUDE 'intranet-bottom.inc' %]