Sip Statcats - Actor/Asset Statcats via SIP2
authorThomas Berezansky <tsbere@mvlc.org>
Sun, 29 May 2011 01:44:35 +0000 (21:44 -0400)
committerBill Erickson <berick@esilibrary.com>
Fri, 3 Jun 2011 12:48:53 +0000 (08:48 -0400)
Stat cats can now have a sip_field and sip_format.
sip_field is the field identifier code, sip_format is one of the following:

1 - Null/Empty, places stat cat value in as-is
2 - A plain string, placed in value as-is when stat cat has value
3 - A plain string with a %s, 1 and 2 combined, where the stat cat value replaces the %s
4 - A regular expression surrounded by | characters (ex, |([0-9]*) -|):
    If the regular expression does not match the value, nothing
    If the regular expression matches and has a capture group, the captured group
    If the regular expression matches and does not have a capture group, the entire match

The | was used because it would otherwise be stripped from the final result anyway.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
14 files changed:
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/actor.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/asset.pm
Open-ILS/src/perlmods/lib/OpenILS/SIP/Item.pm
Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm
Open-ILS/src/sql/Pg/005.schema.actors.sql
Open-ILS/src/sql/Pg/040.schema.asset.sql
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/web/templates/default/conify/global/config/actor_sip_fields.tt2 [new file with mode: 0644]
Open-ILS/web/templates/default/conify/global/config/asset_sip_fields.tt2 [new file with mode: 0644]
Open-ILS/xul/staff_client/chrome/content/main/menu.js
Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul
Open-ILS/xul/staff_client/server/admin/stat_cat_editor.js
Open-ILS/xul/staff_client/server/admin/stat_cat_editor.xhtml

index 706ab89..e41464e 100644 (file)
@@ -4348,10 +4348,13 @@ SELECT  usr,
                        <field reporter:label="Name" name="name" reporter:datatype="text" oils_persist:i18n="true"/>
                        <field reporter:label="OPAC Visible" name="opac_visible" reporter:datatype="bool"/>
                        <field reporter:label="Owning Library" name="owner" reporter:datatype="org_unit"/>
+                       <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"/>
                </fields>
                <links>
                        <link field="owner" reltype="has_a" key="id" map="" class="aou"/>
+                       <link field="sip_field" reltype="has_a" key="field" map="" class="ascsf"/>
                        <link field="entries" reltype="has_many" key="stat_cat" map="" class="asce"/>
                </links>
        </class>
@@ -4366,6 +4369,22 @@ SELECT  usr,
                        <link field="usr" reltype="has_a" key="id" map="" class="au"/>
                </links>
        </class>
+    <class id="actscsf" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="actor::stat_cat_sip_fields" oils_persist:tablename="actor.stat_cat_sip_fields" reporter:label="SIP Statistical Category Field Identifier">
+        <fields oils_persist:primary="field">
+            <field reporter:label="Field Identifier" name="field" reporter:datatype="text" reporter:selector="name"/>
+            <field reporter:label="Field Name" name="name" reporter:datatype="text"/>
+            <field reporter:label="Exclusive?" name="one_only" reporter:datatype="bool"/>
+        </fields>
+        <links/>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <create permission="CREATE_PATRON_STAT_CAT" global_required="true"/>
+                <retrieve />
+                <update permission="UPDATE_PATRON_STAT_CAT" global_required="true"/>
+                <delete permission="DELETE_PATRON_STAT_CAT" global_required="true"/>
+            </actions>
+        </permacrud>
+    </class>
        <class id="actsc" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="actor::stat_cat" oils_persist:tablename="actor.stat_cat" reporter:label="User Statistical Category">
                <fields oils_persist:primary="id" oils_persist:sequence="actor.stat_cat_id_seq">
                        <field reporter:label="Entries" name="entries" oils_persist:virtual="true" reporter:datatype="link"/>
