An exactly soluble model of directed polymers with multiple phase transitions