%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright 2012 Robert Krause
% Copyright @COPYRIGHTDATE@ Louis Paternault
% License : Creative Commons Attribution License
%
% Produced by `scal` version @VERSION@.
% http://git.framasoft.org/spalax/scal
%
% Compile it using `lualatex`
%
% History:
% This file has been posted by original author Robert Krause on TeXample.net
% [1] on 13 July 2012. I (Louis Paternault) used it as a base for this
% template, for the scal software.
%
% [1] http://www.texample.net/tikz/examples/a-calender-for-doublesided-din-a4/
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Compile it using LuaLaTeX
%$ lualatex $basename

\documentclass[10pt]{article}

\IfFileExists{hyperref.sty}{
  \usepackage[
    pdftitle={Calendar for years
        2014
        2015
    },
    pdfcreator={LuaLaTeX, using a file generated by `scal` version @VERSION@},
  ]{hyperref}
}{
  % Hyperref not loaded
}

\usepackage{fontspec}
\renewcommand{\familydefault}{\sfdefault}

\usepackage[french]{babel}
\usepackage[french]{translator} % Internationalized  Month and Day names

\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{calendar}

\usepackage[a4paper, landscape, margin=.5cm]{geometry}

\newcommand{\cellwidth}{\textwidth/11}
\newcommand{\cellheight}{\textheight/34}
\newcommand{\cellsep}{2pt}

