Fully support multiple pickup libraries, and tighten up Request form progression
authorMike Rylander <mrylander@gmail.com>
Wed, 3 Jun 2020 18:28:00 +0000 (14:28 -0400)
committerMike Rylander <mrylander@gmail.com>
Wed, 3 Jun 2020 18:30:05 +0000 (14:30 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/templates/opac/myopac/holds_curbside.tt2

index 7f355c7..8225a89 100644 (file)
             <span class="egth">[% l('Arrival Notes (vehicle description, etc)') %]</span>
             <span class="egth">[% l('Action') %]</span>
         </div>
-    [% FOR lib IN ctx.curbside_pickup_libs %]
-        [% appointment = ctx.curbside_appointments.$lib %]
-        [% IF !ctx.cs_slot && appointment;
-            ctx.cs_slot = appointment;
-            ctx.cs_slot_id = appointment.id;
-            ctx.cs_date = date.format(ctx.parse_datetime(appointment.slot),'%F');
-            ctx.cs_time = date.format(ctx.parse_datetime(appointment.slot),'%T');
-            ctx.cs_notes = appointment.notes;
+    [% FOR lib IN ctx.curbside_pickup_libs;
+
+        cs_slot = '';
+        cs_slot_id = '';
+        cs_date = '';
+        cs_time = '';
+        cs_notes = '';
+
+       cs_org = ctx.cs_org;
+        IF cs_org == lib;
+            cs_slot = ctx.cs_slot;
+            cs_slot_id = ctx.cs_slot_id;
+            cs_date = ctx.cs_date;
+            cs_time = ctx.cs_time;
+            cs_notes = ctx.cs_notes;
+        END;
+
+        appointment = ctx.curbside_appointments.$lib;
+        IF appointment;
+            cs_slot = appointment;
+            cs_slot_id = appointment.id;
+            cs_date = date.format(ctx.parse_datetime(appointment.slot),'%F');
+            cs_time = date.format(ctx.parse_datetime(appointment.slot),'%T');
+            cs_notes = appointment.notes;
         END %]
         <form class="egtr" method="POST">
             <input type="hidden" name="action" value="curbside"/>
                 <input type="hidden" name="cs_org" value="[% lib %]"/>
             </span>
             <span class="egtd">
-                [% IF ctx.cs_date;
-                    cs_date = ctx.cs_date;
-                   ELSE;
-                    cs_date = date.format(date.now, '%F');
-                   END;
-                %]
-                <input type="date" name="cs_date" value="[% cs_date | html %]" [% IF disable_me %]disabled="disabled"[% END %]/>
+                [% IF !cs_date; tmp_cs_date = date.format(date.now, '%F') %]
+                [% ELSE; tmp_cs_date = cs_date; END %]
+                [% IF cs_date %]<input type="hidden" name="cs_date" value="[% cs_date | html %]"/>[% END %]
+                <input type="date" name="cs_date" value="[% tmp_cs_date | html %]" [% IF cs_date %]disabled="disabled"[% END %]/>
             </span>
             <span class="egtd">
-                [% IF ctx.cs_date; # show a select %]
-                  <select name="cs_time" [% IF disable_me %]disabled="disabled"[% END %]>
-                    [% current_date = ctx.cs_date %]
-                    [% found_time = 0 %]
-                    [% FOR t IN ctx.cs_times.$current_date %]
-                      <option value="[% t.0 | html %]"
-                        [% IF ctx.cs_time == t.0; found_time=1 %] selected="selected"[% END %]
-                        [% IF t.1 == 0 %] disabled="disabled[% END %]>[% t.0 | html %]
-                      </option>
-                    [% END %]
-                    [% IF ctx.cs_time && !found_time %]
-                      <option value="[% ctx.cs_time | html %]" selected="selected">
-                        [% ctx.cs_time | html %]
-                      </option>
-                    [% END %]
-                  </select>
+                [% IF appointment || cs_date; # checking times %]
+                  [% current_date = cs_date %]
+                  [% IF ctx.cs_times.$current_date.size; # show a select %]
+                    <select name="cs_time" [% IF disable_me %]disabled="disabled"[% END %]>
+                      [% found_time = 0 %]
+                      [% FOR t IN ctx.cs_times.$current_date %]
+                        <option value="[% t.0 | html %]"
+                          [% IF cs_time == t.0; found_time=1 %] selected="selected"[% END %]
+                          [% IF t.1 == 0 %] disabled="disabled[% END %]>[% t.0 | html %]
+                        </option>
+                      [% END %]
+                      [% IF cs_time && !found_time %]
+                        <option value="[% cs_time | html %]" selected="selected">
+                          [% cs_time | html %]
+                        </option>
+                      [% END %]
+                    </select>
+                  [% ELSE %] 
+                    [% l('No times available') %]
+                    <button type="submit" name="cs_action" value="reset" class="opac-button">
+                        [% l('Select another date') %]
+                    </button><br/>
+                  [% END %]
                 [% ELSE %] 
                   [% l('Select a date') %]
                 [% END %]
             </span>
             <span class="egtd">
-                [% IF ctx.cs_date; # show the notes box %]
-                <input type="text" name="cs_notes" value="[% ctx.cs_notes | html %]" [% IF disable_me %]disabled="disabled"[% END %]/>
+                [% IF cs_date; # show the notes box %]
+                <input type="text" name="cs_notes" value="[% cs_notes | html %]" [% IF disable_me %]disabled="disabled"[% END %]/>
                 [% ELSE %] &nbsp;
                 [% END %]
             </span>
                     <button type="submit" name="cs_action" value="cancel" class="opac-button">
                         [% l('Cancel appointment') %]
                     </button>
-                [% ELSIF ctx.cs_date %]
+                [% ELSIF cs_date %]
                     <button type="submit" name="cs_action" value="save" class="opac-button">
                         [% l('Request appointment') %]
                     </button>
+                    <button type="submit" name="cs_action" value="reset" class="opac-button">
+                        [% l('Select another date') %]
+                    </button><br/>
                 [% ELSE %]
                     <button type="submit" name="cs_action" value="next" class="opac-button">
                         [% l('Check available times') %]