]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/perlmods/OpenILS/Application/Circ.pm
lost materials now charge the copy price and processing fee as separate bills
[Evergreen.git] / Open-ILS / src / perlmods / OpenILS / Application / Circ.pm
1 package OpenILS::Application::Circ;
2 use base qw/OpenSRF::Application/;
3 use strict; use warnings;
4
5 use OpenILS::Application::Circ::Circulate;
6 use OpenILS::Application::Circ::Survey;
7 use OpenILS::Application::Circ::StatCat;
8 use OpenILS::Application::Circ::Holds;
9 use OpenILS::Application::Circ::Money;
10 use OpenILS::Application::Circ::NonCat;
11 use OpenILS::Application::Circ::CopyLocations;
12
13 use DateTime;
14 use DateTime::Format::ISO8601;
15
16 use OpenILS::Application::AppUtils;
17 my $apputils = "OpenILS::Application::AppUtils";
18 my $U = $apputils;
19 use OpenSRF::Utils qw/:datetime/;
20 use OpenILS::Utils::ModsParser;
21 use OpenILS::Event;
22 use OpenSRF::EX qw(:try);
23 use OpenSRF::Utils::Logger qw(:logger);
24 use OpenILS::Utils::Fieldmapper;
25 use OpenILS::Utils::Editor;
26 #my $logger = "OpenSRF::Utils::Logger";
27
28
29 # ------------------------------------------------------------------------
30 # Top level Circ package;
31 # ------------------------------------------------------------------------
32
33 sub initialize {
34         my $self = shift;
35         OpenILS::Application::Circ::Circulate->initialize();
36 }
37
38
39 __PACKAGE__->register_method(
40         method => 'retrieve_circ',
41         api_name        => 'open-ils.circ.retrieve',
42         signature => q/
43                 Retrieve a circ object by id
44                 @param authtoken Login session key
45                 @pararm circid The id of the circ object
46         /
47 );
48 sub retrieve_circ {
49         my( $s, $c, $a, $i ) = @_;
50         my($reqr, $evt) = $U->checksesperm($a, 'VIEW_CIRCULATIONS');
51         return $evt if $evt;
52         my $circ;
53         ($circ, $evt) = $U->fetch_circulation($i);
54         return $evt if $evt;
55         return $circ;
56 }
57
58
59 # ------------------------------------------------------------------------
60 # Returns an array of {circ, record} hashes checked out by the user.
61 # ------------------------------------------------------------------------
62 __PACKAGE__->register_method(
63         method  => "checkouts_by_user",
64         api_name        => "open-ils.circ.actor.user.checked_out",
65         NOTES           => <<"  NOTES");
66         Returns a list of open circulations as a pile of objects.  each object
67         contains the relevant copy, circ, and record
68         NOTES
69
70 sub checkouts_by_user {
71         my( $self, $client, $user_session, $user_id ) = @_;
72
73         my( $requestor, $target, $copy, $record, $evt );
74
75         ( $requestor, $target, $evt ) = 
76                 $apputils->checkses_requestor( $user_session, $user_id, 'VIEW_CIRCULATIONS');
77         return $evt if $evt;
78
79         my $circs = $apputils->simplereq(
80                 'open-ils.storage',
81                 "open-ils.storage.direct.action.open_circulation.search.atomic", 
82                 { usr => $target->id, checkin_time => undef } );
83 #               { usr => $target->id } );
84
85         my @results;
86         for my $circ (@$circs) {
87
88                 ( $copy, $evt )  = $apputils->fetch_copy($circ->target_copy);
89                 return $evt if $evt;
90
91                 $logger->debug("Retrieving record for copy " . $circ->target_copy);
92
93                 ($record, $evt) = $apputils->fetch_record_by_copy( $circ->target_copy );
94                 return $evt if $evt;
95
96                 my $mods = $apputils->record_to_mvr($record);
97
98                 push( @results, { copy => $copy, circ => $circ, record => $mods } );
99         }
100
101         return \@results;
102
103 }
104
105
106
107 __PACKAGE__->register_method(
108         method  => "checkouts_by_user_slim",
109         api_name        => "open-ils.circ.actor.user.checked_out.slim",
110         NOTES           => <<"  NOTES");
111         Returns a list of open circulation objects
112         NOTES
113
114 # DEPRECAT ME?? XXX
115 sub checkouts_by_user_slim {
116         my( $self, $client, $user_session, $user_id ) = @_;
117
118         my( $requestor, $target, $copy, $record, $evt );
119
120         ( $requestor, $target, $evt ) = 
121                 $apputils->checkses_requestor( $user_session, $user_id, 'VIEW_CIRCULATIONS');
122         return $evt if $evt;
123
124         $logger->debug( 'User ' . $requestor->id . 
125                 " retrieving checked out items for user " . $target->id );
126
127         # XXX Make the call correct..
128         return $apputils->simplereq(
129                 'open-ils.storage',
130                 "open-ils.storage.direct.action.open_circulation.search.atomic", 
131                 { usr => $target->id, checkin_time => undef } );
132 #               { usr => $target->id } );
133 }
134
135
136 __PACKAGE__->register_method(
137         method  => "checkouts_by_user_opac",
138         api_name        => "open-ils.circ.actor.user.checked_out.opac",);
139
140 sub checkouts_by_user_opac {
141         my( $self, $client, $auth, $user_id ) = @_;
142
143         my $e = OpenILS::Utils::Editor->new( authtoken => $auth );
144         return $e->event unless $e->checkauth;
145         $user_id ||= $e->requestor->id;
146         return $e->event unless 
147                 my $patron = $e->retrieve_actor_user($user_id);
148
149         my $data;
150         my $search = {usr => $user_id, stop_fines => undef};
151
152         if( $user_id ne $e->requestor->id ) {
153                 $data = $e->search_action_circulation(
154                         $search, {checkperm=>1, permorg=>$patron->home_ou})
155                         or return $e->event;
156
157         } else {
158                 $data = $e->search_action_circulation($search);
159         }
160
161         return $data;
162 }
163
164
165 __PACKAGE__->register_method(
166         method  => "title_from_transaction",
167         api_name        => "open-ils.circ.circ_transaction.find_title",
168         NOTES           => <<"  NOTES");
169         Returns a mods object for the title that is linked to from the 
170         copy from the hold that created the given transaction
171         NOTES
172
173 sub title_from_transaction {
174         my( $self, $client, $login_session, $transactionid ) = @_;
175
176         my( $user, $circ, $title, $evt );
177
178         ( $user, $evt ) = $apputils->checkses( $login_session );
179         return $evt if $evt;
180
181         ( $circ, $evt ) = $apputils->fetch_circulation($transactionid);
182         return $evt if $evt;
183         
184         ($title, $evt) = $apputils->fetch_record_by_copy($circ->target_copy);
185         return $evt if $evt;
186
187         return $apputils->record_to_mvr($title);
188 }
189
190
191 __PACKAGE__->register_method(
192         method  => "set_circ_lost",
193         api_name        => "open-ils.circ.circulation.set_lost",
194         NOTES           => <<"  NOTES");
195         Params are login, barcode
196         login must have SET_CIRC_LOST perms
197         Sets a circulation to lost
198         NOTES
199
200 __PACKAGE__->register_method(
201         method  => "set_circ_lost",
202         api_name        => "open-ils.circ.circulation.set_claims_returned",
203         NOTES           => <<"  NOTES");
204         Params are login, barcode
205         login must have SET_CIRC_MISSING perms
206         Sets a circulation to lost
207         NOTES
208
209 sub set_circ_lost {
210         my( $self, $client, $login, $args ) = @_;
211         my( $user, $circ, $copy, $evt );
212
213         my $barcode             = $$args{barcode};
214         my $backdate    = $$args{backdate};
215
216         ( $user, $evt ) = $U->checkses($login);
217         return $evt if $evt;
218
219         # Grab the related copy
220         ($copy, $evt) = $U->fetch_copy_by_barcode($barcode);
221         return $evt if $evt;
222
223         my $isclaims    = $self->api_name =~ /claims_returned/;
224         my $islost              = $self->api_name =~ /lost/;
225         my $session             = $U->start_db_session(); 
226
227         # grab the circulation
228         ( $circ ) = $U->fetch_open_circulation( $copy->id );
229         return 1 unless $circ;
230
231         if($islost) {
232                 $evt  = _set_circ_lost($copy, $circ, $user, $session) if $islost;
233                 return $evt if $evt;
234         }
235
236         if($isclaims) {
237                 $evt = _set_circ_claims_returned(
238                         $user, $circ, $session, $backdate );
239                 return $evt if $evt;
240
241 #               $evt = $U->check_perms($user->id, $circ->circ_lib, 'SET_CIRC_CLAIMS_RETURNED');
242 #               return $evt if $evt;
243 #               $circ->stop_fines("CLAIMSRETURNED");
244 #
245 #               $logger->activity("user ".$user->id." marking circ".  $circ->id. " as claims returned");
246 #
247 #               # allow the caller to backdate the circulation and void any fines
248 #               # that occurred after the backdate
249 #               if($backdate) {
250 #                       OpenILS::Application::Circ::Circulate::_checkin_handle_backdate(
251 #                               $backdate, $circ, $user, $session );
252 #               }
253 #
254 #               my $patron;
255 #               ($patron, $evt) = $U->fetch_user($circ->usr);
256 #               return $evt if $evt;
257 #               $patron->claims_returned_count( 
258 #                       $patron->claims_returned_count + 1 );
259 #
260 #               my $stat = $U->storagereq(
261 #                       'open-ils.storage.direct.actor.user.update', $patron );
262 #               return $U->DB_UPDATE_FAILED($patron) unless $stat;
263
264         }
265
266         $circ->stop_fines_time('now') unless $circ->stop_fines_time('now');
267         my $s = $session->request(
268                 "open-ils.storage.direct.action.circulation.update", $circ )->gather(1);
269
270         return $U->DB_UPDATE_FAILED($circ) unless defined($s);
271         $U->commit_db_session($session);
272
273         return 1;
274 }
275
276 sub _set_circ_lost {
277         my( $copy, $circ, $reqr, $session ) = @_;
278
279         my $evt = $U->check_perms($reqr->id, $circ->circ_lib, 'SET_CIRC_LOST');
280         return $evt if $evt;
281
282         $logger->activity("user ".$reqr->id." marking copy ".$copy->id.
283                 " lost  for circ ".  $circ->id. " and checking for necessary charges");
284
285         my $newstat = $U->copy_status_from_name('lost');
286         if( $copy->status ne $newstat->id ) {
287
288                 $copy->status($newstat);
289                 $U->update_copy(
290                         copy            => $copy, 
291                         editor  => $reqr->id, 
292                         session => $session);
293         }
294
295         # if the copy has a price defined and/or a processing fee, bill the patron
296
297         my $copy_price = $copy->price || 0;
298
299         # If the copy has a price configured, charge said price to the user
300         if($copy_price) {
301                 $evt = _make_bill($session, $copy_price, 'Lost Materials', $circ->id);
302                 return $evt if $evt;
303         }
304
305         # if the location that owns the copy has a processing fee, charge the user
306         my $owner = $U->fetch_copy_owner($copy->id);
307         $logger->info("circ fetching org settings for $owner to determine processing fee");
308
309         my $settings = $U->simplereq(
310                 'open-ils.actor', 'open-ils.actor.org_unit.settings.retrieve', $owner );
311         my $fee = $settings->{'circ.lost_materials_processing_fee'} || 0;
312
313         if( $fee ) {
314                 $evt = _make_bill($session, $fee, 'Lost Materials Processing Fee', $circ->id);
315                 return $evt if $evt;
316         }
317         
318         $circ->stop_fines("LOST");              
319         return undef;
320 }
321
322 sub _make_bill {
323         my( $session, $amount, $type, $xactid ) = @_;
324
325         $logger->activity("The system is charging $amount ".
326                 " [$type] for lost materials on circulation $xactid");
327
328         my $bill = Fieldmapper::money::billing->new;
329
330         $bill->xact($xactid);
331         $bill->amount($amount);
332         $bill->billing_type($type); # - XXX these strings should be configurable some day
333         $bill->note('SYSTEM GENERATED');
334
335         my $id = $session->request(
336                 'open-ils.storage.direct.money.billing.create', $bill )->gather(1);
337
338         return $U->DB_UPDATE_FAILED($bill) unless defined $id;
339         return undef;
340 }
341
342 sub _set_circ_claims_returned {
343         my( $reqr, $circ, $session, $backdate ) = @_;
344
345         my $evt = $U->check_perms($reqr->id, $circ->circ_lib, 'SET_CIRC_CLAIMS_RETURNED');
346         return $evt if $evt;
347         $circ->stop_fines("CLAIMSRETURNED");
348
349         $logger->activity("user ".$reqr->id.
350                 " marking circ".  $circ->id. " as claims returned");
351
352         # allow the caller to backdate the circulation and void any fines
353         # that occurred after the backdate
354         if($backdate) {
355                 OpenILS::Application::Circ::Circulate::_checkin_handle_backdate(
356                         $backdate, $circ, $reqr, $session );
357         }
358
359         return undef;
360 }
361
362
363
364 __PACKAGE__->register_method (
365         method          => 'set_circ_due_date',
366         api_name                => 'open-ils.circ.circulation.due_date.update',
367         signature       => q/
368                 Updates the due_date on the given circ
369                 @param authtoken
370                 @param circid The id of the circ to update
371                 @param date The timestamp of the new due date
372         /
373 );
374
375 sub set_circ_due_date {
376         my( $s, $c, $authtoken, $circid, $date ) = @_;
377         my ($circ, $evt) = $U->fetch_circulation($circid);
378         return $evt if $evt;
379
380         my $reqr;
381         ($reqr, $evt) = $U->checkses($authtoken);
382         return $evt if $evt;
383
384         $evt = $U->check_perms($reqr->id, $circ->circ_lib, 'CIRC_OVERRIDE_DUE_DATE');
385         return $evt if $evt;
386
387         $date = clense_ISO8601($date);
388         $logger->activity("user ".$reqr->id.
389                 " updating due_date on circ $circid: $date");
390
391         $circ->due_date($date);
392         my $stat = $U->storagereq(
393                 'open-ils.storage.direct.action.circulation.update', $circ);
394         return $U->DB_UPDATE_FAILED unless defined $stat;
395         return $stat;
396 }
397
398
399 __PACKAGE__->register_method(
400         method          => "create_in_house_use",
401         api_name                => 'open-ils.circ.in_house_use.create',
402         signature       =>      q/
403                 Creates an in-house use action.
404                 @param $authtoken The login session key
405                 @param params A hash of params including
406                         'location' The org unit id where the in-house use occurs
407                         'copyid' The copy in question
408                         'count' The number of in-house uses to apply to this copy
409                 @return An array of id's representing the id's of the newly created
410                 in-house use objects or an event on an error
411         /);
412
413 sub create_in_house_use {
414         my( $self, $client, $authtoken, $params ) = @_;
415
416         my( $staff, $evt, $copy );
417         my $org                 = $params->{location};
418         my $copyid              = $params->{copyid};
419         my $count               = $params->{count} || 1;
420         my $use_time    = $params->{use_time} || 'now';
421
422         if(!$copyid) {
423                 my $barcode = $params->{barcode};
424                 ($copy, $evt) = $U->fetch_copy_by_barcode($barcode);
425                 return $evt if $evt;
426                 $copyid = $copy->id;
427         }
428
429         ($staff, $evt) = $U->checkses($authtoken);
430         return $evt if $evt;
431
432         ($copy, $evt) = $U->fetch_copy($copyid) unless $copy;
433         return $evt if $evt;
434
435         $evt = $U->check_perms($staff->id, $org, 'CREATE_IN_HOUSE_USE');
436         return $evt if $evt;
437
438         $logger->activity("User " . $staff->id .
439                 " creating $count in-house use(s) for copy $copyid at location $org");
440
441         if( $use_time ne 'now' ) {
442                 $use_time = clense_ISO8601($use_time);
443                 $logger->debug("in_house_use setting use time to $use_time");
444         }
445
446         my @ids;
447         for(1..$count) {
448                 my $ihu = Fieldmapper::action::in_house_use->new;
449
450                 $ihu->item($copyid);
451                 $ihu->staff($staff->id);
452                 $ihu->org_unit($org);
453                 $ihu->use_time($use_time);
454
455                 my $id = $U->simplereq(
456                         'open-ils.storage',
457                         'open-ils.storage.direct.action.in_house_use.create', $ihu );
458
459                 return $U->DB_UPDATE_FAILED($ihu) unless $id;
460                 push @ids, $id;
461         }
462
463         return \@ids;
464 }
465
466
467
468 __PACKAGE__->register_method(
469         method  => "view_circs",
470         api_name        => "open-ils.circ.copy_checkout_history.retrieve",
471         notes           => q/
472                 Retrieves the last X circs for a given copy
473                 @param authtoken The login session key
474                 @param copyid The copy to check
475                 @param count How far to go back in the item history
476                 @return An array of circ ids
477         /);
478
479 sub view_circs {
480         my( $self, $client, $authtoken, $copyid, $count ) = @_; 
481
482         my( $requestor, $evt ) = $U->checksesperm(
483                         $authtoken, 'VIEW_COPY_CHECKOUT_HISTORY' );
484         return $evt if $evt;
485
486         return [] unless $count;
487
488         my $circs = $U->storagereq(
489                 'open-ils.storage.direct.action.circulation.search_where.atomic',
490                         { 
491                                 target_copy => $copyid, 
492 #                               opac_renewal => 'f',   
493 #                               desk_renewal => 'f',
494 #                               phone_renewal => 'f',
495                         }, 
496                         { 
497                                 limit => $count, 
498                                 order_by => "xact_start DESC" 
499                         } );
500
501 #       my @users;
502 #       push(@users, $_->usr) for @$circs;
503 #       return \@users;
504
505         return $circs;
506 }
507
508
509 __PACKAGE__->register_method(
510         method  => "circ_count",
511         api_name        => "open-ils.circ.circulation.count",
512         notes           => q/
513                 Returns the number of times the item has circulated
514                 @param copyid The copy to check
515         /);
516
517 sub circ_count {
518         my( $self, $client, $copyid ) = @_; 
519         my $e = OpenILS::Utils::Editor->new;
520         my $circs = $e->search_action_circulation({target_copy => $copyid}, {idlist=>1});
521         return scalar @$circs;
522 }
523
524
525
526 __PACKAGE__->register_method(
527         method          => 'fetch_notes',
528         api_name                => 'open-ils.circ.copy_note.retrieve.all',
529         signature       => q/
530                 Returns an array of copy note objects.  
531                 @param args A named hash of parameters including:
532                         authtoken       : Required if viewing non-public notes
533                         itemid          : The id of the item whose notes we want to retrieve
534                         pub                     : True if all the caller wants are public notes
535                 @return An array of note objects
536         /);
537
538 __PACKAGE__->register_method(
539         method          => 'fetch_notes',
540         api_name                => 'open-ils.circ.call_number_note.retrieve.all',
541         signature       => q/@see open-ils.circ.copy_note.retrieve.all/);
542
543 __PACKAGE__->register_method(
544         method          => 'fetch_notes',
545         api_name                => 'open-ils.circ.title_note.retrieve.all',
546         signature       => q/@see open-ils.circ.copy_note.retrieve.all/);
547
548
549 # NOTE: VIEW_COPY/VOLUME/TITLE_NOTES perms should always be global
550 sub fetch_notes {
551         my( $self, $connection, $args ) = @_;
552
553         my $id = $$args{itemid};
554         my $authtoken = $$args{authtoken};
555         my( $r, $evt);
556
557         if( $self->api_name =~ /copy/ ) {
558                 if( $$args{pub} ) {
559                         return $U->storagereq(
560                                 'open-ils.storage.direct.asset.copy_note.search_where.atomic',
561                                 { owning_copy => $id, pub => 't' } );
562                 } else {
563                         ( $r, $evt ) = $U->checksesperm($authtoken, 'VIEW_COPY_NOTES');
564                         return $evt if $evt;
565                         return $U->storagereq(
566                                 'open-ils.storage.direct.asset.copy_note.search.owning_copy.atomic', $id );
567                 }
568
569         } elsif( $self->api_name =~ /call_number/ ) {
570                 if( $$args{pub} ) {
571                         return $U->storagereq(
572                                 'open-ils.storage.direct.asset.call_number_note.search_where.atomic',
573                                 { call_number => $id, pub => 't' } );
574                 } else {
575                         ( $r, $evt ) = $U->checksesperm($authtoken, 'VIEW_VOLUME_NOTES');
576                         return $evt if $evt;
577                         return $U->storagereq(
578                                 'open-ils.storage.direct.asset.call_number_note.search.call_number.atomic', $id );
579                 }
580
581         } elsif( $self->api_name =~ /title/ ) {
582                 if( $$args{pub} ) {
583                         return $U->storagereq(
584                                 'open-ils.storage.direct.bilbio.record_note.search_where.atomic',
585                                 { record => $id, pub => 't' } );
586                 } else {
587                         ( $r, $evt ) = $U->checksesperm($authtoken, 'VIEW_TITLE_NOTES');
588                         return $evt if $evt;
589                         return $U->storagereq(
590                                 'open-ils.storage.direct.biblio.record_note.search.record.atomic', $id );
591                 }
592         }
593
594         return undef;
595 }
596
597 __PACKAGE__->register_method(
598         method  => 'has_notes',
599         api_name        => 'open-ils.circ.copy.has_notes');
600 __PACKAGE__->register_method(
601         method  => 'has_notes',
602         api_name        => 'open-ils.circ.call_number.has_notes');
603 __PACKAGE__->register_method(
604         method  => 'has_notes',
605         api_name        => 'open-ils.circ.title.has_notes');
606
607
608 sub has_notes {
609         my( $self, $conn, $authtoken, $id ) = @_;
610         my $editor = OpenILS::Utils::Editor->new(authtoken => $authtoken);
611         return $editor->event unless $editor->checkauth;
612
613         my $n = $editor->search_asset_copy_note(
614                 {owning_copy=>$id}, {idlist=>1}) if $self->api_name =~ /copy/;
615
616         $n = $editor->search_asset_call_number_note(
617                 {call_number=>$id}, {idlist=>1}) if $self->api_name =~ /call_number/;
618
619         $n = $editor->search_biblio_record_note(
620                 {record=>$id}, {idlist=>1}) if $self->api_name =~ /title/;
621
622         return scalar @$n;
623 }
624
625 __PACKAGE__->register_method(
626         method          => 'create_copy_note',
627         api_name                => 'open-ils.circ.copy_note.create',
628         signature       => q/
629                 Creates a new copy note
630                 @param authtoken The login session key
631                 @param note     The note object to create
632                 @return The id of the new note object
633         /);
634
635 sub create_copy_note {
636         my( $self, $connection, $authtoken, $note ) = @_;
637         my( $cnowner, $requestor, $evt );
638
639         ($cnowner, $evt) = $U->fetch_copy_owner($note->owning_copy);
640         return $evt if $evt;
641         ($requestor, $evt) = $U->checkses($authtoken);
642         return $evt if $evt;
643         $evt = $U->check_perms($requestor->id, $cnowner, 'CREATE_COPY_NOTE');
644         return $evt if $evt;
645
646         $note->create_date('now');
647         $note->creator($requestor->id);
648         $note->pub( ($note->pub) ? 't' : 'f' );
649
650         my $id = $U->storagereq(
651                 'open-ils.storage.direct.asset.copy_note.create', $note );
652         return $U->DB_UPDATE_FAILED($note) unless $id;
653
654         $logger->activity("User ".$requestor->id." created a new copy ".
655                 "note [$id] for copy ".$note->owning_copy." with text ".$note->value);
656
657         return $id;
658 }
659
660 __PACKAGE__->register_method(
661         method          => 'delete_copy_note',
662         api_name                =>      'open-ils.circ.copy_note.delete',
663         signature       => q/
664                 Deletes an existing copy note
665                 @param authtoken The login session key
666                 @param noteid The id of the note to delete
667                 @return 1 on success - Event otherwise.
668                 /);
669
670 sub delete_copy_note {
671         my( $self, $conn, $authtoken, $noteid ) = @_;
672         my( $requestor, $note, $owner, $evt );
673
674         ($requestor, $evt) = $U->checkses($authtoken);
675         return $evt if $evt;
676
677         ($note, $evt) = $U->fetch_copy_note($noteid);
678         return $evt if $evt;
679
680         if( $note->creator ne $requestor->id ) {
681                 ($owner, $evt) = $U->fetch_copy_onwer($note->owning_copy);
682                 return $evt if $evt;
683                 $evt = $U->check_perms($requestor->id, $owner, 'DELETE_COPY_NOTE');
684                 return $evt if $evt;
685         }
686
687         my $stat = $U->storagereq(
688                 'open-ils.storage.direct.asset.copy_note.delete', $noteid );
689         return $U->DB_UPDATE_FAILED($noteid) unless $stat;
690
691         $logger->activity("User ".$requestor->id." deleted copy note $noteid");
692         return 1;
693 }
694
695
696 1;