|
Line 0
Link Here
|
|
|
1 |
package Koha::Ticket; |
| 2 |
|
| 3 |
# This file is part of Koha. |
| 4 |
# |
| 5 |
# Koha is free software; you can redistribute it and/or modify it |
| 6 |
# under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation; either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# Koha is distributed in the hope that it will be useful, but |
| 11 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 17 |
|
| 18 |
use Modern::Perl; |
| 19 |
|
| 20 |
use base qw(Koha::Object); |
| 21 |
|
| 22 |
use Koha::Ticket::Update; |
| 23 |
use Koha::Ticket::Updates; |
| 24 |
|
| 25 |
=head1 NAME |
| 26 |
|
| 27 |
Koha::Ticket - Koha Ticket Object class |
| 28 |
|
| 29 |
=head1 API |
| 30 |
|
| 31 |
=head2 Relations |
| 32 |
|
| 33 |
=cut |
| 34 |
|
| 35 |
=head3 reporter |
| 36 |
|
| 37 |
Return the patron who submitted this ticket |
| 38 |
|
| 39 |
=cut |
| 40 |
|
| 41 |
sub reporter { |
| 42 |
my ($self) = @_; |
| 43 |
my $rs = $self->_result->reporter; |
| 44 |
return unless $rs; |
| 45 |
return Koha::Patron->_new_from_dbic($rs); |
| 46 |
} |
| 47 |
|
| 48 |
=head3 resolver |
| 49 |
|
| 50 |
Return the user who resolved this ticket |
| 51 |
|
| 52 |
=cut |
| 53 |
|
| 54 |
sub resolver { |
| 55 |
my ($self) = @_; |
| 56 |
my $rs = $self->_result->resolver; |
| 57 |
return unless $rs; |
| 58 |
return Koha::Patron->_new_from_dbic($rs) if $rs; |
| 59 |
} |
| 60 |
|
| 61 |
=head3 biblio |
| 62 |
|
| 63 |
Return the biblio linked to this ticket |
| 64 |
|
| 65 |
=cut |
| 66 |
|
| 67 |
sub biblio { |
| 68 |
my ($self) = @_; |
| 69 |
my $rs = $self->_result->biblio; |
| 70 |
return unless $rs; |
| 71 |
return Koha::Biblio->_new_from_dbic($rs); |
| 72 |
} |
| 73 |
|
| 74 |
=head3 updates |
| 75 |
|
| 76 |
Return any updates attached to this ticket |
| 77 |
|
| 78 |
=cut |
| 79 |
|
| 80 |
sub updates { |
| 81 |
my ($self) = @_; |
| 82 |
my $rs = $self->_result->ticket_updates; |
| 83 |
return unless $rs; |
| 84 |
return Koha::Ticket::Updates->_new_from_dbic($rs) if $rs; |
| 85 |
} |
| 86 |
|
| 87 |
=head2 Actions |
| 88 |
|
| 89 |
=head3 add_update |
| 90 |
|
| 91 |
=cut |
| 92 |
|
| 93 |
sub add_update { |
| 94 |
my ( $self, $params ) = @_; |
| 95 |
|
| 96 |
my $rs = $self->_result->add_to_ticket_updates($params)->discard_changes; |
| 97 |
|
| 98 |
return Koha::Ticket::Updates->_new_from_dbic($rs); |
| 99 |
} |
| 100 |
|
| 101 |
=head2 Internal methods |
| 102 |
|
| 103 |
=head3 _type |
| 104 |
|
| 105 |
=cut |
| 106 |
|
| 107 |
sub _type { |
| 108 |
return 'Ticket'; |
| 109 |
} |
| 110 |
|
| 111 |
1; |