-
Notifications
You must be signed in to change notification settings - Fork 0
/
addCode.php
executable file
·162 lines (123 loc) · 4.55 KB
/
addCode.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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
include 'checkUser.php';
include 'connectionFactory.php';
$mysqli= ConnectionFactory::GetConnection();
if (!canEdit()){
header('Location: ./consult.php');
exit();
}
echo'
<!DOCTYPE html>
<html>
<head>';
include 'p_head.php';
makeHead(10);
echo'
</head>
<body>';
$id=$_GET['id'];
$curr=$_GET['cur'];
$origin=$_GET['o'];
$code = $_GET['code'];
$query = 'SELECT
Reg_RecordType.Id,
Reg_RecordType.Name,
Reg_Individual.FirstName,
Reg_Individual.LastName,
Reg_Legal.Name
FROM Reg_Person
LEFT OUTER JOIN Reg_RecordType on Reg_RecordType.Id=Reg_Person.RecordTypeId
LEFT OUTER JOIN Reg_Individual on Reg_Individual.Id=Reg_Person.Id
LEFT OUTER JOIN Reg_Legal on Reg_Legal.Id=Reg_Person.Id
WHERE Reg_Person.Id = ?';
$stmt = $mysqli->prepare($query);
$stmt->bind_param("i",$id);
$stmt->bind_result($typeId, $typeName,$FirstName,$LastName,$Name);
$stmt->execute();
$stmt->fetch();
$stmt->close();
echo '
<span class="fond"></span>
<span class="cont">
<a class="button" href="consultPerson.php?id='.$id.'&o='.$origin.'">Annuler</a><br/>
<h2> Ajouter manuelement un code pour les LEM - '.$curr.'</h2>';
if ($typeId==1){
echo '<h3> Pour l\'Entreprise '.$Name.'</h3></br>';
} else {
echo '<h3> Pour la Personne individuelle '.$FirstName.' '.$LastName.'</h3></br>';
}
if ($code!=''){
echo '<span class="widelabel missing" >Ce code n\'est pas au bon format ou existe déjà dans la base!</span> <br/>';
$query = 'SELECT PersonId
FROM Reg_Code
WHERE Code=?
';
$stmt = $mysqli->prepare($query);
$stmt->bind_param("s",$code);
$stmt->bind_result($pid);
$stmt->execute();
while ($stmt->fetch()){
echo '<a class="button" target="_blank" href="consultPerson.php?id='.$pid.'&o='.$origin.'">Consulter la fiche</a>';
}
$stmt->close();
echo '<br/><br/><br/><br/>';
}
echo '<form action="saveCode.php" method="post" >
<input type="hidden" name="cur" value="'.$curr.'" />
<input type="hidden" name="id" value="'.$id.'" />
<input type="hidden" name="o" value="'.$origin.'" />
<input type="radio" id="code_m" name="ct" value="Manual" checked="checked">Code existant</br>
<span class="half" style="width:Calc(100% - 20px)">
<span class="label" >Code à ajouter:</span>
<input type="text" name="code" value="'.$code.'" placeholder="Code"/>
</span><br/>';
$query = 'SELECT count(*) FROM Reg_Code WHERE PersonId IS NULL AND Currency=?';
$stmt = $mysqli->prepare($query);
$stmt->bind_param('s',$curr);
$stmt->bind_result($nb);
$stmt->execute();
$stmt->fetch();
$stmt->close();
if ($nb>0){
echo '<input type="radio" id="code_m" name="ct" value="Link">Code non lié</br>
<span class="half" style="width:Calc(100% - 20px)">
<span class="label" >Code:</span>';
$query = 'SELECT Reg_Code.Id , code, address FROM Reg_Code LEFT OUTER JOIN Reg_Wallet ON CodeId = Reg_Code.Id WHERE Reg_Code.PersonId IS NULL AND Currency=?';
$stmt = $mysqli->prepare($query);
$stmt->bind_param('s',$curr);
$stmt->bind_result($codeid, $code,$add);
$stmt->execute();
echo ' <select class="inputText" name="lc" >
<option value ="-1"></option>';
while ($stmt->fetch()){
echo ' <option value ="'.$codeid.'">'.$code.'('.$add.')</option>';
}
$stmt->close();
echo '</select></span><br/>';
}
if ($typeId==1) {
$newcode=md5($id.$Name.$curr);
} else {
$newcode=md5($id.$LastName.$FirstName.$curr);
}
$query = 'SELECT count(*) FROM Reg_Code WHERE Code=?';
$stmt = $mysqli->prepare($query);
$stmt->bind_param("s",$newcode);
$stmt = $mysqli->prepare($query);
$stmt->bind_result($nb2);
$stmt->execute();
$stmt->fetch();
$stmt->close();
if ($nb2==0) {
echo' <input type="radio" id="code_m" name="ct" value="Gen">Générer le code
<input type="hidden" name="gen" value="'.$newcode.'" />
</br>';
}
echo'
<input class="button" type="submit" value="Enregistrer" />
</form>';
echo '
</span>
</body>
</html>';
?>