fines on reservations no longer break myopac/main (my account)
authorsenator <lebbeous@esilibrary.com>
Mon, 25 Apr 2011 19:32:50 +0000 (15:32 -0400)
committersenator <lebbeous@esilibrary.com>
Mon, 25 Apr 2011 19:32:50 +0000 (15:32 -0400)
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/web/templates/default/opac/myopac/main.tt2

index e9250ef..048273c 100644 (file)
@@ -2258,6 +2258,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field name="xact" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field name="grocery" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field name="circulation" oils_persist:virtual="true" reporter:datatype="link"/>
+                       <field name="reservation" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field name="billing_location" reporter:datatype="link"/>
                </fields>
                <links>
@@ -2265,6 +2266,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <link field="xact" reltype="might_have" key="id" map="" class="mbt"/>
                        <link field="circulation" reltype="might_have" key="id" map="" class="circ"/>
                        <link field="grocery" reltype="might_have" key="id" map="" class="mg"/>
+                       <link field="reservation" reltype="might_have" key="id" map="" class="bresv"/>
                        <link field="billing_location" reltype="has_a" key="id" map="" class="aou"/>
                </links>
        </class>
index 9881b5e..2486e23 100644 (file)
@@ -613,7 +613,9 @@ sub load_myopac_main {
         {
             flesh => 4,
             flesh_fields => {
-                mobts => ['circulation', 'grocery'],
+                mobts => [qw/grocery circulation reservation/],
+                bresv => ['target_resource_type'],
+                brt => ['record'],
                 mg => ['billings'],
                 mb => ['btype'],
                 circ => ['target_copy'],
@@ -640,14 +642,25 @@ sub load_myopac_main {
             qw/total_paid total_owed balance_owed/
         );
 
+        my $marc_xml = undef;
+        if ($mobts->xact_type eq 'reservation' and
+            $mobts->reservation->target_resource_type->record) {
+            $marc_xml = XML::LibXML->new->parse_string(
+                $mobts->reservation->target_resource_type->record->marc
+            );
+        } elsif ($mobts->xact_type eq 'circulation' and
+            $circ->target_copy->call_number->id != -1) {
+            $marc_xml = XML::LibXML->new->parse_string(
+                $circ->target_copy->call_number->record->marc
+            );
+        }
+
         push(
             @{$ctx->{"fines"}->{$mobts->grocery ? "grocery" : "circulation"}},
             {
                 xact => $mobts,
                 last_grocery_billing => $last_billing,
-                marc_xml => ($mobts->xact_type ne 'circulation' or $circ->target_copy->call_number->id == -1) ?
-                    undef :
-                    XML::LibXML->new->parse_string($circ->target_copy->call_number->record->marc),
+                marc_xml => $marc_xml
             } 
         );
     }
index 6f2584b..a99cc2d 100644 (file)
             <tbody id='myopac_circ_trans_tbody'>
                 [% FOR f IN ctx.fines.circulation;
                     attrs = {marc_xml => f.marc_xml};
-                    PROCESS get_marc_attrs args=attrs %]
+                    IF f.marc_xml;
+                        PROCESS get_marc_attrs args=attrs;
+                    ELSIF f.xact.reservation;
+                        attrs.title = f.xact.reservation.target_resource_type.name;
+                    END %]
                 <tr id='myopac_circ_trans_row'>
                     <td>
                         <a href="[% ctx.opac_root %]/record/[% f.xact.circulation.target_copy.call_number.record.id %]">[% attrs.title %]</a>
                         <a href="[% ctx.opac_root %]/results?qtype=author&query=[% attrs.author | replace('[,\.:;]', '') | url %]">[% attrs.author %]</a>
                     </td>
                     <td name='myopac_circ_trans_start'>
-                        [% date.format(
-                            ctx.parse_datetime(
-                                f.xact.circulation.xact_start
-                            ), DATE_FORMAT
-                        ) %]
+                        [% ts = f.xact.circulation.xact_start || f.xact.reservation.start_time || 0;
+                        IF ts;
+                            date.format(ctx.parse_datetime(ts), DATE_FORMAT);
+                        END %]
                     </td>
                     <td name='myopac_circ_trans_due'>
-                        [% date.format(
-                            ctx.parse_datetime(
-                                f.xact.circulation.due_date
-                            ), DATE_FORMAT
-                        ) %]
+                        [% ts = f.xact.circulation.due_date || f.xact.reservation.end_time || 0;
+                        IF ts;
+                            date.format(ctx.parse_datetime(ts), DATE_FORMAT);
+                        END %]
                     </td>
                     <td name='myopac_circ_trans_finished'>
-                        [%  IF f.xact.circulation.checkin_time;
-                                date.format(
-                                    ctx.parse_datetime(
-                                        f.xact.circulation.checkin_time
-                                    ), DATE_FORMAT
-                                );
+                        [%  ts = f.xact.circulation.checkin_time || f.xact.reservation.return_time || 0;
+                            IF ts;
+                                date.format(ctx.parse_datetime(ts), DATE_FORMAT);
                             ELSE %]
                             <!-- XXX TODO fines aren't really accruing
                                 if circ has hit maxfines. more clarity