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