Thermodynamical theory of galvanomagnetic and thermomagnetic phenomena. I