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