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