Bug 19603: Move admin templates JavaScript to the footer: Patrons and circulation
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / aqcontract.tt
1 [% USE KohaDates %]
2 [% SET footerjs = 1 %]
3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Koha &rsaquo; Acquisitions &rsaquo; Contracts &rsaquo;
5 [% IF ( add_form ) %]
6     [% IF ( contractnumber ) %]Modify contract '[% contractname %]'
7 [% ELSE %]New contract[% END %]
8 [% END %]
9 [% IF ( else ) %]Contracts of [% booksellername %][% END %]
10 [% IF ( add_validate ) %]Data recorded[% END %]
11 [% IF ( delete_confirm ) %]Confirm deletion of contract '[% contractnumber %]'[% END %]
12 [% IF ( delete_confirmed ) %]Contract deleted[% END %]</title>
13 [% INCLUDE 'doc-head-close.inc' %]
14 </head>
15
16 <body id="acq_aqcontract" class="acq">
17 [% INCLUDE 'header.inc' %]
18 [% INCLUDE 'contracts-admin-search.inc' %]
19
20 <div id="breadcrumbs">
21     <a href="/cgi-bin/koha/mainpage.pl">Home</a>
22     &rsaquo;
23     <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
24     &rsaquo;
25     <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername %]</a>
26     &rsaquo;
27     [% IF ( add_form ) %]
28         <a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid %]">Contracts</a>
29         &rsaquo;
30         [% IF ( contractnumber ) %]Modify contract '[% contractname %]'
31         [% ELSE %]New contract
32         [% END %]
33     [% END %]
34     [% IF ( add_validate ) %]
35         <a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid %]">Contracts</a>
36         &rsaquo; Data recorded
37     [% END %]
38     [% IF ( delete_confirm ) %]
39         <a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid %]">Contracts</a>
40         &rsaquo; Confirm deletion of contract [% contractnumber %]
41     [% END %]
42     [% IF ( delete_confirmed ) %]
43         <a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid %]">Contracts</a> &rsaquo; Contract deleted
44     [% END %]
45     [% IF ( else ) %]Contracts[% END %]
46 </div>
47
48 <div id="doc3" class="yui-t2">
49
50     <div id="bd">
51     <div id="yui-main">
52     <div class="yui-b">
53
54 [% INCLUDE 'acquisitions-toolbar.inc' %]
55
56 [% IF error == 'not_deleted' %]
57     <div class="dialog alert">Contract has not been deleted. Maybe a basket linked to this contract exists.</div>
58 [% END %]
59
60                 [% IF ( add_form ) %]
61                     <form name="Aform" action="[% script_name %]" method="post">
62                         <input type="hidden" name="op" value="add_validate" />
63                         <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
64                         <input type="hidden" name="checked" value="0" />
65                         [% IF ( contractnumber ) %]
66                             <h1>Modify contract [% contractname %] for [% booksellername %]</h1>
67                         [% ELSE %]
68                             <h1>New contract for [% booksellername %]</h1>
69                         [% END %]
70                         <fieldset class="rows">
71                             <ol>
72                                 [% IF ( contractnumber ) %]
73                                         <li><span class="label">Contract id </span>[% contractnumber %]
74                                             <input type="hidden" name="contractnumber" value="[% contractnumber %]" />
75                                             <input type="hidden" name="is_a_modif" value="1" />
76                                         </li>
77                                 [% END %]
78                                 <li><label for="contractname" class="required">Name: *</label> &nbsp;
79                                         <input type="text" name="contractname" id="contractname" size="40" maxlength="80" value="[% contractname %]" />
80                                 </li>
81                                 <li><label for="contractdescription">Description: </label> &nbsp;
82                                         <input type="text" name="contractdescription" id="contractdescription" size="40" maxlength="80" value="[% contractdescription %]" />
83                                 </li>
84                                 <li><label for="from" class="required">Start date: *</label> &nbsp;
85                                         <input type="text" name="contractstartdate" id="from" value="[% contractstartdate | $KohaDates %]" maxlength="10" size="10" class="datepickerfrom" />
86                                 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
87                                 </li>
88                                 <li><label for="to" class="required">End date: *</label> &nbsp;
89                                         <input type="text" name="contractenddate" id="to" value="[% contractenddate | $KohaDates %]" maxlength="10"  size="10" class="datepickerto" />
90                                 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
91                                 </li>
92                             </ol>
93                         </fieldset>
94                         <fieldset class="action">
95                             <input type="button" value="Save" onclick="Check(this.form);" /> <a class="cancel" href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid %]&amp;contractnumber=[% contractnumber %]">Cancel</a>
96                         </fieldset>
97                     </form>
98             [% END %]
99             [% IF ( add_validate ) %]
100                 <h3>Data recorded</h3>
101                 <form action="[% script_name %]" method="post">
102                     <input type="submit" value="OK" />
103                 </form>
104             [% END %]
105             [% IF ( delete_confirm ) %]
106                     <div class="dialog alert">
107                         <h3>Confirm deletion of contract <i>[% contractname %]</i></h3>
108                         <table>
109                             <tr><th scope="row">Contract number:</th><td>[% contractnumber %]</td></tr>
110                             <tr><th scope="row">Contract name:</th><td>[% contractname %]</td></tr>
111                             <tr><th scope="row">Contract description:</th><td>[% contractdescription %]</td></tr>
112                             <tr><th scope="row">Contract start date:</th><td>[% contractstartdate | $KohaDates %]</td></tr>
113                             <tr><th scope="row">Contract end date:</th><td>[% contractenddate | $KohaDates %]</td></tr>
114                             <tr><th scope="row">Vendor:</th><td>[% booksellername %]</td></tr>
115                         </table>
116                         <form action="[% script_name %]" method="post">
117                             <input type="hidden" name="op" value="delete_confirmed" />
118                             <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
119                             <input type="hidden" name="contractnumber" value="[% contractnumber %]" />
120                             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete contract</button>
121                         </form>
122                         <form action="/cgi-bin/koha/admin/aqcontract.pl" method="get">
123                             <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
124                             <input type="hidden" name="contractnumber" value="[% contractnumber %]" />
125                             <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
126                         </form>
127                     </div>
128             [% END %]
129             [% IF ( delete_confirmed ) %]
130                 <h3>Contract deleted</h3>
131                 <form action="[% script_name %]" method="post">
132                     <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
133                     <input type="submit" value="OK" />
134                 </form>
135             [% END %]
136             [% IF ( else ) %]
137                 <h2>Contract(s) of [% booksellername %]</h2>
138                 [% IF ( loop ) %]
139                     <table>
140                         <tr>
141                             <th scope="col">Name</th>
142                             <th scope="col">Description</th>
143                             <th scope="col">Start date</th>
144                             <th scope="col">End date</th>
145                             <th scope="col">Actions</th>
146                         </tr>
147                     [% FOREACH loo IN loop %]
148                         <tr>
149                         <td>
150                             <a href="[% loo.script_name %]?op=add_form&amp;booksellerid=[% loo.booksellerid %]&amp;contractnumber=[% loo.contractnumber %]">[% loo.contractname %]</a>
151                         </td>
152                         <td>[% loo.contractdescription %]</td>
153                         <td>[% loo.contractstartdate %]</td>
154                         <td>[% loo.contractenddate %]</td>
155                         <td class="actions">
156                             <a href="[% loo.script_name %]?op=add_form&amp;contractnumber=[% loo.contractnumber %]&amp;booksellerid=[% loo.booksellerid %]" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
157                             <a href="[% loo.script_name %]?op=delete_confirm&amp;contractnumber=[% loo.contractnumber %]&amp;booksellerid=[% loo.booksellerid %]" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a>
158                         </td>
159                         </tr>
160                     [% END %]
161                 </table>
162                 [% ELSE %]
163                     <div class="dialog message">
164                         There are no contracts with this vendor.
165                         [% IF active %]
166                             <a href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&amp;booksellerid=[% booksellerid %]">Add a contract</a>.
167                         [% END %]
168                     </div>
169                 [% END %]
170             [% END %]
171 </div>
172 </div>
173 <div class="yui-b">
174 [% INCLUDE 'vendor-menu.inc' %]
175 </div>
176 </div>
177 [% MACRO jsinclude BLOCK %]
178     [% INCLUDE 'calendar.inc' %]
179     <script type="text/javascript" src="[% interface %]/[% theme %]/js/acq.js"></script>
180     <script type="text/javascript">
181     //<![CDATA[
182     // to check if the data are correctly entered.
183     function Check(ff) {
184         var ok=0;
185         var _alertString=_("Form not submitted because of the following problem(s)");
186         _alertString +="\n-------------------------------------------------------------------\n\n";
187         if (!(isNotNull(ff.contractname,0))){
188             ok=1;
189             _alertString += _("- Name missing") + "\n";
190         }
191         var startDate = Date_from_syspref($("#from").val());
192         var endDate   = Date_from_syspref($("#to").val());
193         if (!parseInt(startDate.getTime())) {
194             ok=1;
195             _alertString += _("- Start date missing or invalid.") + "\n";
196         }
197         if (!parseInt(endDate.getTime())) {
198             ok=1;
199             _alertString += _("- End date missing or invalid.") + "\n";
200         }
201
202         if (startDate > endDate) {
203             ok=1;
204             _alertString += _("Wrong date! start date cannot be after end date.") + "\n";
205         }
206         if (endDate < (new Date)) {
207             ok=1;
208             _alertString += _("End date before today, Invalid end date!") + "\n";
209         }
210         if (ok) { // if there is a problem
211             alert(_alertString);
212         return false;
213     }
214     // if all is good
215         ff.submit();
216     }
217     //]]>
218     </script>
219 [% END %]
220 [% INCLUDE 'intranet-bottom.inc' %]