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

(-)a/C4/Serials.pm (-42 / +1 lines)
Lines 57-63 BEGIN { Link Here
57
      &GetDistributedTo   &SetDistributedTo
57
      &GetDistributedTo   &SetDistributedTo
58
      &getroutinglist     &delroutingmember   &addroutingmember
58
      &getroutinglist     &delroutingmember   &addroutingmember
59
      &reorder_members
59
      &reorder_members
60
      &check_routing &updateClaim &removeMissingIssue
60
      &check_routing &updateClaim
61
      &CountIssues
61
      &CountIssues
62
      HasItems
62
      HasItems
63
      &GetSubscriptionsFromBorrower
63
      &GetSubscriptionsFromBorrower
Lines 1913-1959 sub GetLateOrMissingIssues { Link Here
1913
    return @issuelist;
1913
    return @issuelist;
1914
}
1914
}
1915
1915
1916
=head2 removeMissingIssue
1917
1918
removeMissingIssue($subscriptionid)
1919
1920
this function removes an issue from being part of the missing string in 
1921
subscriptionlist.missinglist column
1922
1923
called when a missing issue is found from the serials-recieve.pl file
1924
1925
=cut
1926
1927
sub removeMissingIssue {
1928
    my ( $sequence, $subscriptionid ) = @_;
1929
1930
    return unless ($sequence and $subscriptionid);
1931
1932
    my $dbh = C4::Context->dbh;
1933
    my $sth = $dbh->prepare("SELECT * FROM subscriptionhistory WHERE subscriptionid = ?");
1934
    $sth->execute($subscriptionid);
1935
    my $data              = $sth->fetchrow_hashref;
1936
    my $missinglist       = $data->{'missinglist'};
1937
    my $missinglistbefore = $missinglist;
1938
1939
    # warn $missinglist." before";
1940
    $missinglist =~ s/($sequence)//;
1941
1942
    # warn $missinglist." after";
1943
    if ( $missinglist ne $missinglistbefore ) {
1944
        $missinglist =~ s/\|\s\|/\|/g;
1945
        $missinglist =~ s/^\| //g;
1946
        $missinglist =~ s/\|$//g;
1947
        my $sth2 = $dbh->prepare(
1948
            "UPDATE subscriptionhistory
1949
                    SET missinglist = ?
1950
                    WHERE subscriptionid = ?"
1951
        );
1952
        $sth2->execute( $missinglist, $subscriptionid );
1953
    }
1954
    return;
1955
}
1956
1957
=head2 updateClaim
1916
=head2 updateClaim
1958
1917
1959
&updateClaim($serialid)
1918
&updateClaim($serialid)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-recieve.tt (-363 lines)
Lines 1-363 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Serials &rsaquo; Check in subscription for [% bibliotitle %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
<script language="JavaScript" type="text/javascript">
5
//<![CDATA[
6
function popup() {
7
	window.open("subscription-renew.pl?subscriptionid=[% subscriptionid %]","subscription_renewal",'width=700,height=400,toolbar=false,scrollbars=yes');
8
}
9
10
function barcode_check(){
11
    [% IF ( count ) %]
12
	var count = '[% count %]';
13
	for(var i=1;i<=count;i++){
14
15
		var barcodenum = "barcode"+i;
16
		var statusnum = "status"+i;
17
		var elembarcode = "document.getElementById('"+barcodenum+"')";
18
		var elemstatus = "document.getElementById('"+statusnum+"')";
19
// alert(elembarcode+"\n"+eval(elembarcode+".value));
20
// alert(elemstatus+"\n"+eval(elemstatus+".value"));
21
		if(eval(elembarcode+".value") =='' && eval(elemstatus+".value") == 2){
22
			var answer = confirm("Leave barcode blank?\n - Note: unable to change this later");
23
			if (answer){
24
				document.f.submit();
25
			} else {
26
				return false;
27
			}
28
		}
29
		if(eval(elembarcode+".value".indexOf('TEMP')) > 0 && eval(elemstatus+".value") == 2){
30
			var answer = confirm("A barcode was not entered.\nDo you want to put in a barcode\nor do you want to use a system generated barcode?");
31
			if (answer){
32
				document.f.submit();
33
			} else {
34
				return false;
35
			}
36
		}
37
	}
38
    [% END %]
39
}
40
//]]>
41
</script>
42
</head>
43
<body id="ser_serials-recieve" class="ser">
44
[% INCLUDE 'header.inc' %]
45
[% INCLUDE 'serials-search.inc' %]
46
47
<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; Check in subscription for <i>[% bibliotitle %]</i></div>
48
49
<div id="doc3" class="yui-t2">
50
   
51
   <div id="bd">
52
	<div id="yui-main">
53
	<div class="yui-b">
54
55
<h1>Check In subscription for <i>[% bibliotitle %]</i></h1>
56
<div id="action">
57
    <a href="subscription-detail.pl?subscriptionid=[% subscriptionid %]" title="detail of the subscription">Subscription Details</a>
58
    <!-- <a href="/cgi-bin/koha/serials/serials-home.pl?biblionumber=[% biblionumber %]" class="button" title="all subscriptions on [% bibliotitle %]">Search all subscriptions</a> -->
59
    <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]" title="go to [% bibliotitle %]">Show biblio</a>
