View | Details | Raw Unified | Return to bug 8628
Collapse All | Expand All

(-)a/Koha/SignStream.pm (+14 lines)
Lines 33-38 Koha::SignStream - Koha SignStream object class Link Here
33
33
34
=cut
34
=cut
35
35
36
=head3 saved_sql
37
38
my $saved_sql = $stream->saved_sql;
39
40
Return the report attached to a stream
41
42
=cut
43
44
sub saved_sql {
45
    my ( $self ) = @_;
46
    my $sql_rs = $self->_result->saved_sql;
47
    return Koha::Report->_new_from_dbic( $sql_rs );
48
}
49
36
sub _type {
50
sub _type {
37
    return 'SignStream';
51
    return 'SignStream';
38
}
52
}
(-)a/Koha/SignsToStream.pm (+14 lines)
Lines 33-38 Koha::SignsToStream - SignsToStream object class Link Here
33
33
34
=cut
34
=cut
35
35
36
=head3 sign_stream
37
38
my $sign_stream = $sts->sign_stream
39
40
Return the stream
41
42
=cut
43
44
sub sign_stream {
45
    my ( $self ) = @_;
46
    my $stream_rs = $self->_result->sign_stream;
47
    return Koha::SignStream->_new_from_dbic( $stream_rs );
48
}
49
36
sub _type {
50
sub _type {
37
    return 'SignsToStream';
51
    return 'SignsToStream';
38
}
52
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc (+3 lines)
Lines 124-129 Link Here
124
    [% IF ( CAN_user_tools_edit_quotes ) %]
124
    [% IF ( CAN_user_tools_edit_quotes ) %]
125
       <li><a href="/cgi-bin/koha/tools/quotes.pl">Quote editor</a></li>
125
       <li><a href="/cgi-bin/koha/tools/quotes.pl">Quote editor</a></li>
126
    [% END %]
126
    [% END %]
127
    [% IF ( CAN_user_tools_edit_digital_signs ) %]
128
        <li><a href="/cgi-bin/koha/tools/signs.pl">Digital signs</a></dt>
129
    [% END %]
127
    [% IF ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool ) %]
130
    [% IF ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool ) %]
128
        <li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=tool">Tool plugins</a></li>
131
        <li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=tool">Tool plugins</a></li>
129
    [% END %]
