Update Delivery.php

Patch to fix errors so delivery works with PostgerSQL 9 and replace many trim()'s with (int) to better match target comparison