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

(-)a/C4/Bookseller.pm (-2 / +2 lines)
Lines 248-254 sub ModBookseller { Link Here
248
            discount=?,notes=?,gstrate=?,deliverytime=?
248
            discount=?,notes=?,gstrate=?,deliverytime=?
249
        WHERE id=?';
249
        WHERE id=?';
250
    my $sth = $dbh->prepare($query);
250
    my $sth = $dbh->prepare($query);
251
    return $sth->execute(
251
    my $cnt = $sth->execute(
252
        $data->{'name'},         $data->{'address1'},
252
        $data->{'name'},         $data->{'address1'},
253
        $data->{'address2'},     $data->{'address3'},
253
        $data->{'address2'},     $data->{'address3'},
254
        $data->{'address4'},     $data->{'postal'},
254
        $data->{'address4'},     $data->{'postal'},
Lines 278-284 sub ModBookseller { Link Here
278
    }
278
    }
279
    $sth = $dbh->prepare($contactquery);
279
    $sth = $dbh->prepare($contactquery);
280
    $sth->execute(@contactparams);
280
    $sth->execute(@contactparams);
281
    return;
281
    return $cnt;
282
}
282
}
283
283
284
=head2 DelBookseller
284
=head2 DelBookseller
(-)a/C4/Bookseller/Contact.pm (-7 / +25 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 claimacquisition
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.
73
74
=item acqprimary
75
76
Whether the contact is the primary contact for acquisitions.
77
78
=item serialsprimary
79
80
Whether the contact is the primary contact for serials.
70
81
71
=item bookseller
82
=item bookseller
72
83
Lines 81-87 use C4::Context; Link Here
81
92
82
use base qw(Class::Accessor);
93
use base qw(Class::Accessor);
83
94
84
__PACKAGE__->mk_accessors(qw(id name position phone altphone fax email notes rank bookseller));
95
__PACKAGE__->mk_accessors(qw(id name position phone altphone fax email notes claimacquisition claimissues acqprimary serialsprimary bookseller));
85
96
86
=head1 METHODS
97
=head1 METHODS
87
98
Lines 152-163 sub save { Link Here
152
    my ($self) = @_;
163
    my ($self) = @_;
153
164
154
    my $query;
165
    my $query;
155
    my @params = ($self->name, $self->position, $self->phone, $self->altphone, $self->fax, $self->email, $self->notes, $self->rank, $self->bookseller);
166
    my @params = (
167
        $self->name,  $self->position,
168
        $self->phone, $self->altphone,
169
        $self->fax,   $self->email,
170
        $self->notes, $self->acqprimary ? 1 : 0,
171
        $self->serialsprimary ? 1 : 0, $self->claimacquisition ? 1 : 0,
172
        $self->claimissues ? 1 : 0, $self->bookseller
173
    );
156
    if ($self->id) {
174
    if ($self->id) {
157
        $query = 'UPDATE aqcontacts SET name = ?, position = ?, phone = ?, altphone = ?, fax = ?, email = ?, notes = ?, rank = ?, booksellerid = ? WHERE id = ?;';
175
        $query = 'UPDATE aqcontacts SET name = ?, position = ?, phone = ?, altphone = ?, fax = ?, email = ?, notes = ?, acqprimary = ?, serialsprimary = ?, claimacquisition = ?, claimissues = ?, booksellerid = ? WHERE id = ?;';
158
        push @params, $self->id;
176
        push @params, $self->id;
159
    } else {
177
    } else {
160
        $query = 'INSERT INTO aqcontacts (name, position, phone, altphone, fax, email, notes, rank, booksellerid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);';
178
        $query = 'INSERT INTO aqcontacts (name, position, phone, altphone, fax, email, notes, acqprimary, serialsprimary, claimacquisition, claimissues, booksellerid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);';
161
    }
179
    }
162
    my $dbh = C4::Context->dbh;
180
    my $dbh = C4::Context->dbh;
163
    my $sth = $dbh->prepare($query);
181
    my $sth = $dbh->prepare($query);
(-)a/C4/Letters.pm (-2 / +14 lines)
Lines 326-339 sub SendAlerts { Link Here
326
          $dbh->prepare("select * from aqbooksellers where id=?");
326
          $dbh->prepare("select * from aqbooksellers where id=?");
327
        $sthbookseller->execute( $dataorders->[0]->{booksellerid} );
327
        $sthbookseller->execute( $dataorders->[0]->{booksellerid} );
328
        my $databookseller = $sthbookseller->fetchrow_hashref;
328
        my $databookseller = $sthbookseller->fetchrow_hashref;
329
        my $addressee =  $type eq 'claimacquisition' ? 'acqprimary' : 'serialsprimary';
330
        my $sthcontact =
331
          $dbh->prepare("SELECT * FROM aqcontacts WHERE booksellerid=? AND $type=1 ORDER BY $addressee DESC");
332
        $sthcontact->execute( $dataorders->[0]->{booksellerid} );
333
        my $datacontact = $sthcontact->fetchrow_hashref;
329
334
330
        my @email;
335
        my @email;
336
        my @cc;
331
        push @email, $databookseller->{bookselleremail} if $databookseller->{bookselleremail};
337
        push @email, $databookseller->{bookselleremail} if $databookseller->{bookselleremail};
332
        push @email, $databookseller->{contemail}       if $databookseller->{contemail};
338
        push @email, $datacontact->{email}           if ( $datacontact && $datacontact->{email} );
333
        unless (@email) {
339
        unless (@email) {
334
            warn "Bookseller $dataorders->[0]->{booksellerid} without emails";
340
            warn "Bookseller $dataorders->[0]->{booksellerid} without emails";
335
            return { error => "no_email" };
341
            return { error => "no_email" };
336
        }
342
        }
343
        my $addlcontact;
344
        while ($addlcontact = $sthcontact->fetchrow_hashref) {
345
            push @cc, $addlcontact->{email} if ( $addlcontact && $addlcontact->{email} );
346
        }
337
347
338
        my $userenv = C4::Context->userenv;
348
        my $userenv = C4::Context->userenv;
339
        my $letter = GetPreparedLetter (
349
        my $letter = GetPreparedLetter (
Lines 343-348 sub SendAlerts { Link Here
343
            tables => {
353
            tables => {
344
                'branches'    => $userenv->{branch},
354
                'branches'    => $userenv->{branch},
345
                'aqbooksellers' => $databookseller,
355
                'aqbooksellers' => $databookseller,
356
                'aqcontacts'    => $datacontact,
346
            },
357
            },
347
            repeat => $dataorders,
358
            repeat => $dataorders,
348
            want_librarian => 1,
359
            want_librarian => 1,
Lines 351-356 sub SendAlerts { Link Here
351
        # ... then send mail
362
        # ... then send mail
352
        my %mail = (
363
        my %mail = (
353
            To => join( ',', @email),
364
            To => join( ',', @email),
365
            Cc             => join( ',', @cc),
354
            From           => $userenv->{emailaddress},
366
            From           => $userenv->{emailaddress},
355
            Subject        => Encode::encode( "utf8", "" . $letter->{title} ),
367
            Subject        => Encode::encode( "utf8", "" . $letter->{title} ),
356
            Message        => Encode::encode( "utf8", "" . $letter->{content} ),
368
            Message        => Encode::encode( "utf8", "" . $letter->{content} ),
Lines 363-369 sub SendAlerts { Link Here
363
            $type eq 'claimissues' ? "CLAIM ISSUE" : "ACQUISITION CLAIM",
375
            $type eq 'claimissues' ? "CLAIM ISSUE" : "ACQUISITION CLAIM",
364
            undef,
376
            undef,
365
            "To="
377
            "To="
366
                . $databookseller->{contemail}
378
                . join( ',', @email )
367
                . " Title="
379
                . " Title="
368
                . $letter->{title}
380
                . $letter->{title}
369
                . " Content="
381
                . " Content="
(-)a/acqui/supplier.pl (-1 / +2 lines)
Lines 67-77 my $booksellerid = $query->param('booksellerid'); Link Here
67
my $supplier = {};
67
my $supplier = {};
68
if ($booksellerid) {
68
if ($booksellerid) {
69
    $supplier = GetBookSellerFromId($booksellerid);
69
    $supplier = GetBookSellerFromId($booksellerid);
70
    foreach ( keys $supplier ) {
70
    foreach ( keys %{$supplier} ) {
71
        $template->{'VARS'}->{$_} = $supplier->{$_};
71
        $template->{'VARS'}->{$_} = $supplier->{$_};
72
    }
72
    }
73
    $template->{'VARS'}->{'booksellerid'} = $booksellerid;
73
    $template->{'VARS'}->{'booksellerid'} = $booksellerid;
74
}
74
}
75
$template->{'VARS'}->{'contacts'} = C4::Bookseller::Contact->new() unless $template->{'VARS'}->{'contacts'};
75
76
76
#build array for currencies
77
#build array for currencies
77
if ( $op eq 'display' ) {
78
if ( $op eq 'display' ) {
(-)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, contact_acqprimary,
45
contact_serialsprimary.
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 acqprimary serialsprimary)) {
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 acqprimary serialsprimary)) {
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 / +5 lines)
Lines 2974-2983 CREATE TABLE aqcontacts ( Link Here
2974
  fax varchar(100) default NULL,  -- contact's fax number
2974
  fax varchar(100) default NULL,  -- contact's fax number
2975
  email varchar(100) default NULL, -- contact's email address
2975
  email varchar(100) default NULL, -- contact's email address
2976
  notes mediumtext, -- notes related to the contact
2976
  notes mediumtext, -- notes related to the contact
2977
  rank SMALLINT default 0, -- display rank for the contact
2977
  claimacquisition BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive acquisitions claims
2978
  claimissues BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive serial claims
2979
  acqprimary BOOLEAN NOT NULL DEFAULT 0, -- is this the primary contact for acquisitions messages
2980
  serialsprimary BOOLEAN NOT NULL DEFAULT 0, -- is this the primary contact for serials messages
2978
  booksellerid int(11) not NULL,
2981
  booksellerid int(11) not NULL,
2979
  PRIMARY KEY  (id),
2982
  PRIMARY KEY  (id),
2980
  CONSTRAINT booksellerid_fk2 FOREIGN KEY (booksellerid)
2983
  CONSTRAINT booksellerid_aqcontacts_fk FOREIGN KEY (booksellerid)
2981
       REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
2984
       REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
2982
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
2985
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
2983
2986
(-)a/installer/data/mysql/updatedatabase.pl (-5 / +15 lines)
Lines 8560-8566 if ( CheckVersion($DBversion) ) { Link Here
8560
    SetVersion($DBversion);
8560
    SetVersion($DBversion);
8561
}
8561
}
8562
8562
8563
$DBversion = "3.13.00.XXX";
8563
$DBversion = "3.17.00.XXX";
8564
if ( CheckVersion($DBversion) ) {
8564
if ( CheckVersion($DBversion) ) {
8565
    $dbh->do("CREATE TABLE aqcontacts (
8565
    $dbh->do("CREATE TABLE aqcontacts (
8566
        id int(11) NOT NULL auto_increment,
8566
        id int(11) NOT NULL auto_increment,
Lines 8571-8590 if ( CheckVersion($DBversion) ) { Link Here
8571
        fax varchar(100) default NULL,
8571
        fax varchar(100) default NULL,
8572
        email varchar(100) default NULL,
8572
        email varchar(100) default NULL,
8573
        notes mediumtext,
8573
        notes mediumtext,
8574
        rank SMALLINT default 0,
8574
        claimacquisition BOOLEAN NOT NULL DEFAULT 0,
8575
        claimissues BOOLEAN NOT NULL DEFAULT 0,
8576
        acqprimary BOOLEAN NOT NULL DEFAULT 0,
8577
        serialsprimary BOOLEAN NOT NULL DEFAULT 0,
8575
        booksellerid int(11) not NULL,
8578
        booksellerid int(11) not NULL,
8576
        PRIMARY KEY  (id),
8579
        PRIMARY KEY  (id),
8577
        CONSTRAINT booksellerid_fk2 FOREIGN KEY (booksellerid)
8580
        CONSTRAINT booksellerid_aqcontacts_fk FOREIGN KEY (booksellerid)
8578
            REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
8581
            REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
8579
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
8582
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
8580
    $dbh->do("INSERT INTO aqcontacts (name, position, phone, altphone, fax,
8583
    $dbh->do("INSERT INTO aqcontacts (name, position, phone, altphone, fax,
8581
            email, notes, booksellerid)
8584
            email, notes, booksellerid, claimacquisition, claimissues, acqprimary, serialsprimary)
8582
        SELECT contact, contpos, contphone, contaltphone, contfax, contemail,
8585
        SELECT contact, contpos, contphone, contaltphone, contfax, contemail,
8583
            contnotes, id FROM aqbooksellers;");
8586
            contnotes, id, 1, 1, 1, 1 FROM aqbooksellers;");
8584
    $dbh->do("ALTER TABLE aqbooksellers DROP COLUMN contact,
8587
    $dbh->do("ALTER TABLE aqbooksellers DROP COLUMN contact,
8585
        DROP COLUMN contpos, DROP COLUMN contphone,
8588
        DROP COLUMN contpos, DROP COLUMN contphone,
8586
        DROP COLUMN contaltphone, DROP COLUMN contfax,
8589
        DROP COLUMN contaltphone, DROP COLUMN contfax,
8587
        DROP COLUMN contemail, DROP COLUMN contnotes;");
8590
        DROP COLUMN contemail, DROP COLUMN contnotes;");
8591
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contact>>', '<<aqcontacts.name>>')");
8592
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contpos>>', '<<aqcontacts.position>>')");
8593
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contphone>>', '<<aqcontacts.phone>>')");
8594
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contaltphone>>', '<<aqcontacts.altphone>>')");
8595
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contfax>>', '<<aqcontacts.contfax>>')");
8596
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contemail>>', '<<aqcontacts.contemail>>')");
8597
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contnotes>>', '<<aqcontacts.contnotes>>')");
8588
    print "Upgrade to $DBversion done (Bug 10402: Move bookseller contacts to separate table)\n";
8598
    print "Upgrade to $DBversion done (Bug 10402: Move bookseller contacts to separate table)\n";
8589
    SetVersion($DBversion);
8599
    SetVersion($DBversion);
8590
}
8600
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt (-5 / +75 lines)
Lines 16-22 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
        [% IF contact.id %]<li><button class="btn" class="delete-contact"><i class="icon-remove"></i> Delete contact</li>[% END %]
19
        <li><label for="contact_acqprimary[% contact.id %]">Primary acquisitions contact</label>
20
            [% IF contact.acqprimary %]
21
                <input type="checkbox" id="contact_acqprimary[% contact.id %]" class="contact_acqprimary" checked="checked"></input>
22
            [% ELSE %]
23
                <input type="checkbox" id="contact_acqprimary[% contact.id %]" class="contact_acqprimary"></input>
24
            [% END %]
25
            <input type="hidden" class="contact_acqprimary_hidden" name="contact_acqprimary" value="[% contact.acqprimary %]"></input>
26
        <li><label for="contact_serialsprimary[% contact.id %]">Primary serials contact</label>
27
            [% IF contact.serialsprimary %]
28
                <input type="checkbox" id="contact_serialsprimary[% contact.id %]" class="contact_serialsprimary" checked="checked"></input>
29
            [% ELSE %]
30
                <input type="checkbox" id="contact_serialsprimary[% contact.id %]" class="contact_serialsprimary"></input>
31
            [% END %]
32
            <input type="hidden" class="contact_serialsprimary_hidden" name="contact_serialsprimary" value="[% contact.serialsprimary %]"></input>
33
        <li><label for="contact_claimacquisition[% contact.id %]">Contact about late orders?</label>
34
            [% IF contact.claimacquisition %]
35
                <input type="checkbox" id="contact_claimacquisition[% contact.id %]" class="contact_claimacquisition" checked="checked"></input>
36
            [% ELSE %]
37
                <input type="checkbox" id="contact_claimacquisition[% contact.id %]" class="contact_claimacquisition"></input>
38
            [% END %]
39
            <input type="hidden" class="contact_claimacquisition_hidden" name="contact_claimacquisition" value="[% contact.claimacquisition %]"></input>
40
        <li><label for="contact_claimissues[% contact.id %]">Contact about late issues?</label>
41
            [% IF contact.claimissues %]
42
                <input type="checkbox" id="contact_claimissues[% contact.id %]" class="contact_claimissues" checked="checked"></input>
43
            [% ELSE %]
44
                <input type="checkbox" id="contact_claimissues[% contact.id %]" class="contact_claimissues"></input>
45
            [% END %]
46
            <input type="hidden" class="contact_claimissues_hidden" name="contact_claimissues" value="[% contact.claimissues %]"></input>
47
        </li>
48
        [% IF contact.id %]<li><button class="btn delete-contact"><i class="icon-remove"></i> Delete contact</li>[% END %]
20
    </ol>
49
    </ol>
21
[% END %]
50
[% END %]
22
51
Lines 32-37 Link Here
32
    [% IF ( contact.notes ) %]
61
    [% IF ( contact.notes ) %]
33
        <p><span class="label">Notes: </span>[% contact.notes %]</p>
62
        <p><span class="label">Notes: </span>[% contact.notes %]</p>
34
    [% END %]
63
    [% END %]
64
    [% IF ( contact.acqprimary ) %]
65
        <p><span class="label">Primary acquisitions contact</span></p>
66
    [% END %]
67
    [% IF ( contact.serialsprimary ) %]
68
        <p><span class="label">Primary serials contact</span></p>
69
    [% END %]
70
    [% IF ( contact.claimacquisition ) %]
71
        <p><span class="label">Receives claims for late orders</span></p>
72
    [% END %]
73
    [% IF ( contact.claimissues ) %]
74
        <p><span class="label">Receives claims for late issues</span></p>
75
    [% END %]
35
[% END %]
76
[% END %]
36
77
37
[% INCLUDE 'doc-head-open.inc' %]
78
[% INCLUDE 'doc-head-open.inc' %]
Lines 59-71 function add_contact() { Link Here
59
        $(this).attr('for', $(this).attr('for') + '_' + timestamp);
100
        $(this).attr('for', $(this).attr('for') + '_' + timestamp);
60
    });
101
    });
61
    $(new_contact).insertBefore(this);
102
    $(new_contact).insertBefore(this);
103
    if ($('.supplier-contact').length === 2) { // First contact
104
        $.each(['.contact_acqprimary', '.contact_serialsprimary', '.contact_claimacquisition', '.contact_claimissues'], function (idx, checkbox) {
105
            $(checkbox, new_contact).click();
106
        });
107
    }
62
    $('input[name="contact_name"]', new_contact).focus();
108
    $('input[name="contact_name"]', new_contact).focus();
63
    return false;
109
    return false;
64
}
110
}
65
111
66
function delete_contact() {
112
function delete_contact(ev) {
67
    $(this).parents('fieldset').delete();
113
    $(this).parents('.supplier-contact').remove();
68
    return false;
114
    ev.preventDefault();
69
}
115
}
70
116
71
 $(document).ready(function() {
117
 $(document).ready(function() {
Lines 76-83 function delete_contact() { Link Here
76
        ],
122
        ],
77
        'sDom': 't'
123
        'sDom': 't'
78
    } ) );
124
    } ) );
79
    $('.delete-contact').click(delete_contact);
125
    $('body').on('click', '.delete-contact', null, delete_contact);
80
    $('#add-contact').click(add_contact);
126
    $('#add-contact').click(add_contact);
127
    $('body').on('click', '.contact_acqprimary', null, function () {
128
        if ($(this).attr('checked') === 'checked') {
129
            $('.contact_acqprimary').filter(':checked').not(this).removeAttr('checked');
130
            $('.contact_acqprimary_hidden').each(function () {
131
                $(this).val('0');
132
            });
133
        }
134
        $(this).next('.contact_acqprimary_hidden').val('1');
135
    });
136
    $('body').on('click', '.contact_serialsprimary', null, function () {
137
        if ($(this).attr('checked') === 'checked') {
138
            $('.contact_serialsprimary').filter(':checked').not(this).removeAttr('checked');
139
            $('.contact_serialsprimary_hidden').each(function () {
140
                $(this).val('0');
141
            });
142
        }
143
        $(this).next('.contact_serialsprimary_hidden').val($(this).attr('checked') === 'checked' ? '1' : '0');
144
    });
145
    $('body').on('click', '.contact_claimacquisition', null, function () {
146
        $(this).next('.contact_claimacquisition_hidden').val($(this).attr('checked') === 'checked' ? '1' : '0');
147
    });
148
    $('body').on('click', '.contact_claimissues', null, function () {
149
        $(this).next('.contact_claimissues_hidden').val($(this).attr('checked') === 'checked' ? '1' : '0');
150
    });
81
 });
151
 });
82
//]]>
152
//]]>
83
</script>
153
</script>
(-)a/t/db_dependent/Bookseller.t (-39 / +4 lines)
Lines 2-8 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Test::More tests => 72;
5
use Test::More tests => 85;
6
use Test::MockModule;
6
use Test::MockModule;
7
use C4::Context;
7
use C4::Context;
8
use Koha::DateUtils;
8
use Koha::DateUtils;
Lines 51-63 my $sample_supplier1 = { Link Here
51
    accountnumber => 'accountnumber1',
51
    accountnumber => 'accountnumber1',
52
    fax           => 'fax1',
52
    fax           => 'fax1',
53
    url           => 'url1',
53
    url           => 'url1',
54
    contact       => 'contact1',
55
    contpos       => 'contpos1',
56
    contphone     => 'contphone1',
57
    contfax       => 'contefax1',
58
    contaltphone  => 'contaltphone1',
59
    contemail     => 'contemail1',
60
    contnotes     => 'contnotes1',
61
    active        => 1,
54
    active        => 1,
62
    gstreg        => 1,
55
    gstreg        => 1,
63
    listincgst    => 1,
56
    listincgst    => 1,
Lines 78-90 my $sample_supplier2 = { Link Here
78
    accountnumber => 'accountnumber2',
71
    accountnumber => 'accountnumber2',
79
    fax           => 'fax2',
72
    fax           => 'fax2',
80
    url           => 'url2',
73
    url           => 'url2',
81
    contact       => 'contact2',
82
    contpos       => 'contpos2',
83
    contphone     => 'contphone2',
84
    contfax       => 'contefax2',
85
    contaltphone  => 'contaltphone2',
86
    contemail     => 'contemail2',
87
    contnotes     => 'contnotes2',
88
    active        => 1,
74
    active        => 1,
89
    gstreg        => 1,
75
    gstreg        => 1,
90
    listincgst    => 1,
76
    listincgst    => 1,
Lines 92-98 my $sample_supplier2 = { Link Here
92
    gstrate       => '2.0000',
78
    gstrate       => '2.0000',
93
    discount      => '2.0000',
79
    discount      => '2.0000',
94
    notes         => 'notes2',
80
    notes         => 'notes2',
95
    deliverytime  => 2,
81
    deliverytime  => 2
96
};
82
};
97
83
98
my $id_supplier1 = C4::Bookseller::AddBookseller($sample_supplier1);
84
my $id_supplier1 = C4::Bookseller::AddBookseller($sample_supplier1);
Lines 232-244 $sample_supplier2 = { Link Here
232
    accountnumber => 'accountnumber2 modified',
218
    accountnumber => 'accountnumber2 modified',
233
    fax           => 'fax2 modified',
219
    fax           => 'fax2 modified',
234
    url           => 'url2 modified',
220
    url           => 'url2 modified',
235
    contact       => 'contact2 modified',
236
    contpos       => 'contpos2 modified',
237
    contphone     => 'contphone2 modified',
238
    contfax       => 'contefax2 modified',
239
    contaltphone  => 'contaltphone2 modified',
240
    contemail     => 'contemail2 modified',
241
    contnotes     => 'contnotes2 modified',
242
    active        => 1,
221
    active        => 1,
243
    gstreg        => 1,
222
    gstreg        => 1,
244
    listincgst    => 1,
223
    listincgst    => 1,
Lines 279-291 my $sample_supplier3 = { Link Here
279
    accountnumber => 'accountnumber3',
258
    accountnumber => 'accountnumber3',
280
    fax           => 'fax3',
259
    fax           => 'fax3',
281
    url           => 'url3',
260
    url           => 'url3',
282
    contact       => 'contact3',
283
    contpos       => 'contpos3',
284
    contphone     => 'contphone3',
285
    contfax       => 'contefax3',
286
    contaltphone  => 'contaltphone3',
287
    contemail     => 'contemail3',
288
    contnotes     => 'contnotes3',
289
    active        => 1,
261
    active        => 1,
290
    gstreg        => 1,
262
    gstreg        => 1,
291
    listincgst    => 1,
263
    listincgst    => 1,
Lines 306-318 my $sample_supplier4 = { Link Here
306
    accountnumber => 'accountnumber4',
278
    accountnumber => 'accountnumber4',
307
    fax           => 'fax4',
279
    fax           => 'fax4',
308
    url           => 'url4',
280
    url           => 'url4',
309
    contact       => 'contact4',
310
    contpos       => 'contpos4',
311
    contphone     => 'contphone4',
312
    contfax       => 'contefax4',
313
    contaltphone  => 'contaltphone4',
314
    contemail     => 'contemail4',
315
    contnotes     => 'contnotes4',
316
    active        => 1,
281
    active        => 1,
317
    gstreg        => 1,
282
    gstreg        => 1,
318
    listincgst    => 1,
283
    listincgst    => 1,
Lines 718-724 my $booksellerid = C4::Bookseller::AddBookseller( Link Here
718
    ]
683
    ]
719
);
684
);
720
685
721
my @booksellers = C4::Bookseller::GetBookSeller('my vendor');
686
@booksellers = C4::Bookseller::GetBookSeller('my vendor');
722
ok(
687
ok(
723
    ( grep { $_->{'id'} == $booksellerid } @booksellers ),
688
    ( grep { $_->{'id'} == $booksellerid } @booksellers ),
724
    'GetBookSeller returns correct record when passed a name'
689
    'GetBookSeller returns correct record when passed a name'
Lines 779-785 sub field_filter { Link Here
779
        'bookselleremail', 'booksellerfax',
744
        'bookselleremail', 'booksellerfax',
780
        'booksellerurl',   'othersupplier',
745
        'booksellerurl',   'othersupplier',
781
        'currency',        'invoiceprice',
746
        'currency',        'invoiceprice',
782
        'listprice'
747
        'listprice',       'contacts'
783
      )
748
      )
784
    {
749
    {
785
750
(-)a/t/db_dependent/Letters.t (-5 / +83 lines)
Lines 18-29 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::MockModule;
22
23
use Test::More tests => 15;
24
25
my %mail;
26
my $module = new Test::MockModule('Mail::Sendmail');
27
$module->mock(
28
    'sendmail',
29
    sub {
30
        warn "Fake sendmail";
31
        %mail = @_;
32
    }
33
);
34
21
35
22
use Test::More tests => 5;
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');
23
41
24
use C4::Context;
42
use_ok('C4::Letters');
25
use C4::Letters;
26
use C4::Members;
27
43
28
my $dbh = C4::Context->dbh;
44
my $dbh = C4::Context->dbh;
29
45
Lines 77-80 is( Link Here
77
    'message marked failed if tried to send SMS message for borrower with no smsalertnumber set (bug 11208)'
93
    'message marked failed if tried to send SMS message for borrower with no smsalertnumber set (bug 11208)'
78
);
94
);
79
95
96
$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>');});
97
98
my $booksellerid = C4::Bookseller::AddBookseller(
99
    {
100
        name => "my vendor",
101
        address1 => "bookseller's address",
102
        phone => "0123456",
103
        active => 1,
104
        deliverytime => 5,
105
    },
106
    [
107
        { name => 'John Smith',  phone => '0123456x1', claimacquisition => 1 },
108
        { name => 'Leo Tolstoy', phone => '0123456x2', claimissues => 1 },
109
    ]
110
);
111
my $basketno = NewBasket($booksellerid, 1);
112
113
my $budgetid = C4::Budgets::AddBudget({
114
    budget_code => "budget_code_test_letters",
115
    budget_name => "budget_name_test_letters",
116
});
117
118
my $ordernumber;
119
my $bib = MARC::Record->new();
120
if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
121
    $bib->append_fields(
122
        MARC::Field->new('200', ' ', ' ', a => 'Silence in the library'),
123
    );
124
} else {
125
    $bib->append_fields(
126
        MARC::Field->new('245', ' ', ' ', a => 'Silence in the library'),
127
    );
128
}
129
130
my ($biblionumber, $biblioitemnumber) = AddBiblio($bib, '');
131
( undef, $ordernumber ) = C4::Acquisition::NewOrder(
132
    {
133
        basketno => $basketno,
134
        quantity => 1,
135
        biblionumber => $biblionumber,
136
        budget_id => $budgetid,
137
    }
138
);
139
140
C4::Acquisition::CloseBasket( $basketno );
141
my $err;
142
eval {
143
    warn "This test may issue a warning. Please ignore it.\n";
144
    $err = SendAlerts( 'claimacquisition', [ $ordernumber ], 'TESTACQCLAIM' );
145
};
146
is($err->{'error'}, 'no_email', "Trying to send an alert when there's no e-mail results in an error");
147
148
my $bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
149
$bookseller->{'contacts'}->[0]->email('testemail@mydomain.com');
150
C4::Bookseller::ModBookseller($bookseller);
151
152
eval {
153
    $err = SendAlerts( 'claimacquisition', [ $ordernumber ], 'TESTACQCLAIM' );
154
};
155
is($err, 1, "Successfully sent claim");
156
is($mail{'To'}, 'testemail@mydomain.com');
157
is($mail{'Message'}, 'my vendor|John Smith|<order>Ordernumber ' . $ordernumber . ' (Silence in the library) (1 ordered)</order>', 'Claim notice text constructed successfully');
158
80
$dbh->rollback;
159
$dbh->rollback;
81
- 

Return to bug 10402