Thermodynamics of Materials with Memory: Theory and