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