% Names of Holidays are inserted by employing this macro. Arguments:
% - #1: First day of holidays
% - #2: Holiday name
\def\printholiday#1#2{
    \node [anchor=north west, align=right, text width={\cellwidth-\cellsep-7pt}] at
    ($(cal-#1.north west)$) {\tiny{#2\par}};
}

% Display weeks
% - #1 Day in which week is to be written
% - #2 Week number (as LaTeX code)
\def\printweek#1#2{
    \node [anchor=east, align=center, color=gray] at
    ($(cal-#1.east)$) {{#2\par}};
}

% Display the year. Arguments are:
% - #1: Year
% - #2: First day of year
% - #3: First day of last month of year
\newcommand{\printyear}[3]{
  \draw[fill=red!70, draw=none]
    ($(cal-#1-#2-01.north west)+(0, {2*\cellheight})$)
    rectangle
    ($(cal-#1-#3-01.south east)+(0, {2*\cellheight})$)
    node[midway, text=white]{\textbf{#1}};
}

\pagestyle{empty}

\begin{document}


\begin{center}
\begin{tikzpicture}[every day/.style={anchor = north}]
\pgftransformyshift{\cellheight}
\calendar[
  dates=2014-9-01 to 2015-7-last,
  name=cal,
  day yshift = \cellheight,
  day code=
  {
    \node[name=\pgfcalendarsuggestedname,every day,shape=rectangle,
    minimum height= \cellheight, draw=black, text width = {\cellwidth-\cellsep-7pt}]{};
    \draw ($(\pgfcalendarsuggestedname.west)+(0  em,0)$)           node[anchor=west, color=gray]{\tikzdaytext};
    \draw ($(\pgfcalendarsuggestedname.west)+(1.5em,0)$) node[anchor=west, color=gray]{\footnotesize \pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday}};
  },
  execute before day scope=
  {
    \ifdate{day of month=1}
    {
      % Shift right
      \pgftransformxshift{\cellwidth}
      % Print month name 
      \draw (0,0) node [shape=rectangle, minimum height= \cellheight,
          text width = {\cellwidth-\cellsep-7pt}, fill = red!70, text= white, draw = red!70, text centered]
        {\textbf{\pgfcalendarmonthname{\pgfcalendarcurrentmonth}}};
    }{}
    \ifdate{workday}
    {
      % normal days are white
      \tikzset{every day/.style={fill=white}}
      % Holidays
      \ifdate{between=2014-11-11 and 2014-11-11}{%
        \tikzset{every day/.style={fill=gray!30}}}{}
      \ifdate{between=2015-05-01 and 2015-05-01}{%
        \tikzset{every day/.style={fill=gray!30}}}{}
      \ifdate{between=2015-05-08 and 2015-05-08}{%
        \tikzset{every day/.style={fill=gray!30}}}{}
      \ifdate{between=2014-12-25 and 2014-12-25}{%
        \tikzset{every day/.style={fill=gray!30}}}{}
      \ifdate{between=2015-04-06 and 2015-04-06}{%
        \tikzset{every day/.style={fill=gray!30}}}{}
      \ifdate{between=2015-05-14 and 2015-05-14}{%
        \tikzset{every day/.style={fill=gray!30}}}{}
      \ifdate{between=2015-05-25 and 2015-05-25}{%
        \tikzset{every day/.style={fill=gray!30}}}{}
      \ifdate{between=2014-10-18 and 2014-11-02}{%
        \tikzset{every day/.style={fill=gray!30}}}{}
      \ifdate{between=2014-12-20 and 2015-01-04}{%
        \tikzset{every day/.style={fill=gray!30}}}{}
      \ifdate{between=2015-02-07 and 2015-02-22}{%
        \tikzset{every day/.style={fill=gray!30}}}{}
      \ifdate{between=2015-04-11 and 2015-04-26}{%
        \tikzset{every day/.style={fill=gray!30}}}{}
      \ifdate{between=2014-09-01 and 2014-09-01}{%
        \tikzset{every day/.style={fill=gray!30}}}{}
      \ifdate{between=2015-07-05 and 2015-07-31}{%
        \tikzset{every day/.style={fill=gray!30}}}{}
    }{}
    % Saturdays
    \ifdate{Saturday}{\tikzset{every day/.style={fill=red!10}}}{}
    % Sundays
    \ifdate{Sunday}{\tikzset{every day/.style={fill=red!20}}}{}
  },
 execute at begin day scope=
  {
    % each day is shifted down according to the day of month
    \pgftransformyshift{-{\cellheight * \number\pgfcalendarcurrentday}}
  }
];

% Print name of Holidays
    \printholiday{2014-11-11}{Armistice}
    \printholiday{2015-05-01}{Fête du travail}
    \printholiday{2015-05-08}{Victoire 1945}
    \printholiday{2014-12-25}{Noël}
    \printholiday{2015-04-06}{Lundi de Pâques}
    \printholiday{2015-05-14}{Ascension}
    \printholiday{2015-05-25}{Lundi de Pentecote}
    \printholiday{2014-10-18}{Vacances d'automne}
    \printholiday{2014-12-20}{Vacances de fin d'année}
    \printholiday{2015-02-07}{Vacances d'hiver}
    \printholiday{2015-04-11}{Vacances de printemps}

% Print week numbers
  \printweek{2014-09-03}{36}
  \printweek{2014-09-10}{37}
  \printweek{2014-09-17}{38}
  \printweek{2014-09-24}{39}
  \printweek{2014-10-01}{40}
  \printweek{2014-10-08}{41}
  \printweek{2014-10-15}{42}
  \printweek{2014-10-22}{43}
  \printweek{2014-10-29}{44}
  \printweek{2014-11-05}{45}
  \printweek{2014-11-12}{46}
  \printweek{2014-11-19}{47}
  \printweek{2014-11-26}{48}
  \printweek{2014-12-03}{49}
  \printweek{2014-12-10}{50}
  \printweek{2014-12-17}{51}
  \printweek{2014-12-24}{52}
  \printweek{2014-12-31}{1}
  \printweek{2015-01-07}{2}
  \printweek{2015-01-14}{3}
  \printweek{2015-01-21}{4}
  \printweek{2015-01-28}{5}
  \printweek{2015-02-04}{6}
  \printweek{2015-02-11}{7}
  \printweek{2015-02-18}{8}
  \printweek{2015-02-25}{9}
  \printweek{2015-03-04}{10}
  \printweek{2015-03-11}{11}
  \printweek{2015-03-18}{12}
  \printweek{2015-03-25}{13}
  \printweek{2015-04-01}{14}
  \printweek{2015-04-08}{15}
  \printweek{2015-04-15}{16}
  \printweek{2015-04-22}{17}
  \printweek{2015-04-29}{18}
  \printweek{2015-05-06}{19}
  \printweek{2015-05-13}{20}
  \printweek{2015-05-20}{21}
  \printweek{2015-05-27}{22}
  \printweek{2015-06-03}{23}
  \printweek{2015-06-10}{24}
  \printweek{2015-06-17}{25}
  \printweek{2015-06-24}{26}
  \printweek{2015-07-01}{27}
  \printweek{2015-07-08}{28}
  \printweek{2015-07-15}{29}
  \printweek{2015-07-22}{30}
  \printweek{2015-07-29}{31}

% Print years
  \printyear{2014}{09}{12}
  \printyear{2015}{01}{07}
\end{tikzpicture}
\end{center}
\end{document}
