Esempio n. 1
0
 public static function ajout_user(&$tab_new_user, $tab_checkbox_sem_imp, $tab_checkbox_sem_p, &$tab_new_jours_an, &$tab_new_solde, $checkbox_user_groups)
 {
     $PHP_SELF = $_SERVER['PHP_SELF'];
     $session = session_id();
     $return = '';
     $verifFalse = '';
     // si pas d'erreur de saisie :
     if (\admin\Fonctions::verif_new_param($tab_new_user, $tab_new_jours_an, $tab_new_solde, $verifFalse) == 0) {
         $return .= $tab_new_user['login'] . ' --- ' . $tab_new_user['nom'] . ' --- ' . $tab_new_user['prenom'] . ' --- ' . $tab_new_user['quotite'];
         $return .= ' --- ' . $tab_new_user['is_resp'] . ' --- ' . $tab_new_user['resp_login'] . ' --- ' . $tab_new_user['is_admin'] . ' --- ' . $tab_new_user['is_hr'] . ' --- ' . $tab_new_user['see_all'] . ' --- ' . $tab_new_user['email'] . '<br>';
         foreach ($tab_new_jours_an as $id_cong => $jours_an) {
             $return .= $tab_new_jours_an[$id_cong] . ' --- ' . $tab_new_solde[$id_cong] . '<br>';
         }
         $new_date_deb_grille = $tab_new_user['new_year'] . "-" . $tab_new_user['new_mois'] . "-" . $tab_new_user['new_jour'];
         $return .= $new_date_deb_grille . '<br>';
         /*****************************/
         /* INSERT dans conges_users  */
         if ($_SESSION['config']['how_to_connect_user'] == "dbconges") {
             $motdepasse = md5($tab_new_user['password1']);
         } else {
             $motdepasse = "none";
         }
         $sql1 = "INSERT INTO conges_users SET ";
         $sql1 = $sql1 . "u_login='******'login'] . "', ";
         $sql1 = $sql1 . "u_nom='" . addslashes($tab_new_user['nom']) . "', ";
         $sql1 = $sql1 . "u_prenom='" . addslashes($tab_new_user['prenom']) . "', ";
         $sql1 = $sql1 . "u_is_resp='" . $tab_new_user['is_resp'] . "', ";
         if ($tab_new_user['resp_login'] == 'no_resp') {
             $sql1 = $sql1 . "u_resp_login= NULL , ";
         } else {
             $sql1 = $sql1 . "u_resp_login='******'resp_login'] . "', ";
         }
         $sql1 = $sql1 . "u_is_admin='" . $tab_new_user['is_admin'] . "', ";
         $sql1 = $sql1 . "u_is_hr='" . $tab_new_user['is_hr'] . "', ";
         $sql1 = $sql1 . "u_see_all='" . $tab_new_user['see_all'] . "', ";
         $sql1 = $sql1 . "u_passwd='{$motdepasse}', ";
         $sql1 = $sql1 . "u_quotite=" . $tab_new_user['quotite'] . ",";
         $sql1 = $sql1 . " u_email='" . $tab_new_user['email'] . "' ";
         $result1 = \includes\SQL::query($sql1);
         /**********************************/
         /* INSERT dans conges_solde_user  */
         foreach ($tab_new_jours_an as $id_cong => $jours_an) {
             $sql3 = "INSERT INTO conges_solde_user (su_login, su_abs_id, su_nb_an, su_solde, su_reliquat) ";
             $sql3 = $sql3 . "VALUES ('" . $tab_new_user['login'] . "' , {$id_cong}, " . $tab_new_jours_an[$id_cong] . ", " . $tab_new_solde[$id_cong] . ", 0) ";
             $result3 = \includes\SQL::query($sql3);
         }
         /*****************************/
         /* INSERT dans conges_artt  */
         $list_colums_to_insert = "a_login";
         $list_values_to_insert = "'" . $tab_new_user['login'] . "'";
         // on parcours le tableau des jours d'absence semaine impaire
         if ($tab_checkbox_sem_imp != "") {
             while (list($key, $val) = each($tab_checkbox_sem_imp)) {
                 $list_colums_to_insert = "{$list_colums_to_insert}, {$key}";
                 $list_values_to_insert = "{$list_values_to_insert}, '{$val}'";
             }
         }
         if ($tab_checkbox_sem_p != "") {
             while (list($key, $val) = each($tab_checkbox_sem_p)) {
                 $list_colums_to_insert = "{$list_colums_to_insert}, {$key}";
                 $list_values_to_insert = "{$list_values_to_insert}, '{$val}'";
             }
         }
         $sql2 = "INSERT INTO conges_artt ({$list_colums_to_insert}, a_date_debut_grille) VALUES ({$list_values_to_insert}, '{$new_date_deb_grille}')";
         $result2 = \includes\SQL::query($sql2);
         /***********************************/
         /* ajout du user dans ses groupes  */
         $result4 = TRUE;
         if ($_SESSION['config']['gestion_groupes'] && $checkbox_user_groups != "") {
             $result4 = \admin\Fonctions::commit_modif_user_groups($tab_new_user['login'], $checkbox_user_groups);
         }
         /*****************************/
         if ($result1 && $result2 && $result3 && $result4) {
             $return .= _('form_modif_ok') . '<br><br>';
         } else {
             $return .= _('form_modif_not_ok') . '<br><br>';
         }
         $comment_log = "ajout_user : "******" / " . addslashes($tab_new_user['nom']) . " " . addslashes($tab_new_user['prenom']) . " (" . $tab_new_user['quotite'] . " %)";
         log_action(0, "", $tab_new_user['login'], $comment_log);
         /* APPEL D'UNE AUTRE PAGE */
         $return .= '<form action="' . $PHP_SELF . '?session=' . $session . '&onglet=admin-users" method="POST">';
         $return .= '<input type="submit" value="' . _('form_retour') . '">';
         $return .= '</form>';
     } else {
         $return .= $verifFalse;
     }
     return $return;
 }