kpac : initial login + place hold combined action
authorBill Erickson <berick@esilibrary.com>
Thu, 5 Apr 2012 16:35:39 +0000 (12:35 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 30 Jul 2012 19:03:21 +0000 (15:03 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm
Open-ILS/src/templates/kpac/getit.tt2

index c0b1f5e..01e2b35 100644 (file)
@@ -62,6 +62,7 @@ sub load_getit {
     $self->ctx->{page} = 'getit'; # repair the page
 
     return $self->save_item_to_bookbag($rec_id, $bbag_id) if $action eq 'save';
+    return $self->login_and_place_hold($rec_id) if $action eq 'hold';
 
     # if the user is logged in, fetch his bookbags
     if ($ctx->{user}) {
@@ -78,6 +79,35 @@ sub load_getit {
     $self->ctx->{page} = 'getit'; # repair the page
     return Apache2::Const::OK;
 }
+    
+sub login_and_place_hold {
+    my $self = shift;
+    my $bre_id = shift;
+    my $ctx = $self->ctx;
+    my $username = $self->cgi->param('username');
+    my $password = $self->cgi->param('password');
+    my $pickup_lib = $self->cgi->param('pickup_lib');
+
+    if (!$ctx->{user}) {
+        # First, log the user in and return to 
+        # TODO: let user know username/password is required..
+        return Apache2::Const::OK unless $username and $password;
+        my $new_uri = $self->apache->unparsed_uri;
+        my $sep = ($new_uri =~ /\?/) ? '&' : '?';
+        $new_uri .= "${sep}pickup_lib=$pickup_lib&action=hold";
+        $self->cgi->param('redirect_to', $new_uri);
+        return $self->load_login;
+    }
+
+    # TODO: place hold
+
+    my $hold_id = '';
+#    (my $new_uri = $self->apache->unparsed_uri) =~ s/getit/getit_results/g;
+#    $new_uri .= ($new_uri =~ /\?/) ? "&hold=$hold_id" : "?hold=$hold_id";
+#    return $self->generic_redirect($new_uri);
+
+    return Apache2::Const::OK;
+}
 
 sub save_item_to_bookbag {
     my $self = shift;
index 1b0dbf6..ebdbbfe 100644 (file)
 
                     <div class="top_side">
                         <h2>get it!</h2>
-                        <p>[% |l %]If you would like to request this item, please enter the following information and click<br />Submit below:[% END %]</p>
+                        <p>[% |l %]If you would like to request this item, please enter the 
+                            following information and click<br />Submit below:[% END %]</p>
                     </div>
-                    <div class="checkout_box">
-                        <div class="box1_top">&nbsp;</div>
-                        <div class="box_inside">
 
-                            [% IF !ctx.user %]
-                                [% seed = l(' Enter Numbers... ') %]
-                                <p>[% l('Library Card Number without spaces:') %]</p>
-                                <div class="input_box">
-                                    <input type="text" class="text_box" style="color:#aaa;" value="[% seed %]" 
-                                        onfocus="if(this.value=='[% seed %]'){this.value='';this.style.color='#424242';}" 
-                                        onblur="if(this.value==''){this.value='[% seed %]'; this.style.color='#aaa';}" />
-                                </div>
-                                <a class="help_btn" href="javascript:;" 
-                                    onclick="helpPopup('card_help', this, event);"><img 
-                                    src="[% ctx.media_prefix %]/images/kpac/question_mark.png" alt="pin number help" /></a>
-                                <div class="clear">&nbsp;</div>
-                                <div class="hr">&nbsp;</div>
+                    <form method='POST'><!-- login + place hold form -->
+
+                        <div class="checkout_box">
+                            <div class="box1_top">&nbsp;</div>
+                            <div class="box_inside">
+
+                                [% IF !ctx.user %]
+                                    [% seed = l(' Enter Numbers... ') %]
+                                    <p>[% l('Library Card Number without spaces:') %]</p>
+                                    <div class="input_box">
+                                        <input name="username" type="text" class="text_box" style="color:#aaa;" value="[% seed %]" 
+                                            onfocus="if(this.value=='[% seed %]'){this.value='';this.style.color='#424242';}" 
+                                            onblur="if(this.value==''){this.value='[% seed %]'; this.style.color='#aaa';}" />
+                                    </div>
+                                    <a class="help_btn" href="javascript:;" 
+                                        onclick="helpPopup('card_help', this, event);"><img 
+                                        src="[% ctx.media_prefix %]/images/kpac/question_mark.png" alt="pin number help" /></a>
 
-                                <p>[% l('Password') %]</p>
-                                <div class="input_box">
-                                    <input type="password" class="text_box" style="color:#aaa;" value="[% seed %]" 
-                                        onfocus="if(this.value=='[% seed %]'){this.value='';this.style.color='#424242';}" 
-                                        onblur="if(this.value==''){this.value='[% seed %]'; this.style.color='#aaa';}" />
+                                    <div class="clear">&nbsp;</div>
+                                    <div class="hr">&nbsp;</div>
 
-                                <a class="help_btn" href="javascript:;" 
-                                    onclick="helpPopup('password_help', this, event);"><img 
-                                    src="[% ctx.media_prefix %]/images/kpac/question_mark.png" alt="[% l('password help') %]" /></a>
+                                    <p>[% l('Password') %]</p>
+                                    <div class="input_box">
+                                        <input name="password" type="password" class="text_box" style="color:#aaa;" value="[% seed %]" 
+                                            onfocus="if(this.value=='[% seed %]'){this.value='';this.style.color='#424242';}" 
+                                            onblur="if(this.value==''){this.value='[% seed %]'; this.style.color='#aaa';}" />
+                                    </div>
 
-                                <div class="clear">&nbsp;</div>
-                                <div class="hr">&nbsp;</div>
-                            [% END %]
+                                    <a class="help_btn" href="javascript:;" 
+                                        onclick="helpPopup('password_help', this, event);"><img 
+                                        src="[% ctx.media_prefix %]/images/kpac/question_mark.png" alt="[% l('password help') %]" /></a>
 
-                            <p>[% l('Choose a Pickup Library:') %]</p>
-                            <div class="pickup_lib">
-                                [%  def_lib = ctx.default_pickup_lib || ctx.physical_loc;
-                                    PROCESS "opac/parts/org_selector.tt2";
-                                    PROCESS build_org_selector name='pickup_lib' 
-                                    value=def_lib id='pickup_lib' can_have_vols_only=1 %]
+                                    <div class="clear">&nbsp;</div>
+                                    <div class="hr">&nbsp;</div>
+                                [% END %]
+
+                                <p>[% l('Choose a Pickup Library:') %]</p>
+                                <div class="pickup_lib">
+                                    [%  def_lib = ctx.default_pickup_lib || ctx.physical_loc;
+                                        PROCESS "opac/parts/org_selector.tt2";
+                                        PROCESS build_org_selector name='pickup_lib' 
+                                        value=def_lib id='pickup_lib' can_have_vols_only=1 %]
+                                </div>
                             </div>
                         </div>
-                    </div>
-                    <div class="submit_btn">
-                        <a href="javascript:;"><img src="[% ctx.media_prefix %]/images/kpac/review_submit_btn.png" alt="submit" /></a>
-                    </div>
+                        <div class="submit_btn">
+                            <input type='hidden' name='action' value='hold'/>
+                            <input type='image' src="[% ctx.media_prefix %]/images/kpac/review_submit_btn.png" alt="[% l('Submit') %]"/>
+                        </div>
+                    </form>
                 </div>
             </td>
 
@@ -83,7 +91,7 @@
                     </div>
                     <form method='POST'>
                         <input type='hidden' name='action' value='save'/>
-                        [% IF ctx.user AND ctx.bookbags.size > 0 %]
+                        [% IF ctx.user AND ctx.bookbags AND ctx.bookbags.size > 0 %]
                             <div class="checkout_box">
                                 <div class="box1_top">&nbsp;</div>
                                 <div class="box_inside">