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 8570-8576 if ( CheckVersion($DBversion) ) { Link Here
8570
    SetVersion($DBversion);
8570
    SetVersion($DBversion);
8571
}
8571
}
8572
8572
8573
$DBversion = "3.13.00.XXX";
8573
$DBversion = "3.17.00.XXX";
8574
if ( CheckVersion($DBversion) ) {
8574
if ( CheckVersion($DBversion) ) {
8575
    $dbh->do("CREATE TABLE aqcontacts (
8575
    $dbh->do("CREATE TABLE aqcontacts (
8576
        id int(11) NOT NULL auto_increment,
8576
        id int(11) NOT NULL auto_increment,
Lines 8581-8600 if ( CheckVersion($DBversion) ) { Link Here
8581
        fax varchar(100) default NULL,
8581
        fax varchar(100) default NULL,
8582
        email varchar(100) default NULL,
8582
        email varchar(100) default NULL,
8583
        notes mediumtext,
8583
        notes mediumtext,
8584
        rank SMALLINT default 0,
8584
        claimacquisition BOOLEAN NOT NULL DEFAULT 0,
8585
        claimissues BOOLEAN NOT NULL DEFAULT 0,
8586
        acqprimary BOOLEAN NOT NULL DEFAULT 0,
8587
        serialsprimary BOOLEAN NOT NULL DEFAULT 0,
8585
        booksellerid int(11) not NULL,
8588
        booksellerid int(11) not NULL,
8586
        PRIMARY KEY  (id),
8589
        PRIMARY KEY  (id),
8587
        CONSTRAINT booksellerid_fk2 FOREIGN KEY (booksellerid)
8590
        CONSTRAINT booksellerid_aqcontacts_fk FOREIGN KEY (booksellerid)
8588
            REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
8591
            REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
8589
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
8592
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
8590
    $dbh->do("INSERT INTO aqcontacts (name, position, phone, altphone, fax,
8593
    $dbh->do("INSERT INTO aqcontacts (name, position, phone, altphone, fax,
8591
            email, notes, booksellerid)
8594
            email, notes, booksellerid, claimacquisition, claimissues, acqprimary, serialsprimary)
8592
        SELECT contact, contpos, contphone, contaltphone, contfax, contemail,
8595
        SELECT contact, contpos, contphone, contaltphone, contfax, contemail,
8593
            contnotes, id FROM aqbooksellers;");
8596
            contnotes, id, 1, 1, 1, 1 FROM aqbooksellers;");
8594
    $dbh->do("ALTER TABLE aqbooksellers DROP COLUMN contact,
8597
    $dbh->do("ALTER TABLE aqbooksellers DROP COLUMN contact,
8595
        DROP COLUMN contpos, DROP COLUMN contphone,
8598
        DROP COLUMN contpos, DROP COLUMN contphone,
8596
        DROP COLUMN contaltphone, DROP COLUMN contfax,
8599
        DROP COLUMN contaltphone, DROP COLUMN contfax,
8597
        DROP COLUMN contemail, DROP COLUMN contnotes;");
8600
        DROP COLUMN contemail, DROP COLUMN contnotes;");
8601
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contact>>', '<<aqcontacts.name>>')");
8602
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contpos>>', '<<aqcontacts.position>>')");
8603
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contphone>>', '<<aqcontacts.phone>>')");
8604
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contaltphone>>', '<<aqcontacts.altphone>>')");
8605
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contfax>>', '<<aqcontacts.contfax>>')");
8606
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contemail>>', '<<aqcontacts.contemail>>')");
8607
    $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contnotes>>', '<<aqcontacts.contnotes>>')");
8598
    print "Upgrade to $DBversion done (Bug 10402: Move bookseller contacts to separate table)\n";
8608
    print "Upgrade to $DBversion done (Bug 10402: Move bookseller contacts to separate table)\n";
8599
    SetVersion($DBversion);
8609
    SetVersion($DBversion);
8600
}
8610
}
(-)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 230-242 $sample_supplier2 = { Link Here
230
    accountnumber => 'accountnumber2 modified',
216
    accountnumber => 'accountnumber2 modified',
231
    fax           => 'fax2 modified',
217
    fax           => 'fax2 modified',
232
    url           => 'url2 modified',
218
    url           => 'url2 modified',
233
    contact       => 'contact2 modified',
234
    contpos       => 'contpos2 modified',
235
    contphone     => 'contphone2 modified',
236
    contfax       => 'contefax2 modified',
237
    contaltphone  => 'contaltphone2 modified',
238
    contemail     => 'contemail2 modified',
239
    contnotes     => 'contnotes2 modified',
240
    active        => 1,
219
    active        => 1,
241
    gstreg        => 1,
220
    gstreg        => 1,
242
    listincgst    => 1,
221
    listincgst    => 1,
Lines 277-289 my $sample_supplier3 = { Link Here
277
    accountnumber => 'accountnumber3',
256
    accountnumber => 'accountnumber3',
278
    fax           => 'fax3',
257
    fax           => 'fax3',
279
    url           => 'url3',
258
    url           => 'url3',
280
    contact       => 'contact3',
281
    contpos       => 'contpos3',
282
    contphone     => 'contphone3',
283
    contfax       => 'contefax3',
284
    contaltphone  => 'contaltphone3',
285
    contemail     => 'contemail3',
286
    contnotes     => 'contnotes3',
287
    active        => 1,
259
    active        => 1,
288
    gstreg        => 1,
260
    gstreg        => 1,
289
    listincgst    => 1,
261
    listincgst    => 1,
Lines 304-316 my $sample_supplier4 = { Link Here
304
    accountnumber => 'accountnumber4',
276
    accountnumber => 'accountnumber4',
305
    fax           => 'fax4',
277
    fax           => 'fax4',
306
    url           => 'url4',
278
    url           => 'url4',
307
    contact       => 'contact4',
308
    contpos       => 'contpos4',
309
    contphone     => 'contphone4',
310
    contfax       => 'contefax4',
311
    contaltphone  => 'contaltphone4',
312
    contemail     => 'contemail4',
313
    contnotes     => 'contnotes4',
314
    active        => 1,
279
    active        => 1,
315
    gstreg        => 1,
280
    gstreg        => 1,
316
    listincgst    => 1,
281
    listincgst    => 1,
Lines 716-722 my $booksellerid = C4::Bookseller::AddBookseller( Link Here
716
    ]
681
    ]
717
);
682
);
718
683
719
my @booksellers = C4::Bookseller::GetBookSeller('my vendor');
684
@booksellers = C4::Bookseller::GetBookSeller('my vendor');
720
ok(
685
ok(
721
    ( grep { $_->{'id'} == $booksellerid } @booksellers ),
686
    ( grep { $_->{'id'} == $booksellerid } @booksellers ),
722
    'GetBookSeller returns correct record when passed a name'
687
    'GetBookSeller returns correct record when passed a name'
Lines 777-783 sub field_filter { Link Here
777
        'bookselleremail', 'booksellerfax',
742
        'bookselleremail', 'booksellerfax',
778
        'booksellerurl',   'othersupplier',
743
        'booksellerurl',   'othersupplier',
779
        'currency',        'invoiceprice',
744
        'currency',        'invoiceprice',
780
        'listprice'
745
        'listprice',       'contacts'
781
      )
746
      )
782
    {
747
    {
783
748
(-)a/t/db_dependent/Letters.t (-8 / +84 lines)
Lines 18-32 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 => 56;
22
use Test::MockModule;
23
24
my %mail;
25
my $module = new Test::MockModule('Mail::Sendmail');
26
$module->mock(
27
    'sendmail',
28
    sub {
29
        warn "Fake sendmail";
30
        %mail = @_;
31
    }
32
);
21
33
22
use Test::More tests => 45;
34
use_ok('C4::Context');
23
35
use_ok('C4::Members');
24
use C4::Context;
36
use_ok('C4::Branch');
25
use C4::Letters;
37
use_ok('C4::Acquisition');
26
use C4::Members;
38
use_ok('C4::Biblio');
27
use C4::Branch;
39
use_ok('C4::Bookseller');
28
use t::lib::Mocks;
40
use t::lib::Mocks;
29
41
42
use_ok('C4::Letters');
43
30
my $dbh = C4::Context->dbh;
44
my $dbh = C4::Context->dbh;
31
45
32
# Start transaction
46
# Start transaction
Lines 109-115 is( Link Here
109
    'message marked failed if tried to send SMS message for borrower with no smsalertnumber set (bug 11208)'
123
    'message marked failed if tried to send SMS message for borrower with no smsalertnumber set (bug 11208)'
110
);
124
);
111
125
112
113
# GetLetters
126
# GetLetters
114
my $letters = C4::Letters::GetLetters();
127
my $letters = C4::Letters::GetLetters();
115
is( @$letters, 0, 'GetLetters returns the correct number of letters' );
128
is( @$letters, 0, 'GetLetters returns the correct number of letters' );
Lines 247-250 $prepared_letter = GetPreparedLetter(( Link Here
247
$my_content_letter = qq|This is a SMS for an $substitute->{status}|;
260
$my_content_letter = qq|This is a SMS for an $substitute->{status}|;
248
is( $prepared_letter->{content}, $my_content_letter, 'GetPreparedLetter returns the content correctly' );
261
is( $prepared_letter->{content}, $my_content_letter, 'GetPreparedLetter returns the content correctly' );
249
262
263
$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>');});
264
265
my $booksellerid = C4::Bookseller::AddBookseller(
266
    {
267
        name => "my vendor",
268
        address1 => "bookseller's address",
269
        phone => "0123456",
270
        active => 1,
271
        deliverytime => 5,
272
    },
273
    [
274
        { name => 'John Smith',  phone => '0123456x1', claimacquisition => 1 },
275
        { name => 'Leo Tolstoy', phone => '0123456x2', claimissues => 1 },
276
    ]
277
);
278
my $basketno = NewBasket($booksellerid, 1);
279
280
my $budgetid = C4::Budgets::AddBudget({
281
    budget_code => "budget_code_test_letters",
282
    budget_name => "budget_name_test_letters",
283
});
284
285
my $ordernumber;
286
my $bib = MARC::Record->new();
287
if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
288
    $bib->append_fields(
289
        MARC::Field->new('200', ' ', ' ', a => 'Silence in the library'),
290
    );
291
} else {
292
    $bib->append_fields(
293
        MARC::Field->new('245', ' ', ' ', a => 'Silence in the library'),
294
    );
295
}
296
297
my ($biblionumber, $biblioitemnumber) = AddBiblio($bib, '');
298
( undef, $ordernumber ) = C4::Acquisition::NewOrder(
299
    {
300
        basketno => $basketno,
301
        quantity => 1,
302
        biblionumber => $biblionumber,
303
        budget_id => $budgetid,
304
    }
305
);
306
307
C4::Acquisition::CloseBasket( $basketno );
308
my $err;
309
eval {
310
    warn "This test may issue a warning. Please ignore it.\n";
311
    $err = SendAlerts( 'claimacquisition', [ $ordernumber ], 'TESTACQCLAIM' );
312
};
313
is($err->{'error'}, 'no_email', "Trying to send an alert when there's no e-mail results in an error");
314
315
my $bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
316
$bookseller->{'contacts'}->[0]->email('testemail@mydomain.com');
317
C4::Bookseller::ModBookseller($bookseller);
318
$bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
319
320
eval {
321
    $err = SendAlerts( 'claimacquisition', [ $ordernumber ], 'TESTACQCLAIM' );
322
};
323
is($err, 1, "Successfully sent claim");
324
is($mail{'To'}, 'testemail@mydomain.com');
325
is($mail{'Message'}, 'my vendor|John Smith|<order>Ordernumber ' . $ordernumber . ' (Silence in the library) (1 ordered)</order>', 'Claim notice text constructed successfully');
326
250
$dbh->rollback;
327
$dbh->rollback;
251
- 

Return to bug 10402