Bug 16127 - Add discharge menu item to patron toolbar
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / includes / members-toolbar.inc
1 [% USE Koha %]
2 [% USE Borrowers %]
3 [% SET NorwegianPatronDBEnable = Koha.Preference( 'NorwegianPatronDBEnable' ) %]
4 <script type="text/javascript">
5 //<![CDATA[
6 $(document).ready(function(){
7     [% IF ( CAN_user_borrowers ) %]
8         [% IF ( NorwegianPatronDBEnable == 1 ) %]
9             $("#deletepatronlocal").click(function(){
10                 confirm_local_deletion();
11                 $(".btn-group").removeClass("open");
12                 return false;
13             });
14             $("#deletepatronremote").click(function(){
15                 confirm_remote_deletion();
16                 $(".btn-group").removeClass("open");
17                 return false;
18             });
19             $("#deletepatronboth").click(function(){
20                 confirm_both_deletion();
21                 $(".btn-group").removeClass("open");
22                 return false;
23             });
24         [% ELSE %]
25             $("#deletepatron").click(function(){
26                 confirm_deletion();
27                 $(".btn-group").removeClass("open");
28                 return false;
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_deletion() {
73     var is_confirmed = window.confirm(_("Are you sure you want to delete this patron? This cannot be undone."));
74     if (is_confirmed) {
75         window.location='/cgi-bin/koha/members/deletemem.pl?member=[% borrowernumber %]';
76     }
77 }
78 function confirm_local_deletion() {
79     var is_confirmed = window.confirm(_("Are you sure you want to delete this patron from the local database? This cannot be undone."));
80     if (is_confirmed) {
81         window.location='/cgi-bin/koha/members/deletemem.pl?member=[% borrowernumber %]&deletelocal=true&deleteremote=false';
82     }
83 }
84 function confirm_remote_deletion() {
85     var is_confirmed = window.confirm(_("Are you sure you want to delete this patron 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=false&deleteremote=true';
88     }
89 }
90 function confirm_both_deletion() {
91     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."));
92     if (is_confirmed) {
93         window.location='/cgi-bin/koha/members/deletemem.pl?member=[% borrowernumber %]&deletelocal=true&deleteremote=true';
94     }
95 }
96
97 [% IF ( is_child ) %]function confirm_updatechild() {
98     var is_confirmed = window.confirm(_("Are you sure you want to update this child to an Adult category?  This cannot be undone."));
99     if (is_confirmed) {
100         window.location='/cgi-bin/koha/members/update-child.pl?op=update&borrowernumber=[% borrowernumber %]&catcode=[% catcode %]&catcode_multi=[% CATCODE_MULTI %]';
101     }
102 }
103
104 function update_child() {
105     [% IF ( CATCODE_MULTI ) %]
106         window.open('/cgi-bin/koha/members/update-child.pl?op=multi&borrowernumber=[% borrowernumber %]','UpdateChild','width=400,height=300,toolbar=no,scrollbars=yes,resizable=yes');
107     [% ELSE %]
108         confirm_updatechild();
109     [% END %]
110 }
111 [% END %]
112
113 function confirm_reregistration() {
114     var is_confirmed = window.confirm(_("Are you sure you want to renew this patron's registration?"));
115     if (is_confirmed) {
116     window.location = '/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% borrowernumber %]&amp;destination=[% destination %]&amp;reregistration=y';
117     }
118 }
119 function export_barcodes() {
120     window.open('/cgi-bin/koha/members/readingrec.pl?borrowernumber=[% borrowernumber %]&amp;op=export_barcodes');
121 }
122 var slip_re = /slip/;
123 function printx_window(print_type) {
124     var handler = print_type.match(slip_re) ? "printslip" : "summary-print";
125     window.open("/cgi-bin/koha/members/" + handler + ".pl?borrowernumber=[% borrowernumber %]&amp;print=" + print_type, "printwindow");
126     return false;
127 }
128 function searchToHold(){
129     var date = new Date();
130     date.setTime(date.getTime() + (10 * 60 * 1000));
131     $.cookie("holdfor", "[% borrowernumber %]", { path: "/", expires: date });
132     location.href="/cgi-bin/koha/catalogue/search.pl";
133 }
134 //]]>
135 </script>
136
137 <div id="toolbar" class="btn-toolbar">
138     [% IF ( CAN_user_borrowers ) %]
139         [% IF ( guarantor ) %]
140             <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 %]">
141         [% ELSE %]
142             <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 %]">
143         [% END %]
144         <i class="fa fa-pencil"></i> Edit</a>
145     [% END %]
146
147     [% IF ( CAN_user_borrowers ) %]
148         [% IF ( adultborrower AND activeBorrowerRelationship ) %]
149             <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>
150         [% END %]
151         [% IF ( CAN_user_borrowers ) %]
152             <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>
153         [% END %]
154         <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>
155     [% END %]
156
157     <div class="btn-group">
158         <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="fa fa-print"></i> Print <span class="caret"></span></button>
159             <ul class="dropdown-menu">
160                 [% IF ( CAN_user_borrowers ) %]<li><a id="printsummary" href="#">Print summary</a></li>[% END %]
161                 <li><a id="printslip" href="#">Print slip</a></li>
162                 <li><a id="printquickslip" href="#">Print quick slip</a></li>
163                 [% IF Borrowers.HasOverdues( borrowernumber ) %]
164                     <li><a id="print_overdues" href="#">Print overdues</a></li>
165                 [% END %]
166             </ul>
167     </div>
168
169     [% IF ( CAN_user_reserveforothers ) %]
170         <a id="searchtohold" class="btn btn-small" href="#"><i class="fa fa-search"></i> Search to hold</a>
171     [% END %]
172
173          <div class="btn-group">
174         <button class="btn btn-small dropdown-toggle" data-toggle="dropdown">More <span class="caret"></span></button>
175             <ul class="dropdown-menu">
176                 [% IF ( CAN_user_borrowers ) %]
177                     <li><a id="renewpatron" href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% borrowernumber %]&amp;destination=[% destination %]&amp;reregistration=y">Renew patron</a></li>
178                 [% ELSE %]
179                     <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>
180                 [% END %]
181                 [% IF ( CAN_user_permissions ) %]
182                     <li><a id="patronflags" href="/cgi-bin/koha/members/member-flags.pl?member=[% borrowernumber %]">Set permissions</a></li>
183                 [% ELSE %]
184                     <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>
185                 [% END %]
186                 [% IF CAN_user_borrowers && useDischarge %]
187                     <li><a href="/cgi-bin/koha/members/discharge.pl?borrowernumber=[% borrowernumber %]">Discharge</a></li>
188                 [% END %]
189                 [% IF ( CAN_user_borrowers ) %]
190                     [% IF ( NorwegianPatronDBEnable == 1 ) %]
191                         <li><a id="deletepatronlocal" href="#">Delete local</a></li>
192                         <li><a id="deletepatronremote" href="#">Delete remote</a></li>
193                         <li><a id="deletepatronboth" href="#">Delete local and remote</a></li>
194                     [% ELSE %]
195                         <li><a id="deletepatron" href="#">Delete</a></li>
196                     [% END %]
197                 [% ELSE %]
198                     <li class="disabled"><a data-toggle="tooltip" data-placement="left" title="You are not authorized to delete patrons" id="deletepatron" href="#">Delete</a></li>
199                 [% END %]
200                 [% IF ( is_child ) %]
201                     <li><a id="updatechild" href="#">Update child to adult patron</a></li>
202                 [% ELSE %]
203                     <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>
204                 [% END %]
205                 [% IF Koha.Preference('intranetreadinghistory') %]
206                     [%IF ( privacy == 2 ) %]
207                         <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>
208                     [% ELSE %]
209                         <li><a id="exportcheckins" href="#">Export today's checked in barcodes</a></li>
210                     [% END %]
211                 [% END %]
212             </ul>
213     </div>
214 </div>