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