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

(-)a/C4/Circulation.pm (-4 / +4 lines)
Lines 732-738 sub CanBookBeIssued { Link Here
732
    #
732
    #
733
    if ( $borrower->{'category_type'} eq 'X' && (  $item->{barcode}  )) { 
733
    if ( $borrower->{'category_type'} eq 'X' && (  $item->{barcode}  )) { 
734
    	# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1  .
734
    	# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1  .
735
        &UpdateStats(C4::Context->userenv->{'branch'},'localuse','','',$item->{'itemnumber'},$item->{'itemtype'},$borrower->{'borrowernumber'});
735
        &UpdateStats(C4::Context->userenv->{'branch'},'localuse','','',$item->{'itemnumber'},$item->{'itemtype'},$borrower->{'borrowernumber'}, undef, $item->{'ccode'});
736
        ModDateLastSeen( $item->{'itemnumber'} );
736
        ModDateLastSeen( $item->{'itemnumber'} );
737
        return( { STATS => 1 }, {});
737
        return( { STATS => 1 }, {});
738
    }
738
    }
Lines 1172-1178 sub AddIssue { Link Here
1172
            C4::Context->userenv->{'branch'},
1172
            C4::Context->userenv->{'branch'},
1173
            'issue', $charge,
1173
            'issue', $charge,
1174
            ($sipmode ? "SIP-$sipmode" : ''), $item->{'itemnumber'},
1174
            ($sipmode ? "SIP-$sipmode" : ''), $item->{'itemnumber'},
1175
            $item->{'itype'}, $borrower->{'borrowernumber'}
1175
            $item->{'itype'}, $borrower->{'borrowernumber'}, undef, $item->{'ccode'}
1176
        );
1176
        );
1177
1177
1178
        # Send a checkout slip.
1178
        # Send a checkout slip.
Lines 1740-1746 sub AddReturn { Link Here
1740
        $branch, $stat_type, '0', '',
1740
        $branch, $stat_type, '0', '',
1741
        $item->{'itemnumber'},
1741
        $item->{'itemnumber'},
1742
        $biblio->{'itemtype'},
1742
        $biblio->{'itemtype'},
1743
        $borrowernumber
1743
        $borrowernumber, undef, $item->{'ccode'}
1744
    );
1744
    );
1745
1745
1746
    # Send a check-in slip. # NOTE: borrower may be undef.  probably shouldn't try to send messages then.
1746
    # Send a check-in slip. # NOTE: borrower may be undef.  probably shouldn't try to send messages then.
Lines 2472-2478 sub AddRenewal { Link Here
2472
            'Rent', $charge, $itemnumber );
2472
            'Rent', $charge, $itemnumber );
2473
    }
2473
    }
2474
    # Log the renewal
2474
    # Log the renewal
2475
    UpdateStats( $branch, 'renew', $charge, '', $itemnumber, $item->{itype}, $borrowernumber);
2475
    UpdateStats( $branch, 'renew', $charge, '', $itemnumber, $item->{itype}, $borrowernumber, undef, $item->{'ccode'});
2476
	return $datedue;
2476
	return $datedue;
2477
}
2477
}
2478
2478
(-)a/C4/Stats.pm (-4 / +4 lines)
Lines 76-95 sub UpdateStats { Link Here
76
    my (
76
    my (
77
        $branch,         $type,
77
        $branch,         $type,
78
        $amount,   $other,          $itemnum,
78
        $amount,   $other,          $itemnum,
79
        $itemtype, $borrowernumber, $accountno
79
        $itemtype, $borrowernumber, $accountno, $ccode
80
      )
80
      )
81
      = @_;
81
      = @_;
82
    my $dbh = C4::Context->dbh;
82
    my $dbh = C4::Context->dbh;
83
    my $sth = $dbh->prepare(
83
    my $sth = $dbh->prepare(
84
        "INSERT INTO statistics
84
        "INSERT INTO statistics
85
        (datetime, branch, type, value,
85
        (datetime, branch, type, value,
86
         other, itemnumber, itemtype, borrowernumber, proccode)
86
         other, itemnumber, itemtype, borrowernumber, proccode, ccode)
87
         VALUES (now(),?,?,?,?,?,?,?,?)"
87
         VALUES (now(),?,?,?,?,?,?,?,?,?)"
88
    );
88
    );
89
    $sth->execute(
89
    $sth->execute(
90
        $branch,    $type,    $amount,
90
        $branch,    $type,    $amount,
91
        $other,     $itemnum, $itemtype, $borrowernumber,
91
        $other,     $itemnum, $itemtype, $borrowernumber,
92
		$accountno
92
		$accountno, $ccode
93
    );
93
    );
94
}
94
}
95
95
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +12 lines)
Lines 5715-5720 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5715
    SetVersion ($DBversion);
5715
    SetVersion ($DBversion);
5716
}
5716
}
5717
5717
5718
$DBversion = '3.09.00.XXX';
5719
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5720
	$dbh->do("ALTER TABLE statistics ADD COLUMN ccode VARCHAR ( 10 ) NULL AFTER associatedborrower");
5721
	$dbh->do("UPDATE statistics SET statistics.ccode = ( SELECT items.ccode FROM items WHERE statistics.itemnumber = items.itemnumber )");
5722
	$dbh->do("UPDATE statistics SET statistics.ccode = (
5723
	  SELECT deleteditems.ccode FROM deleteditems
5724
          WHERE statistics.itemnumber = deleteditems.itemnumber
5725
	  ) WHERE statistics.ccode IS NULL");
5726
	print "Upgrade done ( Added Collection Code to Statistics table. )\n";
5727
    SetVersion ($DBversion);
5728
}
5729
5718
=head1 FUNCTIONS
5730
=head1 FUNCTIONS
5719
5731
5720
=head2 TableExists($table)
5732
=head2 TableExists($table)
5721
- 

Return to bug 4118