@@ -4374,9 +4393,12 @@ SELECT  usr,
                        <field reporter:label="OPAC Visible" name="opac_visible" reporter:datatype="bool"/>
                        <field reporter:label="Owning Library" name="owner" reporter:datatype="org_unit"/>
                        <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"/>
                </fields>
                <links>
                        <link field="owner" reltype="has_a" key="id" map="" class="aou"/>
+                       <link field="sip_field" reltype="has_a" key="field" map="" class="actscsf"/>
                        <link field="entries" reltype="has_many" key="stat_cat" map="" class="actsce"/>
                </links>
         <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
@@ -5290,7 +5312,22 @@ SELECT  usr,
                        <link field="owner" reltype="has_a" key="id" map="" class="aou"/>
                </links>
        </class>
-
+    <class id="ascsf" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="asset::stat_cat_sip_fields" oils_persist:tablename="asset.stat_cat_sip_fields" reporter:label="SIP Statistical Category Field Identifier">
+        <fields oils_persist:primary="field">
+            <field reporter:label="Field Identifier" name="field" reporter:datatype="text" reporter:selector="name"/>
+            <field reporter:label="Field Name" name="name" reporter:datatype="text"/>
+            <field reporter:label="Exclusive?" name="one_only" reporter:datatype="bool"/>
+        </fields>
+        <links/>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <create permission="CREATE_COPY_STAT_CAT" global_required="true"/>
+                <retrieve />
+                <update permission="UPDATE_COPY_STAT_CAT" global_required="true"/>
+                <delete permission="DELETE_COPY_STAT_CAT" global_required="true"/>
+            </actions>
+        </permacrud>
+    </class>
        <class id="ahrcc" controller="open-ils.cstore open-ils.reporter-store open-ils.pcrud" oils_obj:fieldmapper="action::hold_request_cancel_cause" oils_persist:tablename="action.hold_request_cancel_cause" oils_persist:restrict_primary="100" reporter:label="Hold Request Cancel Cause">
                <fields oils_persist:primary="id" oils_persist:sequence="action.hold_request_cancel_cause_id_seq">
                        <field reporter:label="Cause ID" name="id" reporter:datatype="id" />
index 392febe..89495fc 100644 (file)
@@ -118,7 +118,7 @@ use base qw/actor/;
 
 __PACKAGE__->table( 'actor_stat_cat' );
 __PACKAGE__->columns( Primary => qw/id/ );
-__PACKAGE__->columns( Essential => qw/owner name opac_visible usr_summary/ );
+__PACKAGE__->columns( Essential => qw/owner name opac_visible usr_summary sip_field sip_format/ );
 
 #-------------------------------------------------------------------------------
 package actor::stat_cat_entry;
index b464de5..6cecb8d 100644 (file)
@@ -88,7 +88,7 @@ use base qw/asset/;
 
 __PACKAGE__->table( 'asset_stat_cat' );
 __PACKAGE__->columns( Primary => qw/id/ );
-__PACKAGE__->columns( Essential => qw/owner name opac_visible required/ );
+__PACKAGE__->columns( Essential => qw/owner name opac_visible sip_field sip_format required/ );
 
 #-------------------------------------------------------------------------------
 package asset::stat_cat_entry;
index 7eb815c..91302a1 100644 (file)
@@ -88,8 +88,9 @@ sub new {
                        {
                                flesh => 3,
                                flesh_fields => {
-                                       acp => [ 'circ_lib', 'call_number', 'status' ],
+                                       acp => [ 'circ_lib', 'call_number', 'status', 'stat_cat_entry_copy_maps' ],
                                        acn => [ 'owning_lib', 'record' ],
+                    ascecm => [ 'stat_cat', 'stat_cat_entry' ],
                                }
                        }
                ]
@@ -483,6 +484,40 @@ sub available {
     return 0;
 }
 
