Bug 23590: Add the ability to notify a new manager
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / suggestion / suggestion.tt
1 [% PROCESS 'i18n.inc' %]
2 [% USE raw %]
3 [% USE Asset %]
4 [% USE Branches %]
5 [% USE AuthorisedValues %]
6 [% USE KohaDates %]
7 [% USE Price %]
8 [% USE ColumnsSettings %]
9 [% SET footerjs = 1 %]
10 [% INCLUDE 'doc-head-open.inc' %]
11 <title>Koha &rsaquo; Acquisitions  &rsaquo;
12     [% IF op == 'save' %]
13         [% IF ( suggestionid ) %]
14             Suggestions &rsaquo;  Edit suggestion #[% suggestionid | html %]
15         [% ELSE %]
16             Suggestions &rsaquo; Add suggestion
17         [% END %]
18     [% ELSIF ( op == 'show' ) %]
19            Suggestions &rsaquo; Show suggestion #[% suggestionid | html %]
20     [% ELSE %]
21         Suggestions management
22     [% END %]
23 </title>
24 [% INCLUDE 'doc-head-close.inc' %]
25 [% IF op == 'else' %]
26     <style>
27         h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief ol { display : none; }
28         .overlay { top: 180px; left: 50%; position: absolute; margin-left: -100px; width: 200px; text-align: center; display: none; margin-top: -10px; background: #eeffd4; padding: .5em; color: #000; } div.note { background: transparent none; border-style: dotted; border-width: 1px 0 0 0; font-size : 90%; padding: 2px 0 0 0; } div.note i { color: #CCC; }
29     </style>
30 [% END %]
31 </head>
32
33 <body id="acq_suggestion" class="acq">
34 [% INCLUDE 'header.inc' %]
35 [% INCLUDE 'cat-search.inc' %]
36 <div id="breadcrumbs">
37     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo;
38     [% IF op == 'save' %]
39         [% IF ( suggestionid ) %]
40             <a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a> &rsaquo;  Edit suggestion #[% suggestionid | html %]
41         [% ELSE %]
42             <a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a> &rsaquo; Add suggestion
43         [% END %]
44     [% ELSIF ( op == 'show' ) %]
45            <a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a> &rsaquo; Show suggestion #[% suggestionid | html %]
46     [% ELSE %]
47         Suggestions management
48     [% END %]
49 </div>
50
51 [% IF ( op == 'show' ) %]
52     <div class="main container-fluid">
53         <div class="row">
54             <div class="col-md-8 col-md-offset-2">
55
56     <div id="toolbar" class="btn-toolbar">
57         <a class="btn btn-default" id="editsuggestion" href="suggestion.pl?op=edit&amp;suggestionid=[% suggestionid | html %]"><i class="fa fa-pencil"></i> Edit</a>
58         <a class="btn btn-default deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a>
59     </div>
60
61     <fieldset class="rows">
62       <legend>Bibliographic information</legend>
63       <ol>
64             [% IF ( title ) %]
65                 <li>
66                     <span class="label">Title:</span>
67                     [% IF suggestion.biblionumber %]
68                         <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% suggestion.biblionumber | uri %]">[% suggestion.title | html %]</a>
69                     [% ELSE %]
70                         [% title | html %]
71                     [% END %]
72                 </li>
73             [% END %]
74             [% IF ( author ) %]
75                 <li>
76                     <span class="label">Author:</span>
77                     [% author | html %]
78                 </li>
79             [% END %]
80             [% IF ( copyrightdate ) %]
81                 <li>
82                     <span class="label">Copyright date:</span>
83                     [% copyrightdate | html %]
84                 </li>
85             [% END %]
86             [% IF ( isbn ) %]
87                 <li>
88                     <span class="label">ISBN or ISSN or other standard number:</span>
89                     [% isbn | html %]
90                 </li>
91             [% END %]
92             [% IF ( publishercode ) %]
93                 <li>
94                     <span class="label">Publisher:</span>
95                     [% publishercode | html %]
96                 </li>
97             [% END %]
98             [% IF ( place ) %]
99                 <li>
100                     <span class="label">Publication place:</span>
101                     [% place | html %]
102                 </li>
103             [% END %]
104             [% IF ( collectiontitle ) %]
105                 <li>
106                     <span class="label">Collection title:</span>
107                     [% collectiontitle | html %]
108                 </li>
109             [% END %]
110             [% IF ( itemtype ) %]
111                 <li>
112                     <span class="label">Document type:</span>
113                     [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', itemtype, 0 ) | html %]
114                 </li>
115             [% END %]
116         [% IF ( patron_reason_loop ) %]
117           <li><span class="label">Reason for suggestion: </span>
118             [% FOREACH patron_reason_loo IN patron_reason_loop %]
119               [% IF patron_reason_loo.authorised_value == patronreason %][% patron_reason_loo.lib | html %][% END %]
120             [% END %]
121           </li>
122         [% END %]
123             [% IF ( note ) %]
124                 <li>
125                     <span class="label">Notes:</span>
126                     [% note | html %]
127                 </li>
128             [% END %]
129       </ol>
130     </fieldset>
131     <fieldset class="rows"> <legend>Suggestion management</legend>
132       <ol>
133         <li>
134           <span class="label">Status:</span>
135           [% SET status_found = 0 %]
136           [% IF ( STATUS == 'ASKED' ) %]
137               Pending
138               [% SET status_found = 1 %]
139           [% ELSIF ( STATUS == 'ACCEPTED' ) %]
140               Accepted
141               [% SET status_found = 1 %]
142           [% ELSIF ( STATUS == 'CHECKED' ) %]
143               Checked
144               [% SET status_found = 1 %]
145           [% ELSIF ( STATUS == 'REJECTED' ) %]
146               Rejected
147               [% SET status_found = 1 %]
148           [% ELSIF ( STATUS == 'ORDERED' ) %]
149               Ordered
150               [% SET status_found = 1 %]
151           [% ELSIF ( STATUS == 'AVAILABLE' ) %]
152               Available
153               [% SET status_found = 1 %]
154           [% ELSE %]
155               [% FOREACH s IN SuggestionStatuses %]
156                   [% IF STATUS == s.authorised_value %]
157                       [% s.lib | html %]
158                       [% SET status_found = 1 %]
159                   [% END %]
160               [% END %]
161           [% END %]
162
163         </li>
164         <li>
165           <table>
166             <thead><tr><th>&nbsp;</th><th>Date</th><th>By</th></tr></thead>
167             <tbody>
168             <tr>
169                 <th>[% tp('purchase suggestion created by', 'Created by:') | html %]</th>
170                 <td>[% suggesteddate | $KohaDates %]</td>
171                 <td>
172                     [% IF ( suggestedby_patron.borrowernumber ) %]
173                         <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestedby_patron.borrowernumber | uri %]">[% suggestedby_patron.surname | html %], [% suggestedby_patron.firstname | html %] ([% suggestedby_patron.cardnumber | html %])</a>
174                         [% Branches.GetName( suggestedby_patron.branchcode ) | html %] ([% suggestedby_patron.category.description | html %])
175                     [% END %]
176                 </td>
177             </tr>
178             <tr>
179                 <th>Managed by:</th>
180                 <td>[% manageddate | $KohaDates %]</td>
181                 <td>
182                         [% IF ( managedby_patron.borrowernumber ) %]
183                             <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% managedby_patron.borrowernumber | uri %]">[% managedby_patron.surname | html %], [% managedby_patron.firstname | html %] ([% suggestedby_patron.cardnumber | html %])</a>
184                             [% Branches.GetName( managedby_patron.branchcode ) | html %] ([% managedby_patron.category.description | html %])
185                         [% END %]
186                 </td>
187             </tr>
188             <tr>
189                 <th>Accepted on:</th>
190                 <td>[% accepteddate | $KohaDates %]</td>
191                 <td>
192                     [% IF ( acceptedby_patron.borrowernumber ) %]
193                         <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% acceptedby_patron.borrowernumber | uri %]">[% acceptedby_patron.surname | html %], [% acceptedby_patron.firstname | html %] ([% suggestedby_patron.cardnumber | html %])</a>
194                         [% Branches.GetName( acceptedby_patron.branchcode ) | html %] ([% acceptedby_patron.category.description | html %])
195                     [% END %]
196                 </td>
197             </tr>
198             </tbody>
199         </table></li></ol>
200     </fieldset>
201     <fieldset class="rows"> <legend>Acquisition information</legend>
202       <ol>
203         <li>
204           <span class="label">Library:</span> [% Branches.GetName( branchcode ) | html %]
205         </li>
206         <li>
207           <span class="label">Fund:</span> [% budgetname | html %]
208         </li>
209         <li>
210           <span class="label">Copies:</span>[% quantity | html %]
211         </li>
212         <li>
213           <span class="label">Currency:</span>[% currency | html %]
214         </li>
215         <li>
216           <span class="label">Price:</span>[% price | $Price %]
217         </li>
218         <li>
219           <span class="label">Total</span>[% total | $Price %]
220         </li>
221       </ol>
222     </fieldset>
223
224     <fieldset class="action">
225         <a href="suggestion.pl">&lt;&lt; Back to suggestions</a>
226     </fieldset>
227
228     </div>
229     </div>
230 </div>
231 [% ELSE %]
232
233 [% IF op == 'save' %]
234     <div class="main container-fluid">
235         <div class="row">
236             <div class="col-md-8 col-md-offset-2">
237 [% ELSE %]
238     <div class="main container-fluid">
239         <div class="row">
240             <div class="col-sm-10 col-sm-push-2">
241                 <main>
242
243 [% END %]
244
245 [% IF op == 'save' %]
246     [% FOR m IN messages %]
247         <div class="dialog [% m.type | html %]">
248             [% SWITCH m.code %]
249             [% CASE 'biblio_exists' %]
250                 A similar document already exists: <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.id | uri %]">[% m.title | html %]</a>. Click on "Confirm your suggestion" to ignore this message.
251             [% CASE %]
252                 [% m.code | html %]
253             [% END %]
254         </div>
255     [% END %]
256     <form id="add_edit" action="suggestion.pl" method="post" class="validated">
257     <input type="hidden" name="redirect" id="redirect" value="[% redirect | html %]" />
258     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber | html %]" />
259     [% IF ( suggestionid ) %]
260         <h1>Edit purchase suggestion #[% suggestionid | html %]</h1>
261         <input type="hidden" name="suggestionid" value="[% suggestionid | html %]"/>
262     [% ELSE %]
263         <h1>Enter a new purchase suggestion</h1>
264     [% END %]
265     <fieldset class="rows"> <legend>Bibliographic information</legend><ol>
266         <li>
267             <label for="title" class="required">Title:</label>
268             <input type="text" id="title" name="title" size="80" maxlength="255" value="[% title | html %]" required="required" class="required" />
269             <span class="required">Required</span>
270         </li>
271         <li><label for="author">Author:</label><input type="text" id="author" name="author" size="50" maxlength="80" value="[% author | html %]"/></li>
272         <li><label for="copyrightdate">Copyright date:</label><input type="text" id="copyrightdate" name="copyrightdate" size="4" maxlength="4" value="[% copyrightdate | html %]" /></li>
273         <li><label for="isbn">ISBN or ISSN or other standard number:</label><input type="text" id="isbn" name="isbn" size="50" maxlength="80" value="[% isbn | html %]"/></li>
274         <li><label for="publishercode">Publisher:</label><input type="text" id="publishercode" name="publishercode" size="50" maxlength="80" value="[% publishercode | html %]"/></li>
275         <li><label for="place">Publication place:</label><input type="text" id="place" name="place" size="50" maxlength="80" value="[% place | html %]"/></li>
276         <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" size="50" maxlength="80" value="[% collectiontitle | html %]"/></li>
277         <li><label for="itemtype">Document type:</label>
278             [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20, default=itemtype %]
279         </li>
280         [% IF patron_reason_loop %]
281             <li>
282                 <label for="patronreason">Reason for suggestion: </label>
283                 <select name="patronreason" id="patronreason">
284                     <option value=""> -- Choose -- </option>
285                     [% FOREACH patron_reason_loo IN patron_reason_loop %]
286                         [% IF patron_reason_loo.authorised_value == patronreason %]
287                             <option value="[% patron_reason_loo.authorised_value | html %]" selected="selected">[% patron_reason_loo.lib | html %]</option>
288                         [% ELSE %]
289                             <option value="[% patron_reason_loo.authorised_value | html %]">[% patron_reason_loo.lib | html %]</option>
290                         [% END %]
291                     [% END %]
292                 </select>
293             </li>
294         [% END %]
295         <li><label for="note">Notes:</label><textarea name="note" id="note" rows="5" cols="40">[% note | html %]</textarea></li>
296         </ol>
297     </fieldset>
298     <fieldset class="rows"> <legend>Suggestion management</legend>
299        <ol>
300             [% IF ( suggestionid ) %]
301                 <li>
302                     <label for="STATUS">Status:</label>
303                     <select id="STATUS" name="STATUS">
304                         <option value="">No status</option>
305
306                         [% IF (statusselected_ASKED ) %]
307                             <option value="ASKED" selected="selected">Pending</option>
308                         [% ELSE %]
309                             <option value="ASKED">Pending</option>
310                         [% END %]
311
312                         [% IF (statusselected_ACCEPTED ) %]
313                             <option value="ACCEPTED" selected="selected">Accepted</option>
314                         [% ELSE %]
315                             <option value="ACCEPTED">Accepted</option>
316                         [% END %]
317
318                         [% IF (statusselected_CHECKED ) %]
319                             <option value="CHECKED" selected="selected">Checked</option>
320                         [% ELSE %]
321                             <option value="CHECKED">Checked</option>
322                         [% END %]
323
324                         [% IF ( statusselected_REJECTED ) %]
325                             <option value="REJECTED" selected="selected">Rejected</option>
326                         [% ELSE %]
327                             <option value="REJECTED">Rejected</option>
328                         [% END %]
329
330                         [% FOREACH s IN SuggestionStatuses %]
331                             [% IF s.authorised_value == suggestion.STATUS %]
332                                 <option value="[% s.authorised_value | html %]" selected="selected">[% s.lib | html %]</option>
333                             [% ELSE %]
334                                 <option value="[% s.authorised_value | html %]">[% s.lib | html %]</option>
335                             [% END %]
336                         [% END %]
337                     </select>
338                 </li>
339                 <li>
340                     <label for="reason">Reason</label>
341                     <select class="select-reason" id="reason" name="reason">
342                         <option value=""> -- Choose a reason -- </option>
343                         [% FOREACH reasonsloo IN suggestion.reasonsloop %]
344                             [% IF (reasonsloo.lib == suggestion.reason) %]
345                                 <option value="[% reasonsloo.lib | html %]" selected="selected">[% reasonsloo.lib | html %]</option>
346                             [% ELSE %]
347                                 <option value="[% reasonsloo.lib | html %]">[% reasonsloo.lib | html %]</option>
348                             [% END %]
349                         [% END %]
350                         <option value="other">Others...</option>
351                     </select>
352
353                     <span id="other_reason" name="other_reason">
354                         [% IF other_reason %]
355                             <input type="text" size="31" id="select-other_reason" name="other_reason" placeholder="please note your reason here..." value="[% suggestion.reason | html %]"/>
356                         [% ELSE %]
357                             <input type="text" size="31" id="select-other_reason" name="other_reason" placeholder="please note your reason here..." />
358                         [% END %]
359                         <a href="#back">Cancel</a>
360                     </span>
361                 </li>
362             [% END %]
363         <li><table>
364             <thead><tr><th>&nbsp;</th><th>Date</th><th>By</th></tr></thead>
365             <tbody>
366             <tr>
367                 <th><label for="suggesteddate">[% tp('purchase suggestion created by', 'Created by:') | html %]</label> </th>
368                 <td><input type="text" id="suggesteddate" name="suggesteddate" class="datepicker" size="10" maxlength="10" value="[% suggesteddate | $KohaDates %]"/>[% INCLUDE 'date-format.inc' %]</td>
369                 <td><input type="hidden" id="suggestedby" name="suggestedby" value="[% suggestedby | html %]"/>[% IF ( suggestedby_patron.borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestedby_patron.borrowernumber | uri %]">[% suggestedby_patron.surname | html %], [% suggestedby_patron.firstname | html %] ([% suggestedby_patron.cardnumber | html %])</a>  [% Branches.GetName( suggestedby_patron.branchcode ) | html %] ([% suggestedby_patron.category.description | html %])[% END %]
370                 </td>
371             </tr>
372             <tr>
373                 <th><label for="accepteddate">Accepted on:</label> </th>
374                 <td><input type="text" id="accepteddate" name="accepteddate" class="datepicker" size="10" maxlength="10" value="[% accepteddate | $KohaDates %]" />[% INCLUDE 'date-format.inc' %]</td>
375                 <td><input type="hidden" id="acceptedby" name="acceptedby" value="[% acceptedby | html %]"/>[% IF ( acceptedby_patron.borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% acceptedby_patron.borrowernumber | uri %]">[% acceptedby_patron.surname | html %], [% acceptedby_patron.firstname | html %] ([% suggestedby_patron.cardnumber | html %])</a> [% Branches.GetName( acceptedby_patron.branchcode ) | html %] ([% acceptedby_patron.category.description | html %])[% END %]</td>
376             </tr>
377             </tbody>
378         </table></li>
379
380             <li>
381                 <label for="managedon">Managed on:</label>
382                 <input type="text" id="managedon" name="manageddate" class="datepicker" size="10" maxlength="10" value="[% manageddate | $KohaDates %]" />[% INCLUDE 'date-format.inc' %]
383             </li>
384             <li>
385                 <label for="managedby_name">by:</label>
386                 <div>
387                     <span id="managedby_name">
388                         <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% logged_in_user.borrowernumber | uri %]">You</a>
389                     </span>
390                     [% IF managedby_patron.borrowernumber && logged_in_user.borrowernumber != managedby_patron.borrowernumber %]
391                         | Previously was [% INCLUDE 'patron-title.inc' patron=managedby_patron hide_patron_infos_if_needed=1 %] [% Branches.GetName( managedby_patron.branchcode ) | html %] ([% managedby_patron.category.description | html %])
392                     [% END %]
393                     <br />
394                     <a id="edit_manager" class="new_window" href="#"><i class="fa fa-search"></i> Select manager</a>
395                     [% IF managedby_patron.borrowernumber && logged_in_user.borrowernumber != managedby_patron.borrowernumber %]
396                         <a id="restore_previous_manager" href="#"><i class="fa fa-trash"></i> Keep existing manager</a>
397                     [% END %]
398                     <input type="hidden" name="managedby" id="managedby" value="[% logged_in_user.borrowernumber | html %]" />
399
400                     <br/>
401                     <label for="notify">Notify manager:</label>
402                     <input type="checkbox" id="notify" name="notify" value="notify" disabled="disabled" title="A TO_PROCESS notice will be generated and send to the manager if a valid email address is defined. This can be checked if a new manager has been selected." />
403                 </div>
404             </li>
405         </ol>
406     </fieldset>
407     <fieldset class="rows"> <legend>Acquisition information</legend><ol>
408         <li><label for="branchcode">Library:</label>
409             <select name="branchcode" id="branchcode">
410                 <option value="">Any</option>
411                 [% IF branchfilter %]
412                     [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %]
413                 [% ELSE %]
414                     [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
415                 [% END %]
416             </select>
417         </li>
418         <li><label for="budgetid">Fund:</label>
419             <select name="budgetid" id="budgetid">
420                 <option value="">Any</option>[% FOREACH budgetsloo IN budgetsloop %]
421                 [% IF ( budgetsloo.selected ) %]<option value="[% budgetsloo.budget_id | html %]" selected="selected">[% budgetsloo.budget_name | html %]</option>[% ELSE %]<option value="[% budgetsloo.budget_id | html %]">[% budgetsloo.budget_name | html %]</option>[% END %][% END %]
422             </select>
423                 </li><li><label for="quantity">Copies:</label>
424             <input type="text" size="10" id="quantity" name="quantity" value="[% quantity | html %]" />
425                 </li>
426                 <li>
427                     <label for="currency">Currency:</label>
428                     [% FOREACH c IN currencies %]
429                         <input type="hidden" value="[% c.rate | html %]" id="currency_rate_[% c.currency | html %]" name="currency_rate_[% c.currency | html %]" />
430                         <input type="hidden" id="[% c.currency | html %]" name="[% c.currency | html %]" value="[% c.rate | html %]" />
431                     [% END %]
432
433                     <select name="currency" id="currency">
434                         [% FOREACH c IN currencies %]
435                             [% IF suggestionid and suggestion.currency == c.currency or not suggestionid and c.active %]
436                                 <option value="[% c.currency | html %]" selected="selected">[% c.currency | html %]</option>
437                             [% ELSIF not c.archived %]
438                                 <option value="[% c.currency | html %]">[% c.currency | html %]</option>
439                             [% END %]
440                         [% END %]
441                     </select>
442                 </li>
443                 <li><label for="price">Price:</label>
444             <input type="text" size="20" name="price" id="price" value="[% price | html %]" />
445                 </li><li><label for="total">Total: </label>
446                         <input type="text" readonly="readonly" id="total" name="total" size="10" value="[% total | html %]"/>
447                 </li></ol>
448     </fieldset><input type="hidden" id="returnsuggested" name="returnsuggested" value="[% IF ( returnsuggestedby ) %][% returnsuggestedby | html %][% ELSE %]noone[% END %]"/>
449     <fieldset class="action">
450         <input type="hidden" name="op" value="[% op | html %]" />
451         [% IF ( suggestionid ) %]
452             [% IF ( need_confirm ) %]
453                 <input type="hidden" name="save_confirmed" value="1" />
454                 <input onclick="this.form.op.value = 'save'; this.form.submit();" type="submit" value="Confirm your suggestion" />
455             [% ELSE %]
456                 <input type="submit" value="Save" />
457             [% END %]
458             <a class="cancel" href="[% IF ( returnsuggestedby ) %]/cgi-bin/koha/members/moremember.pl?borrowernumber=[% returnsuggestedby | uri %]#suggestions[% ELSE %]suggestion.pl[% END %]">Cancel</a>
459         [% ELSE %]
460             [% IF ( need_confirm ) %]
461                 <input type="hidden" name="save_confirmed" value="1" />
462                 <input onclick="this.form.op.value = 'save'; this.form.submit();" type="submit" value="Confirm your suggestion" />
463             [% ELSE %]
464                 <input type="submit" value="Submit your suggestion" />
465             [% END %]
466             <a class="cancel" href="suggestion.pl">Cancel</a>
467         [% END %]
468     </fieldset>
469     </form>
470 [% END %]
471
472 [% IF op == 'else' %]
473 <div id="toolbar" class="btn-toolbar">
474     <a class="btn btn-default" id="newsuggestion" href="suggestion.pl?op=add"><i class="fa fa-plus"></i> New purchase suggestion</a>
475 </div>
476
477 <h1>Suggestions management</h1>
478
479
480 [% FOR m IN messages %]
481     <div class="dialog [% m.type | html %]">
482         [% SWITCH m.code %]
483         [% CASE 'already_exists' %]
484             The suggestion has not been added. A suggestion with this title already exists (<a href='/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% m.id | html %]&op=show'>suggestion #[% m.id | html %]</a>)
485         [% CASE 'biblio_exists' %]
486             A similar document already exists: <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.id | uri %]">[% m.title | html %]</a>. Click on "Confirm your suggestion" to ignore this message.
487         [% CASE %]
488             [% m.code | html %]
489         [% END %]
490     </div>
491 [% END %]
492
493 [% UNLESS ( notabs ) %]
494     <div id="suggestiontabs" class="toptabs">
495     <ul class="ui-tabs-nav">
496         [% FOREACH suggestion IN suggestions %]
497                 <li>
498             <a href="#tab_[% loop.count | uri %]">
499             [% IF ( suggestion.suggestiontypelabel ) %]
500                 [% IF (suggestion.suggestiontypelabel == "Pending") %]Pending
501                 [% ELSIF (suggestion.suggestiontypelabel == "Accepted") %]Accepted
502                 [% ELSIF (suggestion.suggestiontypelabel == "Checked") %]Checked
503                 [% ELSIF (suggestion.suggestiontypelabel == "Rejected") %]Rejected
504                 [% ELSIF (suggestion.suggestiontypelabel == "Available") %]Available
505                 [% ELSIF (suggestion.suggestiontypelabel == "Ordered") %]Ordered
506                 [% ELSIF (suggestion.suggestiontypelabel == "Unknown") %]Status unknown
507                 [% ELSE %][% suggestion.suggestiontypelabel | html %][% END %]
508             [% ELSE %]
509                 [% IF ( suggestion.suggestiontype ) %]
510                     [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestion.suggestiontype ) | html %]
511                 [% ELSE %]
512                     No name
513                 [% END %]
514             [% END %]
515             ([% suggestion.suggestions_loop.size | html %])</a></li>
516
517         [% END %]
518     </ul>
519 [% END %]
520
521 [% FOREACH suggestion IN suggestions %]
522 <div id="tab_[% loop.count | html %]">
523 <form class="update_suggestions" name="f" method="post" action="/cgi-bin/koha/suggestion/suggestion.pl#tab_[% loop.count | html %]">
524
525 [% IF ( suggestion.suggestions_loop ) %]
526 <p><a class="checkall" href="#">Check all</a> | <a class="uncheckall" href="#">Uncheck all</a></p>
527     <table id="table_[% loop.count | html %]" class="sorted">
528         <thead>
529             <tr>
530                 <th class="NoSort noExport">&nbsp;</th>
531                 <th class="anti-the">Suggestion</th>
532                 <th>Suggested by</th>
533                 <th>Suggested on</th>
534                 <th>Managed by</th>
535                 <th>Managed on</th>
536                 <th>Library</th>
537                 <th>Fund</th>
538                 <th>Status</th>
539                 <th class="NoSort noExport">&nbsp;</th>
540             </tr>
541     </thead>
542         <tbody>
543             [% FOREACH suggestions_loo IN suggestion.suggestions_loop %]
544                 <tr>
545                 <td>
546                     <input type="checkbox" name="suggestionid" value="[% suggestions_loo.suggestionid | html %]" />
547                 </td>
548                 <td>
549                     <a href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid | uri %]&amp;op=show" title="suggestion" >
550                         [% suggestions_loo.title | html %][% IF ( suggestions_loo.author ) %], by [% suggestions_loo.author | html %][% END %]</a>
551                     <br />
552                     [% IF ( suggestions_loo.copyrightdate ) %]&copy; [% suggestions_loo.copyrightdate | html %] [% END %]
553                         [% IF ( suggestions_loo.volumedesc ) %]; Volume:<i>[% suggestions_loo.volumedesc | html %]</i> [% END %]
554                         [% IF ( suggestions_loo.isbn ) %]; ISBN:<i>[% suggestions_loo.isbn | html %]</i> [% END %][% IF ( suggestions_loo.publishercode ) %]; Published by [% suggestions_loo.publishercode | html %] [% END %][% IF ( suggestions_loo.publicationyear ) %] in <i>[% suggestions_loo.publicationyear | html %]</i> [% END %][% IF ( suggestions_loo.place ) %] in <i>[% suggestions_loo.place | html %]</i> [% END %][% IF ( suggestions_loo.collectiontitle ) %]; [% suggestions_loo.collectiontitle | html %] [% END %][% IF ( suggestions_loo.itemtype ) %]; [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestions_loo.itemtype, 0 ) | html %] [% END %]<br />[% IF ( suggestions_loo.note ) %]<div class="note"><i class="fa fa-comment"></i> [% suggestions_loo.note | html %]</div>[% END %]
555                 </td>
556                 <td>
557                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestions_loo.suggestedby | uri %]">[% suggestions_loo.surnamesuggestedby | html %][% IF ( suggestions_loo.firstnamesuggestedby ) %], [% suggestions_loo.firstnamesuggestedby | html %][% END %] [% IF (suggestions_loo.cardnumbersuggestedby ) %]([% suggestions_loo.cardnumbersuggestedby | html %])[% END %]</a>
558                 </td>
559                 <td data-order="[% suggestions_loo.suggesteddate | html %]">
560                     [% IF ( suggestions_loo.suggesteddate ) %][% suggestions_loo.suggesteddate | $KohaDates %][% END %]
561                 </td>
562                 <td>
563                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestions_loo.suggestedby | uri %]">[% suggestions_loo.surnamemanagedby | html %][% IF ( suggestions_loo.firstnamemanagedby ) %], [% suggestions_loo.firstnamemanagedby | html %][% END %]</a>
564                 </td>
565                 <td data-order="[% suggestions_loo.manageddate | html %]">
566                     [% IF ( suggestions_loo.manageddate ) %][% suggestions_loo.manageddate | $KohaDates %][% END %]
567                 </td>
568                 <td>
569                     [% Branches.GetName( suggestions_loo.branchcode ) | html %]
570                 </td>
571                 <td>
572                     [% suggestions_loo.budget_name | html %]
573                 </td>
574                 <td>
575                     [% IF ( suggestions_loo.ASKED ) %]
576                         Pending
577                     [% ELSIF ( suggestions_loo.ACCEPTED ) %]
578                         Accepted
579                     [% ELSIF ( suggestions_loo.ORDERED ) %]
580                         Ordered
581                     [% ELSIF ( suggestions_loo.REJECTED ) %]
582                         Rejected
583                     [% ELSIF ( suggestions_loo.CHECKED ) %]
584                         Checked
585                     [% ELSIF ( suggestions_loo.AVAILABLE ) %]
586                         Available
587                     [% ELSIF AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) %]
588                         [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) | html %]
589                     [% ELSE %]
590                         Status unknown
591                     [% END %]
592
593                     [% IF ( suggestions_loo.reason ) %]
594                         <br />([% suggestions_loo.reason | html %])
595                     [% END %]
596                 </td>
597                 <td class="actions">
598                     <a class="btn btn-xs btn-default" href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid | html %]&amp;op=edit"><i class="fa fa-pencil"></i> Edit</a>
599                     <a class="btn btn-default btn-xs deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% suggestions_loo.suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a>
600                 </td>
601         </tr>
602         [% END %]</tbody>
603         </table>
604
605         <div class="row">
606             <h2 style="padding-left:1em;">Change selected suggestions</h3>
607             <div class="col-sm-4">
608                 <fieldset>
609                     <div id="select-reason">
610                        <label for="STATUS">Mark selected as: </label>
611                        <select name="STATUS" id="STATUS">
612                            <option value=""> -- Choose a status --</option>
613
614                            [% IF (statusselected_ASKED ) %]
615                                <option value="ASKED" selected="selected">Pending</option>
616                            [% ELSE %]
617                                <option value="ASKED">Pending</option>
618                            [% END %]
619
620                            [% IF (statusselected_ACCEPTED ) %]
621                                <option value="ACCEPTED" selected="selected">Accepted</option>
622                            [% ELSE %]
623                                <option value="ACCEPTED">Accepted</option>
624                            [% END %]
625
626                            [% IF (statusselected_CHECKED ) %]
627                                <option value="CHECKED" selected="selected">Checked</option>
628                            [% ELSE %]
629                                <option value="CHECKED">Checked</option>
630                            [% END %]
631
632                            [% IF ( statusselected_REJECTED ) %]
633                                <option value="REJECTED" selected="selected">Rejected</option>
634                            [% ELSE %]
635                                <option value="REJECTED">Rejected</option>
636                            [% END %]
637
638                            [% FOREACH s IN SuggestionStatuses %]
639                                <option value="[% s.authorised_value | html %]">[% s.lib | html %]</option>
640                            [% END %]
641                        </select>
642
643                        <label for="reason">with this reason:</label>
644                        <select name="reason">
645                            <option value=""> -- Choose a reason -- </option>
646                            [% FOREACH reasonsloo IN suggestion.reasonsloop %]
647                                <option value="[% reasonsloo.lib | html %]">[% reasonsloo.lib | html %]</option>
648                            [% END %]
649                            <option value="other">Others...</option>
650                        </select>
651
652                        <span class="other_reason">
653                            <input type="text" size="31" name="other_reason" placeholder="please note your reason here..." />
654                            <a href="#" class="cancel_note">Cancel</a>
655                        </span>
656                     </div>
657
658                     <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
659                     <fieldset class="action"><button type="submit" class="btn btn-default btn-xs" value="update_status"/>Submit</button></fieldset>
660                 </fieldset>
661             </div>
662             <div class="col-sm-4">
663                 <fieldset>
664                     <label for="itemtype">Update item types with: </label>
665                     [% PROCESS 'av-build-dropbox.inc' name="suggestion_itemtype", category="SUGGEST_FORMAT", size = 20  %]
666                     <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
667                     <fieldset class="action"><button type="submit" class="btn btn-default btn-xs" value="update_itemtype"/>Submit</button></fieldset>
668                 </fieldset>
669             </div>
670
671             <div class="col-sm-2">
672                 <fieldset>
673                     <label for="set_manager_[% loop.count %]">Update manager</label><br/>
674                     <a id="edit_manager" class="new_window" href="#"><i class="fa fa-search"></i> Select manager</a>
675                     <span id="managedby_name"></span>
676                     <input type="hidden" name="suggestion_managedby" id="managedby" value="[% logged_in_user.borrowernumber | html %]" />
677                     <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
678                     <fieldset class="action"><button type="submit" class="btn btn-default btn-xs" value="update_manager"/>Submit</button></fieldset>
679                 </fieldset>
680             </div>
681
682             <div class="col-sm-2">
683                 <fieldset>
684                     <label for="delete_[% loop.count | html %]">Delete selected</label>
685                     <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
686                     <fieldset class="action"><button type="submit" class="btn btn-default btn-xs" value="delete"/>Delete</button></fieldset>
687                 </fieldset>
688             </div>
689
690         </div>
691
692 [% ELSE %]
693     <b>No results.</b>
694 [% END %]
695 </form>
696 </div>
697 [% END %]
698 [% END %]
699
700 [% UNLESS op == 'save' %]
701     [% UNLESS ( op == 'show' ) %]
702
703             </main>
704         </div> <!-- /.col-sm-10.col-sm-push-2 -->
705
706         <div class="col-sm-2 col-sm-pull-10">
707             <aside>
708
709 <form name="suggestionfilter" action="suggestion.pl" method="get">
710 <fieldset class="brief"><ol style="display:block;"><li><label for="displayby">Organize by: </label>
711                 <select name="displayby" id="displayby" style="width:auto;">
712                     [% IF ( displayby == "STATUS" ) %]
713                         <option value="STATUS" selected="selected">Status</option>
714                     [% ELSE %]
715                         <option value="STATUS">Status</option>
716                     [% END %]
717                     [% IF ( displayby == "branchcode" ) %]
718                         <option value="branchcode" selected="selected">Library</option>
719                     [% ELSE %]
720                         <option value="branchcode">Library</option>
721                     [% END %]
722                     [% IF ( displayby == "itemtype" ) %]
723                         <option value="itemtype" selected="selected">Item type</option>
724                     [% ELSE %]
725                         <option value="itemtype">Item type</option>
726                     [% END %]
727                     [% IF ( displayby == "managedby" ) %]
728                         <option value="managedby" selected="selected">Managed by</option>
729                     [% ELSE %]
730                         <option value="managedby">Managed by</option>
731                     [% END %]
732                     [% IF ( displayby == "acceptedby" ) %]
733                         <option value="acceptedby" selected="selected">Accepted by</option>
734                     [% ELSE %]
735                         <option value="acceptedby">Accepted by</option>
736                     [% END %]
737                 </select> <input type="submit" value="Go" /></li></ol></fieldset>
738 <h4>Filter by: <a style="font-size:80%;font-weight:normal;" href="/cgi-bin/koha/suggestion/suggestion.pl">[clear]</a></h4>
739                 <div style="display:block;" id="limits">
740
741                                 <fieldset class="brief"><h4 class="local_collapse"><a href="#">Bibliographic information</a></h4>
742                    <ol> <li><label for="title"> Title:</label><input type="text" id="title" name="title" value="[% title | html %]" /></li>
743                     <li><label for="author"> Author:</label><input type="text" id="author" name="author" value="[% author | html %]" /></li>
744                     <li><label for="isbn"> ISBN:</label><input type="text" id="isbn"  name="isbn" value="[% isbn | html %]" /></li>
745                     <li><label for="publishercode"> Publisher:</label><input type="text" id="publishercode" name="publishercode" value="[% publishercode | html %]" /></li>
746                     <li><label for="copyrightdate_filter"> Copyright date:</label><input type="text" id="copyrightdate_filter" name="copyrightdate" value="[% copyrightdate | html %]" /></li>
747                     <li><label for="collectiontitle"> Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" value="[% collectiontitle | html %]" /></li><li><input type="submit" value="Go" /></li></ol>
748                 </fieldset>
749                                  <fieldset class="brief"><h4 class="local_collapse"><a href="#">Suggestion information</a></h4>
750                     <ol>
751                       <li>
752                           <label for="STATUS"> Status:</label>
753                           <select name="STATUS" id="STATUS">
754                               <option value="">Any</option>
755
756                               [% IF (statusselected_ASKED ) %]
757                                   <option value="ASKED" selected="selected">Pending</option>
758                               [% ELSE %]
759                                   <option value="ASKED">Pending</option>
760                               [% END %]
761
762                               [% IF (statusselected_ACCEPTED ) %]
763                                   <option value="ACCEPTED" selected="selected">Accepted</option>
764                               [% ELSE %]
765                                   <option value="ACCEPTED">Accepted</option>
766                               [% END %]
767
768                               [% IF (statusselected_CHECKED ) %]
769                                   <option value="CHECKED" selected="selected">Checked</option>
770                               [% ELSE %]
771                                   <option value="CHECKED">Checked</option>
772                               [% END %]
773
774                               [% IF ( statusselected_REJECTED ) %]
775                                   <option value="REJECTED" selected="selected">Rejected</option>
776                               [% ELSE %]
777                                   <option value="REJECTED">Rejected</option>
778                               [% END %]
779
780                               [% FOREACH s IN SuggestionStatuses %]
781                                   [% IF s.authorised_value == selected_status %]
782                                       <option value="[% s.authorised_value | html %]" selected="selected">[% s.lib | html %]</option>
783                                   [% ELSE %]
784                                       <option value="[% s.authorised_value | html %]">[% s.lib | html %]</option>
785                                   [% END %]
786                               [% END %]
787                           </select>
788                       </li>
789
790                     <li><label for="suggestedby"> Suggested by:</label><select id="suggestedby" name="suggestedby"><option value="">Any</option>
791 [% FOREACH suggestedby_loo IN suggestedby_loop %][% IF ( suggestedby_loo.selected ) %]<option value="[% suggestedby_loo.code | html %]" selected="selected">[% suggestedby_loo.desc | html %]</option>[% ELSE %]<option value="[% suggestedby_loo.code | html %]">[% suggestedby_loo.desc | html %]</option>[% END %][% END %]
792                                                                      </select></li>
793                     <li>
794                         <label for="suggesteddate_from">Suggested date from:</label>
795                         <input type="text" id="suggesteddate_from" size="10" name="suggesteddate_from" value="[% suggesteddate_from | html %]" />
796                     </li>
797                     <li>
798                         <label for="suggesteddate_to">To:</label>
799                         <input type="text" id="suggesteddate_to" size="10" name="suggesteddate_to" value="[% suggesteddate_to | html %]" />
800                     </li>
801                     <li><label for="managedby"> Managed by:</label><select id="managedby" name="managedby"><option value="">Any</option>
802 [% FOREACH managedby_loo IN managedby_loop %][% IF ( managedby_loo.selected ) %]<option value="[% managedby_loo.code | html %]" selected="selected">[% managedby_loo.desc | html %]</option>[% ELSE %]<option value="[% managedby_loo.code | html %]">[% managedby_loo.desc | html %]</option>[% END %][% END %]
803                                                                      </select></li>
804                     <li>
805                         <label for="manageddate_from">Management date from:</label>
806                         <input type="text" id="manageddate_from" size="10" name="manageddate_from" value="[% manageddate_from | html %]" />
807                     </li>
808                     <li>
809                         <label for="manageddate_to">To:</label>
810                         <input type="text" id="manageddate_to" size="10" name="manageddate_to" value="[% manageddate_to | html %]" />
811                     </li>
812                     <li><label for="acceptedby"> Accepted by:</label><select id="acceptedby" name="acceptedby"><option value="">Any</option>
813 [% FOREACH acceptedby_loo IN acceptedby_loop %][% IF ( acceptedby_loo.selected ) %] <option value="[% acceptedby_loo.code | html %]" selected="selected">[% acceptedby_loo.desc | html %]</option>[% ELSE %]<option value="[% acceptedby_loo.code | html %]">[% acceptedby_loo.desc | html %]</option>[% END %][% END %]
814                                                       </select></li>
815                     <li>
816                         <label for="accepteddate_from">Accepted date from:</label>
817                         <input type="text" id="accepteddate_from" size="10" name="accepteddate_from" value="[% accepteddate_from | html %]" />
818                     </li>
819                     <li>
820                         <label for="accepteddate_to">To:</label>
821                         <input type="text" id="accepteddate_to" size="10" name="accepteddate_to" value="[% accepteddate_to | html %]" />
822                     </li>
823                     <li><input type="submit" value="Go" /></li></ol>
824                 </fieldset>
825
826                                 <fieldset class="brief"><h4 class="local_collapse"><a href="#">Acquisition information</a></h4>
827                     <ol><li><label for="budgetid"> Book fund:</label>
828                     <select name="budgetid" id="budgetid">
829                       <option value="__ANY__">Any</option>
830                       [% IF budgetid == '__NONE__' %]
831                           <option value="__NONE__" selected="selected">None</option>
832                       [% ELSE %]
833                           <option value="__NONE__">None</option>
834                       [% END %]
835                     [% FOREACH budgetsloo IN budgetsloop %]
836                         [% IF ( budgetsloo.selected ) %]<option value="[% budgetsloo.budget_id | html %]" selected="selected">[% budgetsloo.budget_name | html %]</option>[% ELSE %]<option value="[% budgetsloo.budget_id | html %]">[% budgetsloo.budget_name | html %]</option>[% END %]
837                         [% END %]
838                     </select></li>
839                     <li><label for="branchcode">Library:</label>
840                     <select name="branchcode" id="branchcode">
841                         <option value="__ANY__">Any</option>
842                         [% IF branchfilter %]
843                             [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %]
844                         [% ELSE %]
845                             [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
846                         [% END %]
847                     </select></li><li><input type="submit" value="Go" /></li></ol>
848                 </fieldset>
849             </form>
850         [% INCLUDE 'acquisitions-menu.inc' %]
851
852             </aside>
853         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
854      </div> <!-- /.row -->
855
856     [% END %]
857     [% END %]
858 </div>
859 [% END %]
860
861 [% MACRO jsinclude BLOCK %]
862     [% INCLUDE 'calendar.inc' %]
863
864     <script type="text/javascript">
865         function editManagerPopup() {
866             window.open("/cgi-bin/koha/suggestion/add_user_search.pl?selection_type=select",
867                 'PatronPopup',
868                 'width=740,height=450,location=yes,toolbar=no,'
869                 + 'scrollbars=yes,resize=yes'
870             );
871         }
872         function select_user(borrowernumber, borrower) {
873             $("#managedby_name").empty();
874             $("#managedby").val('');
875             var borrowername = borrower.firstname + ' ' + borrower.surname;
876             if (borrowernumber) {
877                 var managerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
878                     + '?borrowernumber=' + borrowernumber + '">'
879                     + borrowername + '</a>';
880                 $('#managedby_name').html(managerlink);
881                 $('#managedby').val(borrowernumber);
882             }
883
884             var notify = $('#notify');
885             if ( notify.length ) {
886                 if ( borrowernumber == [% logged_in_user.borrowernumber | html %] || borrowernumber == [% managedby_patron.borrowernumber | html %] ) {
887                     $(notify).prop('checked', false).prop('disabled', true);
888                 } else {
889                     $(notify).prop('disabled', false);
890                 }
891             }
892         }
893
894         $(document).ready(function(){
895             $("#edit_manager").on("click",function(e){
896                 e.preventDefault();
897                 editManagerPopup();
898             });
899         });
900     </script>
901
902     [% IF ( op == 'show' || op == 'else' ) %]
903         <script>
904             $(document).ready(function(){
905                 $(".deletesuggestion").on("click",function(){
906                     return confirm(_("Are you sure you want to delete this suggestion?"));
907                 });
908             });
909         </script>
910     [% END %]
911     [% IF op == 'else' %]
912         [% INCLUDE 'datatables.inc' %]
913         [% INCLUDE 'columns_settings.inc' %]
914         [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
915
916         <script>
917             $(document).ready(function() {
918                 $('#suggestiontabs').tabs();
919
920                 columns_settings = [% ColumnsSettings.GetColumns( 'acqui', 'suggestions', 'suggestions', 'json' ) | $raw %]
921                 [% FOREACH suggestion IN suggestions %]
922                     [% IF ( suggestion.suggestions_loop ) %]
923                         KohaTable("table_[% loop.count| html %]", {
924                             "sorting": [[ 1, "asc" ]],
925                             "autoWidth": false,
926                             "columnDefs": [
927                                 { "sortable": false, "searchable": false, 'targets': [ 'NoSort' ] },
928                                 { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
929                             ]
930                         }, columns_settings );
931                     [% END %]
932                 [% END %]
933
934                 $(".checkall").click(function(e){
935                     e.preventDefault();
936                     $(this).parents('form').checkCheckboxes();
937                     return false;
938                 });
939                 $(".uncheckall").click(function(e){
940                     e.preventDefault();
941                     $(this).parents('form').unCheckCheckboxes();
942                     return false;
943                 });
944                 $(".other_reason").hide();
945                 $("select[name='reason']").change(function(){
946                     if($(this).val() == "other"){
947                         $(this).hide();
948                         $(this).siblings(".other_reason").show();
949                     }
950                 });
951
952                 $("a.cancel_note").click(function(e) {
953                     $(this).parent().siblings("select").show().find("option[value='']").attr("selected","selected");
954                     $(this).siblings("input[name='other_reason']").hide();
955                     e.preventDefault();
956                 });
957                 $("h4.local_collapse a").click(function(){
958                     $(this).parent().parent().find("ol").toggle();
959                     return false;
960                 });
961                 // http://jqueryui.com/demos/datepicker/#date-range
962                 var dates = $( "#suggesteddate_from, #suggesteddate_to" ).datepicker({
963                     changeMonth: true,
964                     numberOfMonths: 1,
965                     onSelect: function( selectedDate ) {
966                         var option = this.id == "suggesteddate_from" ? "minDate" : "maxDate",
967                             instance = $( this ).data( "datepicker" );
968                             date = $.datepicker.parseDate(
969                                 instance.settings.dateFormat ||
970                                 $.datepicker._defaults.dateFormat,
971                                 selectedDate, instance.settings );
972                         dates.not( this ).datepicker( "option", option, date );
973                     }
974                 });
975                 var datesMD = $( "#manageddate_from, #manageddate_to" ).datepicker({
976                     changeMonth: true,
977                     numberOfMonths: 1,
978                     onSelect: function( selectedDate ) {
979                         var option = this.id == "manageddate_from" ? "minDate" : "maxDate",
980                             instance = $( this ).data( "datepicker" );
981                             date = $.datepicker.parseDate(
982                                 instance.settings.dateFormat ||
983                                 $.datepicker._defaults.dateFormat,
984                                 selectedDate, instance.settings );
985                         datesMD.not( this ).datepicker( "option", option, date );
986                     }
987                 });
988                 var datesAD = $( "#accepteddate_from, #accepteddate_to" ).datepicker({
989                     changeMonth: true,
990                     numberOfMonths: 1,
991                     onSelect: function( selectedDate ) {
992                         var option = this.id == "accepteddate_from" ? "minDate" : "maxDate",
993                             instance = $( this ).data( "datepicker" );
994                             date = $.datepicker.parseDate(
995                                 instance.settings.dateFormat ||
996                                 $.datepicker._defaults.dateFormat,
997                                 selectedDate, instance.settings );
998                         datesAD.not( this ).datepicker( "option", option, date );
999                     }
1000                 });
1001
1002                 $("button[type='submit']").on("click", function(e) {
1003                     var form = $(this).parents("form");
1004                     var action = $(this).val();
1005                     var selected_suggestions = $(form).find("input[name='suggestionid']:checked");
1006                     if ( selected_suggestions.length == 0 ) {
1007                         alert(_("Please select at least one suggestion"));
1008                         e.preventDefault();
1009                         return false;
1010                     }
1011                     if ( action == "delete" ) {
1012                         if ( selected_suggestions.length == 1 ) {
1013                             if ( ! confirm(_("Are you sure you want to delete this suggestion?")) ) {
1014                                 e.preventDefault();
1015                                 return false;
1016                             }
1017                         } else if ( selected_suggestions.length > 1 ) {
1018                             if ( ! confirm(_("Are you sure you want to delete these suggestions?")) ) {
1019                                 e.preventDefault();
1020                                 return false;
1021                             }
1022                         }
1023                     } else if ( action == "update_manager" ) {
1024                         if ( $("#managedby").val() == "" ) {
1025                             alert(_("Please select a manager to assign to the selected suggestions"));
1026                             e.preventDefault();
1027                             return false;
1028                         }
1029                     }
1030
1031                     $('<input />').attr('type', 'hidden')
1032                                   .attr('name', "op")
1033                                   .attr('value', action)
1034                                   .appendTo(form);
1035                     return true;
1036                 });
1037             });
1038         </script>
1039     [% END %]
1040     [% IF op == 'save'  %]
1041         <script>
1042
1043             $(document).ready(function(){
1044                 calcNewsuggTotal();
1045                 $("#quantity,#price,#currency").on("change",function(){
1046                     calcNewsuggTotal();
1047                 });
1048
1049                 [% IF other_reason %]
1050                     $(".select-reason").hide();
1051                     $(".select-reason").find("option[value='other']").attr("selected","selected");
1052                     $("#other_reason").show();
1053                 [% ELSE %]
1054                     $("#other_reason").hide();
1055                 [% END %]
1056                 $(".select-reason").change(function(){
1057                     if($(this).val() == "other"){
1058                         $(this).hide();
1059                         $("#other_reason").show();
1060                     }
1061                 });
1062                 $("a[href*=back]").click(function(){
1063                     $(".select-reason").show().find("option[value='']").attr("selected","selected");
1064                     $("#other_reason").hide();
1065                 });
1066
1067                 $("#restore_previous_manager").on("click",function(e){
1068                     e.preventDefault();
1069
1070                     $("#managedby_name").empty();
1071                     $("#managedby").val('');
1072                     var borrowername = "[% managedby_patron.firstname | html %] [% managedby_patron.surname | html %]";
1073                     var managerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
1074                         + '?borrowernumber=[% managedby_patron.borrowernumber | html %]">'
1075                         + borrowername + '</a>';
1076                     $('#managedby_name').html(managerlink);
1077                     $('#managedby').val([% managedby_patron.borrowernumber | html %]);
1078                     $('#notify').prop('checked', false).prop('disabled', true);
1079                 });
1080
1081             });
1082         </script>
1083     [% END %]
1084     [% Asset.js("js/acq.js") | $raw %]
1085     [% Asset.js("js/acquisitions-menu.js") | $raw %]
1086 [% END %]
1087
1088 [% INCLUDE 'intranet-bottom.inc' %]