Oakdale portal elevator was inoperable from the start of the midnight shift until about 4:00 a.m. The problem was a malfunctioning gate latch. Repairs were made by elevator repair contractor. No entrapment at this time. However, at 4""10 a.m. the elevator malfunctioned again and stopped about 100' down the shaft with 18 employees on board. Entrapped for 30 minutes. No injuries.