+sub extra_fields {
+    my( $self ) = @_;
+    my $extra_fields = {};
+    my $c = $self->{copy};
+    foreach my $stat_cat_entry (@{$c->stat_cat_entry_copy_maps}) {
+        my $stat_cat = $stat_cat_entry->stat_cat;
+        next unless ($stat_cat->sip_field);
+        my $value = $stat_cat_entry->stat_cat_entry->value;
+        if(defined $stat_cat->sip_format && length($stat_cat->sip_format) > 0) { # Has a format string?
+            if($stat_cat->sip_format =~ /^\|(.*)\|$/) { # Regex match?
+                if($value =~ /($1)/) { # If we have a match
+                    if(defined $2) { # Check to see if they embedded a capture group
+                        $value = $2; # If so, use it
+                    }
+                    else { # No embedded capture group?
+                        $value = $1; # Use our outer one
+                    }
+                }
+                else { # No match?
+                    $value = ''; # Empty string. Will be checked for below.
+                }
+            }
+            else { # Not a regex match - Try sprintf match (looking for a %s, if any)
+                $value = sprintf($stat_cat->sip_format, $value);
+            }
+        }
+        next unless length($value) > 0; # No value = no export
+        $value =~ s/\|//g; # Remove all lingering pipe chars for sane output purposes
+        $extra_fields->{ $stat_cat->sip_field } = [] unless (defined $extra_fields->{$stat_cat->sip_field});
+        push(@{$extra_fields->{ $stat_cat->sip_field}}, $value);
+    }
+    return $extra_fields;
+}
+
 
 1;
 __END__
index c628820..c3dbb21 100644 (file)
@@ -66,6 +66,10 @@ sub new {
                 "billing_address",
                 "mailing_address",
                 'profile',
+                "stat_cat_entries",
+            ],
+            actscecm => [
+                "stat_cat",
             ],
         }
     };
@@ -721,5 +725,38 @@ sub inet_privileges {
     return $name;
 }
 
+sub extra_fields {
+    my( $self ) = @_;
+    my $extra_fields = {};
+       my $u = $self->{user};
+    foreach my $stat_cat_entry (@{$u->stat_cat_entries}) {
+        my $stat_cat = $stat_cat_entry->stat_cat;
+        next unless ($stat_cat->sip_field);
+        my $value = $stat_cat_entry->stat_cat_entry;
+        if(defined $stat_cat->sip_format && length($stat_cat->sip_format) > 0) { # Has a format string?
+            if($stat_cat->sip_format =~ /^\|(.*)\|$/) { # Regex match?
+                if($value =~ /($1)/) { # If we have a match
+                    if(defined $2) { # Check to see if they embedded a capture group
+                        $value = $2; # If so, use it
+                    }
+                    else { # No embedded capture group?
+                        $value = $1; # Use our outer one
+                    }
+                }
+                else { # No match?
+                    $value = ''; # Empty string. Will be checked for below.
+                }
+            }
+            else { # Not a regex match - Try sprintf match (looking for a %s, if any)
+                $value = sprintf($stat_cat->sip_format, $value);
+            }
+        }
+        next unless length($value) > 0; # No value = no export
+        $value =~ s/\|//g; # Remove all lingering pipe chars for sane output purposes
+        $extra_fields->{ $stat_cat->sip_field } = [] unless (defined $extra_fields->{$stat_cat->sip_field});
+        push(@{$extra_fields->{ $stat_cat->sip_field}}, $value);
+    }
+    return $extra_fields;
+}
 
 1;
index d56e644..058387c 100644 (file)
@@ -154,6 +154,17 @@ $$;
 
 CREATE INDEX actor_usr_setting_usr_idx ON actor.usr_setting (usr);
 
