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