From: Chris Sharp <csharp@georgialibraries.org>
Date: Tue, 16 Jun 2020 15:56:33 +0000 (-0400)
Subject: LP1248734: Add workstation to in-house use
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=53faf16e461e6bf329d3e72915ec474df0271ec7;p=contrib%2FConifer.git

LP1248734: Add workstation to in-house use

Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Signed-off-by: Rogan Hamby <rogan.hamby@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
---

diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml
index 8b4bf85017..f7bfcf725c 100644
--- a/Open-ILS/examples/fm_IDL.xml
+++ b/Open-ILS/examples/fm_IDL.xml
@@ -2402,11 +2402,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 			<field reporter:label="Item" name="item" reporter:datatype="int" />
 			<field reporter:label="Using Library" name="org_unit" reporter:datatype="org_unit"/>
 			<field reporter:label="Recording Staff" name="staff" reporter:datatype="link"/>
+			<field reporter:label="Workstation" name="workstation" reporter:datatype="link"/>
 			<field reporter:label="Use Date/Time" name="use_time" reporter:datatype="timestamp"/>
 		</fields>
 		<links>
 			<link field="item" reltype="has_a" key="id" map="" class="acp"/>
 			<link field="staff" reltype="has_a" key="id" map="" class="au"/>
+			<link field="workstation" reltype="has_a" key="id" map="" class="aws"/>
 			<link field="org_unit" reltype="has_a" key="id" map="" class="aou"/>
 		</links>
 		<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
@@ -2421,11 +2423,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 			<field reporter:label="Item Type" name="item_type" reporter:datatype="link"/>
 			<field reporter:label="Using Library" name="org_unit" reporter:datatype="org_unit"/>
 			<field reporter:label="Recording Staff" name="staff" reporter:datatype="link"/>
+			<field reporter:label="Workstation" name="workstation" reporter:datatype="link"/>
 			<field reporter:label="Use Date/Time" name="use_time" reporter:datatype="timestamp"/>
 		</fields>
 		<links>
 			<link field="item_type" reltype="has_a" key="id" map="" class="cnct"/>
 			<link field="staff" reltype="has_a" key="id" map="" class="au"/>
+			<link field="workstation" reltype="has_a" key="id" map="" class="aws"/>
 			<link field="org_unit" reltype="has_a" key="id" map="" class="aou"/>
 		</links>
 		<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
index af9c9af9ab..bb4412b6d9 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
@@ -773,6 +773,7 @@ sub create_in_house_use {
         }
 
         $ihu->staff($e->requestor->id);
+        $ihu->workstation($e->requestor->wsid);
         $ihu->org_unit($org);
         $ihu->use_time($use_time);
 
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI.pm
index 599764ff3e..1a43510944 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI.pm
@@ -702,6 +702,7 @@ sub modify_from_fieldmapper {
 
     action::in_house_use->has_a( org_unit => 'actor::org_unit' );
     action::in_house_use->has_a( staff => 'actor::user' );
+    action::in_house_use->has_a( workstation => 'actor::workstation' );
     action::in_house_use->has_a( item => 'asset::copy' );
 
     action::non_cataloged_circulation->has_a( circ_lib => 'actor::org_unit' );
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/action.pm
index 5a59393837..1dd595dcc3 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/action.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/action.pm
@@ -10,14 +10,14 @@ package action::in_house_use;
 use base qw/action/;
 __PACKAGE__->table('action_in_house_use');
 __PACKAGE__->columns(Primary => 'id');
-__PACKAGE__->columns(Essential => qw/item staff org_unit use_time/);
+__PACKAGE__->columns(Essential => qw/item staff workstation org_unit use_time/);
 #-------------------------------------------------------------------------------
 
 package action::non_cat_in_house_use;
 use base qw/action/;
 __PACKAGE__->table('action_non_cat_in_house_use');
 __PACKAGE__->columns(Primary => 'id');
-__PACKAGE__->columns(Essential => qw/item_type staff org_unit use_time/);
+__PACKAGE__->columns(Essential => qw/item_type staff workstation org_unit use_time/);
 #-------------------------------------------------------------------------------
 
 package action::non_cataloged_circulation;
diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql
index 8d8163b6f9..685a4c3db5 100644
--- a/Open-ILS/src/sql/Pg/090.schema.action.sql
+++ b/Open-ILS/src/sql/Pg/090.schema.action.sql
@@ -25,10 +25,12 @@ CREATE TABLE action.in_house_use (
 	id		SERIAL				PRIMARY KEY,
 	item		BIGINT				NOT NULL, -- REFERENCES asset.copy (id) DEFERRABLE INITIALLY DEFERRED, -- XXX could be an serial.issuance
 	staff		INT				NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED,
+	workstation INT				REFERENCES actor.workstation (id) DEFERRABLE INITIALLY DEFERRED,
 	org_unit	INT				NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED,
 	use_time	TIMESTAMP WITH TIME ZONE	NOT NULL DEFAULT NOW()
 );
 CREATE INDEX action_in_house_use_staff_idx      ON action.in_house_use ( staff );
+CREATE INDEX action_in_house_use_ws_idx ON action.in_house_use ( workstation );
 
 CREATE TABLE action.non_cataloged_circulation (
 	id		SERIAL				PRIMARY KEY,
@@ -45,10 +47,12 @@ CREATE TABLE action.non_cat_in_house_use (
 	id		SERIAL				PRIMARY KEY,
 	item_type	BIGINT				NOT NULL REFERENCES config.non_cataloged_type(id) DEFERRABLE INITIALLY DEFERRED,
 	staff		INT				NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED,
+	workstation INT				REFERENCES actor.workstation (id) DEFERRABLE INITIALLY DEFERRED,
 	org_unit	INT				NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED,
 	use_time	TIMESTAMP WITH TIME ZONE	NOT NULL DEFAULT NOW()
 );
 CREATE INDEX non_cat_in_house_use_staff_idx ON action.non_cat_in_house_use ( staff );
+CREATE INDEX non_cat_in_house_use_ws_idx ON action.non_cat_in_house_use ( workstation );
 
 CREATE TABLE action.survey (
 	id		SERIAL				PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1248734_add_ws_to_ihu.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1248734_add_ws_to_ihu.sql
new file mode 100644
index 0000000000..5cb74bfb2d
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1248734_add_ws_to_ihu.sql
@@ -0,0 +1,8 @@
+BEGIN;
+
+--SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+ALTER TABLE action.in_house_use ADD COLUMN workstation INT REFERENCES actor.workstation (id) DEFERRABLE INITIALLY DEFERRED;
+ALTER TABLE action.non_cat_in_house_use ADD COLUMN workstation INT REFERENCES actor.workstation (id) DEFERRABLE INITIALLY DEFERRED;
+
+COMMIT;