+CREATE TABLE actor.stat_cat_sip_fields (
+    field   CHAR(2) PRIMARY KEY,
+    name    TEXT    NOT NULL,
+    one_only  BOOL    NOT NULL DEFAULT FALSE
+);
+COMMENT ON TABLE actor.stat_cat_sip_fields IS $$
+Actor Statistical Category SIP Fields
+
+Contains the list of valid SIP Field identifiers for
+Statistical Categories.
+$$;
 
 CREATE TABLE actor.stat_cat (
        id              SERIAL  PRIMARY KEY,
@@ -161,6 +172,8 @@ CREATE TABLE actor.stat_cat (
        name            TEXT    NOT NULL,
        opac_visible    BOOL NOT NULL DEFAULT FALSE,
        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,
        CONSTRAINT sc_once_per_owner UNIQUE (owner,name)
 );
 COMMENT ON TABLE actor.stat_cat IS $$
@@ -202,6 +215,28 @@ $$;
 
 CREATE INDEX actor_stat_cat_entry_usr_idx ON actor.stat_cat_entry_usr_map (target_usr);
 
+CREATE FUNCTION actor.stat_cat_check() RETURNS trigger AS $func$
+DECLARE
+    sipfield actor.stat_cat_sip_fields%ROWTYPE;
+    use_count INT;
+BEGIN
+    IF NEW.sip_field IS NOT NULL THEN
+        SELECT INTO sipfield * FROM actor.stat_cat_sip_fields WHERE field = NEW.sip_field;
+        IF sipfield.one_only THEN
+            SELECT INTO use_count count(id) FROM actor.stat_cat WHERE sip_field = NEW.sip_field AND id != NEW.id;
+            IF use_count > 0 THEN
+                RAISE EXCEPTION 'Sip field cannot be used twice';
+            END IF;
+        END IF;
+    END IF;
+    RETURN NEW;
+END;
+$func$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER actor_stat_cat_sip_update_trigger
+    BEFORE INSERT OR UPDATE ON actor.stat_cat FOR EACH ROW
+    EXECUTE PROCEDURE actor.stat_cat_check();
+
 CREATE TABLE actor.card (
        id      SERIAL  PRIMARY KEY,
        usr     INT     NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED,
index 735cc64..010c3bc 100644 (file)
@@ -127,6 +127,18 @@ CREATE TRIGGER acp_status_changed_trig
     BEFORE UPDATE ON asset.copy
     FOR EACH ROW EXECUTE PROCEDURE asset.acp_status_changed();
 
+CREATE TABLE asset.stat_cat_sip_fields (
+    field   CHAR(2) PRIMARY KEY,
+    name    TEXT    NOT NULL,
+    one_only BOOL    NOT NULL DEFAULT FALSE
+);
+COMMENT ON TABLE asset.stat_cat_sip_fields IS $$
+Asset Statistical Category SIP Fields
+
+Contains the list of valid SIP Field identifiers for
+Statistical Categories.
+$$;
+
 CREATE TABLE asset.stat_cat_entry_transparency_map (
        id                      BIGSERIAL       PRIMARY KEY,
        stat_cat                INT             NOT NULL, -- needs ON DELETE CASCADE
@@ -141,6 +153,8 @@ CREATE TABLE asset.stat_cat (
        opac_visible    BOOL    NOT NULL DEFAULT FALSE,
        name            TEXT    NOT NULL,
        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,
        CONSTRAINT sc_once_per_owner UNIQUE (owner,name)
 );
 
@@ -161,6 +175,28 @@ CREATE TABLE asset.stat_cat_entry_copy_map (
 );
 CREATE INDEX scecm_owning_copy_idx ON asset.stat_cat_entry_copy_map(owning_copy);
 
+CREATE FUNCTION asset.stat_cat_check() RETURNS trigger AS $func$
+DECLARE
+    sipfield asset.stat_cat_sip_fields%ROWTYPE;
+    use_count INT;
+BEGIN
+    IF NEW.sip_field IS NOT NULL THEN
+        SELECT INTO sipfield * FROM asset.stat_cat_sip_fields WHERE field = NEW.sip_field;
+        IF sipfield.one_only THEN
+            SELECT INTO use_count count(id) FROM asset.stat_cat WHERE sip_field = NEW.sip_field AND id != NEW.id;
+            IF use_count > 0 THEN
+                RAISE EXCEPTION 'Sip field cannot be used twice';
+            END IF;
+        END IF;
+    END IF;
+    RETURN NEW;
+END;
+$func$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER asset_stat_cat_sip_update_trigger
+    BEFORE INSERT OR UPDATE ON asset.stat_cat FOR EACH ROW
+    EXECUTE PROCEDURE asset.stat_cat_check();
+
 CREATE TABLE asset.copy_note (
        id              BIGSERIAL                       PRIMARY KEY,
        owning_copy     BIGINT                          NOT NULL,
index 99debd5..0440099 100644 (file)
 <!ENTITY staff.main.menu.admin.server_admin.conify.config_circ_weights "Circulation Matchpoint Weights">
 <!ENTITY staff.main.menu.admin.server_admin.conify.config_hold_weights "Hold Matchpoint Weights">
 <!ENTITY staff.main.menu.admin.server_admin.conify.config_weight_assoc "Weights Association">
+<!ENTITY staff.main.menu.admin.server_admin.conify.config_actor_sip_fields "Actor Stat Cat Sip Fields">
+<!ENTITY staff.main.menu.admin.server_admin.conify.config_asset_sip_fields "Asset Stat Cat Sip Fields">
 <!ENTITY staff.main.menu.admin.server_admin.conify.global_flag.label "Global Flags">
 
 <!ENTITY staff.main.menu.admin.server_admin.acq.label "Acquisitions">
 <!ENTITY staff.server.admin.stat_cat.copy_stat_cats "Copy Statistical Categories">
 <!ENTITY staff.server.admin.stat_cat.patron_stat_cats "Patron Statistical Categories">
 <!ENTITY staff.server.admin.stat_cat.info_prompt "* To edit or view information about an entry, click on the entry in the drop-down menu">
+<!ENTITY staff.server.admin.stat_cat.sip_field_warning "** Some sip fields may only be valid on one stat cat. Entries using them may not save.">
 <!ENTITY staff.server.admin.stat_cat.none_defined "No statistical categories are defined">
 <!ENTITY staff.server.admin.stat_cat.name.label "Statistical Category Name">
 <!ENTITY staff.server.admin.stat_cat.owning_library.label "Owning Library">
 <!ENTITY staff.server.admin.stat_cat.new_entry_name "Enter the value of the new entry: ">
 <!ENTITY staff.server.admin.stat_cat.new_entry_create "Create new entry">
 <!ENTITY staff.server.admin.stat_cat.update_success "Update succeeded">
+<!ENTITY staff.server.admin.stat_cat.sip_field "SIP Field: ">
+<!ENTITY staff.server.admin.stat_cat.sip_field.none "No SIP Export">
+<!ENTITY staff.server.admin.stat_cat.sip_format "SIP Format: ">
+<!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.upload_xacts.title "Upload Offline Transactions">
 <!ENTITY staff.server.admin.upload_xacts.header "Uploading transactions...">
 <!ENTITY staff.server.admin.upload_xacts.upload "Upload">
diff --git a/Open-ILS/web/templates/default/conify/global/config/actor_sip_fields.tt2 b/Open-ILS/web/templates/default/conify/global/config/actor_sip_fields.tt2
new file mode 100644 (file)
index 0000000..5a0c897
--- /dev/null
@@ -0,0 +1,28 @@
+[% WRAPPER default/base.tt2 %]
+[% ctx.page_title = 'Actor Stat Cat Sip Fields' %]
+<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+    <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+        <div>Actor Stat Cat Sip Fields</div>
+        <div>
+            <button dojoType='dijit.form.Button' onClick='actorSipFieldsGrid.showCreateDialog()'>New Sip Field</button>
+            <button dojoType='dijit.form.Button' onClick='actorSipFieldsGrid.deleteSelected()'>Delete Selected</button>
+        </div>
+    </div>
+    <div>
+    <table  jsId="actorSipFieldsGrid"
+            dojoType="openils.widget.AutoGrid"
+            fieldOrder="['field', 'name', 'one_only']"
+            query="{field: '*'}"
+            fmClass='actscsf'
+            defaultCellWidth='15'
+            editOnEnter='true'/>
+</div>
+
+<script type="text/javascript">
+    dojo.require('openils.Util');
+    dojo.require('openils.widget.AutoGrid');
+    openils.Util.addOnLoad( function() { actorSipFieldsGrid.loadAll(); } );
+</script>
+[% END %]
+
+
diff --git a/Open-ILS/web/templates/default/conify/global/config/asset_sip_fields.tt2 b/Open-ILS/web/templates/default/conify/global/config/asset_sip_fields.tt2
new file mode 100644 (file)
index 0000000..bdf6e7e
--- /dev/null
@@ -0,0 +1,28 @@
+[% WRAPPER default/base.tt2 %]
+[% ctx.page_title = 'Asset Stat Cat Sip Fields' %]
+<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+    <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+        <div>Asset Stat Cat Sip Fields</div>
+        <div>
+            <button dojoType='dijit.form.Button' onClick='assetSipFieldsGrid.showCreateDialog()'>New Sip Field</button>
+            <button dojoType='dijit.form.Button' onClick='assetSipFieldsGrid.deleteSelected()'>Delete Selected</button>
+        </div>
+    </div>
+    <div>
+    <table  jsId="assetSipFieldsGrid"
+            dojoType="openils.widget.AutoGrid"
+            fieldOrder="['field', 'name', 'one_only']"
+            query="{field: '*'}"
+            fmClass='ascsf'
+            defaultCellWidth='15'
+            editOnEnter='true'/>
+</div>
+
+<script type="text/javascript">
+    dojo.require('openils.Util');
+    dojo.require('openils.widget.AutoGrid');
+    openils.Util.addOnLoad( function() { assetSipFieldsGrid.loadAll(); } );
+</script>
+[% END %]
+
+
index 47fc718..3c3818a 100644 (file)
@@ -737,6 +737,14 @@ main.menu.prototype = {
                 ['oncommand'],
                 function(event) { open_eg_web_page('conify/global/config/weight_assoc', null, event); }
             ],
+            'cmd_server_admin_config_actor_sip_fields' : [
+                ['oncommand'],
+                function(event) { open_eg_web_page('conify/global/config/actor_sip_fields', null, event); }
+            ],
+            'cmd_server_admin_config_asset_sip_fields' : [
+                ['oncommand'],
+                function(event) { open_eg_web_page('conify/global/config/asset_sip_fields', null, event); }
+            ],
             'cmd_local_admin_external_text_editor' : [
                 ['oncommand'],
                 function() {
index 7fb34b1..1f85b6e 100644 (file)
     <command id="cmd_server_admin_config_weight_assoc"
              perm="ADMIN_CIRC_MATRIX_MATCHPOINT ADMIN_HOLD_MATRIX_MATCHPOINT VIEW_CIRC_MATRIX_MATCHPOINT VIEW_HOLD_MATRIX_MATCHPOINT"
              />
+    <command id="cmd_server_admin_config_actor_sip_fields"
+             perm="CREATE_PATRON_STAT_CAT"
+             />
+    <command id="cmd_server_admin_config_asset_sip_fields"
+             perm="CREATE_COPY_STAT_CAT"
+             />
 
     <command id="cmd_hotkeys_toggle" />
     <command id="cmd_hotkeys_set" />
                 <menuitem label="&staff.main.menu.admin.server_admin.conify.config_circ_weights;" command="cmd_server_admin_config_circ_weights"/>
                 <menuitem label="&staff.main.menu.admin.server_admin.conify.config_hold_weights;" command="cmd_server_admin_config_hold_weights"/>
                 <menuitem label="&staff.main.menu.admin.server_admin.conify.config_weight_assoc;" command="cmd_server_admin_config_weight_assoc"/>
+                <menuitem label="&staff.main.menu.admin.server_admin.conify.config_actor_sip_fields;" command="cmd_server_admin_config_actor_sip_fields"/>
+                <menuitem label="&staff.main.menu.admin.server_admin.conify.config_asset_sip_fields;" command="cmd_server_admin_config_asset_sip_fields"/>
                 <menu id="main.menu.admin.server.acq" label="&staff.main.menu.admin.server_admin.acq.label;" accesskey="&staff.main.menu.admin.server_admin.acq.accesskey;">
                     <menupopup id="main.menu.admin.server.acq.popup">
                         <menuitem label="&staff.main.menu.admin.server_admin.acq.fund.label;" accesskey="&staff.main.menu.admin.server_admin.acq.fund.accesskey;" command="cmd_server_admin_acq_fund" />
index 55bad58..f16761e 100644 (file)
@@ -1,4 +1,5 @@
 var SC_FETCH_ALL        = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.retrieve.all';
+var SC_FETCH_SF         = 'open-ils.pcrud:open-ils.pcrud.search.PCRUD.atomic';
 var SC_CREATE            = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.create';
 var SC_UPDATE            = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.update';
 var SC_DELETE            = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.delete';
@@ -16,6 +17,12 @@ var PERMS                = {};
 PERMS[ACTOR]            = {};
 PERMS[ASSET]            = {};
 
+var PCRUD_CLASS         = {};
+PCRUD_CLASS[ACTOR]      = 'actscsf';
+PCRUD_CLASS[ASSET]      = 'ascsf';
+
+scSFCache               = {};
+
 var currentlyVisible;
 var opacVisible        = false;
 var cgi;
@@ -84,6 +91,21 @@ function scEditorInit() {
         }, 20 );
 }
 
+function scPopSipFields( selector, type ) {
+    while(selector.lastChild.value != '') selector.removeChild(selector.lastChild);
+    if(!scSFCache[type]) {
+        var req = new Request( 
+            SC_FETCH_SF.replace(/PCRUD/, PCRUD_CLASS[type]) , session, { 'field' : { '!=' : null } } );
+        req.send(true);
+        scSFCache[type] = req.result();
+    }
+    for(var f in scSFCache[type]) {
+        var option = document.createElement('option');
+        option.value = scSFCache[type][f].field();
+        option.appendChild(text(scSFCache[type][f].name() + ' (' + scSFCache[type][f].field() + ')' + (isTrue(scSFCache[type][f].one_only()) ? '**' : '')));
+        selector.appendChild(option);
+    }
+}
 
 function scGo() {
     var show = cgi.param('show');
@@ -171,6 +193,16 @@ function scInsertCat( tbody, cat, type ) {
     else 
         unHideMe($n(row, 'sc_opac_invisible'));
 
+    if(cat.sip_field().length != 2)
+        unHideMe($n(row, 'sc_sip_field_none'));
+    else {
+        $n(row, 'sc_sip_field_value').appendChild( text( cat.sip_field() ) );
+        unHideMe($n(row, 'sc_sip_field_value'));
+    }
+
+    $n(row, 'sc_sip_format_td').appendChild( text( cat.sip_format() ) );
+
+
     if(type == ACTOR) {
         if(isTrue(cat.usr_summary()))
             unHideMe($n(row, 'sc_usr_summary_on'));
@@ -285,10 +317,12 @@ function scBuildNew() {
             hideMe($('required_td2'));
             unHideMe($('usr_summary_td1'));
             unHideMe($('usr_summary_td2'));
+            unHideMe($('sip_tr'));
         break;
         case ASSET:
             hideMe($('usr_summary_td1'));
             hideMe($('usr_summary_td2'));
+            hideMe($('sip_tr'));
             unHideMe($('required_td1'));
             unHideMe($('required_td2'));
         break;
@@ -304,6 +338,7 @@ function scBuildNew() {
         libSel.disabled = false;
     }
     buildMergedOrgSel(libSel, org_list, 0, 'shortname');
+    scPopSipFields($('sc_sip_field'),type);
 }
 
 
@@ -328,6 +363,10 @@ function scNew() {
         cat = new asc();
         cat.required( required );
     }
+    var field = getSelectorVal($('sc_sip_field'));
+    if(field.length == 2) cat.sip_field(field);
+    else cat.sip_field(null);
+    cat.sip_format($('sc_sip_format').value);
 
     cat.opac_visible(visible);
     cat.name(name);
@@ -354,7 +393,10 @@ function scEdit( tbody, type, cat ) {
     if(r.nextSibling) { tbody.insertBefore( row, r.nextSibling ); }
     else{ tbody.appendChild(row); }
 
+    scPopSipFields($n(row, 'sc_edit_sip_field'), type);
     $n(row, 'sc_edit_name').value = cat.name();
+    setSelector($n(row, 'sc_edit_sip_field'), cat.sip_field());
+    $n(row, 'sc_edit_sip_format').value = cat.sip_format();
 
     if(type == ACTOR) {
         var cb = $n(row, 'sc_edit_usr_summary');
@@ -425,11 +467,15 @@ function scEditGo( type, cat, row, selector ) {
 
     var usr_summary = $n(row, 'sc_edit_usr_summary').checked;
     var required = $n(row, 'sc_edit_required').checked;
+    var sip_field = getSelectorVal( $n(row, 'sc_edit_sip_field') );
 
     cat.name( name );
     cat.owner( newlib );
     cat.entries(null);
     cat.opac_visible(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);
     if( visible ) cat.opac_visible(1);
     switch(type) {
         case ACTOR:
index b468a97..8c706a7 100644 (file)
                             <span>&staff.server.admin.stat_cat.off;</span>
                             <input type='radio' name='usr_summary' checked='checked'> </input>
                         </td>
-
+                    </tr>
+                    <tr>
+                        <td>&staff.server.admin.stat_cat.sip_field;</td>
+                        <td>
+                            <select name='sip_field' id='sc_sip_field'>
+                                <option value=''>&staff.server.admin.stat_cat.sip_field.none;</option>
+                            </select>
+                        </td>
+                        <td>&staff.server.admin.stat_cat.sip_format;</td>
+                        <td><input type='text' name='sip_format' id='sc_sip_format' /></td>
                     </tr>
                     <tr>
                         <td colspan='4'>
 
             <br/>
             <div>&staff.server.admin.stat_cat.info_prompt;</div>
+            <div>&staff.server.admin.stat_cat.sip_field_warning;</div>
             <br/>
 
             <div style='padding: 20px;' id='sc_none' class='hide_me'><b>&staff.server.admin.stat_cat.none_defined;</b></div>
                             <td>&staff.server.admin.stat_cat.opac_visibility.label;</td>
                             <td id='sc_required_label'>&staff.server.admin.stat_cat.required.label;</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.entries.label;</td>
                             <td>&staff.server.admin.stat_cat.add_entry;</td>
                             <td>&staff.server.admin.stat_cat.edit;</td>
                                 <span class='hide_me' name='sc_usr_summary'>&staff.server.admin.stat_cat.off;</span> 
                             </td>
                             <td>
+                                <span class='hide_me' name='sc_sip_field_none'>&staff.server.admin.stat_cat.sip_field.none.label;</span>
+                                <span class='hide_me' name='sc_sip_field_value' />
+                            </td>
+                            <td name='sc_sip_format_td'/>
+                            <td>
                                 <select class='selector' name='sc_entries_selector'>
                                     <option>&staff.server.admin.stat_cat.none;</option>
                                 </select>
                 <td name='sc_edit_usr_summary_td'>
                     <input type='checkbox' name='sc_edit_usr_summary'/>
                 </td>
+                <td>
+                    <select name='sc_edit_sip_field'>
+                        <option value=''>&staff.server.admin.stat_cat.sip_field.none;</option>
+                    </select>
+                </td>
+                <td name='sc_edit_sip_format_td'>
+                    <input type='text' name='sc_edit_sip_format'/>
+                </td>
                 <td colspan='4'>
                     <span class='padded'>
                         <input  type='submit' value='&staff.server.admin.stat_cat.edit_submit;' name='sc_edit_submit'/>