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

(-)a/C4/Circulation.pm (-2 / +3 lines)
Lines 3309-3315 sub GetTransfers { Link Here
3309
    my $query = '
3309
    my $query = '
3310
        SELECT datesent,
3310
        SELECT datesent,
3311
               frombranch,
3311
               frombranch,
3312
               tobranch
3312
               tobranch,
3313
               branchtransfer_id
3313
        FROM branchtransfers
3314
        FROM branchtransfers
3314
        WHERE itemnumber = ?
3315
        WHERE itemnumber = ?
3315
          AND datearrived IS NULL
3316
          AND datearrived IS NULL
Lines 3333-3339 sub GetTransfersFromTo { Link Here
3333
    return unless ( $frombranch && $tobranch );
3334
    return unless ( $frombranch && $tobranch );
3334
    my $dbh   = C4::Context->dbh;
3335
    my $dbh   = C4::Context->dbh;
3335
    my $query = "
3336
    my $query = "
3336
        SELECT itemnumber,datesent,frombranch
3337
        SELECT branchtransfer_id,itemnumber,datesent,frombranch
3337
        FROM   branchtransfers
3338
        FROM   branchtransfers
3338
        WHERE  frombranch=?
3339
        WHERE  frombranch=?
3339
          AND  tobranch=?
3340
          AND  tobranch=?
(-)a/Koha/Schema/Result/Branchtransfer.pm (-20 / +25 lines)
Lines 1-21 Link Here
1
use utf8;
2
package Koha::Schema::Result::Branchtransfer;
1
package Koha::Schema::Result::Branchtransfer;
3
2
4
# Created by DBIx::Class::Schema::Loader
3
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
5
7
=head1 NAME
8
9
Koha::Schema::Result::Branchtransfer
10
11
=cut
12
13
use strict;
6
use strict;
14
use warnings;
7
use warnings;
15
8
16
use base 'DBIx::Class::Core';
9
use base 'DBIx::Class::Core';
17
10
18
=head1 TABLE: C<branchtransfers>
11
12
=head1 NAME
13
14
Koha::Schema::Result::Branchtransfer
19
15
20
=cut
16
=cut
21
17
Lines 23-28 __PACKAGE__->table("branchtransfers"); Link Here
23
19
24
=head1 ACCESSORS
20
=head1 ACCESSORS
25
21
22
=head2 branchtransfer_id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
26
=head2 itemnumber
28
=head2 itemnumber
27
29
28
  data_type: 'integer'
30
  data_type: 'integer'
Lines 66-71 __PACKAGE__->table("branchtransfers"); Link Here
66
=cut
68
=cut
67
69
68
__PACKAGE__->add_columns(
70
__PACKAGE__->add_columns(
71
  "branchtransfer_id",
72
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
69
  "itemnumber",
73
  "itemnumber",
70
  {
74
  {
71
    data_type      => "integer",
75
    data_type      => "integer",
Lines 104-109 __PACKAGE__->add_columns( Link Here
104
  "comments",
108
  "comments",
105
  { data_type => "mediumtext", is_nullable => 1 },
109
  { data_type => "mediumtext", is_nullable => 1 },
106
);
110
);
111
__PACKAGE__->set_primary_key("branchtransfer_id");
107
112
108
=head1 RELATIONS
113
=head1 RELATIONS
109
114
Lines 122-160 __PACKAGE__->belongs_to( Link Here
122
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
127
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
123
);
128
);
124
129
125
=head2 itemnumber
130
=head2 tobranch
126
131
127
Type: belongs_to
132
Type: belongs_to
128
133
129
Related object: L<Koha::Schema::Result::Item>
134
Related object: L<Koha::Schema::Result::Branch>
130
135
131
=cut
136
=cut
132
137
133
__PACKAGE__->belongs_to(
138
__PACKAGE__->belongs_to(
134
  "itemnumber",
139
  "tobranch",
135
  "Koha::Schema::Result::Item",
140
  "Koha::Schema::Result::Branch",
136
  { itemnumber => "itemnumber" },
141
  { branchcode => "tobranch" },
137
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
142
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
138
);
143
);
139
144
140
=head2 tobranch
145
=head2 itemnumber
141
146
142
Type: belongs_to
147
Type: belongs_to
143
148
144
Related object: L<Koha::Schema::Result::Branch>
149
Related object: L<Koha::Schema::Result::Item>
145
150
146
=cut
151
=cut
147
152
148
__PACKAGE__->belongs_to(
153
__PACKAGE__->belongs_to(
149
  "tobranch",
154
  "itemnumber",
150
  "Koha::Schema::Result::Branch",
155
  "Koha::Schema::Result::Item",
151
  { branchcode => "tobranch" },
156
  { itemnumber => "itemnumber" },
152
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
157
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
153
);
158
);
154
159
155
160
156
# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21
161
# Created by DBIx::Class::Schema::Loader v0.07010 @ 2015-05-27 18:14:12
157
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NPbH+5o2BVPj8yeoUqEavw
162
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:IKdPAJHJdYM3MHxnj6Mxzg
158
163
159
164
160
# You can replace this text with custom content, and it will be preserved on regeneration
165
# You can replace this text with custom content, and it will be preserved on regeneration
(-)a/installer/data/mysql/atomicupdate/14187.perl (+8 lines)
Line 0 Link Here
1
$DBversion = 'XXX';  # will be replaced by the RM
2
if( CheckVersion( $DBversion )  ) {
3
    $dbh->do("ALTER TABLE branchtransfers ADD COLUMN branchtransfer_id int(12) NOT NULL auto_increment FIRST, ADD CONSTRAINT PRIMARY KEY (branchtransfer_id);");
4
5
    # Always end with this (adjust the bug info)
6
    SetVersion( $DBversion );
7
    print "Upgrade to $DBversion done (Bug 14187 - branchtransfer needs a primary key (id) for DBIx and common sense.)\n";
8
}
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 1003-1014 CREATE TABLE `default_branch_item_rules` ( Link Here
1003
1003
1004
DROP TABLE IF EXISTS `branchtransfers`;
1004
DROP TABLE IF EXISTS `branchtransfers`;
1005
CREATE TABLE `branchtransfers` ( -- information for items that are in transit between branches
1005
CREATE TABLE `branchtransfers` ( -- information for items that are in transit between branches
1006
  `branchtransfer_id` int(12) NOT NULL auto_increment, -- primary key
1006
  `itemnumber` int(11) NOT NULL default 0, -- the itemnumber that it is in transit (items.itemnumber)
1007
  `itemnumber` int(11) NOT NULL default 0, -- the itemnumber that it is in transit (items.itemnumber)
1007
  `datesent` datetime default NULL, -- the date the transfer was initialized
1008
  `datesent` datetime default NULL, -- the date the transfer was initialized
1008
  `frombranch` varchar(10) NOT NULL default '', -- the branch the transfer is coming from
1009
  `frombranch` varchar(10) NOT NULL default '', -- the branch the transfer is coming from
1009
  `datearrived` datetime default NULL, -- the date the transfer arrived at its destination
1010
  `datearrived` datetime default NULL, -- the date the transfer arrived at its destination
1010
  `tobranch` varchar(10) NOT NULL default '', -- the branch the transfer was going to
1011
  `tobranch` varchar(10) NOT NULL default '', -- the branch the transfer was going to
1011
  `comments` mediumtext, -- any comments related to the transfer
1012
  `comments` mediumtext, -- any comments related to the transfer
1013
  PRIMARY KEY (`branchtransfer_id`),
1012
  KEY `frombranch` (`frombranch`),
1014
  KEY `frombranch` (`frombranch`),
1013
  KEY `tobranch` (`tobranch`),
1015
  KEY `tobranch` (`tobranch`),
1014
  KEY `itemnumber` (`itemnumber`),
1016
  KEY `itemnumber` (`itemnumber`),
(-)a/t/db_dependent/Circulation/transfers.t (-8 / +9 lines)
Lines 125-131 is(CreateBranchTransferLimit(undef,$branchcode_2),undef, Link Here
125
my @transfers = GetTransfers($item_id1);
125
my @transfers = GetTransfers($item_id1);
126
cmp_deeply(
126
cmp_deeply(
127
    \@transfers,
127
    \@transfers,
128
    [ re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'), $branchcode_1, $branchcode_2 ],
128
    [ re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'), $branchcode_1, $branchcode_2, re('[0-9]*') ],
129
    "Transfers of the item1"
129
    "Transfers of the item1"
130
);    #NOTE: Only the first transfer is returned
130
);    #NOTE: Only the first transfer is returned
131
@transfers = GetTransfers;
131
@transfers = GetTransfers;
Lines 142-155 cmp_deeply( Link Here
142
    \@transferfrom1to2,
142
    \@transferfrom1to2,
143
    [
143
    [
144
        {
144
        {
145
            itemnumber => $item_id1,
145
            branchtransfer_id => re('[0-9]*'),
146
            datesent   => re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'),
146
            itemnumber        => $item_id1,
147
            frombranch => $branchcode_1
147
            datesent          => re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'),
148
            frombranch        => $branchcode_1
148
        },
149
        },
149
        {
150
        {
150
            itemnumber => $item_id2,
151
            branchtransfer_id => re('[0-9]*'),
151
            datesent   => re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'),
152
            itemnumber        => $item_id2,
152
            frombranch => $branchcode_1
153
            datesent          => re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'),
154
            frombranch        => $branchcode_1
153
        }
155
        }
154
    ],
156
    ],
155
    "Item1 and Item2 has been transferred from branch1 to branch2"
157
    "Item1 and Item2 has been transferred from branch1 to branch2"
156
- 

Return to bug 14187