60
    [% IF ( routing ) %]
61
    <a href="routing.pl?subscriptionid=[% subscriptionid %]" title="subscription routing list">Routing list</a>
62
    [% END %]
63
</div>
64
65
<h2>Expected or late</h2>
66
	<form method="post" name="f" action="serials-recieve.pl" onsubmit="return barcode_check()">
67
		<input type="hidden" name="op" value="serialchangestatus" />
68
		<input type="hidden" name="serial" value="[% serial %]" />
69
		<input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
70
		<input type="hidden" name="user" value="[% user %]" />
71
	<table>
72
	<tr>
73
		<th>Numbered</th>
74
		<th>Published on</th>
75
        <th>Planned for</th>
76
		<th>Status</th>
77
		<th>Notes</th>
78
	</tr>
79
	[% FOREACH serialslis IN serialslist %]
80
		<tr>
81
			<td>
82
				Issue <input type="text" name="serialseq" value="[% serialslis.serialseq %]" size="20" maxlength="100" />
83
			[% IF ( serialslis.serialadditems ) %]
84
				<br /><br />
85
                Call number <input type="text" name="itemcallnumber" value="[% serialslis.callnumber %]" size="15" maxlength="100" />
86
				Barcode <input type="text" name="barcode" value="[% serialslis.barcode %]" id="barcode[% serialslis.num %]" size="20" maxlength="20" />
87
			[% END %]
88
			</td>
89
			<td>
90
				<input type="text" name="publisheddate" value="[% serialslis.publisheddate %]" size="10" maxlength="15" />
91
			[% IF ( serialslis.serialadditems ) %]
92
				<br /><br />&nbsp;
93
			[% END %]
94
			</td>
95
			<td>
96
				<input type="text" name="planneddate" value="[% serialslis.planneddate %]" size="10" maxlength="15" />
97
			[% IF ( serialslis.serialadditems ) %]
98
				<br /><br />
99
				<select name="branch">
100
						<option value="">Library</option>
