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

(-)a/C4/Serials.pm (-9 / +17 lines)
Lines 88-97 sub GetSuppliersWithLateIssues { Link Here
88
    my $dbh   = C4::Context->dbh;
88
    my $dbh   = C4::Context->dbh;
89
    my $query = qq|
89
    my $query = qq|
90
        SELECT DISTINCT id, name
90
        SELECT DISTINCT id, name
91
    FROM            subscription
91
        FROM            subscription
92
    LEFT JOIN       serial ON serial.subscriptionid=subscription.subscriptionid
92
        LEFT JOIN       serial ON serial.subscriptionid=subscription.subscriptionid
93
    LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
93
        LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
94
    WHERE id > 0 AND ((planneddate < now() AND serial.status=1) OR serial.STATUS = 3 OR serial.STATUS = 4) ORDER BY name|;
94
        WHERE id > 0 AND ((planneddate < now() AND serial.status=1) OR serial.STATUS = 3 OR serial.STATUS = 4 OR serial.STATUS = 7)
95
        ORDER BY name
96
    |;
95
    return $dbh->selectall_arrayref($query, { Slice => {} });
97
    return $dbh->selectall_arrayref($query, { Slice => {} });
96
}
98
}
97
99
Lines 284-291 sub UpdateClaimdateIssues { Link Here
284
    my $dbh = C4::Context->dbh;
286
    my $dbh = C4::Context->dbh;
285
    $date = strftime( "%Y-%m-%d", localtime ) unless ($date);
287
    $date = strftime( "%Y-%m-%d", localtime ) unless ($date);
286
    my $query = "
288
    my $query = "
287
        UPDATE serial SET claimdate = ?, status = 7
289
        UPDATE serial
288
        WHERE  serialid in (" . join( ",", map { '?' } @$serialids ) . ")";
290
        SET claimdate = ?,
291
            status = 7,
292
            claims_count = claims_count + 1
293
        WHERE  serialid in (" . join( ",", map { '?' } @$serialids ) . ")
294
    ";
289
    my $rq = $dbh->prepare($query);
295
    my $rq = $dbh->prepare($query);
290
    $rq->execute($date, @$serialids);
296
    $rq->execute($date, @$serialids);
291
    return $rq->rows;
297
    return $rq->rows;
Lines 1756-1762 sub GetLateOrMissingIssues { Link Here
1756
            "SELECT
1762
            "SELECT
1757
                serialid,      aqbooksellerid,        name,
1763
                serialid,      aqbooksellerid,        name,
1758
                biblio.title,  planneddate,           serialseq,
1764
                biblio.title,  planneddate,           serialseq,
1759
                serial.status, serial.subscriptionid, claimdate,
1765
                serial.status, serial.subscriptionid, claimdate, claims_count,
1760
                subscription.branchcode
1766
                subscription.branchcode
1761
            FROM      serial 
1767
            FROM      serial 
1762
                LEFT JOIN subscription  ON serial.subscriptionid=subscription.subscriptionid 
1768
                LEFT JOIN subscription  ON serial.subscriptionid=subscription.subscriptionid 
Lines 1773-1779 sub GetLateOrMissingIssues { Link Here
1773
            "SELECT 
1779
            "SELECT 
1774
            serialid,      aqbooksellerid,         name,
1780
            serialid,      aqbooksellerid,         name,
1775
            biblio.title,  planneddate,           serialseq,
1781
            biblio.title,  planneddate,           serialseq,
1776
                serial.status, serial.subscriptionid, claimdate,
1782
                serial.status, serial.subscriptionid, claimdate, claims_count,
1777
                subscription.branchcode
1783
                subscription.branchcode
1778
            FROM serial 
1784
            FROM serial 
1779
                LEFT JOIN subscription ON serial.subscriptionid=subscription.subscriptionid 
1785
                LEFT JOIN subscription ON serial.subscriptionid=subscription.subscriptionid 
Lines 1853-1859 sub updateClaim { Link Here
1853
    my ($serialid) = @_;
1859
    my ($serialid) = @_;
1854
    my $dbh        = C4::Context->dbh;
1860
    my $dbh        = C4::Context->dbh;
1855
    my $sth        = $dbh->prepare(
1861
    my $sth        = $dbh->prepare(
1856
        "UPDATE serial SET claimdate = now()
1862
        "UPDATE serial
1863
         SET claimdate = now(),
1864
             claims_count = claims_count + 1
1857
                WHERE serialid = ?
1865
                WHERE serialid = ?
1858
        "
1866
        "
1859
    );
1867
    );
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 1758-1763 CREATE TABLE `serial` ( Link Here
1758
  `publisheddate` date default NULL,
1758
  `publisheddate` date default NULL,
1759
  `itemnumber` text default NULL,
1759
  `itemnumber` text default NULL,
1760
  `claimdate` date default NULL,
1760
  `claimdate` date default NULL,
1761
  claims_count int(11) default 0,
1761
  `routingnotes` text,
1762
  `routingnotes` text,
1762
  PRIMARY KEY  (`serialid`)
1763
  PRIMARY KEY  (`serialid`)
1763
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1764
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
(-)a/installer/data/mysql/updatedatabase.pl (+10 lines)
Lines 5095-5100 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5095
    SetVersion($DBversion);
5095
    SetVersion($DBversion);
5096
}
5096
}
5097
5097
5098
5099
5100
5101
$DBversion = "3.07.00.XXX";
5102
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5103
    $dbh->do("ALTER TABLE serial ADD COLUMN claims_count INT(11) DEFAULT 0");
5104
    print "Upgrade to $DBversion done (Add claims_count field in serial table)\n";
5105
    SetVersion($DBversion);
5106
}
5107
5098
=head1 FUNCTIONS
5108
=head1 FUNCTIONS
5099
5109
5100
=head2 DropAllForeignKeys($table)
5110
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt (-45 / +49 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 263-303 Link Here
263
    </form>
274
    </form>
264
275
265
    <fieldset>
276
    <fieldset>
266
	<form action="claims.pl" method="post" class="checkboxed" onsubmit="return checkForm()">
277
        <form action="claims.pl" method="post" class="checkboxed" onsubmit="return checkForm()">
267
        <input type="hidden" name="order" value="[% order %]" />
278
            <input type="hidden" name="order" value="[% order %]" />
268
         <table id="claimst">
279
            <table id="claimst">
269
                <thead><tr>
280
                <thead>
270
                    [% IF ( letter ) %]
281
                    <tr>
271
                    <th><input type="checkbox" id="CheckAll"></th>
282
                        [% IF ( letter ) %]
272
                    [% END %]
283
                            <th><input type="checkbox" id="CheckAll"></th>
273
                    <th>Vendor</th>
284
                        [% END %]
274
                    <th>Library</th>
285
                        <th>Vendor</th>
275
                    <th>Title</th>
286
                        <th>Library</th>
276
                    <th>Issue number</th>
287
                        <th>Title</th>
277
                    <th>Status</th>
288
                        <th>Issue number</th>
278
                    <th>Since</th>
289
                        <th>Status</th>
279
                    <th>Claim Date</th>
290
                        <th>Since</th>
280
                <th>Begin Claim</th>
291
                        <th>Claims count</th>
281
                </tr></thead>
292
                        <th>Claim date</th>
293
                    </tr>
294
                </thead>
282
                <tbody>[% FOREACH missingissue IN missingissues %]
295
                <tbody>[% FOREACH missingissue IN missingissues %]
283
                    <tr>
296
                    <tr>
284
                        [% IF ( letter ) %]
297
                        [% IF ( letter ) %]
285
                            <td>
298
                            <td>
286
                    <input type="checkbox" name="serialid" value="[% missingissue.serialid %]" />
299
                                <input type="checkbox" name="serialid" value="[% missingissue.serialid %]" />
287
                            </td>
300
                            </td>
288
                        [% END %]
301
                        [% END %]
289
                        <td>
302
                        <td>[% missingissue.name %]</td>
290
                        [% missingissue.name %]
303
                        <td>[% missingissue.branchcode %]</td>
291
                        </td>
292
                        <td>
293
                        [% missingissue.branchcode %]
294
                        </td>
295
                        <td>
304
                        <td>
296
                        <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% missingissue.subscriptionid %]">[% missingissue.title |html %]</a>
305
                        <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% missingissue.subscriptionid %]">[% missingissue.title |html %]</a>
297
                        </td>
306
                        </td>
298
                        <td>
307
                        <td>[% missingissue.serialseq %]</td>
299
                        [% missingissue.serialseq %]
300
                        </td>
301
                        <td>
308
                        <td>
302
                            [% IF ( missingissue.status1 ) %]Expected[% END %]
309
                            [% IF ( missingissue.status1 ) %]Expected[% END %]
303
                            [% IF ( missingissue.status2 ) %]Arrived[% END %]
310
                            [% IF ( missingissue.status2 ) %]Arrived[% END %]
Lines 305-332 Link Here
305
                            [% IF ( missingissue.status4 ) %]Missing[% END %]
312
                            [% IF ( missingissue.status4 ) %]Missing[% END %]
306
                            [% IF ( missingissue.status7 ) %]Claimed[% END %]
313
                            [% IF ( missingissue.status7 ) %]Claimed[% END %]
307
                        </td>
314
                        </td>
308
                        <td class="planneddate">
315
                        <td class="planneddate">[% missingissue.planneddate %]</td>
309
                        [% missingissue.planneddate %]
316
                        <td>[% missingissue.claims_count %]</td>
310
                        </td>
317
                        <td>[% missingissue.claimdate %]</td>
311
                        <td>
312
                        [% missingissue.claimdate %]
313
                        </td>
314
                        <td>
315
                            <a href="/cgi-bin/koha/serials/lateissues-excel.pl?supplierid=[% missingissue.supplieri %]&amp;serialid=[% missingissue.serialid %]&amp;op=claims">Export item data</a>
316
                        </td>
317
                    </tr>
318
                    </tr>
318
                [% END %]</tbody>
319
                [% END %]</tbody>
319
            </table>
320
            </table>
320
	     <p><span class="exportSelected"></span></p>
321
            <p><span class="exportSelected"></span></p>
321
322
322
[% IF ( letter ) %]
323
            [% IF ( letter ) %]
323
        <fieldset class="action"> <label for="letter_code">Select notice:</label>
324
                <fieldset class="action">
324
            <select name="letter_code" id="letter_code">
325
                    <label for="letter_code">Select notice:</label>
325
                [% FOREACH letter IN letters %]
326
                    <select name="letter_code" id="letter_code">
326
                    <option value="[% letter.code %]">[% letter.name %]</option>
327
                        [% FOREACH letter IN letters %]
327
                [% END %]
328
                            <option value="[% letter.code %]">[% letter.name %]</option>
328
			</select>
329
                        [% END %]
329
	    <input type="hidden" name="op" value="send_alert" /><input type="submit" name="submit" class="button" value="Send notification" /></fieldset>
330
                    </select>
331
                    <input type="hidden" name="op" value="send_alert" />
332
                    <input type="submit" name="submit" class="button" value="Send notification" />
333
                </fieldset>
330
            [% END %]
334
            [% END %]
331
        </form>
335
        </form>
332
    </fieldset>
336
    </fieldset>
(-)a/serials/claims.pl (-4 / +12 lines)
Lines 80-88 if($op && $op eq 'preview'){ Link Here
80
} else {
80
} else {
81
    my @serialnums=$input->param('serialid');
81
    my @serialnums=$input->param('serialid');
82
    if (@serialnums) { # i.e. they have been flagged to generate claims
82
    if (@serialnums) { # i.e. they have been flagged to generate claims
83
        SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
83
        my $err;
84
        my $cntupdate=UpdateClaimdateIssues(\@serialnums);
84
        eval {
85
        ### $cntupdate SHOULD be equal to scalar(@$serialnums)
85
            SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
86
            UpdateClaimdateIssues(\@serialnums);
87
        };
88
        if ( $@ ) {
89
            $template->param(error_claim => $@);
90
        } elsif ( defined $err->{error} and $err->{error} eq "no_email" ) {
91
            $template->{VARS}->{'error_claim'} = "no_email";
92
        } else {
93
            $template->{VARS}->{'info_claim'} = 1;
94
        }
86
    }
95
    }
87
}
96
}
88
$template->param('letters'=>\@letters,'letter'=>$letter);
97
$template->param('letters'=>\@letters,'letter'=>$letter);
89
- 

Return to bug 5342