Opt -> cpt -> h1b

I am on my STEM OPT now and my employer has filed for my H1-B this year. Its currently in processing(I have still not received any receipt and it’s normal processing). I have got admitted for Ph.D.
Now if I have to join Ph.D. I will have to go for CPT. My stem OPT is due to expire in October. My semester starts in August. Which will also be my CPT start date.
1)Will it affect my H1-B filing and if it doesn’t will it impact my COS(Change of status) from F1 to H1-B?
2)If in case my H1-B is approved and my COS is denied will my SEVIS be terminated and do I have to leave the county or can I continue my Ph.D. under the same SEVIS and status?