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 2951-2960 CREATE TABLE aqcontacts ( Link Here
2951
  fax varchar(100) default NULL,  -- contact's fax number
2951
  fax varchar(100) default NULL,  -- contact's fax number
2952
  email varchar(100) default NULL, -- contact's email address
2952
  email varchar(100) default NULL, -- contact's email address
2953
  notes mediumtext, -- notes related to the contact
2953
  notes mediumtext, -- notes related to the contact
2954
  rank SMALLINT default 0, -- display rank for the contact
2954
  claimacquisition BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive acquisitions claims
2955
  claimissues BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive serial claims
2955
  booksellerid int(11) not NULL,
2956
  booksellerid int(11) not NULL,
2956
  PRIMARY KEY  (id),
2957
  PRIMARY KEY  (id),
2957
  CONSTRAINT booksellerid_fk2 FOREIGN KEY (booksellerid)
2958
  CONSTRAINT booksellerid_aqcontacts_fk FOREIGN KEY (booksellerid)
2958
       REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
2959
       REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
2959
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
2960
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
2960
2961
(-)a/installer/data/mysql/updatedatabase.pl (-4 / +12 lines)
Lines 7923-7942 if ( CheckVersion($DBversion) ) { Link Here
7923
        fax varchar(100) default NULL,
7923
        fax varchar(100) default NULL,
7924
        email varchar(100) default NULL,
7924
        email varchar(100) default NULL,
7925
        notes mediumtext,
7925
        notes mediumtext,
7926
        rank SMALLINT default 0,
7926
        claimacquisition BOOLEAN NOT NULL DEFAULT 0,
7927
        claimissues BOOLEAN NOT NULL DEFAULT 0,
7927
        booksellerid int(11) not NULL,
7928
        booksellerid int(11) not NULL,
7928
        PRIMARY KEY  (id),
7929
        PRIMARY KEY  (id),
7929
        CONSTRAINT booksellerid_fk2 FOREIGN KEY (booksellerid)
7930
        CONSTRAINT booksellerid_aqcontacts_fk FOREIGN KEY (booksellerid)
7930
            REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
7931
            REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
7931
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
7932
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
7932
    $dbh->do("INSERT INTO aqcontacts (name, position, phone, altphone, fax,
7933
    $dbh->do("INSERT INTO aqcontacts (name, position, phone, altphone, fax,
7933
            email, notes, booksellerid)
7934
            email, notes, booksellerid, claimacquisition, claimissues)
7934
        SELECT contact, contpos, contphone, contaltphone, contfax, contemail,
7935
        SELECT contact, contpos, contphone, contaltphone, contfax, contemail,
7935
            contnotes, id FROM aqbooksellers;");
7936
            contnotes, id, 1, 1 FROM aqbooksellers;");
7936
    $dbh->do("ALTER TABLE aqbooksellers DROP COLUMN contact,
7937
    $dbh->do("ALTER TABLE aqbooksellers DROP COLUMN contact,
7937
        DROP COLUMN contpos, DROP COLUMN contphone,
7938
        DROP COLUMN contpos, DROP COLUMN contphone,
7938
        DROP COLUMN contaltphone, DROP COLUMN contfax,
7939
        DROP COLUMN contaltphone, DROP COLUMN contfax,
7939
        DROP COLUMN contemail, DROP COLUMN contnotes;");
7940
        DROP COLUMN contemail, DROP COLUMN contnotes;");
7941
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contact>>', '<<aqcontacts.name>>')");
7942
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contpos>>', '<<aqcontacts.position>>')");
7943
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contphone>>', '<<aqcontacts.phone>>')");
7944
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contaltphone>>', '<<aqcontacts.altphone>>')");
7945
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contfax>>', '<<aqcontacts.contfax>>')");
7946
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contemail>>', '<<aqcontacts.contemail>>')");
7947
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contnotes>>', '<<aqcontacts.contnotes>>')");
7940
    print "Upgrade to $DBversion done (Bug 10402: Move bookseller contacts to separate table)\n";
7948
    print "Upgrade to $DBversion done (Bug 10402: Move bookseller contacts to separate table)\n";
7941
    SetVersion($DBversion);
7949
    SetVersion($DBversion);
7942
}
7950
}
(-)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 (-5 / +83 lines)
Lines 19-29 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 4;
22
use Test::MockModule;
23
use Test::More tests => 14;
23
24
24
use C4::Context;
25
my %mail;
25
use C4::Letters;
26
my $module = new Test::MockModule('Mail::Sendmail');
26
use C4::Members;
27
$module->mock(
28
    'sendmail',
29
    sub {
30
        warn "Fake sendmail";
31
        %mail = @_;
32
    }
33
);
34
35
36
use_ok('C4::Context');
37
use_ok('C4::Members');
38
use_ok('C4::Acquisition');
39
use_ok('C4::Biblio');
40
use_ok('C4::Bookseller');
41
42
use_ok('C4::Letters');
27
43
28
my $dbh = C4::Context->dbh;
44
my $dbh = C4::Context->dbh;
29
45
Lines 68-71 is( Link Here
68
    'message marked failed if tried to send SMS message for borrower with no smsalertnumber set (bug 11208)'
84
    'message marked failed if tried to send SMS message for borrower with no smsalertnumber set (bug 11208)'
69
);
85
);
70
86
87
$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>');});
88
89
my $booksellerid = C4::Bookseller::AddBookseller(
90
    {
91
        name => "my vendor",
92
        address1 => "bookseller's address",
93
        phone => "0123456",
94
        active => 1,
95
        deliverytime => 5,
96
    },
97
    [
98
        { name => 'John Smith',  phone => '0123456x1', claimacquisition => 1 },
99
        { name => 'Leo Tolstoy', phone => '0123456x2', claimissues => 1 },
100
    ]
101
);
102
my $basketno = NewBasket($booksellerid, 1);
103
104
my $budgetid = C4::Budgets::AddBudget({
105
    budget_code => "budget_code_test_letters",
106
    budget_name => "budget_name_test_letters",
107
});
108
109
my $ordernumber;
110
my $bib = MARC::Record->new();
111
if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
112
    $bib->append_fields(
113
        MARC::Field->new('200', ' ', ' ', a => 'Silence in the library'),
114
    );
115
} else {
116
    $bib->append_fields(
117
        MARC::Field->new('245', ' ', ' ', a => 'Silence in the library'),
118
    );
119
}
120
121
my ($biblionumber, $biblioitemnumber) = AddBiblio($bib, '');
122
( undef, $ordernumber ) = C4::Acquisition::NewOrder(
123
    {
124
        basketno => $basketno,
125
        quantity => 1,
126
        biblionumber => $biblionumber,
127
        budget_id => $budgetid,
128
    }
129
);
130
131
C4::Acquisition::CloseBasket( $basketno );
132
my $err;
133
eval {
134
    warn "This test may issue a warning. Please ignore it.\n";
135
    $err = SendAlerts( 'claimacquisition', [ $ordernumber ], 'TESTACQCLAIM' );
136
};
137
is($err->{'error'}, 'no_email', "Trying to send an alert when there's no e-mail results in an error");
138
139
my $bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
140
$bookseller->{'contacts'}->[0]->email('testemail@mydomain.com');
141
C4::Bookseller::ModBookseller($bookseller);
142
143
eval {
144
    $err = SendAlerts( 'claimacquisition', [ $ordernumber ], 'TESTACQCLAIM' );
145
};
146
is($err, 1, "Successfully sent claim");
147
is($mail{'To'}, 'testemail@mydomain.com');
148
is($mail{'Message'}, 'my vendor|John Smith|<order>Ordernumber ' . $ordernumber . ' (Silence in the library) (1 ordered)</order>', 'Claim notice text constructed successfully');
149
71
$dbh->rollback;
150
$dbh->rollback;
72
- 

Return to bug 10402