Translation:Shulchan Aruch/Orach Chaim/268

268ː The Law Governing One Who Errs in the Shabbos Prayer. Contains 13 seifim.

1 One says Vayechulu during the prayer of ma'ariv.

2 If one erred and began the weekday prayer, one finishes that blessing wherein he realized that he erred and begins the one of Shabbat. It does not matter if he remembered in the blessing of 'Atah Chonen' or if he remembered in one of the other blessings, whether in the evening prayer or the morning prayer, musaf and minchah. And there are those who say that in musaf, one pauses even in the middle of as blessing.

3 If one was certain that it is a weekday and he began with the intention that it's a weekday, and immediately when he said the word 'Atah', he remembered, before he said 'Chonen', he has the status of one began the weekday one, and finishes that blessing. However, if he knew that it is Shabbat, and without intention, began the word 'Atah', even if it is in the morning prayer which does not open with 'Atah', he does not finish the blessing 'Atah Chonen' because we consider him as one who erred in the prayer of Shabbat, between this one to that one. Gloss: Because he can say 'Atah Kidashta' or 'Atah Echad' (Terumat HaDeshen, Siman 14).

4 One who prayed the weekday prayer on Shabbat and did not mention the Shabbat, has not fulfilled his obligation. And if he mentioned the shabbat during the Shmoneh Esrei, even though he did not designate a blessing for Shabbos, he fulfilled his obligation. Gloss: And in musaf, even if he only said and we will do before You our obligation with the tamid offerings of the day and with the sacrifice of musaf, he fulfilled his obligation. (Beis Yosef, Siman 286, in the name of the Rosh, Perek Mi Shemeto).

5 If one erred and prayed the weekday prayer during Shabbat and did not mention Shabbat – if he moved away his feet, he goes back to the beginning. And if he did not move away his feet, even though he finished his prayer, he returns only to that of Shabbos. (And a chazan that forgot that of Shabbat in the morning prayer – see above, Siman 126).

6 One who erred in the prayer of Shabbat and exchanged this one with another one, he does not return. And there are those who say that if he exchanged the musaf with another one or another one with musaf, he goes back.
7 We go back to say 'Vayechulu' because of yom tov that falls on Shabbat when we do not say it in the amidah, and also to fulfill the obligation for one who does not know. And it is said in a loud voice and while standing.

8 And the chazan says one blessing encapsulating seven. And one praying alone does not say it. Gloss: However, if one praying alone wants to be stringent on himself, one could say it without an opening and without a closing and such is the custom of the congregation to say it with the chazan without an opening and closing (Avudraham and Kol Bo).

9 Yom tov that falls on Shabbat – one does not mention yom tov in the blessing encapsulating seven (meaning, the blessing of "El Elyon, Koneh", etc.).

10 We do not say a blessing encapsulating seven in the house of grooms and mourners because there is not the reason of those who come late lest they be injured.

11 Even during Shabbat that's after yom tov, we say a blessing encapsulating seven.

12 One should not talk at the time when 'Vayechulu' is being said; and not at the time when the chazan says a blessing encapsulating seven.

13 If one prayed the weekday prayer and did not mention Shabbat, or that one did not pray at all, and one heard from the chazan a blessing encapsulating seven from the beginning, and until the end, he fulfilled his obligation.