%( $Id: deslist_cal.txt mickroue(a)yahoo.fr 20140129 templ=templm %)

%define;color(xx)
  %apply;nth%with;
    /606060/993333/339933/333399/999999/339999/993399/999933/AAAAAA/FFAAAA/AAFFAA/AAAAFF/FFFFFF/AAFFFF/FFAAFF/FFFFAA%and;
    xx%end;
%end;

%define;desc_calendar(curlev,maxlev)
  %if;(birth_date.day != "")
    %incr_count;
    %let;mm_dd;%expr(birth_date.month+100)_%expr(birth_date.day+100)%in;
    %apply;add_in_sorted_list(mm_dd,birth_date.month,birth_date.day,index,birth_symbol)
  %end;
  %if;(death_date.day != "")
    %incr_count
    %let;mm_dd;%expr(death_date.month+100)_%expr(death_date.day+100)%in;
    %apply;add_in_sorted_list(mm_dd,death_date.month,death_date.day,index,death_symbol)
  %end;
  %foreach;family;
    %if;(curlev < maxlev and family.desc_level = curlev and has_children)
      %family.set_infinite_desc_level;
      %foreach;child;
        %apply;desc_calendar(curlev+1,maxlev)
      %end;
    %end;
  %end;
%end;

%define;stat_calendar()
%( table calendar nb day-month %)
  %reset_desc_level;
  %reset_count;
  %empty_sorted_list;
  %apply;desc_calendar(0,l_v)
  <div class="stat_calendar bcbg1">
    <a class="title" style="color:#EEEEEE;" href="%prefix;m=D;t=L;tl1=ars;i=%index;;v=%l_v;;only=%evar.only;"
         title="Ars">[*calendar/calendars]0</a>
    <div class="row">
      %for;i;1;32;
        <div>%i;</div>
      %end;
    </div>
    <div class="col">
      [(month)]0<br%/>[(month)]1<br%/>[(month)]2<br%/>[(month)]3<br%/>
      [(month)]4<br%/>[(month)]5<br%/>[(month)]6<br%/>[(month)]7<br%/>
      [(month)]8<br%/>[(month)]9<br%/>[(month)]10<br%/>[(month)]11
    </div><br%/>
    <div class="body">
    %reset_count;
    %foreach;sorted_list_item;
      %if;(prev_item.1 != item.1)
        %reset_count;%incr_count;
        <a href="%prefix;spouse=on;m=RLM;i%count;=%item.4;;t%count;=%item.5;;%nn;
      %end;
      %if;(prev_item.1 = item.1)
        %incr_count;
        i%count;=%item.4;;t%count;=%item.5;;%nn;
      %end;
      %if;(next_item.1 != item.1)
        %let;top;%expr(item.2 * 30 - 30)%in;
        %let;left;%expr(item.3 * 28 - 28)%in;
        %let;colhex;%apply;color(count)%in;
        %incr_count;
        i%count;=%index;;t%count;=%item.3; %apply;nth([(month)],item.2-1);%nn;
        %if;(max_event >= count)
          " style="border:solid 1px #%colhex;; color:#%colhex;;top:%top;px;left:%left;px;">%expr(count - 1)</a>
        %else;
          " style="display:none;"></a>
          <span style="border:solid 1px #%colhex;; color:#%colhex;;top:%top;px;left:%left;px;">%expr(count - 1)</span>
        %end;
      %end;
    %end;
    </div>
  </div>
%end;

%( birth month death month tl1 = cal %)
  <p>%apply;togen(l_v)</p>
  %apply;stat_calendar()
</table>
