1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
<?php
require "include/param.php";
require "include/func.php";
// pour le nom !
if ($nom2 != "")
{
$nom = $nom1.$nom2;
}
else
{
$nom = $nom1;
}
// pour le prenom
if ($prenom2 != "")
{
$prenom = $prenom1.'-'.$prenom2;
}
else
{
$prenom = $prenom1;
}
// pour le numéro d'agent
$num_agt = $num;
(mysql_select_db(BASE,$lien=mysql_connect(HOST,USER,PASSWD))) || erreur(2);
if ($service=="GRH_ADM")
{
$requete="SELECT id FROM agent.agent WHERE chrono='".sprintf("%d",$num_agt)."' AND nom='$nom'";
$donnee=mysql_fetch_object(mysql_db_query(BASE,$requete));
if (empty($donnee->id))
{
$requete="SELECT max(id)+1 maxx FROM agent.agent";
($donnee=mysql_fetch_object(mysql_db_query(BASE,$requete))) || erreur(3);
$nouveau=(empty($donnee->maxx)) ? 1 : $donnee->maxx;
$requete="INSERT INTO agent.agent VALUES($nouveau,'$nom','$prenom',".sprintf("%d",$num_agt).",'1')";
(mysql_db_query(BASE,$requete)) || erreur(4);
$donnee->id=$nouveau;
}
setcookie("agent",$donnee->id);
header("location: manager/cours.php");
exit;
}
elseif ($service=="GRH_USR")
{
$requete="SELECT agentid FROM teleagent WHERE chrono='".sprintf("%d",$num_agt)."' AND nom='$nom'";
$donnee=mysql_fetch_object(mysql_db_query(BASE,$requete));
if (empty($donnee->agentid))
{
$requete="SELECT max(agentid)+1 maxx FROM teleagent";
($donnee=mysql_fetch_object(mysql_db_query(BASE,$requete))) || erreur(3);
$nouveau=(empty($donnee->maxx)) ? 1 : $donnee->maxx;
$requete="INSERT INTO teleagent VALUES($nouveau,'".sprintf("%d",$num_agt)."','1','$nom','$prenom','')";
(mysql_db_query(BASE,$requete)) || erreur(4);
$donnee->agentid=$nouveau;
}
setcookie("agent",$donnee->agentid);
header("location:agt_dem/saisie.php");
}
elseif (substr($service,0,4)=="GRH_")
{
$requete="SELECT id FROM agent.agent WHERE chrono='".sprintf("%d",$num_agt)."' AND nom='$nom'";
$donnee=mysql_fetch_object(mysql_db_query(BASE,$requete));
if (empty($donnee->id))
{
$requete="SELECT max(id)+1 maxx FROM agent.agent";
($donnee=mysql_fetch_object(mysql_db_query(BASE,$requete))) || erreur(3);
$nouveau=(empty($donnee->maxx)) ? 1 : $donnee->maxx;
$requete="INSERT INTO agent.agent VALUES($nouveau,'$nom','$prenom','".sprintf("%d",$num_agt)."','1')";
(mysql_db_query(BASE,$requete)) || erreur(4);
$donnee->id=$nouveau;
}
setcookie("agent",$donnee->id);
setcookie("type",intval(substr($service,4,2))-1);
header("location:gest/cours.php");
}
elseif (ereg(",",$param[9]))
{
$requete="SELECT id FROM agent.agent WHERE chrono='".sprintf("%d",substr($param[7],0,5))."' AND nom='$param[5]'";
$donnee=mysql_fetch_object(mysql_db_query(BASE,$requete));
if (empty($donnee->id))
{
$requete="SELECT max(id)+1 maxx FROM agent.agent";
($donnee=mysql_fetch_object(mysql_db_query(BASE,$requete))) || erreur(3);
$nouveau=(empty($donnee->maxx)) ? 1 : $donnee->maxx;
$requete="INSERT INTO agent.agent VALUES($nouveau,'$param[5]','$param[6]','".sprintf("%d",substr($param[7],0,5))."','".substr($param[7],5,1)."')";
(mysql_db_query(BASE,$requete)) || erreur(4);
$donnee->id=$nouveau;
}
setcookie("agent",$donnee->id);
$tab=explode(",",$param[8]);
$url="gest/choix.php";
for($i=0;$i<count($tab);$i++) $url.=(empty($i) ? "?" : "&")."tab[$i]=".substr($tab[$i],4,2);
header("location:$url");
}
mysql_close($lien);
?> |
Partager