Bug 22318: Example implementation: OpacNavRight system preference
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / koha-news.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% USE Branches %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha &rsaquo; Tools &rsaquo; News</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 [% IF ( opac_news_count ) %]
10 [% END %]
11 </head>
12
13 <body id="tools_koha-news" class="tools">
14 [% INCLUDE 'header.inc' %]
15 [% INCLUDE 'cat-search.inc' %]
16
17 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; [% IF ( add_form ) %]<a href="/cgi-bin/koha/tools/koha-news.pl">News</a> &rsaquo; [% IF ( id ) %]
18 Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
19
20 [% IF ( add_form ) %]
21     <div class="main container-fluid">
22         <div class="row">
23             <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
24 [% ELSE %]
25     <div class="main container-fluid">
26         <div class="row">
27             <div class="col-sm-10 col-sm-push-2">
28 [% END %]
29                 <main>
30
31 [% UNLESS ( add_form ) %]
32     [% IF error_message == 'title_missing' %]
33         <div class="dialog alert">Error: Required news title missing!</div>
34     [% END %]
35 <h2>News</h2>
36 <div id="toolbar" class="btn-toolbar">
37     <a class="btn btn-default" id="newentry" href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;lang=[% lang | html %]"><i class="fa fa-plus"></i> New entry</a>
38 </div>
39 [% END %]
40
41 [% IF ( add_form ) %]
42     [% IF ( op == 'add' ) %]
43         [% default_lang = lang %]
44     [% ELSE %]
45         [% default_lang = new_detail.lang %]
46     [% END %]
47         <form name="add_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl" >
48             <input type="hidden" name="op" value="[% op | html %]" />
49             <input type="hidden" name="id" value="[% id | html %]" />
50                         <fieldset class="rows">
51             <legend>OPAC and Koha news</legend>
52            <ol> <li>
53             <label for="lang">Display location:</label>
54             <select id="lang" name="lang">
55                 [% IF ( default_lang == "" ) %]
56                 <option value="" selected="selected">All</option>
57                 [% ELSE %]
58                 <option value=""                    >All</option>
59                 [% END %]
60                 [% IF ( default_lang == "koha" ) %]
61                 <option value="koha" selected="selected">Librarian interface</option>
62                 [% ELSE %]
63                 <option value="koha"                    >Librarian interface</option>
64                 [% END %]
65                 [% IF ( default_lang == "slip" ) %]
66                 <option value="slip" selected="selected">Slip</option>
67                 [% ELSE %]
68                 <option value="slip"                    >Slip</option>
69                 [% END %]
70                 [% FOREACH lang_lis IN lang_list %]
71                     <optgroup label="[% lang_lis.language | html %]">
72                         [% FOREACH location IN [ '', 'OpacNavRight' ] %]
73                             [% IF ( location == '' ) %]
74                                 [% SET location_lang = lang_lis.language %]
75                                 [% SET location = "OPAC news" %]
76                             [% ELSE %]
77                                 [% SET location_lang = location _ "_" _ lang_lis.language %]
78                             [% END %]
79                             [% IF ( location_lang == default_lang ) %]
80                                 <option value="[% location_lang | html %]" selected="selected">[% location | html %] ([% lang_lis.language | html %])</option>
81                             [% ELSE %]
82                                 <option value="[% location_lang | html %]">[% location | html %] ([% lang_lis.language | html %])</option>
83                             [% END %]
84                         [% END %]
85                     </optgroup>
86                 [% END %]
87             </select>
88             </li>
89             <li>
90                 <label for="branch">Library: </label>
91                 <select id="branch" name="branch">
92                     [% IF ( new_detail.branchcode == '' ) %]
93                         <option value="" selected="selected">All libraries</option>
94                     [% ELSE %]
95                         <option value=""         >All libraries</option>
96                     [% END %]
97                     [% PROCESS options_for_libraries libraries => Branches.all( selected => new_detail.branchcode, unfiltered => 1, ) %]
98                 </select>
99             </li>
100             <li>
101                 <label for="title" class="required">Title: </label>
102                 <input id="title" size="30" type="text" name="title" value="[% new_detail.title | html %]" required="required" class="required" /> <span class="required">Required</span>
103             </li>
104             <li>
105                 <label for="from">Publication date: </label>
106                 <input id="from" type="text" name="timestamp" size="15" value="[% new_detail.timestamp | html %]" class="datepickerfrom" />
107                                 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
108             </li>
109             <li>
110                 <label for="to">Expiration date: </label>
111                 <input id="to" type="text" name="expirationdate" size="15" value="[% new_detail.expirationdate | html %]" class="datepickerto" />
112                 <div class="hint">
113                     [% INCLUDE 'date-format.inc' %]
114                     <br>News will still be accessible by direct URL if expired.
115                 </div>
116             </li>
117             <li>
118                 <label for="number">Appear in position: </label>
119                 [% IF ( new_detail.number ) %]
120                     <input id="number" size="3" name="number" type="text" value="[% new_detail.number | html %]" />
121                 [% ELSE %]
122                     <input id="number" size="3" name="number" type="text" />
123                 [% END %]
124             </li>
125             <li><label for="content">News: </label>
126             <textarea name="content" id="content"  cols="75" rows="10">[% new_detail.content | $raw %]</textarea>
127             </li>
128             </ol>
129                         </fieldset>
130   
131                 <fieldset class="action"><input class="button" type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/tools/koha-news.pl">Cancel</a></fieldset>
132         </form>
133     [% ELSE %]
134         <div style="margin-bottom:5px;">
135         <form name="add_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl" >
136             <label for="lang">Display location:</label>
137             <select name="lang" id="lang">
138             [% IF ( lang == "" ) %]
139             <option value=""     selected="selected">All</option>
140             [% ELSE %]
141             <option value=""             >All</option>
142             [% END %]
143             [% IF ( lang == "koha" ) %]
144             <option value="koha" selected="selected">Librarian interface</option>
145             [% ELSE %]
146             <option value="koha"         >Librarian interface</option>
147             [% END %]
148             [% IF ( lang == "slip" ) %]
149             <option value="slip" selected="selected">Slip</option>
150             [% ELSE %]
151             <option value="slip"         >Slip</option>
152             [% END %]
153                 [% FOREACH lang_lis IN lang_list %]
154                 [% IF ( lang_lis.language == lang ) %]
155                     <option value="[% lang_lis.language | html %]" selected="selected">OPAC ([% lang_lis.language | html %])</option>
156                 [% ELSE %]
157                     <option value="[% lang_lis.language | html %]"         >OPAC ([% lang_lis.language | html %])</option>
158                 [% END %]
159                 [% END %]
160             </select>
161             <label for="branch">Library: </label>
162             <select id="branch" name="branch">
163                 [% IF ( branchcode == "" ) %]
164                 <option value="" selected="selected">All libraries</option>
165                 [% ELSE %]
166                 <option value=""         >All libraries</option>
167                 [% END %]
168                 [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %]
169             </select>
170             <input type="submit" class="button" value="Filter" />
171         </form>
172         </div>
173         [% IF ( opac_news_count ) %]
174         <form id="del_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl">
175                 <table id="newst">
176                    <thead> <tr>
177                         <th>&nbsp;</th>
178                         <th>Location</th>
179                         <th>Library</th>
180                         <th>Number</th>
181                         <th class="title-string">Publication date</th>
182                         <th class="title-string">Expiration date</th>
183                         <th>Title</th>
184                         <th>Author</th>
185                         <th>News</th>
186                         <th>Actions</th>
187                     </tr></thead>
188                     <tbody>[% FOREACH opac_new IN opac_news %]
189                          [% IF ( opac_new.expired ) %]
190                             <tr class="expired">
191                             [% ELSE %]
192                             <tr>
193                             [% END %]
194                             <td>
195                                 <input type="checkbox" name="ids" value="[% opac_new.idnew | html %]" />
196                             </td>
197                             <td>[% SWITCH opac_new.lang %]
198                                 [%   CASE "koha" %]
199                                     Librarian interface
200                                 [%   CASE "slip" %]
201                                     Slip
202                                 [%   CASE "" %]
203                                     All
204                                 [%   CASE %]
205                                     OPAC ([% opac_new.lang | html %])
206                                 [% END %]
207                              </td>
208                             <td>[% IF ( opac_new.branchcode == "" ) -%]
209                                 All libraries
210                                 [% ELSE %][% opac_new.branchname | html %]
211                                 [% END %]</td>
212                             <td>[% opac_new.number | html %]</td>
213                             <td><span title="[% opac_new.newdate | html %]">[% opac_new.newdate | $KohaDates %]</span></td>
214                             <td><span title="[% opac_new.expirationdate | html %]">[% opac_new.expirationdate | $KohaDates %] [% IF ( opac_new.expired ) %](<span class="expired">expired</span>)[% END %]</span></td>
215                             <td>[% opac_new.title | html %]</td>
216                             <td>[% opac_new.author_title | html %] [% opac_new.author_firstname | html %] [% opac_new.author_surname | html %]</td>
217                            <td>
218                                 [% opac_new.content | $raw %]
219                             </td>
220                             <td class="actions">
221                                 <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;id=[% opac_new.idnew | uri %]" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
222                                 <a href="/cgi-bin/koha/tools/koha-news.pl?op=del&amp;ids=[% opac_new.idnew | uri %]" class="delete_news btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a>
223                             </td>
224                         </tr>
225                     [% END %]</tbody>
226                 </table>
227                 <input type="hidden" name="op" value="del" />
228                 <fieldset class="action"><input type="submit" class="button" value="Delete selected" /></fieldset>
229             </form>
230         [% ELSE %]
231             <div class="dialog message">There are no news items.</div>
232         [% END %]
233     [% END %]
234
235                 </main>
236             [% UNLESS ( add_form ) %]
237                 </div> <!-- /.col-sm-10.col-sm-push-2 -->
238
239                 <div class="col-sm-2 col-sm-pull-10">
240                     <aside>
241                         [% INCLUDE 'tools-menu.inc' %]
242                     </aside>
243                 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
244             [% END %]
245         </div> <!-- /.row -->
246
247 [% MACRO jsinclude BLOCK %]
248     [% INCLUDE 'calendar.inc' %]
249     [% Asset.js("js/tools-menu.js") | $raw %]
250     [% IF ( opac_news_count ) %]
251         [% INCLUDE 'datatables.inc' %]
252         <script>
253             $(document).ready(function() {
254                 $("#newst").dataTable($.extend(true, {}, dataTablesDefaults, {
255                     "aoColumnDefs": [
256                         { "aTargets": [ 0,-1,-2 ], "bSortable": false },
257                         { "aTargets": [ 0, -1 ], "bSearchable": false },
258                         { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
259                     ],
260                     "sPaginationType": "full_numbers"
261                 }));
262                 $(".delete_news").on("click", function(){
263                     return confirmDelete( _("Are you sure you want to delete this news item? This cannot be undone.") );
264                 });
265
266                 function Checkbox(){
267                     var form = document.getElementById('del_form');
268                     var inputs = form.getElementsByTagName('input');
269                     var checked = false;
270                     for (var i=0; i<inputs.length; i++) {
271                         if (inputs[i].type == 'checkbox' && inputs[i].name == 'ids') {
272                             checked = inputs[i].checked;
273                             if (checked) return true;
274                         }
275                     }
276                 }
277
278                 $("#del_form").on("submit",function(){
279                     if ( Checkbox() ) {
280                         return confirmDelete( _("Are you sure you want to delete the selected news?") );
281                     } else {
282                         alert(_("Please select a news item to delete."));
283                         return false;
284                     }
285                 });
286             });
287         </script>
288     [% END %]
289     [% Asset.js("lib/tiny_mce/tiny_mce.js") | $raw %]
290     <script>
291         tinyMCE.baseURL = "[% interface | html %]/lib/tiny_mce";
292         tinyMCE.init({
293             mode : "textareas",
294             theme : "advanced",
295             convert_urls : false,
296             relative_urls : false,
297             content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css",
298             plugins : "table,save,advhr,advlink,searchreplace,print,contextmenu",
299             theme_advanced_buttons1 : "save,|,bold,italic,|,cut,copy,paste,|,search,replace,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,link,unlink,anchor,cleanup,help,code,advhr,|,print",
300             theme_advanced_buttons2 : "tablecontrols,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,removeformat,|,visualaid,|,sub,sup,|,charmap",
301             theme_advanced_buttons3 : "",
302             theme_advanced_toolbar_location : "top",
303             theme_advanced_toolbar_align : "left",
304             theme_advanced_path_location : "bottom",
305             theme_advanced_resizing : true,
306             plugin_insertdate_dateFormat : "%Y-%m-%d",
307             plugin_insertdate_timeFormat : "%H:%M:%S",
308             apply_source_formatting : true,
309             height : "300",
310             width : "700"
311         });
312     </script>
313 [% END %]
314
315 [% INCLUDE 'intranet-bottom.inc' %]