132
    [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/signs.tt (+490 lines)
Line 0 Link Here
1
[% USE Koha %]
2
[% USE Asset %]
3
[% SET footerjs = 1 %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Tools &rsaquo; Digital signs</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% Asset.css("css/datatables.css") %]
8
</head>
9
<body id="tools_signs" class="tools">
10
[% INCLUDE 'header.inc' %]
11
[% INCLUDE 'cat-search.inc' %]
12
13
[% BLOCK dslink %]<a href="/cgi-bin/koha/tools/signs.pl">Digital signs</a> &rsaquo;[% END %]
14
<div id="breadcrumbs">
15
    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
16
    <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
17
    [% IF op == 'stream_form' %]
18
        [% IF ( stream.sign_stream_id ) %]
19
            [% INCLUDE dslink %] Edit "[% stream.name %]"
20
        [% ELSE %]
21
            [% INCLUDE dslink %] Add a new stream
22
        [% END %]
23
    [% ELSIF op == 'sign_form' %]
24
        [% IF ( sign.sign_id ) %]
25
            [% INCLUDE dslink %] Edit "[% sign.name %]"
26
        [% ELSE %]
27
            [% INCLUDE dslink %] Add a new sign
28
        [% END %]
29
    [% ELSIF op == 'edit_streams' %]
30
        [% INCLUDE dslink %] Edit streams attached to "[% sign.name %]"
31
    [% ELSIF op == 'get_params' %]
32
        [% INCLUDE dslink %]
33
        <a href="/cgi-bin/koha/tools/signs.pl?op=edit_streams&sign_id=[% sign.sign_id %]">Edit streams attached to "[% sign.name %]"</a> &rsaquo;
34
        Get parameters
35
    [% ELSIF op == 'del_stream' %]
36
        [% INCLUDE dslink %] Delete stream "[% stream.name %]"
37
    [% ELSIF op == 'del_stream_ok' %]
38
        [% INCLUDE dslink %] Stream deleted
39
    [% ELSIF op == 'del_sign' %]
40
        [% INCLUDE dslink %] Delete sign "[% sign.name %]"
41
    [% ELSIF op == 'del_sign_ok' %]
42
        [% INCLUDE dslink %] Sign deleted
43
    [% ELSIF op == 'view_sign' %]
44
        [% INCLUDE dslink %] View sign
45
    [% ELSIF op == 'view_stream' %]
46
        [% INCLUDE dslink %] View stream
47
    [% ELSE %]
48
        Digital signs
49
    [% END %]
50
</div>
51
52
<div id="doc3" class="yui-t2">
53
<div id="bd">
54
<div id="yui-main">
55
<div class="yui-b">
56
57
[% UNLESS Koha.Preference( 'OPACDigitalSigns' ) %]
58
    <div class="dialog alert">
59
        Digital signs are not enabled. Please enable <a href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=OPACDigitalSigns">OPACDigitalSigns</a> for OPAC digital signs to work.
60
    </div>
61
[% END %]
62
63
[% IF ( else ) %]
64
    <div id="toolbar" class="btn-toolbar">
65
        <a id="newsign" href="/cgi-bin/koha/tools/signs.pl?op=add_sign" class="btn btn-default"><i class="fa fa-plus"></i> New sign</a>
66
        <a id="newstream" href="/cgi-bin/koha/tools/signs.pl?op=add_stream" class="btn btn-default"><i class="fa fa-plus"></i> New stream</a>
67
    </div>
68
[% END %]
69
70
[% IF op == 'stream_form' %]
71
    [% UNLESS ( reports ) %]
72
        <div class="dialog alert">
73
            <h3>No reports found</h3>
74
            No reports with group code "SIGN" were found. Please <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create+report+from+SQL&submit=Create+report+from+SQL">create a new report</a> with group code "SIGN" and try again.
75
        </div>
76
    [% END %]
77
78
    [% IF ( stream.sign_stream_id ) %]
79
        <h1>Edit stream</h1>
80
    [% ELSE %]
81
        <h1>Add stream</h1>
82
    [% END %]
83
    <form action="[% script_name %]" name="streamform" id="streamform" method="post">
84
        <input type="hidden" name="op" value="save_stream" />
85
        [% IF ( stream.sign_stream_id ) %]
86
            <input type="hidden" name="sign_stream_id" value="[% stream.sign_stream_id %]" />
87
        [% END %]
88
        <fieldset class="rows">
89
            <ol>
90
                <li>
91
                    <label for="name" class="required">Name</label>
92
                    <input type="text" name="name" value="[% stream.name %]" required="required">
93
                    <span class="required">Required</span>
94
                </li>
95
                <li><label for="report" class="required">Report</label>
96
                    <select name="report" id="report" class="required" required="required">
97
                        [% UNLESS ( stream.sign_stream_id ) %]
98
                            <option value="">Choose report</option>
99
                        [% END %]
100
                        [% FOREACH report IN reports %]
101
                            [% IF ( report.id == stream.saved_sql_id ) %]
102
                                <option value="[% report.id %]" selected="selected">[% report.report_name %]</option>
103
                            [% ELSE %]
104
                                <option value="[% report.id %]">[% report.report_name %]</option>
105
                            [% END %]
106
                        [% END %]
107
                    </select>
108
                    <span class="required">Required</span>
109
                </li>
110
                <li>
111
            </ol>
112
        </fieldset>
113
        <fieldset class="action"> <input type="submit" value="Submit" class="submit" /></fieldset>
114
    </form>
115
116
[% ELSIF op == 'sign_form' %]
117
    [% IF ( sign.sign_id ) %]
118
        <h1>Edit sign</h1>
119
    [% ELSE %]
120
        <h1>Add sign</h1>
121
    [% END %]
122
    <form action="[% script_name %]" name="signform" id="signform" method="post">
123
        <input type="hidden" name="op" value="save_sign" />
124
        [% IF ( sign.sign_id ) %]
125
            <input type="hidden" name="sign_id" value="[% sign.sign_id %]" />
126
        [% END %]
127
        <fieldset id="sign_general_info" class="rows">
128
            <legend id="general_info_lgd">General settings</legend>
129
            <ol>
130
                <li><label for="name">Name</label><input type="text" name="name" value="[% sign.name %]" /></li>
131
            </ol>
132
        </fieldset>
133
        <fieldset id="sign_appearance" class="rows">
134
            <legend id="appearance_lgd">Appearance</legend>
135
            <ol>
136
                <li><label for="webapp">Web-app</label>
137
                    <select name="webapp" id="webapp">
138
                        <option value="0">Display as a normal page</option>
139
                        [% IF ( sign.webapp ) %]
140
                            <option value="1" selected="selected">Display as a Web-app</option>
141
                        [% ELSE %]
142
                            <option value="1">Display as a Web-app</option>
143
                        [% END %]
144
                    </select>
145
                </li>
146
                <li><label for="swatch">Theme (swatch)</label>
147
                    <select name="swatch" id="swatch">
148
                        <option value="">Default</option>
149
                        [% FOREACH swatch IN Koha.Preference('OPACDigitalSignsSwatches').split('') %]
150
                            [% IF swatch == sign.swatch %]
151
                                <option value="[% swatch %]" selected="selected">[% swatch %]</option>
152
                            [% ELSE %]
153
                                <option value="[% swatch %]">[% swatch %]</option>
154
                            [% END %]
155
                        [% END %]
156
                    </select>
157
                </li>
158
                <li><label for="transition">Transition</label>
159
                    <select name="transition" id="transition">
160
                        [% FOREACH transition IN [ 'none' 'fade' 'pop' 'flip' 'turn' 'flow' 'slidefade' 'slide' 'slideup' 'slidedown' ] %]
161
                            [% IF transition == sign.transition %]
162
                                <option value="[% transition %]" selected="selected">[% transition %]</option>
163
                            [% ELSE %]
164
                                <option value="[% transition %]">[% transition %]</option>
165
                            [% END %]
166
                        [% END %]
167
                    </select>
168
                </li>
169
            </ol>
170
        </fieldset>
171
        <fieldset id="sign_autopage" class="rows">
172
            <legend id="autopage_lgd">Automatic page turning</legend>
173
            <ol>
174
                <li><label for="idleafter">Idle after</label>
175
                    <input type="text" name="idleafter" id="idleafter" value="[% sign.idleafter %]" size="4" /> seconds. (Set to 0 to disable automatic page turning.)
176
                </li>
177
                <li><label for="pagedelay">Page delay</label>
178
                    <input type="text" name="pagedelay" id="pagedelay" value="[% sign.pagedelay %]" size="4" /> seconds.
179
                </li>
180
                <li><label for="reloadafter">Reload after</label>
181
                    <input type="text" name="reloadafter" id="reloadafter" value="[% sign.reloadafter %]" size="4" /> seconds.
182
                </li>
183
            </ol>
184
        </fieldset>
185
        <fieldset class="action"> <input type="submit" value="Submit" class="submit" /></fieldset>
186
    </form>
187
188
[% ELSIF op == 'edit_streams' %]
189
    <h1>Edit streams attached to [% sign.name %]</h1>
190
    <h2>Streams already attached to this sign</h2>
191
    [% IF ( sts.count ) %]
192
        <table id="streams_attached">
193
            <thead>
194
            <tr>
195
                <th>Name</th>
196
                <th colspan="2">Parameters</th>
197
                <th>&nbsp;</th>
198
            </tr>
199
            </thead>
200
            <tbody>
201
                [% FOREACH s IN sts %]
202
                <tr>
203
                    <td>[% s.sign_stream.name %]</td>
204
                    <td>[% IF s.params %][% s.params %][% ELSE %]None[% END %]</td>
205
                    <td class="actions">
206
                        [% IF s.params %]
207
                            <a href="/cgi-bin/koha/tools/signs.pl?op=get_params&sign_to_stream_id=[% s.sign_to_stream_id %]&sign_stream_id=[% s.sign_stream_id %]&sign_id=[% s.sign_id %]" class="btn btn-default btn-xs" title="Edit parameters"><i class="fa fa-pencil"></i></a>
208
                        [% ELSE %]
209
                            <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% s.sign_stream.saved_sql_id %]&phase=Edit SQL" class="btn btn-default btn-xs" title="Edit SQL"><i class="fa fa-pencil"></i></a>
