<field reporter:label="Billing Totals" name="billing_total" oils_persist:virtual="true" reporter:datatype="money"/>
<field reporter:label="Payment Totals" name="payment_total" oils_persist:virtual="true" reporter:datatype="money"/>
<field reporter:label="Unrecovered Debt" name="unrecovered" reporter:datatype="bool"/>
+ <field reporter:label="Shelving Location" name="copy_location" reporter:datatype="link"/>
+ <field reporter:label="Archived Patron Stat-Cat Entries" name="aaactsc_entries" oils_persist:virtual="true" reporter:datatype="link"/>
+ <field reporter:label="Archived Copy Stat-Cat Entries" name="aaasc_entries" oils_persist:virtual="true" reporter:datatype="link"/>
</fields>
<links>
<link field="billable_transaction" reltype="might_have" key="id" map="" class="mbt"/>
<link field="checkin_workstation" reltype="has_a" key="id" map="" class="aws"/>
<link field="parent_circ" reltype="has_a" key="id" map="" class="circ"/>
<link field="renewals" reltype="has_many" key="parent_circ" map="" class="circ"/>
+ <link field="copy_location" reltype="has_a" key="id" map="" class="acpl"/>
+ <link field="aaactsc_entries" reltype="has_many" key="xact" map="" class="aaactsc"/>
+ <link field="aaasc_entries" reltype="has_many" key="xact" map="" class="aaasc"/>
</links>
</class>
<class id="combcirc" controller="open-ils.cstore" oils_obj:fieldmapper="action::all_circulation" oils_persist:tablename="action.all_circulation" reporter:core="true" reporter:label="Combined Aged and Active Circulations" oils_persist:readonly="true">
<field reporter:label="Copy Owning Library" name="copy_owning_lib" reporter:datatype="link"/>
<field reporter:label="Copy Circulating Library" name="copy_circ_lib" reporter:datatype="link"/>
<field reporter:label="Bib Record" name="copy_bib_record" reporter:datatype="link"/>
+ <field reporter:label="Archived Patron Stat-Cat Entries" name="aaactsc_entries" oils_persist:virtual="true" reporter:datatype="link"/>
+ <field reporter:label="Archived Copy Stat-Cat Entries" name="aaasc_entries" oils_persist:virtual="true" reporter:datatype="link"/>
</fields>
<links>
<link field="billable_transaction" reltype="might_have" key="id" map="" class="mbt"/>
<link field="copy_owning_lib" reltype="has_a" key="id" map="" class="aou"/>
<link field="copy_circ_lib" reltype="has_a" key="id" map="" class="aou"/>
<link field="copy_bib_record" reltype="has_a" key="id" map="" class="bre"/>
+ <link field="aaactsc_entries" reltype="has_many" key="xact" map="" class="aaactsc"/>
+ <link field="aaasc_entries" reltype="has_many" key="xact" map="" class="aaasc"/>
</links>
</class>
<class id="acirc" controller="open-ils.cstore" oils_obj:fieldmapper="action::aged_circulation" oils_persist:tablename="action.aged_circulation" reporter:core="true" reporter:label="Aged (patronless) Circulation">
<field reporter:label="Copy Owning Library" name="copy_owning_lib" reporter:datatype="link"/>
<field reporter:label="Copy Circulating Library" name="copy_circ_lib" reporter:datatype="link"/>
<field reporter:label="Bib Record" name="copy_bib_record" reporter:datatype="link"/>
+ <field reporter:label="Archived Patron Stat-Cat Entries" name="aaactsc_entries" oils_persist:virtual="true" reporter:datatype="link"/>
+ <field reporter:label="Archived Copy Stat-Cat Entries" name="aaasc_entries" oils_persist:virtual="true" reporter:datatype="link"/>
</fields>
<links>
<link field="billable_transaction" reltype="might_have" key="id" map="" class="mbt"/>
<link field="checkin_workstation" reltype="has_a" key="id" map="" class="aws"/>
<link field="parent_circ" reltype="might_have" key="id" map="" class="circ"/>
<link field="renewals" reltype="has_many" key="parent_circ" map="" class="circ"/>
+ <link field="aaactsc_entries" reltype="has_many" key="xact" map="" class="aaactsc"/>
+ <link field="aaasc_entries" reltype="has_many" key="xact" map="" class="aaasc"/>
</links>
</class>
<field reporter:label="SIP Field" name="sip_field" reporter:datatype="link"/>
<field reporter:label="SIP Format" name="sip_format" reporter:datatype="text"/>
<field reporter:label="Required" name="required" reporter:datatype="bool"/>
+ <field reporter:label="Checkout Archive" name="checkout_archive" reporter:datatype="bool"/>
</fields>
<links>
<link field="owner" reltype="has_a" key="id" map="" class="aou"/>
<field reporter:label="User Summary" name="usr_summary" reporter:datatype="bool"/>
<field reporter:label="SIP Field" name="sip_field" reporter:datatype="link"/>
<field reporter:label="SIP Format" name="sip_format" reporter:datatype="text"/>
+ <field reporter:label="Checkout Archive" name="checkout_archive" reporter:datatype="bool"/>
</fields>
<links>
<link field="owner" reltype="has_a" key="id" map="" class="aou"/>
</actions>
</permacrud>
</class>
+ <class id="aaactsc" controller="open-ils.reporter-store" oils_obj:fieldmapper="action::archive_actor_stat_cat" oils_persist:tablename="action.archive_actor_stat_cat" reporter:label="Circ-Archived Patron Statistical Category Entries">
+ <fields oils_persist:primary="id" oils_persist:sequence="action.archive_actor_stat_cat_id_seq">
+ <field reporter:label="ID" name="id" reporter:datatype="id"/>
+ <field reporter:label="Circ" name="xact" reporter:datatype="link"/>
+ <field reporter:label="Statistical Category" name="stat_cat" reporter:datatype="link"/>
+ <field reporter:label="Entry Value" name="value" reporter:datatype="text"/>
+ </fields>
+ <links>
+ <link field="xact" reltype="has_a" key="id" map="" class="combcirc"/>
+ <link field="stat_cat" reltype="has_a" key="id" map="" class="actsc"/>
+ </links>
+ </class>
+ <class id="aaasc" controller="open-ils.reporter-store" oils_obj:fieldmapper="action::archive_asset_stat_cat" oils_persist:tablename="action.archive_asset_stat_cat" reporter:label="Circ-Archived Copy Statistical Category Entries">
+ <fields oils_persist:primary="id" oils_persist:sequence="action.archive_actor_stat_cat_id_seq">
+ <field reporter:label="ID" name="id" reporter:datatype="id"/>
+ <field reporter:label="Circ" name="xact" reporter:datatype="link"/>
+ <field reporter:label="Statistical Category" name="stat_cat" reporter:datatype="link"/>
+ <field reporter:label="Entry Value" name="value" reporter:datatype="text"/>
+ </fields>
+ <links>
+ <link field="xact" reltype="has_a" key="id" map="" class="combcirc"/>
+ <link field="stat_cat" reltype="has_a" key="id" map="" class="asc"/>
+ </links>
+ </class>
<!-- ********************************************************************************************************************* -->
stop_fines xact_finish due_date opac_renewal
checkin_staff circ_staff circ_lib checkin_lib
stop_fines_time checkin_time desk_renewal
- phone_renewal create_time/);
+ phone_renewal create_time copy_location/);
#-------------------------------------------------------------------------------
__PACKAGE__->table( 'actor_stat_cat' );
__PACKAGE__->columns( Primary => qw/id/ );
-__PACKAGE__->columns( Essential => qw/owner name opac_visible usr_summary sip_field sip_format/ );
+__PACKAGE__->columns( Essential => qw/owner name opac_visible usr_summary sip_field sip_format checkout_archive/ );
#-------------------------------------------------------------------------------
package actor::stat_cat_entry;
__PACKAGE__->table( 'asset_stat_cat' );
__PACKAGE__->columns( Primary => qw/id/ );
-__PACKAGE__->columns( Essential => qw/owner name opac_visible sip_field sip_format required/ );
+__PACKAGE__->columns( Essential => qw/owner name opac_visible sip_field sip_format required checkout_archive/ );
#-------------------------------------------------------------------------------
package asset::stat_cat_entry;
usr_summary BOOL NOT NULL DEFAULT FALSE,
sip_field CHAR(2) REFERENCES actor.stat_cat_sip_fields(field) ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
sip_format TEXT,
+ checkout_archive BOOL NOT NULL DEFAULT FALSE,
CONSTRAINT sc_once_per_owner UNIQUE (owner,name)
);
COMMENT ON TABLE actor.stat_cat IS $$
required BOOL NOT NULL DEFAULT FALSE,
sip_field CHAR(2) REFERENCES asset.stat_cat_sip_fields(field) ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
sip_format TEXT,
+ checkout_archive BOOL NOT NULL DEFAULT FALSE,
CONSTRAINT sc_once_per_owner UNIQUE (owner,name)
);
FOR EACH ROW
EXECUTE PROCEDURE action.survey_response_answer_date_fixup ();
+CREATE TABLE action.archive_actor_stat_cat (
+ id BIGSERIAL PRIMARY KEY,
+ xact BIGINT NOT NULL, -- action.circulation (+aged/all)
+ stat_cat INT NOT NULL,
+ value TEXT NOT NULL
+);
+
+CREATE TABLE action.archive_asset_stat_cat (
+ id BIGSERIAL PRIMARY KEY,
+ xact BIGINT NOT NULL, -- action.circulation (+aged/all)
+ stat_cat INT NOT NULL,
+ value TEXT NOT NULL
+);
+
CREATE TABLE action.circulation (
target_copy BIGINT NOT NULL, -- asset.copy.id
checkin_workstation INT REFERENCES actor.workstation(id)
ON DELETE SET NULL
DEFERRABLE INITIALLY DEFERRED,
+ copy_location INT NOT NULL DEFAULT 1 REFERENCES asset.copy_location (id) DEFERRABLE INITIALLY DEFERRED,
checkin_scan_time TIMESTAMP WITH TIME ZONE
) INHERITS (money.billable_xact);
ALTER TABLE action.circulation ADD PRIMARY KEY (id);
CREATE TRIGGER push_due_date_tgr BEFORE INSERT OR UPDATE ON action.circulation FOR EACH ROW EXECUTE PROCEDURE action.push_circ_due_time();
+CREATE OR REPLACE FUNCTION action.fill_circ_copy_location () RETURNS TRIGGER AS $$
+BEGIN
+ SELECT INTO NEW.copy_location location FROM asset.copy WHERE id = NEW.target_copy;
+ RETURN NEW;
+END;
+$$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER fill_circ_copy_location_tgr BEFORE INSERT ON action.circulation FOR EACH ROW EXECUTE PROCEDURE action.fill_circ_copy_location();
+
+CREATE OR REPLACE FUNCTION action.archive_stat_cats () RETURNS TRIGGER AS $$
+BEGIN
+ INSERT INTO action.archive_actor_stat_cat(xact, stat_cat, value)
+ SELECT NEW.id, asceum.stat_cat, asceum.stat_cat_entry
+ FROM actor.stat_cat_entry_usr_map asceum
+ JOIN actor.stat_cat sc ON asceum.stat_cat = sc.id
+ WHERE NEW.usr = asceum.target_usr AND sc.checkout_archive;
+ INSERT INTO action.archive_asset_stat_cat(xact, stat_cat, value)
+ SELECT NEW.id, ascecm.stat_cat, asce.value
+ FROM asset.stat_cat_entry_copy_map ascecm
+ JOIN asset.stat_cat sc ON ascecm.stat_cat = sc.id
+ JOIN asset.stat_cat_entry asce ON ascecm.stat_cat_entry = asce.id
+ WHERE NEW.target_copy = ascecm.owning_copy AND sc.checkout_archive;
+ RETURN NULL;
+END;
+$$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER archive_stat_cats_tgr AFTER INSERT ON action.circulation FOR EACH ROW EXECUTE PROCEDURE action.archive_stat_cats();
+
CREATE TABLE action.aged_circulation (
usr_post_code TEXT,
usr_home_ou INT NOT NULL,
usr_profile INT NOT NULL,
usr_birth_year INT,
copy_call_number INT NOT NULL,
- copy_location INT NOT NULL,
copy_owning_lib INT NOT NULL,
copy_circ_lib INT NOT NULL,
copy_bib_record BIGINT NOT NULL,
FROM action.aged_circulation
UNION ALL
SELECT DISTINCT circ.id,COALESCE(a.post_code,b.post_code) AS usr_post_code, p.home_ou AS usr_home_ou, p.profile AS usr_profile, EXTRACT(YEAR FROM p.dob)::INT AS usr_birth_year,
- cp.call_number AS copy_call_number, cp.location AS copy_location, cn.owning_lib AS copy_owning_lib, cp.circ_lib AS copy_circ_lib,
+ cp.call_number AS copy_call_number, circ.copy_location, cn.owning_lib AS copy_owning_lib, cp.circ_lib AS copy_circ_lib,
cn.record AS copy_bib_record, circ.xact_start, circ.xact_finish, circ.target_copy, circ.circ_lib, circ.circ_staff, circ.checkin_staff,
circ.checkin_lib, circ.renewal_remaining, circ.grace_period, circ.due_date, circ.stop_fines_time, circ.checkin_time, circ.create_time, circ.duration,
circ.fine_interval, circ.recurring_fine, circ.max_fine, circ.phone_renewal, circ.desk_renewal, circ.opac_renewal, circ.duration_rule,
--- /dev/null
+-- New tables
+
+CREATE TABLE action.archive_actor_stat_cat (
+ id BIGSERIAL PRIMARY KEY,
+ xact BIGINT NOT NULL,
+ stat_cat INT NOT NULL,
+ value TEXT NOT NULL
+);
+
+CREATE TABLE action.archive_asset_stat_cat (
+ id BIGSERIAL PRIMARY KEY,
+ xact BIGINT NOT NULL,
+ stat_cat INT NOT NULL,
+ value TEXT NOT NULL
+);
+
+-- Add columns to existing tables
+
+-- Archive Flag Columns
+ALTER TABLE actor.stat_cat
+ ADD COLUMN checkout_archive BOOL NOT NULL DEFAULT FALSE;
+ALTER TABLE asset.stat_cat
+ ADD COLUMN checkout_archive BOOL NOT NULL DEFAULT FALSE;
+
+-- Circulation copy column
+ALTER TABLE action.circulation
+ ADD COLUMN copy_location INT NOT NULL DEFAULT 1 REFERENCES asset.copy_location(id) DEFERRABLE INITIALLY DEFERRED;
+
+-- Update action.circulation with real copy_location numbers instead of all "Stacks"
+UPDATE action.circulation circ SET copy_location = ac.location FROM asset.copy ac WHERE ac.id = circ.target_copy;
+
+-- Create trigger function to auto-fill the copy_location field
+CREATE OR REPLACE FUNCTION action.fill_circ_copy_location () RETURNS TRIGGER AS $$
+BEGIN
+ SELECT INTO NEW.copy_location location FROM asset.copy WHERE id = NEW.target_copy;
+ RETURN NEW;
+END;
+$$ LANGUAGE PLPGSQL;
+
+-- Create trigger function to auto-archive stat cat entries
+CREATE OR REPLACE FUNCTION action.archive_stat_cats () RETURNS TRIGGER AS $$
+BEGIN
+ INSERT INTO action.archive_actor_stat_cat(xact, stat_cat, value)
+ SELECT NEW.id, asceum.stat_cat, asceum.stat_cat_entry
+ FROM actor.stat_cat_entry_usr_map asceum
+ JOIN actor.stat_cat sc ON asceum.stat_cat = sc.id
+ WHERE NEW.usr = asceum.target_usr AND sc.checkout_archive;
+ INSERT INTO action.archive_asset_stat_cat(xact, stat_cat, value)
+ SELECT NEW.id, ascecm.stat_cat, asce.value
+ FROM asset.stat_cat_entry_copy_map ascecm
+ JOIN asset.stat_cat sc ON ascecm.stat_cat = sc.id
+ JOIN asset.stat_cat_entry asce ON ascecm.stat_cat_entry = asce.id
+ WHERE NEW.target_copy = ascecm.owning_copy AND sc.checkout_archive;
+ RETURN NULL;
+END;
+$$ LANGUAGE PLPGSQL;
+
+-- Apply triggers
+CREATE TRIGGER fill_circ_copy_location_tgr BEFORE INSERT ON action.circulation FOR EACH ROW EXECUTE PROCEDURE action.fill_circ_copy_location();
+CREATE TRIGGER archive_stat_cats_tgr AFTER INSERT ON action.circulation FOR EACH ROW EXECUTE PROCEDURE action.archive_stat_cats();
+
--- /dev/null
+-- Update view to use circ's copy_location field instead of the copy's current copy_location field
+CREATE OR REPLACE VIEW action.all_circulation AS
+ SELECT id,usr_post_code, usr_home_ou, usr_profile, usr_birth_year, copy_call_number, copy_location,
+ copy_owning_lib, copy_circ_lib, copy_bib_record, xact_start, xact_finish, target_copy,
+ circ_lib, circ_staff, checkin_staff, checkin_lib, renewal_remaining, grace_period, due_date,
+ stop_fines_time, checkin_time, create_time, duration, fine_interval, recurring_fine,
+ max_fine, phone_renewal, desk_renewal, opac_renewal, duration_rule, recurring_fine_rule,
+ max_fine_rule, stop_fines, workstation, checkin_workstation, checkin_scan_time, parent_circ
+ FROM action.aged_circulation
+ UNION ALL
+ SELECT DISTINCT circ.id,COALESCE(a.post_code,b.post_code) AS usr_post_code, p.home_ou AS usr_home_ou, p.profile AS usr_profile, EXTRACT(YEAR FROM p.dob)::INT AS usr_birth_year,
+ cp.call_number AS copy_call_number, circ.copy_location, cn.owning_lib AS copy_owning_lib, cp.circ_lib AS copy_circ_lib,
+ cn.record AS copy_bib_record, circ.xact_start, circ.xact_finish, circ.target_copy, circ.circ_lib, circ.circ_staff, circ.checkin_staff,
+ circ.checkin_lib, circ.renewal_remaining, circ.grace_period, circ.due_date, circ.stop_fines_time, circ.checkin_time, circ.create_time, circ.duration,
+ circ.fine_interval, circ.recurring_fine, circ.max_fine, circ.phone_renewal, circ.desk_renewal, circ.opac_renewal, circ.duration_rule,
+ circ.recurring_fine_rule, circ.max_fine_rule, circ.stop_fines, circ.workstation, circ.checkin_workstation, circ.checkin_scan_time,
+ circ.parent_circ
+ FROM action.circulation circ
+ JOIN asset.copy cp ON (circ.target_copy = cp.id)
+ JOIN asset.call_number cn ON (cp.call_number = cn.id)
+ JOIN actor.usr p ON (circ.usr = p.id)
+ LEFT JOIN actor.usr_address a ON (p.mailing_address = a.id)
+ LEFT JOIN actor.usr_address b ON (p.billing_address = b.id);
<!ENTITY staff.server.admin.stat_cat.sip_field.label "SIP Field">
<!ENTITY staff.server.admin.stat_cat.sip_format.label "SIP Format">
<!ENTITY staff.server.admin.stat_cat.sip_field.none.label "No SIP">
+<!ENTITY staff.server.admin.stat_cat.checkout_archive "Archive with Circs">
+<!ENTITY staff.server.admin.stat_cat.checkout_archive.label "Circ Archive">
<!ENTITY staff.server.admin.upload_xacts.title "Upload Offline Transactions">
<!ENTITY staff.server.admin.upload_xacts.header "Uploading transactions...">
<!ENTITY staff.server.admin.upload_xacts.upload "Upload">
$n(row, 'sc_sip_format_td').appendChild( text( cat.sip_format() ) );
+ if(isTrue(cat.checkout_archive()))
+ unHideMe($n(row, 'sc_checkout_archive_on'));
+ else
+ unHideMe($n(row, 'sc_checkout_archive'));
if(type == ACTOR) {
if(isTrue(cat.usr_summary()))
var visible = 0;
var required = 0;
var usr_summary = 0;
+ var checkout_archive = 0;
if( $('sc_make_opac_visible').checked) visible = 1;
if( $('sc_make_required').checked) required = 1;
if( $('sc_make_usr_summary').checked) usr_summary = 1;
+ if( $('sc_make_checkout_archive').checked) checkout_archive = 1;
var cat;
if( type == ACTOR ) {
cat.opac_visible(visible);
cat.name(name);
+ cat.checkout_archive(checkout_archive);
cat.owner(getSelectorVal($('sc_owning_lib_selector')));
cat.isnew(1);
'sc_edit_opac_visibility').checked = true;
}
+ $n( row, 'sc_edit_checkout_archive' ).checked = isTrue(cat.checkout_archive());
+
$n(row, 'sc_edit_submit').onclick =
function() { scEditGo( type, cat, row, selector ); };
cat.owner( newlib );
cat.entries(null);
cat.opac_visible(0);
+ cat.checkout_archive($n(row, 'sc_edit_checkout_archive').checked ? 1 : 0);
if(sip_field.length == 2) cat.sip_field( sip_field );
else cat.sip_field(null);
cat.sip_format($n(row, 'sc_edit_sip_format').value);
<span>&staff.server.admin.stat_cat.off;</span>
<input type='radio' name='usr_summary' checked='checked'> </input>
</td>
+ <td>&staff.server.admin.stat_cat.checkout_archive;</td>
+ <td>
+ <span>&staff.server.admin.stat_cat.on;</span>
+ <input type='radio' name='checkout_archive' id='sc_make_checkout_archive'> </input>
+ <span>&staff.server.admin.stat_cat.off;</span>
+ <input type='radio' name='checkout_archive' checked='checked'> </input>
+ </td>
</tr>
<tr>
<td>&staff.server.admin.stat_cat.sip_field;</td>
<td id='sc_usr_summary_label'>&staff.server.admin.stat_cat.usr_summary.label;</td>
<td>&staff.server.admin.stat_cat.sip_field.label;</td>
<td>&staff.server.admin.stat_cat.sip_format.label;</td>
+ <td>&staff.server.admin.stat_cat.checkout_archive.label;</td>
<td>&staff.server.admin.stat_cat.entries.label;</td>
<td>&staff.server.admin.stat_cat.add_entry;</td>
<td>&staff.server.admin.stat_cat.edit;</td>
</td>
<td name='sc_sip_format_td'/>
<td>
+ <span class='hide_me' name='sc_checkout_archive_on'>&staff.server.admin.stat_cat.on;</span>
+ <span class='hide_me' name='sc_checkout_archive'>&staff.server.admin.stat_cat.off;</span>
+ </td>
+ <td>
<select class='selector' name='sc_entries_selector'>
<option>&staff.server.admin.stat_cat.none;</option>
</select>
<td name='sc_edit_sip_format_td'>
<input type='text' name='sc_edit_sip_format'/>
</td>
+ <td>
+ <input type='checkbox' name='sc_edit_checkout_archive'/>
+ </td>
<td colspan='4'>
<span class='padded'>
<input type='submit' value='&staff.server.admin.stat_cat.edit_submit;' name='sc_edit_submit'/>