# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
-# use warnings;
+#use warnings; FIXME - Bug 2505
use CGI;
use C4::Debug;
use C4::Context;
$sth->execute( $itm, $brc, $itm, $brc );
my ($date1) = $sth->fetchrow_array;
$sth = $dbh->prepare(
-"SELECT max(datearrived) FROM branchtransfers WHERE itemnumber=? AND tobranch = ?"
+ "SELECT MAX(transfer) FROM (SELECT max(datearrived) AS transfer FROM branchtransfers WHERE itemnumber=? AND tobranch = ?
+ UNION ALL
+ SELECT max(datesent) AS transfer FROM branchtransfers WHERE itemnumber=? AND frombranch = ?
+ ) tmp"
);
- $sth->execute( $itm, $brc );
+ $sth->execute( $itm, $brc, $itm, $brc );
my ($date2) = $sth->fetchrow_array;
my $date = ( $date1 lt $date2 ) ? $date2 : $date1 ;