LP#1746098 - Hide SMS Carrier - Catalog hold request
authorJosh Stompro <stomproj@larl.org>
Tue, 30 Jan 2018 20:03:33 +0000 (14:03 -0600)
committerJosh Stompro <stomproj@larl.org>
Tue, 30 Jan 2018 20:03:33 +0000 (14:03 -0600)
Hide the SMS Carier select box if sms.hide_carrier is enabled.
Send either the default sms_carrier id or the first one in
the hash since one is required to be set.

Signed-off-by: Josh Stompro <stomproj@larl.org>
Open-ILS/src/templates/opac/parts/sms_carrier_selector.tt2

index 0a6d5a9..1f04647 100644 (file)
         });
     END;
 %]
-[% IF NOT sms_carrier_hide_label; l('Mobile carrier:'); END; %]
-<select name="sms_carrier">
-    <option value="">[% l('Please select your mobile carrier') %]</option>
-    [% FOR carrier IN carriers.sort('name','region') -%]
-    <option value='[% carrier.id | html %]'[%
-        default_carrier == carrier.id ? ' selected="selected"' : ''
-    %]>[% carrier.name | html %] ([% carrier.region | html %])</option>
-    [% END -%]
-</select>
-[% IF NOT sms_carrier_hide_warning; l('Note: carrier charges may apply'); END; %]
+[% IF ctx.get_org_setting(ctx.search_ou, 'sms.hide_carrier') != 1 %]
+    [% IF NOT sms_carrier_hide_label; l('Mobile carrier:'); END; %]
+    <select name="sms_carrier">
+        <option value="">[% l('Please select your mobile carrier') %]</option>
+        [% FOR carrier IN carriers.sort('name','region') -%]
+        <option value='[% carrier.id | html %]'[%
+            default_carrier == carrier.id ? ' selected="selected"' : ''
+        %]>[% carrier.name | html %] ([% carrier.region | html %])</option>
+       [% END -%]
+    </select>
+    [% IF NOT sms_carrier_hide_warning; l('Note: carrier charges may apply'); END; %]
+[% ELSE #set a value for sms_carrier so the hold placement won't fail %]
+    [%  IF default_carrier; #use the default if set
+            dummy_carrier = default_carrier;
+        ELSE; #pick the first carrier
+            dummy_carrier = carriers.0.id;
+        END;
+    %]
+    <input type="hidden" name="sms_carrier" value="[% dummy_carrier %]">
+[% END %]