Offer yet another pull list printing pathway
authorsenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 1 Oct 2010 19:45:27 +0000 (19:45 +0000)
committersenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 1 Oct 2010 19:45:27 +0000 (19:45 +0000)
If you have pull lists long enough to make A/T groan, perhaps this will work
better for you.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@18124 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/apache/eg_vhost.conf
Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
Open-ILS/web/opac/extras/circ/alt_pull_list.html [new file with mode: 0644]
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/server/patron/holds.js
Open-ILS/xul/staff_client/server/patron/holds_overlay.xul

index 1f93a21..da947e0 100644 (file)
@@ -395,6 +395,17 @@ RewriteRule - - [E=locale:en-US] [L]
     allow from all
 </Location>
 
+<Location /opac/extras/circ>
+    SetHandler perl-script
+    PerlSetVar OILSProxyTitle "Circ Extras Login"
+    PerlSetVar OILSProxyDescription "Please log in with an authorized staff account to export records"
+    PerlSetVar OILSProxyPermissions "STAFF_LOGIN"
+    PerlHandler OpenILS::WWW::Proxy
+    Options +ExecCGI
+    PerlSendHeader On
+    allow from all
+</Location>
+
 # ----------------------------------------------------------------------------------
 # Reporting output lives here
 # ----------------------------------------------------------------------------------
index 2073ce2..143caeb 100644 (file)
@@ -1310,6 +1310,120 @@ sub print_hold_pull_list {
         undef, "ahr.format.pull_list", $sorted_holds,
         $org_id, undef, undef, $client
     );
+
+}
+
+__PACKAGE__->register_method(
+    method    => "print_hold_pull_list_stream",
+    stream   => 1,
+    api_name  => "open-ils.circ.hold_pull_list.print.stream",
+    signature => {
+        desc   => 'Returns a stream of fleshed holds',
+        params => [
+            { desc => 'Authtoken', type => 'string'},
+            { desc => 'Hash of optional param: Org unit ID (defaults to workstation org unit), limit, offset, sort (array of: acplo.position, call_number, request_time)',
+              type => 'object'
+            },
+        ],
+        return => {
+            desc => 'A stream of fleshed holds',
+            type => 'object'
+        }
+    }
+);
+
+sub print_hold_pull_list_stream {
+    my($self, $client, $auth, $params) = @_;
+
+    my $e = new_editor(authtoken=>$auth);
+    return $e->die_event unless $e->checkauth;
+
+    delete($$params{org_id}) unless (int($$params{org_id}));
+    delete($$params{limit}) unless (int($$params{limit}));
+    delete($$params{offset}) unless (int($$params{offset}));
+
+    $$params{org_id} = (defined $$params{org_id}) ? $$params{org_id}: $e->requestor->ws_ou;
+    return $e->die_event unless $e->allowed('VIEW_HOLD', $$params{org_id });
+
+    my $sort = [];
+    if ($$params{sort} && @{ $$params{sort} }) {
+        for my $s (@{ $$params{sort} }) {
+            if ($s eq 'acplo.position') {
+                push @$sort, {
+                    "class" => "acplo", "field" => "position",
+                    "transform" => "coalesce", "params" => [999]
+                };
+            } elsif ($s eq 'call_number') {
+                push @$sort, {"class" => "acn", "field" => "label"};
+            } elsif ($s eq 'request_time') {
+                push @$sort, {"class" => "ahr", "field" => "request_time"};
+            }
+        }
+    } else {
+        push @$sort, {"class" => "ahr", "field" => "request_time"};
+    }
+
+    my $holds_ids = $e->json_query(
+        {
+            "select" => {"ahr" => ["id"]},
+            "from" => {
+                "ahr" => {
+                    "acp" => { 
+                        "field" => "id",
+                        "fkey" => "current_copy",
+                        "filter" => {
+                            "circ_lib" => $$params{org_id}, "status" => [0,7]
+                        },
+                        "join" => {
+                            "acn" => {
+                                "field" => "id",
+                                "fkey" => "call_number" 
+                            },
+                            "acplo" => {
+                                "field" => "org",
+                                "fkey" => "circ_lib", 
+                                "type" => "left",
+                                "filter" => {
+                                    "location" => {"=" => {"+acp" => "location"}}
+                                }
+                            }
+                        }
+                    }
+                }
+            },
+            "where" => {
+                "+ahr" => {
+                    "capture_time" => undef,
+                    "cancel_time" => undef,
+                    "-or" => [
+                        {"expire_time" => undef },
+                        {"expire_time" => {">" => "now"}}
+                    ]
+                }
+            },
+            (@$sort ? (order_by => $sort) : ()),
+            ($$params{limit} ? (limit => $$params{limit}) : ()),
+            ($$params{offset} ? (offset => $$params{offset}) : ())
+        }, {"subquery" => 1}
+    ) or return $e->die_event;
+
+    $logger->info("about to stream back " . scalar(@$holds_ids) . " holds");
+
+    $client->respond(
+        $e->retrieve_action_hold_request([
+            $_->{"id"}, {
+                "flesh" => 3,
+                "flesh_fields" => {
+                    "ahr" => ["usr", "current_copy"],
+                    "acp" => ["location", "call_number"],
+                    "acn" => ["record"]
+                }
+            }
+        ])
+    ) foreach @$holds_ids;
+
+    $e->disconnect;
+    undef;
 }
 
 
