|
Lines 17-24
package C4::Contract;
Link Here
|
| 17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
| 18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 |
|
19 |
|
|
|
20 |
use Modern::Perl; |
| 20 |
use strict; |
21 |
use strict; |
| 21 |
#use warnings; FIXME - Bug 2505 |
22 |
#use warnings; FIXME - Bug 2505 |
|
|
23 |
use C4::Context; |
| 22 |
use C4::SQLHelper qw(:all); |
24 |
use C4::SQLHelper qw(:all); |
| 23 |
|
25 |
|
| 24 |
use vars qw($VERSION @ISA @EXPORT); |
26 |
use vars qw($VERSION @ISA @EXPORT); |
|
Lines 29-38
BEGIN {
Link Here
|
| 29 |
require Exporter; |
31 |
require Exporter; |
| 30 |
@ISA = qw(Exporter); |
32 |
@ISA = qw(Exporter); |
| 31 |
@EXPORT = qw( |
33 |
@EXPORT = qw( |
| 32 |
&GetContract |
34 |
&GetContracts |
| 33 |
&AddContract |
35 |
&GetContract |
| 34 |
&ModContract |
36 |
&AddContract |
| 35 |
&DelContract |
37 |
&ModContract |
|
|
38 |
&DelContract |
| 36 |
); |
39 |
); |
| 37 |
} |
40 |
} |
| 38 |
|
41 |
|
|
Lines 50-61
The functions in this module deal with contracts. They allow to
Link Here
|
| 50 |
add a new contract, to modify it or to get some informations around |
53 |
add a new contract, to modify it or to get some informations around |
| 51 |
a contract. |
54 |
a contract. |
| 52 |
|
55 |
|
| 53 |
This module is just a wrapper for C4::SQLHelper functions, so take a look at |
56 |
=cut |
| 54 |
SQLHelper centralised documentation to know how to use the following subs. |
57 |
|
|
|
58 |
|
| 59 |
=head2 GetContracts |
| 60 |
|
| 61 |
$contractlist = GetContracts({ |
| 62 |
booksellerid => $booksellerid, |
| 63 |
activeonly => $activeonly |
| 64 |
}); |
| 65 |
|
| 66 |
Looks up the contracts that belong to a bookseller |
| 67 |
|
| 68 |
Returns a list of contracts |
| 69 |
|
| 70 |
=over |
| 71 |
|
| 72 |
=item C<$booksellerid> is the "id" field in the "aqbooksellers" table. |
| 73 |
|
| 74 |
=item C<$activeonly> if exists get only contracts that are still active. |
| 75 |
|
| 76 |
=back |
| 55 |
|
77 |
|
| 56 |
=cut |
78 |
=cut |
| 57 |
|
79 |
|
| 58 |
sub GetContract { SearchInTable("aqcontract", shift); } |
80 |
sub GetContracts { |
|
|
81 |
my ($params) = @_; |
| 82 |
my $booksellerid = $params->{booksellerid}; |
| 83 |
my $activeonly = $params->{activeonly}; |
| 84 |
|
| 85 |
my $dbh = C4::Context->dbh; |
| 86 |
my $query = "SELECT * FROM aqcontract"; |
| 87 |
my $result_set; |
| 88 |
if($booksellerid) { |
| 89 |
$query .= " WHERE booksellerid=?"; |
| 90 |
|
| 91 |
if($activeonly) { |
| 92 |
$query .= " AND contractenddate >= CURDATE( )"; |
| 93 |
} |
| 94 |
|
| 95 |
$result_set = $dbh->selectall_arrayref( $query, { Slice => {} }, $booksellerid ); |
| 96 |
} |
| 97 |
else { |
| 98 |
$result_set = $dbh->selectall_arrayref( $query, { Slice => {} } ); |
| 99 |
} |
| 100 |
|
| 101 |
return $result_set; |
| 102 |
} |
| 103 |
|
| 104 |
=head2 GetContract |
| 105 |
|
| 106 |
$contract = GetContract( { contractnumber => $contractnumber } ); |
| 107 |
|
| 108 |
Looks up the contract that has PRIMKEY (contractnumber) value $contractID |
| 109 |
|
| 110 |
Returns a contract |
| 111 |
|
| 112 |
=cut |
| 113 |
|
| 114 |
sub GetContract { |
| 115 |
my ($params) = @_; |
| 116 |
my $contractno = $params->{contractnumber}; |
| 117 |
|
| 118 |
my $dbh = C4::Context->dbh; |
| 119 |
my $query = "SELECT * FROM aqcontract WHERE contractnumber=?"; |
| 120 |
|
| 121 |
my $sth = $dbh->prepare($query); |
| 122 |
$sth->execute($contractno); |
| 123 |
my $result = $sth->fetchrow_hashref; |
| 124 |
return $result; |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
#sub GetContract { SearchInTable("aqcontract", shift); } |
| 59 |
|
129 |
|
| 60 |
sub AddContract { InsertInTable("aqcontract", shift); } |
130 |
sub AddContract { InsertInTable("aqcontract", shift); } |
| 61 |
|
131 |
|