0) { switch ($_FILES[core::getPost("from")]['error']) { case 1: // UPLOAD_ERR_INI_SIZE alert::recError("Le fichier dépasse la limite autorisée par le serveur (fichier php.ini) !"); break; case 2: // UPLOAD_ERR_FORM_SIZE alert::recError("Le fichier dépasse la limite autorisée dans le formulaire HTML !"); break; case 3: // UPLOAD_ERR_PARTIAL alert::recError("L'envoi du fichier a été interrompu pendant le transfert !"); break; case 4: // UPLOAD_ERR_NO_FILE alert::recError("Vous n'avez pas chargé de fichier"); break; } } elseif ($_FILES[core::getPost("from")]['type'] != "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { alert::recError("Seuls les fichiers Excel au format xlsx sont acceptés"); header("Location: /rh-upload-excel.html"); exit(); } else { if (file_exists($_FILES[core::getPost("from")]['tmp_name'])) { $data = array(); $simpleXLSX = new simpleXLSX(); $xlsx = $simpleXLSX->parse($_FILES[core::getPost("from")]['tmp_name']); $returnXlsx = $xlsx->rows(); if( $returnXlsx[0][0] != "ID LOCAL" OR $returnXlsx[0][1] != "NOM" OR $returnXlsx[0][2] != "PRENOM" OR $returnXlsx[0][3] != "SEXE" OR $returnXlsx[0][4] != "STATUT ACTIVITE" OR $returnXlsx[0][5] != "PREMIERE EMBAUCHE" OR $returnXlsx[0][6] != "SOUS-DOMAINE DU PERSONNEL - TE" OR $returnXlsx[0][7] != "LOGIN ID"){ alert::recError("Le fichier " . $_FILES[core::getPost("from")]['name'] . " n'est pas un fichier RH."); ($returnXlsx[0][0] != "ID LOCAL") ? alert::recError("La 1er colonne doit se nommer ID LOCAL") : ""; ($returnXlsx[0][1] != "NOM") ? alert::recError("La 2em colonne doit se nommer NOM") : ""; ($returnXlsx[0][2] != "PRENOM") ? alert::recError("La 3em colonne doit se nommer PRENOM") : ""; ($returnXlsx[0][3] != "SEXE") ? alert::recError("La 4em colonne doit se nommer SEXE") : ""; ($returnXlsx[0][4] != "STATUT ACTIVITE") ? alert::recError("La 5em colonne doit se nommer STATUT ACTIVITE") : ""; ($returnXlsx[0][5] != "PREMIERE EMBAUCHE") ? alert::recError("La 6em colonne doit se nommer PREMIERE EMBAUCHE") : ""; ($returnXlsx[0][6] != "SOUS-DOMAINE DU PERSONNEL - TE") ? alert::recError("La 7em colonne doit se nommer SOUS-DOMAINE DU PERSONNEL - TE") : ""; ($returnXlsx[0][7] != "LOGIN ID") ? alert::recError("La 8em colonne doit se nommer LOGIN ID") : ""; header("Location: /rh-upload-excel.html"); exit(); } $data["md5File"] = file::record($_FILES[core::getPost("from")]); if($data["md5File"] == FALSE){ header("Location: /rh-upload-excel.html"); exit(); } $data["nbSalaries"] = count($returnXlsx) - 1; $data["json"] = json_encode($returnXlsx); $data["date"] = core::getPost("date"); if(salaries::insertExcel($data) == FALSE){ alert::recError("Erreur #submit sur l'import du fichier " . $_FILES[core::getPost("from")]['name']); header("Location: /rh-upload-excel.html"); exit(); } json::create("excel"); alert::recSuccess("Le fichier " . $_FILES[core::getPost("from")]['name'] . " a été chargé avec succès"); header("Location: /rh-historique-excel.html"); exit(); } else { alert::recError("Erreur lors du chargement du fichier : " . $_FILES[core::getPost("from")]['name']); } } header("Location: /rh-upload-excel.html"); exit(); } else { header('HTTP/1.0 401 Unauthorized'); exit(); }