Add reshelving counts, suggest hold when no copies
authorJeff Godin <jgodin@tadl.org>
Mon, 23 Apr 2012 11:25:14 +0000 (07:25 -0400)
committerJeff Godin <jgodin@tadl.org>
Mon, 23 Apr 2012 11:25:14 +0000 (07:25 -0400)
Rather than count "reshelving" copies as "available", note
that there are X available "plus Y recently returned".

Adjust logic to display unavailable count when there are no
available copies, and to include a suggestion to (try) placing
a hold.

Signed-off-by: Jeff Godin <jgodin@tadl.org>
Open-ILS/web/opac/skin/tadlv4/xml/rdetail/rdetail_summary.xml
Open-ILS/web/opac/skin/tadlv4/xml/result/result_table.xml

index 94c76f1..3cedebf 100644 (file)
                                 if (!copySummaryObj[libkey][lockey][cnkey]) {
                                     copySummaryObj[libkey][lockey][cnkey] = new Object();
                                     copySummaryObj[libkey][lockey][cnkey]['count'] = 0;
+                                    copySummaryObj[libkey][lockey][cnkey]['count_reshelving'] = 0;
+                                }
+                                if (status_id == 7) {
+                                    copySummaryObj[libkey][lockey][cnkey]['count_reshelving']++;
+                                } else {
+                                    copySummaryObj[libkey][lockey][cnkey]['count']++;
                                 }
-                                copySummaryObj[libkey][lockey][cnkey]['count']++;
 
                                 item_cnt++;
                                 //if (item_cnt >= max_items) {
                     for (var lib in copySummaryObj) {
                         numLibs++;
                     }
-                    if (numLibs == 0) { return; }
                     if (numLibs == 1) {
                         var lines_output = 0;
                         var sumdiv = dojo.create('div', { "style": "font-weight: bold;" });
                                         morediv.appendChild(dojo.doc.createTextNode("additional copies available - click title for details"));
                                     } else {
                                         var sumcount = copySummaryObj[sumlib][sumloc][sumcn]['count'];
-                                        var summary_line = sumcount + ' available in ' + sumloc + ', call number ' + sumcn;
+                                        var sumcount_reshelving = copySummaryObj[sumlib][sumloc][sumcn]['count_reshelving'];
+                                        var summary_line = sumcount + ' available in ' + sumloc;
+                                        if (sumcount_reshelving) {
+                                            summary_line += ' (plus ' + sumcount_reshelving + ' recently returned)';
+                                        }
+                                        summary_line += ', call number ' + sumcn;
                                         var locdiv = dojo.create('div', null, sumdiv);
                                         locdiv.appendChild(dojo.doc.createTextNode(summary_line));
                                         lines_output++;
                             }
                         }
                         output.appendChild(sumdiv);
-                    } else {
+                    } else if (numLibs > 1) {
                         // output the grouped-by-library summary
                         for (var libname in copySummaryObj) {
                             var copycount = 0;
                     if (count_copies_unavail > 0) {
                         other_or_null = (count_copies_avail > 0) ? 'other ' : ' ';
                         item_or_items = (count_copies_unavail > 1) ? 'items' : 'item';
+                        suggest_hold = (count_copies_avail < 1) ? ' -- try placing a hold!' : '';
                         output.appendChild(
                             dojo.doc.createTextNode(
-                                count_copies_unavail + " " + other_or_null + item_or_items + " not currently available"
+                                count_copies_unavail + " " + other_or_null + item_or_items + " not currently available" + suggest_hold
                             )
                         );
                     }
index 92c5e5d..738971d 100644 (file)
                                             if (!copySummaryObj[libkey][lockey][cnkey]) {
                                                 copySummaryObj[libkey][lockey][cnkey] = new Object();
                                                 copySummaryObj[libkey][lockey][cnkey]['count'] = 0;
+                                                copySummaryObj[libkey][lockey][cnkey]['count_reshelving'] = 0;
+                                            }
+                                            if (status_id == 7) {
+                                                copySummaryObj[libkey][lockey][cnkey]['count_reshelving']++;
+                                            } else {
+                                                copySummaryObj[libkey][lockey][cnkey]['count']++;
                                             }
-                                            copySummaryObj[libkey][lockey][cnkey]['count']++;
-
                                             item_cnt++;
                                             //if (item_cnt >= max_items) {
                                             //    dojo.create('br', null, cp_entry);
                                 for (var lib in copySummaryObj) {
                                     numLibs++;
                                 }
-                                if (numLibs == 0) { return output.innerHTML; }
                                 if (numLibs == 1) {
                                     var lines_output = 0;
                                     var sumdiv = dojo.create('div', { "style": "font-weight: bold;" });
                                                     morediv.appendChild(dojo.doc.createTextNode("additional copies available - click title for details"));
                                                 } else {
                                                     var sumcount = copySummaryObj[sumlib][sumloc][sumcn]['count'];
-                                                    var summary_line = sumcount + ' available in ' + sumloc + ', call number ' + sumcn;
+                                                    var sumcount_reshelving = copySummaryObj[sumlib][sumloc][sumcn]['count_reshelving'];
+                                                    var summary_line = sumcount + ' available in ' + sumloc;
+                                                    if (sumcount_reshelving) {
+                                                        summary_line += ' (plus ' + sumcount_reshelving + ' recently returned)';
+                                                    }
+                                                    summary_line += ', call number ' + sumcn;
                                                     var locdiv = dojo.create('div', null, sumdiv);
                                                     locdiv.appendChild(dojo.doc.createTextNode(summary_line));
                                                     lines_output++;
                                         }
                                     }
                                     output.appendChild(sumdiv);
-                                } else {
+                                } else if (numLibs > 1) {
                                     // output the grouped-by-library summary
                                     for (var libname in copySummaryObj) {
                                         var copycount = 0;
                                 if (count_copies_unavail > 0) {
                                     other_or_null = (count_copies_avail > 0) ? 'other ' : ' ';
                                     item_or_items = (count_copies_unavail > 1) ? 'items' : 'item';
+                                    suggest_hold = (count_copies_avail < 1) ? ' -- try placing a hold!' : '';
                                     output.appendChild(
                                         dojo.doc.createTextNode(
-                                            count_copies_unavail + " " + other_or_null + item_or_items + " not currently available"
+                                            count_copies_unavail + " " + other_or_null + item_or_items + " not currently available" + suggest_hold
                                         )
                                     );
                                 }