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 1755-1761 sub GetLateOrMissingIssues { Link Here
1755
            "SELECT
1761
            "SELECT
1756
                serialid,      aqbooksellerid,        name,
1762
                serialid,      aqbooksellerid,        name,
1757
                biblio.title,  planneddate,           serialseq,
1763
                biblio.title,  planneddate,           serialseq,
1758
                serial.status, serial.subscriptionid, claimdate,
1764
                serial.status, serial.subscriptionid, claimdate, claims_count,
1759
                subscription.branchcode
1765
                subscription.branchcode
1760
            FROM      serial 
1766
            FROM      serial 
1761
                LEFT JOIN subscription  ON serial.subscriptionid=subscription.subscriptionid 
1767
                LEFT JOIN subscription  ON serial.subscriptionid=subscription.subscriptionid 
Lines 1772-1778 sub GetLateOrMissingIssues { Link Here
1772
            "SELECT 
1778
            "SELECT 
1773
            serialid,      aqbooksellerid,         name,
1779
            serialid,      aqbooksellerid,         name,
1774
            biblio.title,  planneddate,           serialseq,
1780
            biblio.title,  planneddate,           serialseq,
1775
                serial.status, serial.subscriptionid, claimdate,
1781
                serial.status, serial.subscriptionid, claimdate, claims_count,
1776
                subscription.branchcode
1782
                subscription.branchcode
1777
            FROM serial 
1783
            FROM serial 
1778
                LEFT JOIN subscription ON serial.subscriptionid=subscription.subscriptionid 
1784
                LEFT JOIN subscription ON serial.subscriptionid=subscription.subscriptionid 
Lines 1852-1858 sub updateClaim { Link Here
1852
    my ($serialid) = @_;
1858
    my ($serialid) = @_;
1853
    my $dbh        = C4::Context->dbh;
1859
    my $dbh        = C4::Context->dbh;
1854
    my $sth        = $dbh->prepare(
1860
    my $sth        = $dbh->prepare(
1855
        "UPDATE serial SET claimdate = now()
1861
        "UPDATE serial
1862
         SET claimdate = now(),
1863
             claims_count = claims_count + 1
1856
                WHERE serialid = ?
1864
                WHERE serialid = ?
1857
        "
1865
        "
1858
    );
1866
    );
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 1701-1706 CREATE TABLE `serial` ( Link Here
1701
  `publisheddate` date default NULL,
1701
  `publisheddate` date default NULL,
1702
  `itemnumber` text default NULL,
1702
  `itemnumber` text default NULL,
1703
  `claimdate` date default NULL,
1703
  `claimdate` date default NULL,
1704
  claims_count int(11) default 0,
1704
  `routingnotes` text,
1705
  `routingnotes` text,
1705
  PRIMARY KEY  (`serialid`)
1706
  PRIMARY KEY  (`serialid`)
1706
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1707
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
(-)a/installer/data/mysql/updatedatabase.pl (+11 lines)
Lines 4924-4929 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
4924
}
4924
}
4925
4925
4926
4926
4927
4928
4929
4930
4931
$DBversion = "3.07.00.XXX";
4932
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4933
    $dbh->do("ALTER TABLE serial ADD COLUMN claims_count INT(11) DEFAULT 0");
4934
    print "Upgrade to $DBversion done (Add claims_count field in serial table)\n";
4935
    SetVersion($DBversion);
4936
}
4937
4927
=head1 FUNCTIONS
4938
=head1 FUNCTIONS
4928
4939
4929
=head2 DropAllForeignKeys($table)
4940
=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>Branch</th>
285
                        <th>Vendor</th>
275
                    <th>Title</th>
286
                        <th>Branch</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