AgentFAQTagOverview.pm
1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package Kernel::Modules::AgentFAQTagOverview;
use strict;
use warnings;
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {%Param};
bless ($Self, $Type);
# check needed objects
for (qw(ParamObject DBObject TicketObject LayoutObject LogObject QueueObject ConfigObject EncodeObject MainObject)) {
if ( !$Self->{$_} ) {
$Self->{LayoutObject}->FatalError( Message => "Got no $_!" );
}
}
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
my %Data = ();
if ($Self->{ParamObject}->GetParam( Param => 'Subaction' ) eq "delete") {
my $Var1 = $Self->{ParamObject}->GetParam( Param => 'id' );
$Self->{DBObject}->Do(
SQL => "DELETE FROM faq_tag where id=?",
Bind => [ \$Var1 ],
);
}
$Self->{DBObject}->Prepare(
SQL => "select faq_tag.id, faq_tag.tag, faq_category.name from faq_category left join faq_tag on (faq_category.id = faq_tag.category_id)",
);
while (my @Row = $Self->{DBObject}->FetchrowArray()) {
$Self->{LayoutObject}->Block(
Name=> 'dadostabela',
Data=> {id=>$Row[0], tag=>$Row[1], category=>$Row[2]}
);
}
# build output
my $Output = $Self->{LayoutObject}->Header(Title => "Tag");
if ($Self->{ParamObject}->GetParam( Param => 'added' )) {
my $Added = $Self->{ParamObject}->GetParam( Param => 'added' );
$Output .= $Self->{LayoutObject}->Notify( Info => 'Tag '.$Added.' adicionada!' );
}
if ($Self->{ParamObject}->GetParam( Param => 'edited' )) {
my $Edited = $Self->{ParamObject}->GetParam( Param => 'edited' );
$Output .= $Self->{LayoutObject}->Notify( Info => 'Tag '.$Edited.' modificada!' );
}
$Output .= $Self->{LayoutObject}->NavigationBar();
$Output .= $Self->{LayoutObject}->Output(
Data => \%Data,
TemplateFile => 'AgentFAQTagOverview',
);
$Output .= $Self->{LayoutObject}->Footer();
return $Output;
}
1;