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