marei: switch to dtx generated files
[kivitendo-erp.git] / templates / print / marei / kiviletter.sty
index 44c4838..7ed1d09 100644 (file)
@@ -25,9 +25,6 @@
 \RequirePackage{tabularx}
 \RequirePackage{longtable}
 \RequirePackage{booktabs}
-\PassOptionsToPackage{table}{xcolor}
-
-\RequirePackage{xcolor}
 \RequirePackage{graphicx}
 
 \ifPDFTeX
@@ -196,6 +193,7 @@ contents={\usebox\shippingAddressBox}
 
 \newcolumntype{P}[1]{>{\raggedleft\arraybackslash}p{#1}<{\__kivi_tab_column_currency:}}
 
+
 \RequirePackage{tcolorbox}
 \tcbuselibrary{breakable, skins}
 
@@ -208,6 +206,7 @@ contents={\usebox\shippingAddressBox}
        },
        underlay~unbroken~and~last={
        \node[anchor=north]  at (interior.north)  {\csname box_use:c\endcsname  {g_kivi_LT@head_box}};
+       \node[anchor=south]  at (interior.south)  {\csname box_use:c\endcsname  {g_kivi_LT@lastfoot_box}};
        },
        boxsep=0pt,
        boxrule=0pt,
@@ -245,6 +244,7 @@ contents={\usebox\shippingAddressBox}
        \seq_set_split:Nnn \l_kivi_PricingTable_seq {\tabularnewline} {#1}
        \seq_remove_all:Nn \l_kivi_PricingTable_seq {}
        \begingroup
+       \let\ExtraDescription\__kivi_addExtraDescription:n
        \setlength{\tabcolsep}{\g_kivi_tabcolsep_dim}
        \seq_map_inline:Nn \l_kivi_PricingTable_seq {
                \seq_set_split:Nnn  \l_kivi_columns_seq {&} {##1}
@@ -258,10 +258,11 @@ contents={\usebox\shippingAddressBox}
        \endtabular
        \seq_if_empty:NTF \g_kivi_extraDescription_seq
        {\par}
-       {\par
+       {\par\nopagebreak
        \begingroup
        \setlength{\hsize}{\dimexpr\l_kivi_tab_desc_dim+\l_kivi_tab_desc_leftskip_dim}
        \setlength{\leftskip}{\l_kivi_tab_desc_leftskip_dim}
+       \usekomafont{extraDescription}
        \seq_use:Nn \g_kivi_extraDescription_seq {\\}
        \par\nointerlineskip
        \endgroup
@@ -294,6 +295,7 @@ contents={\usebox\shippingAddressBox}
 }
 
 \cs_new:Nn \__kivi_tab_column_currency: {\,\currency}
+\def\tabcurrency{\__kivi_tab_column_currency:}
 \cs_set:Nn \__kivi_tab_column_header_currency: {}
 \cs_set_eq:NN \__kivi_tab_column_body_currency:  \__kivi_tab_column_currency:
 
@@ -308,20 +310,7 @@ contents={\usebox\shippingAddressBox}
        \hbox_gset:Nn \g_kivi_LT@head_box {
                \setlength{\tabcolsep}{\g_kivi_tabcolsep_dim}
                \exp_args:Nnx \use:n {\tabular[b]}\g_kivi_Pricing_colspec_tl
-               \toprule
-               \cs_gset_eq:NN \__kivi_tab_column_currency: \__kivi_tab_column_header_currency:
-               \bool_set_false:N \l_tmpa_bool
-               \clist_map_inline:Nn \g_kivi_pricingtable_col_clist     {
-                       \bool_if:cT {l_kivi_col_##1_bool} {
-                       \bool_if:NT \l_tmpa_bool {&}
-                       \bool_set_true:N \l_tmpa_bool
-                               \usekomafont{PricingTableHeader}
-                               \prop_item:cn {l_kivi_col_##1_prop} {header}
-                       }
-               }
-               \cs_gset_eq:NN \__kivi_tab_column_currency: \__kivi_tab_column_body_currency:
-               \\
-               \midrule
+               \__kivi_PricingTabular_header:
                \endtabular
        }
        \hbox_gset:Nn \g_kivi_LT@foot_box {
@@ -332,51 +321,98 @@ contents={\usebox\shippingAddressBox}
                        \end{tabular*}
                }
        }
+       \hbox_gset:Nn \g_kivi_LT@lastfoot_box {
+               \raisebox{\dimexpr\depth+\baselineskip}[0pt][0pt]{
+                       \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}r@{}}
+                               \bottomrule
+                       \end{tabular*}
+               }
+       }
 }
 
 
 %Macht es sinn hier eine Variante zu machen, in der alle Spalten Belegbar sind?
 \newenvironment{PricingTotal}{
-       \tabular[t]{@{}p{\dim_eval:n {\linewidth-\l_kivi_tab_price_dim-2\tabcolsep}}P@{}}
+       \par
+       \vspace{-\ht\strutbox}
+       \unskip
+       \tabular[t]{@{}p{\dim_eval:n {\linewidth-\l_kivi_tab_pricetotal_dim-2\tabcolsep}}P{\l_kivi_tab_pricetotal_dim}@{}}
        \midrule
 }{
-       \bottomrule\endtabular
+       \endtabular
 }
 
-\newcommand{\ExtraDescription}[1]{\seq_gput_right:Nn \g_kivi_extraDescription_seq {#1}}
+
+\newcommand*\ExtraDescription{
+       \PackageError{kiviletter}{The~command~\string\ExtraDescription\space~may~be~only~used~inside~the~\string\FakeTable\space~environment.}{See~documentation~for~details}
+}
+
+
+\cs_new:Nn \__kivi_addExtraDescription:n {\seq_gput_right:Nn \g_kivi_extraDescription_seq {#1}}
 
 \newenvironment{PricingTabular}[1][]{
        \begingroup
+       \tl_if_empty:nF {#1} {\keys_set:nn {kivi/PricingTable} {#1}}
        \setlength{\tabcolsep}{\g_kivi_tabcolsep_dim}
        \__kivi_calc_desc_column:
        \exp_args:Nx \longtable \g_kivi_Pricing_colspec_tl
        % Tabellenkopf
-       \toprule
-       \bfseries\position & \bfseries\artikelnummer & \bfseries\bezeichnung & \bfseries\menge &\multicolumn{1}{P}{\bfseries\einzelpreis}&\multicolumn{1}{P@{}}{\bfseries\gesamtpreis}\\
-       \midrule
+       \__kivi_PricingTabular_header:
        \endhead
        \midrule
-       \multicolumn{6}{@{}r@{}}{\weiteraufnaechsterseite}\\
+       \rlap{\makebox[\textwidth][r]{\weiteraufnaechsterseite}}\\
        \endfoot
+       \bottomrule
+       \endlastfoot
 }{
        \endlongtable
        \endgroup
 }
 
+\cs_set:Nn \__kivi_PricingTabular_header: {
+       \toprule
+       \cs_gset_eq:NN \__kivi_tab_column_currency: \__kivi_tab_column_header_currency:
+       \bool_set_false:N \l_tmpa_bool
+       \clist_map_inline:Nn \g_kivi_pricingtable_col_clist     {
+               \bool_if:cT {l_kivi_col_##1_bool} {
+                       \bool_if:NT \l_tmpa_bool {&}
+                       \bool_set_true:N \l_tmpa_bool
+                       \usekomafont{PricingTableHeader}
+                       \prop_item:cn {l_kivi_col_##1_prop} {header}
+               }
+       }
+       \cs_gset_eq:NN \__kivi_tab_column_currency: \__kivi_tab_column_body_currency:
+       \\
+       \midrule
+}
+
 \RequirePackage{xltabular}
 
+\keys_define:nn {kivi/SimpleTabular} {
+       colspec .tl_set:N =\l_kivi_SimpleTabular_colspec_tl,
+       colspec .initial:n = {rrX},
+       headline .tl_set:N = \l_kivi_SimpleTabular_headline_tl,
+       headline .initial:n = {\bfseries\position & \bfseries\menge & \bfseries\bezeichnung},
+}
 
-\newenvironment{SimpleTabular}[1][\bfseries\position & \bfseries\menge & \bfseries\bezeichnung]
+\newenvironment{SimpleTabular}[1][]
 {
+       \tl_if_in:nnTF {#1} {=} {\keys_set:nn {kivi/SimpleTabular} {#1}} {\tl_if_empty:nF {#1} {\tl_set:Nn \l_kivi_SimpleTabular_headline_tl {#1}}}
        \setlength{\tabcolsep}{\g_kivi_tabcolsep_dim}
-       \xltabular{\linewidth}{@{}rrX@{}}
-       \toprule
-       #1\\
-       \midrule\\\endhead
-       \midrule
-       \multicolumn{3}{@{}>{\raggedright}p{\linewidth}@{}}{\weiteraufnaechsterseite}\\
+       \tl_put_right:Nn \l_kivi_SimpleTabular_colspec_tl {@{}}
+       \tl_put_left:Nn \l_kivi_SimpleTabular_colspec_tl {@{}}
+       \exp_args:NnV \xltabular{\linewidth}\l_kivi_SimpleTabular_colspec_tl
+               \toprule
+               \cs_gset_eq:NN \__kivi_tab_column_currency: \__kivi_tab_column_header_currency:
+               \l_kivi_SimpleTabular_headline_tl
+               \\
+               \noalign{\cs_gset_eq:NN \__kivi_tab_column_currency: \__kivi_tab_column_body_currency:}
+               \midrule
+       \endhead
+               \midrule
+               \rlap{\makebox[\textwidth][r]{\weiteraufnaechsterseite}}\\
        \endfoot
-       \bottomrule
+               \bottomrule
        \endlastfoot
        \ignorespaces
 }{
@@ -390,7 +426,6 @@ contents={\usebox\shippingAddressBox}
 % analog ist dies für pos, amount, price, pricetotal möglich.
 % Die Spalte der Bezeichnung ist nicht deaktivierbar
 \newenvironment{PricingTabular*}[1][]{
-       \bool_gset_true:N \g_kivi_inTable_bool
        \tl_if_empty:nF {#1} {\keys_set:nn {kivi/PricingTable} {#1}}
        \__kivi_setup_LT_boxes:
        \__kivi_setup_FakeTable:
@@ -445,4 +480,6 @@ contents={\usebox\shippingAddressBox}
 
 \renewcommand*{\raggedsignature}{\raggedright}
 
+\newkomafont{extraDescription}{}
+
 \endinput