Mean-field theory of charge ordering and phase transitions in the colossal-magnetoresistive manganites