We sometimes encounter disputes over when exactly a new library card was
issued. Particularly when it comes to lost cards and checkouts on
reportedly lost cards. While we can gleen much of the information from
the auditor tables, it's still not an exact science.
Long ago I mentioned the possibility of adding a timestamp to the card.
While it involves a dreaded schema change, the code to store the data
is very basic. I also added a creator, as it's another piece of
information that is sometimes hard to track down.
For your review. The attached, is against trunk.
Index: Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- Open-ILS/src/perlmods/OpenILS/Application/Actor.pm (revision 18872)
+++ Open-ILS/src/perlmods/OpenILS/Application/Actor.pm (working copy)
@@ -775,6 +775,7 @@
my $session = shift;
my $patron = shift;
my $new_patron = shift;
+ my $user = shift;
my $evt;
@@ -786,7 +787,7 @@
if(ref($card) and $card->isnew()) {
$virtual_id = $card->id();
- ( $card, $evt ) = _add_card($session,$card);
+ ( $card, $evt ) = _add_card($session,$card,$user);
return (undef, $evt) if $evt;
#if(ref($patron->card)) { $patron->card($patron->card->id); }
@@ -807,8 +808,9 @@
# adds an card to the db and returns the card with new id
sub _add_card {
- my( $session, $card ) = @_;
+ my( $session, $card, $user ) = @_;
$card->clear_id();
+ $card->creator($user->id);
$logger->info("Adding new patron card ".$card->barcode);
Index: Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/actor.pm
===================================================================
--- Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/actor.pm (revision 18872)
+++ Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/actor.pm (working copy)
@@ -141,7 +141,7 @@
__PACKAGE__->table( 'actor_card' );
__PACKAGE__->columns( Primary => qw/id/ );
-__PACKAGE__->columns( Essential => qw/usr barcode active/ );
+__PACKAGE__->columns( Essential => qw/usr barcode active creator/ );
#-------------------------------------------------------------------------------
package actor::user_access_entry;
Index: Open-ILS/web/js/ui/default/actor/user/register.js
===================================================================
--- Open-ILS/web/js/ui/default/actor/user/register.js (revision 18872)
+++ Open-ILS/web/js/ui/default/actor/user/register.js (working copy)
@@ -174,6 +174,7 @@
dojo.byId('true').cloneNode(true) :
dojo.byId('false').cloneNode(true)
);
+ getByName(row, 'create_date').innerHTML = card.create_date();
tbody.appendChild(row);
first = false;
Index: Open-ILS/web/templates/default/actor/user/register.tt2
===================================================================
--- Open-ILS/web/templates/default/actor/user/register.tt2 (revision 18872)
+++ Open-ILS/web/templates/default/actor/user/register.tt2 (working copy)
@@ -48,17 +48,19 @@
<tr>
<th>Barcode</th>
<th>Active</th>
+ <th>Created</th>
</tr>
</thead>
<tbody id='uedit-all-cards-tbody'>
<tr id='uedit-all-cards-tr-template'>
<td><div name='barcode'></div></td>
<td><div name='active'></div></td>
+ <td><div name='create_date'></div></td>
</tr>
</tbody>
<tbody>
<tr>
- <td colspan='2' style='text-align:center;'>
+ <td colspan='3' style='text-align:right;'>
<button dojoType='dijit.form.Button' onClick='allCardsDialog.hide()' scrollOnFocus='false'>Close</button>
</td>
</tr>
Index: Open-ILS/examples/fm_IDL.xml
===================================================================
--- Open-ILS/examples/fm_IDL.xml (revision 18872)
+++ Open-ILS/examples/fm_IDL.xml (working copy)
@@ -4020,9 +4020,12 @@
<field reporter:label="Barcode" name="barcode" reporter:datatype="text"/>
<field reporter:label="Card ID" name="id" reporter:datatype="id" />
<field reporter:label="User" name="usr" reporter:datatype="link"/>
+ <field reporter:label="Creator" name="creator" reporter:datatype="link"/>
+ <field reporter:label="Create Date" name="create_date" reporter:datatype="timestamp"/>
</fields>
<links>
<link field="usr" reltype="has_a" key="id" map="" class="au"/>
+ <link field="creator" reltype="has_a" key="id" map="" class="au"/>
</links>
</class>
<class id="actsc" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="actor::stat_cat" oils_persist:tablename="actor.stat_cat" reporter:label="User Statistical Category">
ALTER TABLE actor.card
ADD creator INT NOT NULL default 1;
ALTER TABLE actor.card
ADD create_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now();
ALTER TABLE actor.card ADD CONSTRAINT actor_card_creator_fkey FOREIGN KEY (creator)
REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED;