Add USudbury "moveto" interface feature/move_to_storage_2_7
authorDan Scott <dscott@laurentian.ca>
Mon, 31 Aug 2015 20:59:46 +0000 (16:59 -0400)
committerDan Scott <dscott@laurentian.ca>
Mon, 31 Aug 2015 20:59:46 +0000 (16:59 -0400)
This one also undeletes the copies, call numbers, and records as we go,
as presumably we don't want these things to be deleted if we're moving
them.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/templates/cat/moveto/usudbury.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/cat/moveto/usudbury.js [new file with mode: 0644]

diff --git a/Open-ILS/src/templates/cat/moveto/usudbury.tt2 b/Open-ILS/src/templates/cat/moveto/usudbury.tt2
new file mode 100644 (file)
index 0000000..0fd7181
--- /dev/null
@@ -0,0 +1,30 @@
+[% ctx.page_title = 'Move item to University of Sudbury' %]
+[% WRAPPER base.tt2 %]
+<script src='[% ctx.media_prefix %]/js/ui/default/cat/moveto/usudbury.js'> </script>
+
+<style>
+    label { margin-left: 2em; }
+    .dijitTextBoxFocused, .dijitFocused { border:1px dashed #3e3e3e; color: #303030; font-weight:bold;}
+    .alert { color: red; font-weight: bold; }
+    #resultsDiv { font-size: larger; margin-top: 3em; margin-left: 2em; }
+    h1 { margin-left: 1em; font-weight: bold; }
+    #barcodeForm { margin-top: 2em; }
+
+</style>
+
+<h1>Move item to University of Sudbury</h1>
+
+<form method="get" action="/eg/cat/moveto/usudbury">
+     <table id="barcodeForm">
+      <tr>
+        <td><label for="barcode" style="font-size: larger;">Barcode</label></td>
+        <td><input type="text" id="barcode" name="barcode" dojoType="dijit.form.TextBox" style="margin-left: 1em;"/></td>
+      </tr>
+     </table>
+</form>
+
+<div id="resultsDiv"></div>
+
+[% END %]
+
+
diff --git a/Open-ILS/web/js/ui/default/cat/moveto/usudbury.js b/Open-ILS/web/js/ui/default/cat/moveto/usudbury.js
new file mode 100644 (file)
index 0000000..bead3c5
--- /dev/null
@@ -0,0 +1,99 @@
+dojo.require('fieldmapper.IDL');
+dojo.require('openils.PermaCrud');
+dojo.require('dojo.date');
+dojo.require('openils.CGI');
+dojo.require('openils.XUL');
+
+var pcrud;
+var pcrudReader;
+var staff;
+var copy;
+var volume;
+var record;
+var rmsr;
+var tbody;
+var cgi;
+
+if(!window.xulG) var xulG = null;
+
+function load() {
+    staff = new openils.User().user;
+    pcrud = new openils.PermaCrud();
+    pcrudReader = new openils.PermaCrud();
+    cgi = new openils.CGI();
+    var barcode = cgi.param('barcode');
+
+    if(xulG) {
+        if(xulG.ses) openils.User.authtoken = xulG.ses;
+        if(xulG.usr !== null) userId = xulG.usr
+        if(xulG.params) {
+            var parms = xulG.params;
+            if(parms.ses) 
+                openils.User.authtoken = parms.ses;
+            if(parms.usr !== null)
+                userId = parms.usr
+        }
+    }
+
+    dojo.byId("barcode").focus();
+    moveCopy(barcode);
+}
+
+function moveCopy(barcode) {
+    if (!barcode) {
+        // Just display the barcode entry form
+        return;
+    }
+/*
+    copy = fieldmapper.standardRequest(
+        ['open-ils.search', 'open-ils.search.asset.copy.find_by_barcode'],
+        {params: [barcode]}
+    );
+*/
+    /* Get rid of non-numeric barcode characters - probably need to configure the cheapo scanner */
+    barcode = barcode.replace(/[^0-9]/g, '');
+    copy = pcrud.search('acp', {"barcode":barcode});
+    // There can be only one copy
+    copy = copy[0];
+    if (!copy.location) {
+       dojo.place('<div class="alert">Barcode [' + barcode + '] was not found!</div>', 'resultsDiv', 'only');
+       return;
+    }
+    copy.location(330);
+    copy.circ_lib(107);
+    copy.deleted(false)
+    copy.ischanged(true);
+    pcrud.update(copy);
+
+    volume = pcrudReader.retrieve("acn", copy.call_number());
+    volume.owning_lib(107);
+    volume.deleted(false);
+    pcrud.update(volume);
+
+    record = pcrudReader.retrieve("bre", volume.record());
+    record.active(true);
+    record.deleted(false);
+    pcrud.update(record);
+
+    dojo.place("<div class='barcode'>" + copy.barcode() + "</div>", 'resultsDiv', 'only');
+    dojo.place("<div class='call_number'>" + volume.label() + "</div>", 'resultsDiv', 'last');
+    dojo.place("<div style='display:none'>" + record.marc() + "</div>", dojo.body(), 'last');
+    dojo.place("<div class='title' id='titleDiv'></div>", 'resultsDiv', 'last');
+    dojo.query("datafield[tag='245'] subfield").forEach(function(node, index, arr) {
+        dojo.place("<span class='title'>" + node.innerHTML + " </span>", 'titleDiv', 'last');
+    });
+}
+
+function moveCopyRefresh() {
+    var usr = cgi.param('barcode');
+    var href = location.href.replace(/\?.*/, '');
+    href += ((usr) ? '?barcode=' + barcode : '');
+    location.href = href;
+}
+
+function moveCopyRefreshXUL(newuser) {
+    if (window.xulG && typeof window.xulG.on_save == 'function') 
+        window.xulG.on_save(newuser);
+}
+
+openils.Util.addOnLoad(load);