this function get all suppliers with late issues.
return :
-the supplierlist into a hash. this hash containts id & name of the supplier
-Only valid suppliers are returned. Late subscriptions lacking a supplier are
-ignored.
+an array_ref of suppliers each entry is a hash_ref containing id and name
+the array is in name order
=back
AND (planneddate < now() OR serial.STATUS = 3 OR serial.STATUS = 4)
ORDER BY name
|;
- my $sth = $dbh->prepare($query);
- $sth->execute;
- my %supplierlist;
- while ( my ( $id, $name ) = $sth->fetchrow ) {
- next if !defined $id;
- $supplierlist{$id} = $name;
- }
- return %supplierlist;
+ return $dbh->selectall_arrayref($query, { Slice => {} });
}
=head2 GetLateIssues
my @issuelist;
my $last_title;
my $odd = 0;
- my $count = 0;
while ( my $line = $sth->fetchrow_hashref ) {
$odd++ unless $line->{title} eq $last_title;
$line->{title} = "" if $line->{title} eq $last_title;
$last_title = $line->{title} if ( $line->{title} );
$line->{planneddate} = format_date( $line->{planneddate} );
- $count++;
push @issuelist, $line;
}
- return $count, @issuelist;
+ return @issuelist;
}
=head2 GetSubscriptionHistoryFromSubscriptionId
=over 4
-($count,@issuelist) = &GetLateMissingIssues($supplierid,$serialid)
+@issuelist = &GetLateMissingIssues($supplierid,$serialid)
this function select missing issues on database - where serial.status = 4 or serial.status=3 or planneddate<now
return :
-a count of the number of missing issues
the issuelist into a table. Each line of this table containts a ref to a hash which it containts
name,title,planneddate,serialseq,serial.subscriptionid from tables : subscription, serial & biblio
}
$sth->execute;
my @issuelist;
- my $last_title;
- my $odd = 0;
- my $count = 0;
while ( my $line = $sth->fetchrow_hashref ) {
- $odd++ unless $line->{title} eq $last_title;
- $last_title = $line->{title} if ( $line->{title} );
- $line->{planneddate} = format_date( $line->{planneddate} );
- $line->{claimdate} = format_date( $line->{claimdate} );
- $line->{ "status" . $line->{status} } = 1;
- $line->{'odd'} = 1 if $odd % 2;
- $count++;
+ if ($line->{planneddate}) {
+ $line->{planneddate} = format_date( $line->{planneddate} );
+ }
+ if ($line->{claimdate}) {
+ $line->{claimdate} = format_date( $line->{claimdate} );
+ }
+ $line->{"status".$line->{status}} = 1;
push @issuelist, $line;
}
- return $count, @issuelist;
+ return @issuelist;
}
=head2 removeMissingIssue
<form id="claims" name="claims" action="claims.pl" method="post">
<fieldset><label for="supplierid">View: </label>
<select id="supplierid" size="1" name="supplierid">
- <!-- TMPL_LOOP name="supplier_loop" -->
- <option value="<!--TMPL_VAR name="id"-->" <!-- TMPL_IF NAME="selected" -->selected="1"<!-- /TMPL_IF -->>
- <!--TMPL_VAR name="name"--></option>
- <!--/TMPL_LOOP-->
+ <!-- TMPL_LOOP NAME="supplier_loop" -->
+ <option value="<!-- TMPL_VAR NAME="id" -->"<!-- TMPL_IF NAME="selected" --> selected="yes" <!-- /TMPL_IF -->><!-- TMPL_VAR NAME="name" -->
+ </option>
+ <!-- /TMPL_LOOP -->
</select>
<input type="submit" value="OK" />
<!-- TMPL_IF name="phone" -->Phone: <!-- TMPL_VAR name="phone" --><!-- /TMPL_IF -->
</select>
<input type="hidden" name="op" value="send_alert" /><input type="submit" name="submit" class="button" value="Send notification" /></fieldset>
<!--/TMPL_IF-->
+ </form>
<!-- /TMPL_IF -->
- </form>
<!-- TMPL_ELSE -->
<div id="doc" class="yui-t7">
my $supplierid = $input->param('supplierid');
my $suppliername = $input->param('suppliername');
my $order = $input->param('order');
-my %supplierlist = GetSuppliersWithLateIssues();
+my $supplierlist = GetSuppliersWithLateIssues;
# open template first (security & userenv set here)
my ($template, $loggedinuser, $cookie)
flagsrequired => {serials => 1},
debug => 1,
});
-my $supplier_loop = [];
-foreach my $s_id (sort {$supplierlist{$a} cmp $supplierlist{$b} } keys %supplierlist){
- my ($count) = GetLateOrMissingIssues($s_id,q{},$order);
- push @{$supplier_loop}, {
- id => $s_id,
- name => $supplierlist{$s_id} . "($count)",
- selected => ( $supplierid && $supplierid == $s_id ),
- };
+
+for my $supplier ( @{$supplierlist} ) {
+ my @dummy = GetLateOrMissingIssues($supplier->{id},q{},$order);
+ my $counting = scalar @dummy;
+ $supplier->{name} .= " ($counting)";
+ if ($supplierid && $supplierid == $supplier->{id}) {
+ $supplier->{selected} = 1;
+ }
}
my $letters = GetLetters('claimissues');
}
my $letter=((scalar(@letters)>1) || ($letters[0]->{name}||$letters[0]->{code}));
-my ($count2, @missingissues);
+my @missingissues;
if ($supplierid) {
- ($count2, @missingissues) = GetLateOrMissingIssues($supplierid,$serialid,$order);
+ @missingissues = GetLateOrMissingIssues($supplierid,$serialid,$order);
}
my ($singlesupplier,@supplierinfo);
my $preview=0;
if($op && $op eq 'preview'){
$preview = 1;
+} else {
+ my @serialnums=$input->param('serialid');
+ if (@serialnums) { # i.e. they have been flagged to generate claims
+ SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
+ my $cntupdate=UpdateClaimdateIssues(\@serialnums);
+ ### $cntupdate SHOULD be equal to scalar(@$serialnums)
+ }
}
-if ($op eq "send_alert"){
- my @serialnums=$input->param("serialid");
- SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
- my $cntupdate=UpdateClaimdateIssues(\@serialnums);
- ### $cntupdate SHOULD be equal to scalar(@$serialnums)
- $template->param('SHOWCONFIRMATION' => 1);
- $template->param('suppliername' => $suppliername);
-}
-
$template->param('letters'=>\@letters,'letter'=>$letter);
$template->param(
order =>$order,
- supplier_loop => $supplier_loop,
+ supplier_loop => $supplierlist,
phone => $supplierinfo[0]->{phone},
booksellerfax => $supplierinfo[0]->{booksellerfax},
bookselleremail => $supplierinfo[0]->{bookselleremail},
my $op = $query->param('op') || q{};
my $serialidcount = @serialid;
-my %supplierlist = GetSuppliersWithLateIssues;
-
my @loop1;
-my ($count, @lateissues);
+my @lateissues;
if($op ne 'claims'){
- ($count, @lateissues) = GetLateIssues($supplierid);
+ @lateissues = GetLateIssues($supplierid);
for my $issue (@lateissues){
push @loop1,
[ $issue->{'name'}, $issue->{'title'}, $issue->{'serialseq'}, $issue->{'planneddate'},];
}
my $totalcount2 = 0;
my @loop2;
-my ($count2, @missingissues);
+my @missingissues;
for (my $k=0;$k<@serialid;$k++){
- ($count2, @missingissues) = GetLateOrMissingIssues($supplierid, $serialid[$k]);
+ @missingissues = GetLateOrMissingIssues($supplierid, $serialid[$k]);
for (my $j=0;$j<@missingissues;$j++){
my @rows2 = ($missingissues[$j]->{'name'}, # lets build up a row
);
push (@loop2, \@rows2);
}
- $totalcount2 = $totalcount2 + $count2;
+ $totalcount2 += scalar @missingissues;
# update claim date to let one know they have looked at this missing item
updateClaim($serialid[$k]);
}
print ",,,,,,,\n";
print ",,,,,,,\n";
if($op ne 'claims'){
+ my $count = scalar @lateissues;
print ",,Total Number Late, $count\n";
}
if($serialidcount == 1){