use MARC::Record;
use C4::Suggestions;
use C4::Biblio;
+use C4::Contract;
use C4::Debug;
use C4::SQLHelper qw(InsertInTable UpdateInTable);
use C4::Bookseller qw(GetBookSellerFromId);
&NewOrderItem &ModItemOrder
&GetParcels &GetParcel
- &GetContracts &GetContract
&GetInvoices
&GetInvoice
my ($basketno, $cgi) = @_;
my $basket = GetBasket($basketno);
my @orders = GetOrders($basketno);
- my $contract = GetContract($basket->{'contractnumber'});
+ my $contract = GetContract({
+ contractnumber => $basket->{'contractnumber'}
+ });
my $template = C4::Templates::gettemplate("acqui/csv/basket.tt", "intranet", $cgi);
my @rows;
for my $basket (@$baskets) {
my @orders = GetOrders( $$basket{basketno} );
- my $contract = GetContract( $$basket{contractnumber} );
+ my $contract = GetContract({
+ contractnumber => $$basket{contractnumber}
+ });
my $bookseller = GetBookSellerFromId( $$basket{booksellerid} );
my $basketgroup = GetBasketgroup( $$basket{basketgroupid} );
return $results;
}
-=head3 GetContracts
-
- $contractlist = &GetContracts($booksellerid, $activeonly);
-
-Looks up the contracts that belong to a bookseller
-
-Returns a list of contracts
-
-=over
-
-=item C<$booksellerid> is the "id" field in the "aqbooksellers" table.
-
-=item C<$activeonly> if exists get only contracts that are still active.
-
-=back
-
-=cut
-
-sub GetContracts {
- my ( $booksellerid, $activeonly ) = @_;
- my $dbh = C4::Context->dbh;
- my $query;
- if (! $activeonly) {
- $query = "
- SELECT *
- FROM aqcontract
- WHERE booksellerid=?
- ";
- } else {
- $query = "SELECT *
- FROM aqcontract
- WHERE booksellerid=?
- AND contractenddate >= CURDATE( )";
- }
- my $result_set =
- $dbh->selectall_arrayref( $query, { Slice => {} }, $booksellerid );
- return @{$result_set};
-}
-
#------------------------------------------------------------#
-=head3 GetContract
-
- $contract = &GetContract($contractID);
-
-Looks up the contract that has PRIMKEY (contractnumber) value $contractID
-
-Returns a contract
-
-=cut
-
-sub GetContract {
- my ( $contractno ) = @_;
- my $dbh = C4::Context->dbh;
- my $query = "
- SELECT *
- FROM aqcontract
- WHERE contractnumber=?
- ";
-
- my $sth = $dbh->prepare($query);
- $sth->execute( $contractno );
- my $result = $sth->fetchrow_hashref;
- return $result;
-}
-
=head3 AddClaim
=over
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+use Modern::Perl;
use strict;
#use warnings; FIXME - Bug 2505
+use C4::Context;
use C4::SQLHelper qw(:all);
use vars qw($VERSION @ISA @EXPORT);
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(
- &GetContract
- &AddContract
- &ModContract
- &DelContract
+ &GetContracts
+ &GetContract
+ &AddContract
+ &ModContract
+ &DelContract
);
}
add a new contract, to modify it or to get some informations around
a contract.
-This module is just a wrapper for C4::SQLHelper functions, so take a look at
-SQLHelper centralised documentation to know how to use the following subs.
+=cut
+
+
+=head2 GetContracts
+
+$contractlist = GetContracts({
+ booksellerid => $booksellerid,
+ activeonly => $activeonly
+});
+
+Looks up the contracts that belong to a bookseller
+
+Returns a list of contracts
+
+=over
+
+=item C<$booksellerid> is the "id" field in the "aqbooksellers" table.
+
+=item C<$activeonly> if exists get only contracts that are still active.
+
+=back
=cut
-sub GetContract { SearchInTable("aqcontract", shift); }
+sub GetContracts {
+ my ($params) = @_;
+ my $booksellerid = $params->{booksellerid};
+ my $activeonly = $params->{activeonly};
+
+ my $dbh = C4::Context->dbh;
+ my $query = "SELECT * FROM aqcontract";
+ my $result_set;
+ if($booksellerid) {
+ $query .= " WHERE booksellerid=?";
+
+ if($activeonly) {
+ $query .= " AND contractenddate >= CURDATE( )";
+ }
+
+ $result_set = $dbh->selectall_arrayref( $query, { Slice => {} }, $booksellerid );
+ }
+ else {
+ $result_set = $dbh->selectall_arrayref( $query, { Slice => {} } );
+ }
+
+ return $result_set;
+}
+
+=head2 GetContract
+
+$contract = GetContract( { contractnumber => $contractnumber } );
+
+Looks up the contract that has PRIMKEY (contractnumber) value $contractID
+
+Returns a contract
+
+=cut
+
+sub GetContract {
+ my ($params) = @_;
+ my $contractno = $params->{contractnumber};
+
+ my $dbh = C4::Context->dbh;
+ my $query = "SELECT * FROM aqcontract WHERE contractnumber=?";
+
+ my $sth = $dbh->prepare($query);
+ $sth->execute($contractno);
+ my $result = $sth->fetchrow_hashref;
+ return $result;
+}
+
+
+#sub GetContract { SearchInTable("aqcontract", shift); }
sub AddContract { InsertInTable("aqcontract", shift); }
use C4::Budgets;
use C4::Branch;
use C4::Bookseller qw( GetBookSellerFromId);
+use C4::Contract;
use C4::Debug;
use C4::Biblio;
use C4::Members qw/GetMember/; #needed for permissions checking for changing basketgroup of a basket
}
$basket->{creationdate} = "" unless ( $basket->{creationdate} );
$basket->{authorisedby} = $loggedinuser unless ( $basket->{authorisedby} );
- my $contract = &GetContract($basket->{contractnumber});
+ my $contract = GetContract({
+ contractnumber => $basket->{contractnumber}
+ });
$template->param(
basketno => $basketno,
basketname => $basket->{'basketname'},
push @cancelledorders_loop, $line;
}
- my $contract = &GetContract($basket->{contractnumber});
+ my $contract = GetContract({
+ contractnumber => $basket->{contractnumber}
+ });
my @orders = GetOrders($basketno);
if ($basket->{basketgroupid}){
use C4::Auth;
use C4::Branch;
use C4::Output;
-use C4::Acquisition qw/GetBasket NewBasket GetContracts ModBasketHeader/;
+use C4::Acquisition qw/GetBasket NewBasket ModBasketHeader/;
use C4::Bookseller qw/GetBookSellerFromId GetBookSeller/;
+use C4::Contract qw/GetContracts/;
my $input = new CGI;
if (! $booksellerid) {
$booksellerid=$basket->{'booksellerid'};
}
- @contractloop = &GetContracts($booksellerid, 1);
+ my $contracts = GetContracts({
+ booksellerid => $booksellerid,
+ activeonly => 1,
+ });
+
+ @contractloop = @$contracts;
for (@contractloop) {
if ( $basket->{'contractnumber'} eq $_->{'contractnumber'} ) {
$_->{'selected'} = 1;
} else {
#new basket
my $basket;
- push(@contractloop, &GetContracts($booksellerid, 1));
+ my $contracts = GetContracts({
+ booksellerid => $booksellerid,
+ activeonly => 1,
+ });
+ push(@contractloop, @$contracts);
}
my $bookseller = GetBookSellerFromId($booksellerid);
my $count = scalar @contractloop;
use C4::Bookseller qw/ GetBookSellerFromId /;
use C4::Acquisition;
+use C4::Contract;
use C4::Suggestions; # GetSuggestion
use C4::Biblio; # GetBiblioData GetMarcPrice
use C4::Items; #PrepareItemRecord
$booksellerid = $basket->{booksellerid} unless $booksellerid;
my $bookseller = GetBookSellerFromId($booksellerid);
-my $contract = &GetContract($basket->{contractnumber});
+my $contract = GetContract({
+ contractnumber => $basket->{contractnumber}
+});
#simple parameters reading (all in one :-)
our $params = $input->Vars;
use strict;
use warnings;
use C4::Auth;
-use C4::Contract qw/GetContract/;
+use C4::Contract;
use C4::Biblio;
use C4::Output;
use CGI;
#build array for currencies
if ( $op eq 'display' ) {
-
- my $contracts = GetContract( { booksellerid => $booksellerid } );
+ my $contracts = GetContracts( { booksellerid => $booksellerid } );
$template->param(
booksellerid => $booksellerid,
# if contractnumber exists, it's a modify action, so read values to modify...
if ($contractnumber) {
- my $contract =
- @{ GetContract( { contractnumber => $contractnumber } ) }[0];
+ my $contract = GetContract({
+ contractnumber => $contractnumber
+ });
$template->param(
contractnumber => $contract->{contractnumber},
elsif ( $op eq 'delete_confirm' ) {
$template->param( delete_confirm => 1 );
- my $contract = @{GetContract( { contractnumber => $contractnumber } )}[0];
+ my $contract = GetContract( { contractnumber => $contractnumber } );
$template->param(
contractnumber => $$contract{contractnumber},
$template->param(else => 1);
# get contracts
- my @contracts = @{GetContract( { booksellerid => $booksellerid } )};
+ my @contracts = @{GetContracts( { booksellerid => $booksellerid } )};
# format dates
for ( @contracts ) {