Bug 7910: Give feedack when the subscriptions have been renewed
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / checkexpiration.tt
index e41d5c3..a828f70 100644 (file)
@@ -1,33 +1,11 @@
+[% USE Branches %]
+[% USE KohaDates %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Serials &rsaquo; Check expiration</title>
 [% INCLUDE 'doc-head-close.inc' %]
-[% INCLUDE 'calendar.inc' %]
-[% USE Branches %]
-<script type="text/javascript" language="JavaScript">
-// <![CDATA[
-    /**
-     *  Function CheckForm
-     *  This function checks the form before submit
-     */
-     function CheckForm(form){
-        if(form.date.value){
-            return true;
-        }
-        else {
-            alert(_("You must enter a date!"));
-            document.f.date.focus();
-            return false;
-        }
-     }
-
-       function popup(subscriptionid) {
-          newin=window.open("subscription-renew.pl?mode=popup&subscriptionid="+subscriptionid,'popup','width=590,height=440,toolbar=false,scrollbars=yes,resize=yes');
-       }
-
-     // ]]>
-</script>
-<!-- End of additions -->
 </head>
+
 <body id="ser_checkexpiration" class="ser">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'serials-search.inc' %]
 
 <h1>Check expiration</h1>
 
-    <form name="f" action="/cgi-bin/koha/serials/checkexpiration.pl" method="post" onsubmit="return CheckForm(this);">
+    <form name="f" action="/cgi-bin/koha/serials/checkexpiration.pl" method="get" class="validated">
 <fieldset class="rows">
     <legend>Filter results:</legend>
     
          <ol>
         <li><label for="title">Title:</label>
-        <input id="title" type="text" name="title" size="15" value="[% title %]" /></li>
+        <input id="title" type="text" name="title" size="15" value="[% title | html %]" /></li>
 
         <li><label for="issn">ISSN:</label>
-        <input id="issn" type="text" name="issn" size="15" value="[% issn %]" /></li>
-        [% IF (branches_loop.size) %]
+        <input id="issn" type="text" name="issn" size="15" value="[% issn | html %]" /></li>
+        [% IF can_change_library %]
         <li><label for="branch">Library:</label>
         <select id="branch" name="branch">
             <option value="">All</option>
-            [% FOREACH branch IN branches_loop %]
-                [% IF branch.selected %]
-                    <option selected="selected" value="[% branch.branchcode %]">
-                [% ELSE %]
-                    <option value="[% branch.branchcode %]">
-                [% END %]
-                    [% branch.branchname %]
-                </option>
-            [% END %]
+            [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %]
         </select>
         </li>
         [% END %]
 
-        <li><label for="date" class="required" title="Required field">Expiring before:</label>
-        <input id="date" type="text" name="date" size="10" value="[% date %]" class="focus datepicker" />
+        <li><label for="date" class="required">Expiring before:</label>
+            <input id="date" type="text" name="date" size="10" value="[% date | $KohaDates %]" class="required focus datepicker" required="required" />
         <span class="required">Required</span>
                        <div class="hint">[% INCLUDE 'date-format.inc' %]</div></li>
                        </ol>
 <p>
     <b>[% numsubscription %]</b> subscription(s)
         [% IF ( title ) %]
-        with title matching <span class="title">[% title %]</class>
+        with title matching <span class="title">[% title | html %]</class>
         [% IF ( issn ) %]and [% END %]
     [% END %]
     [% IF ( issn ) %]
-        with ISSN matching <b>[% issn %]</b>
+        with ISSN matching <b>[% issn | html %]</b>
     [% END %]
-        will expire before <b>[% date %]</b>
+        will expire before <b>[% date | $KohaDates %]</b>
 </p>
+
+<div class="checkexpiration-table_table_controls">
+    <a href="#" class="SelectAll"><i class="fa fa-check"></i> Select all</a> |
+    <a href="#" class="ClearAll"><i class="fa fa-remove"></i> Clear all</a>
+    <span class="itemselection_actions">
+      | Actions:
+          <a class="itemselection_action_renew" title="Renew selected subscriptions"><i class="fa fa-refresh"></i> Renew selected subscriptions</a>
+    </span>
+</div>
+
+
 <table>
         <tr>
+            <th></th>
             <th>ISSN</th>
             <th>Title</th>
