View | Details | Raw Unified | Return to bug 5342
Collapse All | Expand All

(-)a/C4/Letters.pm (-3 / +3 lines)
Lines 330-343 sub SendAlerts { Link Here
330
330
331
        my $sthbookseller =
331
        my $sthbookseller =
332
          $dbh->prepare("select * from aqbooksellers where id=?");
332
          $dbh->prepare("select * from aqbooksellers where id=?");
333
        $sthbookseller->execute( $dataorders->[0]->{booksellerid} );
333
        $sthbookseller->execute( $dataorders->[0]->{aqbooksellerid} );
334
        my $databookseller = $sthbookseller->fetchrow_hashref;
334
        my $databookseller = $sthbookseller->fetchrow_hashref;
335
335
336
        my @email;
336
        my @email;
337
        push @email, $databookseller->{bookselleremail} if $databookseller->{bookselleremail};
337
        push @email, $databookseller->{bookselleremail} if $databookseller->{bookselleremail};
338
        push @email, $databookseller->{contemail}       if $databookseller->{contemail};
338
        push @email, $databookseller->{contemail}       if $databookseller->{contemail};
339
        unless (@email) {
339
        unless (@email) {
340
            warn "Bookseller $dataorders->[0]->{booksellerid} without emails";
340
            warn "Bookseller $dataorders->[0]->{aqbooksellerid} without emails";
341
            return { error => "no_email" };
341
            return { error => "no_email" };
342
        }
342
        }
343
343
Lines 356-362 sub SendAlerts { Link Here
356
356
357
        # ... then send mail
357
        # ... then send mail
358
        my %mail = (
358
        my %mail = (
359
            To => join( ','. @email),
359
            To => join( ',', @email),
360
            From           => $userenv->{emailaddress},
360
            From           => $userenv->{emailaddress},
361
            Subject        => Encode::encode( "utf8", "" . $letter->{title} ),
361
            Subject        => Encode::encode( "utf8", "" . $letter->{title} ),
362
            Message        => Encode::encode( "utf8", "" . $letter->{content} ),
362
            Message        => Encode::encode( "utf8", "" . $letter->{content} ),
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js (-1 / +1 lines)
Lines 23-29 var dataTablesDefaults = { Link Here
23
        "sSearch"           : window.MSG_DT_SEARCH || "Search:",
23
        "sSearch"           : window.MSG_DT_SEARCH || "Search:",
24
        "sZeroRecords"      : window.MSG_DT_ZERO_RECORDS || "No matching records found"
24
        "sZeroRecords"      : window.MSG_DT_ZERO_RECORDS || "No matching records found"
25
    },
25
    },
26
    "sDom": '<"top pager"ilpf>t<"bottom pager"ip>'
26
    "sDom": '<"top pager"ilpf>rt<"bottom pager"ip>'
27
};
27
};
28
28
29
29
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt (-300 / +186 lines)
Lines 1-337 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
    <title>Koha &rsaquo; Serials &rsaquo; Claims</title>
2
<title>Koha &rsaquo; Serials &rsaquo; Claims</title>
3
    [% INCLUDE 'doc-head-close.inc' %]
3
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
4
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
4
[% INCLUDE 'doc-head-close.inc' %]
5
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.uitablefilter.js"></script>
5
[% INCLUDE 'calendar.inc' %]
6
<script type="text/JavaScript" language="JavaScript">
6
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
7
//<![CDATA[
7
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
8
	 $(document).ready(function() {
9
        $("#claimst").tablesorter({[% IF ( dateformat == 'metric' ) %]
10
            dateFormat: 'uk',[% END %]
11
            headers: { 0: { sorter: false },1:{sorter:false}}
12
        });
13
        $('#supplierid').change(function() {
14
            $('#claims').submit();
15
        });
16
17
	    // Case-insensitive version of jquery's contains function
18
	    jQuery.extend(
19
		jQuery.expr[':'], { 
20
		    icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0" 
21
		}
22
	    );
23
24
8
25
	    // Checkboxes : Select All / None
9
<script type="text/JavaScript" language="javascript">
26
	    $("span.checkall").html("<input type=\"checkbox\" name=\"CheckAll\"> "+_("Check All")+"</input>");
10
//<![CDATA[
27
	    $("span.exportSelected").html("<a id=\"ExportSelected\" href=\"/cgi-bin/koha/serials/claims.pl\"> "+_("Export selected items data") +"<\/a>");
11
    $(document).ready(function() {
12
        // Case-insensitive version of jquery's contains function
13
        jQuery.extend(
14
            jQuery.expr[':'], {
15
                icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0" 
16
            }
17
        );
18
19
        // Checkboxes : Select All / None
20
        $("span.checkall").html("<input type=\"checkbox\" name=\"CheckAll\"> "+_("Check All")+"</input>");
21
        $("span.exportSelected").html("<a id=\"ExportSelected\" href=\"/cgi-bin/koha/serials/claims.pl\"> "+_("Export selected items data") +"<\/a>");
28
22
29
        $("#CheckAll").click(function() {
23
        $("#CheckAll").click(function() {
30
            $("#claimst tr:visible :checkbox").attr('checked', $("#CheckAll").is(':checked'));
24
            $("#claimst tr:visible :checkbox").attr('checked', $("#CheckAll").is(':checked'));
31
        });
25
        });
32
26
33
	    // Generates a dynamic link for exporting the selection's data as CSV
27
        // Generates a dynamic link for exporting the selection's data as CSV
34
	    $("#ExportSelected").click(function() {
28
        $("#ExportSelected").click(function() {
35
		// We use input:checked because it's faster, but if there must new checkboxes  
29
            // We use input:checked because it's faster, but if there must new checkboxes
36
		// used for other purpose on this page, please use [name=serialid]:checked instead
30
            // used for other purpose on this page, please use [name=serialid]:checked instead
37
		var selected = $("input:checked");
31
            var selected = $("input:checked");
38
32
39
		if (selected.length == 0) {
33
            if (selected.length == 0) {
40
			alert(_('Please select at least one item to export.'));
34
                alert(_('Please select at least one item to export.'));
41
			return false;
35
                return false;
42
		}
36
            }
43
		
37
44
		// Building the url from currently checked boxes
38
            // Building the url from currently checked boxes
45
		var url = '/cgi-bin/koha/serials/lateissues-excel.pl?supplierid=&amp;op=claims';
39
            var url = '/cgi-bin/koha/serials/lateissues-excel.pl?supplierid=&amp;op=claims';
46
		for (var i = 0; i < selected.length; i++) {
40
            for (var i = 0; i < selected.length; i++) {
47
		    url += '&amp;serialid=' + selected[i].value;
41
                url += '&amp;serialid=' + selected[i].value;
48
		}
42
            }
49
		// And redirecting to the CSV page
43
            // And redirecting to the CSV page
50
		location.href = url;
44
            location.href = url;
51
		return false;
45
            return false;
52
	    });	
46
        });
53
54
        $("#titlefilter").keyup(function() {
55
            $.uiTableFilter($("#claimst"), $("#titlefilter").val())
56
	    });
57
58
        $("#branchfilter").keyup(function() {
59
            $.uiTableFilter($("#claimst"), $("#branchfilter").val())
60
	    });
61
	 });
62
63
	// Checks if the form can be sent (at least one checkbox must be checked)
64
	function checkForm() {
65
	    if ($("input:checked").length == 0) {
66
		alert(_('Please select at least one item.'));
67
		return false;
68
	    }
69
	}
70
71
	// Filter by status
72
	function filterByStatus() {
73
	    selectedStatus = $("#statusfilter").val();
74
	    if (selectedStatus == "all") {
75
		clearFilters();
76
	    } else {
77
		$("table#claimst tbody tr").hide();
78
		$("table#claimst tbody tr:contains(" + selectedStatus + ")").show();
79
	    }
80
	}
81
82
	// Filter by branch
83
	function filterByBranch() {
84
	    selectedBranch = $("#branchfilter").val();
85
	    if (selectedBranch == "all") {
86
		clearFilters();
87
	    } else {
88
		$("table#claimst tbody tr").hide();
89
		$("table#claimst tbody tr:contains(" + selectedBranch + ")").show();
90
	    }
91
	}
92
	// Filter by date
93
	function filterByDate() {
94
	    var beginDate = Date_from_syspref($("#begindate").val()).getTime();
95
	    var endDate   = Date_from_syspref($("#enddate").val()).getTime();
96
	    
97
	    // Checks if the beginning date is valid
98
	    if (!parseInt(beginDate)) {
99
		alert(_('The beginning date is missing or invalid.'));
100
		return false;
101
	    }
102
47
103
	    // Checks if the ending date is valid
48
        $("span.replace_me").each(function(){
104
	    if (!parseInt(endDate)) {
49
            replace_html(this);
105
		alert(_('The ending date is missing or invalid.'));
50
        });
106
		return false;
107
	    }
108
51
109
	    // Checks if beginning date is before ending date
52
        var claimst = $("#claimst").dataTable($.extend(true, {}, dataTablesDefaults, {
110
	    if (beginDate > endDate) {
53
            "bAutoWidth": false,
111
		// If not, we swap them
54
            "bProcessing": true,
112
		var tmpDate = endDate;
55
            "bServerSide": true,
113
		endDate = beginDate;
56
            "sAjaxSource": "/cgi-bin/koha/serials/tables/claims.pl",
114
		beginDate = tmpDate;
57
            'fnServerData': function(sSource, aoData, fnCallback) {
115
	    }
58
              aoData.push(
116
	   
59
                {
117
	    // We hide everything
60
                  'name': 'planneddate_from',
118
	    $("table#claimst tbody tr").hide();
61
                  'value': $("#planneddatefrom").val()
62
                },
63
                {
64
                  'name': 'planneddate_to',
65
                  'value': $("#planneddateto").val()
66
                },
67
                {
68
                    'name': 'claimdatefrom',
69
                    'value': $("#claimdatefrom").val()
70
                },
71
                {
72
                    'name': 'claimdateto',
73
                    'value': $("#claimdateto").val()
74
                }
75
              );
76
              $.ajax({
77
                'dataType': 'json',
78
                'type': 'POST',
79
                'url': sSource,
80
                'data': aoData,
81
                'success': fnCallback
82
              });
83
            },
84
            "oLanguage": {
85
                "sSearch": _("Search all columns:"),
86
            },
87
            "aaSorting": [ [3, 'asc'] ], // sorting on title by default
88
            "aoColumnDefs": [
89
                { "aTargets": [ 0 ], "mDataProp": "dt_checkbox", "bSortable":false, "bSearchable":false  }, // No sorting on first column
90
                { "aTargets": [ 1 ], "mDataProp": "dt_suppliername" },
91
                { "aTargets": [ 2 ], "mDataProp": "dt_branchname" },
92
                { "aTargets": [ 3 ], "mDataProp": "dt_title" },
93
                { "aTargets": [ 4 ], "mDataProp": "dt_serialseq" },
94
                { "aTargets": [ 5 ], "mDataProp": "dt_status", "bSortable":false, "bSearchable":false },
95
                { "aTargets": [ 6 ], "mDataProp": "dt_planneddate" },
96
                { "aTargets": [ 7 ], "mDataProp": "dt_claims_count" },
97
                { "aTargets": [ 8 ], "mDataProp": "dt_claimdate" },
98
                { "aTargets": [ '_all' ], "bSortable": true }
99
            ],
100
            "sPaginationType": "full_numbers",
101
        }) );
102
103
        claimst.fnAddFilters("filter", 750);
104
105
106
        $("#status_filter").change(function() {
107
            claimst.fnFilter($(this).val(), 5);
108
        });
119
109
120
	    // For each date in the table
121
	    $(".planneddate").each(function() {
122
110
123
		// We make a JS Date Object, according to the locale
111
        $('#planneddatefrom').change( function() {claimst.fnDraw(); } );
124
		var pdate = Date_from_syspref($(this).text()).getTime();
112
        $('#planneddateto').change( function() { claimst.fnDraw(); } );
113
        $('#claimdatefrom').change( function() {claimst.fnDraw(); } );
114
        $('#claimdateto').change( function() {claimst.fnDraw(); } );
125
115
126
		// And checks if the date is between the beginning and ending dates
116
    });
127
		if (pdate > beginDate && 
128
		    pdate < endDate) {
129
			// If so, we can show the row
130
			$(this).parent().show();
131
		    }
132
117
133
	    });
118
    function clearDate(nodeid) {
134
	}
119
        $("#"+nodeid).val("");
120
        $("#"+nodeid).change();
121
    }
135
122
136
	// Clears filters : shows everything
123
    // Checks if the form can be sent (at least one checkbox must be checked)
137
	function clearFilters() {
124
    function checkForm() {
138
	    $("table#claimst tbody tr").show();
125
        if ($("input:checked").length == 0) {
139
	}
126
            alert(_('Please select at least one item.'));
127
            return false;
128
        }
129
    }
140
130
141
//]]>
131
//]]>
132
142
</script>
133
</script>
143
[% INCLUDE 'calendar.inc' %]
144
</head>
134
</head>
145
<body id="ser_claims" class="ser">
135
<body>
146
    [% INCLUDE 'header.inc' %]
136
    [% INCLUDE 'header.inc' %]
147
    [% INCLUDE 'serials-search.inc' %]
137
    [% INCLUDE 'serials-search.inc' %]
148
138
149
<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>
139
<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>
150
140
151
<div id="doc3" class="yui-t2">
141
<div id="doc3" class="yui-t2">
152
   
153
   <div id="bd">
154
	<div id="yui-main">
155
	<div class="yui-b">
156
142
157
    <h1>Claims</h1>
143
  <div id="bd">
144
    <div id="yui-main">
145
    <div class="yui-b">
158
146
159
    [% IF error_claim %]
147
    <h1>Claims</h1>
160
        [% IF ( error_claim == "no_email" ) %]
148
    [% IF ( error_claim ) %]
161
            <div class="error">This vendor has no email</div>
149
        <div class='error'>[% error_claim %]</div>
162
        [% ELSE %]
163
            <div class="error">[% error_claim %]</div>
164
        [% END %]
165
    [% END %]
150
    [% END %]
166
    [% IF info_claim %]
151
    [% IF ( info_claim ) %]
167
        <div class="dialog message">Email has been sent.</div>
152
        <div class="dialog message">Email has been sent.</div>
168
    [% END %]
153
    [% END %]
154
    [% UNLESS ( letter ) %]
155
        <div class="dialog alert">No claims notice defined. <a href="/cgi-bin/koha/tools/letter.pl">Please define one</a></div>
156
    [% END %]
169
157
170
[% 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 %]
171
	
172
	     [% IF ( SHOWCONFIRMATION ) %]
173
     <div class="dialog alert">Your notification has been sent.</div>
174
     [% END %]
175
[% UNLESS ( letter ) %]<div class="dialog alert">No claims notice defined. <a href="/cgi-bin/koha/tools/letter.pl">Please define one</a>.</div>[% END %]
176
    <form id="claims" name="claims" action="claims.pl" method="post">
177
    <fieldset>
178
	    <label for="supplierid">Vendor: </label>
179
	    <select id="supplierid" name="supplierid">
180
	        [% FOREACH suploo IN suploop %]
181
	            [% IF ( suploo.selected ) %]
182
	            <option value="[% suploo.id %]" selected="selected" >
183
	            [% ELSE %]
184
	            <option value="[% suploo.id %]">
185
	            [% END %]
186
	                [% suploo.name %]
187
	                ([% suploo.count %])
188
	            </option>
189
	        [% END %]
190
	    </select>
191
        <input type="submit" value="OK" />
192
        [% IF ( phone ) %]Phone: [% phone %][% END %]
193
        [% IF ( booksellerfax ) %]Fax: [% booksellerfax %][% END %]
194
        [% IF ( bookselleremail ) %]</p><p><a href="mailto:[% bookselleremail %]">[% bookselleremail %]</a>[% END %]
195
    </fieldset>
196
</form>
197
198
   [% IF ( missingissues ) %]	
199
    <h3>Missing Issues</h3>
158
    <h3>Missing Issues</h3>
200
    <form action="claims.pl" onsubmit="return false;">
201
	<fieldset class="rows">
202
	<legend>Filters :</legend>
203
	
204
	<ol>
205
	<li>
206
	    <label for="statusfilter">Status : </label>
207
	    <select id="statusfilter" onchange="filterByStatus();">
208
		<option value="all" selected="selected">(All)</option>
209
		<option>Expected</option>
210
		<option>Arrived</option>
211
		<option>Late</option>
212
		<option>Missing</option>
213
		<option>Claimed</option>
214
	    </select>
215
	</li>
216
	
217
	<li>
218
	    <label for="titlefilter">Title : </label>
219
	    <input id="titlefilter" type="text" />
220
	    <label for="branchfilter">Library: </label>
221
	    <select id="branchfilter" onchange="filterByBranch();">
222
            [% FOREACH branchloo IN branchloop %]
223
                [% IF ( branchloo.selected ) %]
224
                <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
225
                [% ELSE %]
226
                <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>
227
                [% END %]
228
            [% END %]
229
        </select>
230
	</li>
231
	
232
	<li>
233
	    <label for="begindate">From</label>
234
	    <img src="[% themelang %]/lib/calendar/cal.gif" id="begindatebutton" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" />
235
	    <input type="text" name="begindate" id="begindate" value="[% begindate %]" size="10" maxlength="10" />
236
	    <script type="text/javascript">
237
		 //<![CDATA[ 
238
		Calendar.setup({
239
		    inputField	: "begindate", 
240
		    button		: "begindatebutton",
241
		    ifFormat	: "[% DHTMLcalendar_dateformat %]"
242
		});
243
		//]]>
244
	    </script>
245
159
246
	    <label for="enddate" style="float:none;">To</label>
160
    <form action="claims.pl" method="post" class="checkboxed" onsubmit="return checkForm()">
247
	    <img src="[% themelang %]/lib/calendar/cal.gif" id="enddatebutton" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" />
161
      <fieldset>
248
	    <input type="text" name="enddate" id="enddate" value="[% enddate %]" size="10" maxlength="10" />
162
        <input type="hidden" name="order" value="[% order %]" />
249
	    <script type="text/javascript">
163
        <table id="claimst" class="display">
250
		 //<![CDATA[ 
164
           <thead><tr>
251
		 Calendar.setup({
165
               <th><input type="checkbox" id="CheckAll"></th>
252
		    inputField      : "enddate", 
166
               <th>Vendor</th>
253
		    button          : "enddatebutton",
167
               <th>Branch</th>
254
		    ifFormat        : "[% DHTMLcalendar_dateformat %]"
168
               <th>Title</th>
255
		});
169
               <th>Issue number</th>
256
		//]]>
170
               <th>Status</th>
257
	    </script> <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
171
               <th>Since</th>
258
	    <input type="button" value="OK" onclick="filterByDate();" />
172
               <th>Claims count</th>
259
        </li>
173
               <th>Claim Date</th>
260
	
174
           </tr></thead>
261
	<li>
175
           <tbody></tbody>
262
	    <input type="reset" value="Clear Filters" onclick="clearFilters();" />
176
           <tfoot>
263
	</li>
177
             <tr>
264
	</ol>
178
               <th></th>
265
	</fieldset>
179
               <th><input type="text" class="filter" id="suppliername_filter" data-column_num="1" placeholder="Search vendor" /></th>
180
               <th><input type="text" class="filter" id="branchname_filter"  data-column_num="2" placeholder="Search branch" /></th>
181
               <th><input type="text" class="filter" id="title_filter"  data-column_num="3" placeholder="Search title" /></th>
182
               <th><input type="text" class="filter" id="serialseq_filter"  data-column_num="4" placeholder="Search issue number" /></th>
183
               <th>
184
                 <select id="status_filter" data-column_num="5">
185
                   <option value="">All</option>
186
                   <option value="1">Expected</option>
187
                   <option value="2">Arrived</option>
188
                   <option value="3">Late</option>
189
                   <option value="4">Missing</option>
190
                   <option value="7">Claimed</option>
191
                 </select>
192
               </th>
193
               <th>
194
                 <span class="replace_me" data-id="planneddate" data-type="range_dates" data-format="[% DHTMLcalendar_dateformat %]"></span>
195
               </th>
196
               <th><input type="text" class="filter" id="claimscount_filter" data-column_num="7" placeholder="Search claims count" /></th>
197
               <th><span class="replace_me" data-type="range_dates" data-id="claimdate" data-format="[% DHTMLcalendar_dateformat %]"></span></th>
198
            </tfoot>
199
        </table>
200
201
        <div class="spacer"></div>
202
        <p style="display:block;"><span class="exportSelected"></span></p>
203
204
        [% IF ( letter ) %]
205
          <fieldset class="action">
206
            <label for="letter_code">Select notice:</label>
207
            <select name="letter_code" id="letter_code">
208
              [% FOREACH letter IN letters %]
209
                  <option value="[% letter.code %]">[% letter.name %]</option>
210
              [% END %]
211
            </select>
212
            <input type="hidden" name="op" value="send_alert" /><input type="submit" name="submit" class="button" value="Send notification" /></fieldset>
213
          </fieldset>
214
        [% END %]
215
      </fieldset>
266
    </form>
216
    </form>
267
217
268
    <fieldset>
218
    </div>
269
        <form action="claims.pl" method="post" class="checkboxed" onsubmit="return checkForm()">
219
    </div>
270
            <input type="hidden" name="order" value="[% order %]" />
220
  <div class="yui-b">
271
            <table id="claimst">
272
                <thead>
273
                    <tr>
274
                        [% IF ( letter ) %]
275
                            <th><input type="checkbox" id="CheckAll"></th>
276
                        [% END %]
277
                        <th>Vendor</th>
278
                        <th>Library</th>
279
                        <th>Title</th>
280
                        <th>Issue number</th>
281
                        <th>Status</th>
282
                        <th>Since</th>
283
                        <th>Claims count</th>
284
                        <th>Claim date</th>
285
                    </tr>
286
                </thead>
287
                <tbody>[% FOREACH missingissue IN missingissues %]
288
                    <tr>
289
                        [% IF ( letter ) %]
290
                            <td>
291
                                <input type="checkbox" name="serialid" value="[% missingissue.serialid %]" />
292
                            </td>
293
                        [% END %]
294
                        <td>[% missingissue.name %]</td>
295
                        <td>[% missingissue.branchcode %]</td>
296
                        <td>
297
                        <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% missingissue.subscriptionid %]">[% missingissue.title |html %]</a>
