<?php

session_name("eoDACS");
session_start();
setcookie(session_name(), '', 100);
session_unset();
session_destroy();


include '../Config/config.php';

require_once dirname(__FILE__). '/../Config/eoLibrariesManagerDACS.php';

$libmanager = new eoLibrariesManagerDACS ();
			$libmanager->init_page();
			$libmanager->render_library ();
?>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>eoDACS Login</title>
		
		
		
		<style>
			#errorMessage {
				color : #ff726f;
			}
		</style>

		<script>
			window.addEventListener("load", function() 
            {
			    var loginForm = document.getElementById("LoginForm");
			    loginForm.addEventListener("submit", function() {
			         login(loginForm);
			     });
			 });

			async function login(form) {

					var un = form.username.value;
					var pw = form.password.value;
					var lang = eoDACS.CurrentLanguage;
					var params = 'username='+un+'&password='+pw+'&hexsha=1'+'&lang='+lang;

				
			    var xmlhttp = new XMLHttpRequest();

			    xmlhttp.open("POST", "<?php echo $EODACS_ROOT;?>/SubFW/database/authentification.php", true);
					xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
			
				  xmlhttp.onreadystatechange = function () {
			        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
									var response = JSON.parse(xmlhttp.responseText);
								  if(response.success)
									{
										 window.location = '../eoDACS/index.php';

/*                                        const form = document.createElement('form');
                                        form.method = 'POST';
                                        form.action = '../eoDACS/index.php';

                                        const inputLang = document.createElement('input');
                                        inputLang.type = 'hidden';
                                        inputLang.name = 'lang';
                                        inputLang.value = eoDACS.CurrentLanguage;

                                        form.appendChild(inputLang);

                                        document.body.appendChild(form);
                                        form.submit();*/
									}
									else
									{
										var errorMessage = document.getElementById("errorMessage");
                                        errorMessage.style.display = "block";
										errorMessage.innerHTML = response.message;
									}
			            }
			        }
					xmlhttp.send(params);
			    }
                
		</script>
	</head>
    
    <body onload="document.getElementById('username').focus()">
        <div id="IdcMainDiv" class="container-fluid vh-100 bg-light">
            
            <div class="h-100 d-flex flex-column m-0 p-0 w-100">

                <div class="row border-bottom m-0 p-0">
                    <nav id="idnavbar" class="navbar navbar-expand navbar-dark bg-gray1 w-100">
                        <a href="http://ximeo.be"
                        class="d-flex align-items-center col-md-3 mb-2 mb-md-0 text-dark text-decoration-none">
                            <img src="SubFW/bmp/ximeo.png" alt="XIMEO" style="width:90px;">
                        </a>

                        <div class="collapse navbar-collapse">
                            <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"></ul>

                            <div class="container">
                                <div id="IdcLanguageDiv" class="row"></div>
                            </div>
                        </div>
                    </nav>
                </div>

                <div class="flex-grow-1 d-flex flex-column bg-light">

                        <div id="IdcWelcomeDiv" class="flex-grow-1 d-flex flex-column">

                            <div class="pt-2">
                                <h1 data-langkey="eoDACS, the Dose Management System by XIMEO">
                                    eoDACS, le Système de Gestion Dosimétrique par XIMEO
                                </h1>
                            </div>

                            <div class="flex-grow-1 d-flex flex-column">

                                <div class="d-flex" style="flex:1;">
                                    
                                    <div id="IdcWelcomeCarouselDiv" class="carousel slide w-100" data-bs-ride="carousel">

                                        <div class="carousel-indicators">
                                            <button type="button" data-bs-target="#IdcWelcomeCarouselDiv" data-bs-slide-to="0" class="active"></button>
                                            <button type="button" data-bs-target="#IdcWelcomeCarouselDiv" data-bs-slide-to="1"></button>
                                            <button type="button" data-bs-target="#IdcWelcomeCarouselDiv" data-bs-slide-to="2"></button>
                                            <button type="button" data-bs-target="#IdcWelcomeCarouselDiv" data-bs-slide-to="3"></button>
                                            <button type="button" data-bs-target="#IdcWelcomeCarouselDiv" data-bs-slide-to="4"></button>
                                            <button type="button" data-bs-target="#IdcWelcomeCarouselDiv" data-bs-slide-to="5"></button>
                                        </div>

                                        <div class="carousel-inner h-100">
                                            <div class="carousel-item  active">
                                                <svg class="bd-placeholder-img" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" preserveAspectRatio="xMidYMid slice" focusable="false"><rect width="100%" height="100%" fill="#7a0058"/></svg>

                                                <div class="container">
                                                    <div class="carousel-caption text-start">
                                                        <h1>Toute modalité DICOM SR</h1>
                                                        <p>Collecter les doses de l'ensemble de vos modalités compatibles DICOM SR.</p>
                                                        <p><a class="btn btn-lg btn-primary" data-langkey="Learn more..."  href="#"></a></p>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="carousel-item">
                                                <svg class="bd-placeholder-img" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" preserveAspectRatio="xMidYMid slice" focusable="false"><rect width="100%" height="100%" fill="#7a0058"/></svg>

                                                <div class="container">
                                                    <div class="carousel-caption text-start">
                                                        <h1 data-langkey="Statistic"></h1>
                                                        <p>Un outil statistique largement paramétrable.</p>
                                                        <p><a class="btn btn-lg btn-primary" data-langkey="Learn more..." href="#"></a></p>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="carousel-item">
                                                <svg class="bd-placeholder-img" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" preserveAspectRatio="xMidYMid slice" focusable="false"><rect width="100%" height="100%" fill="#7a0058"/></svg>

                                                <div class="container">
                                                    <div class="carousel-caption text-start">
                                                        <h1>Dossier dosimétrique patient</h1>
                                                        <p>Visualisation claire et détaillée des informations dosimétriques de vos patients.</p>
                                                        <p><a class="btn btn-lg btn-primary" data-langkey="Learn more..."  href="#"></a></p>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="carousel-item">
                                                <svg class="bd-placeholder-img" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" preserveAspectRatio="xMidYMid slice" focusable="false"><rect width="100%" height="100%" fill="#7a0058"/></svg>

                                                <div class="container">
                                                    <div class="carousel-caption text-start">
                                                        <h1>Alertes</h1>
                                                        <p>Gestion efficace des alertes de dépassement des NRD.</p>
                                                        <p><a class="btn btn-lg btn-primary" data-langkey="Learn more..." href="#"></a></p>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="carousel-item">
                                                <svg class="bd-placeholder-img" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" preserveAspectRatio="xMidYMid slice" focusable="false"><rect width="100%" height="100%" fill="#7a0058"/></svg>

                                                <div class="container">
                                                    <div class="carousel-caption text-start">
                                                        <h1>Multi-sites - multi-départements</h1>
                                                        <p>Gérer vos établissements et/ou départements de manière aisée.</p>
                                                        <p><a class="btn btn-lg btn-primary" data-langkey="Learn more..." href="#"></a></p>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="carousel-item">
                                                <svg class="bd-placeholder-img" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" preserveAspectRatio="xMidYMid slice" focusable="false"><rect width="100%" height="100%" fill="#7a0058"/></svg>

                                                <div class="container">
                                                    <div class="carousel-caption text-start">
                                                        <h1>Exportation vers les autorités</h1>
                                                        <p>Effectuez aisément vos exports périodiques vers les autorités de surveillance.</p>
                                                        <p><a class="btn btn-lg btn-primary" data-langkey="Learn more..." href="#"></a></p>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <button class="carousel-control-prev" type="button" data-bs-target="#IdcWelcomeCarouselDiv" data-bs-slide="prev">
                                            <span class="carousel-control-prev-icon"></span>
                                        </button>

                                        <button class="carousel-control-next" type="button"
                                                data-bs-target="#IdcWelcomeCarouselDiv" data-bs-slide="next">
                                            <span class="carousel-control-next-icon"></span>
                                        </button>
                                    </div>
                                    
                                </div>

                                <div class="d-flex justify-content-center align-items-center" style="flex:3;">
                                    <div class="card p-0 shadow mt-n7 rounded-top" style="min-width:320px;">

                                        <h4 class="text-center mb-3 ximeo_app-color text-white rounded-top pt-2 pb-2" data-langkey="Connection to eoDACS"></h4>

                                        <form id="LoginForm" onsubmit="return false">

                                            <div id="errorMessage" style="display: none;" class="form-floating mb-3">
                                                <small class="text-danger" data-langkey="Incorrect username or password"></small>
                                            </div>                                            
                                            <div class="form-floating m-0 p-0 ms-2 me-2 mb-2">
                                                <input type="text" class="form-control rounded-4" id="username">
                                                <label for="username" data-langkey="Identifier"></label>
                                            </div>
                                            <div class="form-floating m-0 p-0 ms-2 me-2 mb-2">
                                                <input type="password" class="form-control rounded-4" id="password">
                                                <label for="password" data-langkey="Password"></label>
                                            </div>

                                            <div class="d-grid ms-3 me-3 mt-3">
                                                <button type="submit" class="ximeo_button ximeo_app-color">
                                                    Valider
                                                </button>
                                            </div>

                                        </form>
                                    </div>
                                </div>

                            </div>
                        </div>
                </div>

                <footer class="border-top py-2 bg-light">
                    <p class="mb-0">&copy; 2024 XIMEO SA. All rights reserved.</p>
                </footer>

            </div>
        </div>

    
        <script>
            window.eoDACS = window.eoDACS || {};

            eoDACS.CurrentLanguage = navigator.language.substr(0,2);

			window.addEventListener('load', function() {
                AddLanguages (navigator.language.substr(0,2));
                switchLanguage ( eoDACS.CurrentLanguage );
            });
        </script>

    </body>

</html>