I'm sorry to hear about your situation. I was in this situation before. I know how frustrating it is when you move to somewhere new and have to manage everything from the start. It happened to me before when I move from Italy to Ireland for a company. I will tell you how my company and I have managed this issue. This may help you.
My Italian company has bought an Ltd company in Ireland for a while before they decided to send people to work here. When they sent me to Ireland, they gave me a new employment contract for a company in Ireland, and another contract stating that I will work for a company in Italy on the year next in order to protect me when I want to move back in Italy. This 2 contracts can be renewed every year.
An Italian company is not so nice too. At first, they didn't want to give me any pay raise or any moving expenses. However, I told them clearly that I would never move if they couldn't give me what I want. Finally, I have a payraise, a monthly house rent for 800 euro, 1,000 euro for shipping expenses, and the company would buy me a flight anytime I want to go back to Italy, just the company will not pay for my wife.
Once I work in Ireland, the company outsources payroll service. I receive a payslip from a payroll company every month. My salary is paid and I pay tax in Ireland. A company's income that occurs in Ireland go to Irish Revenue for tax. Of course, a part of income that is difficult to distinguish still goes to Italy.
Is a new office a legit company in Spain? If not, you should tell the company to make it a legit company. Once it is a legit company, the company should outsource some HR company to make a payroll for you in accordance to Spanish laws. They should give a new employment contract for this new Spanish company. You should be now working for and receiving your salary from a new Spanish company, not a company in Ireland anymore.
Now I am moving back to Italy. The company in Ireland will give me P45 that I am not working in Ireland anymore, and I will start my employment in Italy soon.