$hold->clear_prev_check_time;
$hold->clear_shelf_expire_time;
$hold->clear_current_shelf_lib;
- create_reset_hold_note($e,$hold,"Hold Reset due to Uncancelation","Hold was reset due to Uncancelation.");
+ _create_reset_hold_note($e,$hold,"Hold Reset due to Uncancelation","Hold was reset due to Uncancelation.");
$e->update_action_hold_request($hold) or return $e->die_event;
$e->commit;
my $note_body = "Hold Cancelation.";
$note_body .= " Cancel Cause ID - $cause;";
$note_body .= " Cancel Note - $note" unless $note eq "";
- create_reset_hold_note($e,$hold,"Hold Reset due to Cancelation",$note_body);
+ _create_reset_hold_note($e,$hold,"Hold Reset due to Cancelation",$note_body);
$e->update_action_hold_request($hold)
or return $e->die_event;
}
$e->update_action_hold_request($hold) or return $e->die_event;
- create_reset_hold_note($e,$hold,"Hold Reset due to Update",$note_body) unless $note_body eq "";
+ _create_reset_hold_note($e,$hold,"Hold Reset due to Update",$note_body) unless $note_body eq "";
$e->commit;
if(!$U->is_true($hold->frozen) && $U->is_true($orig_hold->frozen)) {
} else {
if($U->is_true($orig_hold->frozen)) {
$logger->info("Running targeter on activated hold ".$hold->id);
- create_reset_hold_note($e,$hold,"Hold Reset by Unfreezing","Running targeter on activated hold");
+ _create_reset_hold_note($e,$hold,"Hold Reset by Unfreezing","Running targeter on activated hold");
$U->simplereq('open-ils.hold-targeter',
'open-ils.hold-targeter.target', {hold => $hold->id});
}
return 1;
}
+__PACKAGE__->register_method(
+ method => 'create_reset_hold_note',
+ api_name => 'open-ils.circ.hold_reset_note.create'
+);
+
sub create_reset_hold_note
{
+ my($self, $conn, $holdid, $title, $note_body) = @_;
+ my $e = new_editor(xact => 1);
+ $logger->info("got editor");
+ #return $e->die_event unless $e->checkauth;
+ my ($hold, $evt) = $U->fetch_hold($holdid);
+ $logger->info("fetched hold");
+ return $evt if $evt;
+ _create_reset_hold_note($e, $hold, $title, $note_body);
+ $e->commit;
+ return 1;
+}
+
+sub _create_reset_hold_note
+{
my($e, $hold, $title, $note_body) = @_;
my $ts = DateTime->now;
- my $note = Fieldmapper::action::hold_request_note->new;
+ my $note = Fieldmapper::action::hold_request_note->new;
+ $logger->info("Creating hold note with title: " . $title . " and body: " . $note_body . " hold id: " . $hold->id);
my $last_copy = $hold->current_copy || 0;
my $reqr = $e->requestor;
+ my $reqr_id = defined $reqr ? $reqr->id : 0;
+ my $reqr_usrname = $reqr_id ? $reqr->usrname : "";
$title.=" ".$ts->mdy." ".$ts->hms;
my $json = "{";
$json .= "\"Reset Reason\" : \"$note_body\",";
$json .= "\"Timestamp\" : \"".$ts->mdy." ".$ts->hms."\",";
$json .= "\"Previous Copy ID\" : \"$last_copy\"," unless $last_copy == 0;
- $json .= "\"Requestor ID\" : \"".$reqr->id."\",";
- $json .= "\"Requestor Usrname\" : \"".$reqr->usrname."\"";
+ $json .= "\"Requestor ID\" : \"".$reqr_id."\",";
+ $json .= "\"Requestor Usrname\" : \"".$reqr_usrname."\"";
$json .= "}";
$note->hold($hold);
$note->staff(1);
}
}
- create_reset_hold_note($e,$hold,"Hold Reset by Staff",$note_body);
+ _create_reset_hold_note($e,$hold,"Hold Reset by Staff",$note_body);
$hold->clear_capture_time;
$hold->clear_current_copy;
$hold->clear_shelf_time;
next if $old_hold->id eq $best_hold->id; # don't re-target the hold we want
$logger->info("circulator: clearing current_copy and prev_check_time on hold ".
$old_hold->id." after a better hold [".$best_hold->id."] was found");
+ _create_reset_hold_note($editor,$old_hold,"Hold Reset due to Age","Old hold was reset. Last check time was ".$old_hold->prev_check_time.". a better hold [".$best_hold->id."] was found");
$old_hold->clear_current_copy;
$old_hold->clear_prev_check_time;
$editor->update_action_hold_request($old_hold)