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