Bug 19755: Move template JavaScript to the footer: Acquisitions, part 3
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / supplier.tt
1 [% USE KohaDates %]
2 [% BLOCK edit_contact %]
3     <ol id="contact-form">
4         <input type="hidden" name="contact_id" value="[% contact.id %]" />
5         <li><label for="contact_name[% contact.id %]">Contact name: </label>
6             <input type="text" size="40" id="contact_name[% contact.id %]" name="contact_name" value="[% contact.name %]" /></li>
7         <li><label for="contact_position[% contact.id %]">Position: </label>
8             <input type="text" size="40" id="contact_position[% contact.id %]" name="contact_position" value="[% contact.position %]" /></li>
9         <li><label for="contact_phone[% contact.id %]">Phone: </label>
10                 <input type="text" size="20" id="contact_phone[% contact.id %]" name="contact_phone" value="[% contact.phone %]" /> </li>
11         <li><label for="contact_altphone[% contact.id %]">Alternative phone: </label>
12             <input type="text" size="20" id="contact_altphone[% contact.id %]" name="contact_altphone" value="[% contact.altphone %]" /></li>
13         <li><label for="contact_fax[% contact.id %]">Fax: </label>
14             <input type="text" size="20" id="contact_fax[% contact.id %]" name="contact_fax" value="[% contact.fax %]" /></li>
15         <li><label for="contact_email[% contact.id %]">Email: </label>
16             <input type="text" size="40" id="contact_email[% contact.id %]" name="contact_email" value="[% contact.email %]" class="email" /></li>
17         <li><label for="contact_notes[% contact.id %]">Notes: </label>
18             <textarea id="contact_notes[% contact.id %]" name="contact_notes" cols="40" rows="4">[% contact.notes %]</textarea></li>
19         <li><label for="contact_acqprimary[% contact.id %]">Primary acquisitions contact:</label>
20             [% IF contact.acqprimary %]
21                 <input type="checkbox" id="contact_acqprimary[% contact.id %]" class="contact_acqprimary" checked="checked"></input>
22             [% ELSE %]
23                 <input type="checkbox" id="contact_acqprimary[% contact.id %]" class="contact_acqprimary"></input>
24             [% END %]
25             <input type="hidden" class="contact_acqprimary_hidden" name="contact_acqprimary" value="[% contact.acqprimary %]"></input>
26         <li><label for="contact_serialsprimary[% contact.id %]">Primary serials contact:</label>
27             [% IF contact.serialsprimary %]
28                 <input type="checkbox" id="contact_serialsprimary[% contact.id %]" class="contact_serialsprimary" checked="checked"></input>
29             [% ELSE %]
30                 <input type="checkbox" id="contact_serialsprimary[% contact.id %]" class="contact_serialsprimary"></input>
31             [% END %]
32             <input type="hidden" class="contact_serialsprimary_hidden" name="contact_serialsprimary" value="[% contact.serialsprimary %]"></input>
33         <li><label for="contact_orderacquisition[% contact.id %]">Contact when ordering?</label>
34             [% IF contact.orderacquisition %]
35                 <input type="checkbox" id="contact_orderacquisition[% contact.id %]" class="contact_orderacquisition" checked="checked"></input>
36             [% ELSE %]
37                 <input type="checkbox" id="contact_orderacquisition[% contact.id %]" class="contact_orderacquisition"></input>
38             [% END %]
39             <input type="hidden" class="contact_orderacquisition_hidden" name="contact_orderacquisition" value="[% contact.orderacquisition %]"></input>
40         <li><label for="contact_claimacquisition[% contact.id %]">Contact about late orders?</label>
41             [% IF contact.claimacquisition %]
42                 <input type="checkbox" id="contact_claimacquisition[% contact.id %]" class="contact_claimacquisition" checked="checked"></input>
43             [% ELSE %]
44                 <input type="checkbox" id="contact_claimacquisition[% contact.id %]" class="contact_claimacquisition"></input>
45             [% END %]
46             <input type="hidden" class="contact_claimacquisition_hidden" name="contact_claimacquisition" value="[% contact.claimacquisition %]"></input>
47         <li><label for="contact_claimissues[% contact.id %]">Contact about late issues?</label>
48             [% IF contact.claimissues %]
49                 <input type="checkbox" id="contact_claimissues[% contact.id %]" class="contact_claimissues" checked="checked"></input>
50             [% ELSE %]
51                 <input type="checkbox" id="contact_claimissues[% contact.id %]" class="contact_claimissues"></input>
52             [% END %]
53             <input type="hidden" class="contact_claimissues_hidden" name="contact_claimissues" value="[% contact.claimissues %]"></input>
54         </li>
55         [% IF contact.id %]<li><button class="btn btn-default delete-contact"><i class="fa fa-trash"></i> Delete contact</li>[% END %]
56     </ol>
57 [% END %]
58
59 [% BLOCK show_contact %]
60     <h3>[% contact.name |html %]</h3>
61     <p><span class="label">Position: </span>[% contact.position |html %]</p>
62     <p><span class="label">Phone: </span>[% contact.phone |html %]</p>
63     <p><span class="label">Alternative phone: </span>[% contact.altphone |html %]</p>
64     <p><span class="label">Fax: </span>[% contact.fax |html %]</p>
65     [% IF ( contact.email ) %]
66         <p><span class="label">Email: </span><a href="mailto:[% contact.email %]">[% contact.email %]</a></p>
67     [% END %]
68     [% IF ( contact.notes ) %]
69         <p><span class="label">Notes: </span>[% contact.notes |html %]</p>
70     [% END %]
71     [% IF ( contact.acqprimary ) %]
72         <p><span class="label">Primary acquisitions contact</span></p>
73     [% END %]
74     [% IF ( contact.serialsprimary ) %]
75         <p><span class="label">Primary serials contact</span></p>
76     [% END %]
77     [% IF ( contact.orderacquisition ) %]
78         <p><span class="label">Receives orders</span></p>
79     [% END %]
80     [% IF ( contact.claimacquisition ) %]
81         <p><span class="label">Receives claims for late orders</span></p>
82     [% END %]
83     [% IF ( contact.claimissues ) %]
84         <p><span class="label">Receives claims for late issues</span></p>
85     [% END %]
86 [% END %]
87
88 [% SET footerjs = 1 %]
89 [% INCLUDE 'doc-head-open.inc' %]
90 <title>Koha &rsaquo; Vendor [% name %]</title>
91 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
92 [% INCLUDE 'doc-head-close.inc' %]
93 </head>
94
95 <body id="acq_supplier" class="acq">
96 [% INCLUDE 'header.inc' %]
97 [% INCLUDE 'acquisitions-search.inc' %]
98
99 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; [% IF ( enter ) %][% IF ( booksellerid ) %] <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% name |html %]</a> &rsaquo; Update: [% name |html %][% ELSE %]Add vendor[% END %] [% ELSE %][% name |html %][% END %]</div>
100
101 <div id="doc3" class="yui-t2">
102
103 <div id="bd">
104     <div id="yui-main">
105     <div class="yui-b">
106     [% IF ( enter ) %]
107         [% IF ( booksellerid ) %]
108         <h1>Update: [% name |html %]</h1>
109     [% ELSE %]
110         <h1>Add vendor</h1>
111     [% END %]
112     [% END %]
113 [% UNLESS ( enter ) %][% INCLUDE 'acquisitions-toolbar.inc' %][% END %]
114 [% IF ( enter ) %]
115     <form action="updatesupplier.pl" name="updatesupplier" class="validated" method="post">
116     <div class="yui-g">
117         <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
118         <fieldset class="rows">
119             <legend>Company details</legend>
120             <ol><li><label for="company" class="required">Name:</label>
121                 <input type="text" size="40" id="company" name="company" value="[% name %]" required="required" class="required" /><span class="required">Required</span></li>
122             <li><label for="company_postal">Postal address: </label>
123                     <textarea id="company_postal" name="company_postal" cols="40" rows="3">[% postal %]</textarea></li>
124             <li><label for="physical">Physical address: </label>
125                 <textarea id="physical" name="physical" cols="40" rows="3">[% address1 %][% address2 %][% address3 %][% address4 %]</textarea></li>
126             <li><label for="company_phone">Phone: </label>
127                 <input type="text" size="20" id="company_phone" name="company_phone" value="[% phone %]" /></li>
128             <li><label for="company_fax">Fax: </label>
129                 <input type="text" size="20" id="company_fax" name="company_fax" value="[% fax %]" /></li>
130             <li><label for="website">Website: </label>
131                 <input type="text" size="40" id="website" name="website" value="[% url %]" class="url" /></li>
132             <li><label for="accountnumber">Account number: </label>
133                 <input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol>
134         </fieldset>
135         <fieldset class="rows">
136             <legend>Contacts</legend>
137             <fieldset id="contact-template" class="supplier-contact">
138                 <legend>Contact details</legend>
139                 [% INCLUDE edit_contact %]
140             </fieldset>
141             [% FOREACH contact IN contacts %]
142                 <fieldset class="supplier-contact">
143                     <legend>Contact details</legend>
144                     [% INCLUDE edit_contact %]
145                 </fieldset>
146             [% END %]
147             <button id="add-contact" class="btn btn-default"><i class="fa fa-plus"></i> Add another contact</button>
148         </fieldset>
149     </div>
150         <div class="yui-g">
151         <fieldset class="rows">
152             <legend>Ordering information</legend>
153             <ol class="radio"><li><label for="activestatus" class="radio">Vendor is:</label>
154                     [% IF ( active ) %]
155                         <label for="activestatus">Active</label> <input type="radio" id="activestatus" name="status" value="1" checked="checked" />
156                         <label for="inactivestatus">Inactive</label> <input type="radio" id="inactivestatus" name="status" value="0" />
157                     [% ELSE %]
158                         <label for="activestatus">Active</label> <input type="radio" id="activestatus" name="status" value="1" />
159                         <label for="inactivestatus">Inactive</label> <input type="radio" id="inactivestatus" name="status" value="0" checked="checked" />
160                     [% END %]</li>
161             </ol>
162             <ol>
163             <li><label for="list_currency">List prices are: </label>
164                 <select name="list_currency" id="list_currency">
165                     [% FOREACH c IN currencies %]
166                         [% IF booksellerid and c.currency == listprice or not booksellerid and c.active %]
167                             <option value="[% c.currency %]" selected="selected">[% c.currency %]</option>
168                         [% ELSIF not c.archived %]
169                             <option value="[% c.currency %]">[% c.currency %]</option>
170                         [% END %]
171                     [% END %]
172                 </select>
173             </li>
174             <li><label for="invoice_currency">Invoice prices are: </label>
175                 <select name="invoice_currency" id="invoice_currency">
176                     [% FOREACH c IN currencies %]
177                         [% IF booksellerid and c.currency == invoiceprice or not booksellerid and c.active %]
178                             <option value="[% c.currency %]" selected="selected">[% c.currency %]</option>
179                         [% ELSIF not c.archived %]
180                             <option value="[% c.currency %]">[% c.currency %]</option>
181                         [% END %]
182                     [% END %]
183                 </select>
184             </li>
185             </ol>
186             <ol class="radio">
187             <li><label for="gstyes" class="radio">Tax number registered:</label>
188                 [% IF ( gstreg ) %]
189                     <label for="gstyes">Yes</label> <input type="radio" name="gst" id="gstyes" value="1" checked="checked" />
190                     <label for="gstno">No</label> <input type="radio" name="gst" id="gstno" value="0" />
191                 [% ELSE %]
192                     <label for="gstyes">Yes</label> <input type="radio" name="gst" id="gstyes" value="1" />
193                     <label for="gstno">No</label> <input type="radio" name="gst" id="gstno" value="0" checked="checked" />
194                 [% END %]</li>
195             
196             <li><label for="list_gstyes" class="radio">List prices:</label>
197                 [% IF ( listincgst ) %]
198                     <label for="list_gstyes">Include tax</label> <input type="radio" id="list_gstyes" name="list_gst" value="1" checked="checked" />
199                     <label for="list_gstno">Don't include tax</label> <input type="radio" id="list_gstno" name="list_gst" value="0" />
200                 [% ELSE %]
201                     <label for="list_gstyes">Include tax</label> <input type="radio" id="list_gstyes" name="list_gst" value="1" />
202                     <label for="list_gstno">Don't include tax</label> <input type="radio" id="list_gstno" name="list_gst" value="0" checked="checked" />
203                 [% END %]</li>
204             
205             <li><label for="invoice_gstyes" class="radio">Invoice prices:</label>
206                 [% IF ( invoiceincgst ) %]
207                     <label for="invoice_gstyes">Include tax</label> <input type="radio" id="invoice_gstyes" name="invoice_gst" value="1" checked="checked" />
208                     <label for="invoice_gstno">Don't include tax</label> <input type="radio" id="invoice_gstno" name="invoice_gst" value="0" />
209                     [% ELSE %]
210                     <label for="invoice_gstyes">Include tax</label> <input type="radio" id="invoice_gstyes" name="invoice_gst" value="1" />
211                     <label for="invoice_gstno">Don't include tax</label> <input type="radio" id="invoice_gstno" name="invoice_gst" value="0" checked="checked" />
212                 [% END %]</li>
213             </ol>
214             [% IF gst_values %]
215                 <ol>
216                   <li>
217                     <label for="tax_rate">Tax rate: </label>
218                     <select name="tax_rate" id="tax_rate">
219                     [% FOREACH gst IN gst_values %]
220                       [% IF ( tax_rate == gst.option ) %]
221                         <option value="[% gst.option %]" selected="selected">[% gst.option * 100 %] %</option>
222                       [% ELSE %]
223                         <option value="[% gst.option %]">[% gst.option * 100 %] %</option>
224                       [% END %]
225                     [% END %]
226                     </select>
227                   </li>
228                 </ol>
229             [% ELSE %]
230                 <input type="hidden" name="tax_rate" value="0" />
231             [% END %]
232             <ol>
233             <li><label for="discount">Discount: </label>
234                 <input type="text" size="6" id="discount" name="discount" value="[% discount | format ("%.1f") %]" />%</li>
235             <li>
236                 <label for="deliverytime">Delivery time: </label>
237                 <input type="text" size="2" id="deliverytime" name="deliverytime" value="[% deliverytime %]" /> days
238             </li>
239             <li><label for="notes">Notes: </label>
240                 <textarea cols="40" rows="4" id="notes" name="notes" >[% notes %]</textarea></li></ol>
241         </fieldset>
242         <fieldset class="action"><input type="submit" value="Save" /> [% IF ( booksellerid ) %]
243         <a class="cancel" href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% ELSE %]<a class="cancel" href="/cgi-bin/koha/acqui/acqui-home.pl">
244         [% END %]Cancel</a></fieldset>
245         </div>
246     </form>
247 [% ELSE %]
248     <h1>[% name |html %]</h1>
249         <div class="yui-g">
250             <div id="supplier-company-details" class="yui-u first">
251                 <h2>Vendor details</h2>
252                 <p><span class="label">Company name: </span>[% name |html %]</p>
253                 <p><span class="label">Postal address: </span>[% postal |html %]</p>
254                 <p><span class="label">Physical address: </span>[% address1 |html %][% address2 |html %][% address3 |html %][% address4 |html %]</p>
255                 <p><span class="label">Phone: </span>[% phone |html %]</p>
256                 <p><span class="label">Fax: </span>[% fax |html %]</p>
257                 [% IF ( url ) %]
258                     <p><span class="label">Website: </span><a href="[% url %]">[% url %]</a></p>
259                 [% END %]
260                 [% IF ( accountnumber ) %]
261                     <p><span class="label">Account number: </span>[% accountnumber |html %]</p>
262                 [% END %]
263
264             <div id="supplier-ordering-information">
265             <h2>Ordering information</h2>
266                 <p><strong>Vendor is: </strong>
267                         [% IF ( active ) %]
268                             Active
269                         [% ELSE %]
270                             Inactive
271                         [% END %]</p>
272                 <p><strong>List prices are: </strong>[% listprice %]</p>
273                 <p><strong>Invoice prices are: </strong>[% invoiceprice %]</p>
274                 [% IF ( tax_rate ) %]<p><strong>Tax number registered: </strong>
275                         [% IF ( gstreg ) %]Yes[% ELSE %]No[% END %]</p>
276                 <p><strong>List item price includes tax: </strong>
277                         [% IF ( listincgst ) %]Yes[% ELSE %]No[% END %]</p>
278                 <p><strong>Invoice item price includes tax: </strong>
279                         [% IF ( invoiceincgst ) %]Yes[% ELSE %]No[% END %]</p>[% END %]
280                 <p><strong>Discount: </strong>
281                     [% discount | format("%.1f") %] %</p>
282                 <p><strong>Tax rate: </strong>
283                     [% ( tax_rate || 0 ) * 100 %] %</p>
284                 [% IF deliverytime.defined %]
285                     <p><strong>Delivery time: </strong>
286                         [% deliverytime %] days</p>
287                 [% END %]
288                 [% IF ( notes ) %]<p><strong>Notes: </strong>
289                     [% notes |html %]</p>[% END %]
290             </div>
291             </div>
292
293             <div class="supplier-contact-details yui-u">
294                 <h2>Contact</h2>
295                 [% FOREACH contact IN contacts %]
296                     [% INCLUDE show_contact %]
297                 [% END %]
298             </div>
299
300             <div>
301
302                 <div class="subscription-details">
303                     <h2>Subscription details</h2>
304                     <p><strong>Number of subscriptions: </strong>[% subscriptioncount %]</p>
305                 </div>
306
307             </div>
308
309         </div>
310
311         [% IF ( contracts ) %]
312             <div id="supplier-contracts" class="yui-g">
313                 <h2>Contract(s)</h2>
314                 <table id="contractst">
315                   <thead>
316                     <tr>
317                         <th scope="col">Name</th>
318                         <th scope="col">Description</th>
319                         <th scope="col" class="title-string">Start date</th>
320                         <th scope="col" class="title-string">End date</th>
321                         <th scope="col">Actions</th>
322                     </tr>
323                   </thead>
324                   <tbody>
325                     [% FOREACH contract IN contracts %]
326                         <tr>
327                         <td>
328                             <a href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&amp;contractnumber=[% contract.contractnumber %]&amp;booksellerid=[% contract.booksellerid %]">[% contract.contractname %]</a>
329                         </td>
330                         <td>[% contract.contractdescription %]</td>
331                         <td><span title="[% contract.contractstartdate %]">[% contract.contractstartdate | $KohaDates %]</span></td>
332                         <td><span title="[% contract.contractenddate %]">[% contract.contractenddate | $KohaDates %]</span></td>
333                         <td class="actions">
334                             <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&amp;contractnumber=[% contract.contractnumber %]&amp;booksellerid=[% contract.booksellerid %]"><i class="fa fa-pencil"></i> Edit</a>
335                             <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/aqcontract.pl?op=delete_confirm&amp;contractnumber=[% contract.contractnumber %]&amp;booksellerid=[% contract.booksellerid %]"><i class="fa fa-trash"></i> Delete</a>
336                         </td>
337                         </tr>
338                     [% END %]
339                   </tbody>
340                 </table>
341             </div>
342         [% END %]
343
344 [% END %]
345
346 </div>
347 </div>
348 <div class="yui-b">
349 [% INCLUDE 'vendor-menu.inc' %]
350 </div>
351 </div>
352
353 [% MACRO jsinclude BLOCK %]
354     <script type="text/javascript" src="[% interface %]/[% theme %]/js/acquisitions-menu_[% KOHA_VERSION %].js"></script>
355     [% INCLUDE 'datatables.inc' %]
356     <script type="text/javascript">
357         function confirm_deletion() {
358             if (confirm(_("Confirm deletion of this vendor ?"))) {
359                 window.location="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]&op=delete";
360             }
361         }
362
363         function add_contact() {
364             var new_contact = $('#contact-template').clone();
365             var timestamp = new Date().getTime();
366             $(new_contact).removeAttr('id');
367             $('input, textarea', new_contact).each(function () {
368                 $(this).attr('id', $(this).attr('id') + '_' + timestamp);
369             });
370             $('label', new_contact).each(function () {
371                 $(this).attr('for', $(this).attr('for') + '_' + timestamp);
372             });
373             $(new_contact).insertBefore(this);
374             if ($('.supplier-contact').length === 2) { // First contact
375                 $.each(['.contact_acqprimary', '.contact_serialsprimary', '.contact_orderacquisition', '.contact_claimacquisition', '.contact_claimissues'], function (idx, checkbox) {
376                     $(checkbox, new_contact).click();
377                 });
378             }
379             $('input[name="contact_name"]', new_contact).focus();
380             return false;
381         }
382
383         function delete_contact(ev) {
384             $(this).parents('.supplier-contact').remove();
385             ev.preventDefault();
386         }
387
388          $(document).ready(function() {
389             var contractst = $("#contractst").dataTable($.extend(true, {}, dataTablesDefaults, {
390                 "aoColumnDefs": [
391                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
392                     { "sType": "title-string", "aTargets" : [ "title-string" ] }
393                 ],
394                 'sDom': 't'
395             } ) );
396             $('body').on('click', '.delete-contact', null, delete_contact);
397             $('#add-contact').click(add_contact);
398             $('body').on('click', '.contact_acqprimary', null, function () {
399                 if ($(this).is(':checked')) {
400                     $('.contact_acqprimary').filter(':checked').not(this).prop('checked', false);
401                     $('.contact_acqprimary_hidden').each(function () {
402                         $(this).val('0');
403                     });
404                 }
405                 $(this).next('.contact_acqprimary_hidden').val('1');
406             });
407             $('body').on('click', '.contact_serialsprimary', null, function () {
408                 if ($(this).is(':checked')) {
409                     $('.contact_serialsprimary').filter(':checked').not(this).prop('checked', false);
410                     $('.contact_serialsprimary_hidden').each(function () {
411                         $(this).val('0');
412                     });
413                 }
414                 $(this).next('.contact_serialsprimary_hidden').val($(this).is(':checked') ? '1' : '0');
415             });
416             $('body').on('click', '.contact_orderacquisition', null, function () {
417                 $(this).next('.contact_orderacquisition_hidden').val($(this).is(':checked') ? '1' : '0');
418             });
419             $('body').on('click', '.contact_claimacquisition', null, function () {
420                 $(this).next('.contact_claimacquisition_hidden').val($(this).is(':checked') ? '1' : '0');
421             });
422             $('body').on('click', '.contact_claimissues', null, function () {
423                 $(this).next('.contact_claimissues_hidden').val($(this).is(':checked') ? '1' : '0');
424             });
425         });
426     </script>
427 [% END %]
428
429 [% INCLUDE 'intranet-bottom.inc' %]