Bug 15758: Koha::Libraries - Remove GetBranches
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / koha-news.tt
index 927c4ac..1cf4313 100644 (file)
@@ -1,33 +1,41 @@
+[% USE KohaDates %]
+[% USE Branches %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; News</title>
 [% INCLUDE 'doc-head-close.inc' %]
 [% INCLUDE 'calendar.inc' %]
 [% IF ( opac_news_count ) %]
-    <link rel="stylesheet" type="text/css" href="/intranet-tmpl/prog/en/css/datatables.css" />
-    <script type="text/javascript" src="/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.dataTables.min.js"></script>
-    [% INCLUDE 'datatables-strings.inc' %]
-    <script type="text/javascript" src="/intranet-tmpl/prog/en/js/datatables.js"></script>
+    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
+    [% INCLUDE 'datatables.inc' %]
     <script type="text/javascript">//<![CDATA[
-    [% IF (dateformat == 'metric') %]dt_add_type_uk_date();[% END %]
     $(document).ready(function() {
         $("#newst").dataTable($.extend(true, {}, dataTablesDefaults, {
-            "sDom": 't',
             "aoColumnDefs": [
-                { "aTargets": [ 0,-1,-2 ], "bSortable": false, "bSearchable": false }
+                { "aTargets": [ 0,-1,-2 ], "bSortable": false },
+                { "aTargets": [ 0, -1 ], "bSearchable": false },
+                { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
             ],
-            "bPaginate": false
+            "sPaginationType": "full_numbers"
         }));
+        $(".delete_news").on("click", function(){
+            return confirmDelete( _("Are you sure you want to delete this news item? This cannot be undone.") );
+        });
+        $("#del_form").on("submit",function(){
+            return confirmDelete( _("Are you sure you want to delete the selected news?") );
+        });
     });
     //]]>
     </script>
 [% END %]
-<script type="text/javascript" src="[% themelang %]/js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
+<script type="text/javascript" src="[% interface %]/lib/tiny_mce/tiny_mce.js"></script>
 <script type="text/javascript">//<![CDATA[
 tinyMCE.init({
     mode : "textareas",
     theme : "advanced",
-    content_css : "[% themelang %]/css/tinymce.css",
-    plugins : "table,save,advhr,advlink,iespell,searchreplace,print,contextmenu",
+    convert_urls : false,
+    relative_urls : false,
+    content_css : "[% interface %]/[% theme %]/css/tinymce.css",
+    plugins : "table,save,advhr,advlink,searchreplace,print,contextmenu",
     theme_advanced_buttons1 : "save,|,bold,italic,|,cut,copy,paste,|,search,replace,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,link,unlink,anchor,cleanup,help,code,advhr,|,print",
     theme_advanced_buttons2 : "tablecontrols,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,removeformat,|,visualaid,|,sub,sup,|,charmap",
     theme_advanced_buttons3 : "",
@@ -42,6 +50,7 @@ tinyMCE.init({
     width : "700"
 //]]>
 });
+//]]>
 </script>
 </head>
 <body id="tools_koha-news" class="tools">
@@ -49,7 +58,7 @@ tinyMCE.init({
 [% INCLUDE 'cat-search.inc' %]
 
 <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 ) %]
-Edit News Item[% ELSE %]Add News Item[% END %][% ELSE %]News[% END %]</div>
+Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
 
 [% IF ( add_form ) %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %]
    <div id="bd">
@@ -57,30 +66,64 @@ Edit News Item[% ELSE %]Add News Item[% END %][% ELSE %]News[% END %]</div>
        <div class="yui-b">
 
 [% UNLESS ( add_form ) %]
+    [% IF error_message == 'title_missing' %]
+        <div class="dialog alert">Error: Required news title missing!</div>
+    [% END %]
 <div id="toolbar" class="btn-toolbar">
-    <a class="btn btn-small" id="newentry" href="/cgi-bin/koha/tools/koha-news.pl?op=add_form"><i class="icon-plus"></i> New entry</a>
+    <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>
 </div>
 [% END %]
 
 [% IF ( add_form ) %]
+    [% IF ( op == 'add' ) %][% default_lang = lang %]
+    [% ELSE %][% default_lang = new_detail.lang %]
+    [% END %]
         <form name="add_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl" >
             <input type="hidden" name="op" value="[% op %]" />
             <input type="hidden" name="id" value="[% id %]" />
                        <fieldset class="rows">
             <legend>OPAC and Koha news</legend>
            <ol> <li>
-            <label for="lang">Display location</label>
+            <label for="lang">Display location:</label>
             <select id="lang" name="lang">
-                <option value="koha">Librarian interface</option>
-                [% IF ( slip ) %]<option value="slip" selected="selected">Slip</option>[% ELSE %]<option value="slip">Slip</option>[% END %]
+                [% IF ( default_lang == "" ) %]
+                <option value="" selected="selected">All</option>
+                [% ELSE %]
+                <option value=""                    >All</option>
+                [% END %]
+                [% IF ( default_lang == "koha" ) %]
+                <option value="koha" selected="selected">Librarian interface</option>
+                [% ELSE %]
+                <option value="koha"                    >Librarian interface</option>
+                [% END %]
+                [% IF ( default_lang == "slip" ) %]
+                <option value="slip" selected="selected">Slip</option>
+                [% ELSE %]
+                <option value="slip"                    >Slip</option>
+                [% END %]
                 [% FOREACH lang_lis IN lang_list %]
-                    [% IF ( lang_lis.selected ) %]<option value="[% lang_lis.language %]" selected="selected">OPAC ([% lang_lis.language %])</option>[% ELSE %]<option value="[% lang_lis.language %]">OPAC ([% lang_lis.language %])</option>[% END %]
+                [% IF ( lang_lis.language == default_lang ) %]
+                    <option value="[% lang_lis.language %]" selected="selected">OPAC ([% lang_lis.language %])</option>
+                [% ELSE %]
+                    <option value="[% lang_lis.language %]"                    >OPAC ([% lang_lis.language %])</option>
+                [% END %]
                 [% END %]
             </select>
             </li>
             <li>
-                <label for="title">Title: </label>
-                <input id="title" size="30" type="text" name="title" value="[% new_detail.title %]" />
+                <label for="branch">Library: </label>
+                <select id="branch" name="branch">
+                    [% IF ( new_detail.branchcode == '' ) %]
+                        <option value="" selected="selected">All libraries</option>
+                    [% ELSE %]
+                        <option value=""         >All libraries</option>
+                    [% END %]
+                    [% PROCESS options_for_libraries libraries => Branches.all( selected => new_detail.branchcode, unfiltered => 1, ) %]
+                </select>
+            </li>
+            <li>
+                <label for="title" class="required">Title: </label>
+                <input id="title" size="30" type="text" name="title" value="[% new_detail.title %]" required="required" class="required" /> <span class="required">Required</span>
             </li>
             <li>
                 <label for="from">Publication date: </label>
@@ -95,13 +138,14 @@ Edit News Item[% ELSE %]Add News Item[% END %][% ELSE %]News[% END %]</div>
             <li>
                 <label for="number">Appear in position: </label>
                 [% IF ( new_detail.number ) %]
-                    <input id="number" size="3" name="number" type="text" checked="checked" value="[% new_detail.number %]" />
+                    <input id="number" size="3" name="number" type="text" value="[% new_detail.number %]" />
                 [% ELSE %]
                     <input id="number" size="3" name="number" type="text" />
                 [% END %]
             </li>
             <li><label for="new">News: </label>
-            <textarea name="new" id="new"  cols="75" rows="10">[% new_detail.new %]</textarea></li>
+            <textarea name="new" id="new"  cols="75" rows="10">[% new_detail.new %]</textarea>
+            </li>
             </ol>
                        </fieldset>
   
@@ -112,34 +156,55 @@ Edit News Item[% ELSE %]Add News Item[% END %][% ELSE %]News[% END %]</div>
         <form name="add_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl" >
             <label for="lang">Display location:</label>
             <select name="lang" id="lang">
-            <option value="">All</option>
-            <option value="koha">Librarian interface</option>
-           <option value="slip">Slip</option>
+            [% IF ( lang == "" ) %]
+            <option value=""     selected="selected">All</option>
+            [% ELSE %]
+            <option value=""             >All</option>
+            [% END %]
+            [% IF ( lang == "koha" ) %]
+            <option value="koha" selected="selected">Librarian interface</option>
+            [% ELSE %]
+            <option value="koha"         >Librarian interface</option>
+            [% END %]
+            [% IF ( lang == "slip" ) %]
+            <option value="slip" selected="selected">Slip</option>
+            [% ELSE %]
+            <option value="slip"         >Slip</option>
+            [% END %]
                 [% FOREACH lang_lis IN lang_list %]
-                    [% IF ( lang_lis.selected ) %]
-                        <option value="[% lang_lis.language %]" selected="selected">
-                    [% ELSE %]
-                        <option value="[% lang_lis.language %]">
-                    [% END %]
-                        OPAC ([% lang_lis.language %])
-                    </option>
+                [% IF ( lang_lis.language == lang ) %]
+                    <option value="[% lang_lis.language %]" selected="selected">OPAC ([% lang_lis.language %])</option>
+                [% ELSE %]
+                    <option value="[% lang_lis.language %]"         >OPAC ([% lang_lis.language %])</option>
+                [% END %]
                 [% END %]
             </select>
+            <label for="branch">Library: </label>
+            <select id="branch" name="branch">
+                [% IF ( branchcode == "" ) %]
+                <option value="" selected="selected">All libraries</option>
+                [% ELSE %]
+                <option value=""         >All libraries</option>
+                [% END %]
+                [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %]
+            </select>
             <input type="submit" class="button" value="Filter" />
         </form>
         </div>
         [% IF ( opac_news_count ) %]
-        <form name="del_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl" onsubmit="return confirm('Are you sure you want to delete the selected news?')">
+        <form id="del_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl">
                 <table id="newst">
                    <thead> <tr>
                         <th>&nbsp;</th>
                         <th>Location</th>
+                        <th>Library</th>
                         <th>Number</th>
-                        <th>Creation date</th>
-                        <th>Expiration date</th>
+                        <th class="title-string">Publication date</th>
+                        <th class="title-string">Expiration date</th>
                         <th>Title</th>
+                        <th>Author</th>
                         <th>News</th>
-                        <th>&nbsp;</th>
+                        <th>Actions</th>
                     </tr></thead>
                     <tbody>[% FOREACH opac_new IN opac_news %]
                          [% IF ( opac_new.expired ) %]
@@ -150,25 +215,33 @@ Edit News Item[% ELSE %]Add News Item[% END %][% ELSE %]News[% END %]</div>
                             <td>
                                 <input type="checkbox" name="ids" value="[% opac_new.idnew %]" />
                             </td>
-                            <td>[% IF ( opac_new.lang == 'koha' ) %]
-                                   Librarian interface
-                                 [% ELSE %]
-                                    [% IF ( opac_new.lang == 'slip' ) %]
-                                       Slip
-                                    [% ELSE %]
-                                        OPAC
-                                   [% END %]
-                                [% END %]
+                            <td>[% SWITCH opac_new.lang %]
+                                [%   CASE "koha" %]
+                                    Librarian interface
+                                [%   CASE "slip" %]
+                                    Slip
+                                [%   CASE "" %]
+                                    All
+                                [%   CASE %]
+                                    OPAC ([% opac_new.lang %])
+                                [% END %]
                              </td>
-
+                            <td>[% IF ( opac_new.branchcode == "" ) -%]
+                                All libraries
+                                [% ELSE %][% opac_new.branchname %]
+                                [% END %]</td>
                             <td>[% opac_new.number %]</td>
-                            <td>[% opac_new.newdate %]</td>
-                            <td>[% opac_new.expirationdate %] [% IF ( opac_new.expired ) %](<span class="expired">expired</span>)[% END %]</td>
+                            <td><span title="[% opac_new.newdate %]">[% opac_new.newdate | $KohaDates %]</span></td>
+                            <td><span title="[% opac_new.expirationdate %]">[% opac_new.expirationdate | $KohaDates %] [% IF ( opac_new.expired ) %](<span class="expired">expired</span>)[% END %]</span></td>
                             <td>[% opac_new.title %]</td>
+                            <td>[% opac_new.author_title %] [% opac_new.author_firstname %] [% opac_new.author_surname %]</td>
                            <td>
                                 [% opac_new.new %]
                             </td>
-                            <td><a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;id=[% opac_new.idnew %]">Edit</a></td>
+                            <td class="actions">
+                                <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>
+                                <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>
+                            </td>
                         </tr>
                     [% END %]</tbody>
                 </table>
@@ -176,7 +249,7 @@ Edit News Item[% ELSE %]Add News Item[% END %][% ELSE %]News[% END %]</div>
                 <fieldset class="action"><input type="submit" class="button" value="Delete selected" /></fieldset>
             </form>
         [% ELSE %]
-            <p>No news loaded</p>
+            <div class="dialog message">There are no news items.</div>
         [% END %]
     [% END %]
 </div>