A first-principles study of phthalocyanine-based multifunctional spintronic molecular devices.