use OpenILS::Event;
use OpenSRF::Utils::JSON;
use OpenSRF::Utils::Cache;
+use OpenILS::Utils::DateTime qw/:datetime/;
use Digest::MD5 qw(md5_hex);
use Data::Dumper;
$Data::Dumper::Indent = 0;
for my $id (@$hold_ids) {
push @sorted, grep { $_->{hold}->{hold}->id == $id } @holds;
- my $h = $sorted[-1];
+ my $h = $sorted[-1]->{hold}->{hold};
# if available, report the pickup lib in the list
$pickup_libs{$h->pickup_lib} = 1 if (
- $h->pickup_lib == $h->current_shelf_lib &&
+ $h && $h->pickup_lib == $h->current_shelf_lib &&
$h->shelf_time && !$h->cancel_time && !$h->fulfillment_time
);
}
my $date = $self->cgi->param("cs_date");
my $time = $self->cgi->param("cs_time");
my $notes = $self->cgi->param("cs_notes");
-
+
if ($slot) {
$org ||= $slot->org;
$notes ||= $slot->notes;
if ($slot->slot) {
- my $dt = DateTime::Format::ISO8601->parse_datetime($slot->slot);
+ my $dt = DateTime::Format::ISO8601->new->parse_datetime(clean_ISO8601($slot->slot));
$date ||= $dt->strftime('%F');
$time ||= $dt->strftime('%T');
}
$ctx->{cs_date} = $date;
$ctx->{cs_time} = $time;
$ctx->{cs_notes} = $notes;
- $ctx->{cs_slot_id} = $slot->id;
+ $ctx->{cs_slot_id} = $slot->id if ($slot);
$ctx->{cs_slot} = $slot;
if ($cs_action eq 'save' && $org && $date && $time) {
$ctx->{cs_slot} = undef;
} else {
$ctx->{cs_slot} = $slot;
-
- # just redirect back to the holds page
}
- } elsif ($cs_action eq 'next' && $org && $date) { # get a list of times
- $ctx->{cs_times} = $circ->request(
+ $url = $self->ctx->{proto} . '://' . $self->ctx->{hostname} . $self->ctx->{opac_root} . '/myopac/holds_curbside';
+ } elsif ($cs_action eq 'cancel' && $slot) {
+ my $curbsides = $U->simplereq(
+ 'open-ils.curbside',
+ 'open-ils.curbside.delete_appointment',
+ $e->authtoken, $slot->id
+ );
+ $url = $self->ctx->{proto} . '://' . $self->ctx->{hostname} . $self->ctx->{opac_root} . '/myopac/holds_curbside';
+ } elsif ($cs_action eq 'arrive' && $slot) {
+ my $curbsides = $U->simplereq(
+ 'open-ils.curbside',
+ 'open-ils.curbside.mark_arrived',
+ $e->authtoken, $slot->id
+ );
+ } elsif ($cs_action eq 'deliver' && $slot) {
+ my $curbsides = $U->simplereq(
+ 'open-ils.curbside',
+ 'open-ils.curbside.mark_delivered',
+ $e->authtoken, $slot->id
+ );
+ }
+
+ if ($date and $org and !$ctx->{cs_times}{$date}) {
+ $ctx->{cs_times}{$date} = $circ->request(
'open-ils.curbside.times_for_date.atomic',
$e->authtoken, $date, $org
)->gather(1);
}
-
- $url = $self->ctx->{proto} . '://' . $self->ctx->{hostname} . $self->ctx->{opac_root} . '/myopac/hold_curbside';
}
$circ->kill_me;
if($holds_object->{holds}) {
$ctx->{holds} = $holds_object->{holds};
- $ctx->{curbside_appointments} = $holds_object->{curbsides};
+ $ctx->{curbside_appointments} = {};
+
+ $logger->info('curbside: found '.scalar(@{$holds_object->{curbsides}}).' appointments');
+
+ for my $cs (@{$holds_object->{curbsides}}) {
+ my $dt = DateTime::Format::ISO8601->new->parse_datetime(clean_ISO8601($cs->slot))->strftime('%F');
+ $ctx->{cs_times}{$dt} = $U->simplereq(
+ 'open-ils.curbside', 'open-ils.curbside.times_for_date.atomic',
+ $e->authtoken, $dt, $cs->org
+ );
+ $ctx->{curbside_appointments}{$cs->org} = $cs;
+ }
+
$ctx->{curbside_pickup_libs} = [];
for my $pul (@{$holds_object->{pickup_libs}}) {
push(@{$ctx->{curbside_pickup_libs}}, $pul) if $ctx->{get_org_setting}->($pul, 'circ.curbside');
PROCESS "opac/parts/hold_notify.tt2";
PROCESS "opac/parts/myopac/column_sort_support.tt2";
WRAPPER "opac/parts/myopac/base.tt2";
- myopac_page = "holds";
- limit = (ctx.holds_limit.defined) ? ctx.holds_limit : 0;
- offset = (ctx.holds_offset.defined) ? ctx.holds_offset : 0;
- count = (ctx.holds_ids.size.defined) ? ctx.holds_ids.size : 0;
+ myopac_page = "holds_curbside";
%]
<h3 class="sr-only">[% l('Curbside pickup') %]</h3>
<div id='myopac_holds_div'>
<div id="acct_holds_tabs">
<div class="align">
- <a href='#'>[% l("Items on Hold") %]</a>
+ <a href='[% mkurl('holds',{},['limit','offset']) %]'>[% l("Items on Hold") %]</a>
</div>
- [% IF ctx.curbside_pickup_libs.length > 0 %]
+ [% IF ctx.curbside_pickup_libs.size > 0 %]
<div class="align selected">
- <a href=''>[% l("Curbside pickup") %]</a>
+ <a href='#'>[% l("Curbside pickup") %]</a>
</div>
[% END %]
[% IF ebook_api.enabled == 'true' %]
<div class="header_middle">
<span id="acct_holds_header" style="float:left;">
- [% l("Curbside pickup appointments"); %]
+ [% l("Curbside pickup appointments") %]
</span>
</div>
<div class="clear-both"></div>
- <div title="[% l('Curbside Pickup Appointments') %]"
+ <div title="[% l('Curbside Pickup Appointments') %]" style="width:90%"
class="egtable table_no_border_space table_no_cell_pad">
<div class="egtr">
<span class="egth">[% l('Pickup Location') %]</span>
<span class="egth">[% l('Date') %]</span>
<span class="egth">[% l('Time') %]</span>
- <span class="egth">[% l('Notes') %]</span>
+ <span class="egth">[% l('Arrival Notes (vehicle description, etc)') %]</span>
<span class="egth">[% l('Action') %]</span>
</div>
[% FOR lib IN ctx.curbside_pickup_libs %]
- <form class="egtr" method="GET">
+ [% 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;
+ END %]
+ <form class="egtr" method="POST">
<input type="hidden" name="action" value="curbside"/>
- <input type="hidden" name="cs_slot_id" value="[% ctx.cs_slot_id %]"/>
+ <input type="hidden" name="cs_slot_id" value="[% appointment.id %]"/>
[% disable_me = 0 %]
- [% IF ctx.slot && ctx.slot.arrival; disable_me = 1; END %]
+ [% IF appointment && appointment.arrival; disable_me = 1; END %]
<span class="egtd">
[% ctx.get_aou(lib).name | html %]
<input type="hidden" name="cs_org" value="[% lib %]"/>
cs_date = date.format(date.now, '%F');
END;
%]
- <input type="date" name="cs_date" value="[% ctx.cs_date | html %]" [% IF disable_me %]disabled="disabled"[% END %]/>
+ <input type="date" name="cs_date" value="[% cs_date | html %]" [% IF disable_me %]disabled="disabled"[% END %]/>
</span>
<span class="egtd">
- [% IF ctx.cs_times.length > 0; # show a select %]
- <select name="cs_time">
- [% FOR t IN ctx.cs_times %]
+ [% 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 %] selected="selected"[% END %]
- [% IF t.1 == %] disabled="disabled[% END %]>[% t.0 %]</option>
+ [% 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>
[% ELSE %]
[% l('Select a date') %]
[% END %]
<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 %]/>
+ [% ELSE %]
[% END %]
</span>
<span class="egtd">
- [% IF ctx.cs_time; # relevant submit action %]
+ [% IF appointment.staged && !appointment.arrival; # relevant submit action %]
+ <button type="submit" name="cs_action" value="arrive" class="opac-button">
+ [% l('Alert staff of your arrival') %]
+ </button><br/>
+ <button type="submit" name="cs_action" value="cancel" class="opac-button">
+ [% l('Cancel appointment') %]
+ </button>
+ [% ELSIF appointment.arrival %]
+ <button type="submit" name="cs_action" value="deliver" class="opac-button">
+ [% l('Confirm delivery of items') %]
+ </button><br/>
+ <button type="submit" name="cs_action" value="cancel" class="opac-button">
+ [% l('Cancel appointment') %]
+ </button>
+ [% ELSIF appointment.slot %]
+ <button type="submit" name="cs_action" value="arrive" class="opac-button">
+ [% l('Alert staff of your arrival') %]
+ </button><br/>
<button type="submit" name="cs_action" value="save" class="opac-button">
[% l('Update appointment') %]
+ </button><br/>
+ <button type="submit" name="cs_action" value="cancel" class="opac-button">
+ [% l('Cancel appointment') %]
</button>
[% ELSIF ctx.cs_date %]
- <button type="submit" name="cs_action" value="next" class="opac-button">
+ <button type="submit" name="cs_action" value="save" class="opac-button">
[% l('Request appointment') %]
</button>
[% ELSE %]
[% END %]
</span>
</form>
+ [% END %]
</div>
</div>
[% END %]