essentially functioning hold editor
authorsenator <lebbeous@esilibrary.com>
Wed, 30 Mar 2011 21:41:17 +0000 (17:41 -0400)
committersenator <lebbeous@esilibrary.com>
Wed, 30 Mar 2011 21:43:51 +0000 (17:43 -0400)
Still needs a way to report failures to the user

Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/web/css/skin/default/opac/style.css
Open-ILS/web/templates/default/opac/myopac/holds/edit.tt2
Open-ILS/web/templates/default/opac/parts/myopac/base.tt2

index bed70d4..67920e3 100644 (file)
@@ -125,7 +125,7 @@ sub handle_hold_update {
     my $self = shift;
     my $action = shift;
     my $e = $self->editor;
-
+    my $url;
 
     my @hold_ids = $self->cgi->param('hold_id'); # for non-_all actions
     @hold_ids = @{$self->fetch_user_holds(undef, 1)} if $action =~ /_all/;
@@ -139,7 +139,7 @@ sub handle_hold_update {
                 'open-ils.circ.hold.cancel', $e->authtoken, $hold_id, 6 )->gather(1); # 6 == patron-cancelled-via-opac
         }
 
-    } else {
+    } elsif ($action =~ /activate|suspend/) {
         
         my $vlist = [];
         for my $hold_id (@hold_ids) {
@@ -157,10 +157,32 @@ sub handle_hold_update {
         }
 
         $circ->request('open-ils.circ.hold.update.batch.atomic', $e->authtoken, undef, $vlist)->gather(1);
+    } elsif ($action eq 'edit') {
+
+        my @vals = map {
+            my $val = {"id" => $_};
+            $val->{"frozen"} = $self->cgi->param("frozen");
+            $val->{"pickup_lib"} = $self->cgi->param("pickup_lib");
+
+            for my $field (qw/expire_time thaw_date/) {
+                # XXX TODO make this support other date formats, not just
+                # MM/DD/YYYY.
+                next unless $self->cgi->param($field) =~
+                    m:^(\d{2})/(\d{2})/(\d{4})$:;
+                $val->{$field} = "$3-$1-$2";
+            }
+            $val;
+        } @hold_ids;
+
+        $circ->request(
+            'open-ils.circ.hold.update.batch.atomic',
+            $e->authtoken, undef, \@vals
+        )->gather(1);   # LFW XXX test for failure
+        $url = 'https://' . $self->apache->hostname . $self->ctx->{opac_root} . '/myopac/holds';
     }
 
     $circ->kill_me;
-    return undef;
+    return defined($url) ? $self->generic_redirect($url) : undef;
 }
 
 sub load_myopac_holds {
@@ -174,11 +196,12 @@ sub load_myopac_holds {
     my $action = $self->cgi->param('action') || '';
     my $available = int($self->cgi->param('available') || 0);
 
-    $self->handle_hold_update($action) if $action;
+    my $hold_handle_result;
+    $hold_handle_result = $self->handle_hold_update($action) if $action;
 
     $ctx->{holds} = $self->fetch_user_holds(undef, 0, 1, $available, $limit, $offset);
 
-    return Apache2::Const::OK;
+    return defined($hold_handle_result) ? $hold_handle_result : Apache2::Const::OK;
 }
 
 sub load_place_hold {
index 6b40404..32a3c82 100644 (file)
@@ -971,4 +971,9 @@ a.dash-link:hover { text-decoration: underline !important; }
 #hold_editor h1 { font-size: 120%; font-weight: bold; }
 #hold_editor h2 { font-size: 111%; font-weight: normal; text-indent: 2em; font-style: italic; }
 #hold_editor h1, #hold_editor h2 { margin: 2px 0; }
+#hold_editor_table { background-color: #ddd; padding: 0.5em; }
 #hold_editor_table th { text-align: right; padding-right: 1em; }
+#hold_editor_table td { padding: 0.25em 0; }
+.fmt-note { vertical-align: middle; padding-left: 1em !important; }
+.hold-editor-controls { text-align: center; padding-top: 1em !important; }
+.hold-editor-controls a { padding-left: 2em; }
index bf30913..53e12c9 100644 (file)
@@ -24,6 +24,8 @@
 <div class="pad-bottom-five">
     <div class="header_middle">
         <span id="acct_holds_header float-left">[% l('Editing Hold') %]</span>
+        &nbsp; &nbsp; &nbsp; &nbsp;
+        <a href="[% ctx.opac_root %]/myopac/holds">[% l('List all holds') %]</a>
     </div>
     <div id="hold_editor">
         [% IF hold %]
             <p>
                 <strong>[% l('Status') %]</strong>: [% hold.human_status %]
             </p>
-            <form>
+            <form method="POST">
                 <table id="hold_editor_table">
                     <tr>
                         <th>
-                            <input type="hidden" name="hold"
+                            <input type="hidden" name="action" value="edit" />
+                            <input type="hidden" name="hold_id"
                                 value="[% ahr.id %]" />
                             [% l('Pickup library') %]
                         </th>
                             <input type="text" name="expire_time"
                                 value="[% expire_time | html %]" />
                         </td>
+                        <td class="fmt-note">
+                            <em>[% l('Enter date in MM/DD/YYYY format') %]</em>
+                            <!-- XXX TODO pick out a minimal, simple, reliable
+                            calendar widget that's not part of some giant,
+                            bloated framework and doesn't do anything at onload.
+                            -->
+                        </td>
                     </tr>
                     <tr>
                         <th>
-                            [% l('Activate on') %]
+                            [% l('Active?') %]
+                        </th>
+                        <td>
+                            <select name="frozen">
+                                <option value="f"[% ahr.frozen == 't' ? '' :' selected="selected"' %]>
+                                    [% l('Yes, this hold is active now') %]
+                                </option>
+                                <option value="t"[% ahr.frozen == 't' ? ' selected="selected"' : '' %]>
+                                    [% l('No, this hold is suspended') %]
+                                </option>
+                            </select>
+                        </td>
+                    </tr>
+                    <tr>
+                        <th>
+                            [% l('If suspended, activate on') %]
                         </th>
                         <td>
                             <input type="text" name="thaw_date"
                                 value="[% thaw_date | html %]" />
                         </td>
+                        <td class="fmt-note">
+                            <em>[% l('Enter date in MM/DD/YYYY format') %]</em>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td colspan="2" class="hold-editor-controls">
+                            <input type="image"
+                                src="[% ctx.media_prefix %]/images/btnSubmit.png"
+                                alt="[% l('Submit') %]"
+                                title="[% l('Submit') %]" />
+                            <a href="[% ctx.opac_root %]/myopac/holds"><img
+                                src="[% ctx.media_prefix %]/images/btnCancel.png"
+                                alt="[% l('Cancel') %]"
+                                title="[% l('Cancel') %]" /></a>
+                        </td>
                     </tr>
                 </table>
             </form>
index d41caa1..f374db2 100644 (file)
@@ -22,7 +22,7 @@
                     ELSE;
                         cls_which = "off";
                     END -%]
-                <a href="[% page.url %]"
+                <a href="[% ctx.opac_root _ '/myopac/' _ page.url %]"
                     class="acct-[% page.url; '-'; cls_which %] acct-tab"></a>
                 [% END %]
             </div>