Not sure I've understood, but if you're looking for cell K99 (or whatever) to have the contents of J99 if D99 says P1, then you'd put in K99
=IF(D99="P1",J99,0)
and in L99 you'd have
=IF(D99="P2",J99,0)
You could even have an error-check in a later column to say
-IF(K99+L99<>J99,"Error","")
which would warn you that you'd got a duff entry in D99.
You could go on to have it pick up Pu/t and P1/S and all the other fun ideas. Mine does.
If you want a cumulative hours column, then you would add K99 to whatever was in the cumulative column cell above.