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