Notes about contact.
+=item orderacquisition
+
+Whether the contact should receive acquisitions orders.
+
=item claimacquisition
Whether the contact should receive acquisitions claims.
use base qw(Class::Accessor);
-__PACKAGE__->mk_accessors(qw(id name position phone altphone fax email notes claimacquisition claimissues acqprimary serialsprimary bookseller));
+__PACKAGE__->mk_accessors(qw(id name position phone altphone fax email notes orderacquisition claimacquisition claimissues acqprimary serialsprimary bookseller));
=head1 METHODS
$self->phone, $self->altphone,
$self->fax, $self->email,
$self->notes, $self->acqprimary ? 1 : 0,
- $self->serialsprimary ? 1 : 0, $self->claimacquisition ? 1 : 0,
+ $self->serialsprimary ? 1 : 0,
+ $self->orderacquisition ? 1 : 0, $self->claimacquisition ? 1 : 0,
$self->claimissues ? 1 : 0, $self->bookseller
);
if ($self->id) {
- $query = 'UPDATE aqcontacts SET name = ?, position = ?, phone = ?, altphone = ?, fax = ?, email = ?, notes = ?, acqprimary = ?, serialsprimary = ?, claimacquisition = ?, claimissues = ?, booksellerid = ? WHERE id = ?;';
+ $query = 'UPDATE aqcontacts SET name = ?, position = ?, phone = ?, altphone = ?, fax = ?, email = ?, notes = ?, acqprimary = ?, serialsprimary = ?, orderacquisition = ?, claimacquisition = ?, claimissues = ?, booksellerid = ? WHERE id = ?;';
push @params, $self->id;
} else {
- $query = 'INSERT INTO aqcontacts (name, position, phone, altphone, fax, email, notes, acqprimary, serialsprimary, claimacquisition, claimissues, booksellerid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);';
+ $query = 'INSERT INTO aqcontacts (name, position, phone, altphone, fax, email, notes, acqprimary, serialsprimary, orderacquisition, claimacquisition, claimissues, booksellerid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);';
}
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare($query);
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
-use strict;
-use warnings;
+use Modern::Perl;
use MIME::Lite;
use Mail::Sendmail;
=head2 SendAlerts
- parameters :
- - $type : the type of alert
- - $externalid : the id of the "object" to query
- - $letter_code : the letter to send.
+ my $err = &SendAlerts($type, $externalid, $letter_code);
- send an alert to all borrowers having put an alert on a given subject.
+Parameters:
+ - $type : the type of alert
+ - $externalid : the id of the "object" to query
+ - $letter_code : the notice template to use
+
+C<&SendAlerts> sends an email notice directly to a patron or a vendor.
+Currently it supports ($type):
+- claim serial issues (claimissues)
+- claim acquisition orders (claimacquisition)
+- send acquisition orders to the vendor (orderacquisition)
+- notify patrons about newly received serial issues (issue)
+- notify patrons when their account is created (members)
Returns undef or { error => 'message } on failure.
Returns true on success.
}
}
}
- elsif ( $type eq 'claimacquisition' or $type eq 'claimissues' ) {
+ elsif ( $type eq 'claimacquisition' or $type eq 'claimissues' or $type eq 'orderacquisition' ) {
# prepare the letter...
- # search the biblionumber
- my $strsth = $type eq 'claimacquisition'
- ? qq{
+ my $strsth;
+ my $sthorders;
+ my $dataorders;
+ my $action;
+ if ( $type eq 'claimacquisition') {
+ $strsth = qq{
SELECT aqorders.*,aqbasket.*,biblio.*,biblioitems.*
FROM aqorders
LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
LEFT JOIN biblioitems ON aqorders.biblionumber=biblioitems.biblionumber
WHERE aqorders.ordernumber IN (
+ };
+
+ if (!@$externalid){
+ carp "No order selected";
+ return { error => "no_order_selected" };
}
- : qq{
+ $strsth .= join( ",", @$externalid ) . ")";
+ $action = "ACQUISITION CLAIM";
+ $sthorders = $dbh->prepare($strsth);
+ $sthorders->execute;
+ $dataorders = $sthorders->fetchall_arrayref( {} );
+ }
+
+ if ($type eq 'claimissues') {
+ $strsth = qq{
SELECT serial.*,subscription.*, biblio.*, aqbooksellers.*,
aqbooksellers.id AS booksellerid
FROM serial
WHERE serial.serialid IN (
};
- if (!@$externalid){
- carp "No Order selected";
- return { error => "no_order_selected" };
+ if (!@$externalid){
+ carp "No Order selected";
+ return { error => "no_order_selected" };
+ }
+
+ $strsth .= join( ",", @$externalid ) . ")";
+ $action = "CLAIM ISSUE";
+ $sthorders = $dbh->prepare($strsth);
+ $sthorders->execute;
+ $dataorders = $sthorders->fetchall_arrayref( {} );
}
- $strsth .= join( ",", @$externalid ) . ")";
- my $sthorders = $dbh->prepare($strsth);
- $sthorders->execute;
- my $dataorders = $sthorders->fetchall_arrayref( {} );
+ if ( $type eq 'orderacquisition') {
+ $strsth = qq{
+ SELECT aqorders.*,aqbasket.*,biblio.*,biblioitems.*
+ FROM aqorders
+ LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
+ LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
+ LEFT JOIN biblioitems ON aqorders.biblionumber=biblioitems.biblionumber
+ WHERE aqbasket.basketno = ?
+ AND orderstatus IN ('new','ordered')
+ };
+
+ if (!$externalid){
+ carp "No basketnumber given";
+ return { error => "no_basketno" };
+ }
+ $action = "ACQUISITION ORDER";
+ $sthorders = $dbh->prepare($strsth);
+ $sthorders->execute($externalid);
+ $dataorders = $sthorders->fetchall_arrayref( {} );
+ }
my $sthbookseller =
$dbh->prepare("select * from aqbooksellers where id=?");
$sthbookseller->execute( $dataorders->[0]->{booksellerid} );
my $databookseller = $sthbookseller->fetchrow_hashref;
- my $addressee = $type eq 'claimacquisition' ? 'acqprimary' : 'serialsprimary';
+
+ my $addressee = $type eq 'claimacquisition' || $type eq 'orderacquisition' ? 'acqprimary' : 'serialsprimary';
+
my $sthcontact =
$dbh->prepare("SELECT * FROM aqcontacts WHERE booksellerid=? AND $type=1 ORDER BY $addressee DESC");
$sthcontact->execute( $dataorders->[0]->{booksellerid} );
: 'text/plain; charset="utf-8"',
);
- $mail{'Reply-to'} = C4::Context->preference('ReplytoDefault')
- if C4::Context->preference('ReplytoDefault');
- $mail{'Sender'} = C4::Context->preference('ReturnpathDefault')
- if C4::Context->preference('ReturnpathDefault');
- $mail{'Bcc'} = $userenv->{emailaddress}
- if C4::Context->preference("ClaimsBccCopy");
+ if ($type eq 'claimacquisition' || $type eq 'claimissues' ) {
+ $mail{'Reply-to'} = C4::Context->preference('ReplytoDefault')
+ if C4::Context->preference('ReplytoDefault');
+ $mail{'Sender'} = C4::Context->preference('ReturnpathDefault')
+ if C4::Context->preference('ReturnpathDefault');
+ $mail{'Bcc'} = $userenv->{emailaddress}
+ if C4::Context->preference("ClaimsBccCopy");
+ }
unless ( sendmail(%mail) ) {
carp $Mail::Sendmail::error;
logaction(
"ACQUISITION",
- $type eq 'claimissues' ? "CLAIM ISSUE" : "ACQUISITION CLAIM",
+ $action,
undef,
"To="
. join( ',', @email )
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
-use strict;
-use warnings;
+use Modern::Perl;
use C4::Auth;
use C4::Koha;
use C4::Output;
use C4::Items;
use C4::Suggestions;
use Koha::Libraries;
+use C4::Letters qw/SendAlerts/;
use Date::Calc qw/Add_Delta_Days/;
use Koha::Database;
use Koha::EDI qw( create_edi_order get_edifact_ean );
my $confirm_pref= C4::Context->preference("BasketConfirmations") || '1';
$template->param( skip_confirm_reopen => 1) if $confirm_pref eq '2';
+$template->param( email_ok => 1 ) if defined $query->param('email_ok');
+$template->param( email_error => $query->param('email_error') ) if defined $query->param('email_error');
+
+
if ( $op eq 'delete_confirm' ) {
my $basketno = $query->param('basketno');
my $delbiblio = $query->param('delbiblio');
);
print GetBasketAsCSV($query->param('basketno'), $query);
exit;
+} elsif ($op eq 'email') {
+ my $redirect_url = '/cgi-bin/koha/acqui/basket.pl?basketno='.$basket->{'basketno'};
+ my $err;
+
+ eval {
+ $err = SendAlerts( 'orderacquisition', $query->param('basketno'), 'ACQORDER' );
+ };
+ if ( $@ ) {
+ $redirect_url .= '&email_error='.$@;
+ } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) {
+ $redirect_url .= '&email_error=no_email';
+ } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_basketno" ) {
+ $redirect_url .= '&email_error=no_basketno';
+ } else {
+ $redirect_url .= '&email_ok=1';
+ }
+
+ print $query->redirect($redirect_url)
+
} elsif ($op eq 'close') {
my $confirm = $query->param('confirm') || $confirm_pref eq '2';
if ($confirm) {
}
if ($op and $op eq "send_alert"){
- my @ordernums = $input->multi_param("ordernumber");# FIXME: Fallback values?
+ my @ordernums = $input->multi_param("ordernumber");
my $err;
eval {
- $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") ); # FIXME: Fallback value?
+ $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") );
if ( not ref $err or not exists $err->{error} ) {
AddClaim ( $_ ) for @ordernums;
}
my @contacts;
my %contact_info;
-foreach (qw(id name position phone altphone fax email notes claimacquisition claimissues acqprimary serialsprimary)) {
+foreach (qw(id name position phone altphone fax email notes orderacquisition claimacquisition claimissues acqprimary serialsprimary)) {
$contact_info{$_} = [ $input->param('contact_' . $_) ];
}
for my $cnt (0..scalar(@{$contact_info{'id'}})) {
my %contact;
my $real_contact;
- foreach (qw(id name position phone altphone fax email notes claimacquisition claimissues acqprimary serialsprimary)) {
+ foreach (qw(id name position phone altphone fax email notes orderacquisition claimacquisition claimissues acqprimary serialsprimary)) {
$contact{$_} = $contact_info{$_}->[$cnt];
$real_contact = 1 if $contact{$_};
}
--- /dev/null
+ALTER TABLE `aqcontacts` ADD `orderacquisition` BOOLEAN NOT NULL DEFAULT 0 AFTER `notes`;
fax varchar(100) default NULL, -- contact's fax number
email varchar(100) default NULL, -- contact's email address
notes mediumtext, -- notes related to the contact
+ orderacquisition BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive acquisition orders
claimacquisition BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive acquisitions claims
claimissues BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive serial claims
acqprimary BOOLEAN NOT NULL DEFAULT 0, -- is this the primary contact for acquisitions messages
[% IF ediaccount %]
<div class="btn-group"><a href="/cgi-bin/koha/acqui/edi_ean.pl?op=ediorder&basketno=[% basketno %]&booksellerid=[% booksellerid %]" class="btn btn-small" id="ediorderbutton"><i class="fa fa-download"></i> Create EDIFACT order</a></div>
[% END %]
+ [% IF ( active && books_loop ) %]
+ <div class="btn-group"><a href="[% script_name %]?op=email&basketno=[% basketno %]" class="btn btn-small" id="emailvendorbutton"><i class="fa fa-envelope"></i> E-mail order</a></div>
+ [% END %]
</div>
<!-- Modal for confirm deletion box-->
<div class="modal hide" id="deleteBasketModal" tabindex="-1" role="dialog" aria-labelledby="delbasketModalLabel" aria-hidden="true">
<META HTTP-EQUIV=Refresh CONTENT="0; url=booksellers.pl">
[% END %]
[% ELSE %]
+
+ [% IF email_error %]
+ <div class="dialog alert">
+ [% IF ( email_error == "no_email" ) %]
+ This vendor has no contact selected for sending orders to or is missing an e-mail address.
+ [% ELSIF ( email_error == "no_basketno" ) %]
+ No basket given.
+ [% ELSE %]
+ ERROR! - [% email_error %]
+ [% END %]
+ </div>
+ [% END %]
+ [% IF ( email_ok ) %]
+ <div class="dialog message">Order e-mail was sent to the vendor.</div>
+ [% END %]
<h1>[% UNLESS ( basketno ) %]New [% END %]Basket [% basketname|html %] ([% basketno %]) for <a href="supplier.pl?booksellerid=[% booksellerid %]">[% name|html %]</a></h1>
[% IF ( basketno ) %]
<div id="acqui_basket_summary" class="yui-g">
<th>No.</th>
<th class="anti-the">Order</th>
<th class="gste">RRP tax exc.</th>
- <th class="gste">ecost tax exc.</th>
+ <th class="gste">Ecost tax exc.</th>
<th class="gsti">RRP tax inc.</th>
<th class="gsti">ecost tax inc.</th>
<th>Qty.</th>
<input type="checkbox" id="contact_serialsprimary[% contact.id %]" class="contact_serialsprimary"></input>
[% END %]
<input type="hidden" class="contact_serialsprimary_hidden" name="contact_serialsprimary" value="[% contact.serialsprimary %]"></input>
+ <li><label for="contact_orderacquisition[% contact.id %]">Contact when ordering?</label>
+ [% IF contact.orderacquisition %]
+ <input type="checkbox" id="contact_orderacquisition[% contact.id %]" class="contact_orderacquisition" checked="checked"></input>
+ [% ELSE %]
+ <input type="checkbox" id="contact_orderacquisition[% contact.id %]" class="contact_orderacquisition"></input>
+ [% END %]
+ <input type="hidden" class="contact_orderacquisition_hidden" name="contact_orderacquisition" value="[% contact.orderacquisition %]"></input>
<li><label for="contact_claimacquisition[% contact.id %]">Contact about late orders?</label>
[% IF contact.claimacquisition %]
<input type="checkbox" id="contact_claimacquisition[% contact.id %]" class="contact_claimacquisition" checked="checked"></input>
[% IF ( contact.serialsprimary ) %]
<p><span class="label">Primary serials contact</span></p>
[% END %]
+ [% IF ( contact.orderacquisition ) %]
+ <p><span class="label">Receives orders</span></p>
+ [% END %]
[% IF ( contact.claimacquisition ) %]
<p><span class="label">Receives claims for late orders</span></p>
[% END %]
});
$(new_contact).insertBefore(this);
if ($('.supplier-contact').length === 2) { // First contact
- $.each(['.contact_acqprimary', '.contact_serialsprimary', '.contact_claimacquisition', '.contact_claimissues'], function (idx, checkbox) {
+ $.each(['.contact_acqprimary', '.contact_serialsprimary', '.contact_orderacquisition', '.contact_claimacquisition', '.contact_claimissues'], function (idx, checkbox) {
$(checkbox, new_contact).click();
});
}
}
$(this).next('.contact_serialsprimary_hidden').val($(this).is(':checked') ? '1' : '0');
});
+ $('body').on('click', '.contact_orderacquisition', null, function () {
+ $(this).next('.contact_orderacquisition_hidden').val($(this).is(':checked') ? '1' : '0');
+ });
$('body').on('click', '.contact_claimacquisition', null, function () {
$(this).next('.contact_claimacquisition_hidden').val($(this).is(':checked') ? '1' : '0');
});
[% ELSE %]
<option value="circulation">Circulation</option>
[% END %]
+ [% IF ( module == "orderacquisition" ) %]
+ <option value="orderacquisition" selected="selected">Order acquisition</option>
+ [% ELSE %]
+ <option value="orderacquisition">Order acquisition</option>
+ [% END %]
[% IF ( module == "claimacquisition" ) %]
<option value="claimacquisition" selected="selected">Claim acquisition</option>
[% ELSE %]
elsif ( $module eq 'acquisition' ) {
push @{$field_selection}, add_fields('aqbooksellers', 'aqorders', 'biblio', 'items');
}
- elsif ($module eq 'claimacquisition') {
- push @{$field_selection}, add_fields('aqbooksellers', 'aqorders', 'biblio', 'biblioitems');
+ elsif ($module eq 'claimacquisition' || $module eq 'orderacquisition') {
+ push @{$field_selection}, add_fields('aqbooksellers', 'aqbasket', 'aqorders', 'biblio', 'biblioitems');
}
elsif ($module eq 'claimissues') {
push @{$field_selection}, add_fields('aqbooksellers', 'serial', 'subscription');