<html>
    <head>
        <title>Excel Export</title>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
        <link rel="stylesheet" type="text/css" href="styles/[% $CSSTEMPLATE %]/css/screen.css" />
        <link rel="stylesheet" href="styles/installation.css" />
        <script type="text/javascript" src="includes/js/ajax.js"></script>
        <script type="text/javascript" language="javascript">
            // <!--
            var percent = 0;
            var pos = -1;
            var gesammt = [% $cnt %];

            function showStatus() {
                pos++;
                var url = "index.php?module=ticketlist&event=xmlExcelExport&pos=" + pos;
                makeHttpRequest(url, "updateProgressbar", false);
            }

            function updateProgressbar(xmldoc) {

                percent = parseInt(xmldoc);

                var bar = document.getElementById("progress");
                var val = document.getElementById("progressvalue");
                var width = 0;

                if (percent != 999) {
                    val.innerHTML = percent + "%";
                    width = Math.ceil(percent * 1.68);
                    bar.style.width = width + "px";

                    document.getElementById("Zaehler").innerHTML = Math.ceil(((gesammt / 100) * percent)) + " / " + gesammt;

                    if (percent < 100) {
                        showStatus();
                    } else {
                        document.getElementById("finalize").style.visibility = "visible";
                    }

                } else {
                    val.innerHTML = "0%";
                    bar.style.background = " url(images/progressbar3.gif) no-repeat center left";
                    bar.style.width = "168px";
                }
            }
            // -->
        </script>
        <style type="text/css">
            div#progressbar {
                background: url(images/progressbar.gif) no-repeat center left;
                height : 20px;
                width  : 170px;
            }

            div#progress {
                background: url(images/progressbar2.gif) no-repeat center left;
                height : 20px;
                width  : 0px;
            }

            #finalize {
                visibility : hidden;
            }
            body {background:#FFF !important;}
        </style>
    </head>

    <body onload="[% if $closing %]closing();[% else %]showStatus();[% /if %]">
          <form action="index.php?option=final" method="post" name="setup_db">
            <!-- ###CONTENT### begin -->
            <div id="content"  >
                <div class="wrapper  center" >
                    <table class="listview formview" cellspacing="0" border="0" style="width: 270px;">
                        <thead>
                            <tr>
                                <th colspan="6">Export</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr class="even">
                                <td colspan="1">
                                    <div id="progressbar" style="float:left;margin-right:10px;border:2px solid black;"><div id="progress"></div></div>
                                </td>
                                <td colspan="2"
                                    <div id="progressvalue" style="line-height:22px;">0 %</div>
                                </td>
                            </tr>
                            <tr class="even">
                                <td colspan="3">
                                    <div id="Zaehler"></div>
                                </td>
                            </tr>
                            <tr class="even">
                                <td colspan="3">
                                    <div id="finalize">
                                        <input type="button" class="button button-green" value="[% $user->gettext('Download .csv Datei') %]" onclick='window.location.href = "index.php?module=ticketlist&event=xmlExcelExport&finish=2";
                                                closing();'>
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </form>
    </body>
</html>
