Bug 17097: Add a confirmation page when deleting a patron
[srvgit] / koha-tmpl / intranet-tmpl / prog / en / includes / members-toolbar.inc
1 [% USE Koha %]
2 [% USE Borrowers %]
3 [% USE Branches %]
4 [% USE AuthorisedValues %]
5 [% SET NorwegianPatronDBEnable = Koha.Preference( 'NorwegianPatronDBEnable' ) %]
6 <script type="text/javascript">
7 //<![CDATA[
8 $(document).ready(function(){
9     [% IF ( CAN_user_borrowers ) %]
10         [% IF ( NorwegianPatronDBEnable == 1 ) %]
11             $("#deletepatronlocal").click(function(){
12                 confirm_local_deletion();
13                 $(".btn-group").removeClass("open");
14                 return false;
15             });
16             $("#deletepatronremote").click(function(){
17                 confirm_remote_deletion();
18                 $(".btn-group").removeClass("open");
19                 return false;
20             });
21             $("#deletepatronboth").click(function(){
22                 confirm_both_deletion();
23                 $(".btn-group").removeClass("open");
24                 return false;
25             });
26         [% ELSE %]
27             $("#deletepatron").click(function(){
28                 window.location='/cgi-bin/koha/members/deletemem.pl?member=[% borrowernumber | url%]';
29             });
30         [% END %]
31         $("#renewpatron").click(function(){
32             confirm_reregistration();
33             $(".btn-group").removeClass("open");
34             return false;
35         });
36         [% IF ( is_child ) %]$("#updatechild").click(function(){
37             update_child();
38             $(".btn-group").removeClass("open");
39         });[% END %]
40     [% END %]
41     $("#updatechild, #patronflags, #renewpatron, #deletepatron, #exportbarcodes").tooltip();
42     $("#exportcheckins").click(function(){
43         export_barcodes();
44         $(".btn-group").removeClass("open");
45         return false;
46     });
47     $("#printsummary").click(function(){
48         printx_window("page");
49         $(".btn-group").removeClass("open");
50         return false;
51     });
52     $("#printslip").click(function(){
53         printx_window("slip");
54         $(".btn-group").removeClass("open");
55         return false;
56     });
57     $("#printquickslip").click(function(){
58         printx_window("qslip");
59         $(".btn-group").removeClass("open");
60         return false;
61     });
62     $("#print_overdues").click(function(){
63         window.open("/cgi-bin/koha/members/print_overdues.pl?borrowernumber=[% borrowernumber %]", "printwindow");
64         $(".btn-group").removeClass("open");
65         return false;
66     });
67     $("#searchtohold").click(function(){
68         searchToHold();
69         return false;
70     })
71 });
72 function confirm_local_deletion() {
73     var is_confirmed = window.confirm(_("Are you sure you want to delete this patron from the local database? This cannot be undone."));
74     if (is_confirmed) {
75         window.location='/cgi-bin/koha/members/deletemem.pl?member=[% borrowernumber %]&deletelocal=true&deleteremote=false';
76     }
77 }
78 function confirm_remote_deletion() {
79     var is_confirmed = window.confirm(_("Are you sure you want to delete this patron from the Norwegian national patron database? This cannot be undone."));
80     if (is_confirmed) {
81         window.location='/cgi-bin/koha/members/deletemem.pl?member=[% borrowernumber %]&deletelocal=false&deleteremote=true';
82     }
83 }
84 function confirm_both_deletion() {
85     var is_confirmed = window.confirm(_("Are you sure you want to delete this patron both from the local database and from the Norwegian national patron database? This cannot be undone."));
86     if (is_confirmed) {
87         window.location='/cgi-bin/koha/members/deletemem.pl?member=[% borrowernumber %]&deletelocal=true&deleteremote=true';
88     }
89 }
90
91 [% IF ( is_child ) %]function confirm_updatechild() {
92     var is_confirmed = window.confirm(_("Are you sure you want to update this child to an Adult category?  This cannot be undone."));
93     if (is_confirmed) {
94         window.location='/cgi-bin/koha/members/update-child.pl?op=update&borrowernumber=[% borrowernumber %]&catcode=[% catcode %]&catcode_multi=[% CATCODE_MULTI %]';
95     }
96 }
97
98 function update_child() {
99     [% IF ( CATCODE_MULTI ) %]
100         window.open('/cgi-bin/koha/members/update-child.pl?op=multi&borrowernumber=[% borrowernumber %]','UpdateChild','width=400,height=300,toolbar=no,scrollbars=yes,resizable=yes');
101     [% ELSE %]
102         confirm_updatechild();
103     [% END %]
104 }
105 [% END %]
106
107 function confirm_reregistration() {
108     var is_confirmed = window.confirm(_("Are you sure you want to renew this patron's registration?"));
109     if (is_confirmed) {
110     window.location = '/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% borrowernumber %]&amp;destination=[% destination %]&amp;reregistration=y';
111     }
112 }
113 function export_barcodes() {
114     window.open('/cgi-bin/koha/members/readingrec.pl?borrowernumber=[% borrowernumber %]&amp;op=export_barcodes');
115 }
116 var slip_re = /slip/;
117 function printx_window(print_type) {
118     var handler = print_type.match(slip_re) ? "printslip" : "summary-print";
119     window.open("/cgi-bin/koha/members/" + handler + ".pl?borrowernumber=[% borrowernumber %]&amp;print=" + print_type, "printwindow");
120     return false;
121 }
122 function searchToHold(){
123     var date = new Date();
124     date.setTime(date.getTime() + (10 * 60 * 1000));
125     $.cookie("holdfor", "[% borrowernumber %]", { path: "/", expires: date });
126     location.href="/cgi-bin/koha/catalogue/search.pl";
127 }
128 //]]>
129 </script>
130
131 <div id="toolbar" class="btn-toolbar">
132     [% IF ( CAN_user_borrowers ) %]
133         [% IF ( guarantor ) %]
134             <a id="editpatron" class="btn btn-small" href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% borrowernumber %]&amp;guarantorid=[% guarantorborrowernumber %]&amp;categorycode=[% categorycode %]">
135         [% ELSE %]
136             <a id="editpatron" class="btn btn-small" href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% borrowernumber %]&amp;categorycode=[% categorycode %]">
137         [% END %]
138         <i class="fa fa-pencil"></i> Edit</a>
139     [% END %]
140
141     [% IF ( CAN_user_borrowers ) %]
142         [% IF ( adultborrower AND activeBorrowerRelationship ) %]
143             <a id="addchild" class="btn btn-small" href="/cgi-bin/koha/members/memberentry.pl?op=add&amp;guarantorid=[% borrowernumber %]"><i class="fa fa-plus"></i> Add child</a>
144         [% END %]
145         [% IF ( CAN_user_borrowers ) %]
146             <a id="changepassword" class="btn btn-small" href="/cgi-bin/koha/members/member-password.pl?member=[% borrowernumber %]"><i class="fa fa-lock"></i> Change password</a>
147         [% END %]
148         <a id="duplicate" class="btn btn-small" href="/cgi-bin/koha/members/memberentry.pl?op=duplicate&amp;borrowernumber=[% borrowernumber %]&amp;categorycode=[% categorycode %]"><i class="fa fa-copy"></i> Duplicate</a>
149     [% END %]
150
151     <div class="btn-group">
152         <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="fa fa-print"></i> Print <span class="caret"></span></button>
153             <ul class="dropdown-menu">
154                 [% IF ( CAN_user_borrowers ) %]<li><a id="printsummary" href="#">Print summary</a></li>[% END %]
155                 <li><a id="printslip" href="#">Print slip</a></li>
156                 <li><a id="printquickslip" href="#">Print quick slip</a></li>
157                 [% IF Borrowers.HasOverdues( borrowernumber ) %]
158                     <li><a id="print_overdues" href="#">Print overdues</a></li>
159                 [% END %]
160             </ul>
161     </div>
162
163     [% IF ( CAN_user_reserveforothers ) %]
164         <a id="searchtohold" class="btn btn-small" href="#"><i class="fa fa-search"></i> Search to hold</a>
165     [% END %]
166
167     <a id="addnewmessageLabel" href="#add_message_form" data-toggle="modal" class="btn btn-small"><i class="fa fa-comment-o"></i> Add message</a>
168
169          <div class="btn-group">
170         <button class="btn btn-small dropdown-toggle" data-toggle="dropdown">More <span class="caret"></span></button>
171             <ul class="dropdown-menu">
172                 [% IF ( CAN_user_borrowers ) %]
173                     <li><a id="renewpatron" href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% borrowernumber %]&amp;destination=[% destination %]&amp;reregistration=y">Renew patron</a></li>
174                 [% ELSE %]
175                     <li class="disabled"><a data-toggle="tooltip" data-placement="left" title="You are not authorized to renew patrons" id="renewpatron" href="#">Renew patron</a></li>
176                 [% END %]
177                 [% IF ( CAN_user_permissions ) %]
178                     <li><a id="patronflags" href="/cgi-bin/koha/members/member-flags.pl?member=[% borrowernumber %]">Set permissions</a></li>
179                 [% ELSE %]
180                     <li class="disabled"><a data-toggle="tooltip" data-placement="left" title="You are not authorized to set permissions" id="patronflags" href="#">Set permissions</a></li>
181                 [% END %]
182                 [% IF CAN_user_borrowers && useDischarge %]
183                     <li><a href="/cgi-bin/koha/members/discharge.pl?borrowernumber=[% borrowernumber %]">Discharge</a></li>
184                 [% END %]
185                 [% IF ( CAN_user_borrowers ) %]
186                     [% IF ( NorwegianPatronDBEnable == 1 ) %]
187                         <li><a id="deletepatronlocal" href="#">Delete local</a></li>
188                         <li><a id="deletepatronremote" href="#">Delete remote</a></li>
189                         <li><a id="deletepatronboth" href="#">Delete local and remote</a></li>
190                     [% ELSE %]
191                         <li><a id="deletepatron" href="#">Delete</a></li>
192                     [% END %]
193                 [% ELSE %]
194                     <li class="disabled"><a data-toggle="tooltip" data-placement="left" title="You are not authorized to delete patrons" id="deletepatron" href="#">Delete</a></li>
195                 [% END %]
196                 [% IF ( is_child ) %]
197                     <li><a id="updatechild" href="#">Update child to adult patron</a></li>
198                 [% ELSE %]
199                     <li class="disabled"><a data-toggle="tooltip" data-placement="left" title="Patron is an adult" id="updatechild" href="#">Update child to adult patron</a></li></li>
200                 [% END %]
201                 [% IF Koha.Preference('intranetreadinghistory') %]
202                     [%IF ( privacy == 2 ) %]
203                         <li class="disabled"><a data-toggle="tooltip" data-placement="left" title="Not allowed by patron's privacy settings" id="exportbarcodes" href="#">Export today's checked in barcodes</a></li>
204                     [% ELSE %]
205                         <li><a id="exportcheckins" href="#">Export today's checked in barcodes</a></li>
206                     [% END %]
207                 [% END %]
208             </ul>
209     </div>
210 </div>
211
212 <!-- Modal -->
213 <div id="add_message_form" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="addnewmessageLabel" aria-hidden="true">
214     <div class="modal-body">
215         <form method="post" action="/cgi-bin/koha/circ/add_message.pl" id="message_form" name="message_f">
216         <fieldset id="borrower_messages" class="brief">
217             <legend>Leave a message</legend>
218             <ol>
219                 <li>
220                     <label for="message_type">Add a message for:</label>
221                     <select name="message_type" id="message_type">
222                         <option value="L">Staff - Internal note</option>
223                         <option value="B">OPAC - [% firstname %] [% surname %]</option>
224                     </select>
225                 </li>
226                 [% bor_notes = AuthorisedValues.Get( 'BOR_NOTES' ) %]
227                 [% IF bor_notes %]
228                     <li>
229                         <label for="type">Predefined notes: </label>
230                         <select name="type" id="type" onchange="this.form.borrower_message.value=this.options[this.selectedIndex].value;">
231                             <option value="">Select note</option>
232                             [% FOREACH bor_note IN bor_notes %]
233                                 <option value="[% bor_note.lib %]">[% bor_note.lib %]</option>
234                             [% END %]
235                         </select>
236                     </li>
237                 [% END %]
238                 <li>
239                     <textarea rows="3" cols="60" name="borrower_message" id="borrower_message" ></textarea>
240                 </li>
241             </ol>
242             <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
243             <input type="hidden" name="batch" value="[% batch %]" />
244             <input type="hidden" name="branchcode" value="[% LoginBranchcode %]" />
245         </fieldset>
246     </div>
247     <div class="modal-footer">
248         <fieldset class="action">
249             <input type="submit" value="Save" /> </form><a href="#" class="cancel" data-dismiss="modal" aria-hidden="true">Cancel</a>
250         </fieldset>
251     </div>
252 </div>