% Info-sheet for the parcel service
% Context file
% filename: infotable.tex
% W.Egger
% 06-01-2006
% Thanks to a thread on the Context mailinglist this works now!


\environment layout
\setupbodyfont[10pt]
\setuppapersize[A4,landscape][A4,landscape]
\setuplayout[
    topspace=1.5cm,
    backspace=1.5cm,
    width=27cm]
\setupheadertexts[\leftaligned{\bfd Parcel service info-sheet}]

\def\Addressee#1#2#3#4#5#6#7#8{%
	\setvalue{Ordno#1}{#2}%
	\setvalue{Bestno#1}{#3}%
	\setvalue{Adres#1}{#4}%
	\setvalue{Dimension#1}{#5}%
	\setvalue{Weight#1}{#6}%
	\setvalue{Value#1}{#7}%
	\setvalue{Tel#1}{#8}}

\def\Parcel#1{%
	\bTR%
		\bTD\getvalue{Ordno#1}%
			\doiftextelse{\getvalue{Bestno#1}}%
			{\blank[small]Ext. Orderno:\par\hfill\getvalue{Bestno#1}}{\strut\blank} \eTD%
		\bTD \getvalue{Adres#1} \eTD%
        \bTD \getvalue{Dimension#1} \eTD%
        \bTD \getvalue{Weight#1} \eTD%
        \bTD \getvalue{Value#1} \eTD%
        \bTD \getvalue{Tel#1} \eTD\eTR}

\def\Numberofparcels{3}

\starttext

\Addressee{1}%
	{293-291}%Ordernumber
	{12345-2009}%External ordernumber
	{Maximilian Smallbody\\ Sunshinestreet 24\\ 3456 EE Natland\\ Cloudyland}%Addres
	{70 x 67 x 15 cm}%Dimension
	{7.5 kg}%Weight
	{1.000.00\euro}%Value
	{+31 455535251}%Phone

\Addressee{2}%
	{293-292}%TC-nummer
	{}%External ordernumber
	{Milly Milltower\\ 3\high{rd} Duststreet\\ Millerstown 56789\\ Millersland}%Addres
	{120 x 12 x 12 cm}%Dimension
	{2.5 kg}%Gewicht
	{293.00\euro}%Waarde buiten EU
	{+99-9192939495}%Telefoon

\Addressee{3}%
	{}%
	{}%
	{}%
	{}%
	{}%
	{}%
	{}%


%= Do not edit below this line!=
{\bfa Date: \date}

\blank[1.5cm]
\bTABLE
    \setupTABLE[row][first][style=bold,align=middle]
    \setupTABLE[column][each][width=.166\textwidth,align=right]
	\setupTABLE[x][3][align=middle]
	\setupTABLE[x][4][align=left]
	\setupTABLE[x][5][align=left]

    \bTR
        \bTD Ordernumber\eTD
        \bTD Address \eTD
        \bTD Dimension \eTD
        \bTD Weight \eTD
        \bTD Value \eTD
        \bTD Phone \eTD\eTR

    \dostepwiserecurse{1}{\Numberofparcels}{1}{%
		\expanded{\Parcel{\recurselevel}}}

\eTABLE
\stoptext
