Index: anr/gantt.l
===================================================================
--- anr/gantt.l	(revision 296)
+++ anr/gantt.l	(revision 300)
@@ -40,4 +40,15 @@
     0
 };
+char* subtask_names[20][20];
+char* get_subtask_name(int tn, int stn)
+{
+    char* ret=subtask_names[tn][stn];
+    if (ret==0)  {
+        fprintf(stderr,"ERROR: no name found for st%d-%d sub-task.\n",tn,stn);
+        return "";
+    } else
+        return ret;
+}
+
 struct partner_def { char *key, *name, *fnfull, *fnshort; } partner_table[] = {
     { "UNKNOW" ,"relax"  ,0                             ,0                        },
@@ -242,4 +253,15 @@
         milestones[i] = atoi(yytext+3);
     }
+STN=.*   {
+        int nb,tn, stn;
+        char tmp[1000];
+        nb=sscanf(yytext+4,"%d%d%s",&tn,&stn,tmp);
+        if ( nb==3 && 0<=tn && tn<10 && 0<=stn && stn<10 ) {
+            char* p =strstr(yytext+4,tmp);
+            subtask_names[tn][stn]=strdup(p);
+        } else {
+            fprintf(stderr, "bad formated ST rule (ignored): %s.\n",yytext);
+        }
+}
 BM=[0-9]+ { bm=atoi(yytext+3); }
 EM=[0-9]+ { em=atoi(yytext+3); }
@@ -725,9 +747,10 @@
                 sum2 = lcurr->hman[1]; sum +=sum2;
                 sum3 = lcurr->hman[2]; sum +=sum3;
-                char label[1000],title[1000];
+                char label_lnk[1000],label[1000],title[1000];
                 gen_label_base(label,leader);
+                sprintf(label_lnk,"\\hyperlink{%s}{%s}",label,label);
                 sprintf(title,"\\resstablestyletitle{%s}",leader->title);
                 fprintf(curr->os,"%s & %s & %2.1f & %2.1f & %2.1f & %2.1f \\\\\\hline\n",
-                   label,title,sum1,sum2,sum3,sum);
+                   label_lnk,title,sum1,sum2,sum3,sum);
                 an1 += sum1 ; tsk1 += sum1 ;
                 an2 += sum2 ; tsk2 += sum2 ;
@@ -818,6 +841,4 @@
                 an  += sum  ; tsk  += sum  ;
                 newlineadded=0;
-                char label[1000];
-                gen_label_base(label,leader);
             }
         }
@@ -886,6 +907,7 @@
             if ( l==0 ) break;
             if ( l->leader==0 ) continue;
-            char label[1000],resp[100],date[100],kind[100],desc[1000];
+            char label_lnk[1000],label[1000],resp[100],date[100],kind[100],desc[1000];
             gen_label_full(label,l);
+            sprintf(label_lnk,"\\hyperlink{%s}{%s}",label,label);
             sprintf(resp,"\\S%s",partner_table[l->partner].key);
             sprintf(date,"\\makebox[2mm][r]{%d}",l->em);
@@ -902,5 +924,5 @@
                 sprintf(desc, "\\\\\\cline{1-4}\n");
 
-             fprintf(curr->os,"%-15s", label);
+             fprintf(curr->os,"%-15s", label_lnk);
              fprintf(curr->os," & %-10s", resp);
              fprintf(curr->os," & %-30s", date);
@@ -913,5 +935,4 @@
 }
 
