put hold block logic back in skin, missed it in last version
authorartunit <artunit@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Mon, 18 Oct 2010 02:03:02 +0000 (02:03 +0000)
committerartunit <artunit@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Mon, 18 Oct 2010 02:03:02 +0000 (02:03 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/branches/rel_1_6_1@1043 6d9bc8c9-1ec2-4278-b937-99fde70a366f

web/opac/skin/uwin/js/myopac.js

index 3e4ca8a..0c3624a 100644 (file)
@@ -1436,37 +1436,118 @@ var __renew_circs = [];
 /* true if 1 renewal succeeded */
 var __success_count = 0;
 
-/* renews all selected circulations */
-function myOPACRenewSelected() {
-   var rows = myopacGetCheckedOutRows();
-       if(!confirm($('myopac_renew_confirm').innerHTML)) return;
-   __success_count = 0;
-
-   for( var i = 0; i < rows.length; i++ ) {
-
-      var row = rows[i];
-      if( ! $n(row, 'selectme').checked ) continue;
-      var circ_id = row.getAttribute('circid');
-
-          var circ;
-          for( var j = 0; j != circsCache.length; j++ ) 
-                  if(circsCache[j].id() == circ_id)
-                          circ = circsCache[j];
-
-      __renew_circs.push(circ);
-   }
-
-    if( __renew_circs.length == 0 ) return;
+/*
+        holdBlock - checking for holds before allowing renewals
 
-    unHideMe($('my_renewing'));
-    moClearCheckedTable();
+*/
+function holdBlock(r) {
+        var rec = r.getResultObject();
+        var circ = r.circ;
+
+        //this may be inefficient, but go this route to snag needed title id
+        var new_req = new Request( FETCH_BIB_ID_BY_BARCODE, rec.barcode() );
+        new_req.send(true);
+
+        if (new_req) {
+                var record = new_req.result();
+
+                if (record){
+                        //alert(HOLDSU + ' start for ' + circ.id() + ' - ' + rec.barcode());
+                        /*
+                        var init_request = new Request( LOGIN_INIT, HOLDSU );
+                        init_request.send(true);
+                        var seed = init_request.result();
+
+                        var args = {
+                                password : hex_md5(seed + hex_md5(HOLDSP)),
+                                type            : "opac",
+                                org             : getOrigLocation(),
+                                username : HOLDSU
+                        };
+
+                        var auth_request = new Request( LOGIN_COMPLETE, args );
+
+                        auth_request.request.alertEvent = false;
+                        auth_request.send(true);
+                        var auth_result = auth_request.result();
+
+                        if(!auth_result) {
+                                alertId('problem with renewing');
+                                return null;
+                        }
+                        var temp_session = auth_result.payload.authtoken;
+                        */
+
+                        //if you needed a special session for this, would use the above
+                        //and pass it in the call, however, this doesn't seem to matter
+                        //for this call
+                        /*
+                        new_req = new Request( "open-ils.circ:open-ils.circ.open_holds.retrieve",
+                                temp_session, record, 'T', getOrigLocation() );
+                        */
+
+                        //make the call with user's credentials
+                        new_req = new Request( "open-ils.circ:open-ils.circ.open_holds.retrieve",
+                                G.user.session, record, 'T', getOrigLocation() );
+
+                        new_req.send(true);
+
+                        //we would clean up session right away if we had created one
+                        /*
+                        var sess_req = new Request(LOGIN_DELETE, temp_session);
+                        sess_req.send(true);
+                        try { sess_req.result(); } catch(E){}
+                        */
+
+                        if (new_req) {
+                                record = new_req.result();
+                                if (record.length > 0) {
+                                        var renewTitle = __circ_titles[circ.id()];
+                                        if (renewTitle) {
+                                                alert('Sorry, someone has requested \"' + renewTitle +
+                                                        '\", it can not be renewed, please return this title to the library.');
+                                        }//if renewTitle
+                                        return null;
+                                } else {
+                                        //alert('renew for ' + circ.id());
+                                        moRenewCirc( circ.target_copy(), G.user.id(), circ );
+                                }//if record
+                        }//if new_req
+
+                }//if record
+        }//if new_req
+
+}//holdBlock
 
-    for( var i = 0; i < __renew_circs.length; i++ ) {
-        var circ = __renew_circs[i];
-        moRenewCirc( circ.target_copy(), G.user.id(), circ );
-    }
-}
+/* renews all selected circulations */
+function myOPACRenewSelected() {
 
+        var rows = myopacGetCheckedOutRows();
+        if(!confirm($('myopac_renew_confirm').innerHTML)) return;
+        __success_count = 0;
+
+        for( var i = 0; i < rows.length; i++ ) {
+
+                var row = rows[i];
+                if( ! $n(row, 'selectme').checked ) continue;
+                var circ_id = row.getAttribute('circid');
+
+                var circ;
+                for( var j = 0; j != circsCache.length; j++ ) {
+                        if(circsCache[j].id() == circ_id) {
+                                circ = circsCache[j];
+                                var cp =  circ.target_copy();
+                                if (cp) {
+                                        var hold_req = new Request(FETCH_FLESHED_COPY,
+                                                circ.target_copy() );
+                                        hold_req.request.circ = circ;
+                                        hold_req.callback(holdBlock);
+                                        hold_req.send();
+                                }//if cp
+                        }//if circsCache
+                }//for j
+        }//for i
+}//myOPACRenewSelected
 
 /* renews a single circulation */
 function moRenewCirc(copy_id, user_id, circ) {