210
                        [% END %]
211
                    </td>
212
                    <td class="actions"><a href="/cgi-bin/koha/tools/signs.pl?op=detach_stream_from_sign&sign_id=[% s.sign_id %]&sign_to_stream_id=[% s.sign_to_stream_id %]" class="btn btn-default btn-xs detach"><i class="fa fa-times"></i> Detach</a></td>
213
                </tr>
214
                [% END %]
215
            </tbody>
216
        </table>
217
    [% ELSE %]
218
        There are no streams attached to this sign.
219
    [% END %]
220
221
    <h2>Attach a new stream to this sign</h2>
222
    <form action="[% script_name %]" name="attach_stream_to_sign_form" id="attach_stream_to_sign_form" method="post">
223
        <input type="hidden" name="op" value="attach_stream_to_sign" />
224
        <input type="hidden" name="sign_id" value="[% sign_id %]" />
225
        <fieldset class="rows">
226
            <ol>
227
                <li><label for="stream">Choose a stream to attach</label>
228
                    <select name="sign_stream_id" id="stream">
229
                        [% FOREACH s IN streams %]
230
                            <option value="[% s.sign_stream_id %]">[% s.name %]</option>
231
                        [% END %]
232
                    </select>
233
                </li>
234
            </ol>
235
        </fieldset>
236
        <fieldset class="action"> <input type="submit" value="Submit" class="submit" /></fieldset>
237
    </form>
238
239
[% ELSIF op == 'get_params' %]
240
    <h1>Parameters for [% stream.name %]</h1>
241
    Based on report: [% sql.report_name %] | <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% stream.saved_sql_id %]&phase=Edit SQL">Edit this report</a>
242
243
    <form action="[% script_name %]" name="get_params_form" id="get_params_form" method="post">
244
        <input type="hidden" name="op" value="save_params" />
245
        <input type="hidden" name="sign_to_stream_id" value="[% sign_to_stream_id %]" />
246
        <input type="hidden" name="sign_stream_id" value="[% sign_stream_id %]" />
247
        <input type="hidden" name="sign_id" value="[% sign_id %]" />
248
        <fieldset class="rows">
249
            [% IF ( sts.params ) %]