298
                        </td>
299
                        <td>[% missingissue.serialseq %]</td>
300
                        <td>
301
                            [% IF ( missingissue.status1 ) %]Expected[% END %]
302
                            [% IF ( missingissue.status2 ) %]Arrived[% END %]
303
                            [% IF ( missingissue.status3 ) %]Late[% END %]
304
                            [% IF ( missingissue.status4 ) %]Missing[% END %]
305
                            [% IF ( missingissue.status7 ) %]Claimed[% END %]
306
                        </td>
307
                        <td class="planneddate">[% missingissue.planneddate %]</td>
308
                        <td>[% missingissue.claims_count %]</td>
309
                        <td>[% missingissue.claimdate %]</td>
310
                    </tr>
311
                [% END %]</tbody>
312
            </table>
313
            <p><span class="exportSelected"></span></p>
314
315
            [% IF ( letter ) %]
316
                <fieldset class="action">
317
                    <label for="letter_code">Select notice:</label>
318
                    <select name="letter_code" id="letter_code">
319
                        [% FOREACH letter IN letters %]
320
                            <option value="[% letter.code %]">[% letter.name %]</option>
321
                        [% END %]
322
                    </select>
323
                    <input type="hidden" name="op" value="send_alert" />
324
                    <input type="submit" name="submit" class="button" value="Send notification" />