101
			[% FOREACH branchloo IN serialslis.branchloop %][% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
102
				[% ELSE %]
103
				<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>
104
				[% END %]
105
			[% END %]
106
				</select>
107
			[% END %]
108
			</td>
109
			<td>
110
				<input type="hidden" name="serialid" value="[% serialslis.serialid %]" />
111
				<select name="status" id="status[% serialslis.num %]">
112
					[% IF ( serialslis.status1 ) %]
113
						<option value="1" selected="selected">Expected</option>
114
					[% END %]
115
					[% IF ( serialslis.status2 ) %]
116
						<option value="2" selected="selected">Arrived</option>
117
					[% ELSE %]
118
						<option value="2">Arrived</option>
119
					[% END %]
120
					[% IF ( serialslis.status3 ) %]
121
						<option value="3" selected="selected">Late</option>
122
					[% ELSE %]
123
						<option value="3">Late</option>
124
					[% END %]
125
					[% IF ( serialslis.status4 ) %]
126
						<option value="4" selected="selected">Missing</option>
127
					[% ELSE %]
128
						<option value="4">Missing</option>
129
					[% END %]
130
                    [% IF ( serialslis.status41 ) %]
131
                      <option value="41" selected="selected">Missing (never received)</option>
132
                    [% ELSE %]
133
                      <option value="41">Missing (never received)</option>
134
                    [% END %]
135
                    [% IF ( serialslis.status42 ) %]
136
                      <option value="42" selected="selected">Missing (sold out)</option>
137
                    [% ELSE %]
138
                      <option value="42">Missing (sold out)</option>
139
                    [% END %]
140
                    [% IF ( serialslis.status43 ) %]
141
                      <option value="43" selected="selected">Missing (damaged)</option>
142
                    [% ELSE %]
143
                      <option value="43">Missing (damaged)</option>
144
                    [% END %]
145
                    [% IF ( serialslis.status44 ) %]
146
                      <option value="44" selected="selected">Missing (lost)</option>
147
                    [% ELSE %]
148
                      <option value="44">Missing (lost)</option>
149
                    [% END %]
150
					[% IF ( serialslis.status5 ) %]
151
                        <option value="5" selected="selected">Not available</option>
152
					[% ELSE %]
153
                        <option value="5">Not available</option>
154
					[% END %]
155
					[% IF ( serialslis.status6 ) %]
156
						<option value="6" selected="selected">Delete</option>
157
					[% ELSE %]
158
						<option value="6">Delete</option>
159
					[% END %]
160
                    [% IF serialslis.status8 %]
161
                        <option value="8" selected="selected">Stopped</option>
162
                    [% END %]
163
				</select>
164
			[% IF ( serialslis.serialadditems ) %]
165
				<br /><br />
166
				[% IF ( serialslis.itemstatus ) %]
167
				    [% IF ( serialslis.choice ) %]
168
						[% FOREACH itemstatusloo IN serialslis.itemstatusloop %]
169
							[% itemstatusloo.itemlib %]: 
170
							[% IF ( itemstatusloo.selected ) %]
171
							<input type="checkbox" name="itemstatus" value="[% itemstatusloo.itemval %]" checked="checked" />
172
							[% ELSE %]
173
							<input type="checkbox" name="itemstatus" value="[% itemstatusloo.itemval %]" />
174
							[% END %]
175
						[% END %]
176
				    [% ELSE %]
177
					<select name="itemstatus">
178
                        <option value="">Item status</option>
179
						[% FOREACH itemstatusloo IN serialslis.itemstatusloop %]
180
						[% IF ( itemstatusloo.selected ) %]
181
							<option value="[% itemstatusloo.itemval %]" selected="selected">[% itemstatusloo.itemlib %]</option>
182
							[% ELSE %]
183
							<option value="[% itemstatusloo.itemval %]">[% itemstatusloo.itemlib %]</option>
184
							[% END %]
185
						[% END %]
186
					</select>
187
				    [% END %]
188
				[% ELSE %]
189
				&nbsp;
190
				[% END %]
191
			[% END %]
192
193
			</td>
194
			<td>
195
				<input type="text" name="notes" value="[% serialslis.notes %]" size="20" maxlength="255" />
196
			[% IF ( serialslis.serialadditems ) %]
197
				<br /><br />
198
				[% IF ( serialslis.itemlocation ) %]
199
					<select name="location">
200
						<option value="">Location</option>
201
						[% FOREACH itemlocationloo IN serialslis.itemlocationloop %]
202
						[% IF ( itemlocationloo.selected ) %]
203
							<option value="[% itemlocationloo.value %]" selected="selected">[% itemlocationloo.itemlocationname %]</option>
204
							[% ELSE %]
205
							<option value="[% itemlocationloo.value %]">[% itemlocationloo.itemlocationname %]</option>
206
						[% END %]
207
						[% END %]
208
					</select>
209
				[% ELSE %]
210
				&nbsp;
211
				[% END %]
212
			[% END %]
213
			</td>
214
		</tr>
215
	[% END %]
216
	[% UNLESS ( hassubscriptionexpired ) %]
217
		<tr>
218
			<td>
219
				Manual issue <input type="text" name="serialseq" size="30" maxlength="100" value="[% missingseq %]" />
220
			[% IF ( serialadditems ) %]
221
				<br /><br />
222
                Call number <input type="text" name="itemcallnumber" value="" size="10" maxlength="15" />
223
				Barcode <input type="text" name="barcode" value="" size="20" maxlength="20" />
224
			[% END %]
225
			</td>
226
			<td>
227
				<input type="text" name="publisheddate" value="[% publisheddate %]" size="10" maxlength="15" />
228
			[% IF ( serialadditems ) %]
229
				<br /><br />&nbsp;
230
			[% END %]
231
			</td>
232
			<td>
233
				<input type="text" name="planneddate" size="10" maxlength="15" value="[% missingdate %]" />
234
			[% IF ( serialadditems ) %]
235
				<br /><br />
236
				<select name="branch">
237
						<option value="">Library</option>
238
			[% FOREACH branchloo IN branchloop %]
239
				[% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
240
				[% ELSE %]
241
				<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>
242
				[% END %]
243
			[% END %]
244
				</select>
245
			[% END %]
246
			</td>
247
			<td>
248
				[% IF ( frommissing ) %]
249
				<input type="hidden" name="serialid" value="[% missingid %]" />
250
				[% ELSE %]
251
				<input type="hidden" name="serialid" value="0" />
252
				[% END %]
253
				<select name="status">
254
						[% IF ( frommissing ) %]
255
						<option value="2" selected="selected">Arrived</option>
256
						[% ELSE %]
257
						<option value="2">Arrived</option>
258
				
259
						[% END %]
260
						[% IF ( frommissing ) %]
261
						<option value="3">Late</option>
262
						[% ELSE %]
263
						<option value="3" selected="selected">Late</option>
264
						[% END %]
265
						<option value="4">Missing</option>
266
                        <option value="5">Not available</option>
267
268
269
				</select>
270
			[% IF ( serialadditems ) %]
271
				<br /><br />
272
				[% IF ( itemstatus ) %]
273
				    [% IF ( choice ) %]
274
						[% FOREACH itemstatusloo IN itemstatusloop %]
275
							[% itemstatusloo.itemlib %]: 
276
							[% IF ( itemstatusloo.selected ) %]
277
							<input type="checkbox" name="itemstatus" value="[% itemstatusloo.itemval %]" checked="checked" />
278
							[% ELSE %]
279
							<input type="checkbox" name="itemstatus" value="[% itemstatusloo.itemval %]" />
280
							[% END %]
281
						[% END %]
282
				    [% ELSE %]
283
					<select name="itemstatus">
284
                        <option value="">Item status</option>
285
						[% FOREACH itemstatusloo IN itemstatusloop %]
286
						[% IF ( itemstatusloo.selected ) %]
287
							<option value="[% itemstatusloo.itemval %]" selected="selected">[% itemstatusloo.itemlib %]</option>
288
						[% ELSE %]
289
							<option value="[% itemstatusloo.itemval %]">[% itemstatusloo.itemlib %]</option>
290
[% END %]
291
						[% END %]
292
					</select>
293
				    [% END %]
294
				[% ELSE %]
295
				&nbsp;
296
				[% END %]
297
			[% END %]
298
			</td>
299
			<td>
300
				&nbsp;
301
			[% IF ( serialadditems ) %]
302
				<br /><br />
303
				[% IF ( itemlocation ) %]
304
					<select name="location">
305
						<option value="">Location</option>
306
						[% FOREACH itemlocationloo IN itemlocationloop %]
307
						[% IF ( itemlocationloo.selected ) %]
308
							<option value="[% itemlocationloo.value %]" selected="selected">[% itemlocationloo.itemlocationname %]</option>
309
						[% ELSE %]
310
							<option value="[% itemlocationloo.value %]">[% itemlocationloo.itemlocationname %]</option>
311
					[% END %]
312
						[% END %]
313
					</select>
314
				[% ELSE %]
315
				&nbsp;
316
				[% END %]
317
			[% END %]
318
			</td>
319
		</tr>
320
	[% END %]
321
	</table>
322
	<input type="submit" value="Save changes" accesskey="w" class="button" />
323
	[% IF ( hassubscriptionexpired ) %]
324
		<h3>Subscription has expired.</h3>
325
		<p><b>Expected issue status can't be changed. <a href="#" onclick="popup()" class="button">Renew</a> your subscription</b></p>
326
	[% END %]
327
	[% IF ( abouttoexpire ) %]
328
		<h3>Note: Subscription is about to expire next issue.</h3>
329
		<script type="text/javascript">
330
		<!--
331
		alert(_("Subscription is about to expire next issue"));
332
		//-->
333
		</script>
334
	[% END %]	
335
	</form>
336
337
	<h2>Subscription summary</h2>
338
	<form method="post" name="f2" action="serials-recieve.pl">
339
		<input type="hidden" name="op" value="modsubscriptionhistory" />
340
		<input type="hidden" name="serial" value="[% serial %]" />
341
		<input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
342
		<input type="hidden" name="user" value="[% user %]" />
343
		<p><label>Librarian</label>[% user %]</p>
344
		<p><label>Starting date:</label><input type="text" name="histstartdate" value="[% histstartdate %]" /> (the date of the 1st subscription)</p>
345
		<p><label>Ending date:</label><input type="text" name="enddate" value="[% enddate %]" />(if empty subscription is still active)</p>
346
		<p>Received issues</p>
347
		<p><textarea name="recievedlist" cols="60" rows="5">[% recievedlist %]</textarea></p>
348
		<p>Missing issues</p>
349
		<p><textarea name="missinglist" cols="60" rows="2">[% missinglist %]</textarea></p>
350
		<p>OPAC note</p>
351
		<p><textarea name="opacnote" cols="60" rows="5">[% opacnote %]</textarea></p>
352
		<input type="submit" value="Save changes" class="button" />
353
	</form>
354
355
356
</div>
357
</div>
358
359
<div class="yui-b">
360
[% INCLUDE 'serials-menu.inc' %]
361
</div>
362
</div>
363
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/serials/serials-recieve.pl (-278 lines)
Lines 1-278 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2000-2002 Katipo Communications
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
21
=head1 NAME
22
23
serials-recieve.pl
24
25
=head1 Parameters
26
27
=over 4
28
29
=item op
30
op can be :
31
    * modsubscriptionhistory :to modify the subscription history
32
    * serialchangestatus     :to modify the status of this subscription
33
34
=item subscriptionid
35
36
=item user
37
38
=item histstartdate
39
40
=item enddate
41
42
=item recievedlist
43
44
=item missinglist
45
46
=item opacnote
47
48
=item librariannote
49
50
=item serialid
51
52
=item serialseq
53
54
=item planneddate
55
56
=item notes
57
58
=item status
59
60
=back
61
62
=cut
63
64
65
use strict;
66
use warnings;
67
use CGI qw ( -utf8 );
68
use C4::Auth;
69
use C4::Dates qw/format_date format_date_in_iso/;
70
use C4::Biblio;
71
use C4::Items;
72
use C4::Koha;
73
use C4::Output;
74
use C4::Context;
75
use C4::Serials;
76
use C4::Branch; # GetBranches
77
78
my $query = new CGI;
79
my $op = $query->param('op') || q{};
80
my $dbh = C4::Context->dbh;
81
my $subscriptionid = $query->param('subscriptionid');
82
# my $auser = $query->param('user');
83
my $histstartdate = format_date_in_iso($query->param('histstartdate'));
84
my $enddate = format_date_in_iso($query->param('enddate'));
85
my $recievedlist = $query->param('recievedlist');
86
my $missinglist = $query->param('missinglist');
87
my $opacnote = $query->param('opacnote');
88
my $librariannote = $query->param('librariannote');
89
my @serialids = $query->param('serialid');
90
my @serialseqs = $query->param('serialseq');
91
my @planneddates = $query->param('planneddate');
92
my @publisheddates = $query->param('publisheddate');
93
my @status = $query->param('status');
94
my @notes = $query->param('notes');
95
my @barcodes = $query->param('barcode');
96
my @itemcallnumbers = $query->param('itemcallnumber');
97
my @locations = $query->param('location');
98
my @itemstatus = $query->param('itemstatus');
99
my @homebranches = $query->param('branch');
100
my $hassubscriptionexpired = HasSubscriptionExpired($subscriptionid);
101
my $abouttoexpire = abouttoexpire($subscriptionid);
102
103
my $subscription=GetSubscription($subscriptionid);
104
105
106
my $auser = $subscription->{'librarian'}; # bob
107
my $routing = check_routing($subscriptionid); # to see if routing list exists
108
my $manualdate ='';
109
my $manualissue ='';
110
my $manualstatus =0;
111
my $manualid ='';
112
if ($op eq 'found'){
113
    $manualdate = $query->param('planneddate');
114
    $manualissue = $query->param('missingissue');
115
    $manualstatus = 1;
116
    my $sth = $dbh->prepare("select serialid from serial where subscriptionid = ? AND serialseq = ? AND planneddate = ?");
117
    $sth->execute($subscriptionid,$manualissue,format_date_in_iso($manualdate));
118
    $manualid = $sth->fetchrow;
119
}
120
if ($op eq 'modsubscriptionhistory') {
121
    ModSubscriptionHistory($subscriptionid,$histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote);
122
}
123
124
# change status except, if subscription has expired, for the "waited" issue.
125
if ($op eq 'serialchangestatus') {
126
    my $sth = $dbh->prepare("select status from serial where serialid=?");
127
    for (my $i=0;$i<=$#serialids;$i++) {
128
        $sth->execute($serialids[$i]);
129
130
        my ($oldstatus) = $sth->fetchrow;
131
        if ($serialids[$i]) {
132
            ModSerialStatus($serialids[$i],$serialseqs[$i],format_date_in_iso($planneddates[$i]),format_date_in_iso($publisheddates[$i]),$status[$i],$notes[$i]) unless ($hassubscriptionexpired && $oldstatus == 1);
133
            if (($status[$i]==2) && C4::Context->preference("serialsadditems")){
134
                my %info;
135
                $info{branch}=$homebranches[$i];
136
                $info{barcode}=$barcodes[$i];
137
                $info{itemcallnumber}=$itemcallnumbers[$i];
138
                $info{location}=$locations[$i];
139
                $info{status}=$itemstatus[$i];
140
                $info{notes}=$serialseqs[$i]." (".$planneddates[$i].")";
141
                my ($status2, @errors)= ItemizeSerials($serialids[$i],\%info);
142
                my $sth2 = $dbh->prepare("UPDATE subscriptionhistory SET lastbranch = ? WHERE subscriptionid = ?");
143
                $sth2->execute($homebranches[$i],$subscriptionid);
144
                $sth2->finish;
145
                # remove from missing list if item being checked in is on it
146
                if ($status2 ==1){
147
                removeMissingIssue($serialseqs[$i],$subscriptionid);
148
                }
149
            }
150
        } else {
151
            # add a special issue
152
            if ($serialseqs[$i]) {
153
                NewIssue($serialseqs[$i],$subscriptionid,$subscription->{biblionumber},$status[$i] ,format_date_in_iso($publisheddates[$i]),format_date_in_iso($planneddates[$i]));
154
            }
155
            if (($status[$i]==2) && C4::Context->preference("serialsadditems") && !hassubscriptionexpired($subscriptionid)){
156
                my %info;
157
                $info{branch}=$homebranches[$i];
158
                $info{barcode}=$barcodes[$i];
159
                $info{itemcallnumber}=$itemcallnumbers[$i];
160
                $info{location}=$locations[$i];
161
                $info{status}=$itemstatus[$i];
162
                $info{notes}=$serialseqs[$i]." (".$planneddates[$i].")";
163
                my ($status2, @errors)= ItemizeSerials($serialids[$i],\%info);
164
                my $sth2 = $dbh->prepare("UPDATE subscriptionhistory SET lastbranch = ? WHERE subscriptionid = ?");
165
                $sth2->execute($homebranches[$i],$subscriptionid);
166
                $sth2->finish;
167
                # remove from missing list if item being checked in is on it
168
                if ($status2 ==1){
169
                 removeMissingIssue($serialseqs[$i],$subscriptionid);
170
                }
171
            }
172
173
        }
174
    }
175
}
176
my ($template, $loggedinuser, $cookie)
177
= get_template_and_user({template_name => "serials/serials-recieve.tt",
178
                query => $query,
179
                type => "intranet",
180
                authnotrequired => 0,
181
                flagsrequired => {serials => 1},
182
                debug => 1,
183
                });
184
185
my $subs = &GetSubscription($subscriptionid);
186
my ($totalissues,@serialslist) = GetSerials($subscriptionid);
187
my $count = @serialslist;
188
for(my $i=0;$i<$count;$i++){
189
    #warn "la : $i";
190
    $serialslist[$i]->{'callnumber'} = $subscription->{'callnumber'};
191
    my $temp = rand(10000000);
192
    $serialslist[$i]->{'barcode'} = "TEMP" . sprintf("%.0f",$temp);
193
}
194
195
my $solhistory = GetSubscriptionHistoryFromSubscriptionId($subscriptionid);
196
197
$subs = &GetSubscription($subscriptionid);
198
($totalissues,@serialslist) = GetSerials($subscriptionid);
199
200
if (C4::Context->preference("serialsadditems")){
201
    my $fwk=GetFrameworkCode($subscription->{biblionumber});
202
203
    my $branches = GetBranches;
204
    my @branchloop;
205
    foreach my $thisbranch (keys %$branches) {
206
        my $selected = 0;
207
        if($thisbranch eq $solhistory->{'lastbranch'}){
208
        $selected = 1;
209
        }
210
        my %row =(value => $thisbranch,
211
            branchname => $branches->{$thisbranch}->{'branchname'},
212
                selected => $selected,
213
                );
214
        push @branchloop, \%row;
215
    }
216
    my $itemstatushash = GetItemStatus($fwk);
217
    my @itemstatusloop;
218
	my $itemstatusloopcount=0;
219
    foreach my $thisitemstatus (keys %$itemstatushash) {
220
        my %row =(itemval => $thisitemstatus,
221
                    itemlib => $itemstatushash->{$thisitemstatus},
222
                );
223
#		warn "".$row{'itemval'}.", ". $row{"itemlib"};
224
		$itemstatusloopcount++;
225
        push @itemstatusloop, \%row;
226
    }
227
    my $itemlocationhash = GetItemLocation($fwk);
228
    my @itemlocationloop;
229
    foreach my $thisitemlocation (keys %$itemlocationhash) {
230
        my %row =(value => $thisitemlocation,
231
                    itemlocationname => $itemlocationhash->{$thisitemlocation},
232
                );
233
        push @itemlocationloop, \%row;
234
    }
235
236
	my $choice = ($itemstatusloopcount == 1) ? 1 : 0;
237
	foreach my $data (@serialslist){
238
		$data->{"itemstatusloop"}   = (scalar(@itemstatusloop  )) ? \@itemstatusloop   : [];
239
		$data->{"itemlocationloop"} = (scalar(@itemlocationloop)) ? \@itemlocationloop : [];
240
		$data->{"branchloop"} = \@branchloop ;
241
	}
242
# warn "Choice: $choice";
243
    $template->param(choice => $choice);
244
    $template->param(serialadditems =>C4::Context->preference("serialsadditems"),
245
                    branchloop => \@branchloop,
246
                    ) ;
247
	$template->param(  itemstatus=>1,  itemstatusloop=>\@itemstatusloop  ) if (scalar(@itemstatusloop  ));
248
	$template->param(itemlocation=>1,itemlocationloop=>\@itemlocationloop) if (scalar(@itemlocationloop));
249
} else {
250
    $template->param(branchloop=>[],itemstatusloop=>[],itemlocationloop=>[]) ;
251
}
252
253
$solhistory = GetSubscriptionHistoryFromSubscriptionId($subscriptionid);
254
255
$template->param(
256
            user => $auser,
257
            serialslist => \@serialslist,
258
            count => $count,
259
            biblionumber => $subscription->{biblionumber},
260
            histstartdate => format_date($solhistory->{'histstartdate'}),
261
            enddate => format_date($solhistory->{'enddate'}),
262
            recievedlist => $solhistory->{'recievedlist'},
263
            missinglist => $solhistory->{'missinglist'},
264
            opacnote => $solhistory->{'opacnote'},
265
            librariannote => $solhistory->{'librariannote'},
266
            subscriptionid => $subscriptionid,
267
            bibliotitle => $subs->{bibliotitle},
268
            biblionumber => $subs->{biblionumber},
269
            hassubscriptionexpired =>$hassubscriptionexpired,
270
            abouttoexpire =>$abouttoexpire,
271
            routing => $routing,
272
            missingseq => $manualissue,
273
            frommissing => $manualstatus,
274
            missingdate => $manualdate,
275
            missingid => $manualid,
276
            (uc(C4::Context->preference("marcflavour"))) => 1
277
        );
278
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/t/db_dependent/Serials.t (-3 lines)
Lines 182-189 is(C4::Serials::HasSubscriptionExpired(), undef, 'test if the subscriptions has Link Here
182
182
183
is(C4::Serials::GetLateOrMissingIssues(), undef, 'test getting last or missing issues');
183
is(C4::Serials::GetLateOrMissingIssues(), undef, 'test getting last or missing issues');
184
184
185
is(C4::Serials::removeMissingIssue(), undef, 'test removing a missing issue');
186
187
is(C4::Serials::updateClaim(),undef, 'test updating claim');
185
is(C4::Serials::updateClaim(),undef, 'test updating claim');
188
186
189
is(C4::Serials::getsupplierbyserialid(),undef, 'test getting supplier idea');
187
is(C4::Serials::getsupplierbyserialid(),undef, 'test getting supplier idea');
190
- 

Return to bug 13423