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

(-)a/C4/Bookseller/Contact.pm (-7 / +16 lines)
Lines 63-72 Contact's e-mail address. Link Here
63
63
64
Notes about contact.
64
Notes about contact.
65
65
66
=item rank
66
=item claimacquistion
67
67
68
Ranking of the contact so that the contact can be given the correct
68
Whether the contact should receive acquisitions claims.
69
priority in display.
69
70
=item claimissues
71
72
Whether the contact should receive serials claims.
70
73
71
=item bookseller
74
=item bookseller
72
75
Lines 81-87 use C4::Context; Link Here
81
84
82
use base qw(Class::Accessor);
85
use base qw(Class::Accessor);
83
86
84
__PACKAGE__->mk_accessors(qw(id name position phone altphone fax email notes rank bookseller));
87
__PACKAGE__->mk_accessors(qw(id name position phone altphone fax email notes claimacquisition claimissues bookseller));
85
88
86
=head1 METHODS
89
=head1 METHODS
87
90
Lines 152-163 sub save { Link Here
152
    my ($self) = @_;
155
    my ($self) = @_;
153
156
154
    my $query;
157
    my $query;
155
    my @params = ($self->name, $self->position, $self->phone, $self->altphone, $self->fax, $self->email, $self->notes, $self->rank, $self->bookseller);
158
    my @params = (
159
        $self->name,  $self->position,
160
        $self->phone, $self->altphone,
161
        $self->fax,   $self->email,
162
        $self->notes, $self->claimacquisition ? 1 : 0,
163
        $self->claimissues ? 1 : 0, $self->bookseller
164
    );
156
    if ($self->id) {
165
    if ($self->id) {
157
        $query = 'UPDATE aqcontacts SET name = ?, position = ?, phone = ?, altphone = ?, fax = ?, email = ?, notes = ?, rank = ?, booksellerid = ? WHERE id = ?;';
166
        $query = 'UPDATE aqcontacts SET name = ?, position = ?, phone = ?, altphone = ?, fax = ?, email = ?, notes = ?, claimacquisition = ?, claimissues = ?, booksellerid = ? WHERE id = ?;';
158
        push @params, $self->id;
167
        push @params, $self->id;
159
    } else {
168
    } else {
160
        $query = 'INSERT INTO aqcontacts (name, position, phone, altphone, fax, email, notes, rank, booksellerid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);';
169
        $query = 'INSERT INTO aqcontacts (name, position, phone, altphone, fax, email, notes, claimacquisition, claimissues, booksellerid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);';
161
    }
170
    }
162
    my $dbh = C4::Context->dbh;
171
    my $dbh = C4::Context->dbh;
163
    my $sth = $dbh->prepare($query);
172
    my $sth = $dbh->prepare($query);
(-)a/C4/Letters.pm (-2 / +7 lines)
Lines 346-355 sub SendAlerts { Link Here
346
          $dbh->prepare("select * from aqbooksellers where id=?");
346
          $dbh->prepare("select * from aqbooksellers where id=?");
347
        $sthbookseller->execute( $dataorders->[0]->{booksellerid} );
347
        $sthbookseller->execute( $dataorders->[0]->{booksellerid} );
348
        my $databookseller = $sthbookseller->fetchrow_hashref;
348
        my $databookseller = $sthbookseller->fetchrow_hashref;
349
        my $sthcontact =
350
          $dbh->prepare("SELECT * FROM aqcontacts WHERE booksellerid=? AND $type=1 LIMIT 1");
351
        $sthcontact->execute( $dataorders->[0]->{booksellerid} );
352
        my $datacontact = $sthcontact->fetchrow_hashref;
349
353
350
        my @email;
354
        my @email;
351
        push @email, $databookseller->{bookselleremail} if $databookseller->{bookselleremail};
355
        push @email, $databookseller->{bookselleremail} if $databookseller->{bookselleremail};
352
        push @email, $databookseller->{contemail}       if $databookseller->{contemail};
356
        push @email, $datacontact->{email}           if ( $datacontact && $datacontact->{email} );
353
        unless (@email) {
357
        unless (@email) {
354
            warn "Bookseller $dataorders->[0]->{booksellerid} without emails";
358
            warn "Bookseller $dataorders->[0]->{booksellerid} without emails";
355
            return { error => "no_email" };
359
            return { error => "no_email" };
Lines 363-368 sub SendAlerts { Link Here
363
            tables => {
367
            tables => {
364
                'branches'    => $userenv->{branch},
368
                'branches'    => $userenv->{branch},
365
                'aqbooksellers' => $databookseller,
369
                'aqbooksellers' => $databookseller,
370
                'aqcontacts'    => $datacontact,
366
            },
371
            },
367
            repeat => $dataorders,
372
            repeat => $dataorders,
368
            want_librarian => 1,
373
            want_librarian => 1,
Lines 383-389 sub SendAlerts { Link Here
383
            $type eq 'claimissues' ? "CLAIM ISSUE" : "ACQUISITION CLAIM",
388
            $type eq 'claimissues' ? "CLAIM ISSUE" : "ACQUISITION CLAIM",
384
            undef,
389
            undef,
385
            "To="
390
            "To="
386
                . $databookseller->{contemail}
391
                . join( ',', @email )
387
                . " Title="
392
                . " Title="
388
                . $letter->{title}
393
                . $letter->{title}
389
                . " Content="
394
                . " Content="
(-)a/acqui/updatesupplier.pl (-6 / +8 lines)
Lines 37-46 All informations regarding this supplier are listed on input parameter. Link Here
37
Here is the list :
37
Here is the list :
38
38
39
supplier, id, company, company_postal, physical, company_phone,
39
supplier, id, company, company_postal, physical, company_phone,
40
physical, company_phone, company_fax, website, company_contact_name,
40
physical, company_phone, company_fax, website, company_email, notes,
41
company_contact_position, contact_phone, contact_phone_2, contact_fax,
41
status, publishers_imprints, list_currency, gst, list_gst, invoice_gst,
42
company_email, contact_notes, notes, status, publishers_imprints,
42
discount, gstrate, contact_name, contact_position, contact_phone,
43
list_currency, gst, list_gst, invoice_gst, discount, gstrate.
43
contact_altphone, contact_fax, contact_email, contact_notes,
44
contact_claimacquisition, contact_claimissues.
45
44
46
45
=cut
47
=cut
46
48
Lines 102-115 $data{'active'}=$input->param('status'); Link Here
102
my @contacts;
104
my @contacts;
103
my %contact_info;
105
my %contact_info;
104
106
105
foreach (qw(id name position phone altphone fax email notes)) {
107
foreach (qw(id name position phone altphone fax email notes claimacquisition claimissues)) {
106
    $contact_info{$_} = [ $input->param('contact_' . $_) ];
108
    $contact_info{$_} = [ $input->param('contact_' . $_) ];
107
}
109
}
108
110
109
for my $cnt (0..scalar(@{$contact_info{'id'}})) {
111
for my $cnt (0..scalar(@{$contact_info{'id'}})) {
110
    my %contact;
112
    my %contact;
111
    my $real_contact;
113
    my $real_contact;
112
    foreach (qw(id name position phone altphone fax email notes)) {
114
    foreach (qw(id name position phone altphone fax email notes claimacquisition claimissues)) {
113
        $contact{$_} = $contact_info{$_}->[$cnt];
115
        $contact{$_} = $contact_info{$_}->[$cnt];
114
        $real_contact = 1 if $contact{$_};
116
        $real_contact = 1 if $contact{$_};
115
    }
117
    }
(-)a/installer/data/mysql/kohastructure.sql (-2 / +3 lines)
Lines 2869-2878 CREATE TABLE aqcontacts ( Link Here
2869
  fax varchar(100) default NULL,  -- contact's fax number
2869
  fax varchar(100) default NULL,  -- contact's fax number
2870
  email varchar(100) default NULL, -- contact's email address
2870
  email varchar(100) default NULL, -- contact's email address
2871
  notes mediumtext, -- notes related to the contact
2871
  notes mediumtext, -- notes related to the contact
2872
  rank SMALLINT default 0, -- display rank for the contact
2872
  claimacquisition BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive acquisitions claims
2873
  claimissues BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive serial claims
2873
  booksellerid int(11) not NULL,
2874
  booksellerid int(11) not NULL,
2874
  PRIMARY KEY  (id),
2875
  PRIMARY KEY  (id),
2875
  CONSTRAINT booksellerid_fk2 FOREIGN KEY (booksellerid)
2876
  CONSTRAINT booksellerid_aqcontacts_fk FOREIGN KEY (booksellerid)
2876
       REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
2877
       REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
2877
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
2878
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
2878
2879
(-)a/installer/data/mysql/updatedatabase.pl (-4 / +12 lines)
Lines 7166-7185 if ( CheckVersion($DBversion) ) { Link Here
7166
        fax varchar(100) default NULL,
7166
        fax varchar(100) default NULL,
7167
        email varchar(100) default NULL,
7167
        email varchar(100) default NULL,
7168
        notes mediumtext,
7168
        notes mediumtext,
7169
        rank SMALLINT default 0,
7169
        claimacquisition BOOLEAN NOT NULL DEFAULT 0,
7170
        claimissues BOOLEAN NOT NULL DEFAULT 0,
7170
        booksellerid int(11) not NULL,
7171
        booksellerid int(11) not NULL,
7171
        PRIMARY KEY  (id),
7172
        PRIMARY KEY  (id),
7172
        CONSTRAINT booksellerid_fk2 FOREIGN KEY (booksellerid)
7173
        CONSTRAINT booksellerid_aqcontacts_fk FOREIGN KEY (booksellerid)
7173
            REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
7174
            REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
7174
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
7175
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
7175
    $dbh->do("INSERT INTO aqcontacts (name, position, phone, altphone, fax,
7176
    $dbh->do("INSERT INTO aqcontacts (name, position, phone, altphone, fax,
7176
            email, notes, booksellerid)
7177
            email, notes, booksellerid, claimacquisition, claimissues)
7177
        SELECT contact, contpos, contphone, contaltphone, contfax, contemail,
7178
        SELECT contact, contpos, contphone, contaltphone, contfax, contemail,
7178
            contnotes, id FROM aqbooksellers;");
7179
            contnotes, id, 1, 1 FROM aqbooksellers;");
7179
    $dbh->do("ALTER TABLE aqbooksellers DROP COLUMN contact,
7180
    $dbh->do("ALTER TABLE aqbooksellers DROP COLUMN contact,
7180
        DROP COLUMN contpos, DROP COLUMN contphone,
7181
        DROP COLUMN contpos, DROP COLUMN contphone,
7181
        DROP COLUMN contaltphone, DROP COLUMN contfax,
7182
        DROP COLUMN contaltphone, DROP COLUMN contfax,
7182
        DROP COLUMN contemail, DROP COLUMN contnotes;");
7183
        DROP COLUMN contemail, DROP COLUMN contnotes;");
7184
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contact>>', '<<aqcontacts.name>>')");
7185
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contpos>>', '<<aqcontacts.position>>')");
7186
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contphone>>', '<<aqcontacts.phone>>')");
7187
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contaltphone>>', '<<aqcontacts.altphone>>')");
7188
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contfax>>', '<<aqcontacts.contfax>>')");
7189
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contemail>>', '<<aqcontacts.contemail>>')");
7190
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contnotes>>', '<<aqcontacts.contnotes>>')");
7183
    print "Upgrade to $DBversion done (Bug 10402: Move bookseller contacts to separate table)\n";
7191
    print "Upgrade to $DBversion done (Bug 10402: Move bookseller contacts to separate table)\n";
7184
    SetVersion($DBversion);
7192
    SetVersion($DBversion);
7185
}
7193
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt (+35 lines)
Lines 16-21 Link Here
16
            <input type="text" size="40" id="contact_email[% contact.id %]" name="contact_email" value="[% contact.email %]" /></li>
16
            <input type="text" size="40" id="contact_email[% contact.id %]" name="contact_email" value="[% contact.email %]" /></li>
17
        <li><label for="contact_notes[% contact.id %]">Notes: </label>
17
        <li><label for="contact_notes[% contact.id %]">Notes: </label>
18
            <textarea id="contact_notes[% contact.id %]" name="contact_notes" cols="40" rows="4">[% contnotes %]</textarea></li>
18
            <textarea id="contact_notes[% contact.id %]" name="contact_notes" cols="40" rows="4">[% contnotes %]</textarea></li>
19
        <li><label for="contact_claimacquisition[% contact.id %]">Contact about late orders?</label>
20
            [% IF contact.claimacquisition %]
21
                <input type="checkbox" id="contact_claimacquisition[% contact.id %]" class="contact_claimacquisition" checked="checked"></input>
22
            [% ELSE %]
23
                <input type="checkbox" id="contact_claimacquisition[% contact.id %]" class="contact_claimacquisition"></input>
24
            [% END %]
25
            <input type="hidden" class="contact_claimacquisition_hidden" name="contact_claimacquisition" value="[% contact.claimacquisition %]"></input>
26
        <li><label for="contact_claimissues[% contact.id %]">Contact about late issues?</label>
27
            [% IF contact.claimissues %]
28
                <input type="checkbox" id="contact_claimissues[% contact.id %]" class="contact_claimissues" checked="checked"></input>
29
            [% ELSE %]
30
                <input type="checkbox" id="contact_claimissues[% contact.id %]" class="contact_claimissues"></input>
31
            [% END %]
32
            <input type="hidden" class="contact_claimissues_hidden" name="contact_claimissues" value="[% contact.claimissues %]"></input>
33
        </li>
19
        [% IF contact.id %]<li><button class="btn" class="delete-contact"><i class="icon-remove"></i> Delete contact</li>[% END %]
34
        [% IF contact.id %]<li><button class="btn" class="delete-contact"><i class="icon-remove"></i> Delete contact</li>[% END %]
20
    </ol>
35
    </ol>
21
[% END %]
36
[% END %]
Lines 32-37 Link Here
32
    [% IF ( contact.notes ) %]
47
    [% IF ( contact.notes ) %]
33
        <p><span class="label">Notes: </span>[% contact.notes %]</p>
48
        <p><span class="label">Notes: </span>[% contact.notes %]</p>
34
    [% END %]
49
    [% END %]
50
    [% IF ( contact.claimacquisition ) %]
51
        <p><span class="label">Receives claims for late orders</span></p>
52
    [% END %]
53
    [% IF ( contact.claimissues ) %]
54
        <p><span class="label">Receives claims for late issues</span></p>
55
    [% END %]
35
[% END %]
56
[% END %]
36
57
37
[% INCLUDE 'doc-head-open.inc' %]
58
[% INCLUDE 'doc-head-open.inc' %]
Lines 93-98 function delete_contact() { Link Here
93
    } ) );
114
    } ) );
94
    $('.delete-contact').click(delete_contact);
115
    $('.delete-contact').click(delete_contact);
95
    $('#add-contact').click(add_contact);
116
    $('#add-contact').click(add_contact);
117
    $('.contact_claimacquisition').click(function () {
118
        $('.contact_claimacquisition').filter(':checked').not(this).removeAttr('checked');
119
        $('.contact_claimacquisition_hidden').each(function () {
120
            $(this).val('0');
121
        });
122
        $(this).next('.contact_claimacquisition_hidden').val('1');
123
    });
124
    $('.contact_claimissues').click(function () {
125
        $('.contact_claimissues').filter(':checked').not(this).removeAttr('checked');
126
        $('.contact_claimissues_hidden').each(function () {
127
            $(this).val('0');
128
        });
129
        $(this).next('.contact_claimissues_hidden').val('1');
130
    });
96
 });
131
 });
97
//]]>
132
//]]>
98
</script>
133
</script>
(-)a/t/db_dependent/Letters.t (-1 / +92 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
#
3
# This Koha test module is a stub!
4
# Add more tests here!!!
5
6
use strict;
7
use warnings;
8
use Test::MockModule;
9
use Test::More tests => 9;
10
11
my %mail;
12
my $module = new Test::MockModule('Mail::Sendmail');
13
$module->mock(
14
    'sendmail',
15
    sub {
16
        %mail = @_;
17
    }
18
);
19
20
use_ok('C4::Context');
21
use_ok('C4::Acquisition');
22
use_ok('C4::Biblio');
23
use_ok('C4::Bookseller');
24
25
my $dbh = C4::Context->dbh;
26
$dbh->{AutoCommit} = 0;
27
$dbh->{RaiseError} = 1;
28
29
$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('claimacquisition','TESTACQCLAIM','Acquisition Claim','Item Not Received','<<aqbooksellers.name>>|<<aqcontacts.name>>|<order>Ordernumber <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> ordered)</order>');});
30
31
use_ok('C4::Letters');
32
33
my $booksellerid = C4::Bookseller::AddBookseller(
34
    {
35
        name => "my vendor",
36
        address1 => "bookseller's address",
37
        phone => "0123456",
38
        active => 1,
39
        deliverytime => 5,
40
    },
41
    [
42
        { name => 'John Smith',  phone => '0123456x1', claimacquisition => 1 },
43
        { name => 'Leo Tolstoy', phone => '0123456x2', claimissues => 1 },
44
    ]
45
);
46
my $basketno = NewBasket($booksellerid, 1);
47
48
my $budgetid = C4::Budgets::AddBudget({
49
    budget_code => "budget_code_test_letters",
50
    budget_name => "budget_name_test_letters",
51
});
52
53
my $ordernumber;
54
my $bib = MARC::Record->new();
55
if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
56
    $bib->append_fields(
57
        MARC::Field->new('200', ' ', ' ', a => 'Silence in the library'),
58
    );
59
} else {
60
    $bib->append_fields(
61
        MARC::Field->new('245', ' ', ' ', a => 'Silence in the library'),
62
    );
63
}
64
65
my ($biblionumber, $biblioitemnumber) = AddBiblio($bib, '');
66
( undef, $ordernumber ) = C4::Acquisition::NewOrder(
67
    {
68
        basketno => $basketno,
69
        quantity => 1,
70
        biblionumber => $biblionumber,
71
        budget_id => $budgetid,
72
    }
73
);
74
75
C4::Acquisition::CloseBasket( $basketno );
76
my $err;
77
eval {
78
    warn "This test may issue a warning. Please ignore it.\n";
79
    $err = SendAlerts( 'claimacquisition', [ $ordernumber ], 'TESTACQCLAIM' );
80
};
81
is($err->{'error'}, 'no_email', "Trying to send an alert when there's no e-mail results in an error");
82
83
my $bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
84
$bookseller->{'contacts'}->[0]->email('testemail@mydomain.com');
85
C4::Bookseller::ModBookseller($bookseller);
86
87
eval {
88
    $err = SendAlerts( 'claimacquisition', [ $ordernumber ], 'TESTACQCLAIM' );
89
};
90
is($err, 1, "Successfully sent claim");
91
is($mail{'To'}, 'testemail@mydomain.com');
92
is($mail{'Message'}, 'my vendor|John Smith|<order>Ordernumber ' . $ordernumber . ' (Silence in the library) (1 ordered)</order>', 'Claim notice text constructed successfully');

Return to bug 10402