325
                </fieldset>
326
            [% END %]
327
        </form>
328
    </fieldset>
329
[% END %]
330
331
</div>
332
</div>
333
334
<div class="yui-b">
335
[% INCLUDE 'serials-menu.inc' %]
221
[% INCLUDE 'serials-menu.inc' %]
336
</div>
222
</div>
337
</div>
223
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/tables/claims.tt (+38 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
{
3
    'sEcho': '[% sEcho %]',
4
    'iTotalRecords': '[% iTotalRecords %]',
5
    'iTotalDisplayRecords': '[% iTotalDisplayRecords %]',
6
    'aaData': [
7
        [% FOREACH data IN aaData %]
8
            {
9
                'dt_checkbox':
10
                    '[% UNLESS ( data.cannot_claim ) %]<input type="checkbox" name="serialid" value="[% data.serialid %]" />[% END %]',
11
12
                'dt_suppliername':
13
                    '[% data.suppliername |html %]',
14
15
                'dt_title':
16
                    '<a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% data.subscriptionid %]">[% data.title |html %]</a>',
17
18
                'dt_branchname':
19
                    '[% data.branchname %]',
20
21
                'dt_serialseq':
22
                    '[% data.serialseq %]',
23
24
                'dt_status':
25
                    '[% IF ( data.status == 1 ) %]Expected[% END %][% IF ( data.status == 2 ) %]Arrived[% END %][% IF ( data.status == 3 ) %]Late[% END %][% IF ( data.status == 4 ) %]Missing[% END %][% IF ( data.status == 7 ) %]Claimed[% END %]',
26
27
                'dt_planneddate':
28
                    '[% data.planneddate|$KohaDates %]',
29
30
                'dt_claims_count':
31
                    '[% data.claims_count %]',
32
33
                'dt_claimdate':
34
                    '[% data.claimdate|$KohaDates %]'
35
            },
36
        [% END %]
37
    ]
38
}
(-)a/serials/claims.pl (-38 / +19 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Parts Copyright 2010 Biblibre
3
# Parts Copyright 2012 Biblibre
4
4
5
# This file is part of Koha.
5
# This file is part of Koha.
6
#
6
#
Lines 17-24 Link Here
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
use strict;
20
use Modern::Perl;
21
use warnings;
22
use CGI;
21
use CGI;
23
use C4::Auth;
22
use C4::Auth;
24
use C4::Serials;
23
use C4::Serials;
Lines 50-107 my ($template, $loggedinuser, $cookie) Link Here
50
49
51
# supplierlist is returned in name order
50
# supplierlist is returned in name order
52
my $supplierlist = GetSuppliersWithLateIssues();
51
my $supplierlist = GetSuppliersWithLateIssues();
53
for my $s (@{$supplierlist} ) {
54
    $s->{count} = scalar  GetLateOrMissingIssues($s->{id}, q{}, $order);
55
    if ($supplierid && $s->{id} == $supplierid) {
56
        $s->{selected} = 1;
57
    }
58
}
59
52
60
my $letters = GetLetters('claimissues');
53
my @suploop;
61
my @letters;
54
foreach my $s ( @{$supplierlist} ) {
62
foreach (keys %{$letters}){
55
    push @suploop, { %$s };
63
    push @letters ,{code=>$_,name=> $letters->{$_}};
64
}
56
}
65
57
66
my $letter=((scalar(@letters)>1) || ($letters[0]->{name}||$letters[0]->{code}));
58
my $letters = GetLetters("claimissues");
67
my  @missingissues;
59
my @letters;
68
my @supplierinfo;
60
foreach ( keys %{$letters} ) {
69
if ($supplierid) {
61
    push @letters, { code => $_, name => $letters->{$_} };
70
    @missingissues = GetLateOrMissingIssues($supplierid,$serialid,$order);
71
    @supplierinfo=GetBookSeller($supplierid);
72
}
62
}
73
63
74
my $branchloop = GetBranchesLoop();
64
my $letter = ( ( scalar(@letters) > 1 ) || ( $letters[0]->{name} || $letters[0]->{code} ) );
75
unshift @$branchloop, {value=> 'all',name=>''};
76
65
77
my @serialnums=$input->param('serialid');
66
my @serialnums=$input->param('serialid');
78
if (@serialnums) { # i.e. they have been flagged to generate claims
67
if (@serialnums) { # i.e. they have been flagged to generate claims
79
    my $err;
68
    my $err;
80
    eval {
69
    eval {
81
        SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
70
        $err = SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
82
        UpdateClaimdateIssues(\@serialnums);
71
        UpdateClaimdateIssues(\@serialnums);
83
    };
72
    };
84
    if ( $@ ) {
73
    if ( $@ ) {
85
        $template->param(error_claim => $@);
74
        $template->{VARS}->{'error_claim'} = $@;
86
    } elsif ( defined $err->{error} and $err->{error} eq "no_email" ) {
75
    } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) {
87
        $template->{VARS}->{'error_claim'} = "no_email";
76
        $template->{VARS}->{'error_claim'} = "no_email";
88
    } else {
77
    } else {
89
        $template->{VARS}->{'info_claim'} = 1;
78
        $template->{VARS}->{'info_claim'} = 1;
90
    }
79
    }
91
}
80
}
92
$template->param('letters'=>\@letters,'letter'=>$letter);
81
93
$template->param(
82
$template->param(
94
        order =>$order,
83
    letters                  => \@letters,
95
        suploop => $supplierlist,
84
    letter                   => $letter,
96
        phone => $supplierinfo[0]->{phone},
85
    order                    => $order,
97
        booksellerfax => $supplierinfo[0]->{booksellerfax},
86
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
98
        bookselleremail => $supplierinfo[0]->{bookselleremail},
87
);
99
        missingissues => \@missingissues,
100
        supplierid => $supplierid,
101
        claimletter => $claimletter,
102
        supplierloop => \@supplierinfo,
103
        branchloop   => $branchloop,
104
        dateformat    => C4::Context->preference("dateformat"),
105
        DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
106
        );
107
output_html_with_http_headers $input, $cookie, $template->output;
88
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/serials/tables/claims.pl (-1 / +107 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
5
use CGI;
6
use JSON;
7
8
use C4::Auth;
9
use C4::Circulation qw/CanBookBeRenewed/;
10
use C4::Context;
11
use C4::Koha qw/getitemtypeimagelocation/;
12
use C4::Reserves qw/CheckReserves/;
13
use C4::Utils::DataTables;
14
use C4::Output;
15
16
my $input = new CGI;
17
18
my $planneddate_to = $input->param('planneddate_to');
19
my $planneddate_from = $input->param('planneddate_from');
20
my $claimdatefrom = $input->param('claimdatefrom');
21
my $claimdateto = $input->param('claimdateto');
22
23
24
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user({
25
    template_name   => 'serials/tables/claims.tmpl',
26
    query           => $input,
27
    type            => 'intranet',
28
    authnotrequired => 0,
29
    flagsrequired   => { circulate => 'circulate_remaining_permission' },
30
});
31
32
# Fetch DataTables parameters
33
my %dtparam = dt_get_params( $input );
34
35
while ( my ( $k, $v ) = each %dtparam ) {
36
    $v =~ s/^dt_(.+)/$1/;
37
    $dtparam{$k} = $v;
38
}
39
40
my $branchcode;
41
unless( $flags->{'superlibrarian'} == 1
42
 || $template->{'param_map'}->{'CAN_user_serials_superserials'} ){
43
     $branchcode = C4::Context->userenv->{'branch'};
44
}
45
46
my $dbh = C4::Context->dbh;
47
48
# Build the query
49
my $select = <<EOQ;
50
    SELECT SQL_CALC_FOUND_ROWS
51
    serialid, aqbooksellerid, name AS suppliername, biblio.title, planneddate, serialseq,
52
    serial.status, serial.subscriptionid, claimdate, claims_count,
53
    branches.branchname
54
EOQ
55
my $from = <<EOQ;
56
    FROM serial
57
    LEFT JOIN subscription  ON serial.subscriptionid=subscription.subscriptionid 
58
    LEFT JOIN biblio        ON subscription.biblionumber=biblio.biblionumber
59
    LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
60
    LEFT JOIN branches ON branches.branchcode = subscription.branchcode
61
EOQ
62
my $where = <<EOQ;
63
    WHERE (serial.STATUS = 4 OR ((planneddate < now() AND serial.STATUS =1) OR serial.STATUS = 3 OR serial.STATUS = 7))
64
EOQ
65
66
my @bind_params;
67
$where .= qq{ AND subscription.branchcode = ?} if $branchcode;
68
push @bind_params, $branchcode ? $branchcode : ();
69
my ( $planneddate_q , $planneddate_f  ) = dt_build_query( 'range_dates', $planneddate_from, $planneddate_to, 'planneddate' );
70
my ( $claimdate_q, $claimdate_f ) = dt_build_query('range_dates', $claimdatefrom, $claimdateto, 'claimdate');
71
72
my $where_filters;
73
$where_filters .= ( $planneddate_q    ? $planneddate_q : '' );
74
push @bind_params, scalar( @$planneddate_f )    > 0 ? @$planneddate_f : ();
75
76
$where_filters .= ( $claimdate_q ? $claimdate_q : '' );
77
push @bind_params, scalar( @$claimdate_f ) > 0 ? @$claimdate_f : ();
78
79
my ($filters, $filter_params) = dt_build_having(\%dtparam);
80
my $having = @$filters ? " HAVING ". join(" AND ", @$filters) : '';
81
my $order_by = dt_build_orderby(\%dtparam);
82
my $limit .= " LIMIT ?,? ";
83
84
my $query = $select . $from . $where . $where_filters . ( $having || '' ) . $order_by . $limit;
85
push @bind_params, @$filter_params, $dtparam{'iDisplayStart'}, $dtparam{'iDisplayLength'};
86
my $sth = $dbh->prepare($query);
87
$sth->execute(@bind_params);
88
my $results = $sth->fetchall_arrayref({});
89
90
$sth = $dbh->prepare("SELECT FOUND_ROWS()");
91
$sth->execute;
92
my ($iTotalDisplayRecords) = $sth->fetchrow_array;
93
94
# This is mandatory for DataTables to show the total number of results
95
my $select_total_count = "SELECT COUNT(*) ";
96
$sth = $dbh->prepare($select_total_count.$from.$where);
97
$sth->execute($branchcode ? $branchcode : ());
98
my ($iTotalRecords) = $sth->fetchrow_array;
99
100
$template->param(
101
    sEcho => $dtparam{'sEcho'},
102
    iTotalRecords => $iTotalRecords,
103
    iTotalDisplayRecords => $iTotalDisplayRecords,
104
    aaData => $results,
105
);
106
107
output_with_http_headers $input, $cookie, $template->output, "json";

Return to bug 5342