-            [% IF ( branches_loop.size ) %]<th>Library</th>[% END %]
+            [% IF can_change_library %]<th>Library</th>[% END %]
             <th>OPAC note</th>
             <th>Nonpublic note</th>
             <th>Expiration date</th>
-                       <th colspan="2">&nbsp;</th>
+            <th>Actions</th>
         </tr>
     [% FOREACH subscriptions_loo IN subscriptions_loop %]
-        [% IF ( subscriptions_loo.toogle ) %]
-        <tr class="highlight">
-        [% ELSE %]
         <tr>
-        [% END %]
+            <td style="text-align:center;vertical-align:middle">
+                <input type="checkbox" value="[% subscriptions_loo.subscriptionid %]" name="subscriptionid" />
+            </td>
             <td>
                 [% subscriptions_loo.issn %]
             </td>
                 [% END %]
                 </a>
             </td>
-            [% IF ( branches_loop.size ) %]<td>
+            [% IF can_change_library %]<td>
                 [% Branches.GetName( subscriptions_loo.branchcode ) %]
             </td>[% END %]
             <td>
                 [% subscriptions_loo.internalnotes %]
             </td>
             <td>
-                [% subscriptions_loo.expirationdate %]
+                [% subscriptions_loo.expirationdate | $KohaDates %]
+            </td>
+            <td class="actions">
+                <a href="/cgi-bin/koha/serials/subscription-add.pl?op=modify&amp;subscriptionid=[% subscriptions_loo.subscriptionid %]" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
+                <a href="/cgi-bin/koha/serials/subscription-renew.pl?subscriptionid=[% subscriptions_loo.subscriptionid %]" data-subscriptionid="[% subscriptions_loo.subscriptionid %]" class="btn btn-default btn-xs renew_subscription"><i class="fa fa-refresh"></i> Renew</a>
             </td>
-            <td><a href="/cgi-bin/koha/serials/subscription-add.pl?op=modify&amp;subscriptionid=[% subscriptions_loo.subscriptionid %]">Edit</a></td>
-                       <td><a href="/cgi-bin/koha/serials/subscription-renew.pl?subscriptionid=[% subscriptions_loo.subscriptionid %]" onclick="popup([% subscriptions_loo.subscriptionid %]); return false;">Renew</a></td>
         </tr>
     [% END %]
     </table>
 [% INCLUDE 'serials-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'calendar.inc' %]
+    <script type="text/javascript" language="JavaScript">
+        $(document).ready(function(){
+            $(".renew_subscription").on("click",function(e){
+                e.preventDefault();
+                var subscriptionid = $(this).data("subscriptionid");
+                newin=window.open("/cgi-bin/koha/serials/subscription-renew.pl?mode=popup&subscriptionid="+subscriptionid,'popup','width=590,height=440,toolbar=false,scrollbars=yes,resize=yes');
+            });
+            $('a.itemselection_action_renew').on("click", function(e){
+                e.preventDefault();
+                newin=window.open($(this).attr('href'),'popup','width=590,height=440,toolbar=false,scrollbars=yes,resize=yes');
+            });
+            function itemSelectionBuildRenewLink() {
+                var subscription_ids= new Array();
+                $("input[name='subscriptionid'][type='checkbox']:checked").each(function() {
+                    subscription_ids.push($(this).val());
+                });
+                if (subscription_ids.length > 0) {
+                    var url = '/cgi-bin/koha/serials/subscription-renew.pl?op=multi_renew';
+                    url += '&subscriptionid=' + subscription_ids.join('&subscriptionid=');
+                    $('a.itemselection_action_renew').attr('href', url);
+                } else {
+                    return false;
+                }
+                return true;
+            }
+
+            function itemSelectionBuildActionLinks() {
+                var export_link_ok = itemSelectionBuildRenewLink();
+                if (export_link_ok) {
+                    $('.itemselection_actions').show();
+                } else {
+                    $('.itemselection_actions').hide();
+                }
+            }
+
+            itemSelectionBuildActionLinks();
+
+            $("input[name='subscriptionid'][type='checkbox']").change(function() {
+                itemSelectionBuildActionLinks();
+            });
+
+            $(".SelectAll, .ClearAll").on("click",function(e){
+                e.preventDefault();
+                var checkboxes = $(this).parent().siblings('table').first().find('input[type="checkbox"]');
+                checkboxes.prop('checked', $(this).hasClass('SelectAll'));
+                itemSelectionBuildActionLinks();
+            });
+
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]