Tax residents in Spain are subject to tax in respect of their worldwide income (no matter where that income has been obtained or who is the payer of that income).
There is a Special Tax Regime for individuals coming to Spain due to labour reasons, that allows them to be subject to tax according to the non resident rules (while keeping the status of residents), at the flat rate of 24% (up to 600.000 Euros) and 47% (form 600.000 onwards).