250
                <legend id="save_params_lgd">Edit parameters</legend>
251
            [% ELSE %]
252
                <legend id="save_params_lgd">Add parameters</legend>
253
            [% END %]
254
            <ol>
255
                <li><label for="stream">Parameters</label>
256
                    <input type="text" size="60" name="parameters" id="parameters" value="[% sts.params %]" />
257
                </li>
258
            </ol>
259
        </fieldset>
260
        <fieldset class="action"> <input type="submit" value="Submit" class="submit" /></fieldset>
261
    </form>
262
263
    <h2>Raw SQL</h2>
264
    <pre id="sql_output">[% sql.savedsql | html %]</pre>
265
266
    <h2>SQL with current parameters replaced</h2>
267
    <pre id="sql_output">[% newsql | html %]</pre>
268
269
    [% IF ( has_params ) %]
270
        Sorry, your SQL still contains placeholders. You need to add more parameters.
271
    [% ELSE %]
272
        <h2>Records</h2>
273
        [% INCLUDE display_records %]
274
    [% END %]
275
276
[% ELSIF op == 'del_stream' %]
277
    <div class="dialog alert">
278
        <h3>Confirm deletion of stream <span class="ex">'[% stream.name %]'</span>?</h3>
279
        <form action="[% script_name %]" id ="confirm_stream_delete_form" method="post">
280
            <input type="hidden" name="op" value="del_stream_ok" />
281
            <input type="hidden" name="sign_stream_id" value="[% stream.sign_stream_id %]" />
282
            <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this stream</button>
283
        </form>
284
285
        <form action="[% script_name %]" id="cancel_stream_delete_form" method="get">
286
            <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
287
        </form>
288
    </div>
289
290
[% ELSIF op == 'del_stream_ok' %]
291
    <div class="dialog message">
292
        <h3>Stream deleted</h3>
293
        <form action="[% script_name %]" method="get">
294
            <input type="submit" value="OK" class="approve" />
295
        </form>
296
    </div>
297
298
[% ELSIF op == 'del_sign' %]
299
    <div class="dialog alert">
300
        <h3>Confirm deletion of sign <span class="ex">'[% sign.name %]'</span>?</h3>
301
        <form action="[% script_name %]" id ="confirm_sign_delete_form" method="post">
302
            <input type="hidden" name="op" value="del_sign_ok" />
303
            <input type="hidden" name="sign_id" value="[% sign.sign_id %]" />
304
            <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this sign</button>
305
        </form>
306
307
        <form action="[% script_name %]" id="cancel_sign_delete_form" method="get">
308
            <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
309
        </form>
310
    </div>
311
312
[% ELSIF op == 'del_sign_ok' %]
313
    <div class="dialog message">
314
        <h3>Sign deleted</h3>
315
        <form action="[% script_name %]" method="get">
316
            <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
317
        </form>
318
    </div>
319
320
[% ELSIF op == 'view_sign' %]
321
    <h1>[% sign.name %]</h1>
322
    <h2>Streams</h2>
323
324
    [% IF ( streams ) %]
325
        [% FOREACH stream IN streams %]
326
            <h3>[% stream.sign_stream.name %]</h3>
327
            <ul>
328
                [% FOREACH record IN stream.records %]
329
                    <li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% record.biblionumber %]">[% record.title %]</a></li>
330
                [% END %]
331
            </ul>
332
        [% END %]
333
    [% ELSE %]
334
        No streams attached.
335
    [% END %]
336
337
[% ELSIF op == 'view_stream' %]
338
    <h1>[% stream.name %]</h1>
339
    Based on report: [% stream.saved_sql_id.report_name %] | <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% stream.saved_sql_id %]&phase=Edit SQL">Edit this report</a>
340
341
    <h2>SQL</h2>
342
    <pre id="sql_output">[% stream.saved_sql_id.savedsql | html %]</pre>
343
344
    <h2>Records</h2>
345
    [% IF ( has_params ) %]
346
        Unable to display records. Check that this stream has been attached to a sign and any parameters have been filled appropriately.
347
    [% ELSE %]
348
        [% INCLUDE display_records %]
349
    [% END %]
350
351
[% ELSE %]
352
    <h1>Digital signs</h1>
353
354
    [% IF ( error_on_insert_stream ) %]
355
        <div class="dialog error">Failed to create a new stream.</div>
356
    [% ELSIF ( success_on_insert_stream ) %]
357
        <div class="dialog message">New stream added.</div>
358
    [% END %]
359
360
    <h2>Signs</h2>
361
    [% IF signs %]
362
        <table id="table_signs">
363
            <thead>
364
            <tr>
365
                <th>Name</th>
366
                <th>Web-app</th>
367
                <th>Theme (swatch)</th>
368
                <th>Transition</th>
369
                <th>Idle after</th>
370
                <th>Page delay</th>
371
                <th>Reload after</th>
372
                <th>&nbsp;</th>
373
            </tr>
374
            </thead>
375
            <tbody>
376
                [% FOREACH s IN signs %]
