-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpopup_intervention_agent_ajout.php
76 lines (73 loc) · 3.16 KB
/
popup_intervention_agent_ajout.php
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
<? include "verification.php" ?>
<?php
if (isset($_POST['Submit']) || isset($_POST['Submit_x']))
{
$idinterv = $_POST[finterv];
$queryverif= "SELECT intervention_id, utilisateur_id FROM interventions.cor_interventions_agents
WHERE intervention_id='$_POST[finterv]' AND utilisateur_id='$_POST[fagent]'";
$resultverif = pg_query($queryverif) or die( "Erreur requete" );
$verif = pg_numrows($resultverif);
if ($verif == '1')
{
header("Location: edit_intervention_modif.php?id=$idinterv&message=2");
}
else
{
$query= "INSERT INTO interventions.cor_interventions_agents (intervention_id, utilisateur_id)
VALUES('$_POST[finterv]','$_POST[fagent]')";
pg_query($query) or die( "Erreur requete" );
pg_close($dbconn);
header("Location: edit_intervention_modif.php?id=$idinterv");
}
}
?>
<? $idinterv = $_GET[id];?>
<script src="js/forms_verifications.js"></script>
<form action="popup_intervention_agent_ajout.php" method="post" name="agent" onsubmit="return VerifFormAgent();">
<table width="100%">
<tr>
<td colspan="2" class="Col1liste">
Ajouter un agent pour cette intervention
</td>
</tr>
<br/>
<tr>
<td class="Col1ajout" width="20%">Agent</td>
<td class="Col2ajout" width="80%">
<select name="fagent" >
<option value="">...</option>
<?
$sql_agent = "
SELECT a.* FROM
(
(SELECT u.id_role, u.nom_role, u.prenom_role
FROM utilisateurs.t_roles u
JOIN utilisateurs.cor_roles g ON g.id_role_utilisateur = u.id_role
JOIN utilisateurs.cor_role_menu crm ON crm.id_role = g.id_role_groupe
WHERE crm.id_menu = $id_menu)
UNION
(SELECT u.id_role, u.nom_role, u.prenom_role
FROM utilisateurs.t_roles u
JOIN utilisateurs.cor_role_menu crm ON crm.id_role = u.id_role
WHERE crm.id_menu = $id_menu
AND u.groupe = false
)
) a
ORDER BY a.nom_role";
$result = pg_query($sql_agent) or die ("Erreur requête") ;
while ($val = pg_fetch_assoc($result)){
?>
<option value="<?=$val['id_role'];?>"><?=$val['nom_role'].' '.' '.$val['prenom_role'];?></option>
<? } ?>
</select>
<input type="hidden" name="finterv" value="<? echo $idinterv; ?>">
</td>
</tr>
<br/>
<tr>
<td align="right" colspan="2">
<input name="Submit" id="Submit" value="OK" type="image" src = "images/icones/ajouter.gif" alt="Ajouter" title="Ajouter" border="0" align="absmiddle"> Ajouter l'agent</a>
</td>
</tr>
</table>
</form>