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

(-)a/C4/Serials.pm (-7 / +13 lines)
Lines 89-102 the array is in name order Link Here
89
sub GetSuppliersWithLateIssues {
89
sub GetSuppliersWithLateIssues {
90
    my $dbh   = C4::Context->dbh;
90
    my $dbh   = C4::Context->dbh;
91
    my $query = qq|
91
    my $query = qq|
92
        SELECT DISTINCT id, name
92
    SELECT DISTINCT id, name
93
    FROM            subscription
93
    FROM            subscription
94
    LEFT JOIN       serial ON serial.subscriptionid=subscription.subscriptionid
94
    LEFT JOIN       serial ON serial.subscriptionid=subscription.subscriptionid
95
    LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
95
    LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
96
    WHERE id > 0
96
    WHERE id > 0
97
        AND (
97
        AND (
98
            (planneddate < now() AND serial.status=1)
98
            (planneddate < now() AND serial.status=1)
99
            OR serial.STATUS = 3 OR serial.STATUS = 4
99
            OR serial.STATUS = 3 OR serial.STATUS = 4 OR serial.STATUS = 7
100
        )
100
        )
101
        AND subscription.closed = 0
101
        AND subscription.closed = 0
102
    ORDER BY name|;
102
    ORDER BY name|;
Lines 294-301 sub UpdateClaimdateIssues { Link Here
294
    my $dbh = C4::Context->dbh;
294
    my $dbh = C4::Context->dbh;
295
    $date = strftime( "%Y-%m-%d", localtime ) unless ($date);
295
    $date = strftime( "%Y-%m-%d", localtime ) unless ($date);
296
    my $query = "
296
    my $query = "
297
        UPDATE serial SET claimdate = ?, status = 7
297
        UPDATE serial
298
        WHERE  serialid in (" . join( ",", map { '?' } @$serialids ) . ")";
298
        SET claimdate = ?,
299
            status = 7,
300
            claims_count = claims_count + 1
301
        WHERE  serialid in (" . join( ",", map { '?' } @$serialids ) . ")
302
    ";
299
    my $rq = $dbh->prepare($query);
303
    my $rq = $dbh->prepare($query);
300
    $rq->execute($date, @$serialids);
304
    $rq->execute($date, @$serialids);
301
    return $rq->rows;
305
    return $rq->rows;
Lines 1859-1865 sub GetLateOrMissingIssues { Link Here
1859
            "SELECT
1863
            "SELECT
1860
                serialid,      aqbooksellerid,        name,
1864
                serialid,      aqbooksellerid,        name,
1861
                biblio.title,  planneddate,           serialseq,
1865
                biblio.title,  planneddate,           serialseq,
1862
                serial.status, serial.subscriptionid, claimdate,
1866
                serial.status, serial.subscriptionid, claimdate, claims_count,
1863
                subscription.branchcode
1867
                subscription.branchcode
1864
            FROM      serial 
1868
            FROM      serial 
1865
                LEFT JOIN subscription  ON serial.subscriptionid=subscription.subscriptionid 
1869
                LEFT JOIN subscription  ON serial.subscriptionid=subscription.subscriptionid 
Lines 1876-1882 sub GetLateOrMissingIssues { Link Here
1876
            "SELECT 
1880
            "SELECT 
1877
            serialid,      aqbooksellerid,         name,
1881
            serialid,      aqbooksellerid,         name,
1878
            biblio.title,  planneddate,           serialseq,
1882
            biblio.title,  planneddate,           serialseq,
1879
                serial.status, serial.subscriptionid, claimdate,
1883
                serial.status, serial.subscriptionid, claimdate, claims_count,
1880
                subscription.branchcode
1884
                subscription.branchcode
1881
            FROM serial 
1885
            FROM serial 
1882
                LEFT JOIN subscription ON serial.subscriptionid=subscription.subscriptionid 
1886
                LEFT JOIN subscription ON serial.subscriptionid=subscription.subscriptionid 
Lines 1956-1962 sub updateClaim { Link Here
1956
    my ($serialid) = @_;
1960
    my ($serialid) = @_;
1957
    my $dbh        = C4::Context->dbh;
1961
    my $dbh        = C4::Context->dbh;
1958
    my $sth        = $dbh->prepare(
1962
    my $sth        = $dbh->prepare(
1959
        "UPDATE serial SET claimdate = now()
1963
        "UPDATE serial
1964
         SET claimdate = now(),
1965
             claims_count = claims_count + 1
1960
                WHERE serialid = ?
1966
                WHERE serialid = ?
1961
        "
1967
        "
1962
    );
1968
    );
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 1801-1806 CREATE TABLE `serial` ( Link Here
1801
  `publisheddate` date default NULL,
1801
  `publisheddate` date default NULL,
1802
  `itemnumber` text default NULL,
1802
  `itemnumber` text default NULL,
1803
  `claimdate` date default NULL,
1803
  `claimdate` date default NULL,
1804
  claims_count int(11) default 0,
1804
  `routingnotes` text,
1805
  `routingnotes` text,
1805
  PRIMARY KEY  (`serialid`)
1806
  PRIMARY KEY  (`serialid`)
1806
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1807
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
(-)a/installer/data/mysql/updatedatabase.pl (+9 lines)
Lines 6339-6344 if ( CheckVersion($DBversion) ) { Link Here
6339
   SetVersion ($DBversion);
6339
   SetVersion ($DBversion);
6340
}
6340
}
6341
6341
6342
6343
6344
$DBversion = "3.11.00.XXX";
6345
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6346
    $dbh->do("ALTER TABLE serial ADD COLUMN claims_count INT(11) DEFAULT 0 after claimdate");
6347
    print "Upgrade to $DBversion done (Add claims_count field in serial table)\n";
6348
    SetVersion($DBversion);
6349
}
6350
6342
=head1 FUNCTIONS
6351
=head1 FUNCTIONS
6343
6352
6344
=head2 TableExists($table)
6353
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt (-45 / +51 lines)
Lines 164-169 Link Here
164
164
165
    <h1>Claims</h1>
165
    <h1>Claims</h1>
166
166
167
    [% IF error_claim %]
168
        [% IF ( error_claim == "no_email" ) %]
169
            <div class="error">This vendor has no email</div>
170
        [% ELSE %]
171
            <div class="error">[% error_claim %]</div>
172
        [% END %]
173
    [% END %]
174
    [% IF info_claim %]
175
        <div class="dialog message">Email has been sent.</div>
176
    [% END %]
177
167
[% 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 %]
178
[% 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 %]
168
	
179
	
169
	     [% IF ( SHOWCONFIRMATION ) %]
180
	     [% IF ( SHOWCONFIRMATION ) %]
Lines 215-220 Link Here
215
	<li>
226
	<li>
216
	    <label for="titlefilter">Title : </label>
227
	    <label for="titlefilter">Title : </label>
217
	    <input id="titlefilter" type="text" />
228
	    <input id="titlefilter" type="text" />
229
    </li>
230
    <li>
218
	    <label for="branchfilter">Library: </label>
231
	    <label for="branchfilter">Library: </label>
219
	    <select id="branchfilter" onchange="filterByBranch();">
232
	    <select id="branchfilter" onchange="filterByBranch();">
220
            [% FOREACH branchloo IN branchloop %]
233
            [% FOREACH branchloo IN branchloop %]
Lines 244-284 Link Here
244
    </form>
257
    </form>
245
258
246
    <fieldset>
259
    <fieldset>
247
	<form action="claims.pl" method="post" class="checkboxed" onsubmit="return checkForm()">
260
        <form action="claims.pl" method="post" class="checkboxed" onsubmit="return checkForm()">
248
        <input type="hidden" name="order" value="[% order %]" />
261
            <table id="claimst">
249
         <table id="claimst">
262
                <thead>
250
                <thead><tr>
263
                    <tr>
251
                    [% IF ( letter ) %]
264
                        [% IF ( letter ) %]
252
                    <th><input type="checkbox" id="CheckAll"></th>
265
                            <th><input type="checkbox" id="CheckAll"></th>
253
                    [% END %]
266
                        [% END %]
254
                    <th>Vendor</th>
267
                        <th>Vendor</th>
255
                    <th>Library</th>
268
                        <th>Library</th>
256
                    <th>Title</th>
269
                        <th>Title</th>
257
                    <th>Issue number</th>
270
                        <th>Issue number</th>
258
                    <th>Status</th>
271
                        <th>Status</th>
259
                    <th>Since</th>
272
                        <th>Since</th>
260
                    <th>Claim date</th>
273
                        <th>Claims count</th>
261
                <th>Begin claim</th>
274
                        <th>Claim date</th>
262
                </tr></thead>
275
                    </tr>
276
                </thead>
263
                <tbody>[% FOREACH missingissue IN missingissues %]
277
                <tbody>[% FOREACH missingissue IN missingissues %]
264
                    <tr>
278
                    <tr>
265
                        [% IF ( letter ) %]
279
                        [% IF ( letter ) %]
266
                            <td>
280
                            <td>
267
                    <input type="checkbox" name="serialid" value="[% missingissue.serialid %]" />
281
                                <input type="checkbox" name="serialid" value="[% missingissue.serialid %]" />
268
                            </td>
282
                            </td>
269
                        [% END %]
283
                        [% END %]
270
                        <td>
284
                        <td>[% missingissue.name %]</td>
271
                        [% missingissue.name %]
285
                        <td>[% missingissue.branchcode %]</td>
272
                        </td>
273
                        <td>
274
                        [% missingissue.branchcode %]
275
                        </td>
276
                        <td>
286
                        <td>
277
                        <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% missingissue.subscriptionid %]">[% missingissue.title |html %]</a>
287
                        <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% missingissue.subscriptionid %]">[% missingissue.title |html %]</a>
278
                        </td>
288
                        </td>
279
                        <td>
289
                        <td>[% missingissue.serialseq %]</td>
280
                        [% missingissue.serialseq %]
281
                        </td>
282
                        <td>
290
                        <td>
283
                            [% IF ( missingissue.status1 ) %]Expected[% END %]
291
                            [% IF ( missingissue.status1 ) %]Expected[% END %]
284
                            [% IF ( missingissue.status2 ) %]Arrived[% END %]
292
                            [% IF ( missingissue.status2 ) %]Arrived[% END %]
Lines 287-314 Link Here
287
                            [% IF ( missingissue.status7 ) %]Claimed[% END %]
295
                            [% IF ( missingissue.status7 ) %]Claimed[% END %]
288
                            [% IF ( missingissue.status8 ) %]Stopped[% END %]
296
                            [% IF ( missingissue.status8 ) %]Stopped[% END %]
289
                        </td>
297
                        </td>
290
                        <td class="planneddate">
298
                        <td class="planneddate">[% missingissue.planneddate %]</td>
291
                        [% missingissue.planneddate %]
299
                        <td>[% missingissue.claims_count %]</td>
292
                        </td>
300
                        <td>[% missingissue.claimdate %]</td>
293
                        <td>
294
                        [% missingissue.claimdate %]
295
                        </td>
296
                        <td>
297
                            <a href="/cgi-bin/koha/serials/lateissues-excel.pl?supplierid=[% missingissue.supplieri %]&amp;serialid=[% missingissue.serialid %]&amp;op=claims">Export item data</a>
298
                        </td>
299
                    </tr>
301
                    </tr>
300
                [% END %]</tbody>
302
                [% END %]</tbody>
301
            </table>
303
            </table>
302
	     <p><span class="exportSelected"></span></p>
304
            <p><span class="exportSelected"></span></p>
303
305
304
[% IF ( letter ) %]
306
            [% IF ( letter ) %]
305
        <fieldset class="action"> <label for="letter_code">Select notice:</label>
307
                <fieldset class="action">
306
            <select name="letter_code" id="letter_code">
308
                    <label for="letter_code">Select notice:</label>
307
                [% FOREACH letter IN letters %]
309
                    <select name="letter_code" id="letter_code">
308
                    <option value="[% letter.code %]">[% letter.name %]</option>
310
                        [% FOREACH letter IN letters %]
309
                [% END %]
311
                            <option value="[% letter.code %]">[% letter.name %]</option>
310
			</select>
312
                        [% END %]
311
	    <input type="hidden" name="op" value="send_alert" /><input type="submit" name="submit" class="button" value="Send notification" /></fieldset>
313
                    </select>
314
                    <input type="hidden" name="op" value="send_alert" />
315
                    <input type="hidden" name="supplierid" value="[% supplierid %]" />
316
                    <input type="submit" name="submit" class="button" value="Send notification" />
317
                </fieldset>
312
            [% END %]
318
            [% END %]
313
        </form>
319
        </form>
314
    </fieldset>
320
    </fieldset>
(-)a/serials/claims.pl (-19 / +28 lines)
Lines 36-42 my $op = $input->param('op'); Link Here
36
my $claimletter = $input->param('claimletter');
36
my $claimletter = $input->param('claimletter');
37
my $supplierid = $input->param('supplierid');
37
my $supplierid = $input->param('supplierid');
38
my $suppliername = $input->param('suppliername');
38
my $suppliername = $input->param('suppliername');
39
my $order = $input->param('order');
40
39
41
# open template first (security & userenv set here)
40
# open template first (security & userenv set here)
42
my ($template, $loggedinuser, $cookie)
41
my ($template, $loggedinuser, $cookie)
Lines 51-62 my ($template, $loggedinuser, $cookie) Link Here
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} ) {
52
for my $s (@{$supplierlist} ) {
54
    $s->{count} = scalar  GetLateOrMissingIssues($s->{id}, q{}, $order);
53
    $s->{count} = scalar  GetLateOrMissingIssues($s->{id}, q{});
55
    if ($supplierid && $s->{id} == $supplierid) {
54
    if ($supplierid && $s->{id} == $supplierid) {
56
        $s->{selected} = 1;
55
        $s->{selected} = 1;
57
    }
56
    }
58
}
57
}
59
58
59
my $branchloop = GetBranchesLoop();
60
unshift @$branchloop, {value=> 'all',name=>''};
61
62
my $preview=0;
63
if($op && $op eq 'preview'){
64
    $preview = 1;
65
} else {
66
    my @serialnums=$input->param('serialid');
67
    if (@serialnums) { # i.e. they have been flagged to generate claims
68
        my $err;
69
        eval {
70
            $err = SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
71
            if ( not ref $err or not exists $err->{error} ) {
72
               UpdateClaimdateIssues(\@serialnums);
73
            }
74
        };
75
        if ( $@ ) {
76
            $template->param(error_claim => $@);
77
        } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) {
78
            $template->{VARS}->{'error_claim'} = "no_email";
79
        } else {
80
            $template->{VARS}->{'info_claim'} = 1;
81
        }
82
    }
83
}
84
60
my $letters = GetLetters('claimissues');
85
my $letters = GetLetters('claimissues');
61
my @letters;
86
my @letters;
62
foreach (keys %{$letters}){
87
foreach (keys %{$letters}){
Lines 67-93 my $letter=((scalar(@letters)>1) || ($letters[0]->{name}||$letters[0]->{code})); Link Here
67
my  @missingissues;
92
my  @missingissues;
68
my @supplierinfo;
93
my @supplierinfo;
69
if ($supplierid) {
94
if ($supplierid) {
70
    @missingissues = GetLateOrMissingIssues($supplierid,$serialid,$order);
95
    @missingissues = GetLateOrMissingIssues($supplierid);
71
    @supplierinfo=GetBookSeller($supplierid);
96
    @supplierinfo=GetBookSeller($supplierid);
72
}
97
}
73
98
74
my $branchloop = GetBranchesLoop();
75
unshift @$branchloop, {value=> 'all',name=>''};
76
77
my $preview=0;
78
if($op && $op eq 'preview'){
79
    $preview = 1;
80
} else {
81
    my @serialnums=$input->param('serialid');
82
    if (@serialnums) { # i.e. they have been flagged to generate claims
83
        SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
84
        my $cntupdate=UpdateClaimdateIssues(\@serialnums);
85
        ### $cntupdate SHOULD be equal to scalar(@$serialnums)
86
    }
87
}
88
$template->param('letters'=>\@letters,'letter'=>$letter);
99
$template->param('letters'=>\@letters,'letter'=>$letter);
89
$template->param(
100
$template->param(
90
        order =>$order,
91
        suploop => $supplierlist,
101
        suploop => $supplierlist,
92
        phone => $supplierinfo[0]->{phone},
102
        phone => $supplierinfo[0]->{phone},
93
        booksellerfax => $supplierinfo[0]->{booksellerfax},
103
        booksellerfax => $supplierinfo[0]->{booksellerfax},
94
- 

Return to bug 5342