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

(-)a/C4/Circulation.pm (-2 / +3 lines)
Lines 3111-3117 sub GetTransfers { Link Here
3111
    my $query = '
3111
    my $query = '
3112
        SELECT datesent,
3112
        SELECT datesent,
3113
               frombranch,
3113
               frombranch,
3114
               tobranch
3114
               tobranch,
3115
               branchtransfer_id
3115
        FROM branchtransfers
3116
        FROM branchtransfers
3116
        WHERE itemnumber = ?
3117
        WHERE itemnumber = ?
3117
          AND datearrived IS NULL
3118
          AND datearrived IS NULL
Lines 3135-3141 sub GetTransfersFromTo { Link Here
3135
    return unless ( $frombranch && $tobranch );
3136
    return unless ( $frombranch && $tobranch );
3136
    my $dbh   = C4::Context->dbh;
3137
    my $dbh   = C4::Context->dbh;
3137
    my $query = "
3138
    my $query = "
3138
        SELECT itemnumber,datesent,frombranch
3139
        SELECT branchtransfer_id,itemnumber,datesent,frombranch
3139
        FROM   branchtransfers
3140
        FROM   branchtransfers
3140
        WHERE  frombranch=?
3141
        WHERE  frombranch=?
3141
          AND  tobranch=?
3142
          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/kohastructure.sql (+2 lines)
Lines 440-451 CREATE TABLE `branchrelations` ( -- this table links libraries/branches to group Link Here
440
440
441
DROP TABLE IF EXISTS `branchtransfers`;
441
DROP TABLE IF EXISTS `branchtransfers`;
442
CREATE TABLE `branchtransfers` ( -- information for items that are in transit between branches
442
CREATE TABLE `branchtransfers` ( -- information for items that are in transit between branches
443
  `branchtransfer_id` int(12) NOT NULL auto_increment, -- primary key
443
  `itemnumber` int(11) NOT NULL default 0, -- the itemnumber that it is in transit (items.itemnumber)
444
  `itemnumber` int(11) NOT NULL default 0, -- the itemnumber that it is in transit (items.itemnumber)
444
  `datesent` datetime default NULL, -- the date the transfer was initialized
445
  `datesent` datetime default NULL, -- the date the transfer was initialized
445
  `frombranch` varchar(10) NOT NULL default '', -- the branch the transfer is coming from
446
  `frombranch` varchar(10) NOT NULL default '', -- the branch the transfer is coming from
446
  `datearrived` datetime default NULL, -- the date the transfer arrived at its destination
447
  `datearrived` datetime default NULL, -- the date the transfer arrived at its destination
447
  `tobranch` varchar(10) NOT NULL default '', -- the branch the transfer was going to
448
  `tobranch` varchar(10) NOT NULL default '', -- the branch the transfer was going to
448
  `comments` mediumtext, -- any comments related to the transfer
449
  `comments` mediumtext, -- any comments related to the transfer
450
  PRIMARY KEY (`branchtransfer_id`),
449
  KEY `frombranch` (`frombranch`),
451
  KEY `frombranch` (`frombranch`),
450
  KEY `tobranch` (`tobranch`),
452
  KEY `tobranch` (`tobranch`),
451
  KEY `itemnumber` (`itemnumber`),
453
  KEY `itemnumber` (`itemnumber`),
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +7 lines)
Lines 8490-8495 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
8490
    SetVersion($DBversion);
8490
    SetVersion($DBversion);
8491
}
8491
}
8492
8492
8493
$DBversion = "3.99.00.XXX";
8494
if ( CheckVersion($DBversion) ) {
8495
    $dbh->do("ALTER TABLE branchtransfers ADD COLUMN branchtransfer_id int(12) NOT NULL auto_increment FIRST, ADD CONSTRAINT PRIMARY KEY (branchtransfer_id);");
8496
    print "Upgrade to $DBversion done (Bug 14187 - branchtransfer needs a primary key (id) for DBIx and common sense.)\n";
8497
    SetVersion ($DBversion);
8498
}
8499
8493
$DBversion = "3.15.00.050";
8500
$DBversion = "3.15.00.050";
8494
if ( CheckVersion($DBversion) ) {
8501
if ( CheckVersion($DBversion) ) {
8495
    $dbh->do("
8502
    $dbh->do("
8496
- 

Return to bug 14187