diff --git a/Open-ILS/web/opac/extras/circ/alt_pull_list.html b/Open-ILS/web/opac/extras/circ/alt_pull_list.html
new file mode 100644 (file)
index 0000000..6302ac2
--- /dev/null
@@ -0,0 +1,139 @@
+<html>
+    <head>
+        <title>Printable Pull List</title>
+        <style type="text/css">
+            @import url('/js/dojo/dojo/resources/dojo.css');
+            @import url('/js/dojo/dijit/themes/tundra/tundra.css');
+            @import url('/js/dojo/dojox/widget/Toaster/Toaster.css');
+            @import url('/opac/skin/default/css/layout.css');
+        </style>
+        <style type="text/css">
+           /* html, body {
+                height: 100%;
+                width: 100%;
+                margin: 0px 0px 0px 0px;
+                padding: 0px 0px 0px 0px;
+                overflow: hidden;
+            } */
+            td {
+                padding-right: 1em;
+                padding-bottom: 1em;
+                border-bottom: 1px #999 dashed;
+            }
+            th {
+                text-align: left; font-weight: bold;
+                border-bottom: 1px #000 solid;
+                border-right: 1px #000 solid;
+                padding: 0.5em;
+            }
+        </style>
+        <!-- The OpenSRF API writ JS -->
+        <script language='javascript' src='/opac/common/js/utils.js' type='text/javascript'></script>
+        <script language='javascript' src='/opac/common/js/Cookies.js' type='text/javascript'></script>
+        <script language='javascript' src='/opac/common/js/CGI.js' type='text/javascript'></script>
+        <script language='javascript' src='/opac/common/js/JSON_v1.js' type='text/javascript'></script>
+        <!-- Dojo goodness -->
+        <script type="text/javascript">
+            var djConfig = {parseOnLoad:true,isDebug:false,AutoIDL:['aou','aout','pgt','ahr','acp','acn']};
+            var sort_order = ["acplo.position", "call_number", "request_time"];
+        </script>
+        <script type="text/javascript" src="/js/dojo/dojo/dojo.js"></script>
+        <script type="text/javascript" src="/js/dojo/dojo/openils_dojo.js"></script>
+        <script type="text/javascript" src="/js/dojo/dijit/dijit.js"></script>
+        <script type="text/javascript" src="/js/dojo/openils/AutoIDL.js"></script>
+        <script type="text/javascript" src="/js/dojo/openils/User.js"></script>
+        <script type="text/javascript" src="/js/dojo/openils/Util.js"></script>
+        <script type="text/javascript">
+            dojo.require("dojo.cookie");
+            dojo.require("dojox.xml.parser");
+            dojo.require("openils.BibTemplate");
+            dojo.require("openils.widget.ProgressDialog");
+
+            function my_init() {
+                var cgi = new CGI();
+                var ses = (typeof ses == "function" ? ses() : 0) ||
+                    cgi.param("ses") || dojo.cookie("ses");
+                var user = new openils.User({"authtoken": ses});
+
+                progress_dialog.show(true);
+                fieldmapper.standardRequest(
+                    ['open-ils.circ','open-ils.circ.hold_pull_list.print.stream'],
+                    { async : true,
+                      params: [
+                        user.authtoken,
+                        { org_id   : cgi.param('o'),
+                          limit    : cgi.param('limit'),
+                          offset   : cgi.param('offset'),
+                          sort     : sort_order
+                        }
+                      ],
+                      onresponse : function (r) {
+                        var hold_fm = openils.Util.readResponse(r);
+
+                        // hashify the hold
+                        var hold = hold_fm.toHash(true);
+                        hold.current_copy = hold_fm.current_copy().toHash(true);
+                        hold.current_copy.location = hold_fm.current_copy().location().toHash(true);
+                        hold.current_copy.call_number = hold_fm.current_copy().call_number().toHash(true);
+                        hold.current_copy.call_number.record = hold_fm.current_copy().call_number().record().toHash(true);
+
+                        // clone the template's html
+                        var tr = dojo.clone(
+                            dojo.query("tr", dojo.byId('template'))[0]
+                        );
+                        dojo.query("td:not([type])", tr).forEach(
+                            function(td) {
+                                td.innerHTML =
+                                    dojo.string.substitute(td.innerHTML, hold);
+                            }
+                        );
+
+                        new openils.BibTemplate({
+                            root : tr,
+                            xml  : dojox.xml.parser.parse(hold.current_copy.call_number.record.marc),
+                            delay: false
+                        });
+
+                        dojo.place(tr, "target");
+
+
+                      },
+                    oncomplete : function () {
+                     progress_dialog.hide(); window.print() }
+                    }
+                );
+            }
+            dojo.addOnLoad(my_init);
+        </script>
+    </head>
+    <body class='tundra'>
+
+        <div dojoType="openils.widget.ProgressDialog" jsId="progress_dialog"></div>
+<!-- START OF TEMPLATE SECTION -->
+
+        <table>
+            <tbody id='target'>
+                <tr>
+                    <th>Title</th>
+                    <th>Author</th>
+                    <th>Shelving Location</th>
+                    <th>Call Number</th>
+                    <th>Barcode</th>
+                </tr>
+            </tbody>
+            <tbody id='template' class='hide_me'>
+                <tr>
+                    <td type='opac/slot-data' query='datafield[tag=245]'></td>
+                    <td type='opac/slot-data' query='datafield[tag^=1]' limit='1'> </td>
+                    <td>${current_copy.location.name}</td>
+                    <td>${current_copy.call_number.label}</td>
+                    <td>${current_copy.barcode}</td>
+                </tr>
+            </tbody>
+        </table>
+
+<!-- END OF TEMPLATE SECTION -->
+
+
+    </body>
+</html>
index d1a0a09..8b2b606 100644 (file)
 <!ENTITY staff.patron.holds_overlay.print.accesskey "P">
 <!ENTITY staff.patron.holds_overlay.print_full_pull_list.label "Print Full Pull List">
 <!ENTITY staff.patron.holds_overlay.print_full_pull_list.accesskey "u">
