*:*************************************************************************************************************
*: Procedure: HTML_PPGM
*: 
*:
*:*************************************************************************************************************
PARAMETERS jmeno_html

#DEFINE VERZE "2015-11-08"

if empt(m.jmeno_html)
    jmeno_html = ".\report.htm"
endif
IF EMPTY(JUSTPATH(m.jmeno_html))
    jmeno_html = ".\" + m.jmeno_html
ENDIF 

fh = fcreate(m.jmeno_html)
if m.fh > 0
     DO create_html_head
     DO create_html_tables
     DO create_html_tail
endif


*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  
PROCEDURE create_html_tables

o_datum = "xyxy-xy-xy"
SCAN 
  IF LEFT(cas, 10) # o_datum
      DO create_html_table_head WITH STRTRAN(LEFT(cas, 10), "-", " - ")
      o_datum = LEFT(cas, 10)
  ENDIF 

  IF EMPTY(comment)
      fputs(m.fh, '<TR class="a">')
  ELSE
      fputs(m.fh, '<TR class="a_red">')
  ENDIF 
  fputs(m.fh, '<TD class="left"   >' + ALLTRIM(cas) + ' </TD>')
*  fputs(m.fh, '<TD class="leftt"  >' + ALLTRIM(status) + ' </TD>')

  FOR ii = 1 TO 9
    cislo = STR(m.ii,1)
    fputs(m.fh, '<TD class="' + ALLTRIM(class&cislo) + 'right">' + IIF(pocet&cislo=0, '', trans(pocet&cislo , "999" )) + ' </TD>')
  ENDFOR 

  fputs(m.fh, '<TD class="right"  >' + IIF(pocet   =0, '', trans(pocet ,   "99999")) + ' </TD>')
  fputs(m.fh, '<TD class="right"  >' + IIF(trvani  =0, '', trans(trvani,   "99.99")) + ' </TD>')
  fputs(m.fh, '<TD class="smallleft" >&nbsp; ' + ALLTRIM(comment)                    + ' </TD>')
  fputs(m.fh, '</TR>')
ENDSCAN 

DO create_html_table_tail


*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  
PROCEDURE create_html_table_head
PARAMETERS nadpis_casu

DO create_html_table_tail

fputs(m.fh, '<TABLE class="a" cellspacing="1" cellpadding="1"> <TR class="ah">' )
fputs(m.fh, '<TD class="datetime"> ' + m.nadpis_casu + ' </TD>')
*fputs(m.fh, '<TD class="status"  > Status </TD>')

FOR ii = 1 TO 8
    fputs(m.fh, '<TD class="procento"> ' + ALLTRIM(STR(hranice(ii),6,2)) + ' sec % </TD>')
ENDFOR 
fputs(m.fh, '<TD class="procento"> vice %     </TD>')

fputs(m.fh, '<TD class="center" width="40px"> Počet vzorků </TD>')
fputs(m.fh, '<TD class="center" width="40px"> Trvání sec</TD>')
fputs(m.fh, '<TD class="center"> Comment </TD></TR>')


*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  
PROCEDURE create_html_table_tail
fputs(m.fh, '</TABLE><BR>')



*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  
PROCEDURE create_html_head

*  fputs(m.fh, '<!doctype html>' )
  fputs(m.fh, '<HTML><HEAD>' )
  fputs(m.fh, '<TITLE> Report ' + ttoc(datetime(),3) + '</TITLE>' )
  fputs(m.fh, '<meta http-equiv="content-type" content="text/html; charset=windows-1250" >' )
  fputs(m.fh, '<meta http-equiv="content-language" content="cs" >' )
  fputs(m.fh, '<meta http-equiv="refresh" content="22">' )
  fputs(m.fh, '<link href="report.css" rel="stylesheet" type="text/css">' )
  fputs(m.fh, '</HEAD><BODY>' )


*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  
PROCEDURE create_html_tail
  fputs(m.fh, '<h5> generated: ' + TTOC(DATETIME(),3) +  ' &nbsp; &nbsp; &nbsp; &nbsp; v.' + VERZE + ' </h5>')
  fputs(m.fh, '</BODY></HTML>' )
  fclose(m.fh)
