there is getdir, it works on dx and dy.
PHP Code:
dx = dragitem.x - player.x;
dy = dragitem.y - player.y;
player.dir = getdir(dx,dy);
if the player is pointing the opposite way, reverse the dragitem and player, can't remember which way it's supposed to go and I'm about to go to bed :P