Lines 21-26
use Modern::Perl;
Link Here
|
21 |
|
21 |
|
22 |
use Carp; |
22 |
use Carp; |
23 |
|
23 |
|
|
|
24 |
use C4::Context; |
25 |
|
24 |
use Koha::Database; |
26 |
use Koha::Database; |
25 |
use Koha::DateUtils; |
27 |
use Koha::DateUtils; |
26 |
use Koha::Exceptions; |
28 |
use Koha::Exceptions; |
Lines 40-45
Koha::RotatingCollection - Koha Rotating collection Object class
Link Here
|
40 |
|
42 |
|
41 |
=cut |
43 |
=cut |
42 |
|
44 |
|
|
|
45 |
=head3 new |
46 |
|
47 |
$collection = Koha::RotatingCollection->new(); |
48 |
|
49 |
This sub automatically adds date of creation and librarian who created collection if it is not present in params. |
50 |
|
51 |
=cut |
52 |
|
53 |
sub new { |
54 |
my ($class, $params) = @_; |
55 |
$params->{createdOn} //= output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); |
56 |
$params->{createdBy} = undef; |
57 |
$params->{createdBy} = C4::Context->userenv->{number} if defined C4::Context->userenv; |
58 |
|
59 |
return $class->SUPER::new($params); |
60 |
} |
61 |
|
43 |
=head3 items |
62 |
=head3 items |
44 |
|
63 |
|
45 |
=cut |
64 |
=cut |
Lines 58-63
sub items {
Link Here
|
58 |
return $items; |
77 |
return $items; |
59 |
} |
78 |
} |
60 |
|
79 |
|
|
|
80 |
=head3 untransferred_items |
81 |
|
82 |
my $untransferred_items = $collection->untransferred_items; |
83 |
|
84 |
Return all items which are not transferred yet |
85 |
|
86 |
=cut |
87 |
|
88 |
sub untransferred_items { |
89 |
my ( $self ) = @_; |
90 |
|
91 |
my $items = Koha::Items->search( |
92 |
{ |
93 |
'collections_trackings.colId' => $self->colId, |
94 |
'branchtransfers.branchtransfer_id' => undef, |
95 |
}, |
96 |
{ |
97 |
join => [ 'collections_trackings', 'branchtransfers' ] |
98 |
} |
99 |
); |
100 |
|
101 |
return $items; |
102 |
} |
103 |
|
61 |
=head3 add_item |
104 |
=head3 add_item |
62 |
|
105 |
|
63 |
$collection->add_item( $item_object ); |
106 |
$collection->add_item( $item_object ); |
Lines 134-140
sub transfer {
Link Here
|
134 |
|
177 |
|
135 |
Koha::Exceptions::ObjectNotFound->throw if ref($library) ne 'Koha::Library'; |
178 |
Koha::Exceptions::ObjectNotFound->throw if ref($library) ne 'Koha::Library'; |
136 |
|
179 |
|
137 |
$self->colBranchcode( $library->branchcode )->store; |
180 |
$self->colBranchcode( $library->branchcode ); |
|
|
181 |
$self->lastTransferredOn( output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }) ); |
182 |
$self->store; |
138 |
|
183 |
|
139 |
my $from; |
184 |
my $from; |
140 |
$from = C4::Context->userenv->{'branch'} if C4::Context->userenv; |
185 |
$from = C4::Context->userenv->{'branch'} if C4::Context->userenv; |
Lines 162-167
sub transfer {
Link Here
|
162 |
} |
207 |
} |
163 |
} |
208 |
} |
164 |
|
209 |
|
|
|
210 |
=head3 creator |
211 |
|
212 |
$creator = $collection->creator |
213 |
|
214 |
return creator (Koha::Patron object) of this collection |
215 |
|
216 |
=cut |
217 |
|
218 |
sub creator { |
219 |
my ( $self ) = @_; |
220 |
|
221 |
return unless $self->createdBy; |
222 |
|
223 |
my $patron = Koha::Patrons->find( $self->createdBy ); |
224 |
|
225 |
return $patron; |
226 |
} |
227 |
|
165 |
=head3 type |
228 |
=head3 type |
166 |
|
229 |
|
167 |
=cut |
230 |
=cut |