View | Details | Raw Unified | Return to bug 20144
Collapse All | Expand All

(-)a/C4/Letters.pm (-2 / +5 lines)
Lines 70-75 C4::Letters - Give functions for Letters management Link Here
70
  returns informations about letters.
70
  returns informations about letters.
71
  if needed, $module filters for letters given module
71
  if needed, $module filters for letters given module
72
72
73
  DEPRECATED - You must use Koha::Notice::Templates instead
74
  The group by clause is confusing and can lead to issues
75
73
=cut
76
=cut
74
77
75
sub GetLetters {
78
sub GetLetters {
Lines 80-93 sub GetLetters { Link Here
80
    my $dbh       = C4::Context->dbh;
83
    my $dbh       = C4::Context->dbh;
81
    my $letters   = $dbh->selectall_arrayref(
84
    my $letters   = $dbh->selectall_arrayref(
82
        q|
85
        q|
83
            SELECT module, code, branchcode, name
86
            SELECT code, module, name
84
            FROM letter
87
            FROM letter
85
            WHERE 1
88
            WHERE 1
86
        |
89
        |
87
          . ( $module ? q| AND module = ?| : q|| )
90
          . ( $module ? q| AND module = ?| : q|| )
88
          . ( $code   ? q| AND code = ?|   : q|| )
91
          . ( $code   ? q| AND code = ?|   : q|| )
89
          . ( defined $branchcode   ? q| AND branchcode = ?|   : q|| )
92
          . ( defined $branchcode   ? q| AND branchcode = ?|   : q|| )
90
          . q| GROUP BY code ORDER BY name|, { Slice => {} }
93
          . q| GROUP BY code, module, name ORDER BY name|, { Slice => {} }
91
        , ( $module ? $module : () )
94
        , ( $module ? $module : () )
92
        , ( $code ? $code : () )
95
        , ( $code ? $code : () )
93
        , ( defined $branchcode ? $branchcode : () )
96
        , ( defined $branchcode ? $branchcode : () )
(-)a/t/db_dependent/Letters.t (-2 / +1 lines)
Lines 18-24 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use Test::More tests => 77;
21
use Test::More tests => 76;
22
use Test::MockModule;
22
use Test::MockModule;
23
use Test::Warn;
23
use Test::Warn;
24
24
Lines 176-182 Look at this wonderful biblio timestamp: <<biblio.timestamp>>. Link Here
176
$dbh->do( q|INSERT INTO letter(branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES (?,'my module','my code','my name',1,?,?,'email')|, undef, $library->{branchcode}, $title, $content );
176
$dbh->do( q|INSERT INTO letter(branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES (?,'my module','my code','my name',1,?,?,'email')|, undef, $library->{branchcode}, $title, $content );
177
$letters = C4::Letters::GetLetters();
177
$letters = C4::Letters::GetLetters();
178
is( @$letters, 1, 'GetLetters returns the correct number of letters' );
178
is( @$letters, 1, 'GetLetters returns the correct number of letters' );
179
is( $letters->[0]->{branchcode}, $library->{branchcode}, 'GetLetters gets the branch code correctly' );
180
is( $letters->[0]->{module}, 'my module', 'GetLetters gets the module correctly' );
179
is( $letters->[0]->{module}, 'my module', 'GetLetters gets the module correctly' );
181
is( $letters->[0]->{code}, 'my code', 'GetLetters gets the code correctly' );
180
is( $letters->[0]->{code}, 'my code', 'GetLetters gets the code correctly' );
182
is( $letters->[0]->{name}, 'my name', 'GetLetters gets the name correctly' );
181
is( $letters->[0]->{name}, 'my name', 'GetLetters gets the name correctly' );
(-)a/t/db_dependent/Letters/GetLettersAvailableForALibrary.t (-11 / +10 lines)
Lines 15-21 my $letters = [ Link Here
15
        module                 => 'circulation',
15
        module                 => 'circulation',
16
        code                   => 'code1',
16
        code                   => 'code1',
17
        branchcode             => '',
17
        branchcode             => '',
18
        name                   => 'B default name for code1 circ',
18
        name                   => 'B name for code1 circ',
19
        is_html                => 0,
19
        is_html                => 0,
20
        title                  => 'default title for code1 email',
20
        title                  => 'default title for code1 email',
21
        content                => 'default content for code1 email',
21
        content                => 'default content for code1 email',
Lines 25-31 my $letters = [ Link Here
25
        module                 => 'circulation',
25
        module                 => 'circulation',
26
        code                   => 'code1',
26
        code                   => 'code1',
27
        branchcode             => '',
27
        branchcode             => '',
28
        name                   => 'B default name for code1 circ',
28
        name                   => 'B name for code1 circ',
29
        is_html                => 0,
29
        is_html                => 0,
30
        title                  => 'default title for code1 sms',
30
        title                  => 'default title for code1 sms',
31
        content                => 'default content for code1 sms',
31
        content                => 'default content for code1 sms',
Lines 35-41 my $letters = [ Link Here
35
        module                 => 'circulation',
35
        module                 => 'circulation',
36
        code                   => 'code2',
36
        code                   => 'code2',
37
        branchcode             => '',
37
        branchcode             => '',
38
        name                   => 'A default name for code2 circ',
38
        name                   => 'A name for code2 circ',
39
        is_html                => 0,
39
        is_html                => 0,
40
        title                  => 'default title for code2 email',
40
        title                  => 'default title for code2 email',
41
        content                => 'default content for code2 email',
41
        content                => 'default content for code2 email',
Lines 45-51 my $letters = [ Link Here
45
        module                 => 'circulation',
45
        module                 => 'circulation',
46
        code                   => 'code3',
46
        code                   => 'code3',
47
        branchcode             => '',
47
        branchcode             => '',
48
        name                   => 'C default name for code3 circ',
48
        name                   => 'C name for code3 circ',
49
        is_html                => 0,
49
        is_html                => 0,
50
        title                  => 'default title for code3 email',
50
        title                  => 'default title for code3 email',
51
        content                => 'default content for code3 email',
51
        content                => 'default content for code3 email',
Lines 56-62 my $letters = [ Link Here
56
        module                 => 'cataloguing',
56
        module                 => 'cataloguing',
57
        code                   => 'code1',
57
        code                   => 'code1',
58
        branchcode             => '',
58
        branchcode             => '',
59
        name                   => 'default name for code1 cat',
59
        name                   => 'D name for code1 cat',
60
        is_html                => 0,
60
        is_html                => 0,
61
        title                  => 'default title for code1 cat email',
61
        title                  => 'default title for code1 cat email',
62
        content                => 'default content for code1 cat email',
62
        content                => 'default content for code1 cat email',
Lines 67-73 my $letters = [ Link Here
67
        module                 => 'circulation',
67
        module                 => 'circulation',
68
        code                   => 'code1',
68
        code                   => 'code1',
69
        branchcode             => 'CPL',
69
        branchcode             => 'CPL',
70
        name                   => 'B CPL name for code1 circ',
70
        name                   => 'B name for code1 circ',
71
        is_html                => 0,
71
        is_html                => 0,
72
        title                  => 'CPL title for code1 email',
72
        title                  => 'CPL title for code1 email',
73
        content                => 'CPL content for code1 email',
73
        content                => 'CPL content for code1 email',
Lines 77-93 my $letters = [ Link Here
77
        module                 => 'circulation',
77
        module                 => 'circulation',
78
        code                   => 'code2',
78
        code                   => 'code2',
79
        branchcode             => 'CPL',
79
        branchcode             => 'CPL',
80
        name                   => 'A CPL name for code1 circ',
80
        name                   => 'A name for code2 circ',
81
        is_html                => 0,
81
        is_html                => 0,
82
        title                  => 'CPL title for code1 sms',
82
        title                  => 'CPL title for code2 sms',
83
        content                => 'CPL content for code1 sms',
83
        content                => 'CPL content for code2 sms',
84
        message_transport_type => 'sms',
84
        message_transport_type => 'sms',
85
    },
85
    },
86
    {
86
    {
87
        module                 => 'circulation',
87
        module                 => 'circulation',
88
        code                   => 'code1',
88
        code                   => 'code1',
89
        branchcode             => 'MPL',
89
        branchcode             => 'MPL',
90
        name                   => 'B MPL name for code1 circ',
90
        name                   => 'B name for code1 circ',
91
        is_html                => 0,
91
        is_html                => 0,
92
        title                  => 'MPL title for code1 email',
92
        title                  => 'MPL title for code1 email',
93
        content                => 'MPL content for code1 email',
93
        content                => 'MPL content for code1 email',
94
- 

Return to bug 20144