377
                <tr>
378
                    <td><a href="/cgi-bin/koha/tools/signs.pl?op=view_sign&amp;sign_id=[% s.sign_id %]">[% s.name %]</a></td>
379
                    <td>[% IF ( s.webapp ) %]Yes[% ELSE %]No[% END %]</td>
380
                    <td>[% s.swatch %]</td>
381
                    <td>[% s.transition %]</td>
382
                    <td>[% s.idleafter %]</td>
383
                    <td>[% s.pagedelay %]</td>
384
                    <td>[% s.reloadafter %]</td>
385
                    <td>
386
                        <div class="dropdown">
387
                            <a class="btn btn-default btn-xs dropdown-toggle" id="opensignsactions[% s.sign_id %]" role="button" data-toggle="dropdown" href="#"> Actions <b class="caret"></b></a>
388
                            <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="opensignsactions[% s.sign_id %]">
389
                                <li><a href="/cgi-bin/koha/tools/signs.pl?op=edit_sign&amp;sign_id=[% s.sign_id %]"><i class="fa fa-pencil"></i> Edit</a></li>
390
                                <li><a href="/cgi-bin/koha/tools/signs.pl?op=edit_streams&amp;sign_id=[% s.sign_id %]"><i class="fa fa-pencil"></i> Edit streams</a></li>
391
                                <li><a href="/cgi-bin/koha/tools/signs.pl?op=del_sign&amp;sign_id=[% s.sign_id %]"><i class="fa fa-trash"></i> Delete</a></li>
392
                                [% IF ( OPACBaseURL ) %]<li><a href="[% OPACBaseURL %]/cgi-bin/koha/opac-signs.pl?sign=[% s.sign_id %]" title="View this sign in the OPAC"><i class="fa fa-eye"></i> View sign</a></li>[% END %]
393
                            </ul>
394
                        </div>
395
                    </td>
396
                </tr>
397
                [% END %]
398
            </tbody>
399
        </table>
400
        [% UNLESS ( OPACBaseURL ) %]Please note: Links to view signs in the OPAC will only be displayed if you fill in the OPACBaseURL system preference.[% END %]
401
    [% ELSE %]
402
        <div class="dialog message">No signs defined. <a href="/cgi-bin/koha/tools/signs.pl?op=add_sign">Create a new sign.</a></div>
403
    [% END %]
404
405
    <h2>Streams</h2>
406
    [% IF streams %]
407
        <table id="table_streams">
408
            <thead>
409
            <tr>
410
                <th>Name</th>
411
                <th>Report</th>
412
                <th>Actions</th>
413
            </tr>
414
            </thead>
415
            <tbody>
416
                [% FOREACH s IN streams %]
417
                <tr>
418
                    <td><a href="/cgi-bin/koha/tools/signs.pl?op=view_stream&amp;sign_stream_id=[% s.sign_stream_id %]">[% s.name %]</a></td>
419
                    <td title="ID: [% s.saved_sql_id %]">[% s.saved_sql.report_name %]</td>
420
                    <td class="actions">
421
                        <a class="btn btn-default btn-xs" href="/cgi-bin/koha/tools/signs.pl?op=edit_stream&amp;sign_stream_id=[% s.sign_stream_id %]"><i class="fa fa-pencil"></i> Edit</a>
422
                        <a class="btn btn-default btn-xs" href="/cgi-bin/koha/tools/signs.pl?op=del_stream&amp;sign_stream_id=[% s.sign_stream_id %]"><i class="fa fa-trash"></i> Delete</a>
423
                    </td>
424
                </tr>
425
                [% END %]
426
            </tbody>
427
        </table>
428
    [% ELSE %]
429
        <div class="dialog message">No streams defined. <a href="/cgi-bin/koha/tools/signs.pl?op=add_stream">Create a new stream.</a></div>
430
    [% END %]
431
432
[% END %]
433
434
</div>
435
</div>
436
437
<div class="yui-b">
438
[% INCLUDE 'tools-menu.inc' %]
439
</div>
440
441
</div>
442
443
[% MACRO jsinclude BLOCK %]
444
[% INCLUDE 'datatables.inc' %]
445
[% Asset.js("js/tools-menu.js") | $raw %]
446
<script>
447
//<![CDATA[
448
     $(document).ready(function() {
449
        $("#table_signs").dataTable($.extend(true, {}, dataTablesDefaults, {
450
            "aoColumnDefs": [
451
                { "aTargets": [ -1 ], "bSearchable": false, "bSortable": false },
452
            ],
453
            "sPaginationType": "four_button"
454
        }));
455
        $("#table_streams").dataTable($.extend(true, {}, dataTablesDefaults, {
456
            "aoColumnDefs": [
457
                { "aTargets": [ -1 ], "bSearchable": false, "bSortable": false },
458
            ],
459
            "sPaginationType": "four_button"
460
        }));
461
462
        $(".detach").on("click", function(){
463
            return confirmDelete(_("Are you sure you want to detach this stream from this sign?"));
464
        });
465
     });
