Bug 20755: (QA follow-up) Fix capitalization in system preference description
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / supplier.tt
1 [% USE raw %]
2 [% USE To %]
3 [% USE Asset %]
4 [% USE KohaDates %]
5 [% USE AuthorisedValues %]
6 [% PROCESS 'i18n.inc' %]
7 [% BLOCK edit_contact %]
8     <ol id="contact-form">
9         <input type="hidden" name="contact_id" value="[% contact.id | html %]" />
10         <li><label for="contact_name[% contact.id | html %]">Contact name: </label>
11             <input type="text" size="40" id="contact_name[% contact.id | html %]" name="contact_name" value="[% contact.name | html %]" /></li>
12         <li><label for="contact_position[% contact.id | html %]">Position: </label>
13             <input type="text" size="40" id="contact_position[% contact.id | html %]" name="contact_position" value="[% contact.position | html %]" /></li>
14         <li><label for="contact_phone[% contact.id | html %]">Phone: </label>
15                 <input type="tel" size="20" id="contact_phone[% contact.id | html %]" name="contact_phone" value="[% contact.phone | html %]" /> </li>
16         <li><label for="contact_altphone[% contact.id | html %]">Alternative phone: </label>
17             <input type="tel" size="20" id="contact_altphone[% contact.id | html %]" name="contact_altphone" value="[% contact.altphone | html %]" /></li>
18         <li><label for="contact_fax[% contact.id | html %]">Fax: </label>
19             <input type="tel" size="20" id="contact_fax[% contact.id | html %]" name="contact_fax" value="[% contact.fax | html %]" /></li>
20         <li><label for="contact_email[% contact.id | html %]">Email: </label>
21             <input type="email" size="40" id="contact_email[% contact.id | html %]" name="contact_email" value="[% contact.email | html %]" class="email" /></li>
22         <li><label for="contact_notes[% contact.id | html %]">Notes: </label>
23             <textarea id="contact_notes[% contact.id | html %]" name="contact_notes" cols="40" rows="4">[% contact.notes | html %]</textarea></li>
24     </ol>
25     <div style="display:flex">
26         <div>
27             <fieldset class="rows">
28                 <legend>Acquisitions options</legend>
29                 <ol class="radio">
30                     <li>
31                         <label>
32                             [% IF contact.acqprimary %]
33                                 <input type="checkbox" id="contact_acqprimary[% contact.id | html %]" class="contact_acqprimary" checked="checked" />
34                             [% ELSE %]
35                                 <input type="checkbox" id="contact_acqprimary[% contact.id | html %]" class="contact_acqprimary" />
36                             [% END %]
37                             <input type="hidden" class="contact_acqprimary_hidden" name="contact_acqprimary" value="[% contact.acqprimary | html %]" />
38                             Primary acquisitions contact
39                         </label>
40                     </li>
41                     <li>
42                         <label>
43                             [% IF contact.orderacquisition %]
44                                 <input type="checkbox" id="contact_orderacquisition[% contact.id | html %]" class="contact_orderacquisition" checked="checked" />
45                             [% ELSE %]
46                                 <input type="checkbox" id="contact_orderacquisition[% contact.id | html %]" class="contact_orderacquisition" />
47                             [% END %]
48                             <input type="hidden" class="contact_orderacquisition_hidden" name="contact_orderacquisition" value="[% contact.orderacquisition | html %]" />
49                             Contact when ordering
50                         </label>
51                     </li>
52                     <li>
53                         <label>
54                             [% IF contact.claimacquisition %]
55                                 <input type="checkbox" id="contact_claimacquisition[% contact.id | html %]" class="contact_claimacquisition" checked="checked" />
56                             [% ELSE %]
57                                 <input type="checkbox" id="contact_claimacquisition[% contact.id | html %]" class="contact_claimacquisition" />
58                             [% END %]
59                             <input type="hidden" class="contact_claimacquisition_hidden" name="contact_claimacquisition" value="[% contact.claimacquisition | html %]" />
60                             Contact about late orders
61                         </label>
62                     </li>
63                 </ol>
64             </fieldset>
65         </div>
66         <div>
67             <fieldset class="rows">
68                 <legend>Serials options</legend>
69                 <ol class="radio">
70                     <li>
71                         <label>
72                             [% IF contact.serialsprimary %]
73                                 <input type="checkbox" id="contact_serialsprimary[% contact.id | html %]" class="contact_serialsprimary" checked="checked" />
74                             [% ELSE %]
75                                 <input type="checkbox" id="contact_serialsprimary[% contact.id | html %]" class="contact_serialsprimary" />
76                             [% END %]
77                             <input type="hidden" class="contact_serialsprimary_hidden" name="contact_serialsprimary" value="[% contact.serialsprimary | html %]" />
78                             Primary serials contact
79                         </label>
80                     </li>
81                     <li>
82                         <label>
83                             [% IF contact.claimissues %]
84                                 <input type="checkbox" id="contact_claimissues[% contact.id | html %]" class="contact_claimissues" checked="checked" />
85                             [% ELSE %]
86                                 <input type="checkbox" id="contact_claimissues[% contact.id | html %]" class="contact_claimissues" />
87                             [% END %]
88                             <input type="hidden" class="contact_claimissues_hidden" name="contact_claimissues" value="[% contact.claimissues | html %]" />
89                             Contact about late issues
90                         </label>
91                     </li>
92                 </ol>
93             </fieldset>
94         </div>
95     </div>
96
97         [% IF contact.id %]<li><button class="btn btn-default delete-contact"><i class="fa fa-trash-can"></i> Delete contact</li>[% END %]
98     </ol>
99 [% END %]
100
101 [% BLOCK show_contact %]
102     <h3>[% contact.name | html %]</h3>
103     <ol>
104         <li><span class="label">Position: </span>[% contact.position | html %]</li>
105         <li><span class="label">Phone: </span>[% contact.phone | html %]</li>
106         <li><span class="label">Alternative phone: </span>[% contact.altphone | html %]</li>
107         <li><span class="label">Fax: </span>[% contact.fax | html %]</li>
108         [% IF ( contact.email ) %]
109             <li><span class="label">Email: </span><a href="mailto:[% contact.email | uri %]">[% contact.email | html %]</a></li>
110         [% END %]
111         [% IF ( contact.notes ) %]
112             <li><span class="label">Notes: </span>[% contact.notes | html %]</li>
113         [% END %]
114         [% IF ( contact.acqprimary || contact.orderacquisition || contact.claimacquisition ) %]
115             <li>
116                 <span class="label">Acquisitions options:</span>
117                 <ol>
118                     [% IF ( contact.acqprimary ) %]
119                         <li><span class="label"></span> <i class="fa fa-check"></i> Primary acquisitions contact</li>
120                     [% END %]
121                     [% IF ( contact.orderacquisition ) %]
122                         <li><span class="label"></span> <i class="fa fa-check"></i> Receives orders</li>
123                     [% END %]
124                     [% IF ( contact.claimacquisition ) %]
125                         <li><span class="label"></span> <i class="fa fa-check"></i> Receives claims for late orders</li>
126                     [% END %]
127                 </ol>
128             </li>
129         [% END %]
130         [% IF ( contact.serialsprimary || contact.claimissues ) %]
131             <li>
132                 <span class="label">Serials options:</span>
133                 <ol>
134                     [% IF ( contact.serialsprimary ) %]
135                         <li><span class="label"></span> <i class="fa fa-check"></i> Primary serials contact</li>
136                     [% END %]
137                     [% IF ( contact.claimissues ) %]
138                         <li><span class="label"></span> <i class="fa fa-check"></i> Receives claims for late issues</li>
139                     [% END %]
140                 </ol>
141             </li>
142         [% END %]
143     </ol>
144 [% END %]
145
146 [% SET footerjs = 1 %]
147 [% INCLUDE 'doc-head-open.inc' %]
148 <title>[% FILTER collapse %]
149     [% tx("Vendor {vendor}", { vendor = name }) | html %] &rsaquo;
150     [% t("Koha") | html %]
151 [% END %]</title>
152 [% INCLUDE 'doc-head-close.inc' %]
153 </head>
154
155 <body id="acq_supplier" class="acq">
156 [% WRAPPER 'header.inc' %]
157     [% INCLUDE 'acquisitions-search.inc' %]
158 [% END %]
159
160 [% WRAPPER 'sub-header.inc' %]
161     [% WRAPPER breadcrumbs %]
162         [% WRAPPER breadcrumb_item %]
163             <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
164         [% END %]
165         [% IF ( enter ) %]
166             [% IF ( booksellerid ) %]
167                 [% WRAPPER breadcrumb_item %]
168                     <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% name | html %]</a>
169                 [% END %]
170                 [% WRAPPER breadcrumb_item bc_active= 1 %]
171                     <span>Modify [% name | html %]</span>
172                 [% END %]
173             [% ELSE %]
174                 [% WRAPPER breadcrumb_item bc_active= 1 %]
175                     <span>Add vendor</span>
176                 [% END %]
177             [% END %]
178         [% ELSE %]
179             [% WRAPPER breadcrumb_item bc_active= 1 %]
180                 [% name | html %]
181             [% END %]
182         [% END # /IF (enter) %]
183     [% END #/ WRAPPER breadcrumbs %]
184 [% END #/ WRAPPER sub-header.inc %]
185
186 <div class="main container-fluid">
187     <div class="row">
188         <div class="col-sm-10 col-sm-push-2">
189             <main>
190
191     [% IF ( enter ) %]
192         [% IF ( booksellerid ) %]
193         <h1>Update: [% name | html %]</h1>
194     [% ELSE %]
195         <h1>Add vendor</h1>
196     [% END %]
197     [% END %]
198 [% UNLESS ( enter ) %][% INCLUDE 'acquisitions-toolbar.inc' %][% END %]
199 [% IF ( enter ) %]
200     <form action="updatesupplier.pl" name="updatesupplier" style="display:block" class="validated" method="post">
201         <div id="toolbar" class="btn-toolbar">
202             <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> Save</button>
203             [% IF ( booksellerid ) %]
204                 <a class="btn btn-default cancel" href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | html %]">
205             [% ELSE %]
206                 <a class="btn btn-default cancel" href="/cgi-bin/koha/acqui/acqui-home.pl">
207             [% END %] <i class="fa fa-times"></i> Cancel</a>
208         </div>
209
210         <input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
211         <fieldset class="rows">
212             <legend>Company details</legend>
213             <ol><li><label for="company" class="required">Name:</label>
214                 <input type="text" size="40" id="company" name="company" value="[% name | html %]" required="required" class="required focus" /><span class="required">Required</span></li>
215             <li><label for="company_postal">Postal address: </label>
216                     <textarea id="company_postal" name="company_postal" cols="40" rows="3">[% postal | html %]</textarea></li>
217             <li><label for="physical">Physical address: </label>
218                 <textarea id="physical" name="physical" cols="40" rows="3">[% address1 | html %][% address2 | html %][% address3 | html %][% address4 | html %]</textarea></li>
219             <li><label for="company_phone">Phone: </label>
220                 <input type="tel" size="20" id="company_phone" name="company_phone" value="[% phone | html %]" /></li>
221             <li><label for="company_fax">Fax: </label>
222                 <input type="tel" size="20" id="company_fax" name="company_fax" value="[% fax | html %]" /></li>
223             <li><label for="website">Website: </label>
224                 <input type="url" size="40" id="website" name="website" value="[% url | html %]" class="url" /></li>
225             <li><label for="accountnumber">Account number: </label>
226                 <input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber | html %]" /></li>
227                 <li>
228                     <label for="vendor_type">Vendor type: </label>
229                     [% PROCESS 'av-build-dropbox.inc' name="vendor_type", category="VENDOR_TYPE", default=type, empty=1, size = 20 %]
230                 </li>
231                 <li>
232                     <label for="aliases">Aliases: </label>
233                     <div id="aliases" style="padding-left: 11rem;"></div>
234                 </li>
235             </ol>
236         </fieldset>
237         <fieldset class="rows">
238             <legend>Contacts</legend>
239             <fieldset id="contact-template" class="supplier-contact">
240                 <legend>Contact details</legend>
241                 [% INCLUDE edit_contact %]
242             </fieldset>
243             [% FOREACH contact IN contacts %]
244                 <fieldset class="supplier-contact">
245                     <legend>Contact details</legend>
246                     [% INCLUDE edit_contact %]
247                 </fieldset>
248             [% END %]
249             <button id="add-contact" class="btn btn-default"><i class="fa fa-plus"></i> Add another contact</button>
250         </fieldset>
251
252         <fieldset class="rows">
253             <legend>Interfaces</legend>
254             <div id="interfaces"></div>
255         </fieldset>
256
257         <fieldset class="rows">
258             <legend>Ordering information</legend>
259             <ol><li><label for="activestatus">Vendor is:</label>
260                     [% IF ( active ) %]
261                         <input type="radio" id="activestatus" name="status" value="1" checked="checked" />
262                         <label class="radio" for="activestatus">Active</label>
263                         <input type="radio" id="inactivestatus" name="status" value="0" />
264                         <label class="radio" for="inactivestatus">Inactive</label>
265                     [% ELSE %]
266                         <input type="radio" id="activestatus" name="status" value="1" />
267                         <label class="radio" for="activestatus">Active</label>
268                         <input type="radio" id="inactivestatus" name="status" value="0" checked="checked" />
269                         <label class="radio" for="inactivestatus">Inactive</label>
270                     [% END %]</li>
271             <li><label for="list_currency">List prices are: </label>
272                 <select name="list_currency" id="list_currency">
273                     [% FOREACH c IN currencies %]
274                         [% IF booksellerid and c.currency == listprice or not booksellerid and c.active %]
275                             <option value="[% c.currency | html %]" selected="selected">[% c.currency | html %]</option>
276                         [% ELSIF not c.archived %]
277                             <option value="[% c.currency | html %]">[% c.currency | html %]</option>
278                         [% END %]
279                     [% END %]
280                 </select>
281             </li>
282             <li><label for="invoice_currency">Invoice prices are: </label>
283                 <select name="invoice_currency" id="invoice_currency">
284                     [% FOREACH c IN currencies %]
285                         [% IF booksellerid and c.currency == invoiceprice or not booksellerid and c.active %]
286                             <option value="[% c.currency | html %]" selected="selected">[% c.currency | html %]</option>
287                         [% ELSIF not c.archived %]
288                             <option value="[% c.currency | html %]">[% c.currency | html %]</option>
289                         [% END %]
290                     [% END %]
291                 </select>
292             </li>
293             <li><label for="gstyes">Tax number registered:</label>
294                 [% IF ( gstreg ) %]
295                     <label class="radio" for="gstyes">Yes</label>
296                     <input type="radio" name="gst" id="gstyes" value="1" checked="checked" />
297                     <label class="radio" for="gstno">No</label>
298                     <input type="radio" name="gst" id="gstno" value="0" />
299                 [% ELSE %]
300                     <label class="radio" for="gstyes">Yes</label>
301                     <input type="radio" name="gst" id="gstyes" value="1" />
302                     <label class="radio" for="gstno">No</label>
303                     <input type="radio" name="gst" id="gstno" value="0" checked="checked" />
304                 [% END %]</li>
305
306             <li><label for="list_gstyes">List prices:</label>
307                 [% IF ( listincgst ) %]
308                     <label class="radio" for="list_gstyes">Include tax</label>
309                     <input type="radio" id="list_gstyes" name="list_gst" value="1" checked="checked" />
310                     <label class="radio" for="list_gstno">Don't include tax</label>
311                     <input type="radio" id="list_gstno" name="list_gst" value="0" />
312                 [% ELSE %]
313                     <label class="radio" for="list_gstyes">Include tax</label>
314                     <input type="radio" id="list_gstyes" name="list_gst" value="1" />
315                     <label class="radio" for="list_gstno">Don't include tax</label>
316                     <input type="radio" id="list_gstno" name="list_gst" value="0" checked="checked" />
317                 [% END %]</li>
318
319             <li><label for="invoice_gstyes">Invoice prices:</label>
320                 [% IF ( invoiceincgst ) %]
321                     <label class="radio" for="invoice_gstyes">Include tax</label>
322                     <input type="radio" id="invoice_gstyes" name="invoice_gst" value="1" checked="checked" />
323                     <label class="radio" for="invoice_gstno">Don't include tax</label>
324                     <input type="radio" id="invoice_gstno" name="invoice_gst" value="0" />
325                     [% ELSE %]
326                     <label class="radio" for="invoice_gstyes">Include tax</label>
327                     <input type="radio" id="invoice_gstyes" name="invoice_gst" value="1" />
328                     <label class="radio" for="invoice_gstno">Don't include tax</label>
329                     <input type="radio" id="invoice_gstno" name="invoice_gst" value="0" checked="checked" />
330                 [% END %]</li>
331
332             [% IF gst_values %]
333                 <li>
334                   <label for="tax_rate">Tax rate: </label>
335                   <select name="tax_rate" id="tax_rate">
336                   [% FOREACH gst IN gst_values %]
337                     [% IF ( tax_rate == gst.option ) %]
338                       <option value="[% gst.option | html %]" selected="selected">[% gst.option * 100 | html %] %</option>
339                     [% ELSE %]
340                       <option value="[% gst.option | html %]">[% gst.option * 100 | html %] %</option>
341                     [% END %]
342                   [% END %]
343                   </select>
344                 </li>
345             [% ELSE %]
346                 <input type="hidden" name="tax_rate" value="0" />
347             [% END %]
348             <li><label for="discount">Discount: </label>
349                 <input type="text" size="6" id="discount" name="discount" value="[% discount | format ('%.1f') %]" />%</li>
350             <li>
351                 <label for="deliverytime">Delivery time: </label>
352                 <input type="text" size="2" id="deliverytime" name="deliverytime" value="[% deliverytime | html %]" /> days
353             </li>
354             <li><label for="notes">Notes: </label>
355                 <textarea cols="40" rows="4" id="notes" name="notes" >[% notes | html %]</textarea></li>
356             </ol>
357         </fieldset>
358
359     </form>
360 [% ELSE %]
361     <h1>[% name | html %]</h1>
362         <div class="row">
363             <div class="col-sm-6">
364                 <div id="supplier-company-details" class="page-section rows">
365                     <h2>Vendor details</h2>
366                     <li>
367                         <span class="label">Type: </span>
368                         [% IF (type) %][% AuthorisedValues.GetByCode( 'VENDOR_TYPE', type ) | html %][% END %]
369                     </li>
370                     <li><span class="label">Company name: </span>[% name | html %]</li>
371                     <li><span class="label">Postal address: </span>[% postal | html %]</li>
372                     <li><span class="label">Physical address: </span>[% address1 | html %][% address2 | html %][% address3 | html %][% address4 | html %]</li>
373                     <li><span class="label">Phone: </span>[% phone | html %]</li>
374                     <li><span class="label">Fax: </span>[% fax | html %]</li>
375                     [% IF ( url ) %]
376                         <li><span class="label">Website: </span><a href="[% url | url %]" target="_blank">[% url | html %]</a></li>
377                     [% END %]
378                     [% IF ( accountnumber ) %]
379                         <li><span class="label">Account number: </span>[% accountnumber | html %]</li>
380                     [% END %]
381                     [% IF vendor.aliases.count %]
382                         <li>
383                             <span class="label">Aliases: </span>
384                             <ul>
385                             [% FOR alias IN vendor.aliases %]
386                                 <li>[% alias.alias | html %]</li>
387                             [% END %]
388                             </ul>
389                         </li>
390                     [% END %]
391                 </div> <!-- /#supplier-company-details -->
392
393                 <div id="supplier-ordering-information" class="page-section rows">
394                     <h2>Ordering information</h2>
395                     <li><span class="label">Vendor is: </span>[% IF ( active ) %]Active[% ELSE %]Inactive[% END %]</li>
396                     <li><span class="label">List prices are: </span>[% listprice | html %]</li>
397                     <li><span class="label">Invoice prices are: </span>[% invoiceprice | html %]</li>
398                     [% IF ( tax_rate ) %]
399                         <li><span class="label">Tax number registered: </span>[% IF ( gstreg ) %]Yes[% ELSE %]No[% END %]</li>
400                         <li><span class="label">List item price includes tax: </span>[% IF ( listincgst ) %]Yes[% ELSE %]No[% END %]</li>
401                         <li><span class="label">Invoice item price includes tax: </span>[% IF ( invoiceincgst ) %]Yes[% ELSE %]No[% END %]</li>
402                     [% END %]
403                     <li><span class="label">Discount: </span>[% ( discount || 0 ) | format("%.1f" ) %] %</li>
404                     <li><span class="label">Tax rate: </span>[% ( tax_rate || 0 ) * 100 | html %] %</li>
405                     [% IF deliverytime.defined %]
406                         <li><span class="label">Delivery time: </span>[% deliverytime | html %] days</li>
407                     [% END %]
408                     [% IF ( notes ) %]
409                         <li><span class="label">Notes: </span>[% notes | html %]</li>
410                     [% END %]
411                 </div> <!-- #supplier-ordering-information -->
412
413                 [% IF vendor.interfaces.count %]
414                 <div id="supplier-interfaces" class="page-section rows">
415                     <h2>Interfaces</h2>
416
417                     [% FOR i IN vendor.interfaces %]
418                         <h3>[% i.name | html %]</h3>
419                         [% IF i.type %]
420                             <li><span class="label">Type: </span>[% AuthorisedValues.GetByCode( 'VENDOR_INTERFACE_TYPE', i.type) | html %]</li>
421                         [% END %]
422                         [% IF i.uri %]
423                             <li>
424                                 <span class="label">URI: </span><a href="[% i.uri | url %]" target="_blank">[% i.uri | html %]</a>
425                             </li>
426                         [% END %]
427                         [% IF i.login %]
428                             <li><span class="label">Login: </span>[% i.login | html %]</li>
429                         [% END %]
430                         [% IF i.password %]
431                             <li><span class="label">Password: </span><span class="password"><a href="#" class="show_password" data-plain-text-password="[% i.plain_text_password | html %]">Show</a></span></span></li>
432                         [% END %]
433                         [% IF i.account_email %]
434                             <li><span class="label">Account email: </span>[% i.account_email | html %]</li>
435                         [% END %]
436                         [% IF i.notes %]
437                             <li><span class="label">Notes: </span>[% i.notes | html %]</li>
438                         [% END %]
439                     [% END %]
440                 </div>
441                 [% END %]
442
443             </div> <!-- /.col-sm-6 -->
444
445             <div class="col-sm-6">
446                 <div id="supplier-contact-details" class="page-section rows">
447                     <h2>Contact</h2>
448                     [% FOREACH contact IN contacts %]
449                         [% INCLUDE show_contact %]
450                     [% END %]
451                 </div> <!-- /#supplier-contact-details -->
452
453                 <div id="subscription-details" class="page-section">
454                     <h2>Subscription details</h2>
455                     <p><strong>Number of subscriptions: </strong>
456                         [% IF (  CAN_user_serials ) %]
457                             <a href="/cgi-bin/koha/serials/serials-search.pl?bookseller_filter=[% name | uri %]&searched=1">[% subscriptioncount | html %]</a>
458                         [% ELSE %]
459                             [% subscriptioncount | html %]
460                         [% END %]
461                     </p>
462                 </div> <!-- /#subscription-details -->
463             </div> <!-- /.col-sm-6 -->
464
465         </div> <!-- /.row -->
466
467         [% IF ( contracts ) %]
468             <div id="supplier-contracts" class="page-section rows">
469                 <h2>Contract(s)</h2>
470                 <table id="contractst">
471                   <thead>
472                     <tr>
473                         <th scope="col">Name</th>
474                         <th scope="col">Description</th>
475                         <th scope="col">Start date</th>
476                         <th scope="col">End date</th>
477                         [% IF CAN_user_acquisition_contracts_manage %]
478                             <th scope="col" class="NoSort noExport">Actions</th>
479                         [% END %]
480                     </tr>
481                   </thead>
482                   <tbody>
483                     [% FOREACH contract IN contracts %]
484                         <tr>
485                         <td>
486                             <a href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&amp;contractnumber=[% contract.contractnumber | uri %]&amp;booksellerid=[% contract.booksellerid | uri %]">[% contract.contractname | html %]</a>
487                         </td>
488                         <td>[% contract.contractdescription | html %]</td>
489                         <td data-order="[% contract.contractstartdate | html %]">[% contract.contractstartdate | $KohaDates %]</td>
490                         <td data-order="[% contract.contractenddate | html %]">[% contract.contractenddate | $KohaDates %]</td>
491                         [% IF CAN_user_acquisition_contracts_manage %]
492                             <td class="actions">
493                                 <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&amp;contractnumber=[% contract.contractnumber | html %]&amp;booksellerid=[% contract.booksellerid | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
494                                 <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/aqcontract.pl?op=delete_confirm&amp;contractnumber=[% contract.contractnumber | html %]&amp;booksellerid=[% contract.booksellerid | html %]"><i class="fa fa-trash-can"></i> Delete</a>
495                             </td>
496                         [% END %]
497                         </tr>
498                     [% END %]
499                   </tbody>
500                 </table>
501             </div> <!-- /#supplier-contracts -->
502         [% END %]
503
504 [% END %]
505
506 </main>
507 </div> <!-- /.col-sm-10.col-sm-push-2 -->
508
509 <div class="col-sm-2 col-sm-pull-10">
510     <aside>
511         [% INCLUDE 'vendor-menu.inc' %]
512     </aside>
513 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
514 </div> <!-- /.row -->
515 [% MACRO jsinclude BLOCK %]
516     [% Asset.js("js/acquisitions-menu.js") | $raw %]
517     [% Asset.js("lib/hc-sticky.js") | $raw %]
518     [% Asset.js("js/acq.js") | $raw %]
519     [% INCLUDE 'datatables.inc' %]
520     <script>
521         function confirm_deletion() {
522             if (confirm(_("Confirm deletion of this vendor ?"))) {
523                 window.location="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | html %]&op=delete";
524             }
525         }
526
527         function add_contact() {
528             var new_contact = $('#contact-template').clone();
529             var timestamp = new Date().getTime();
530             $(new_contact).removeAttr('id');
531             $('input, textarea', new_contact).each(function () {
532                 $(this).attr('id', $(this).attr('id') + '_' + timestamp);
533             });
534             $(new_contact).insertBefore(this);
535             if ($('.supplier-contact').length === 2) { // First contact
536                 $.each(['.contact_acqprimary', '.contact_serialsprimary', '.contact_orderacquisition', '.contact_claimacquisition', '.contact_claimissues'], function (idx, checkbox) {
537                     $(checkbox, new_contact).click();
538                 });
539             }
540             $('input[name="contact_name"]', new_contact).focus();
541             return false;
542         }
543
544         function delete_contact(ev) {
545             $(this).parents('.supplier-contact').remove();
546             ev.preventDefault();
547         }
548
549         [% IF vendor %]
550         let aliases = [% To.json(vendor.aliases.unblessed) | $raw %];
551         [% ELSE %]
552         let aliases = [];
553         [% END %]
554         function remove_alias(i){
555             aliases.splice(i, 1);
556             refresh_aliases();
557         }
558
559         function encodeHTMLEntities(str){
560             return str.replace(/[&<>'"]/g,
561               tag => ({
562                   '&': '&amp;',
563                   '<': '&lt;',
564                   '>': '&gt;',
565                   "'": '&#39;',
566                   '"': '&quot;'
567                 }[tag]));
568         }
569
570         function add_alias(){
571             let alias = $("#new_alias").val();
572             if ( !alias.length > 0 ) { return }
573             aliases.push({alias});
574             refresh_aliases();
575         }
576         function refresh_aliases(){
577             let nodes = $("<div></div>");
578             aliases.forEach((a, i) => {
579                 let alias_str = encodeHTMLEntities(a.alias);
580                 let n = $("<div></div>").append(alias_str);
581                 let input = $('<input type="hidden" name="alias" />');
582                 input.val(a.alias);
583                 n.append(input);
584                 n.append(` <a style="cursor: pointer;" onclick="remove_alias(${i});"><i class="fa fa-trash" aria-hidden="true"></i> ` + _("Remove") + '</a>');
585                 nodes.append(n);
586             });
587             nodes.append("<input id='new_alias' type='text' class='noEnterSubmit' />");
588             nodes.append(' <a style="cursor: pointer;" onclick="add_alias();"><i class="fa fa-plus" aria-hidden="true"></i> ' + _("Add") + '</a>');
589             $("#aliases").html(nodes.html());
590         }
591
592         [% IF vendor %]
593             let interfaces = [];
594             [% FOR i_object IN vendor.interfaces %]
595                 [% SET i = i_object.unblessed %]
596                 [% SET i.password = i_object.plain_text_password %]
597                 interfaces.push([% To.json(i) | $raw %]);
598             [% END %]
599         [% ELSE %]
600             let interfaces = [];
601         [% END %]
602         function serialize_interface_form(){
603             interfaces = [];
604             $("#interfaces > fieldset.supplier-interface > ol.interface-form").each( (index, interface_form )=> {
605                 let interface = {};
606                 $(interface_form).find('input,textarea,select').serializeArray().map(attr => {
607                     let name = attr.name.replace(/interface_([\w_]+)_\d+/, "$1");
608                     interface[name] = attr.value
609                 })
610                 interfaces.push(interface);
611             });
612             return interfaces;
613         }
614         function remove_interface(i){
615             interfaces = serialize_interface_form();
616             interfaces.splice(i, 1);
617             refresh_interfaces();
618         }
619         function add_interface(){
620             interfaces = serialize_interface_form();
621             interfaces.push({
622                 type: "",
623                 name: "",
624                 uri: "",
625                 login: "",
626                 password: "",
627                 account_email: "",
628                 notes: "",
629             });
630             refresh_interfaces();
631         }
632         let av_select = {
633             VENDOR_INTERFACE_TYPE: $("[% PROCESS 'av-build-dropbox.inc', category="VENDOR_INTERFACE_TYPE" empty=1 | replace('\n', '') | replace('"', '\"') %]"),
634         };
635         function refresh_interfaces(){
636             let nodes = $("<div id='interfaces'></div>");
637             interfaces.forEach((interface, i) => {
638                 let n = $("<fieldset class='supplier-interface'></fieldset>");
639                 n.append("<legend>" + _("Interface details") + "</legend>");
640                 n.append(`<input type="hidden" name="interface_counter" value="${i}" />`);
641                 let ol = $('<ol class="interface-form"></ol>');
642                 let attributes = [
643                     { label: _("Name:"),          name: 'name',          type: 'text',     node: 'input' },
644                     { label: _("Type:"),          name: 'type',          type: 'select',   node: 'av_select', av_cat: 'VENDOR_INTERFACE_TYPE' },
645                     { label: _("URI:"),           name: 'uri',           type: 'url',      node: 'input' },
646                     { label: _("Login:"),         name: 'login',         type: 'text',     node: 'input' },
647                     { label: _("Password:"),      name: 'password',      type: 'text',     node: 'input' },
648                     { label: _("Account email:"), name: 'account_email', type: 'email',    node: 'input' },
649                     { label: _("Notes:"),         name: 'notes',         type: 'textarea', node: 'textarea' }
650                 ];
651                 attributes.forEach((attribute, ii) => {
652                     let li = $('<li></li>');
653                     li.append(`<label for="interface_${attribute.name}_${i}">${attribute.label}</label>`);
654                     if( attribute.node == 'input' ) {
655                         li.append(`<input type="${attribute.type}" size="40" id="interface_${attribute.name}_${i}" name="interface_${attribute.name}_${i}" value="${interface[attribute.name]}" />`);
656                     } else if ( attribute.node == 'textarea' ) {
657                         li.append(`<textarea cols="40" rows="3" id="interface_${attribute.name}_${i}" name="interface_${attribute.name}_${i}">${interface[attribute.name]}</textarea>`);
658                     } else if ( attribute.node == 'av_select' ) {
659                         let select = av_select[attribute.av_cat].clone();
660                         select.attr('name', `interface_${attribute.name}_${i}`);
661                         select.find(`option[value='${interface[attribute.name]}']`).prop("selected", true);
662                         li.append(select);
663                     }
664                     ol.append(li);
665                 });
666                 ol.append(`<li><button class="btn btn-default" onclick="remove_interface(${i});"><i class="fa fa-trash"></i> ` + _("Delete interface") + '</li>');
667                 n.append(ol);
668                 nodes.append(n);
669             });
670             nodes.append(`<button onclick="add_interface();" class="btn btn-default"><i class="fa fa-plus"></i> ` + _("Add another interface") + '</button>')
671             $("#interfaces").replaceWith(nodes);
672
673             interfaces.forEach((interface, i) => {
674                 $("#interface_account_email_" + i).rules("add", {
675                     email: true,
676                 });
677             });
678         }
679
680         var Sticky;
681
682          $(document).ready(function() {
683             var contractst = $("#contractst").dataTable($.extend(true, {}, dataTablesDefaults, {
684                 "aoColumnDefs": [
685                     { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }
686                 ],
687                 'sDom': 't'
688             } ) );
689             $('body').on('click', '.delete-contact', null, delete_contact);
690             $('#add-contact').click(add_contact);
691             $('body').on('click', '.contact_acqprimary', null, function () {
692                 if ($(this).is(':checked')) {
693                     $('.contact_acqprimary').filter(':checked').not(this).prop('checked', false);
694                     $('.contact_acqprimary_hidden').each(function () {
695                         $(this).val('0');
696                     });
697                 }
698                 $(this).next('.contact_acqprimary_hidden').val('1');
699             });
700             $('body').on('click', '.contact_serialsprimary', null, function () {
701                 if ($(this).is(':checked')) {
702                     $('.contact_serialsprimary').filter(':checked').not(this).prop('checked', false);
703                     $('.contact_serialsprimary_hidden').each(function () {
704                         $(this).val('0');
705                     });
706                 }
707                 $(this).next('.contact_serialsprimary_hidden').val($(this).is(':checked') ? '1' : '0');
708             });
709             $('body').on('click', '.contact_orderacquisition', null, function () {
710                 $(this).next('.contact_orderacquisition_hidden').val($(this).is(':checked') ? '1' : '0');
711             });
712             $('body').on('click', '.contact_claimacquisition', null, function () {
713                 $(this).next('.contact_claimacquisition_hidden').val($(this).is(':checked') ? '1' : '0');
714             });
715             $('body').on('click', '.contact_claimissues', null, function () {
716                 $(this).next('.contact_claimissues_hidden').val($(this).is(':checked') ? '1' : '0');
717             });
718
719             $('body').on('click', '.show_password', null, function(e){
720                 e.preventDefault();
721                 $(this).parent().replaceWith($(this).data('plain-text-password'));
722             });
723             refresh_aliases();
724             refresh_interfaces();
725
726             Sticky = $("#toolbar");
727             Sticky.hcSticky({
728                 stickTo: "main",
729                 stickyClass: "floating"
730             });
731         });
732     </script>
733 [% END %]
734
735 [% INCLUDE 'intranet-bottom.inc' %]