Theory of phase transitions in second-order ferroelectric films: effects of surfaces and surface-induced stresses on polarization