Bug 26592: [20.05] Prevent XSS vulnerabilities when circ/ysearch.pl is used
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / reports / dictionary.tt
1 [% SET footerjs = 1 %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha &rsaquo; Reports &rsaquo; Guided reports &rsaquo; Dictionary</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5 <style>fieldset.rows table { clear: none; margin: 0;}</style>
6 </head>
7
8 <body id="rep_dictionary" class="rep">
9 [% INCLUDE 'header.inc' %]
10 [% INCLUDE 'circ-search.inc' %]
11
12 [%- BLOCK area_name -%]
13     [%- SWITCH area -%]
14         [%- CASE 'CIRC' -%]Circulation
15         [%- CASE 'CAT'  -%]Catalog
16         [%- CASE 'PAT'  -%]Patrons
17         [%- CASE 'ACQ'  -%]Acquisitions
18         [%- CASE 'ACC'  -%]Accounts
19         [%- CASE 'SER'  -%]Serials
20     [%- END -%]
21 [%- END -%]
22
23 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a> &rsaquo; <a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports wizard</a>
24 [% IF ( new_dictionary ) %] &rsaquo; <a href="/cgi-bin/koha/reports/dictionary.pl">Dictionary</a> &rsaquo; <strong>Name the new definition</strong>
25 [% ELSIF ( step_2 ) %] &rsaquo; <a href="/cgi-bin/koha/reports/dictionary.pl">Dictionary</a> &rsaquo; <strong>Step 2: Choose the area </strong> 
26 [% ELSIF ( step_3 ) %] &rsaquo; <a href="/cgi-bin/koha/reports/dictionary.pl">Dictionary</a> &rsaquo; <strong>Step 3: Choose a column </strong>
27 [% ELSIF ( step_4 ) %] &rsaquo; <a href="/cgi-bin/koha/reports/dictionary.pl">Dictionary</a> &rsaquo; <strong>Step 4: Specify a value </strong> 
28 [% ELSIF ( step_5 ) %] &rsaquo; <a href="/cgi-bin/koha/reports/dictionary.pl">Dictionary</a> &rsaquo; <strong>Step 5: Confirm definition</strong> 
29 [% ELSE %] &rsaquo; <strong> Dictionary </strong>[% END %]</div>
30
31 <div class="main container-fluid">
32     <div class="row">
33         <div class="col-sm-10 col-sm-push-2">
34             <main>
35
36 [% IF ( start_dictionary ) %]
37     <div id="toolbar">
38         <a id="newdictionary" class="btn btn-default" href="/cgi-bin/koha/reports/dictionary.pl?phase=Add%20New%20Definition"><i class="fa fa-plus"></i> New definition</a>
39     </div>
40 [% END %]
41 <h1>Dictionary</h1>
42 [% IF ( start_dictionary ) %]
43         <p>Use the dictionary to define custom criteria for reporting.</p>
44
45                 [% IF ( definitions ) %]
46         <h2>Current terms</h2>
47                 <form action="/cgi-bin/koha/reports/dictionary.pl" method="post">
48         <input type="hidden" name="phase" value="View Dictionary" />
49   [% IF ( areas ) %]
50         Filter by area
51         <select name="area">
52           <option value="">All</option>
53         [% FOREACH area IN areas %]
54           [%- IF ( area.selected ) -%]
55           <option value="[% area.id | html %]" selected="selected">[%- PROCESS area_name area=area.id -%]</option>
56           [%- ELSE -%]
57           <option value="[% area.id | html %]">[%- PROCESS area_name area=area.id -%]</option>
58           [%- END -%]
59         [% END %]
60         </select>
61       <input name="submit" value="Go" type="submit" />
62   [% END %]
63       </form>
64       <br />
65         <table>
66             <tr>
67                 <th>Name</th>
68                 <th>Description</th>
69                 <th>Area</th>
70                 <th>Definition</th>
71                 <th>Action</th>
72             </tr>
73             [% FOREACH definition IN definitions %]
74             <tr>
75                 <td>[% definition.name | html %]</td>
76                 <td>[% definition.description | html %]</td>
77                 <td>[% definition.areaname | html %]</td>
78                 <td>[% definition.saved_sql | html %]</td>
79                 <td class="actions"><form method="post" action="/cgi-bin/koha/reports/dictionary.pl">
80                     <input type="hidden" name="id" value="[% definition.id | html %]" />
81                     <input type="hidden" name="phase" value="Delete Definition" />
82                     <button type="submit" name="submit" class="btn btn-default btn-xs" id="delete"><i class="fa fa-trash"></i> Delete</button>
83                 </form></td>
84             </tr>
85             [% END %]
86         </table>
87                 [% ELSE %]
88                 <div class="dialog message">There are no saved definitions. <a id="newdictionary" href="/cgi-bin/koha/reports/dictionary.pl?phase=Add%20New%20Definition">Add a definition to the dictionary.</a></div>
89                 [% END %]
90 [% END %]
91
92 [% IF ( new_dictionary ) %]
93 <h3>Add new definition</h3>
94 <form action="/cgi-bin/koha/reports/dictionary.pl" method="post">
95 <fieldset class="rows"><legend>Step 1 of 5: Name the new definition</legend><ol>
96 <li>
97 <label for="definition_name">Definition name:</label>
98 <input type="text" id="definition_name" name="definition_name" />
99 </li>
100 <li>
101 <label for="definition_description">Definition description:</label>
102 <textarea name="definition_description" id="definition_description" rows="3" cols="20"></textarea>
103 </li>
104 </ol></fieldset>
105
106 <fieldset class="action"><input type="hidden" name="phase" value="New Term step 2" />
107 <input name="submit" value="Next" type="submit" /></fieldset>
108 </form>
109 [% END %]
110
111 [%- IF ( step_2 ) -%]
112 <h3>Add new definition</h3>
113 <form action="/cgi-bin/koha/reports/dictionary.pl" method="post">
114   <fieldset class="rows">
115     <legend>Step 2 of 5: Choose the area</legend>
116     <ol>
117       <li>
118         <input type="hidden" name="phase" value="New Term step 3" />
119         <input type="hidden" name="definition_name" value="[% definition_name | html %]" />
120         <input type="hidden" name="definition_description" value="[% definition_description | html %]" />
121         <label for="area">Select table:</label><select name="area" id="area">
122       [%- FOREACH area IN areas -%]
123         <option value="[%- area.id | html -%]">[%- PROCESS area_name area=area.id -%]</option>
124       [%- END -%]
125         </select>
126       </li>
127     </ol>
128   </fieldset>
129   <fieldset class="action"><input name="submit" value="Next" type="submit" /></fieldset>
130 </form>
131 [%- END -%]
132
133 [% IF ( step_3 ) %]
134 <h3>Add new definition</h3>
135 <form action="/cgi-bin/koha/reports/dictionary.pl" method="post">      
136 <fieldset class="rows">
137 <legend>Step 3 of 5: Choose a column</legend>
138 <input type="hidden" name="area" value="[% area | html %]" />
139 <input type="hidden" name="definition_name" value="[% definition_name | html %]" />
140 <input type="hidden" name="definition_description" value="[% definition_description | html %]" />
141
142 <select id="availableColumns" name="columns" size="25" style="width:200px;height:300px;margin:1em;">
143 [% FOREACH column IN columns %]
144 [% IF ( column.table ) %]
145 [% IF ( loop.first ) %]                              
146 [% ELSE %]               
147 </optgroup>        
148 [% END %]                                                         
149
150 <optgroup label="[% column.table | html %]">              
151 [% ELSE %]               
152 <option value="[% column.name | html %]">
153 [% IF ( column.description ) %][% column.description | html %]    
154 [% ELSE %]               
155 [% column.name | html %]                          
156 [% END %]              
157 </option>      
158 [% END %]              
159 [% END %]                
160 </optgroup>
161 </select>
162
163 <input type="hidden" name="phase" value="New Term step 4" />
164 </fieldset>
165 <fieldset class="action"><input type="submit" name="submit" value="Next" /></fieldset>
166 </form>
167 [% END %]
168
169 [% IF ( step_4 ) %]
170 <h3>Add new definition</h3>
171 <form action="/cgi-bin/koha/reports/dictionary.pl" method="post">
172 <fieldset class="rows">
173 <legend>Step 4 of 5: Specify a value</legend>
174 <input type="hidden" name="area" value="[% area | html %]" />
175 <input type="hidden" name="definition_name" value="[% definition_name | html %]" />
176 <input type="hidden" name="definition_description" value="[% definition_description | html %]" />
177 <input type="hidden" name="columnstring" value="[% columnstring | html %]" />
178
179 [% FOREACH column IN columns %]
180 <input type="hidden" name="criteria_column" value="[% column.name | html %]" />
181 <ol><li><span class="label">Column: </span> [% column.name | html %]</li>
182 [% IF ( column.distinct ) %]
183     <li><label for="[% column.name | html %]_value">Choose: </label> <select id="[% column.name | html %]_value" name="[% column.name | html %]_value">
184         [% FOREACH value IN column.values %]
185             <option value="[% value.availablevalues | html %]">[% value.availablevalues | html %]</option>
186         [% END %]
187     </select></li>
188 [% END %]
189 [% IF ( column.date ) %]
190     <li class="radio">
191         <label for="all_dates">All dates</label>
192         <input type="radio" id="all_dates" name="[% column.name | html %]_date_type_value" value="all" checked="checked" />
193         <label for="date_range">Date range</label>
194         <input type="radio" id="date_range" name="[% column.name | html %]_date_type_value" value="range" />
195     </li>
196     <li class="radio">
197         Start of date range
198         <input type="text" size="10" id="from" name="[% column.name | html %]_start_value" value="" class="datepickerfrom" />
199         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
200         End of date range
201         <input type="text" size="10" id="to" name="[% column.name | html %]_end_value" value="" class="datepickerto" />
202         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
203     </li>
204 [% END %]
205 [% IF ( column.text ) %]
206         <li><label for="[% column.name | html %]_value">Search string matches: </label> <input type="text" size="13" name="[% column.name | html %]_value" /></li>
207 [% END %]
208
209 [% END %]
210 </ol>
211 <input type="hidden" name="phase" value="New Term step 5" />
212 </fieldset>
213 <fieldset class="action">
214 <input type="submit" name="submit" value="Next" />
215 </fieldset>
216 </form>
217 [% END %]
218
219 [% IF ( step_5 ) %]
220 <form action="/cgi-bin/koha/reports/dictionary.pl" method="post">
221 <input type="hidden" name="area" value="[% area | html %]" />
222 <input type="hidden" name="definition_name" value="[% definition_name | html %]" />
223 <input type="hidden" name="definition_description" value="[% definition_description | html %]" />
224 <input type="hidden" name="columnstring" value="[% columnstring | html %]" />
225
226 <h3>Add new definition</h3>
227
228 <fieldset class="rows">
229   <legend>Step 5 of 5: Confirm details</legend>
230   <ol>
231     <li>
232       <span class="label">Name:</span>[%- definition_name | html -%]
233     </li>
234     <li>
235       <span class="label">Description:</span>[%- definition_description | html -%]
236     </li>
237     <li>
238       <span class="label">Area:</span>[%- PROCESS area_name area=area -%]
239     </li>
240     <li>
241       <span class="label">Data:</span>
242       <table>
243         <tr>
244           <th>Columns</th>
245           <th>Values</th>
246         </tr>
247       [%- FOREACH criteria_loo IN criteria_loop -%]
248         <tr>
249           <td>[%- criteria_loo.name | html -%]</td>
250           <td>[%- criteria_loo.value | html -%]</td>
251         </tr>
252       [%- END -%]
253       </table>
254     </li>
255   </ol>
256 </fieldset>
257
258 <fieldset class="action"><input type="hidden" name="sql" value="[% query | html %]" />
259 <input type="hidden" name="phase" value="New Term step 6" />
260 <input type="submit" name="submit" value="Save" />         </fieldset>
261
262 </form>
263 [% END %]
264
265             </main>
266         </div> <!-- /.col-sm-10.col-sm-push-2 -->
267
268         <div class="col-sm-2 col-sm-pull-10">
269             <aside>
270                 [% INCLUDE 'guided-reports-view.inc' %]
271             </aside>
272         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
273      </div> <!-- /.row -->
274
275 [% MACRO jsinclude BLOCK %]
276     [% INCLUDE 'calendar.inc' %]
277     <script>
278         var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this dictionary definition? This cannot be undone.");
279
280         $(document).ready(function() {
281             $("#delete").on("click",function(){
282                 return confirmDelete(MSG_CONFIRM_DELETE);
283             });
284
285             $("#date_range").change(function(){
286                 $("input#from").parents('li').show();
287             });
288             $("#all_dates").change(function(){
289                 $("input#from").parents('li').hide();
290             });
291             $("#all_dates").click().change();
292         });
293     </script>
294 [% END %]
295
296 [% INCLUDE 'intranet-bottom.inc' %]