<label i18n>Pickup Location: </label>
</div>
<div class="col-lg-6">
- <eg-org-select (onChange)="pickupLib = $event ? $event.id() : null"
+ <eg-org-select (onChange)="pickupLib = $event ? $event.id() : null;if(suspendTilOpen)nextOpenTime();"
[disableOrgs]="disableOrgs" [applyOrgId]="pickupLib"></eg-org-select>
</div>
</div>
<label class="form-check-label" for="suspend" i18n>Suspend Hold</label>
</div>
</div>
- <div class="col-lg-6">
+ <div class="col-lg-3">
+ <div class="form-check">
+ <input class="form-check-input" type="checkbox" id="suspendTilOpen"
+ name="suspendTilOpen" [(ngModel)]="suspendTilOpen" [disabled]="!suspend" (ngModelChange)="nextOpenTime()"/>
+ <label class="form-check-label" for="suspendTilOpen" i18n>When Library Opens</label>
+ </div>
+ </div>
+ <div class="col-lg-3">
<div [ngClass]="{'border border-danger rounded': activeDateInvalid}">
<eg-date-select [(ngModel)]="activeDate" name='active-date'
(onChangeAsYmd)="activeDateYmd = $event"
(onChangeAsDate)="setActiveDate($event)"
- (onChangeAsIso)="activeDateSelected($event)" [disabled]="!suspend">
+ (onChangeAsIso)="activeDateSelected($event)" [disabled]="!suspend && !suspendTilOpen">
</eg-date-select>
</div>
</div>
notifySms: boolean;
smsValue: string;
suspend: boolean;
+ suspendTilOpen: boolean;
activeDateStr: string;
activeDateYmd: string;
activeDate: Date;
this.activeDate = null;
this.activeDateStr = null;
this.suspend = false;
+ this.suspendTilOpen = false;
if (this.smsCbox) { this.smsCbox.selectedId = null; }
// Avoid clearing the barcode in cases where the form is
goBack() {
history.back();
}
+
+ nextOpenTime(){
+ this.net.request('open-ils.actor',
+ 'open-ils.actor.org_unit.next_operating_hour',this.pickupLib
+ ).subscribe(resp => {
+ console.log(resp);
+ this.activeDateSelected(resp);
+ });
+ }
+
}
}
__PACKAGE__->register_method(
+ method => "get_next_operating_hour",
+ api_name => "open-ils.actor.org_unit.next_operating_hour",
+ signature => {
+ params => [
+ {type => 'number', desc => 'Context Organizational Unit ID'},
+ {type => 'string', desc => 'Date string to start from (optional)'}
+ ],
+ return => { desc => 'An ISO8601 formatted date string of the next time the context org unit is operating.'}
+ }
+);
+
+sub get_next_operating_hour {
+ my( $self, $client, $org_id, $start_time_str ) = @_;
+ my $e = new_editor();
+ my $start_time;
+ if(defined($start_time_str)){
+ $start_time = DateTime::Format::ISO8601->parse_datetime($start_time_str);
+ }
+ else{
+ # default to current time if none defined
+ $start_time = DateTime::Format::ISO8601->new();
+ }
+ my $h = $e->search_actor_hours_of_operation({id => $org_id})->[0];
+ my $found = 0;
+ # look for thaw date up to 1 week in future
+ for(my $dow = 0;!$found && $dow < 6;$dow++){
+ if($dow){
+ # need to check another day
+ # set to first moment of tomorrow
+ $start_time->add(days => 1);
+ $start_time->set(hour => 0,minute => 0, second=> 0);
+ }
+ my $day_of_week = $start_time->wday;
+ my $open_time_st = $h->{'dow_'.$day_of_week.'_open'};
+ my $close_time_st = $h->{'dow_'.$day_of_week.'_close'};
+ # library closed, check back tomorrow
+ next if($open_time_st eq '00:00:00' and $close_time_st eq '00:00:00');
+ my @open_times = split(':',$open_time_st);
+ my @close_times = split(':',$close_time_st);
+ # create open/close datetimes based on current thaw date
+ my $open_time = $start_time->clone->set(hour => @open_times[0],minute => @open_times[1],second => @open_times[2]);
+ my $close_time = $start_time->clone->set(hour => @open_times[0],minute => @open_times[1],second => @open_times[2]);
+ if($start_time->is_between($open_time,$close_time)){
+ # we found a good time, end loop
+ $found = 1;
+ }
+ else if(DateTime->compare($thaw_dt,$close_time) <= 0){
+ # our start is before opening time
+ # set start to opening time
+ $start_time->set(hour => $open_times[0],minute => $open_times[1])
+ $found = 1;
+ }
+ # start falls after closing time, check tomorrow
+ }
+ # error, library is never operating
+ return $e->event unless $found;
+ return DateTime::Format::ISO8601->format_datetime($start_time);
+}
+
+__PACKAGE__->register_method(
method => "retrieve_coordinates",
api_name => "open-ils.actor.geo.retrieve_coordinates",
signature => {
}
elsif ($cgi->param('hold_suspend') =~ /p/) {
eval {
- #start thaw date at current time
- my $thaw_dt = DateTime::Format::ISO8601->new();
- my $thaw_found = 0;
- my $h = $e->search_actor_hours_of_operation({id => $cgi->param('pickup_lib') || $self->ctx->{search_ou}})->[0];
- #look for thaw date up to 1 week in future
- for(my $dow = 0;!$thaw_found && $dow < 6;$dow++){
- if($dow){
- # need to check another day
- # set to first moment of tomorrow
- $thaw_dt->add(days => 1);
- $thaw_dt->set(hour => 0,minute => 0, second=> 0);
- }
- my $day_of_week = $thaw_dt->wday;
- my $open_time_st = $h->{'dow_'.$day_of_week.'_open'};
- my $close_time_st = $h->{'dow_'.$day_of_week.'_close'};
- # library closed, check back tomorrow
- next if($open_time_st eq '00:00:00' and $close_time_st eq '00:00:00');
- my @open_times = split(':',$open_time_st);
- my @close_times = split(':',$close_time_st);
- # create open/close datetimes based on current thaw date
- my $open_time = $thaw_dt->clone->set(hour => @open_times[0],minute => @open_times[1],second => @open_times[2]);
- my $close_time = $thaw_dt->clone->set(hour => @open_times[0],minute => @open_times[1],second => @open_times[2]);
- if($thaw_dt->is_between($open_time,$close_time)){
- # we found a good time, end loop
- $thaw_found = 1;
- }
- else if(DateTime->compare($thaw_dt,$close_time) <= 0){
- # our thaw date is before opening time
- # set thaw date to opening time
- $thaw_found->set(hour => $open_times[0],minute => $open_times[1])
- $thaw_found = 1;
- }
- # thaw date falls after closing time, check tomorrow
- }
- $ctx->{thaw_date} = $thaw_dt->ymd;
+ my $thaw_date_str = $U->simplereq(
+ 'open-ils.actor',
+ 'open-ils.actor.org_unit.next_operating_hour', $cgi->param('pickup_lib') || $self->ctx->{search_ou});
+ my $thaw_dt = DateTime::Format::ISO8601->parse_datetime($thaw_date_str);
+ $ctx->{thaw_date} = $thaw_dt->ymd;
$ctx->{frozen} = 1;
};
if ($@) {