-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajax.php
More file actions
194 lines (175 loc) · 7.11 KB
/
ajax.php
File metadata and controls
194 lines (175 loc) · 7.11 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<?php
session_start();
if (isset($_SESSION['adherent_connected']) && $_SESSION['adherent_connected']) {
require_once(dirname(__FILE__) . '/conf/config.php');
require_once(dirname(__FILE__) . '/lib/httpful.phar');
require_once(dirname(__FILE__) . '/lib/fonctions_generales.php');
if (isset($_GET['cp'])) {
$url = 'http://localhost:3000/villes';
$data = array(
"code_postal" => $_GET['cp']
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$data_string = json_encode($data);
curl_setopt(
$ch,
CURLOPT_HTTPHEADER,
array(
'Content-Type:application/json',
'Content-Length: ' . strlen($data_string)
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_URL, $url);
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
/* $url = URL_WS_ADH . 'v1.0/json/getListeVilles'; */
/* $response = \Httpful\Request::get($url . '/' . ((int)$_GET['cp']))->send(); */
echo $response;
die();
} elseif (isset($_GET['cp_partenaire'])) {
$url = URL_WS_ADH . 'v1.0/json/getListeVillesByName';
$response = \Httpful\Request::get($url . '/' . ((int)$_GET['cp_partenaire']))->send();
echo $response->body;
die();
} elseif (isset($_POST['message'])) {
$url = 'http://localhost:3000/comments';
$data = array(
"id_fiche" => trim($_POST['IdFiche']),
'message' => trim($_POST['message']),
'id_contact' => $_SESSION['adherent_infos']->IdContact
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$data_string = json_encode($data);
curl_setopt(
$ch,
CURLOPT_HTTPHEADER,
array(
'Content-Type:application/json',
'Content-Length: ' . strlen($data_string)
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_URL, $url);
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
/* $url = URL_WS_ADH . 'v1.0/json/user/insert_action'; */
/* $response = \Httpful\Request::post($url)->authenticateWith(trim($_SESSION['adherent_login']), trim($_SESSION['adherent_pass']))->sendsType(\Httpful\Mime::FORM)->body('IdFiche=' . trim($_POST['IdFiche']) . '&Message=' . trim(urlencode($_POST['message'])))->send(); */
if ($httpcode == 200) {
$resultat = notifyEDC($_POST["IdFiche"], $_POST["message"]);
echo "<div style='padding:5px;color:#060;background-color:#6F6;border-style:solid;border-width:1px;border-color:#060;'>La publication de votre Action a été effectuée avec succès et le mail a bien été envoyé</div>";
} else {
print_r($response);
$html = '<strong>Erreur WS</strong>';
}
} elseif ($_GET['_type'] == 'tel') {
$url = 'http://localhost:3000/telephone/change';
$data = array(
"IdContactTelephone" => trim($_GET['IdContactTelephone']),
"Numero" => trim($_GET['Numero']),
"TelephoneType" => trim($_GET['IdTelephoneType'])
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$data_string = json_encode($data);
curl_setopt(
$ch,
CURLOPT_HTTPHEADER,
array(
'Content-Type:application/json',
'Content-Length: ' . strlen($data_string)
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_URL, $url);
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
/* $url = URL_WS_ADH . 'v1.0/json/user/change_tel'; */
/* $response = \Httpful\Request::post($url)->authenticateWith(trim($_SESSION['adherent_login']), trim($_SESSION['adherent_pass']))->sendsType(\Httpful\Mime::FORM)->body('IdTelephoneType=' . trim($_GET['IdTelephoneType']) . '&Numero=' . trim($_GET['Numero']) . '&IdContactTelephone=' . trim($_GET['IdContactTelephone']))->send(); */
if ($httpcode == 200) {
echo '1';
} else {
print_r($response);
$html = '<strong>Erreur WS</strong>';
}
} elseif ($_GET['_type'] == 'dob') {
$url = 'http://localhost:3000/changes/dob';
$data = array(
"IdContact" => trim($_GET['IdContact']),
"DateNaissance" => trim($_GET['DateNaissance']),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$data_string = json_encode($data);
curl_setopt(
$ch,
CURLOPT_HTTPHEADER,
array(
'Content-Type:application/json',
'Content-Length: ' . strlen($data_string)
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_URL, $url);
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
/* $url = URL_WS_ADH . 'v1.0/json/user/change_date_naissance'; */
/* $response = \Httpful\Request::post($url)->authenticateWith(trim($_SESSION['adherent_login']), trim($_SESSION['adherent_pass']))->sendsType(\Httpful\Mime::FORM)->body('IdContact=' . trim($_GET['IdContact']) . '&DateNaissance=' . trim($_GET['DateNaissance']))->send(); */
if ($httpcode == 200) {
$_SESSION['adherent_infos']->DateNaissance = $_GET['DateNaissance'];
echo '1';
} else {
print_r($response);
$html = '<strong>Erreur WS</strong>';
}
} elseif ($_GET['_type'] == 'loc') {
$url = 'http://localhost:3000/changes/loc';
$data = array(
"id_investissement" => $_GET['IdInvestissement'],
"date_premiere_loc" => $_GET['datePremiereLoc']
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$data_string = json_encode($data);
curl_setopt(
$ch,
CURLOPT_HTTPHEADER,
array(
'Content-Type:application/json',
'Content-Length: ' . strlen($data_string)
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_URL, $url);
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
/* $url = URL_WS_ADH . 'v1.0/json/user/change_premiere_loc'; */
/* $response = \Httpful\Request::post($url)->authenticateWith(trim($_SESSION['adherent_login']), trim($_SESSION['adherent_pass']))->sendsType(\Httpful\Mime::FORM)->body('IdInvestissement=' . trim($_GET['IdInvestissement']) . '&datePremiereLoc=' . trim($_GET['datePremiereLoc']))->send(); */
if ($httpcode == 200) {
echo '1';
} else {
print_r($response);
$html = '<strong>Erreur WS</strong>';
}
} elseif ($_GET['_type'] == 'actions') {
$result = displayListeActions($_GET["IdFiche"]);
return ($result);
}
}