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

(-)a/C4/Circulation.pm (-2 / +3 lines)
Lines 3205-3211 sub GetTransfers { Link Here
3205
    my $query = '
3205
    my $query = '
3206
        SELECT datesent,
3206
        SELECT datesent,
3207
               frombranch,
3207
               frombranch,
3208
               tobranch
3208
               tobranch,
3209
               branchtransfer_id
3209
        FROM branchtransfers
3210
        FROM branchtransfers
3210
        WHERE itemnumber = ?
3211
        WHERE itemnumber = ?
3211
          AND datearrived IS NULL
3212
          AND datearrived IS NULL
Lines 3229-3235 sub GetTransfersFromTo { Link Here
3229
    return unless ( $frombranch && $tobranch );
3230
    return unless ( $frombranch && $tobranch );
3230
    my $dbh   = C4::Context->dbh;
3231
    my $dbh   = C4::Context->dbh;
3231
    my $query = "
3232
    my $query = "
3232
        SELECT itemnumber,datesent,frombranch
3233
        SELECT branchtransfer_id,itemnumber,datesent,frombranch
3233
        FROM   branchtransfers
3234
        FROM   branchtransfers
3234
        WHERE  frombranch=?
3235
        WHERE  frombranch=?
3235
          AND  tobranch=?
3236
          AND  tobranch=?
(-)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