Apply CW MARS Customization to Quipu Ecard Form
authorJason Stephenson <jstephenson@cwmars.org>
Wed, 20 Oct 2021 19:00:11 +0000 (15:00 -0400)
committerJason Stephenson <jason@sigio.com>
Tue, 17 Jan 2023 20:24:50 +0000 (15:24 -0500)
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm
Open-ILS/src/templates/opac/ecard/form.tt2

index 1b16c94..be9bb19 100644 (file)
@@ -27,8 +27,8 @@ my @api_fields = (
     {name => 'day_phone', class => 'au', required => 0},
     {name => 'dob', class => 'au', required => 1},
     {name => 'home_ou', class => 'au', required => 1},
-    {name => 'ident_type', class => 'au', required => 1},
-    {name => 'ident_value', class => 'au', required => 1},
+    {name => 'ident_type', class => 'au', required => 0},
+    {name => 'ident_value', class => 'au', required => 0},
     {name => 'guardian',
      class => 'au', 
      notes => "AKA parent/guardian",
@@ -56,6 +56,7 @@ my @api_fields = (
     {name => 'mailing_country', class => 'aua', required => 1},
     {name => 'voter_registration', class => 'asvr', required => 0},
     {name => 'in_house_registration', required => 0},
+    {name => 'newsletter', required => 0},
 );
 
 
@@ -256,6 +257,7 @@ sub load_ecard_submit {
 
     return $self->compile_response unless $self->make_user;
     return $self->compile_response unless $self->add_addresses;
+    return $self->compile_response unless $self->add_stat_cats;
     return $self->compile_response unless $self->check_dupes;
     return $self->compile_response unless $self->add_card;
     # Add survey responses commented out because it is not universal.
@@ -393,6 +395,9 @@ sub make_user {
         $au->$field($val);
     }
 
+    # CW MARS: Force ident_type to 1.
+    $au->ident_type(1);
+
     return undef if $ctx->{response}->{status}; 
     return $ctx->{user} = $au;
 }
@@ -605,34 +610,23 @@ sub add_survey_responses {
     return 1;
 }
 
-# TODO: this is KCLS-specific, but maybe we can make it something
+# TODO: this is CW MARS-specific, but maybe we can make it something
 # generic for adding stat cats to the patron
 
-#sub add_stat_cats {
-#    my $self = shift;
-#    my $cgi = $self->cgi;
-#    my $user = $self->ctx->{user};
-#
-#    my $ds_map = Fieldmapper::actor::stat_cat_entry_user_map->new;
-#    $ds_map->isnew(1);
-#    $ds_map->stat_cat(12);
-#    $ds_map->stat_cat_entry('KCLS');
-#
-#    my $events = $cgi->param('events_mailing');
-#    my $em_map = Fieldmapper::actor::stat_cat_entry_user_map->new;
-#    $em_map->isnew(1);
-#    $em_map->stat_cat(3);
-#    $em_map->stat_cat_entry($events ? 'Y' : 'N');
-#
-#    my $foundation = $cgi->param('foundation_mailing');
-#    my $fm_map = Fieldmapper::actor::stat_cat_entry_user_map->new;
-#    $fm_map->isnew(1);
-#    $fm_map->stat_cat(4);
-#    $fm_map->stat_cat_entry($foundation ? 'Y' : 'N');
-#
-#    $user->stat_cat_entries([$ds_map, $em_map, $fm_map]);
-#    return 1;
-#}
+sub add_stat_cats {
+   my $self = shift;
+   my $cgi = $self->cgi;
+   my $user = $self->ctx->{user};
+
+   my $newsletter = $cgi->param('newsletter');
+   my $map = Fieldmapper::actor::stat_cat_entry_user_map->new;
+   $map->isnew(1);
+   $map->stat_cat(28);
+   $map->stat_cat_entry($newsletter ? 'Yes' : 'No');
+
+   $user->stat_cat_entries([$map]);
+   return 1;
+}
 
 # Returns true if no dupes found, false if dupes are found.
 sub check_dupes {
index 4f29711..012fee9 100644 (file)
@@ -2,20 +2,34 @@
     PROCESS "opac/parts/org_selector.tt2";
     WRAPPER "opac/parts/base.tt2";
     INCLUDE "opac/parts/topnav.tt2";
-    ctx.page_title = l("Request Electronic Card");
+    ctx.page_title = l("Get a CW MARS eCard");
     ctx_org = ctx.physical_loc || ctx.search_ou || ctx.aou_tree.id;
 %]
 <div id="content-wrapper">
-<div id="main-content-register">
+<div id="main-content-register"
+     style="margin: auto; width: 65%;">
 <h2>[% ctx.page_title %]</h2>
 [% IF ctx.ecard.enabled && ctx.ecard.quipu_id %]
 <div id="ecard-intro">
 <!-- The following script tags can be placed in the library's <head> or <body> tag -->
 <script src="https://ecard-us2.quipugroup.net/js/eCARDEmbed.js"></script>
 <script>loadQGeCARD([% ctx.ecard.quipu_id %])</script>
-<p>
-[% l('Fill out the application below to get immediate access to electronic services, such as e-books, audiobooks, magazines, and databases, provided by your local library.') %]
-</p>
+
+<p>An eCard is a CW MARS library card that you can register for online to access electronic materials, such as ebooks, audiobooks, magazines, and databases.</p>
+
+<p>The eCard is for patrons who do not already have a CW MARS library card and may be upgraded to a physical library card with borrowing privileges by visiting your local library. For more information about the eCard, <a href="https://www.cwmars.org/help/general-faq" target="_blank" rel="noopener">read our FAQ</a>.</p>
+
+<p>You are eligible to apply for a CW MARS eCard, if you...</p>
+<ul>
+<li>live in a Massachusetts town with a <a href="https://www.cwmars.org/memberlibraries" target="_blank" rel="noopener">CW MARS member library</a>,</li>
+<li>are age 13 or older,</li>
+<li>and do not currently have a library card from a <a href="https://www.cwmars.org/memberlibraries" target="_blank" rel="noopener">CW MARS member library</a>.</li>
+</ul>
+
+<p>Contact your local library if you are not eligible to register online or to renew an expired card.</p>
+
+<p>Funding for electronic content is provided by <a href="https://www.cwmars.org/memberlibraries" target="_blank" rel="noopener">CW MARS member libraries</a>, and the <a href="https://mblc.state.ma.us/" target="_blank" rel="noopener">Massachusetts Board of Library Commissioners</a> with funding from the <a href="https://www.imls.gov/" target="_blank" rel="noopener">Institute of Museum and Library Services</a> and the Commonwealth of Massachusetts.</p>
+
 </div>
 <!-- The following <div> tag should be placed on the web page where the library would like the registration form to display -->
 <div id="eCARD" data-language="en" data-branchid="[% ctx_org %]"></div>