Bug 8438: Users can only claim for serials related to their branch.
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / claims.tt
index 83fdcf3..dd77a73 100644 (file)
@@ -1,26 +1,26 @@
 [% USE Branches %]
 
 [% INCLUDE 'doc-head-open.inc' %]
+[% USE AuthorisedValues %]
     <title>Koha &rsaquo; Serials &rsaquo; Claims</title>
     [% INCLUDE 'doc-head-close.inc' %]
 [% INCLUDE 'calendar.inc' %]
-<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/en/css/datatables.css" />
-<script type="text/javascript" src="[% interface %]/[% theme %]/en/lib/jquery/plugins/jquery.dataTables.min.js"></script>
-[% INCLUDE 'datatables-strings.inc' %]
-<script type="text/javascript" src="[% interface %]/[% theme %]/en/js/datatables.js"></script>
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+[% INCLUDE 'datatables.inc' %]
 <script type="text/javascript">
 //<![CDATA[
-    [% IF (dateformat == 'metric') %]dt_add_type_uk_date();[% END %]
+    var sTable;
         $(document).ready(function() {
-        [% UNLESS ( preview ) %]
-         var sTable = $("#claimst").dataTable($.extend(true, {}, dataTablesDefaults, {
+         sTable = $("#claimst").dataTable($.extend(true, {}, dataTablesDefaults, {
             "sDom": 't',
-            "aoColumnDefs": [
-                { "aTargets": [ 0,1 ], "bSortable": false, "bSearchable": false }
-            ],
+                "aoColumnDefs": [
+                    { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
+                    { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] },
+                    { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
+                ],
             "bPaginate": false
         }));
-        [% END %]
+        sTable.fnAddFilters("filter", "200");
            $('#supplierid').change(function() {
            $('#claims').submit();
            });
@@ -32,7 +32,7 @@
             $("#claimst tr:visible :checkbox").attr('checked', $("#CheckAll").is(':checked'));
         });
 
-           // Generates a dynamic link for exporting the selection's data as CSV
+        // Generates a dynamic link for exporting the selections data as CSV
            $("#ExportSelected").click(function() {
                // We need to use "input[name=serialid]:checked" instead of "input:checked". Otherwise, the "check all" box will pass the value of "on" as a serialid, which produces a SQL error.
              var selected = $("input[name=serialid]:checked");
         return false;
         });
 
-        $("#titlefilter").keyup( function () {
-            sTable.fnFilter( this.value, 3 ); // 3 is position of title column
-        } );
-
-        $("#branchfilter").keyup(function() {
-            sTable.fnFilter( this.value, 2 ); // 2 is the position of the author column
-           });
         });
 
        // Checks if the form can be sent (at least one checkbox must be checked)
        function checkForm() {
            if ($("input:checked").length == 0) {
-               alert(_("Please select at least one item."));
+        alert(_("Please select at least one issue."));
                return false;
            }
        }
 
-    // Filter by status
-    function filterByStatus() {
-        selectedStatus = $("#statusfilter").val();
-        if (selectedStatus == "all") {
-            clearFilters();
-        } else {
-            $("table#claimst tbody tr").hide();
-            $("table#claimst tbody tr").each( function() {
-                if ( $(this).find("span.status-" + selectedStatus).size() > 0 ) {
-                    $(this).show();
-                }
-            });
-        }
-    }
-
-    // Filter by branch
-    function filterByBranch() {
-        selectedBranch = $("#branchfilter").val();
-        if (selectedBranch == "all") {
-            clearFilters();
-        } else {
-            $("table#claimst tbody tr").hide();
-            $("table#claimst tbody tr").each( function() {
-                if ( $(this).find("span.branch-" + selectedBranch).size() > 0 ) {
-                    $(this).show();
-                }
-            });
-        }
-    }
-
        // Filter by date
        function filterByDate() {
         var beginDate = Date_from_syspref($("#from").val()).getTime();
        // Clears filters : shows everything
        function clearFilters() {
            $("table#claimst tbody tr").show();
-       }
 
-       function popup(supplierid,serialid){
-               window.open('claims.pl?supplierid='+ supplierid +'&amp;serialid='+ serialid +'&amp;op=preview' ,'popup', 'width=600,height=400,toolbar=no,scrollbars=yes');
        }
 
 //]]>
 </head>
 <body id="ser_claims" class="ser">
     [% INCLUDE 'header.inc' %]
-[% UNLESS ( preview ) %]
     [% INCLUDE 'serials-search.inc' %]
-[% END %]
 
 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> &rsaquo; Claims</div>
 
-[% UNLESS ( preview ) %]
-
 <div id="doc3" class="yui-t2">
    
    <div id="bd">
 
     <h1>Claims</h1>
 
-[% IF ( letter ) %][% UNLESS ( missingissues ) %][% IF ( supplierid ) %] <div class="dialog alert">No missing issues found.</div>[% ELSE %]<div class="dialog message">Please choose a vendor.</div>[% END %][% END %][% END %]
+    [% IF error_claim %]
+        [% IF error_claim == 'no_vendor_email' %]
+            <div class="error">This vendor has no email defined for late issues.</div>
+        [% ELSIF error_claim == 'no_loggedin_user_email' %]
+            <div class="error">No email is configured for your user.</div>
+        [% ELSE %]
+            <div class="error">[% error_claim %]</div>
+        [% END %]
+    [% END %]
+    [% IF info_claim %]
+        <div class="dialog message">Email has been sent.</div>
+    [% END %]
+
+[% IF letters %][% UNLESS ( missingissues ) %][% IF ( supplierid ) %] <div class="dialog alert">No missing issues found.</div>[% ELSE %]<div class="dialog message">Please choose a vendor.</div>[% END %][% END %][% END %]
        
             [% IF ( SHOWCONFIRMATION ) %]
      <div class="dialog alert">Your notification has been sent.</div>
      [% END %]
-[% UNLESS ( letter ) %]<div class="dialog alert">No claims notice defined. <a href="/cgi-bin/koha/tools/letter.pl">Please define one</a>.</div>[% END %]
+[% UNLESS letters %]<div class="dialog alert">No claims notice defined. <a href="/cgi-bin/koha/tools/letter.pl">Please define one</a>.</div>[% END %]
     <form id="claims" name="claims" action="claims.pl" method="post">
     <fieldset>
            <label for="supplierid">Vendor: </label>
                [% END %]
            </select>
         <input type="submit" value="OK" />
-        [% IF ( phone ) %]Phone: [% phone %][% END %]
-        [% IF ( booksellerfax ) %]Fax: [% booksellerfax %][% END %]
-        [% IF ( bookselleremail ) %]</p><p><a href="mailto:[% bookselleremail %]">[% bookselleremail %]</a>[% END %]
     </fieldset>
 </form>
 
        <legend>Filters :</legend>
        
        <ol>
-       <li>
-           <label for="statusfilter">Status : </label>
-           <select id="statusfilter" onchange="filterByStatus();">
-            <option value="all" selected="selected">(All)</option>
-            <option value="expected">Expected</option>
-            <option value="late">Late</option>
-            <option value="missing">Missing</option>
-            <option value="missing_never_received">Missing (never received)</option>
-            <option value="missing_sold_out">Missing (sold out)</option>
-            <option value="missing_damaged">Missing (damaged)</option>
-            <option value="missing_lost">Missing (lost)</option>
-            <option value="claimed">Claimed</option>
-           </select>
-       </li>
-       
-       <li>
-           <label for="titlefilter">Title : </label>
-        <input id="titlefilter" type="text" />
-    </li>
-    <li>
-           <label for="branchfilter">Library: </label>
-           <select id="branchfilter" onchange="filterByBranch();">
-            <option value="all" selected="selected">(All)</option>
-            [% FOREACH branchloo IN branchloop %]
-                <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>
-            [% END %]
-        </select>
-       </li>
-       
        <li>
         <label for="from">From:</label>
         <input type="text" name="begindate" id="from" value="[% begindate %]" size="10" maxlength="10" class="datepickerfrom" />
         <input type="text" name="enddate" id="to" value="[% enddate %]" size="10" maxlength="10" class="datepickerto" />
         <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
            <input type="button" value="OK" onclick="filterByDate();" />
-        </li>
-       
+    </li>
+
        <li>
         <input type="reset" value="Clear filters" onclick="clearFilters();" />
        </li>
     </form>
 
     <fieldset>
-       <form action="claims.pl" method="post" class="checkboxed" onsubmit="return checkForm()">
-        <input type="hidden" name="order" value="[% order %]" />
-         <table id="claimst">
-                <thead><tr>
-                    <th><input type="checkbox" id="CheckAll"></th>
-                    <th>Vendor</th>
-                    <th>Library</th>
-                    <th>Title</th>
-                    <th>Issue number</th>
-                    <th>Status</th>
-                    <th>Since</th>
-                    <th>Claim date</th>
-                </tr></thead>
+        <form action="claims.pl" method="post" class="checkboxed" onsubmit="return checkForm()">
+            <table id="claimst">
+                <thead>
+                    <tr>
+                        <th><input type="checkbox" id="CheckAll"></th>
+                        <th>Vendor</th>
+                        <th>Library</th>
+                        <th class="anti-the">Title</th>
+                        <th>ISSN</th>
+                        <th>Issue number</th>
+                        <th>Status</th>
+                        <th class="title-string">Since</th>
+                        <th>Claims count</th>
+                        <th class="title-string">Claim date</th>
+                        [% FOR field IN additional_fields_for_subscription %]
+                          <th>[% field.name %]</th>
+                        [% END %]
+                    </tr>
+                </thead>
+                <tfoot>
+                  <tr>
+                    <td></td>
+                    <td><input type="text" class="filter" data-column_num="1" placeholder="Search vendor" /></td>
+                    <td><input type="text" class="filter" data-column_num="2" placeholder="Search library" /></td>
+                    <td><input type="text" class="filter" data-column_num="3" placeholder="Search title" /></td>
+                    <td><input type="text" class="filter" data-column_num="4" placeholder="Search ISSN" /></td>
+                    <td><input type="text" class="filter" data-column_num="5" placeholder="Search issue number" /></td>
+                    <td><input type="text" class="filter" data-column_num="6" placeholder="Search status" /></td>
+                    <td><input type="text" class="filter" data-column_num="7" placeholder="Search since" /></td>
+                    <td><input type="text" class="filter" data-column_num="8" placeholder="Search claim count" /></td>
+                    <td><input type="text" class="filter" data-column_num="9" placeholder="Search claim date" /></td>
+                    [% FOR field IN additional_fields_for_subscription %]
+                      <td><input type="text" class="filter" data-column_num="[% loop.count + 9 %]" placeholder="Search [% field.name %]" /></td>
+                    [% END %]
+                  </tr>
+                </tfoot>
                 <tbody>[% FOREACH missingissue IN missingissues %]
                     <tr>
                         <td>
+                          [% UNLESS missingissue.cannot_claim %]
                             <input type="checkbox" name="serialid" value="[% missingissue.serialid %]" />
+                          [% END %]
                         </td>
-                        <td>
-                        [% missingissue.name %]
-                        </td>
+                        <td>[% missingissue.name %]</td>
                         <td>
                             <span class="branch-[% missingissue.branchcode %]">[% Branches.GetName( missingissue.branchcode ) %]</span>
                         </td>
                         <td>
                         <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% missingissue.subscriptionid %]">[% missingissue.title |html %]</a>
                         </td>
-                        <td>
-                        [% missingissue.serialseq %]
-                        </td>
+                        <td>[% missingissue.issn %]</td>
+                        <td>[% missingissue.serialseq %]</td>
                         <td>
                             [% IF ( missingissue.status1 ) %]<span class="status-expected">Expected</span>[% END %]
                             [% IF ( missingissue.status3 ) %]<span class="status-late">Late</span>[% END %]
                             [% IF ( missingissue.status7 ) %]<span class="status-claimed">Claimed</span>[% END %]
                         </td>
                         <td class="planneddate">
-                        [% missingissue.planneddate %]
+                            [% IF ( missingissue.planneddate ) %]
+                                <span title="[% missingissue.planneddateISO %]">[% missingissue.planneddate %]</span>
+                            [% ELSE %]
+                                <span title="0000-00-00"></span>
+                            [% END %]
                         </td>
+                        <td>[% missingissue.claims_count %]</td>
                         <td>
-                        [% missingissue.claimdate %]
+                            [% IF ( missingissue.claimdate ) %]
+                                <span title="[% missingissue.claimdateISO %]">[% missingissue.claimdate %]</span>
+                            [% ELSE %]
+                                <span title="0000-00-00"></span>
+                            [% END %]
                         </td>
+                        [% FOR field IN additional_fields_for_subscription %]
+                          [% IF field.authorised_value_category %]
+                            <td>[% AuthorisedValues.GetByCode( field.authorised_value_category, missingissue.additional_fields.${field.name} ) %]</td>
+                          [% ELSE %]
+                            <td>[% missingissue.additional_fields.${field.name} %]</td>
+                          [% END %]
+                        [% END %]
                     </tr>
                 [% END %]</tbody>
             </table>
 
-        [% IF csv_profiles %]
-          <fieldset class="action">
-            <label for="csv_code">Select CSV profile:</label>
-            <select id="csv_profile_for_export">
-              [% FOR csv IN csv_profiles %]
-                <option value="[% csv.export_format_id %]">[% csv.profile %]</option>
-               [% END %]
-            </select>
-            <span class="exportSelected"><a id="ExportSelected" href="/cgi-bin/koha/serials/claims.pl">Download selected claims</a></span>
-        [% END %]
+            [% IF csv_profiles %]
+              <fieldset class="action">
+                <label for="csv_code">Select CSV profile:</label>
+                <select id="csv_profile_for_export">
+                  [% FOR csv IN csv_profiles %]
+                    <option value="[% csv.export_format_id %]">[% csv.profile %]</option>
+                   [% END %]
+                </select>
+                <span class="exportSelected"><a id="ExportSelected" href="/cgi-bin/koha/serials/claims.pl">Download selected claims</a></span>
+            [% END %]
 
-[% IF ( letter ) %]
-        <fieldset class="action"> <label for="letter_code">Select notice:</label>
-            <select name="letter_code" id="letter_code">
-                [% FOREACH letter IN letters %]
-                    <option value="[% letter.code %]">[% letter.name %]</option>
-                [% END %]
-                       </select>
-           <input type="hidden" name="op" value="send_alert" /><input type="submit" name="submit" class="button" value="Send notification" /></fieldset>
+            [% IF letters %]
+                <fieldset class="action">
+                    <label for="letter_code">Select notice:</label>
+                    <select name="letter_code" id="letter_code">
+                        [% FOREACH letter IN letters %]
+                            <option value="[% letter.code %]">[% letter.name %]</option>
+                        [% END %]
+                    </select>
+                    <input type="hidden" name="op" value="send_alert" />
+                    <input type="hidden" name="supplierid" value="[% supplierid %]" />
+                    <input type="submit" name="submit" class="button" value="Send notification" />
+                </fieldset>
             [% END %]
         </form>
     </fieldset>
 [% END %]
 
-[% ELSE %]
-
-<div id="doc" class="yui-t7">
-   <div id="bd">
-       
-[% IF ( supplierloop ) %]
-        [% FOREACH supplierloo IN supplierloop %]
-        [% IF ( supplierloo.name ) %]
-        <p><b>[% supplierloo.name %]</b><br />
-        [% END %]
-        [% IF ( supplierloo.postal ) %]
-        [% supplierloo.postal %]<br />
-        [% END %]
-        [% IF ( supplierloo.contphone ) %]
-        Ph: [% supplierloo.contphone %]<br />
-        [% END %]
-        [% IF ( supplierloo.contfax ) %]
-        Fax: [% supplierloo.contfax %]<br />
-        [% END %]
-        [% IF ( supplierloo.contemail ) %]
-        Email: [% supplierloo.contemail %]<br />
-        [% END %]
-        [% IF ( supplierloo.accountnumber ) %]
-        A/C: [% supplierloo.accountnumber %]</p>
-        [% END %]
-        [% IF ( supplierloo.contact ) %]
-        <p>Dear [% supplierloo.contact %]</p>
-        [% ELSE %]
-        <p>To whom it may concern</p>
-        [% END %]
-        <p>The following items have not been received from you and are now considered missing:</p>
-        [% END %]
-[% END %]
-        [% IF ( missingissues ) %]
-        <h3>Missing issues</h3>
-        <table>
-            <tr>
-                <td><b>Vendor<b></td>
-                <td><b>Title</b></td>
-                <td><b>Issue number</b></td>
-                <td><b>Missing since</b></td>
-            </tr>
-            [% FOREACH missingissue IN missingissues %]
-                <tr>
-                    <td>
-                    [% missingissue.name %]
-                    </td>
-                    <td>
-                    [% missingissue.Title |html %]
-                    </td>
-                    <td>
-                    [% missingissue.serialseq %]
-                    </td>
-                    <td>
-                    [% missingissue.planneddate %]
-                    </td>
-                </tr>
-            [% END %]
-        </table>
-        [% END %]
-
-<p class="noprint"><a href="#" onclick="window.print(); return false;">Print</a> &nbsp; <a href="#" class="close">Close</a></p>
-[% END %]
-
 </div>
 </div>
 
-[% UNLESS ( preview ) %]
 <div class="yui-b">
 [% INCLUDE 'serials-menu.inc' %]
 </div>
-[% END %]
 </div>
 [% INCLUDE 'intranet-bottom.inc' %]