-#if 1
 void do_effort_par_livrable(char* filename,int from_task, int to_task)
 {
@@ -919,5 +940,5 @@
     if ( (curr->os=fopen(filename,"w"))==0 ) {
         fprintf(stderr,"can not open %s file for writing.\n",filename);
-        fprintf(stderr,"generation of %s partner table is skipped.\n",filename);
+        fprintf(stderr,"generation of %s file is skipped.\n",filename);
         return;
     }
@@ -953,9 +974,10 @@
                 sum2 = lcurr->hman[1]; sum +=sum2;
                 sum3 = lcurr->hman[2]; sum +=sum3;
-                char label[1000],title[1000];
+                char label_lnk[1000],label[1000],title[1000];
                 gen_label_base(label,lcurr);
+                sprintf(label_lnk,"\\hyperlink{%s}{%s}",label,label);
                 sprintf(title,"\\resstablestyletitle{%s}",top->title);
                 fprintf(curr->os,"%10s & %50s & %10s & %2.1f & %2.1f & %2.1f & %2.1f \\\\\\hline\n",
-                   linenb==0 ? label : "",
+                   linenb==0 ? label_lnk : "",
                    linenb==0 ? title : "",
                    partner_table[lcurr->partner].key,
@@ -980,5 +1002,5 @@
                 char title[1000];
                 sprintf(name,"st%d-%d",task_n,subtask_n);
-                sprintf(title,"\\resstablestyletitle{%s}","");
+                sprintf(title,"\\resstablestyletitle{%s}",get_subtask_name(task_n,subtask_n));
     	        fprintf(curr->os,"%10s & %50s & %10s & %2.1f & %2.1f & %2.1f & %2.1f \\\\\\hline\n",
                     name,title,"total",st_sum1,st_sum2,st_sum3,st_sum);
@@ -999,4 +1021,182 @@
     curr->os=0;
 }
+
+void do_partner_by_subtask()
+{
+    char filename[2000];
+    int tn,stn,dn,partner;
+    for (tn=0 ; tn<T_MAX ; tn++) {
+        int livrablenb=0,subtasknb=0;
+        int task_n,subtask_n;
+        double  t_sum1=0, t_sum2=0, t_sum3=0, t_sum=0;
+        double st_sum1=0,st_sum2=0,st_sum3=0,st_sum=0;
+        if (curr->ls[tn][0][0][0]==0) break;
+        for (stn=0; stn<S_MAX; stn++) {
+          int parts[100]; memset(parts,0,sizeof(parts));
+          int partnb=0;
+          for (dn=0; dn<D_MAX; dn++) {
+            int linenb = 0;
+            Tlivrable* top=curr->ls[tn][stn][dn][0];
+            if ( top==0 ) break;
+            double liv1=0,liv2=0,liv3=0,liv=0;
+            for (partner=1 ; partner_table[partner].key!=0 ; partner+=1) {
+                Tlivrable *lcurr,*leader;
+                if ( (lcurr=do_partner_table_getLivrable(&leader,top,partner))==0 ) {
+                    continue;
+                }
+                parts[partner]=1; partnb+=1;
+                task_n = top->tn;
+                subtask_n = top->stn;
+            }
+          }
+          if (partnb==0) continue;
+          sprintf(filename,"tmp/st%d-%d-partner.tex",task_n,subtask_n);
+          if ( (curr->os=fopen(filename,"w"))==0 ) {
+              fprintf(stderr,"can not open %s file for writing.\n",filename);
+              fprintf(stderr,"generation of %s file is skipped.\n",filename);
+              continue;
+          }
+          for ( partner=1 ; partner_table[partner].key!=0 ; partner+=1) {
+            if ( parts[partner]==0) continue;
+            fprintf(curr->os,"\\S%s\n",partner_table[partner].key);
+          }
+          fclose(curr->os);
+          curr->os=0;
+       }
+    }
+}
+
+#if 1
+void do_effort_par_livrable_xls(char* filename,int from_task, int to_task)
+{
+    //struct partner_def* part;
+    if ( (curr->os=fopen(filename,"w"))==0 ) {
+        fprintf(stderr,"can not open %s file for writing.\n",filename);
+        fprintf(stderr,"generation of %s file is skipped.\n",filename);
+        return;
+    }
+    int tn,stn,dn,partner;
+    fprintf(curr->os,"\"task\";\"sub-task\";\"delivrable\";");
+    fprintf(curr->os,"\"cumul\";;;;");
+    for ( partner=1 ; partner_table[partner].key!=0 ; partner+=1) {
+        fprintf(curr->os,"\"%s\";;;;",partner_table[partner].key);
+    }
+    fprintf(curr->os,"\"description\";\n");
+    fprintf(curr->os,";;;");
+    fprintf(curr->os,"\"an 1\";\"an 2\";\"an 3\";\"sum\";");
+    for ( partner=1 ; partner_table[partner].key!=0 ; partner+=1) {
+        fprintf(curr->os,"\"an 1\";\"an 2\";\"an 3\";\"sum\";");
+    }
+    fprintf(curr->os,";\n");
+    double an1=0,an2=0,an3=0,anA=0;
+    double an1p[100], an2p[100], an3p[100], anAp[100];
+    memset(an1p,0,sizeof(an1p)); memset(an2p,0,sizeof(an2p));
+    memset(an3p,0,sizeof(an3p)); memset(anAp,0,sizeof(anAp));
+    for (tn=0 ; tn<T_MAX ; tn++) {
+        int livrablenb=0,subtasknb=0;
+        int task_n,subtask_n;
+        double  t_sum1=0,     t_sum2=0,     t_sum3=0,     t_sumA=0;
+        double  t_sum1p[100], t_sum2p[100], t_sum3p[100], t_sumAp[100];
+        memset(t_sum1p,0,sizeof(t_sum1p)); memset(t_sum2p,0,sizeof(t_sum2p));
+        memset(t_sum3p,0,sizeof(t_sum3p)); memset(t_sumAp,0,sizeof(t_sumAp));
+        if (curr->ls[tn][0][0][0]==0) break;
+        for (stn=0; stn<S_MAX; stn++) {
+          double st_sum1=0,     st_sum2=0,     st_sum3=0,     st_sumA=0;
+          double st_sum1p[100], st_sum2p[100], st_sum3p[100], st_sumAp[100];
+          memset(st_sum1p,0,sizeof(st_sum1p)); memset(st_sum2p,0,sizeof(st_sum2p));
+          memset(st_sum3p,0,sizeof(st_sum3p)); memset(st_sumAp,0,sizeof(st_sumAp));
+          
+          livrablenb=0;
+          for (dn=0; dn<D_MAX; dn++) {
+            int linenb = 0;
+            Tlivrable* top=curr->ls[tn][stn][dn][0];
+            if ( top==0 ) break;
+            if ( !( from_task<=top->tn &&  top->tn<=to_task ) ) break;
+            double liv1=0,liv2=0,liv3=0,liv=0;
+            char label_lnk[1000],label[1000],title[1000];
+            gen_label_base(label,top);
+            sprintf(label_lnk,"\\hyperlink{%s}{%s}",label,label);
+            sprintf(title,"%s",top->title);
+            double sum1p[20], sum2p[20], sum3p[20], sumAp[20];
+            memset(sum1p,0,sizeof(sum1p)); memset(sum2p,0,sizeof(sum2p));
+            memset(sum3p,0,sizeof(sum3p)); memset(sumAp,0,sizeof(sumAp));
+            task_n=top->tn;
+            subtask_n=top->stn;
+            for (partner=1 ; partner_table[partner].key!=0 ; partner+=1) {
+                Tlivrable *lcurr,*leader;
+                if ( (lcurr=do_partner_table_getLivrable(&leader,top,partner))==0 )
+                    continue;
+                double sum1,sum2,sum3,sum=0;
+                sum1 = lcurr->hman[0]; sum +=sum1;
+                sum2 = lcurr->hman[1]; sum +=sum2;
+                sum3 = lcurr->hman[2]; sum +=sum3;
+                linenb += 1;
+                liv1 += sum1 ; st_sum1 += sum1 ; t_sum1 += sum1 ; an1 += sum1 ; 
+                liv2 += sum2 ; st_sum2 += sum2 ; t_sum2 += sum2 ; an2 += sum2 ; 
+                liv3 += sum3 ; st_sum3 += sum3 ; t_sum3 += sum3 ; an3 += sum3 ; 
+                liv  += sum  ; st_sumA += sum  ; t_sumA += sum  ; anA += sum  ; 
+                sum1p[partner] += sum1 ; st_sum1p[partner] += sum1 ; t_sum1p[partner] += sum1 ; an1p[partner] += sum1 ;
+                sum2p[partner] += sum2 ; st_sum2p[partner] += sum2 ; t_sum2p[partner] += sum2 ; an2p[partner] += sum2 ;
+                sum3p[partner] += sum3 ; st_sum3p[partner] += sum3 ; t_sum3p[partner] += sum3 ; an3p[partner] += sum3 ;
+                sumAp[partner] += sum  ; st_sumAp[partner] += sum  ; t_sumAp[partner] += sum  ; anAp[partner] += sum  ;
+            }
+            if (linenb>=1) {
+                livrablenb+=1;
+    	        fprintf(curr->os,";;\"%s\";",label);
+                fprintf(curr->os,"%2.1f;%2.1f;%2.1f;%2.1f;",liv1,liv2,liv3,liv);
+                for ( partner=1 ; partner_table[partner].key!=0 ; partner+=1) {
+                    fprintf(curr->os,"%2.1f;%2.1f;%2.1f;%2.1f;",
+                        sum1p[partner],sum2p[partner],sum3p[partner],sumAp[partner]);
+                }
+    	        fprintf(curr->os,"\"%s\";",title);
+                fprintf(curr->os,"\n");
+            }
+          }
+          if ( livrablenb>0) {
+                subtasknb += 1;
+                char name[100];
+                char title[1000];
+                sprintf(name,"st%d-%d",task_n,subtask_n);
+                sprintf(title,"%s",get_subtask_name(task_n,subtask_n));
+    	        fprintf(curr->os,";\"%s\";;",name);
+                fprintf(curr->os,"%2.1f;%2.1f;%2.1f;%2.1f;",st_sum1,st_sum2,st_sum3,st_sumA);
+                for ( partner=1 ; partner_table[partner].key!=0 ; partner+=1) {
+                    fprintf(curr->os,"%2.1f;%2.1f;%2.1f;%2.1f;",
+                        st_sum1p[partner],st_sum2p[partner],st_sum3p[partner],st_sumAp[partner]);
+                }
+    	        fprintf(curr->os,"\"%s\";",title);
+                fprintf(curr->os,"\n");
+          }
+       }
+       if ( subtasknb>0 ) {
+                char name[100];
+                char title[1000];
+                sprintf(name,"task-%d",task_n);
+                sprintf(title,"%s",task_names[task_n]);
+    	        fprintf(curr->os,"\"%s\";;;",name);
+                fprintf(curr->os,"%2.1f;%2.1f;%2.1f;%2.1f;",t_sum1,t_sum2,t_sum3,t_sumA);
+                for ( partner=1 ; partner_table[partner].key!=0 ; partner+=1) {
+                    fprintf(curr->os,"%2.1f;%2.1f;%2.1f;%2.1f;",
+                        t_sum1p[partner],t_sum2p[partner],t_sum3p[partner],t_sumAp[partner]);
+                }
+    	        fprintf(curr->os,"\"%s\";",title);
+                fprintf(curr->os,"\n");
+       }
+    }
+                char name[100];
+                char title[1000];
+                sprintf(name,"total");
+                sprintf(title,"%s","");
+    	        fprintf(curr->os,"\"%s\";;;",name);
+                fprintf(curr->os,"%2.1f;%2.1f;%2.1f;%2.1f;",an1,an2,an3,anA);
+                for ( partner=1 ; partner_table[partner].key!=0 ; partner+=1) {
+                    fprintf(curr->os,"%2.1f;%2.1f;%2.1f;%2.1f;",
+                        an1p[partner],an2p[partner],an3p[partner],anAp[partner]);
+                }
+    	        fprintf(curr->os,"\"%s\";",title);
+                fprintf(curr->os,"\n");
+    fclose(curr->os);
+    curr->os=0;
+}
 #endif
 
@@ -1030,5 +1230,5 @@
     prepare2(curr);
     prepare3(curr);
-    do_livrable_tables(40);
+    do_livrable_tables(44);
 
     curr = data_new(0,0);
@@ -1040,4 +1240,12 @@
     do_effort_par_livrable("effort-par-livrable-2.tex",4,7);
     do_effort_par_livrable("effort-par-livrable-3.tex",8,8);
+    do_effort_par_livrable_xls("tmp/effort-par-livrable.csv",1,8);
+
+    curr = data_new(0,0);
+    prepare0(curr);
+    prepare1(curr);
+    prepare2(curr);
+    prepare3(curr);
+    do_partner_by_subtask();
     return 0;
 }
