Bug 9302: Add error message if keeper patron is invalid
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / merge-patrons.tt
1 [% USE Asset %]
2 [% USE Branches %]
3 [% USE Categories %]
4 [% USE KohaDates %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha &rsaquo; Patrons &rsaquo; Merge patron records</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9
10 </head>
11 <body id="pat_merge" class="pat">
12 [% INCLUDE 'header.inc' %]
13 [% INCLUDE 'patron-search.inc' %]
14
15 [% BLOCK display_names %]
16     [% SWITCH rs %]
17         [% CASE 'Accountline'           %]account lines
18         [% CASE 'ArticleRequest'        %]article requests
19         [% CASE 'BorrowerAttribute'     %]extended patron attributes
20         [% CASE 'BorrowerDebarment'     %]patron restrictions
21         [% CASE 'BorrowerFile'          %]patrons files
22         [% CASE 'BorrowerModification'  %]patron modification requests
23         [% CASE 'ClubEnrollment'        %]club enrollments
24         [% CASE 'Issue'                 %]checkouts
25         [% CASE 'ItemsLastBorrower'     %]marks as last borrower of item
26         [% CASE 'Linktracker'           %]tracked link clicks
27         [% CASE 'Message'               %]patron messages
28         [% CASE 'MessageQueue'          %]patron notices
29         [% CASE 'OldIssue'              %]previous checkouts
30         [% CASE 'OldReserve'            %]filled holds
31         [% CASE 'Rating'                %]ratings
32         [% CASE 'Reserve'               %]current holds
33         [% CASE 'Review'                %]reviews
34         [% CASE 'Statistic'             %]statistics
35         [% CASE 'SearchHistory'         %]historical searches
36         [% CASE 'Suggestion'            %]purchase suggestions
37         [% CASE 'TagAll'                %]tags
38         [% CASE 'Virtualshelfcontent'   %]list items
39         [% CASE 'Virtualshelfshare'     %]list shares
40         [% CASE 'Virtualshelve'         %]lists
41         [% CASE %][% rs %]
42     [% END %]
43 [% END %]
44
45 <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>
46
47 <div class="main container-fluid">
48     <div class="row">
49         <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
50             <h3>Merge patron records</h3>
51
52             [% IF action == 'show' %]
53                 [% IF patrons.count > 1 %]
54                     <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>
55                     <form type="post" action="merge-patrons.pl">
56                         <table id="patron-merge-table" class="datatable">
57                             <thead>
58                                 <tr>
59                                     <th>&nbsp;</th>
60                                     <th>Card</th>
61                                     <th>Name</th>
62                                     <th>Date of birth</th>
63                                     <th>Category</th>
64                                     <th>Library</th>
65                                     <th>Expires on</th>
66                                 </tr>
67                             </thead>
68
69                             <tbody>
70                                 [% FOREACH p IN patrons %]
71                                     <tr>
72                                         <td><input class='keeper' type='radio' name='keeper' value='[% p.id %]' /></td>
73                                         <td>[% p.cardnumber | html %]</td>
74                                         <td>[% INCLUDE 'patron-title.inc' patron = p %]</td>
75                                         <td>[% p.dateofbirth | $KohaDates %]</td>
76                                         <td>[% Categories.GetName( p.categorycode ) %] ([% p.categorycode %])</td>
77                                         <td>[% Branches.GetName( p.branchcode ) %]</td>
78                                         <td>[% p.dateexpiry | $KohaDates %]</td>
79                                 [% END %]
80                             </tbody>
81                         </table>
82
83                         [% FOREACH p IN patrons %]
84                             <input type="hidden" name="id" value="[% p.id %]" />
85                         [% END %]
86
87                         <p/>
88
89                         <input type="hidden" name="action" value="merge" />
90                         <input id="merge-patrons" type="submit" value="Merge patrons" />
91                     [% ELSE %]
92                         <div class="dialog alert">Error: Two or more patrons need to be selected for merging</div>
93                     [% END %]
94                 </form>
95             [% ELSIF action == 'merge' %]
96                 <h4>Results</h4>
97                 [% IF error %]
98                     [% IF error == 'INVALID_KEEPER' %]
99                         <div class="dialog alert">Merge failed! The patron to keep was invalid.</div>
100                     [% ELSE %]
101                         <div class="dialog alert">Merge failed! The following error was reported: [% error %].</div>
102                     [% END %]
103                 [% ELSIF !results.merged.keys.size %]
104                     <div class="dialog alert">No valid patrons to merge were found.</div>
105                 [% ELSE %]
106                     <p>
107                         Patron records merged into <a href="moremember.pl?borrowernumber=[% keeper.id %]">[% INCLUDE 'patron-title.inc' patron = keeper %]</a>
108                     </p>
109
110                     [% FOREACH pair IN results.merged.pairs %]
111                         [% SET patron = pair.value.patron %]
112
113                         <h5>[% INCLUDE 'patron-title.inc' %]</h5>
114
115                         [% FOREACH r IN pair.value.updated.pairs %]
116                             [% SET name = r.key %]
117                             [% SET count = r.value %]
118                             [% IF count %]
119                                 <p>
120                                     <span>[% count %] [% PROCESS display_names rs = name %] transferred.</span>
121                                     [% IF name == 'Reserve' %]
122                                         <strong>It is advisable to check for and resolve duplicate holds due to merging.</strong>
123                                     [% END %]
124                                 </p>
125                             [% END %]
126                         [% END %]
127                     [% END %]
128                 [% END %]
129
130                 [% UNLESS error %]
131                     <a class="btn btn-default btn-sm" href="moremember.pl?borrowernumber=[% keeper.id %]">View patron record</a>
132                 [% END %]
133             [% END %]
134         </div>
135     </div>
136
137 [% MACRO jsinclude BLOCK %]
138     [% Asset.js("js/members-menu.js") %]
139
140     <script>
141     $(document).ready(function() {
142         $('#merge-patrons').prop('disabled', true);
143         $('#patron-merge-table').on('change', 'input', function() {
144             if ( $('.keeper:checked').length > 0 ) {
145                 $('#merge-patrons').prop('disabled', false);
146             } else {
147                 $('#merge-patrons').prop('disabled', true);
148             }
149         });
150     });
151     </script>
152 [% END %]
153
154 [% INCLUDE 'intranet-bottom.inc' %]