+<!ENTITY staff.patron.holds_overlay.print_alt_pull_list.label "Print Full Pull List (Alternate strategy)">
+<!ENTITY staff.patron.holds_overlay.print_alt_pull_list.accesskey "y">
 <!ENTITY staff.patron.holds_overlay.place_hold.label "Place Hold">
 <!ENTITY staff.patron.holds_overlay.place_hold.accesskey "H">
 <!ENTITY staff.patron.holds_overlay.show_cancelled_holds.label "Show Cancelled Holds">
index b1ae0b1..678d87e 100644 (file)
@@ -327,6 +327,43 @@ patron.holds.prototype = {
                             }
                         }
                     ],
+                    'cmd_holds_print_alt' : [
+                        ['command'],
+                        function() {
+                            try {
+                                var content_params = {
+                                    "session": ses(),
+                                    "authtime": ses("authtime"),
+                                    "no_xulG": false,
+                                    "show_nav_buttons": true,
+                                    "show_print_button": false
+                                };
+                                ["url_prefix", "new_tab", "set_tab",
+                                    "close_tab", "new_patron_tab",
+                                    "set_patron_tab", "volume_item_creator",
+                                    "get_new_session",
+                                    "holdings_maintenance_tab", "set_tab_name",
+                                    "open_chrome_window", "url_prefix",
+                                    "network_meter", "page_meter",
+                                    "set_statusbar", "set_help_context"
+                                ].forEach(function(k) {
+                                    content_params[k] = xulG[k];
+                                });
+
+                                var loc = urls.XUL_BROWSER + "?url=" + window.escape(
+                                    xulG.url_prefix("/opac/extras/circ/alt_pull_list.html")
+                                );
+                                xulG.new_tab(
+                                    loc, {
+                                        "tab_name": "Printable Pull List", /* XXX i18n */
+                                        "browser": false
+                                    }, content_params
+                                );
+                            } catch (E) {
+                                g.error.sdump("D_ERROR", E);
+                            }
+                        }
+                    ],
                     'cmd_holds_print' : [
                         ['command'],
                         function() {
index df10145..7b2accd 100644 (file)
@@ -19,6 +19,7 @@
         <command id="cmd_csv_to_file" />
         <command id="cmd_holds_print" />
         <command id="cmd_holds_print_full" />
+        <command id="cmd_holds_print_alt" />
         <command id="cmd_show_catalog" />
         <command id="cmd_retrieve_patron" />
         <command id="cmd_holds_edit_desire_mint_condition" />
 
         <button id="holds_print" label="&staff.patron.holds_overlay.print.label;" command="cmd_holds_print" accesskey="&staff.patron.holds_overlay.print.accesskey;" />
         <button id="print_full_btn" hidden="true" label="&staff.patron.holds_overlay.print_full_pull_list.label;" command="cmd_holds_print_full" accesskey="&staff.patron.holds_overlay.print_full_pull_list.accesskey;" />
+        <button id="print_alt_btn" label="&staff.patron.holds_overlay.print_alt_pull_list.label;" command="cmd_holds_print_alt" accesskey="&staff.patron.holds_overlay.print_alt_pull_list.accesskey;" />
         <spacer flex="1"/>
     </hbox>