466
//]]>
467
</script>
468
[% END %]
469
470
[% INCLUDE 'intranet-bottom.inc' %]
471
472
[% BLOCK display_records %]
473
    [% IF ( records.0 ) %]
474
        <table>
475
            <thead>
476
            <tr>
477
                <th>biblionumber</th>
478
                <th>title</th>
479
            </tr>
480
            </thead>
481
            <tbody>
482
                [% FOREACH r IN records %]
483
                    <tr><td>[% r.biblionumber %]</td><td>[% r.title %]</td></tr>
484
                [% END %]
485
            </tbody>
486
        </table>
487
    [% ELSE %]
488
        No records found.
489
    [% END %]
490
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (+5 lines)
Lines 120-125 Link Here
120
    <dd>Quote editor for Quote-of-the-day feature in OPAC</dd>
120
    <dd>Quote editor for Quote-of-the-day feature in OPAC</dd>
121
    [% END %]
121
    [% END %]
122
122
123
    [% IF ( CAN_user_tools_edit_digital_signs ) %]
124
    <dt><a href="/cgi-bin/koha/tools/signs.pl">Digital signs</a></dt>
125
    <dd>Create and edit digital signs for the OPAC</dd>
126
    [% END %]
127
123
    [% IF ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool && tool_plugins ) %]
128
    [% IF ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool && tool_plugins ) %]
124
    <dt><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=tool">Tool plugins</a></dt>
129
    <dt><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=tool">Tool plugins</a></dt>
125
    <dd>
130
    <dd>
(-)a/koha-tmpl/intranet-tmpl/prog/js/tools-menu.js (+2 lines)
Lines 18-22 Link Here
18
          $('#navmenulist a[href$="/cgi-bin/koha/tools/stockrotation.pl"]').addClass("current");
18
          $('#navmenulist a[href$="/cgi-bin/koha/tools/stockrotation.pl"]').addClass("current");
19
      } else if (path.indexOf("plugins") >= 0 ) {
19
      } else if (path.indexOf("plugins") >= 0 ) {
20
          $('#navmenulist a[href$="/cgi-bin/koha/plugins/plugins-home.pl?method=tool"]').addClass("current");
20
          $('#navmenulist a[href$="/cgi-bin/koha/plugins/plugins-home.pl?method=tool"]').addClass("current");
21
      } else if (path.indexOf("signs") >= 0 ) {
22
          $('#navmenulist a[href$="/cgi-bin/koha/tools/signs.pl"]').addClass("current");
21
      }
23
      }
22
  });
24
  });
