initial checkouts-by-circ-mods support
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 9 Mar 2008 01:03:32 +0000 (01:03 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 9 Mar 2008 01:03:32 +0000 (01:03 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@8930 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/javascript/backend/circ/circ_lib.js
Open-ILS/src/perlmods/OpenILS/Application/Circ/ScriptBuilder.pm

index a39794b..621e453 100644 (file)
@@ -205,7 +205,12 @@ function hasCommonAncestor( org1, org2, depth ) {
        return false;
 }
 
-
+/* returns a dictionary of circmod : count for checked out items */
+function checkoutsByCircModifier(userid) {
+    var key = scratchKey();
+    __OILS_FUNC_userCircsByCircmod(scratchPad(key), userid);
+    return getScratch(key);
+}
 
 /* useful for testing */
 function die(msg) {
index 41ab511..3f8d46f 100644 (file)
@@ -390,6 +390,45 @@ sub insert_user_funcs {
                        return $val;
                }
        );
+
+       $runner->insert(__OILS_FUNC_userCircsByCircmod  => 
+               sub {
+                       my( $write_key, $userid ) = @_;
+
+            # this bug ugly thing generates a count of checkouts by circ_modifier
+             my $query = {
+                "select" => {
+                    "acp" => ["circ_modifier"]
+                    "circ"=>[{
+                        "aggregate"=>1,
+                        "transform"=>"count",
+                        "alias"=>"count",
+                        "column"=>"id"
+                    }],
+                },
+                "from"=>{"acp"=>{"circ"=>{"field"=>"target_copy","fkey"=>"id"}}},
+                "where"=>{
+                    "+circ"=>{
+                        "checkin_time"=>undef,
+                        "usr"=>$userid,
+                        "-or"=>[
+                            {"stop_fines"=>["LOST","LONGOVERDUE","CLAIMSRETURNED"]},
+                            {"stop_fines"=>undef}
+                        ]
+                    }
+                }
+            };
+
+            my $mods = $e->json_query($query);
+            my $breakdown = {};
+            $breakdown->{$_->{circ_modifier}} = $_->{count} for @$mods;
+            use OpenSRF::Utils::JSON;
+            $logger->info("script_runner: Loaded checkouts by circ_modifier breakdown:". 
+                OpenSRF::Utils::JSON->perl2JSON($breakdown));
+                       $runner->insert($write_key, $breakdown, 1) if (keys %$breakdown);
+               }
+       );
+
 }