<!doctype html>
<html lang="fr">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- CSS DE BASE -->
    <link rel="stylesheet" href="<?=base_url();?>/assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="<?=base_url();?>/assets/css/jquery-ui.min.css">
    <link rel="stylesheet" href="<?=base_url();?>/assets/css/jquery.fancybox.css">
    <link rel="stylesheet" href="<?=base_url();?>/assets/css/spectrum.css">
    <link rel="stylesheet" href="<?=base_url();?>/assets/css/style_boutons.css">
    <link rel="stylesheet" href="<?=base_url();?>/assets/css/agenda.css">
    <link rel="stylesheet" href="<?=base_url();?>/assets/css/patient.css">
    <link rel="stylesheet" href="<?=base_url();?>/assets/css/scan.css">
    <!-- FIN CSS DE BASE -->
    <title>Nouveau fichier pour <?=$patient['prenom'];?> <?=$patient['nom'];?></title>

    <style type="text/css">
	  #div_icone_parcourir{position:relative ;padding:0px;width:32px ;height:32px;overflow:hidden ;}
	  #div_icone_parcourir img{position:absolute;cursor:pointer ;top:0px;left:0px;}
	  #div_icone_parcourir input{position:absolute;background-color:transparent;border-color:transparent;cursor:pointer;font-size:1.5em;top:0px;left:0px;margin-left:-250px;-moz-opacity:0;filter:alpha(opacity:0);opacity:0;}
	  </style>
    <script language="javascript1.3">
      function verif_data(){
        var res = true ;
	      if(document.form_photo.photo.value==""){
	        alert("Choisissez un fichier � l'aide du bouton parcourir...") ;
	        document.form_photo.photo.focus() ;
	        res = false ;
	      }
	      // else{
        //
	      //   nbchar = document.form_photo.photo.value.length ;
	      //   var place = (document.form_photo.photo.value.lastIndexOf(".")+1) ;
	      //   var ext = document.form_photo.photo.value.substring(place,nbchar) ;
        //   if(ext!="jpg" && ext!="JPG" && ext!="jpeg" && ext!="JPEG" && ext!="gif" && ext!="GIF" && ext!="png" && ext!="PNG" && document.form_photo.photo.value!=""){
	      //     alert("Vous devez selectionner un fichier au format jpg ou png...") ;
	      //     document.form_photo.photo.focus() ;
	      //     res = false ;
	      //   }
 	      // }
	      if(res){
		      // parent.startLoad("div_inter_load") ;
          // parent.loadProduitPhoto() ;
		      document.form_photo.submit() ;
		    }
      }
      function majParent(){
		    parent.listeSnap() ;
      }
      function alertParent(){
        parent.afficheMessage($("#media_texte_erreur").val()) ;
        // parent.listeMedia($("#id_type").val(),$("#table_ref").val(),$("#id_ref").val()) ;
      }
    </script>
  </head>
  <?php
    if($upload_erreur) echo "<body style=\"margin:0px;padding:0px;height:100%;\" onload=\"javascript:alertParent();\">" ;
    else if($upload) echo "<body style=\"margin:0px;padding:0px;height:100%;\" onload=\"javascript:majParent();\">" ;
    else echo "<body style=\"margin:0px;padding:0px;height:100%;\">" ;
  ?>
    <form name="form_photo" action="" method="POST" enctype="multipart/form-data" style="margin:0px;padding:0px;">
	  <div id="div_icone_parcourir">
		  <img src="<?=base_url();?>/assets/images/icones/ajouter-fichier.png">
		  <input type="file" name="photo[]" id="photo" onchange="javascript:verif_data();" title="ajouter un fichier" multiple>
		</div>
    <textarea name="media_texte_erreur" id="media_texte_erreur" style="display:none;">
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
              <?=$texte_erreur;?>
              <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
          </textarea>
	</form>
    <footer>
      <input type="hidden" name="cf_url" id="cf_url" value="<?=base_url();?>">
    </footer>

    <script type="text/javascript" src="<?=base_url();?>/assets/js/jquery-3.5.1.min.js"></script>
    <script type="text/javascript" src="<?=base_url();?>/assets/js/jquery-ui.min.js"></script>
    <script type="text/javascript" src="<?=base_url();?>/assets/js/bootstrap.min.js"></script>
  </body>
</html>
