\documentclass[a4paper,12pt,twoside]{book}

\usepackage{bierbook-style}
% All required packages should be included in bierbook-style

\newcommand{\expotitle}{
	% makes the title page
	\thispagestyle{empty}
        \begin{center}
	{\Large Cambridge University Caving Club}
	\vskip80pt
	{\Huge \bf Expo \the\year}
	\vskip40pt
	{\fontsize{100}{120}\selectfont\sc Sesh}
        \vskip24pt
	{\fontsize{100}{120}\selectfont\sc Book}
	\vskip120pt
	The Sesh Book is intended to be taken to every sesh at the Gasthof, so the Bier Book can
	remain in the Potato Hut. 
        \vskip12pt
	For each sesh, the table recording attendees, amount owed and amount paid is the primary reference for the treasurer and should be completed accurately. The totals give a quick check that everything has been accounted for. 
        \vskip12pt
	The space on the opposite page can be used for recording the details of what each person had, and
	for tallies etc. Any other details that might make it easier for the treasurer to decipher the receipt
	should also be noted.
        \vskip24pt
        \textbf{Expo Dinner choices at the back of this book}
        \end{center}
	\vfill
	\clearpage
}

\newcommand{\expoheading}[1]{
% provides the formatting for a title of a section
\vspace{10pt}
{\LARGE\bf #1}
\vspace{20pt}
}

\newcommand{\sesh}[1]{
% argument is the number of the sesh
% longtable
\begin{longtable}{p{10cm}|p{2cm}|p{2cm}}
\multicolumn{3}{l}{\expoheading{Sesh #1 - \ldots\ldots/(Jul/Aug)/\the\year}} \\
Attendee \and Amount ordered \and Amount paid \\
\toprule 
\endhead
%
\bottomrule
Totals \and \and \\
\endfoot
%
\setcounter{seshlines}{0}
\whiledo{\value{seshlines}<24}{
\and \and \\
\midrule
\stepcounter{seshlines}
}
%
\and \and \\
%
\end{longtable}
\clearpage
\begin{longtable}{p{14cm}}
\expoheading{Sesh #1 - Notes} \\
Please use this page to record details of the sesh, who ordered what, how much individual items cost, to avoid clutter on the opposite table.\\
\end{longtable}
\clearpage
}

\newcommand{\dinnerlist}{
% no arguments required
% longtable, generated from the list of names
% uses dinnerline for each line
\openin\namesread=names.txt
\setcounter{linecount}{0}
\begin{longtable}{l|p{1.2cm}|p{3cm}|p{3cm}|l}
\multicolumn{5}{l}{\expoheading{Expo Dinner}} \\
\multicolumn{5}{p{\textwidth}}{Please record people's dinner choices here in advance of the expo dinner.}
\vspace{1cm}\\
Name \and Going? \and Allergies? \and Dessert \and Notes \\
\toprule
\endfirsthead
Name \and Going? \and Allergies? \and Dessert \and Notes \\
\toprule
\endhead
\bottomrule
\endfoot
%
\stepcounter{linecount}
\whiledo{\value{linecount}<\value{maxlines}}{
	\stepcounter{linecount}
	\read\namesread to \currentname
	\dinnerline{\currentname}
	\midrule
}
%
\read\namesread to \currentname
\dinnerline{\currentname}
\midrule
%
\end{longtable}
\clearpage
}

\newcommand{\dinnerline}[1]{
% argument is the name on the line
% boxes are a tikz grid
\begin{tikzpicture}
\pgfmathsetmacro{\wvar}{0.4}
\node at (0,0.6*\wvar) [anchor=east] {#1};
\node at (0,0) {};
\node at (0,4*\wvar) {};
\end{tikzpicture}
\and
\and
\and
\and
\\
}

\newcommand{\blankpage}[1]{
% for creating a double page with nothing but a title
% longtable to consistent formatting
\begin{longtable}{p{\textwidth}}
\expoheading{#1} \\
\vspace{\textheight} \\
\end{longtable}
}


\begin{document}

\newread\namesread
\newcounter{maxlines}
\newcounter{linecount}
\def\and{&}

\openin\namesread=names.txt
\loop\unless\ifeof\namesread
	\read\namesread to \currentname
	\stepcounter{maxlines}
\repeat
\addtocounter{maxlines}{-1}

\expotitle

\newpage

\newcounter{seshcount}
\newcounter{seshlines}
\stepcounter{seshcount}
\def\and{&}
\whiledo{\value{seshcount}<50}{
	\sesh{\theseshcount}
	\stepcounter{seshcount}
}

\blankpage{Sesh Quotes}
\blankpage{}
\blankpage{}

\dinnerlist

\end{document}