(-)a/tools/signs.pl (-1 / +327 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2012 Magnus Enger Libriotech
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
=head1 NAME
21
22
signs.pl - Script for managing digital signs for the OPAC.
23
24
=head1 SYNOPSIS
25
26
signs.pl
27
28
=head1 DESCRIPTION
29
30
Allows authorized users to create and manage digital signs for the OPAC.
31
32
=cut
33
34
use Koha::Sign;
35
use Koha::Signs;
36
use Koha::SignStream;
37
use Koha::SignStreams;
38
use Koha::SignsToStreams;
39
use Koha::Reports;
40
use CGI;
41
use C4::Auth;
42
use C4::Context;
43
use C4::Log;
44
use C4::Output;
45
use C4::Reports::Guided;
46
use Modern::Perl;
47
48
my $cgi = new CGI;
49
my $dbh = C4::Context->dbh;
50
my $script_name = 'signs.pl';
51
52
my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
53
    template_name   => "tools/signs.tt",
54
    query           => $cgi,
55
    type            => "intranet",
56
    authnotrequired => 0,
57
    flagsrequired   => { tools => 'edit_digital_signs' },
58
    debug           => 0,
59
});
60
61
my $op                = $cgi->param('op') || '';
62
my $sign_id           = $cgi->param('sign_id') || '';
63
my $sign_stream_id    = $cgi->param('sign_stream_id') || '';
64
my $sign_to_stream_id = $cgi->param('sign_to_stream_id') || '';
65
my $parameters        = $cgi->param('parameters') || '';
66
67
# Streams
68
69
if ( $op eq 'add_stream' ) {
70
71
    $template->param(
72
        op      => 'stream_form',
73
        reports => get_saved_reports({ group => 'SIGN' }),
74
    );
75
76
} elsif ( $op eq 'edit_stream' && $sign_stream_id ne '') {
77
78
    my $stream = Koha::SignStreams->find( $sign_stream_id );
79
80
    $template->param(
81
      op          => 'stream_form',
82
      stream      => $stream,
83
      reports     => get_saved_reports({ group => 'SIGN' }),
84
      script_name => $script_name
85
    );
86
87
} elsif ( $op eq 'save_stream' ) {
88
89
    my $name = $cgi->param('name');
90
    my $report = $cgi->param('report');
91
    if ( $sign_stream_id ne '' ) {
92
        Koha::SignStreams->find( $sign_stream_id )->set({ name => $name, saved_sql_id => $report })->store; # modify
93
    } else {
94
        Koha::SignStream->new({ name => $name, saved_sql_id => $report })->store; # add new
95
    }
96
    print $cgi->redirect($script_name);
97
98
} elsif ( $op eq 'view_stream' && $sign_stream_id ne '' ) {
99
100
    my $stream = Koha::SignStreams->find( $sign_stream_id );
101
    my $report = Koha::Reports->find($stream->saved_sql_id);
102
    my $sql = $report->savedsql;
103
    my ( $records, $error ) = execute_query( $sql, 0, 999999 );
104
    if ( $records && not $error ) {
105
        $records = $records->fetchall_arrayref({});
106
        $template->param( records => $records );
107
    } else {
108
        $template->param( has_params => 1 );
109
    }
110
111
    $template->param(
112
        op          => 'view_stream',
113
        stream      => $stream,
114
        script_name => $script_name
115
    );
116
117
} elsif ( $op eq 'del_stream' ) {
118
119
    my $stream = Koha::SignStreams->find( $sign_stream_id );
120
121
    $template->param(
122
        op          => 'del_stream',
123
        stream      => $stream,
124
        script_name => $script_name,
125
    );
126
127
} elsif ( $op eq 'del_stream_ok' ) {
128
129
    Koha::SignStreams->find( $sign_stream_id )->delete;
130
131
    $template->param(
132
        op          => 'del_stream_ok',
133
        script_name => $script_name,
134
    );
135
136
# Signs
137
138
} elsif ( $op eq 'add_sign' ) {
139
140
    $template->param( op => 'sign_form' );
141
142
} elsif ( $op eq 'edit_sign' && $sign_id ne '' ) {
143
144
    my $sign = Koha::Signs->find( $sign_id );
145
146
    $template->param(
147
        op          => 'sign_form',
148
        sign        => $sign,
149
        script_name => $script_name,
150
    );
151
152
} elsif ( $op eq 'save_sign' ) {
153
154
    if ($cgi->param('sign_id')) {
155
        Koha::Signs->find( scalar $cgi->param('sign_id') )->set({
156
            name        => scalar $cgi->param('name'),
157
            webapp      => scalar $cgi->param('webapp'),
158
            swatch      => scalar $cgi->param('swatch'),
159
            transition  => scalar $cgi->param('transition'),
160
            idleafter   => scalar $cgi->param('idleafter'),
161
            pagedelay   => scalar $cgi->param('pagedelay'),
162
            reloadafter => scalar $cgi->param('reloadafter')
163
        })->store; # modify
164
    } else {
165
        Koha::Sign->new({
166
            name        => scalar $cgi->param('name'),
167
            webapp      => scalar $cgi->param('webapp'),
168
            swatch      => scalar $cgi->param('swatch'),
169
            transition  => scalar $cgi->param('transition'),
170
            idleafter   => scalar $cgi->param('idleafter'),
171
            pagedelay   => scalar $cgi->param('pagedelay'),
172
            reloadafter => scalar $cgi->param('reloadafter')
173
        })->store; # add new
174
    }
175
    print $cgi->redirect($script_name);
176
177
} elsif ( $op eq 'view_sign' && $sign_id ne '' ) {
178
179
    # Getting sign streams attached to sign with records
180
    my $schema = Koha::Database->new()->schema();
181
    my @signstostreams = $schema->resultset('SignsToStream')->search({ 'me.sign_id' => $sign_id }, { prefetch => 'sign_stream' });
182
    my @changedstreams;
183
184
    foreach my $s ( @signstostreams ) {
185
        my $stream = Koha::SignStreams->find( $s->sign_stream_id );
186
        my $sql = Koha::Reports->find($stream->saved_sql_id);
187
        my $params = Koha::SignsToStreams->find({ sign_to_stream_id => $s->sign_to_stream_id });
188
        # Generate SQL with added params
189
        my $newsql = $sql->savedsql;
190
        foreach my $param ( split /&/, $params->params ) {
191
            my ( $key, $value ) = split /=|<|>/, $param; # The < and > in the split are just to prevent software errors, the sign in the query must be changed in the report itself
192
            $newsql =~ s/$key/$value/g;
193
        }
194
        # Run query with new sql
195
        my ( $records, $error ) = execute_query( $newsql, 0, 999999 );
196
        if ( $records && not $error ) {
197
            $s->{'records'} = $records->fetchall_arrayref({});
198
            push @changedstreams, $s;
199
        }
200
    }
201
202
    $template->param(
203
        op          => 'view_sign',
204
        sign        => Koha::Signs->find( $sign_id ),
205
        streams     => \@changedstreams,
206
        script_name => $script_name,
207
    );
208
209
} elsif ( $op eq 'del_sign' && $sign_id ne '' ) {
210
211
    my $sign = Koha::Signs->find( $sign_id );
212
213
    $template->param(
214
        op          => 'del_sign',
215
        sign        => $sign,
216
        script_name => $script_name,
217
    );
218
219
} elsif ( $op eq 'del_sign_ok' ) {
220
221
    Koha::Signs->find( $sign_id )->delete;
222
223
    $template->param(
224
        op          => 'del_sign_ok',
225
        script_name => $script_name,
226
    );
227
228
# Signs and streams
229
230
} elsif ( $op eq 'edit_streams' && $sign_id ne '') {
231
232
    my $sign = Koha::Signs->find( $sign_id );
233
    my $streams = Koha::SignStreams->search({});
234
    my $signstostreams = Koha::SignsToStreams->search({ 'sign_id' => $sign_id });
235
236
    $template->param(
237
        op          => 'edit_streams',
238
        sign        => $sign,
239
        sign_id     => $sign_id,
240
        streams     => $streams,
241
        sts         => $signstostreams,
242
        script_name => $script_name
243
    );
244
245
} elsif ( $op eq 'attach_stream_to_sign' && $sign_stream_id ne '' && $sign_id ne '' ) {
246
247
    my $sign_to_stream = Koha::SignsToStream->new({ sign_stream_id => $sign_stream_id, sign_id => $sign_id })->store;
248
249
    # Check if the SQL associated with the stream needs parameters
250
    my $stream = Koha::SignStreams->find( $sign_stream_id );
251
    my $sql = Koha::Reports->find($stream->saved_sql_id);
252
    if ( $sql->savedsql =~ m/WHERE/ ) {
253
        print $cgi->redirect( $script_name . '?op=get_params&sign_to_stream_id=' . $sign_to_stream->sign_to_stream_id . '&sign_stream_id=' . $sign_stream_id . '&sign_id=' . $sign_id );
254
    } else {
255
        print $cgi->redirect( $script_name . '?op=edit_streams&sign_id=' . $sign_id );
256
    }
257
258
} elsif ( $op eq 'get_params' && $sign_to_stream_id ne '' && $sign_stream_id ne '' && $sign_id ne '' ) {
259
260
    my $stream = Koha::SignStreams->find( $sign_stream_id );
261
    my $sql = Koha::Reports->find($stream->saved_sql_id);
262
    my $sts = Koha::SignsToStreams->find({ sign_to_stream_id => $sign_to_stream_id });
263
    # Generate SQL with added params
264
    my $newsql = $sql->savedsql;
265
    foreach my $param ( split /&/, $sts->params ) {
266
        $param =~ tr/ //ds; # replace any whitespace with nothing, strip the spaces out so the query works
267
        my ( $key, $value ) = split /=|<|>/, $param; # The < and > in the split are just to prevent software errors, the sign in the query must be changed in the report itself
268
        $newsql =~ s/$key/$value/g;
269
    }
270
    # Run query with new sql
271
    my ( $records, $error ) = execute_query( $newsql, 0, 999999 );
272
    if ( $records && not $error) {
273
        $template->param( records => $records->fetchall_arrayref({}) );
274
    } else {
275
        $template->param( has_params => 1 );
276
    }
277
278
    my $sign = Koha::Signs->find( $sign_id );
279
280
    $template->param(
281
        op                => 'get_params',
282
        stream            => $stream,
283
        sign_id           => $sign_id,
284
        sign_stream_id    => $sign_stream_id,
285
        sign_to_stream_id => $sign_to_stream_id,
286
        sts               => $sts,
287
        sql               => $sql,
288
        newsql            => $newsql,
289
        script_name       => $script_name,
290
        sign              => $sign
291
    );
292
293
} elsif ( $op eq 'save_params' && $sign_to_stream_id ne '' && $sign_id ne '' ) {
294
295
    Koha::SignsToStreams->find( $sign_to_stream_id )->set({ params => $parameters })->store;
296
    print $cgi->redirect( $script_name . '?op=get_params&sign_to_stream_id=' . $sign_to_stream_id . '&sign_stream_id=' . $sign_stream_id . '&sign_id=' . $sign_id );
297
298
} elsif ( $op eq 'detach_stream_from_sign' && $sign_to_stream_id ne '' ) {
299
300
    Koha::SignsToStreams->find( $sign_to_stream_id )->delete;
301
    print $cgi->redirect($script_name . '?op=edit_streams&sign_id=' . $sign_id);
302
303
} else {
304
305
    my @streams = Koha::SignStreams->search();
306
    my @signs = Koha::Signs->search();
307
308
    $template->param(
309
        streams     => \@streams,
310
        signs       => \@signs,
311
        reports     => get_saved_reports({ group => 'SIGN' }),
312
        OPACBaseURL => C4::Context->preference( 'OPACBaseURL' ) || '',
313
        else        => 1
314
    );
315
316
}
317
318
output_html_with_http_headers $cgi, $cookie, $template->output;
319
320
exit 0;
321
322
=head1 AUTHORS
323
324
Written by Magnus Enger of Libriotech.
325
Aleisha Amohia <aleisha@catalyst.net.nz>
326
327
=cut

Return to bug 8628