@@ -3,7 +3,7 @@ |
||
3 | 3 | |
4 | 4 | $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
5 | 5 | |
6 | - require $vdir.'/../vendor/autoload.php'; |
|
6 | + require $vdir.'/../vendor/autoload.php'; |
|
7 | 7 | |
8 | 8 | use Route4Me\Route4Me; |
9 | 9 | use Route4Me\Order; |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
4 | + $vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
5 | 5 | |
6 | 6 | require $vdir.'/../vendor/autoload.php'; |
7 | 7 |
@@ -3,7 +3,7 @@ |
||
3 | 3 | |
4 | 4 | $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
5 | 5 | |
6 | - require $vdir.'/../vendor/autoload.php'; |
|
6 | + require $vdir.'/../vendor/autoload.php'; |
|
7 | 7 | |
8 | 8 | use Route4Me\Route4Me; |
9 | 9 | use Route4Me\Member; |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
4 | + $vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
5 | 5 | |
6 | 6 | require $vdir.'/../vendor/autoload.php'; |
7 | 7 |
@@ -3,7 +3,7 @@ |
||
3 | 3 | |
4 | 4 | $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
5 | 5 | |
6 | - require $vdir.'/../vendor/autoload.php'; |
|
6 | + require $vdir.'/../vendor/autoload.php'; |
|
7 | 7 | |
8 | 8 | use Route4Me\Route4Me; |
9 | 9 | use Route4Me\Member; |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
4 | + $vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
5 | 5 | |
6 | 6 | require $vdir.'/../vendor/autoload.php'; |
7 | 7 |
@@ -204,6 +204,9 @@ |
||
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
207 | + /** |
|
208 | + * @param string $url |
|
209 | + */ |
|
207 | 210 | public static function makeUrlRequst($url, $options) { |
208 | 211 | $method = isset($options['method']) ? $options['method'] : 'GET'; |
209 | 212 | $query = isset($options['query']) ? |
@@ -7,37 +7,37 @@ discard block |
||
7 | 7 | |
8 | 8 | class Route4Me |
9 | 9 | { |
10 | - static public $apiKey; |
|
11 | - static public $baseUrl = 'https://api.route4me.com'; |
|
10 | + static public $apiKey; |
|
11 | + static public $baseUrl = 'https://api.route4me.com'; |
|
12 | 12 | |
13 | - public static function setApiKey($apiKey) |
|
14 | - { |
|
15 | - self::$apiKey = $apiKey; |
|
16 | - } |
|
13 | + public static function setApiKey($apiKey) |
|
14 | + { |
|
15 | + self::$apiKey = $apiKey; |
|
16 | + } |
|
17 | 17 | |
18 | - public static function getApiKey() |
|
19 | - { |
|
20 | - return self::$apiKey; |
|
21 | - } |
|
18 | + public static function getApiKey() |
|
19 | + { |
|
20 | + return self::$apiKey; |
|
21 | + } |
|
22 | 22 | |
23 | - public static function setBaseUrl($baseUrl) |
|
24 | - { |
|
25 | - self::$baseUrl = $baseUrl; |
|
26 | - } |
|
23 | + public static function setBaseUrl($baseUrl) |
|
24 | + { |
|
25 | + self::$baseUrl = $baseUrl; |
|
26 | + } |
|
27 | 27 | |
28 | - public static function getBaseUrl() |
|
29 | - { |
|
30 | - return self::$baseUrl; |
|
31 | - } |
|
28 | + public static function getBaseUrl() |
|
29 | + { |
|
30 | + return self::$baseUrl; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | public static function fileUploadRequest($options) { |
34 | 34 | $query = isset($options['query']) ? |
35 | - array_filter($options['query']) : array(); |
|
35 | + array_filter($options['query']) : array(); |
|
36 | 36 | |
37 | 37 | if (sizeof($query)==0) return null; |
38 | 38 | |
39 | 39 | $body = isset($options['body']) ? |
40 | - array_filter($options['body']) : null; |
|
40 | + array_filter($options['body']) : null; |
|
41 | 41 | |
42 | 42 | $fname = isset($body['strFilename']) ? $body['strFilename'] : ''; |
43 | 43 | if ($fname=='') return null; |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | $fp=fopen(realpath($fname),"r"); |
48 | 48 | |
49 | 49 | $url = self::$baseUrl.$options['url'] . '?' . http_build_query(array_merge( |
50 | - array( 'api_key' => self::getApiKey()), $query) |
|
51 | - ); |
|
50 | + array( 'api_key' => self::getApiKey()), $query) |
|
51 | + ); |
|
52 | 52 | |
53 | 53 | //self::simplePrint($body);die(""); |
54 | 54 | //echo "url=".$url."<br>";die(""); |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | $ch = curl_init($url); |
57 | 57 | |
58 | 58 | $curlOpts = array( |
59 | - CURLOPT_RETURNTRANSFER => true, |
|
60 | - CURLOPT_TIMEOUT => 60, |
|
61 | - CURLOPT_FOLLOWLOCATION => true, |
|
62 | - CURLOPT_SSL_VERIFYHOST => FALSE, |
|
63 | - CURLOPT_SSL_VERIFYPEER => FALSE |
|
64 | - ); |
|
59 | + CURLOPT_RETURNTRANSFER => true, |
|
60 | + CURLOPT_TIMEOUT => 60, |
|
61 | + CURLOPT_FOLLOWLOCATION => true, |
|
62 | + CURLOPT_SSL_VERIFYHOST => FALSE, |
|
63 | + CURLOPT_SSL_VERIFYPEER => FALSE |
|
64 | + ); |
|
65 | 65 | |
66 | 66 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
67 | 67 | |
@@ -77,65 +77,65 @@ discard block |
||
77 | 77 | fclose($fp); |
78 | 78 | //var_dump($result); die(''); |
79 | 79 | $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
80 | - curl_close($ch); |
|
80 | + curl_close($ch); |
|
81 | 81 | //echo "code = $code <br>"; |
82 | 82 | $json = json_decode($result, true); |
83 | 83 | //var_dump($json); die(""); |
84 | - if (200 == $code) { |
|
85 | - return $json; |
|
86 | - } elseif (isset($json['errors'])) { |
|
87 | - throw new ApiError(implode(', ', $json['errors'])); |
|
88 | - } else { |
|
89 | - throw new ApiError('Something wrong'); |
|
90 | - } |
|
84 | + if (200 == $code) { |
|
85 | + return $json; |
|
86 | + } elseif (isset($json['errors'])) { |
|
87 | + throw new ApiError(implode(', ', $json['errors'])); |
|
88 | + } else { |
|
89 | + throw new ApiError('Something wrong'); |
|
90 | + } |
|
91 | 91 | } |
92 | 92 | |
93 | - public static function makeRequst($options) { |
|
94 | - $errorHandler = new myErrorHandler(); |
|
93 | + public static function makeRequst($options) { |
|
94 | + $errorHandler = new myErrorHandler(); |
|
95 | 95 | |
96 | - $old_error_handler = set_error_handler(array( $errorHandler, "proc_error")); |
|
97 | - $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
98 | - $query = isset($options['query']) ? |
|
99 | - array_filter($options['query']) : array(); |
|
96 | + $old_error_handler = set_error_handler(array( $errorHandler, "proc_error")); |
|
97 | + $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
98 | + $query = isset($options['query']) ? |
|
99 | + array_filter($options['query']) : array(); |
|
100 | 100 | //echo "query=".$query['member_id'];die(""); |
101 | - $body = isset($options['body']) ? |
|
102 | - array_filter($options['body']) : null; |
|
101 | + $body = isset($options['body']) ? |
|
102 | + array_filter($options['body']) : null; |
|
103 | 103 | $file = isset($options['FILE']) ? $options['FILE'] : null; |
104 | - $headers = array( |
|
105 | - "User-Agent: Route4Me php-sdk" |
|
106 | - ); |
|
104 | + $headers = array( |
|
105 | + "User-Agent: Route4Me php-sdk" |
|
106 | + ); |
|
107 | 107 | |
108 | - if (isset($options['HTTPHEADER'])) { |
|
109 | - $headers[]=$options['HTTPHEADER']; |
|
110 | - } |
|
108 | + if (isset($options['HTTPHEADER'])) { |
|
109 | + $headers[]=$options['HTTPHEADER']; |
|
110 | + } |
|
111 | 111 | |
112 | 112 | if (isset($options['HTTPHEADERS'])) { |
113 | - foreach ($options['HTTPHEADERS'] As $header) $headers[]=$header; |
|
114 | - } |
|
115 | - //self::simplePrint($headers); die(""); |
|
116 | - $ch = curl_init(); |
|
117 | - $url = $options['url'] . '?' . http_build_query(array_merge( |
|
118 | - $query, array( 'api_key' => self::getApiKey()) |
|
119 | - )); |
|
113 | + foreach ($options['HTTPHEADERS'] As $header) $headers[]=$header; |
|
114 | + } |
|
115 | + //self::simplePrint($headers); die(""); |
|
116 | + $ch = curl_init(); |
|
117 | + $url = $options['url'] . '?' . http_build_query(array_merge( |
|
118 | + $query, array( 'api_key' => self::getApiKey()) |
|
119 | + )); |
|
120 | 120 | //var_dump($body); echo "<br><br>"; |
121 | 121 | //$jfile=json_encode($body); echo "<br><br>".$jfile; die("STOPPPP"); |
122 | 122 | |
123 | - //self::simplePrint($headers); die(""); |
|
123 | + //self::simplePrint($headers); die(""); |
|
124 | 124 | $baseUrl=self::getBaseUrl(); |
125 | 125 | |
126 | 126 | if (strpos($url,'move_route_destination')>0) $baseUrl='https://api.route4me.com'; |
127 | - $curlOpts = arraY( |
|
128 | - CURLOPT_URL => $baseUrl. $url, |
|
129 | - CURLOPT_RETURNTRANSFER => true, |
|
130 | - CURLOPT_TIMEOUT => 60, |
|
131 | - CURLOPT_FOLLOWLOCATION => true, |
|
132 | - CURLOPT_SSL_VERIFYHOST => FALSE, |
|
133 | - CURLOPT_SSL_VERIFYPEER => FALSE, |
|
134 | - CURLOPT_HTTPHEADER => $headers |
|
135 | - ); |
|
127 | + $curlOpts = arraY( |
|
128 | + CURLOPT_URL => $baseUrl. $url, |
|
129 | + CURLOPT_RETURNTRANSFER => true, |
|
130 | + CURLOPT_TIMEOUT => 60, |
|
131 | + CURLOPT_FOLLOWLOCATION => true, |
|
132 | + CURLOPT_SSL_VERIFYHOST => FALSE, |
|
133 | + CURLOPT_SSL_VERIFYPEER => FALSE, |
|
134 | + CURLOPT_HTTPHEADER => $headers |
|
135 | + ); |
|
136 | 136 | |
137 | 137 | //echo "url=".$baseUrl.$url."<br>";die(""); |
138 | - curl_setopt_array($ch, $curlOpts); |
|
138 | + curl_setopt_array($ch, $curlOpts); |
|
139 | 139 | |
140 | 140 | if ($file !=null) { |
141 | 141 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
@@ -144,21 +144,21 @@ discard block |
||
144 | 144 | curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file)); |
145 | 145 | } |
146 | 146 | |
147 | - switch($method) { |
|
148 | - case 'DELETE': |
|
149 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
147 | + switch($method) { |
|
148 | + case 'DELETE': |
|
149 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
150 | 150 | |
151 | 151 | if (isset($body)) { |
152 | 152 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
153 | 153 | } |
154 | - break; |
|
154 | + break; |
|
155 | 155 | case 'DELETEARRAY': |
156 | 156 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
157 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
158 | - break; |
|
159 | - case 'PUT': |
|
157 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
158 | + break; |
|
159 | + case 'PUT': |
|
160 | 160 | //$jfile=json_encode($body); echo $jfile; die(""); |
161 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
161 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
162 | 162 | if (isset($query)) { |
163 | 163 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
164 | 164 | } |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
168 | 168 | } |
169 | 169 | break; |
170 | - case 'POST': |
|
170 | + case 'POST': |
|
171 | 171 | if (isset($query)) { |
172 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
172 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | //echo "<br><br>". json_encode($body); |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | } |
179 | 179 | break; |
180 | 180 | case 'ADD': |
181 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
182 | - } |
|
181 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
182 | + } |
|
183 | 183 | |
184 | - $result = curl_exec($ch); |
|
184 | + $result = curl_exec($ch); |
|
185 | 185 | //var_dump($result); die(""); |
186 | 186 | $isxml=FALSE; |
187 | 187 | $jxml=""; |
@@ -192,63 +192,63 @@ discard block |
||
192 | 192 | $isxml = TRUE; |
193 | 193 | } |
194 | 194 | |
195 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
196 | - curl_close($ch); |
|
195 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
196 | + curl_close($ch); |
|
197 | 197 | //echo "code -> $code <br>"; |
198 | 198 | |
199 | - if (200 == $code) { |
|
200 | - if ($isxml) { |
|
201 | - $json = $jxml; |
|
202 | - } else $json = json_decode($result, true); |
|
203 | - //var_dump($json); die(""); |
|
204 | - if (isset($json['errors'])) { |
|
205 | - throw new ApiError(implode(', ', $json['errors'])); |
|
206 | - } else { |
|
207 | - return $json; |
|
208 | - } |
|
209 | - } elseif (409 == $code) { |
|
210 | - throw new ApiError('Wrong API key'); |
|
211 | - } else { |
|
212 | - throw new ApiError('Something wrong'); |
|
213 | - } |
|
214 | - } |
|
199 | + if (200 == $code) { |
|
200 | + if ($isxml) { |
|
201 | + $json = $jxml; |
|
202 | + } else $json = json_decode($result, true); |
|
203 | + //var_dump($json); die(""); |
|
204 | + if (isset($json['errors'])) { |
|
205 | + throw new ApiError(implode(', ', $json['errors'])); |
|
206 | + } else { |
|
207 | + return $json; |
|
208 | + } |
|
209 | + } elseif (409 == $code) { |
|
210 | + throw new ApiError('Wrong API key'); |
|
211 | + } else { |
|
212 | + throw new ApiError('Something wrong'); |
|
213 | + } |
|
214 | + } |
|
215 | 215 | |
216 | 216 | public static function makeUrlRequst($url, $options) { |
217 | 217 | $method = isset($options['method']) ? $options['method'] : 'GET'; |
218 | - $query = isset($options['query']) ? |
|
219 | - array_filter($options['query']) : array(); |
|
220 | - $body = isset($options['body']) ? |
|
221 | - array_filter($options['body']) : null; |
|
222 | - $ch = curl_init(); |
|
218 | + $query = isset($options['query']) ? |
|
219 | + array_filter($options['query']) : array(); |
|
220 | + $body = isset($options['body']) ? |
|
221 | + array_filter($options['body']) : null; |
|
222 | + $ch = curl_init(); |
|
223 | 223 | |
224 | 224 | $curlOpts = arraY( |
225 | - CURLOPT_URL => $url, |
|
226 | - CURLOPT_RETURNTRANSFER => true, |
|
227 | - CURLOPT_TIMEOUT => 60, |
|
228 | - CURLOPT_FOLLOWLOCATION => true, |
|
229 | - CURLOPT_SSL_VERIFYHOST => FALSE, |
|
230 | - CURLOPT_SSL_VERIFYPEER => FALSE, |
|
231 | - CURLOPT_HTTPHEADER => array( |
|
232 | - 'User-Agent' => 'Route4Me php-sdk' |
|
233 | - ) |
|
234 | - ); |
|
225 | + CURLOPT_URL => $url, |
|
226 | + CURLOPT_RETURNTRANSFER => true, |
|
227 | + CURLOPT_TIMEOUT => 60, |
|
228 | + CURLOPT_FOLLOWLOCATION => true, |
|
229 | + CURLOPT_SSL_VERIFYHOST => FALSE, |
|
230 | + CURLOPT_SSL_VERIFYPEER => FALSE, |
|
231 | + CURLOPT_HTTPHEADER => array( |
|
232 | + 'User-Agent' => 'Route4Me php-sdk' |
|
233 | + ) |
|
234 | + ); |
|
235 | 235 | |
236 | 236 | curl_setopt_array($ch, $curlOpts); |
237 | 237 | |
238 | - switch($method) { |
|
239 | - case 'DELETE': |
|
240 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
238 | + switch($method) { |
|
239 | + case 'DELETE': |
|
240 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
241 | 241 | |
242 | 242 | if (isset($body)) { |
243 | 243 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
244 | 244 | } |
245 | - break; |
|
245 | + break; |
|
246 | 246 | case 'DELETEARRAY': |
247 | 247 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
248 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
249 | - break; |
|
250 | - case 'PUT': |
|
251 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
248 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
249 | + break; |
|
250 | + case 'PUT': |
|
251 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
252 | 252 | if (isset($query)) { |
253 | 253 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
254 | 254 | } |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
258 | 258 | } |
259 | 259 | break; |
260 | - case 'POST': |
|
260 | + case 'POST': |
|
261 | 261 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
262 | 262 | if (isset($query)) { |
263 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
263 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | if (isset($body)) { |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | } |
269 | 269 | break; |
270 | 270 | case 'ADD': |
271 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
272 | - } |
|
271 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
272 | + } |
|
273 | 273 | |
274 | 274 | $result = curl_exec($ch); |
275 | 275 | |
@@ -282,21 +282,21 @@ discard block |
||
282 | 282 | $isxml = TRUE; |
283 | 283 | } |
284 | 284 | |
285 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
286 | - curl_close($ch); |
|
285 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
286 | + curl_close($ch); |
|
287 | 287 | |
288 | 288 | if ($isxml) { |
289 | 289 | $json = $jxml; |
290 | 290 | } else $json = json_decode($result, true); |
291 | 291 | |
292 | 292 | |
293 | - if (200 == $code) { |
|
294 | - return $json; |
|
295 | - } elseif (isset($json['errors'])) { |
|
296 | - throw new ApiError(implode(', ', $json['errors'])); |
|
297 | - } else { |
|
298 | - throw new ApiError('Something wrong'); |
|
299 | - } |
|
293 | + if (200 == $code) { |
|
294 | + return $json; |
|
295 | + } elseif (isset($json['errors'])) { |
|
296 | + throw new ApiError(implode(', ', $json['errors'])); |
|
297 | + } else { |
|
298 | + throw new ApiError('Something wrong'); |
|
299 | + } |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | |
45 | 45 | $rpath = realpath($fname); |
46 | 46 | |
47 | - $fp=fopen(realpath($fname),"r"); |
|
47 | + $fp = fopen(realpath($fname), "r"); |
|
48 | 48 | |
49 | - $url = self::$baseUrl.$options['url'] . '?' . http_build_query(array_merge( |
|
50 | - array( 'api_key' => self::getApiKey()), $query) |
|
49 | + $url = self::$baseUrl.$options['url'].'?'.http_build_query(array_merge( |
|
50 | + array('api_key' => self::getApiKey()), $query) |
|
51 | 51 | ); |
52 | 52 | |
53 | 53 | //self::simplePrint($body);die(""); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | //echo "code = $code <br>"; |
82 | 82 | $json = json_decode($result, true); |
83 | 83 | //var_dump($json); die(""); |
84 | - if (200 == $code) { |
|
84 | + if (200==$code) { |
|
85 | 85 | return $json; |
86 | 86 | } elseif (isset($json['errors'])) { |
87 | 87 | throw new ApiError(implode(', ', $json['errors'])); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | public static function makeRequst($options) { |
94 | 94 | $errorHandler = new myErrorHandler(); |
95 | 95 | |
96 | - $old_error_handler = set_error_handler(array( $errorHandler, "proc_error")); |
|
96 | + $old_error_handler = set_error_handler(array($errorHandler, "proc_error")); |
|
97 | 97 | $method = isset($options['method']) ? $options['method'] : 'GET'; |
98 | 98 | $query = isset($options['query']) ? |
99 | 99 | array_filter($options['query']) : array(); |
@@ -106,26 +106,26 @@ discard block |
||
106 | 106 | ); |
107 | 107 | |
108 | 108 | if (isset($options['HTTPHEADER'])) { |
109 | - $headers[]=$options['HTTPHEADER']; |
|
109 | + $headers[] = $options['HTTPHEADER']; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | if (isset($options['HTTPHEADERS'])) { |
113 | - foreach ($options['HTTPHEADERS'] As $header) $headers[]=$header; |
|
113 | + foreach ($options['HTTPHEADERS'] As $header) $headers[] = $header; |
|
114 | 114 | } |
115 | 115 | //self::simplePrint($headers); die(""); |
116 | 116 | $ch = curl_init(); |
117 | - $url = $options['url'] . '?' . http_build_query(array_merge( |
|
118 | - $query, array( 'api_key' => self::getApiKey()) |
|
117 | + $url = $options['url'].'?'.http_build_query(array_merge( |
|
118 | + $query, array('api_key' => self::getApiKey()) |
|
119 | 119 | )); |
120 | 120 | //var_dump($body); echo "<br><br>"; |
121 | 121 | //$jfile=json_encode($body); echo "<br><br>".$jfile; die("STOPPPP"); |
122 | 122 | |
123 | 123 | //self::simplePrint($headers); die(""); |
124 | - $baseUrl=self::getBaseUrl(); |
|
124 | + $baseUrl = self::getBaseUrl(); |
|
125 | 125 | |
126 | - if (strpos($url,'move_route_destination')>0) $baseUrl='https://api.route4me.com'; |
|
126 | + if (strpos($url, 'move_route_destination')>0) $baseUrl = 'https://api.route4me.com'; |
|
127 | 127 | $curlOpts = arraY( |
128 | - CURLOPT_URL => $baseUrl. $url, |
|
128 | + CURLOPT_URL => $baseUrl.$url, |
|
129 | 129 | CURLOPT_RETURNTRANSFER => true, |
130 | 130 | CURLOPT_TIMEOUT => 60, |
131 | 131 | CURLOPT_FOLLOWLOCATION => true, |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | //echo "url=".$baseUrl.$url."<br>";die(""); |
138 | 138 | curl_setopt_array($ch, $curlOpts); |
139 | 139 | |
140 | - if ($file !=null) { |
|
140 | + if ($file!=null) { |
|
141 | 141 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
142 | - $fp=fopen($file,'r'); |
|
143 | - curl_setopt($ch, CURLOPT_INFILE , $fp); |
|
142 | + $fp = fopen($file, 'r'); |
|
143 | + curl_setopt($ch, CURLOPT_INFILE, $fp); |
|
144 | 144 | curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file)); |
145 | 145 | } |
146 | 146 | |
147 | - switch($method) { |
|
147 | + switch ($method) { |
|
148 | 148 | case 'DELETE': |
149 | 149 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
150 | 150 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | break; |
170 | 170 | case 'POST': |
171 | 171 | if (isset($query)) { |
172 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
172 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | //echo "<br><br>". json_encode($body); |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | |
184 | 184 | $result = curl_exec($ch); |
185 | 185 | //var_dump($result); die(""); |
186 | - $isxml=FALSE; |
|
187 | - $jxml=""; |
|
186 | + $isxml = FALSE; |
|
187 | + $jxml = ""; |
|
188 | 188 | if (strpos($result, '<?xml')>-1) |
189 | 189 | { |
190 | 190 | $xml = simplexml_load_string($result); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | curl_close($ch); |
197 | 197 | //echo "code -> $code <br>"; |
198 | 198 | |
199 | - if (200 == $code) { |
|
199 | + if (200==$code) { |
|
200 | 200 | if ($isxml) { |
201 | 201 | $json = $jxml; |
202 | 202 | } else $json = json_decode($result, true); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | } else { |
207 | 207 | return $json; |
208 | 208 | } |
209 | - } elseif (409 == $code) { |
|
209 | + } elseif (409==$code) { |
|
210 | 210 | throw new ApiError('Wrong API key'); |
211 | 211 | } else { |
212 | 212 | throw new ApiError('Something wrong'); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | curl_setopt_array($ch, $curlOpts); |
237 | 237 | |
238 | - switch($method) { |
|
238 | + switch ($method) { |
|
239 | 239 | case 'DELETE': |
240 | 240 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
241 | 241 | |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | |
274 | 274 | $result = curl_exec($ch); |
275 | 275 | |
276 | - $isxml=FALSE; |
|
277 | - $jxml=""; |
|
276 | + $isxml = FALSE; |
|
277 | + $jxml = ""; |
|
278 | 278 | if (strpos($result, '<?xml')>-1) |
279 | 279 | { |
280 | 280 | $xml = simplexml_load_string($result); |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | } else $json = json_decode($result, true); |
291 | 291 | |
292 | 292 | |
293 | - if (200 == $code) { |
|
293 | + if (200==$code) { |
|
294 | 294 | return $json; |
295 | 295 | } elseif (isset($json['errors'])) { |
296 | 296 | throw new ApiError(implode(', ', $json['errors'])); |
@@ -34,13 +34,17 @@ discard block |
||
34 | 34 | $query = isset($options['query']) ? |
35 | 35 | array_filter($options['query']) : array(); |
36 | 36 | |
37 | - if (sizeof($query)==0) return null; |
|
37 | + if (sizeof($query)==0) { |
|
38 | + return null; |
|
39 | + } |
|
38 | 40 | |
39 | 41 | $body = isset($options['body']) ? |
40 | 42 | array_filter($options['body']) : null; |
41 | 43 | |
42 | 44 | $fname = isset($body['strFilename']) ? $body['strFilename'] : ''; |
43 | - if ($fname=='') return null; |
|
45 | + if ($fname=='') { |
|
46 | + return null; |
|
47 | + } |
|
44 | 48 | |
45 | 49 | $rpath = realpath($fname); |
46 | 50 | |
@@ -110,7 +114,9 @@ discard block |
||
110 | 114 | } |
111 | 115 | |
112 | 116 | if (isset($options['HTTPHEADERS'])) { |
113 | - foreach ($options['HTTPHEADERS'] As $header) $headers[]=$header; |
|
117 | + foreach ($options['HTTPHEADERS'] As $header) { |
|
118 | + $headers[]=$header; |
|
119 | + } |
|
114 | 120 | } |
115 | 121 | //self::simplePrint($headers); die(""); |
116 | 122 | $ch = curl_init(); |
@@ -123,7 +129,9 @@ discard block |
||
123 | 129 | //self::simplePrint($headers); die(""); |
124 | 130 | $baseUrl=self::getBaseUrl(); |
125 | 131 | |
126 | - if (strpos($url,'move_route_destination')>0) $baseUrl='https://api.route4me.com'; |
|
132 | + if (strpos($url,'move_route_destination')>0) { |
|
133 | + $baseUrl='https://api.route4me.com'; |
|
134 | + } |
|
127 | 135 | $curlOpts = arraY( |
128 | 136 | CURLOPT_URL => $baseUrl. $url, |
129 | 137 | CURLOPT_RETURNTRANSFER => true, |
@@ -199,14 +207,16 @@ discard block |
||
199 | 207 | if (200 == $code) { |
200 | 208 | if ($isxml) { |
201 | 209 | $json = $jxml; |
202 | - } else $json = json_decode($result, true); |
|
210 | + } else { |
|
211 | + $json = json_decode($result, true); |
|
212 | + } |
|
203 | 213 | //var_dump($json); die(""); |
204 | 214 | if (isset($json['errors'])) { |
205 | 215 | throw new ApiError(implode(', ', $json['errors'])); |
206 | 216 | } else { |
207 | 217 | return $json; |
208 | 218 | } |
209 | - } elseif (409 == $code) { |
|
219 | + } elseif (409 == $code) { |
|
210 | 220 | throw new ApiError('Wrong API key'); |
211 | 221 | } else { |
212 | 222 | throw new ApiError('Something wrong'); |
@@ -287,7 +297,9 @@ discard block |
||
287 | 297 | |
288 | 298 | if ($isxml) { |
289 | 299 | $json = $jxml; |
290 | - } else $json = json_decode($result, true); |
|
300 | + } else { |
|
301 | + $json = json_decode($result, true); |
|
302 | + } |
|
291 | 303 | |
292 | 304 | |
293 | 305 | if (200 == $code) { |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
3 | - require $vdir.'/../vendor/autoload.php'; |
|
3 | + require $vdir.'/../vendor/autoload.php'; |
|
4 | 4 | |
5 | 5 | use Route4Me\MyQ; |
6 | 6 |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
2 | + $vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
3 | 3 | require $vdir.'/../vendor/autoload.php'; |
4 | 4 | |
5 | 5 | use Route4Me\MyQ; |
@@ -68,60 +68,60 @@ discard block |
||
68 | 68 | |
69 | 69 | public static function fromArray(array $params) { |
70 | 70 | $member= new Member(); |
71 | - foreach($params as $key => $value) { |
|
72 | - if (property_exists($member, $key)) { |
|
73 | - $member->{$key} = $value; |
|
74 | - } |
|
71 | + foreach($params as $key => $value) { |
|
72 | + if (property_exists($member, $key)) { |
|
73 | + $member->{$key} = $value; |
|
74 | + } |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | return $member; |
78 | 78 | } |
79 | 79 | |
80 | 80 | public static function getUsers() |
81 | - { |
|
82 | - $response = Route4Me::makeRequst(array( |
|
83 | - 'url' => self::$apiUrl, |
|
84 | - 'method' => 'GET' |
|
85 | - )); |
|
81 | + { |
|
82 | + $response = Route4Me::makeRequst(array( |
|
83 | + 'url' => self::$apiUrl, |
|
84 | + 'method' => 'GET' |
|
85 | + )); |
|
86 | 86 | //var_dump($response); die(""); |
87 | 87 | return $response; |
88 | 88 | } |
89 | 89 | |
90 | 90 | public static function getUser($params) |
91 | - { |
|
92 | - $response = Route4Me::makeRequst(array( |
|
93 | - 'url' => self::$apiUrl, |
|
94 | - 'method' => 'GET', |
|
95 | - 'query' => array( |
|
96 | - 'member_id' => isset($params['member_id']) ? $params['member_id'] : null |
|
91 | + { |
|
92 | + $response = Route4Me::makeRequst(array( |
|
93 | + 'url' => self::$apiUrl, |
|
94 | + 'method' => 'GET', |
|
95 | + 'query' => array( |
|
96 | + 'member_id' => isset($params['member_id']) ? $params['member_id'] : null |
|
97 | 97 | ) |
98 | - )); |
|
98 | + )); |
|
99 | 99 | //var_dump($response); die(""); |
100 | 100 | return $response; |
101 | 101 | } |
102 | 102 | |
103 | 103 | public static function getUserLocations($param) |
104 | - { |
|
105 | - $response = Route4Me::makeRequst(array( |
|
106 | - 'url' => self::$apiUserLocations, |
|
107 | - 'method' => 'GET', |
|
108 | - 'query' => array( |
|
109 | - 'query' => $param |
|
104 | + { |
|
105 | + $response = Route4Me::makeRequst(array( |
|
106 | + 'url' => self::$apiUserLocations, |
|
107 | + 'method' => 'GET', |
|
108 | + 'query' => array( |
|
109 | + 'query' => $param |
|
110 | 110 | ) |
111 | - )); |
|
111 | + )); |
|
112 | 112 | //var_dump($response); die(""); |
113 | 113 | return $response; |
114 | 114 | } |
115 | 115 | |
116 | 116 | public static function addDeviceRecord($body) |
117 | - { |
|
118 | - $response = Route4Me::makeRequst(array( |
|
119 | - 'url' => self::$apiUrlDevice, |
|
120 | - 'method' => 'POST', |
|
121 | - 'body' => array( |
|
117 | + { |
|
118 | + $response = Route4Me::makeRequst(array( |
|
119 | + 'url' => self::$apiUrlDevice, |
|
120 | + 'method' => 'POST', |
|
121 | + 'body' => array( |
|
122 | 122 | 'device_id' => isset($body->device_id) ? $body->device_id: null, |
123 | - 'device_type' => isset($body->device_type) ? $body->device_type : null, |
|
124 | - 'format' => isset($body->format) ? $body->format : null |
|
123 | + 'device_type' => isset($body->device_type) ? $body->device_type : null, |
|
124 | + 'format' => isset($body->format) ? $body->format : null |
|
125 | 125 | ) |
126 | 126 | |
127 | 127 | )); |
@@ -129,25 +129,25 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | public static function createMember($body) |
132 | - { |
|
133 | - $response = Route4Me::makeRequst(array( |
|
134 | - 'url' => self::$apiUrl, |
|
135 | - 'method' => 'POST', |
|
136 | - 'body' => array( |
|
132 | + { |
|
133 | + $response = Route4Me::makeRequst(array( |
|
134 | + 'url' => self::$apiUrl, |
|
135 | + 'method' => 'POST', |
|
136 | + 'body' => array( |
|
137 | 137 | 'HIDE_ROUTED_ADDRESSES' => isset($body->HIDE_ROUTED_ADDRESSES) ? $body->HIDE_ROUTED_ADDRESSES: null, |
138 | - 'member_phone' => isset($body->member_phone) ? $body->member_phone : null, |
|
139 | - 'member_zipcode' => isset($body->member_zipcode) ? $body->member_zipcode : null, |
|
140 | - 'route_count' => isset($body->route_count) ? $body->route_count : null, |
|
141 | - 'member_email' => isset($body->member_email) ? $body->member_email : null, |
|
142 | - 'HIDE_VISITED_ADDRESSES' => isset($body->HIDE_VISITED_ADDRESSES) ? $body->HIDE_VISITED_ADDRESSES : null, |
|
143 | - 'READONLY_USER' => isset($body->READONLY_USER) ? $body->READONLY_USER : null, |
|
144 | - 'date_of_birth' => isset($body->date_of_birth) ? $body->date_of_birth : null, |
|
145 | - 'member_first_name' => isset($body->member_first_name) ? $body->member_first_name : null, |
|
146 | - 'member_password' => isset($body->member_password) ? $body->member_password : null, |
|
147 | - 'HIDE_NONFUTURE_ROUTES' => isset($body->HIDE_NONFUTURE_ROUTES) ? $body->HIDE_NONFUTURE_ROUTES : null, |
|
148 | - 'member_last_name' => isset($body->member_last_name) ? $body->member_last_name : null, |
|
149 | - 'SHOW_ALL_VEHICLES' => isset($body->SHOW_ALL_VEHICLES) ? $body->SHOW_ALL_VEHICLES : null, |
|
150 | - 'SHOW_ALL_DRIVERS' => isset($body->SHOW_ALL_DRIVERS) ? $body->SHOW_ALL_DRIVERS : null |
|
138 | + 'member_phone' => isset($body->member_phone) ? $body->member_phone : null, |
|
139 | + 'member_zipcode' => isset($body->member_zipcode) ? $body->member_zipcode : null, |
|
140 | + 'route_count' => isset($body->route_count) ? $body->route_count : null, |
|
141 | + 'member_email' => isset($body->member_email) ? $body->member_email : null, |
|
142 | + 'HIDE_VISITED_ADDRESSES' => isset($body->HIDE_VISITED_ADDRESSES) ? $body->HIDE_VISITED_ADDRESSES : null, |
|
143 | + 'READONLY_USER' => isset($body->READONLY_USER) ? $body->READONLY_USER : null, |
|
144 | + 'date_of_birth' => isset($body->date_of_birth) ? $body->date_of_birth : null, |
|
145 | + 'member_first_name' => isset($body->member_first_name) ? $body->member_first_name : null, |
|
146 | + 'member_password' => isset($body->member_password) ? $body->member_password : null, |
|
147 | + 'HIDE_NONFUTURE_ROUTES' => isset($body->HIDE_NONFUTURE_ROUTES) ? $body->HIDE_NONFUTURE_ROUTES : null, |
|
148 | + 'member_last_name' => isset($body->member_last_name) ? $body->member_last_name : null, |
|
149 | + 'SHOW_ALL_VEHICLES' => isset($body->SHOW_ALL_VEHICLES) ? $body->SHOW_ALL_VEHICLES : null, |
|
150 | + 'SHOW_ALL_DRIVERS' => isset($body->SHOW_ALL_DRIVERS) ? $body->SHOW_ALL_DRIVERS : null |
|
151 | 151 | ) |
152 | 152 | |
153 | 153 | )); |
@@ -155,26 +155,26 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | public static function updateMember($body) |
158 | - { |
|
159 | - $response = Route4Me::makeRequst(array( |
|
160 | - 'url' => self::$apiUrl, |
|
161 | - 'method' => 'PUT', |
|
162 | - 'body' => array( |
|
158 | + { |
|
159 | + $response = Route4Me::makeRequst(array( |
|
160 | + 'url' => self::$apiUrl, |
|
161 | + 'method' => 'PUT', |
|
162 | + 'body' => array( |
|
163 | 163 | 'member_id' => isset($body->member_id) ? $body->member_id: null, |
164 | - 'member_phone' => isset($body->member_phone) ? $body->member_phone : null, |
|
165 | - 'HIDE_ROUTED_ADDRESSES' => isset($body->HIDE_ROUTED_ADDRESSES) ? $body->HIDE_ROUTED_ADDRESSES: null, |
|
166 | - 'member_zipcode' => isset($body->member_zipcode) ? $body->member_zipcode : null, |
|
167 | - 'route_count' => isset($body->route_count) ? $body->route_count : null, |
|
168 | - 'member_email' => isset($body->member_email) ? $body->member_email : null, |
|
169 | - 'HIDE_VISITED_ADDRESSES' => isset($body->HIDE_VISITED_ADDRESSES) ? $body->HIDE_VISITED_ADDRESSES : null, |
|
170 | - 'READONLY_USER' => isset($body->READONLY_USER) ? $body->READONLY_USER : null, |
|
171 | - 'date_of_birth' => isset($body->date_of_birth) ? $body->date_of_birth : null, |
|
172 | - 'member_first_name' => isset($body->member_first_name) ? $body->member_first_name : null, |
|
173 | - 'member_password' => isset($body->member_password) ? $body->member_password : null, |
|
174 | - 'HIDE_NONFUTURE_ROUTES' => isset($body->HIDE_NONFUTURE_ROUTES) ? $body->HIDE_NONFUTURE_ROUTES : null, |
|
175 | - 'member_last_name' => isset($body->member_last_name) ? $body->member_last_name : null, |
|
176 | - 'SHOW_ALL_VEHICLES' => isset($body->SHOW_ALL_VEHICLES) ? $body->SHOW_ALL_VEHICLES : null, |
|
177 | - 'SHOW_ALL_DRIVERS' => isset($body->SHOW_ALL_DRIVERS) ? $body->SHOW_ALL_DRIVERS : null |
|
164 | + 'member_phone' => isset($body->member_phone) ? $body->member_phone : null, |
|
165 | + 'HIDE_ROUTED_ADDRESSES' => isset($body->HIDE_ROUTED_ADDRESSES) ? $body->HIDE_ROUTED_ADDRESSES: null, |
|
166 | + 'member_zipcode' => isset($body->member_zipcode) ? $body->member_zipcode : null, |
|
167 | + 'route_count' => isset($body->route_count) ? $body->route_count : null, |
|
168 | + 'member_email' => isset($body->member_email) ? $body->member_email : null, |
|
169 | + 'HIDE_VISITED_ADDRESSES' => isset($body->HIDE_VISITED_ADDRESSES) ? $body->HIDE_VISITED_ADDRESSES : null, |
|
170 | + 'READONLY_USER' => isset($body->READONLY_USER) ? $body->READONLY_USER : null, |
|
171 | + 'date_of_birth' => isset($body->date_of_birth) ? $body->date_of_birth : null, |
|
172 | + 'member_first_name' => isset($body->member_first_name) ? $body->member_first_name : null, |
|
173 | + 'member_password' => isset($body->member_password) ? $body->member_password : null, |
|
174 | + 'HIDE_NONFUTURE_ROUTES' => isset($body->HIDE_NONFUTURE_ROUTES) ? $body->HIDE_NONFUTURE_ROUTES : null, |
|
175 | + 'member_last_name' => isset($body->member_last_name) ? $body->member_last_name : null, |
|
176 | + 'SHOW_ALL_VEHICLES' => isset($body->SHOW_ALL_VEHICLES) ? $body->SHOW_ALL_VEHICLES : null, |
|
177 | + 'SHOW_ALL_DRIVERS' => isset($body->SHOW_ALL_DRIVERS) ? $body->SHOW_ALL_DRIVERS : null |
|
178 | 178 | ) |
179 | 179 | |
180 | 180 | )); |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | public static function deleteMember($body) |
185 | - { |
|
186 | - $response = Route4Me::makeRequst(array( |
|
187 | - 'url' => self::$apiUrl, |
|
188 | - 'method' => 'DELETE', |
|
189 | - 'body' => array( |
|
185 | + { |
|
186 | + $response = Route4Me::makeRequst(array( |
|
187 | + 'url' => self::$apiUrl, |
|
188 | + 'method' => 'DELETE', |
|
189 | + 'body' => array( |
|
190 | 190 | 'member_id' => isset($body->member_id) ? $body->member_id: null |
191 | 191 | ) |
192 | 192 | |
@@ -195,50 +195,50 @@ discard block |
||
195 | 195 | } |
196 | 196 | |
197 | 197 | public static function newAccountRegistration($body) |
198 | - { |
|
199 | - $response = Route4Me::makeRequst(array( |
|
200 | - 'url' => self::$apiUrlRegistr, |
|
201 | - 'method' => 'POST', |
|
202 | - 'body' => array( |
|
198 | + { |
|
199 | + $response = Route4Me::makeRequst(array( |
|
200 | + 'url' => self::$apiUrlRegistr, |
|
201 | + 'method' => 'POST', |
|
202 | + 'body' => array( |
|
203 | 203 | 'strEmail' => isset($body->strEmail) ? $body->strEmail: null, |
204 | - 'strPassword_1' => isset($body->strPassword_1) ? $body->strPassword_1 : null, |
|
205 | - 'strPassword_2' => isset($body->strPassword_2) ? $body->strPassword_2 : null, |
|
206 | - 'strFirstName' => isset($body->strFirstName) ? $body->strFirstName: null, |
|
207 | - 'strLastName' => isset($body->strLastName) ? $body->strLastName: null, |
|
208 | - 'strIndustry' => isset($body->strIndustry) ? $body->strIndustry: null, |
|
209 | - 'chkTerms' => isset($body->chkTerms) ? $body->chkTerms: null, |
|
210 | - 'plan' => isset($body->plan) ? $body->plan: null, |
|
211 | - 'strSubAccountType' => isset($body->strSubAccountType) ? $body->strSubAccountType: null, |
|
212 | - 'blDisableMarketing' => isset($body->blDisableMarketing) ? $body->blDisableMarketing: false, |
|
213 | - 'blDisableAccountActivationEmail' => isset($body->blDisableAccountActivationEmail) ? $body->blDisableAccountActivationEmail: false |
|
204 | + 'strPassword_1' => isset($body->strPassword_1) ? $body->strPassword_1 : null, |
|
205 | + 'strPassword_2' => isset($body->strPassword_2) ? $body->strPassword_2 : null, |
|
206 | + 'strFirstName' => isset($body->strFirstName) ? $body->strFirstName: null, |
|
207 | + 'strLastName' => isset($body->strLastName) ? $body->strLastName: null, |
|
208 | + 'strIndustry' => isset($body->strIndustry) ? $body->strIndustry: null, |
|
209 | + 'chkTerms' => isset($body->chkTerms) ? $body->chkTerms: null, |
|
210 | + 'plan' => isset($body->plan) ? $body->plan: null, |
|
211 | + 'strSubAccountType' => isset($body->strSubAccountType) ? $body->strSubAccountType: null, |
|
212 | + 'blDisableMarketing' => isset($body->blDisableMarketing) ? $body->blDisableMarketing: false, |
|
213 | + 'blDisableAccountActivationEmail' => isset($body->blDisableAccountActivationEmail) ? $body->blDisableAccountActivationEmail: false |
|
214 | 214 | ) |
215 | 215 | )); |
216 | 216 | return $response; |
217 | 217 | } |
218 | 218 | |
219 | 219 | public static function validateSession($params) |
220 | - { |
|
221 | - $response = Route4Me::makeRequst(array( |
|
222 | - 'url' => self::$apiUrlSessValid, |
|
223 | - 'method' => 'GET', |
|
224 | - 'query' => array( |
|
220 | + { |
|
221 | + $response = Route4Me::makeRequst(array( |
|
222 | + 'url' => self::$apiUrlSessValid, |
|
223 | + 'method' => 'GET', |
|
224 | + 'query' => array( |
|
225 | 225 | 'session_guid' => isset($params->session_guid) ? $params->session_guid: null, |
226 | - 'member_id' => isset($params->member_id) ? $params->member_id : null, |
|
227 | - 'format' => isset($params->format) ? $params->format : null |
|
226 | + 'member_id' => isset($params->member_id) ? $params->member_id : null, |
|
227 | + 'format' => isset($params->format) ? $params->format : null |
|
228 | 228 | ) |
229 | 229 | )); |
230 | 230 | return $response; |
231 | 231 | } |
232 | 232 | |
233 | 233 | public static function memberAuthentication($body) |
234 | - { |
|
235 | - $response = Route4Me::makeRequst(array( |
|
236 | - 'url' => self::$apiUrlAuthen, |
|
237 | - 'method' => 'POST', |
|
238 | - 'body' => array( |
|
234 | + { |
|
235 | + $response = Route4Me::makeRequst(array( |
|
236 | + 'url' => self::$apiUrlAuthen, |
|
237 | + 'method' => 'POST', |
|
238 | + 'body' => array( |
|
239 | 239 | 'strEmail' => isset($body->strEmail) ? $body->strEmail: null, |
240 | - 'strPassword' => isset($body->strPassword) ? $body->strPassword : null, |
|
241 | - 'format' => isset($body->format) ? $body->format : null |
|
240 | + 'strPassword' => isset($body->strPassword) ? $body->strPassword : null, |
|
241 | + 'format' => isset($body->format) ? $body->format : null |
|
242 | 242 | ) |
243 | 243 | |
244 | 244 | )); |
@@ -246,18 +246,18 @@ discard block |
||
246 | 246 | } |
247 | 247 | |
248 | 248 | public static function webinarRegistration($body) |
249 | - { |
|
250 | - $response = Route4Me::makeRequst(array( |
|
251 | - 'url' => self::$apiUrlWebinar, |
|
252 | - 'method' => 'POST', |
|
253 | - 'body' => array( |
|
249 | + { |
|
250 | + $response = Route4Me::makeRequst(array( |
|
251 | + 'url' => self::$apiUrlWebinar, |
|
252 | + 'method' => 'POST', |
|
253 | + 'body' => array( |
|
254 | 254 | 'email_address' => isset($body->email_address) ? $body->email_address: null, |
255 | - 'first_name' => isset($body->first_name) ? $body->first_name : null, |
|
256 | - 'last_name' => isset($body->last_name) ? $body->last_name : null, |
|
257 | - 'phone_number' => isset($body->phone_number) ? $body->phone_number : null, |
|
258 | - 'phone_number' => isset($body->phone_number) ? $body->phone_number : null, |
|
259 | - 'member_id' => isset($body->member_id) ? $body->member_id : null, |
|
260 | - 'webiinar_date' => isset($body->webiinar_date) ? $body->webiinar_date : null, |
|
255 | + 'first_name' => isset($body->first_name) ? $body->first_name : null, |
|
256 | + 'last_name' => isset($body->last_name) ? $body->last_name : null, |
|
257 | + 'phone_number' => isset($body->phone_number) ? $body->phone_number : null, |
|
258 | + 'phone_number' => isset($body->phone_number) ? $body->phone_number : null, |
|
259 | + 'member_id' => isset($body->member_id) ? $body->member_id : null, |
|
260 | + 'webiinar_date' => isset($body->webiinar_date) ? $body->webiinar_date : null, |
|
261 | 261 | ) |
262 | 262 | |
263 | 263 | )); |
@@ -265,19 +265,19 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | public static function purchaseUserLicense($body) |
268 | - { |
|
269 | - $response = Route4Me::makeRequst(array( |
|
270 | - 'url' => self::$apiUrlLicense, |
|
271 | - 'method' => 'POST', |
|
272 | - 'body' => array( |
|
268 | + { |
|
269 | + $response = Route4Me::makeRequst(array( |
|
270 | + 'url' => self::$apiUrlLicense, |
|
271 | + 'method' => 'POST', |
|
272 | + 'body' => array( |
|
273 | 273 | 'member_id' => isset($body->member_id) ? $body->member_id: null, |
274 | - 'session_guid' => isset($body->session_guid) ? $body->session_guid : null, |
|
275 | - 'device_id' => isset($body->device_id) ? $body->device_id : null, |
|
276 | - 'device_type' => isset($body->device_type) ? $body->device_type : null, |
|
277 | - 'subscription_name' => isset($body->subscription_name) ? $body->subscription_name : null, |
|
278 | - 'token' => isset($body->token) ? $body->token : null, |
|
279 | - 'payload' => isset($body->payload) ? $body->payload : null, |
|
280 | - 'format' => isset($body->format) ? $body->format : null, |
|
274 | + 'session_guid' => isset($body->session_guid) ? $body->session_guid : null, |
|
275 | + 'device_id' => isset($body->device_id) ? $body->device_id : null, |
|
276 | + 'device_type' => isset($body->device_type) ? $body->device_type : null, |
|
277 | + 'subscription_name' => isset($body->subscription_name) ? $body->subscription_name : null, |
|
278 | + 'token' => isset($body->token) ? $body->token : null, |
|
279 | + 'payload' => isset($body->payload) ? $body->payload : null, |
|
280 | + 'format' => isset($body->format) ? $body->format : null, |
|
281 | 281 | ) |
282 | 282 | |
283 | 283 | )); |
@@ -285,24 +285,24 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | public static function newMemberConfigKey($body) |
288 | - { |
|
289 | - $response = Route4Me::makeRequst(array( |
|
290 | - 'url' => self::$apiMemberConfig, |
|
291 | - 'method' => 'POST', |
|
292 | - 'body' => array( |
|
288 | + { |
|
289 | + $response = Route4Me::makeRequst(array( |
|
290 | + 'url' => self::$apiMemberConfig, |
|
291 | + 'method' => 'POST', |
|
292 | + 'body' => array( |
|
293 | 293 | 'config_key' => isset($body->config_key) ? $body->config_key: null, |
294 | - 'config_value' => isset($body->config_value) ? $body->config_value : null |
|
294 | + 'config_value' => isset($body->config_value) ? $body->config_value : null |
|
295 | 295 | ) |
296 | 296 | )); |
297 | 297 | return $response; |
298 | 298 | } |
299 | 299 | |
300 | 300 | public static function removeMemberConfigKey($body) |
301 | - { |
|
302 | - $response = Route4Me::makeRequst(array( |
|
303 | - 'url' => self::$apiMemberConfig, |
|
304 | - 'method' => 'DELETE', |
|
305 | - 'body' => array( |
|
301 | + { |
|
302 | + $response = Route4Me::makeRequst(array( |
|
303 | + 'url' => self::$apiMemberConfig, |
|
304 | + 'method' => 'DELETE', |
|
305 | + 'body' => array( |
|
306 | 306 | 'config_key' => isset($body->config_key) ? $body->config_key: null |
307 | 307 | ) |
308 | 308 | )); |
@@ -310,11 +310,11 @@ discard block |
||
310 | 310 | } |
311 | 311 | |
312 | 312 | public static function getMemberConfigData($body) |
313 | - { |
|
314 | - $response = Route4Me::makeRequst(array( |
|
315 | - 'url' => self::$apiMemberConfig, |
|
316 | - 'method' => 'GET', |
|
317 | - 'query' => array( |
|
313 | + { |
|
314 | + $response = Route4Me::makeRequst(array( |
|
315 | + 'url' => self::$apiMemberConfig, |
|
316 | + 'method' => 'GET', |
|
317 | + 'query' => array( |
|
318 | 318 | 'config_key' => isset($body->config_key) ? $body->config_key: null |
319 | 319 | ) |
320 | 320 | )); |
@@ -322,13 +322,13 @@ discard block |
||
322 | 322 | } |
323 | 323 | |
324 | 324 | public static function updateMemberConfigKey($body) |
325 | - { |
|
326 | - $response = Route4Me::makeRequst(array( |
|
327 | - 'url' => self::$apiMemberConfig, |
|
328 | - 'method' => 'PUT', |
|
329 | - 'body' => array( |
|
325 | + { |
|
326 | + $response = Route4Me::makeRequst(array( |
|
327 | + 'url' => self::$apiMemberConfig, |
|
328 | + 'method' => 'PUT', |
|
329 | + 'body' => array( |
|
330 | 330 | 'config_key' => isset($body->config_key) ? $body->config_key: null, |
331 | - 'config_value' => isset($body->config_value) ? $body->config_value : null |
|
331 | + 'config_value' => isset($body->config_value) ? $body->config_value : null |
|
332 | 332 | ) |
333 | 333 | )); |
334 | 334 | return $response; |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | public $config_key; |
65 | 65 | public $config_value; |
66 | 66 | |
67 | - public function __construct () { } |
|
67 | + public function __construct() { } |
|
68 | 68 | |
69 | 69 | public static function fromArray(array $params) { |
70 | - $member= new Member(); |
|
71 | - foreach($params as $key => $value) { |
|
70 | + $member = new Member(); |
|
71 | + foreach ($params as $key => $value) { |
|
72 | 72 | if (property_exists($member, $key)) { |
73 | 73 | $member->{$key} = $value; |
74 | 74 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | 'url' => self::$apiUrlDevice, |
120 | 120 | 'method' => 'POST', |
121 | 121 | 'body' => array( |
122 | - 'device_id' => isset($body->device_id) ? $body->device_id: null, |
|
122 | + 'device_id' => isset($body->device_id) ? $body->device_id : null, |
|
123 | 123 | 'device_type' => isset($body->device_type) ? $body->device_type : null, |
124 | 124 | 'format' => isset($body->format) ? $body->format : null |
125 | 125 | ) |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | 'url' => self::$apiUrl, |
135 | 135 | 'method' => 'POST', |
136 | 136 | 'body' => array( |
137 | - 'HIDE_ROUTED_ADDRESSES' => isset($body->HIDE_ROUTED_ADDRESSES) ? $body->HIDE_ROUTED_ADDRESSES: null, |
|
137 | + 'HIDE_ROUTED_ADDRESSES' => isset($body->HIDE_ROUTED_ADDRESSES) ? $body->HIDE_ROUTED_ADDRESSES : null, |
|
138 | 138 | 'member_phone' => isset($body->member_phone) ? $body->member_phone : null, |
139 | 139 | 'member_zipcode' => isset($body->member_zipcode) ? $body->member_zipcode : null, |
140 | 140 | 'route_count' => isset($body->route_count) ? $body->route_count : null, |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | 'url' => self::$apiUrl, |
161 | 161 | 'method' => 'PUT', |
162 | 162 | 'body' => array( |
163 | - 'member_id' => isset($body->member_id) ? $body->member_id: null, |
|
163 | + 'member_id' => isset($body->member_id) ? $body->member_id : null, |
|
164 | 164 | 'member_phone' => isset($body->member_phone) ? $body->member_phone : null, |
165 | - 'HIDE_ROUTED_ADDRESSES' => isset($body->HIDE_ROUTED_ADDRESSES) ? $body->HIDE_ROUTED_ADDRESSES: null, |
|
165 | + 'HIDE_ROUTED_ADDRESSES' => isset($body->HIDE_ROUTED_ADDRESSES) ? $body->HIDE_ROUTED_ADDRESSES : null, |
|
166 | 166 | 'member_zipcode' => isset($body->member_zipcode) ? $body->member_zipcode : null, |
167 | 167 | 'route_count' => isset($body->route_count) ? $body->route_count : null, |
168 | 168 | 'member_email' => isset($body->member_email) ? $body->member_email : null, |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | 'url' => self::$apiUrl, |
188 | 188 | 'method' => 'DELETE', |
189 | 189 | 'body' => array( |
190 | - 'member_id' => isset($body->member_id) ? $body->member_id: null |
|
190 | + 'member_id' => isset($body->member_id) ? $body->member_id : null |
|
191 | 191 | ) |
192 | 192 | |
193 | 193 | )); |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | 'url' => self::$apiUrlRegistr, |
201 | 201 | 'method' => 'POST', |
202 | 202 | 'body' => array( |
203 | - 'strEmail' => isset($body->strEmail) ? $body->strEmail: null, |
|
203 | + 'strEmail' => isset($body->strEmail) ? $body->strEmail : null, |
|
204 | 204 | 'strPassword_1' => isset($body->strPassword_1) ? $body->strPassword_1 : null, |
205 | 205 | 'strPassword_2' => isset($body->strPassword_2) ? $body->strPassword_2 : null, |
206 | - 'strFirstName' => isset($body->strFirstName) ? $body->strFirstName: null, |
|
207 | - 'strLastName' => isset($body->strLastName) ? $body->strLastName: null, |
|
208 | - 'strIndustry' => isset($body->strIndustry) ? $body->strIndustry: null, |
|
209 | - 'chkTerms' => isset($body->chkTerms) ? $body->chkTerms: null, |
|
210 | - 'plan' => isset($body->plan) ? $body->plan: null, |
|
211 | - 'strSubAccountType' => isset($body->strSubAccountType) ? $body->strSubAccountType: null, |
|
212 | - 'blDisableMarketing' => isset($body->blDisableMarketing) ? $body->blDisableMarketing: false, |
|
213 | - 'blDisableAccountActivationEmail' => isset($body->blDisableAccountActivationEmail) ? $body->blDisableAccountActivationEmail: false |
|
206 | + 'strFirstName' => isset($body->strFirstName) ? $body->strFirstName : null, |
|
207 | + 'strLastName' => isset($body->strLastName) ? $body->strLastName : null, |
|
208 | + 'strIndustry' => isset($body->strIndustry) ? $body->strIndustry : null, |
|
209 | + 'chkTerms' => isset($body->chkTerms) ? $body->chkTerms : null, |
|
210 | + 'plan' => isset($body->plan) ? $body->plan : null, |
|
211 | + 'strSubAccountType' => isset($body->strSubAccountType) ? $body->strSubAccountType : null, |
|
212 | + 'blDisableMarketing' => isset($body->blDisableMarketing) ? $body->blDisableMarketing : false, |
|
213 | + 'blDisableAccountActivationEmail' => isset($body->blDisableAccountActivationEmail) ? $body->blDisableAccountActivationEmail : false |
|
214 | 214 | ) |
215 | 215 | )); |
216 | 216 | return $response; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | 'url' => self::$apiUrlSessValid, |
223 | 223 | 'method' => 'GET', |
224 | 224 | 'query' => array( |
225 | - 'session_guid' => isset($params->session_guid) ? $params->session_guid: null, |
|
225 | + 'session_guid' => isset($params->session_guid) ? $params->session_guid : null, |
|
226 | 226 | 'member_id' => isset($params->member_id) ? $params->member_id : null, |
227 | 227 | 'format' => isset($params->format) ? $params->format : null |
228 | 228 | ) |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | 'url' => self::$apiUrlAuthen, |
237 | 237 | 'method' => 'POST', |
238 | 238 | 'body' => array( |
239 | - 'strEmail' => isset($body->strEmail) ? $body->strEmail: null, |
|
239 | + 'strEmail' => isset($body->strEmail) ? $body->strEmail : null, |
|
240 | 240 | 'strPassword' => isset($body->strPassword) ? $body->strPassword : null, |
241 | 241 | 'format' => isset($body->format) ? $body->format : null |
242 | 242 | ) |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | 'url' => self::$apiUrlWebinar, |
252 | 252 | 'method' => 'POST', |
253 | 253 | 'body' => array( |
254 | - 'email_address' => isset($body->email_address) ? $body->email_address: null, |
|
254 | + 'email_address' => isset($body->email_address) ? $body->email_address : null, |
|
255 | 255 | 'first_name' => isset($body->first_name) ? $body->first_name : null, |
256 | 256 | 'last_name' => isset($body->last_name) ? $body->last_name : null, |
257 | 257 | 'phone_number' => isset($body->phone_number) ? $body->phone_number : null, |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | 'url' => self::$apiUrlLicense, |
271 | 271 | 'method' => 'POST', |
272 | 272 | 'body' => array( |
273 | - 'member_id' => isset($body->member_id) ? $body->member_id: null, |
|
273 | + 'member_id' => isset($body->member_id) ? $body->member_id : null, |
|
274 | 274 | 'session_guid' => isset($body->session_guid) ? $body->session_guid : null, |
275 | 275 | 'device_id' => isset($body->device_id) ? $body->device_id : null, |
276 | 276 | 'device_type' => isset($body->device_type) ? $body->device_type : null, |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | 'url' => self::$apiMemberConfig, |
291 | 291 | 'method' => 'POST', |
292 | 292 | 'body' => array( |
293 | - 'config_key' => isset($body->config_key) ? $body->config_key: null, |
|
293 | + 'config_key' => isset($body->config_key) ? $body->config_key : null, |
|
294 | 294 | 'config_value' => isset($body->config_value) ? $body->config_value : null |
295 | 295 | ) |
296 | 296 | )); |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | 'url' => self::$apiMemberConfig, |
304 | 304 | 'method' => 'DELETE', |
305 | 305 | 'body' => array( |
306 | - 'config_key' => isset($body->config_key) ? $body->config_key: null |
|
306 | + 'config_key' => isset($body->config_key) ? $body->config_key : null |
|
307 | 307 | ) |
308 | 308 | )); |
309 | 309 | return $response; |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | 'url' => self::$apiMemberConfig, |
316 | 316 | 'method' => 'GET', |
317 | 317 | 'query' => array( |
318 | - 'config_key' => isset($body->config_key) ? $body->config_key: null |
|
318 | + 'config_key' => isset($body->config_key) ? $body->config_key : null |
|
319 | 319 | ) |
320 | 320 | )); |
321 | 321 | return $response; |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | 'url' => self::$apiMemberConfig, |
328 | 328 | 'method' => 'PUT', |
329 | 329 | 'body' => array( |
330 | - 'config_key' => isset($body->config_key) ? $body->config_key: null, |
|
330 | + 'config_key' => isset($body->config_key) ? $body->config_key : null, |
|
331 | 331 | 'config_value' => isset($body->config_value) ? $body->config_value : null |
332 | 332 | ) |
333 | 333 | )); |
@@ -6,7 +6,6 @@ |
||
6 | 6 | require $vdir.'/../vendor/autoload.php'; |
7 | 7 | |
8 | 8 | use Route4Me\OptimizationProblem; |
9 | -use Route4Me\Route; |
|
10 | 9 | use Route4Me\Route4Me; |
11 | 10 | |
12 | 11 | /* The example demonstrates process of creating a Hybrid Optimization using scheduling addresses and orders. |
@@ -43,21 +43,21 @@ discard block |
||
43 | 43 | $locationsFieldsMapping['monthly_nth_wwhat']=17; |
44 | 44 | |
45 | 45 | if (($handle = fopen("$source_file", "r")) !== FALSE) { |
46 | - $oAbook = new AddressBookLocation(); |
|
46 | + $oAbook = new AddressBookLocation(); |
|
47 | 47 | |
48 | - $results=$oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping); //Temporarry |
|
48 | + $results=$oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping); //Temporarry |
|
49 | 49 | |
50 | - echo "Errors: <br><br>"; |
|
51 | - foreach ($results['fail'] as $evalue) { |
|
52 | - echo $evalue."<br>"; |
|
53 | - } |
|
50 | + echo "Errors: <br><br>"; |
|
51 | + foreach ($results['fail'] as $evalue) { |
|
52 | + echo $evalue."<br>"; |
|
53 | + } |
|
54 | 54 | |
55 | - echo "Successes: <br><br>"; |
|
56 | - foreach ($results['success'] as $svalue) { |
|
57 | - echo $svalue."<br>"; |
|
58 | - } |
|
55 | + echo "Successes: <br><br>"; |
|
56 | + foreach ($results['success'] as $svalue) { |
|
57 | + echo $svalue."<br>"; |
|
58 | + } |
|
59 | 59 | |
60 | - } |
|
60 | + } |
|
61 | 61 | |
62 | 62 | /* Add orders with schedules from a CSV file */ |
63 | 63 | |
@@ -76,91 +76,91 @@ discard block |
||
76 | 76 | $ordersFieldsMapping['day_scheduled_for_YYMMDD']=8; |
77 | 77 | |
78 | 78 | if (($handle = fopen("$orders_file", "r")) !== FALSE) { |
79 | - $order = new Order(); |
|
80 | - $results=$order->addOrdersFromCsvFile($handle, $ordersFieldsMapping); |
|
79 | + $order = new Order(); |
|
80 | + $results=$order->addOrdersFromCsvFile($handle, $ordersFieldsMapping); |
|
81 | 81 | |
82 | - echo "Errors: <br><br>"; |
|
83 | - foreach ($results['fail'] as $evalue) { |
|
84 | - echo $evalue."<br>"; |
|
85 | - } |
|
82 | + echo "Errors: <br><br>"; |
|
83 | + foreach ($results['fail'] as $evalue) { |
|
84 | + echo $evalue."<br>"; |
|
85 | + } |
|
86 | 86 | |
87 | - echo "Successes: <br><br>"; |
|
88 | - foreach ($results['success'] as $svalue) { |
|
89 | - echo $svalue."<br>"; |
|
90 | - } |
|
87 | + echo "Successes: <br><br>"; |
|
88 | + foreach ($results['success'] as $svalue) { |
|
89 | + echo $svalue."<br>"; |
|
90 | + } |
|
91 | 91 | |
92 | - } |
|
92 | + } |
|
93 | 93 | |
94 | 94 | /* Get Hybrid Optimization */ |
95 | 95 | |
96 | - $ep = time()+604800; |
|
97 | - $sched_date = date("Y-m-d", $ep); |
|
96 | + $ep = time()+604800; |
|
97 | + $sched_date = date("Y-m-d", $ep); |
|
98 | 98 | |
99 | - $hybridParams = array( |
|
100 | - "target_date_string" => $sched_date, |
|
101 | - "timezone_offset_minutes" => 480 |
|
102 | - ); |
|
99 | + $hybridParams = array( |
|
100 | + "target_date_string" => $sched_date, |
|
101 | + "timezone_offset_minutes" => 480 |
|
102 | + ); |
|
103 | 103 | |
104 | - $optimization = new OptimizationProblem(); |
|
105 | - $hybridOptimization = $optimization->getHybridOptimization($hybridParams); |
|
104 | + $optimization = new OptimizationProblem(); |
|
105 | + $hybridOptimization = $optimization->getHybridOptimization($hybridParams); |
|
106 | 106 | |
107 | - if ($hybridOptimization!=null) { |
|
107 | + if ($hybridOptimization!=null) { |
|
108 | 108 | |
109 | - if (isset($hybridOptimization['optimization_problem_id'])) { |
|
110 | - $optid = $hybridOptimization['optimization_problem_id']; |
|
109 | + if (isset($hybridOptimization['optimization_problem_id'])) { |
|
110 | + $optid = $hybridOptimization['optimization_problem_id']; |
|
111 | 111 | |
112 | - echo "Hibrid optimization with optimization_problem_id=$optid <br><br>"; |
|
112 | + echo "Hibrid optimization with optimization_problem_id=$optid <br><br>"; |
|
113 | 113 | |
114 | - /* Add depots to the Hybrid Optimization */ |
|
115 | - $depotfile = "depots.csv"; |
|
114 | + /* Add depots to the Hybrid Optimization */ |
|
115 | + $depotfile = "depots.csv"; |
|
116 | 116 | |
117 | - if (($handle = fopen("$depotfile", "r")) !== FALSE) { |
|
117 | + if (($handle = fopen("$depotfile", "r")) !== FALSE) { |
|
118 | 118 | |
119 | - $columns = fgetcsv($handle, $max_line_length, $delemietr); |
|
119 | + $columns = fgetcsv($handle, $max_line_length, $delemietr); |
|
120 | 120 | |
121 | - if (!$columns) { |
|
122 | - $error['message'] = 'Empty'; |
|
123 | - return ($error); |
|
124 | - } |
|
121 | + if (!$columns) { |
|
122 | + $error['message'] = 'Empty'; |
|
123 | + return ($error); |
|
124 | + } |
|
125 | 125 | |
126 | - $depotsParams = array( |
|
127 | - 'optimization_problem_id' => $optid, |
|
128 | - 'delete_old_depots' => true, |
|
129 | - ); |
|
126 | + $depotsParams = array( |
|
127 | + 'optimization_problem_id' => $optid, |
|
128 | + 'delete_old_depots' => true, |
|
129 | + ); |
|
130 | 130 | |
131 | - $iRow=1; |
|
132 | - $depotAddresses = array(); |
|
131 | + $iRow=1; |
|
132 | + $depotAddresses = array(); |
|
133 | 133 | |
134 | - while (($rows = fgetcsv($handle, $max_line_length, $delemietr)) !== false) { |
|
135 | - if ($rows[0] && $rows[1] && $rows[3] && array(null) !== $rows) { |
|
136 | - $depotAddress['lat']= $rows[0]; |
|
137 | - $depotAddress['lng']= $rows[1]; |
|
138 | - $depotAddress['address']= $rows[3]; |
|
139 | - array_push($depotAddresses,$depotAddress); |
|
140 | - } |
|
141 | - } |
|
134 | + while (($rows = fgetcsv($handle, $max_line_length, $delemietr)) !== false) { |
|
135 | + if ($rows[0] && $rows[1] && $rows[3] && array(null) !== $rows) { |
|
136 | + $depotAddress['lat']= $rows[0]; |
|
137 | + $depotAddress['lng']= $rows[1]; |
|
138 | + $depotAddress['address']= $rows[3]; |
|
139 | + array_push($depotAddresses,$depotAddress); |
|
140 | + } |
|
141 | + } |
|
142 | 142 | |
143 | - $depotsParams['new_depots'] = $depotAddresses; |
|
143 | + $depotsParams['new_depots'] = $depotAddresses; |
|
144 | 144 | |
145 | - $optProblem = new OptimizationProblem(); |
|
145 | + $optProblem = new OptimizationProblem(); |
|
146 | 146 | |
147 | - $resultDepots = $optProblem->addDepotsToHybrid($depotsParams); |
|
147 | + $resultDepots = $optProblem->addDepotsToHybrid($depotsParams); |
|
148 | 148 | |
149 | - var_dump($resultDepots); |
|
149 | + var_dump($resultDepots); |
|
150 | 150 | |
151 | - /* Reoptimize hybrid optimization */ |
|
151 | + /* Reoptimize hybrid optimization */ |
|
152 | 152 | |
153 | - if ($resultDepots!=null) { |
|
154 | - $problemParams = array( |
|
155 | - 'optimization_problem_id' => $optid |
|
156 | - ); |
|
157 | - $problem = OptimizationProblem::reoptimize($problemParams); |
|
153 | + if ($resultDepots!=null) { |
|
154 | + $problemParams = array( |
|
155 | + 'optimization_problem_id' => $optid |
|
156 | + ); |
|
157 | + $problem = OptimizationProblem::reoptimize($problemParams); |
|
158 | 158 | |
159 | - Route4Me::simplePrint($problem); |
|
160 | - } |
|
161 | - } |
|
159 | + Route4Me::simplePrint($problem); |
|
160 | + } |
|
161 | + } |
|
162 | 162 | |
163 | - } |
|
163 | + } |
|
164 | 164 | |
165 | - } |
|
165 | + } |
|
166 | 166 | ?> |
167 | 167 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | -$vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
4 | +$vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
5 | 5 | |
6 | 6 | require $vdir.'/../vendor/autoload.php'; |
7 | 7 | |
@@ -17,35 +17,35 @@ discard block |
||
17 | 17 | |
18 | 18 | Route4Me::setApiKey('bd48828717021141485a701453273458'); |
19 | 19 | |
20 | -$source_file="addresses_1000.csv"; |
|
20 | +$source_file = "addresses_1000.csv"; |
|
21 | 21 | $max_line_length = 512; |
22 | -$delemietr=','; |
|
22 | +$delemietr = ','; |
|
23 | 23 | |
24 | 24 | |
25 | 25 | /* Add Address Book Locations with schedules from a CSV file */ |
26 | 26 | |
27 | 27 | /* Mapping of a CSV file with the address book locations - which of the CSV table column is corresponding to which of the Address Book's field*/ |
28 | -$locationsFieldsMapping['cached_lat']=0; |
|
29 | -$locationsFieldsMapping['cached_lng']=1; |
|
30 | -$locationsFieldsMapping['address_alias']=2; |
|
31 | -$locationsFieldsMapping['address_1']=3; |
|
32 | -$locationsFieldsMapping['address_city']=4; |
|
33 | -$locationsFieldsMapping['address_state_id']=5; |
|
34 | -$locationsFieldsMapping['address_zip']=6; |
|
35 | -$locationsFieldsMapping['address_phone_number']=7; |
|
36 | -$locationsFieldsMapping['schedule_mode']=8; |
|
37 | -$locationsFieldsMapping['schedule_enabled']=9; |
|
38 | -$locationsFieldsMapping['schedule_every']=10; |
|
39 | -$locationsFieldsMapping['schedule_weekdays']=11; |
|
40 | -$locationsFieldsMapping['monthly_mode']=12; |
|
41 | -$locationsFieldsMapping['monthly_dates']=13; |
|
42 | -$locationsFieldsMapping['monthly_nth_n']=16; |
|
43 | -$locationsFieldsMapping['monthly_nth_wwhat']=17; |
|
44 | - |
|
45 | -if (($handle = fopen("$source_file", "r")) !== FALSE) { |
|
28 | +$locationsFieldsMapping['cached_lat'] = 0; |
|
29 | +$locationsFieldsMapping['cached_lng'] = 1; |
|
30 | +$locationsFieldsMapping['address_alias'] = 2; |
|
31 | +$locationsFieldsMapping['address_1'] = 3; |
|
32 | +$locationsFieldsMapping['address_city'] = 4; |
|
33 | +$locationsFieldsMapping['address_state_id'] = 5; |
|
34 | +$locationsFieldsMapping['address_zip'] = 6; |
|
35 | +$locationsFieldsMapping['address_phone_number'] = 7; |
|
36 | +$locationsFieldsMapping['schedule_mode'] = 8; |
|
37 | +$locationsFieldsMapping['schedule_enabled'] = 9; |
|
38 | +$locationsFieldsMapping['schedule_every'] = 10; |
|
39 | +$locationsFieldsMapping['schedule_weekdays'] = 11; |
|
40 | +$locationsFieldsMapping['monthly_mode'] = 12; |
|
41 | +$locationsFieldsMapping['monthly_dates'] = 13; |
|
42 | +$locationsFieldsMapping['monthly_nth_n'] = 16; |
|
43 | +$locationsFieldsMapping['monthly_nth_wwhat'] = 17; |
|
44 | + |
|
45 | +if (($handle = fopen("$source_file", "r"))!==FALSE) { |
|
46 | 46 | $oAbook = new AddressBookLocation(); |
47 | 47 | |
48 | - $results=$oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping); //Temporarry |
|
48 | + $results = $oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping); //Temporarry |
|
49 | 49 | |
50 | 50 | echo "Errors: <br><br>"; |
51 | 51 | foreach ($results['fail'] as $evalue) { |
@@ -61,23 +61,23 @@ discard block |
||
61 | 61 | |
62 | 62 | /* Add orders with schedules from a CSV file */ |
63 | 63 | |
64 | -$orders_file="orders_baton.csv"; |
|
64 | +$orders_file = "orders_baton.csv"; |
|
65 | 65 | |
66 | 66 | /* Mapping of a CSV file with the orders - which of the CSV table column is corresponding to which of the Order's field */ |
67 | 67 | |
68 | -$ordersFieldsMapping['cached_lat']=1; |
|
69 | -$ordersFieldsMapping['cached_lng']=0; |
|
70 | -$ordersFieldsMapping['address_alias']=2; |
|
71 | -$ordersFieldsMapping['address_1']=3; |
|
72 | -$ordersFieldsMapping['order_city']=4; |
|
73 | -$ordersFieldsMapping['order_state_id']=5; |
|
74 | -$ordersFieldsMapping['order_zip_code']=6; |
|
75 | -$ordersFieldsMapping['EXT_FIELD_phone']=7; |
|
76 | -$ordersFieldsMapping['day_scheduled_for_YYMMDD']=8; |
|
77 | - |
|
78 | -if (($handle = fopen("$orders_file", "r")) !== FALSE) { |
|
68 | +$ordersFieldsMapping['cached_lat'] = 1; |
|
69 | +$ordersFieldsMapping['cached_lng'] = 0; |
|
70 | +$ordersFieldsMapping['address_alias'] = 2; |
|
71 | +$ordersFieldsMapping['address_1'] = 3; |
|
72 | +$ordersFieldsMapping['order_city'] = 4; |
|
73 | +$ordersFieldsMapping['order_state_id'] = 5; |
|
74 | +$ordersFieldsMapping['order_zip_code'] = 6; |
|
75 | +$ordersFieldsMapping['EXT_FIELD_phone'] = 7; |
|
76 | +$ordersFieldsMapping['day_scheduled_for_YYMMDD'] = 8; |
|
77 | + |
|
78 | +if (($handle = fopen("$orders_file", "r"))!==FALSE) { |
|
79 | 79 | $order = new Order(); |
80 | - $results=$order->addOrdersFromCsvFile($handle, $ordersFieldsMapping); |
|
80 | + $results = $order->addOrdersFromCsvFile($handle, $ordersFieldsMapping); |
|
81 | 81 | |
82 | 82 | echo "Errors: <br><br>"; |
83 | 83 | foreach ($results['fail'] as $evalue) { |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | /* Get Hybrid Optimization */ |
95 | 95 | |
96 | - $ep = time()+604800; |
|
96 | + $ep = time() + 604800; |
|
97 | 97 | $sched_date = date("Y-m-d", $ep); |
98 | 98 | |
99 | 99 | $hybridParams = array( |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | /* Add depots to the Hybrid Optimization */ |
115 | 115 | $depotfile = "depots.csv"; |
116 | 116 | |
117 | - if (($handle = fopen("$depotfile", "r")) !== FALSE) { |
|
117 | + if (($handle = fopen("$depotfile", "r"))!==FALSE) { |
|
118 | 118 | |
119 | 119 | $columns = fgetcsv($handle, $max_line_length, $delemietr); |
120 | 120 | |
@@ -128,15 +128,15 @@ discard block |
||
128 | 128 | 'delete_old_depots' => true, |
129 | 129 | ); |
130 | 130 | |
131 | - $iRow=1; |
|
131 | + $iRow = 1; |
|
132 | 132 | $depotAddresses = array(); |
133 | 133 | |
134 | - while (($rows = fgetcsv($handle, $max_line_length, $delemietr)) !== false) { |
|
135 | - if ($rows[0] && $rows[1] && $rows[3] && array(null) !== $rows) { |
|
136 | - $depotAddress['lat']= $rows[0]; |
|
137 | - $depotAddress['lng']= $rows[1]; |
|
138 | - $depotAddress['address']= $rows[3]; |
|
139 | - array_push($depotAddresses,$depotAddress); |
|
134 | + while (($rows = fgetcsv($handle, $max_line_length, $delemietr))!==false) { |
|
135 | + if ($rows[0] && $rows[1] && $rows[3] && array(null)!==$rows) { |
|
136 | + $depotAddress['lat'] = $rows[0]; |
|
137 | + $depotAddress['lng'] = $rows[1]; |
|
138 | + $depotAddress['address'] = $rows[3]; |
|
139 | + array_push($depotAddresses, $depotAddress); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 |
@@ -103,6 +103,9 @@ |
||
103 | 103 | return $ablocations; |
104 | 104 | } |
105 | 105 | |
106 | + /** |
|
107 | + * @param AddressBookLocation $params |
|
108 | + */ |
|
106 | 109 | public static function addAdressBookLocation($params) |
107 | 110 | { |
108 | 111 | $ablocations = Route4Me::makeRequst(array( |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | public $address_zip; |
24 | 24 | public $cached_lat; |
25 | 25 | public $cached_lng; |
26 | - public $curbside_lat; |
|
27 | - public $curbside_lng; |
|
26 | + public $curbside_lat; |
|
27 | + public $curbside_lng; |
|
28 | 28 | public $color; |
29 | - public $address_custom_data; |
|
30 | - public $schedule; |
|
29 | + public $address_custom_data; |
|
30 | + public $schedule; |
|
31 | 31 | |
32 | 32 | //public $offset; |
33 | 33 | //public $limit; |
@@ -36,415 +36,415 @@ discard block |
||
36 | 36 | |
37 | 37 | public static function fromArray(array $params) { |
38 | 38 | $addressbooklocation = new AddressBookLocation(); |
39 | - foreach($params as $key => $value) { |
|
40 | - if (property_exists($addressbooklocation, $key)) { |
|
41 | - $addressbooklocation->{$key} = $value; |
|
42 | - } |
|
39 | + foreach($params as $key => $value) { |
|
40 | + if (property_exists($addressbooklocation, $key)) { |
|
41 | + $addressbooklocation->{$key} = $value; |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | return $addressbooklocation; |
46 | 46 | } |
47 | 47 | |
48 | 48 | public static function getAddressBookLocation($addressId) |
49 | - { |
|
50 | - $ablocations = Route4Me::makeRequst(array( |
|
51 | - 'url' => self::$apiUrl, |
|
52 | - 'method' => 'GET', |
|
53 | - 'query' => array( |
|
54 | - 'query' => $addressId, |
|
55 | - 'limit' => 30 |
|
56 | - ) |
|
57 | - )); |
|
49 | + { |
|
50 | + $ablocations = Route4Me::makeRequst(array( |
|
51 | + 'url' => self::$apiUrl, |
|
52 | + 'method' => 'GET', |
|
53 | + 'query' => array( |
|
54 | + 'query' => $addressId, |
|
55 | + 'limit' => 30 |
|
56 | + ) |
|
57 | + )); |
|
58 | 58 | |
59 | 59 | return $ablocations; |
60 | 60 | } |
61 | 61 | |
62 | 62 | public static function searchRoutedLocation($params) |
63 | - { |
|
64 | - $result= Route4Me::makeRequst(array( |
|
65 | - 'url' => self::$apiUrl, |
|
66 | - 'method' => 'GET', |
|
67 | - 'query' => array( |
|
68 | - 'display' => isset($params['display']) ? $params['display']: null, |
|
69 | - 'query' => isset($params['query']) ? $params['query']: null, |
|
70 | - 'fields' => isset($params['fields']) ? $params['fields']: null, |
|
71 | - 'limit' => isset($params['limit']) ? $params['limit']: null, |
|
72 | - 'offset' => isset($params['offset']) ? $params['offset'] : null, |
|
73 | - ) |
|
74 | - )); |
|
63 | + { |
|
64 | + $result= Route4Me::makeRequst(array( |
|
65 | + 'url' => self::$apiUrl, |
|
66 | + 'method' => 'GET', |
|
67 | + 'query' => array( |
|
68 | + 'display' => isset($params['display']) ? $params['display']: null, |
|
69 | + 'query' => isset($params['query']) ? $params['query']: null, |
|
70 | + 'fields' => isset($params['fields']) ? $params['fields']: null, |
|
71 | + 'limit' => isset($params['limit']) ? $params['limit']: null, |
|
72 | + 'offset' => isset($params['offset']) ? $params['offset'] : null, |
|
73 | + ) |
|
74 | + )); |
|
75 | 75 | |
76 | 76 | return $result; |
77 | 77 | } |
78 | 78 | |
79 | 79 | public static function getAddressBookLocations($params) |
80 | - { |
|
81 | - $ablocations = Route4Me::makeRequst(array( |
|
82 | - 'url' => self::$apiUrl, |
|
83 | - 'method' => 'GET', |
|
84 | - 'query' => array( |
|
85 | - 'limit' => isset($params->limit) ? $params->limit: null, |
|
86 | - 'offset' => isset($params->offset) ? $params->offset : null, |
|
87 | - ) |
|
88 | - )); |
|
80 | + { |
|
81 | + $ablocations = Route4Me::makeRequst(array( |
|
82 | + 'url' => self::$apiUrl, |
|
83 | + 'method' => 'GET', |
|
84 | + 'query' => array( |
|
85 | + 'limit' => isset($params->limit) ? $params->limit: null, |
|
86 | + 'offset' => isset($params->offset) ? $params->offset : null, |
|
87 | + ) |
|
88 | + )); |
|
89 | 89 | |
90 | 90 | return $ablocations; |
91 | 91 | } |
92 | 92 | |
93 | 93 | public static function getAddressBookLocationsByIds($ids) |
94 | - { |
|
95 | - $ablocations = Route4Me::makeRequst(array( |
|
96 | - 'url' => self::$apiUrl, |
|
97 | - 'method' => 'GET', |
|
98 | - 'query' => array( |
|
99 | - 'address_id' => $ids |
|
100 | - ) |
|
101 | - )); |
|
94 | + { |
|
95 | + $ablocations = Route4Me::makeRequst(array( |
|
96 | + 'url' => self::$apiUrl, |
|
97 | + 'method' => 'GET', |
|
98 | + 'query' => array( |
|
99 | + 'address_id' => $ids |
|
100 | + ) |
|
101 | + )); |
|
102 | 102 | |
103 | 103 | return $ablocations; |
104 | 104 | } |
105 | 105 | |
106 | 106 | public static function addAdressBookLocation($params) |
107 | - { |
|
108 | - $ablocations = Route4Me::makeRequst(array( |
|
109 | - 'url' => self::$apiUrl, |
|
110 | - 'method' => 'POST', |
|
111 | - 'body' => array( |
|
112 | - 'address_1' => isset($params->address_1) ? $params->address_1: null, |
|
113 | - 'address_2' => isset($params->address_2) ? $params->address_2: null, |
|
114 | - 'address_alias' => isset($params->address_alias) ? $params->address_alias: null, |
|
115 | - 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
|
116 | - 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
|
117 | - 'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null, |
|
118 | - 'curbside_lng' => isset($params->curbside_lng) ? $params->curbside_lng : null, |
|
119 | - 'address_phone_number' => isset($params->address_phone_number) ? $params->address_phone_number: null, |
|
120 | - 'address_group' => isset($params->address_group) ? $params->address_group: null, |
|
121 | - 'first_name' => isset($params->first_name) ? $params->first_name: null, |
|
122 | - 'last_name' => isset($params->last_name) ? $params->last_name: null, |
|
123 | - 'local_time_window_start' => isset($params->local_time_window_start) ? $params->local_time_window_start: null, |
|
124 | - 'local_time_window_end' => isset($params->local_time_window_end) ? $params->local_time_window_end: null, |
|
125 | - 'local_time_window_start_2' => isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null, |
|
126 | - 'local_time_window_end_2' => isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null, |
|
127 | - 'address_email' => isset($params->address_email) ? $params->address_email: null, |
|
128 | - 'address_city' => isset($params->address_city) ? $params->address_city: null, |
|
129 | - 'address_state_id' => isset($params->address_state_id) ? $params->address_state_id: null, |
|
130 | - 'address_country_id' => isset($params->address_country_id) ? $params->address_country_id: null, |
|
131 | - 'address_zip' => isset($params->address_zip) ? $params->address_zip: null, |
|
132 | - 'address_custom_data' => isset($params->address_custom_data) ? $params->address_custom_data: null, |
|
133 | - 'schedule' => isset($params->schedule) ? $params->schedule: null, |
|
134 | - 'schedule_blacklist' => isset($params->schedule_blacklist) ? $params->schedule_blacklist: null, |
|
135 | - 'service_time' => isset($params->service_time) ? $params->service_time: null, |
|
136 | - 'local_timezone_string' => isset($params->local_timezone_string) ? $params->local_timezone_string: null, |
|
137 | - 'color' => isset($params->color) ? $params->color: null, |
|
138 | - 'address_icon' => isset($params->address_icon) ? $params->address_icon: null, |
|
139 | - 'address_stop_type' => isset($params->address_stop_type) ? $params->address_stop_type: null, |
|
140 | - 'address_cube' => isset($params->address_cube) ? $params->address_cube: null, |
|
141 | - 'address_pieces' => isset($params->address_pieces) ? $params->address_pieces: null, |
|
142 | - 'address_reference_no' => isset($params->address_reference_no) ? $params->address_reference_no: null, |
|
143 | - 'address_revenue' => isset($params->address_revenue) ? $params->address_revenue: null, |
|
144 | - 'address_weight' => isset($params->address_weight) ? $params->address_weight: null, |
|
145 | - 'address_priority' => isset($params->address_priority) ? $params->address_priority: null, |
|
146 | - 'address_customer_po' => isset($params->address_customer_po) ? $params->address_customer_po: null, |
|
147 | - ) |
|
148 | - )); |
|
107 | + { |
|
108 | + $ablocations = Route4Me::makeRequst(array( |
|
109 | + 'url' => self::$apiUrl, |
|
110 | + 'method' => 'POST', |
|
111 | + 'body' => array( |
|
112 | + 'address_1' => isset($params->address_1) ? $params->address_1: null, |
|
113 | + 'address_2' => isset($params->address_2) ? $params->address_2: null, |
|
114 | + 'address_alias' => isset($params->address_alias) ? $params->address_alias: null, |
|
115 | + 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
|
116 | + 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
|
117 | + 'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null, |
|
118 | + 'curbside_lng' => isset($params->curbside_lng) ? $params->curbside_lng : null, |
|
119 | + 'address_phone_number' => isset($params->address_phone_number) ? $params->address_phone_number: null, |
|
120 | + 'address_group' => isset($params->address_group) ? $params->address_group: null, |
|
121 | + 'first_name' => isset($params->first_name) ? $params->first_name: null, |
|
122 | + 'last_name' => isset($params->last_name) ? $params->last_name: null, |
|
123 | + 'local_time_window_start' => isset($params->local_time_window_start) ? $params->local_time_window_start: null, |
|
124 | + 'local_time_window_end' => isset($params->local_time_window_end) ? $params->local_time_window_end: null, |
|
125 | + 'local_time_window_start_2' => isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null, |
|
126 | + 'local_time_window_end_2' => isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null, |
|
127 | + 'address_email' => isset($params->address_email) ? $params->address_email: null, |
|
128 | + 'address_city' => isset($params->address_city) ? $params->address_city: null, |
|
129 | + 'address_state_id' => isset($params->address_state_id) ? $params->address_state_id: null, |
|
130 | + 'address_country_id' => isset($params->address_country_id) ? $params->address_country_id: null, |
|
131 | + 'address_zip' => isset($params->address_zip) ? $params->address_zip: null, |
|
132 | + 'address_custom_data' => isset($params->address_custom_data) ? $params->address_custom_data: null, |
|
133 | + 'schedule' => isset($params->schedule) ? $params->schedule: null, |
|
134 | + 'schedule_blacklist' => isset($params->schedule_blacklist) ? $params->schedule_blacklist: null, |
|
135 | + 'service_time' => isset($params->service_time) ? $params->service_time: null, |
|
136 | + 'local_timezone_string' => isset($params->local_timezone_string) ? $params->local_timezone_string: null, |
|
137 | + 'color' => isset($params->color) ? $params->color: null, |
|
138 | + 'address_icon' => isset($params->address_icon) ? $params->address_icon: null, |
|
139 | + 'address_stop_type' => isset($params->address_stop_type) ? $params->address_stop_type: null, |
|
140 | + 'address_cube' => isset($params->address_cube) ? $params->address_cube: null, |
|
141 | + 'address_pieces' => isset($params->address_pieces) ? $params->address_pieces: null, |
|
142 | + 'address_reference_no' => isset($params->address_reference_no) ? $params->address_reference_no: null, |
|
143 | + 'address_revenue' => isset($params->address_revenue) ? $params->address_revenue: null, |
|
144 | + 'address_weight' => isset($params->address_weight) ? $params->address_weight: null, |
|
145 | + 'address_priority' => isset($params->address_priority) ? $params->address_priority: null, |
|
146 | + 'address_customer_po' => isset($params->address_customer_po) ? $params->address_customer_po: null, |
|
147 | + ) |
|
148 | + )); |
|
149 | 149 | |
150 | 150 | return $ablocations; |
151 | 151 | } |
152 | 152 | |
153 | 153 | public function deleteAdressBookLocation($address_ids) |
154 | - { |
|
155 | - $address = Route4Me::makeRequst(array( |
|
156 | - 'url' => self::$apiUrl, |
|
157 | - 'method' => 'DELETEARRAY', |
|
158 | - 'query' => array( |
|
159 | - 'address_ids' => $address_ids |
|
160 | - ) |
|
161 | - )); |
|
154 | + { |
|
155 | + $address = Route4Me::makeRequst(array( |
|
156 | + 'url' => self::$apiUrl, |
|
157 | + 'method' => 'DELETEARRAY', |
|
158 | + 'query' => array( |
|
159 | + 'address_ids' => $address_ids |
|
160 | + ) |
|
161 | + )); |
|
162 | 162 | |
163 | - return $address; |
|
164 | - } |
|
163 | + return $address; |
|
164 | + } |
|
165 | 165 | |
166 | 166 | public function updateAdressBookLocation($params) |
167 | - { |
|
168 | - //echo "address_id --> ".$params["address_id"]."<br"; |
|
169 | - $address = Route4Me::makeRequst(array( |
|
170 | - 'url' => self::$apiUrl, |
|
171 | - 'method' => 'PUT', |
|
172 | - 'query' => $params, |
|
167 | + { |
|
168 | + //echo "address_id --> ".$params["address_id"]."<br"; |
|
169 | + $address = Route4Me::makeRequst(array( |
|
170 | + 'url' => self::$apiUrl, |
|
171 | + 'method' => 'PUT', |
|
172 | + 'query' => $params, |
|
173 | 173 | |
174 | - )); |
|
174 | + )); |
|
175 | 175 | |
176 | - return $address; |
|
177 | - } |
|
176 | + return $address; |
|
177 | + } |
|
178 | 178 | |
179 | 179 | public static function get($params) |
180 | - { |
|
181 | - $ablocations = Route4Me::makeRequst(array( |
|
182 | - 'url' => self::$apiUrl, |
|
183 | - 'method' => 'ADD', |
|
184 | - 'query' => array( |
|
185 | - 'first_name' => isset($params->first_name) ? $params->first_name : null, |
|
186 | - 'address_1' => isset($params->address_1) ? $params->address_1: null, |
|
187 | - 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
|
188 | - 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
|
189 | - ) |
|
190 | - )); |
|
180 | + { |
|
181 | + $ablocations = Route4Me::makeRequst(array( |
|
182 | + 'url' => self::$apiUrl, |
|
183 | + 'method' => 'ADD', |
|
184 | + 'query' => array( |
|
185 | + 'first_name' => isset($params->first_name) ? $params->first_name : null, |
|
186 | + 'address_1' => isset($params->address_1) ? $params->address_1: null, |
|
187 | + 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
|
188 | + 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
|
189 | + ) |
|
190 | + )); |
|
191 | 191 | |
192 | 192 | return $ablocations; |
193 | 193 | } |
194 | 194 | |
195 | - public static function validateScheduleMode($scheduleMode) |
|
196 | - { |
|
197 | - $schedMmodes=array("daily","weekly","monthly","annually"); |
|
195 | + public static function validateScheduleMode($scheduleMode) |
|
196 | + { |
|
197 | + $schedMmodes=array("daily","weekly","monthly","annually"); |
|
198 | 198 | |
199 | - if (in_array($scheduleMode, $schedMmodes)) return TRUE; else return FALSE; |
|
200 | - } |
|
199 | + if (in_array($scheduleMode, $schedMmodes)) return TRUE; else return FALSE; |
|
200 | + } |
|
201 | 201 | |
202 | - public static function validateScheduleEnable($scheduleEnabled) |
|
203 | - { |
|
204 | - $schedEnambles=array(TRUE,FALSE); |
|
202 | + public static function validateScheduleEnable($scheduleEnabled) |
|
203 | + { |
|
204 | + $schedEnambles=array(TRUE,FALSE); |
|
205 | 205 | |
206 | - if (in_array($scheduleEnabled, $schedEnambles)) return TRUE; else return FALSE; |
|
207 | - } |
|
206 | + if (in_array($scheduleEnabled, $schedEnambles)) return TRUE; else return FALSE; |
|
207 | + } |
|
208 | 208 | |
209 | - public static function validateScheduleEvery($scheduleEvery) |
|
210 | - { |
|
211 | - if (is_numeric($scheduleEvery)) return TRUE; else return FALSE; |
|
212 | - } |
|
209 | + public static function validateScheduleEvery($scheduleEvery) |
|
210 | + { |
|
211 | + if (is_numeric($scheduleEvery)) return TRUE; else return FALSE; |
|
212 | + } |
|
213 | 213 | |
214 | - public static function validateScheduleWeekDays($scheduleWeekDays) |
|
215 | - { |
|
216 | - $weekdays = explode(',', $scheduleWeekDays); |
|
214 | + public static function validateScheduleWeekDays($scheduleWeekDays) |
|
215 | + { |
|
216 | + $weekdays = explode(',', $scheduleWeekDays); |
|
217 | 217 | |
218 | - if (sizeof($weekdays)<1) return FALSE; |
|
218 | + if (sizeof($weekdays)<1) return FALSE; |
|
219 | 219 | |
220 | - $isValid=TRUE; |
|
220 | + $isValid=TRUE; |
|
221 | 221 | |
222 | - for ($i=0; $i < sizeof($weekdays); $i++) { |
|
223 | - if (is_numeric($weekdays[$i])) { |
|
224 | - $wday=intval($weekdays[$i]); |
|
225 | - if ($wday<1 || $wday>7) $isValid=FALSE; |
|
226 | - } |
|
227 | - else $isValid=FALSE; |
|
228 | - } |
|
229 | - //echo $scheduleWeekDays.' --- '. $isValid."<br>"; |
|
230 | - return $isValid; |
|
231 | - } |
|
222 | + for ($i=0; $i < sizeof($weekdays); $i++) { |
|
223 | + if (is_numeric($weekdays[$i])) { |
|
224 | + $wday=intval($weekdays[$i]); |
|
225 | + if ($wday<1 || $wday>7) $isValid=FALSE; |
|
226 | + } |
|
227 | + else $isValid=FALSE; |
|
228 | + } |
|
229 | + //echo $scheduleWeekDays.' --- '. $isValid."<br>"; |
|
230 | + return $isValid; |
|
231 | + } |
|
232 | 232 | |
233 | - public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
|
234 | - { |
|
235 | - $schedMonthlyMmodes=array("dates","nth"); |
|
233 | + public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
|
234 | + { |
|
235 | + $schedMonthlyMmodes=array("dates","nth"); |
|
236 | 236 | |
237 | - if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) return TRUE; else return FALSE; |
|
238 | - } |
|
237 | + if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) return TRUE; else return FALSE; |
|
238 | + } |
|
239 | 239 | |
240 | - public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
|
241 | - { |
|
242 | - $monthlyDates = explode(',', $scheduleMonthlyDates); |
|
240 | + public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
|
241 | + { |
|
242 | + $monthlyDates = explode(',', $scheduleMonthlyDates); |
|
243 | 243 | |
244 | - if (sizeof($monthlyDates)<1) return FALSE; |
|
244 | + if (sizeof($monthlyDates)<1) return FALSE; |
|
245 | 245 | |
246 | - $isValid=TRUE; |
|
246 | + $isValid=TRUE; |
|
247 | 247 | |
248 | - for ($i=0; $i < sizeof($monthlyDates); $i++) { |
|
249 | - if (is_numeric($monthlyDates[$i])) { |
|
250 | - $mday=intval($monthlyDates[$i]); |
|
251 | - if ($mday<1 || $mday>31) $isValid=FALSE; |
|
252 | - } |
|
253 | - else $isValid=FALSE; |
|
254 | - } |
|
248 | + for ($i=0; $i < sizeof($monthlyDates); $i++) { |
|
249 | + if (is_numeric($monthlyDates[$i])) { |
|
250 | + $mday=intval($monthlyDates[$i]); |
|
251 | + if ($mday<1 || $mday>31) $isValid=FALSE; |
|
252 | + } |
|
253 | + else $isValid=FALSE; |
|
254 | + } |
|
255 | 255 | |
256 | - return $isValid; |
|
257 | - } |
|
256 | + return $isValid; |
|
257 | + } |
|
258 | 258 | |
259 | - public static function validateScheduleNthN($scheduleNthN) |
|
260 | - { |
|
261 | - if (!is_numeric($scheduleNthN)) return FALSE; |
|
259 | + public static function validateScheduleNthN($scheduleNthN) |
|
260 | + { |
|
261 | + if (!is_numeric($scheduleNthN)) return FALSE; |
|
262 | 262 | |
263 | - $schedNthNs=array(1,2,3,4,5,-1); |
|
264 | - if (in_array($scheduleNthN, $schedNthNs)) return TRUE; else return FALSE; |
|
265 | - } |
|
263 | + $schedNthNs=array(1,2,3,4,5,-1); |
|
264 | + if (in_array($scheduleNthN, $schedNthNs)) return TRUE; else return FALSE; |
|
265 | + } |
|
266 | 266 | |
267 | - public static function validateScheduleNthWhat($scheduleNthWhat) |
|
268 | - { |
|
269 | - if (!is_numeric($scheduleNthWhat)) return FALSE; |
|
267 | + public static function validateScheduleNthWhat($scheduleNthWhat) |
|
268 | + { |
|
269 | + if (!is_numeric($scheduleNthWhat)) return FALSE; |
|
270 | 270 | |
271 | - $schedNthWhats=array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
272 | - if (in_array($scheduleNthWhat, $schedNthWhats)) return TRUE; else return FALSE; |
|
273 | - } |
|
271 | + $schedNthWhats=array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
272 | + if (in_array($scheduleNthWhat, $schedNthWhats)) return TRUE; else return FALSE; |
|
273 | + } |
|
274 | 274 | |
275 | - /* Function adds the locations (with/without schedule) from the CSV file. |
|
275 | + /* Function adds the locations (with/without schedule) from the CSV file. |
|
276 | 276 | * $csvFileHandle - a file handler. |
277 | 277 | * Returns array $results which contains two arrays: fail and succes. |
278 | 278 | */ |
279 | - public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping) |
|
280 | - { |
|
281 | - $max_line_length = 512; |
|
282 | - $delemietr=','; |
|
279 | + public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping) |
|
280 | + { |
|
281 | + $max_line_length = 512; |
|
282 | + $delemietr=','; |
|
283 | 283 | |
284 | - $results=array(); |
|
285 | - $results['fail']=array(); |
|
286 | - $results['success']=array(); |
|
284 | + $results=array(); |
|
285 | + $results['fail']=array(); |
|
286 | + $results['success']=array(); |
|
287 | 287 | |
288 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
289 | - if (!empty($columns)) { |
|
290 | - array_push($results['fail'],'Empty CSV table'); |
|
291 | - return ($results); |
|
292 | - } |
|
288 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
289 | + if (!empty($columns)) { |
|
290 | + array_push($results['fail'],'Empty CSV table'); |
|
291 | + return ($results); |
|
292 | + } |
|
293 | 293 | |
294 | - $iRow=1; |
|
294 | + $iRow=1; |
|
295 | 295 | |
296 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) { |
|
297 | - if ($rows[$locationsFieldsMapping['cached_lat']] && $rows[$locationsFieldsMapping['cached_lng']] && $rows[$locationsFieldsMapping['address_1']] && array(null) !== $rows) { |
|
298 | - $curSchedule=""; |
|
299 | - $mode=""; |
|
296 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) { |
|
297 | + if ($rows[$locationsFieldsMapping['cached_lat']] && $rows[$locationsFieldsMapping['cached_lng']] && $rows[$locationsFieldsMapping['address_1']] && array(null) !== $rows) { |
|
298 | + $curSchedule=""; |
|
299 | + $mode=""; |
|
300 | 300 | |
301 | - if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
302 | - if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
303 | - $curSchedule='"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
304 | - $mode=$rows[$locationsFieldsMapping['schedule_mode']]; |
|
305 | - } |
|
306 | - else {array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); $curSchedule="";} |
|
307 | - } |
|
308 | - else {array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); $curSchedule="";} |
|
301 | + if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
302 | + if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
303 | + $curSchedule='"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
304 | + $mode=$rows[$locationsFieldsMapping['schedule_mode']]; |
|
305 | + } |
|
306 | + else {array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); $curSchedule="";} |
|
307 | + } |
|
308 | + else {array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); $curSchedule="";} |
|
309 | 309 | |
310 | - if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
311 | - if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
312 | - $curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
313 | - } |
|
314 | - else {array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set "); $curSchedule="";} |
|
315 | - } |
|
310 | + if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
311 | + if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
312 | + $curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
313 | + } |
|
314 | + else {array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set "); $curSchedule="";} |
|
315 | + } |
|
316 | 316 | |
317 | - if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
318 | - if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
319 | - $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
320 | - if ($mode=='daily') { |
|
321 | - $curSchedule=trim($curSchedule,','); |
|
322 | - $curSchedule.='}'; |
|
323 | - } |
|
324 | - } |
|
325 | - else {array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); $curSchedule=""; } |
|
326 | - } |
|
317 | + if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
318 | + if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
319 | + $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
320 | + if ($mode=='daily') { |
|
321 | + $curSchedule=trim($curSchedule,','); |
|
322 | + $curSchedule.='}'; |
|
323 | + } |
|
324 | + } |
|
325 | + else {array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); $curSchedule=""; } |
|
326 | + } |
|
327 | 327 | |
328 | - if ($mode!='daily') { |
|
329 | - switch ($mode) { |
|
330 | - case 'weekly': |
|
331 | - if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
332 | - if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
333 | - $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
334 | - } |
|
335 | - else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $curSchedule="";} |
|
336 | - } |
|
337 | - else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $curSchedule="";} |
|
338 | - break; |
|
339 | - case 'monthly': |
|
340 | - $monthlyMode=""; |
|
341 | - if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
342 | - if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
343 | - $monthlyMode=$rows[$locationsFieldsMapping['monthly_mode']]; |
|
344 | - $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
345 | - } |
|
346 | - else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $curSchedule="";} |
|
347 | - } |
|
348 | - else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $curSchedule="";} |
|
328 | + if ($mode!='daily') { |
|
329 | + switch ($mode) { |
|
330 | + case 'weekly': |
|
331 | + if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
332 | + if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
333 | + $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
334 | + } |
|
335 | + else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $curSchedule="";} |
|
336 | + } |
|
337 | + else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $curSchedule="";} |
|
338 | + break; |
|
339 | + case 'monthly': |
|
340 | + $monthlyMode=""; |
|
341 | + if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
342 | + if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
343 | + $monthlyMode=$rows[$locationsFieldsMapping['monthly_mode']]; |
|
344 | + $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
345 | + } |
|
346 | + else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $curSchedule="";} |
|
347 | + } |
|
348 | + else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $curSchedule="";} |
|
349 | 349 | |
350 | - if ($monthlyMode!="") { |
|
351 | - switch ($monthlyMode) { |
|
352 | - case 'dates': |
|
353 | - if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
354 | - if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
355 | - $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
356 | - } |
|
357 | - else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $curSchedule="";} |
|
358 | - } |
|
359 | - break; |
|
360 | - case 'nth': |
|
361 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
362 | - if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
363 | - $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
364 | - } |
|
365 | - else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $curSchedule="";} |
|
366 | - } |
|
367 | - else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $curSchedule="";} |
|
350 | + if ($monthlyMode!="") { |
|
351 | + switch ($monthlyMode) { |
|
352 | + case 'dates': |
|
353 | + if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
354 | + if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
355 | + $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
356 | + } |
|
357 | + else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $curSchedule="";} |
|
358 | + } |
|
359 | + break; |
|
360 | + case 'nth': |
|
361 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
362 | + if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
363 | + $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
364 | + } |
|
365 | + else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $curSchedule="";} |
|
366 | + } |
|
367 | + else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $curSchedule="";} |
|
368 | 368 | |
369 | - if ($curSchedule!="") { |
|
370 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
371 | - if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
372 | - $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
373 | - } |
|
374 | - else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $curSchedule="";} |
|
375 | - } |
|
376 | - else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $curSchedule="";} |
|
377 | - } |
|
369 | + if ($curSchedule!="") { |
|
370 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
371 | + if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
372 | + $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
373 | + } |
|
374 | + else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $curSchedule="";} |
|
375 | + } |
|
376 | + else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $curSchedule="";} |
|
377 | + } |
|
378 | 378 | |
379 | - break; |
|
380 | - } |
|
381 | - } |
|
382 | - break; |
|
383 | - default: |
|
384 | - $curSchedule==""; |
|
385 | - break; |
|
386 | - } |
|
379 | + break; |
|
380 | + } |
|
381 | + } |
|
382 | + break; |
|
383 | + default: |
|
384 | + $curSchedule==""; |
|
385 | + break; |
|
386 | + } |
|
387 | 387 | |
388 | - } |
|
388 | + } |
|
389 | 389 | |
390 | - if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") {$iRow++; continue;} |
|
390 | + if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") {$iRow++; continue;} |
|
391 | 391 | |
392 | - $curSchedule=strtolower($curSchedule); |
|
392 | + $curSchedule=strtolower($curSchedule); |
|
393 | 393 | |
394 | - $curSchedule='[{'.$curSchedule.'}]'; |
|
394 | + $curSchedule='[{'.$curSchedule.'}]'; |
|
395 | 395 | |
396 | - $oSchedule= json_decode($curSchedule,TRUE); |
|
396 | + $oSchedule= json_decode($curSchedule,TRUE); |
|
397 | 397 | |
398 | - $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
399 | - "cached_lat" => $rows[$locationsFieldsMapping['cached_lat']], |
|
400 | - "cached_lng" => $rows[$locationsFieldsMapping['cached_lng']], |
|
401 | - "curbside_lat" => isset($locationsFieldsMapping['curbside_lat']) ? $rows[$locationsFieldsMapping['curbside_lat']] : null, |
|
402 | - "curbside_lng" => isset($locationsFieldsMapping['curbside_lng']) ? $rows[$locationsFieldsMapping['curbside_lng']] : null, |
|
403 | - "address_alias" => isset($locationsFieldsMapping['address_alias']) ? $rows[$locationsFieldsMapping['address_alias']] : null, |
|
404 | - "address_1" => $rows[$locationsFieldsMapping['address_1']], |
|
405 | - "address_2" => isset($locationsFieldsMapping['address_2']) ? $rows[$locationsFieldsMapping['address_2']] : null, |
|
406 | - "address_city" => isset($locationsFieldsMapping['address_city']) ? $rows[$locationsFieldsMapping['address_city']] : null, |
|
407 | - "address_state_id" => isset($locationsFieldsMapping['address_state_id']) ? $rows[$locationsFieldsMapping['address_state_id']] : null, |
|
408 | - "address_zip" => isset($locationsFieldsMapping['address_zip']) ? $rows[$locationsFieldsMapping['address_zip']] : null, |
|
409 | - "address_phone_number" => isset($locationsFieldsMapping['address_phone_number']) ? $rows[$locationsFieldsMapping['address_phone_number']] : null, |
|
410 | - "schedule" => isset($oSchedule) ? $oSchedule : null, |
|
411 | - "address_group" => isset($locationsFieldsMapping['address_group']) ? $rows[$locationsFieldsMapping['address_group']] : null, |
|
412 | - "first_name" => isset($locationsFieldsMapping['first_name']) ? $rows[$locationsFieldsMapping['first_name']] : null, |
|
413 | - "last_name" => isset($locationsFieldsMapping['last_name']) ? $rows[$locationsFieldsMapping['last_name']] : null, |
|
414 | - "local_time_window_start" => isset($locationsFieldsMapping['local_time_window_start']) ? $rows[$locationsFieldsMapping['local_time_window_start']] : null, |
|
415 | - "local_time_window_end" => isset($locationsFieldsMapping['local_time_window_end']) ? $rows[$locationsFieldsMapping['local_time_window_end']] : null, |
|
416 | - "local_time_window_start_2" => isset($locationsFieldsMapping['local_time_window_start_2']) ? $rows[$locationsFieldsMapping['local_time_window_start_2']] : null, |
|
417 | - "local_time_window_end_2" => isset($locationsFieldsMapping['local_time_window_end_2']) ? $rows[$locationsFieldsMapping['local_time_window_end_2']] : null, |
|
418 | - "address_email" => isset($locationsFieldsMapping['address_email']) ? $rows[$locationsFieldsMapping['address_email']] : null, |
|
419 | - "address_country_id" => isset($locationsFieldsMapping['address_country_id']) ? $rows[$locationsFieldsMapping['address_country_id']] : null, |
|
420 | - "address_custom_data" => isset($locationsFieldsMapping['address_custom_data']) ? $rows[$locationsFieldsMapping['address_custom_data']] : null, |
|
421 | - "schedule_blacklist" => isset($locationsFieldsMapping['schedule_blacklist']) ? $rows[$locationsFieldsMapping['schedule_blacklist']] : null, |
|
422 | - "service_time" => isset($locationsFieldsMapping['service_time']) ? $rows[$locationsFieldsMapping['service_time']] : null, |
|
423 | - "local_timezone_string" => isset($locationsFieldsMapping['local_timezone_string']) ? $rows[$locationsFieldsMapping['local_timezone_string']] : null, |
|
424 | - "color" => isset($locationsFieldsMapping['color']) ? $rows[$locationsFieldsMapping['color']] : null, |
|
425 | - "address_icon" => isset($locationsFieldsMapping['address_icon']) ? $rows[$locationsFieldsMapping['address_icon']] : null, |
|
426 | - "address_stop_type" => isset($locationsFieldsMapping['address_stop_type']) ? $rows[$locationsFieldsMapping['address_stop_type']] : null, |
|
427 | - "address_cube" => isset($locationsFieldsMapping['address_cube']) ? $rows[$locationsFieldsMapping['address_cube']] : null, |
|
428 | - "address_pieces" => isset($locationsFieldsMapping['address_pieces']) ? $rows[$locationsFieldsMapping['address_pieces']] : null, |
|
429 | - "address_reference_no" => isset($locationsFieldsMapping['address_reference_no']) ? $rows[$locationsFieldsMapping['address_reference_no']] : null, |
|
430 | - "address_revenue" => isset($locationsFieldsMapping['address_revenue']) ? $rows[$locationsFieldsMapping['address_revenue']] : null, |
|
431 | - "address_weight" => isset($locationsFieldsMapping['address_weight']) ? $rows[$locationsFieldsMapping['address_weight']] : null, |
|
432 | - "address_priority" => isset($locationsFieldsMapping['address_priority']) ? $rows[$locationsFieldsMapping['address_priority']] : null, |
|
433 | - "address_customer_po" => isset($locationsFieldsMapping['address_customer_po']) ? $rows[$locationsFieldsMapping['address_customer_po']] : null, |
|
434 | - )); |
|
398 | + $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
399 | + "cached_lat" => $rows[$locationsFieldsMapping['cached_lat']], |
|
400 | + "cached_lng" => $rows[$locationsFieldsMapping['cached_lng']], |
|
401 | + "curbside_lat" => isset($locationsFieldsMapping['curbside_lat']) ? $rows[$locationsFieldsMapping['curbside_lat']] : null, |
|
402 | + "curbside_lng" => isset($locationsFieldsMapping['curbside_lng']) ? $rows[$locationsFieldsMapping['curbside_lng']] : null, |
|
403 | + "address_alias" => isset($locationsFieldsMapping['address_alias']) ? $rows[$locationsFieldsMapping['address_alias']] : null, |
|
404 | + "address_1" => $rows[$locationsFieldsMapping['address_1']], |
|
405 | + "address_2" => isset($locationsFieldsMapping['address_2']) ? $rows[$locationsFieldsMapping['address_2']] : null, |
|
406 | + "address_city" => isset($locationsFieldsMapping['address_city']) ? $rows[$locationsFieldsMapping['address_city']] : null, |
|
407 | + "address_state_id" => isset($locationsFieldsMapping['address_state_id']) ? $rows[$locationsFieldsMapping['address_state_id']] : null, |
|
408 | + "address_zip" => isset($locationsFieldsMapping['address_zip']) ? $rows[$locationsFieldsMapping['address_zip']] : null, |
|
409 | + "address_phone_number" => isset($locationsFieldsMapping['address_phone_number']) ? $rows[$locationsFieldsMapping['address_phone_number']] : null, |
|
410 | + "schedule" => isset($oSchedule) ? $oSchedule : null, |
|
411 | + "address_group" => isset($locationsFieldsMapping['address_group']) ? $rows[$locationsFieldsMapping['address_group']] : null, |
|
412 | + "first_name" => isset($locationsFieldsMapping['first_name']) ? $rows[$locationsFieldsMapping['first_name']] : null, |
|
413 | + "last_name" => isset($locationsFieldsMapping['last_name']) ? $rows[$locationsFieldsMapping['last_name']] : null, |
|
414 | + "local_time_window_start" => isset($locationsFieldsMapping['local_time_window_start']) ? $rows[$locationsFieldsMapping['local_time_window_start']] : null, |
|
415 | + "local_time_window_end" => isset($locationsFieldsMapping['local_time_window_end']) ? $rows[$locationsFieldsMapping['local_time_window_end']] : null, |
|
416 | + "local_time_window_start_2" => isset($locationsFieldsMapping['local_time_window_start_2']) ? $rows[$locationsFieldsMapping['local_time_window_start_2']] : null, |
|
417 | + "local_time_window_end_2" => isset($locationsFieldsMapping['local_time_window_end_2']) ? $rows[$locationsFieldsMapping['local_time_window_end_2']] : null, |
|
418 | + "address_email" => isset($locationsFieldsMapping['address_email']) ? $rows[$locationsFieldsMapping['address_email']] : null, |
|
419 | + "address_country_id" => isset($locationsFieldsMapping['address_country_id']) ? $rows[$locationsFieldsMapping['address_country_id']] : null, |
|
420 | + "address_custom_data" => isset($locationsFieldsMapping['address_custom_data']) ? $rows[$locationsFieldsMapping['address_custom_data']] : null, |
|
421 | + "schedule_blacklist" => isset($locationsFieldsMapping['schedule_blacklist']) ? $rows[$locationsFieldsMapping['schedule_blacklist']] : null, |
|
422 | + "service_time" => isset($locationsFieldsMapping['service_time']) ? $rows[$locationsFieldsMapping['service_time']] : null, |
|
423 | + "local_timezone_string" => isset($locationsFieldsMapping['local_timezone_string']) ? $rows[$locationsFieldsMapping['local_timezone_string']] : null, |
|
424 | + "color" => isset($locationsFieldsMapping['color']) ? $rows[$locationsFieldsMapping['color']] : null, |
|
425 | + "address_icon" => isset($locationsFieldsMapping['address_icon']) ? $rows[$locationsFieldsMapping['address_icon']] : null, |
|
426 | + "address_stop_type" => isset($locationsFieldsMapping['address_stop_type']) ? $rows[$locationsFieldsMapping['address_stop_type']] : null, |
|
427 | + "address_cube" => isset($locationsFieldsMapping['address_cube']) ? $rows[$locationsFieldsMapping['address_cube']] : null, |
|
428 | + "address_pieces" => isset($locationsFieldsMapping['address_pieces']) ? $rows[$locationsFieldsMapping['address_pieces']] : null, |
|
429 | + "address_reference_no" => isset($locationsFieldsMapping['address_reference_no']) ? $rows[$locationsFieldsMapping['address_reference_no']] : null, |
|
430 | + "address_revenue" => isset($locationsFieldsMapping['address_revenue']) ? $rows[$locationsFieldsMapping['address_revenue']] : null, |
|
431 | + "address_weight" => isset($locationsFieldsMapping['address_weight']) ? $rows[$locationsFieldsMapping['address_weight']] : null, |
|
432 | + "address_priority" => isset($locationsFieldsMapping['address_priority']) ? $rows[$locationsFieldsMapping['address_priority']] : null, |
|
433 | + "address_customer_po" => isset($locationsFieldsMapping['address_customer_po']) ? $rows[$locationsFieldsMapping['address_customer_po']] : null, |
|
434 | + )); |
|
435 | 435 | |
436 | - $abContacts=new AddressBookLocation(); |
|
436 | + $abContacts=new AddressBookLocation(); |
|
437 | 437 | |
438 | - $abcResults=$abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
438 | + $abcResults=$abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
439 | 439 | |
440 | - array_push($results['success'],"The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
440 | + array_push($results['success'],"The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
441 | 441 | |
442 | - } |
|
442 | + } |
|
443 | 443 | |
444 | - } |
|
444 | + } |
|
445 | 445 | |
446 | - return $results; |
|
447 | - } |
|
446 | + return $results; |
|
447 | + } |
|
448 | 448 | |
449 | 449 | |
450 | 450 | } |
@@ -327,62 +327,62 @@ |
||
327 | 327 | |
328 | 328 | if ($mode!='daily') { |
329 | 329 | switch ($mode) { |
330 | - case 'weekly': |
|
331 | - if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
332 | - if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
333 | - $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
334 | - } |
|
335 | - else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $curSchedule="";} |
|
330 | + case 'weekly': |
|
331 | + if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
332 | + if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
333 | + $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
336 | 334 | } |
337 | - else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $curSchedule="";} |
|
338 | - break; |
|
339 | - case 'monthly': |
|
340 | - $monthlyMode=""; |
|
341 | - if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
342 | - if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
343 | - $monthlyMode=$rows[$locationsFieldsMapping['monthly_mode']]; |
|
344 | - $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
345 | - } |
|
346 | - else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $curSchedule="";} |
|
335 | + else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $curSchedule="";} |
|
336 | + } |
|
337 | + else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $curSchedule="";} |
|
338 | + break; |
|
339 | + case 'monthly': |
|
340 | + $monthlyMode=""; |
|
341 | + if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
342 | + if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
343 | + $monthlyMode=$rows[$locationsFieldsMapping['monthly_mode']]; |
|
344 | + $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
347 | 345 | } |
348 | - else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $curSchedule="";} |
|
346 | + else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $curSchedule="";} |
|
347 | + } |
|
348 | + else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $curSchedule="";} |
|
349 | 349 | |
350 | - if ($monthlyMode!="") { |
|
351 | - switch ($monthlyMode) { |
|
352 | - case 'dates': |
|
353 | - if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
354 | - if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
355 | - $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
356 | - } |
|
357 | - else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $curSchedule="";} |
|
358 | - } |
|
359 | - break; |
|
360 | - case 'nth': |
|
361 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
362 | - if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
363 | - $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
364 | - } |
|
365 | - else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $curSchedule="";} |
|
366 | - } |
|
367 | - else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $curSchedule="";} |
|
368 | - |
|
369 | - if ($curSchedule!="") { |
|
370 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
371 | - if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
372 | - $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
373 | - } |
|
374 | - else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $curSchedule="";} |
|
375 | - } |
|
376 | - else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $curSchedule="";} |
|
377 | - } |
|
350 | + if ($monthlyMode!="") { |
|
351 | + switch ($monthlyMode) { |
|
352 | + case 'dates': |
|
353 | + if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
354 | + if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
355 | + $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
356 | + } |
|
357 | + else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $curSchedule="";} |
|
358 | + } |
|
359 | + break; |
|
360 | + case 'nth': |
|
361 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
362 | + if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
363 | + $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
364 | + } |
|
365 | + else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $curSchedule="";} |
|
366 | + } |
|
367 | + else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $curSchedule="";} |
|
378 | 368 | |
379 | - break; |
|
369 | + if ($curSchedule!="") { |
|
370 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
371 | + if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
372 | + $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
380 | 373 | } |
374 | + else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $curSchedule="";} |
|
375 | + } |
|
376 | + else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $curSchedule="";} |
|
381 | 377 | } |
378 | + |
|
382 | 379 | break; |
383 | - default: |
|
384 | - $curSchedule==""; |
|
380 | + } |
|
381 | + } |
|
385 | 382 | break; |
383 | + default: |
|
384 | + $curSchedule==""; |
|
385 | + break; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | } |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | //public $offset; |
33 | 33 | //public $limit; |
34 | 34 | |
35 | - public function __construct () { } |
|
35 | + public function __construct() { } |
|
36 | 36 | |
37 | 37 | public static function fromArray(array $params) { |
38 | 38 | $addressbooklocation = new AddressBookLocation(); |
39 | - foreach($params as $key => $value) { |
|
39 | + foreach ($params as $key => $value) { |
|
40 | 40 | if (property_exists($addressbooklocation, $key)) { |
41 | 41 | $addressbooklocation->{$key} = $value; |
42 | 42 | } |
@@ -61,14 +61,14 @@ discard block |
||
61 | 61 | |
62 | 62 | public static function searchRoutedLocation($params) |
63 | 63 | { |
64 | - $result= Route4Me::makeRequst(array( |
|
64 | + $result = Route4Me::makeRequst(array( |
|
65 | 65 | 'url' => self::$apiUrl, |
66 | 66 | 'method' => 'GET', |
67 | 67 | 'query' => array( |
68 | - 'display' => isset($params['display']) ? $params['display']: null, |
|
69 | - 'query' => isset($params['query']) ? $params['query']: null, |
|
70 | - 'fields' => isset($params['fields']) ? $params['fields']: null, |
|
71 | - 'limit' => isset($params['limit']) ? $params['limit']: null, |
|
68 | + 'display' => isset($params['display']) ? $params['display'] : null, |
|
69 | + 'query' => isset($params['query']) ? $params['query'] : null, |
|
70 | + 'fields' => isset($params['fields']) ? $params['fields'] : null, |
|
71 | + 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
72 | 72 | 'offset' => isset($params['offset']) ? $params['offset'] : null, |
73 | 73 | ) |
74 | 74 | )); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'url' => self::$apiUrl, |
83 | 83 | 'method' => 'GET', |
84 | 84 | 'query' => array( |
85 | - 'limit' => isset($params->limit) ? $params->limit: null, |
|
85 | + 'limit' => isset($params->limit) ? $params->limit : null, |
|
86 | 86 | 'offset' => isset($params->offset) ? $params->offset : null, |
87 | 87 | ) |
88 | 88 | )); |
@@ -109,41 +109,41 @@ discard block |
||
109 | 109 | 'url' => self::$apiUrl, |
110 | 110 | 'method' => 'POST', |
111 | 111 | 'body' => array( |
112 | - 'address_1' => isset($params->address_1) ? $params->address_1: null, |
|
113 | - 'address_2' => isset($params->address_2) ? $params->address_2: null, |
|
114 | - 'address_alias' => isset($params->address_alias) ? $params->address_alias: null, |
|
112 | + 'address_1' => isset($params->address_1) ? $params->address_1 : null, |
|
113 | + 'address_2' => isset($params->address_2) ? $params->address_2 : null, |
|
114 | + 'address_alias' => isset($params->address_alias) ? $params->address_alias : null, |
|
115 | 115 | 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
116 | 116 | 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
117 | 117 | 'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null, |
118 | 118 | 'curbside_lng' => isset($params->curbside_lng) ? $params->curbside_lng : null, |
119 | - 'address_phone_number' => isset($params->address_phone_number) ? $params->address_phone_number: null, |
|
120 | - 'address_group' => isset($params->address_group) ? $params->address_group: null, |
|
121 | - 'first_name' => isset($params->first_name) ? $params->first_name: null, |
|
122 | - 'last_name' => isset($params->last_name) ? $params->last_name: null, |
|
123 | - 'local_time_window_start' => isset($params->local_time_window_start) ? $params->local_time_window_start: null, |
|
124 | - 'local_time_window_end' => isset($params->local_time_window_end) ? $params->local_time_window_end: null, |
|
125 | - 'local_time_window_start_2' => isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null, |
|
126 | - 'local_time_window_end_2' => isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null, |
|
127 | - 'address_email' => isset($params->address_email) ? $params->address_email: null, |
|
128 | - 'address_city' => isset($params->address_city) ? $params->address_city: null, |
|
129 | - 'address_state_id' => isset($params->address_state_id) ? $params->address_state_id: null, |
|
130 | - 'address_country_id' => isset($params->address_country_id) ? $params->address_country_id: null, |
|
131 | - 'address_zip' => isset($params->address_zip) ? $params->address_zip: null, |
|
132 | - 'address_custom_data' => isset($params->address_custom_data) ? $params->address_custom_data: null, |
|
133 | - 'schedule' => isset($params->schedule) ? $params->schedule: null, |
|
134 | - 'schedule_blacklist' => isset($params->schedule_blacklist) ? $params->schedule_blacklist: null, |
|
135 | - 'service_time' => isset($params->service_time) ? $params->service_time: null, |
|
136 | - 'local_timezone_string' => isset($params->local_timezone_string) ? $params->local_timezone_string: null, |
|
137 | - 'color' => isset($params->color) ? $params->color: null, |
|
138 | - 'address_icon' => isset($params->address_icon) ? $params->address_icon: null, |
|
139 | - 'address_stop_type' => isset($params->address_stop_type) ? $params->address_stop_type: null, |
|
140 | - 'address_cube' => isset($params->address_cube) ? $params->address_cube: null, |
|
141 | - 'address_pieces' => isset($params->address_pieces) ? $params->address_pieces: null, |
|
142 | - 'address_reference_no' => isset($params->address_reference_no) ? $params->address_reference_no: null, |
|
143 | - 'address_revenue' => isset($params->address_revenue) ? $params->address_revenue: null, |
|
144 | - 'address_weight' => isset($params->address_weight) ? $params->address_weight: null, |
|
145 | - 'address_priority' => isset($params->address_priority) ? $params->address_priority: null, |
|
146 | - 'address_customer_po' => isset($params->address_customer_po) ? $params->address_customer_po: null, |
|
119 | + 'address_phone_number' => isset($params->address_phone_number) ? $params->address_phone_number : null, |
|
120 | + 'address_group' => isset($params->address_group) ? $params->address_group : null, |
|
121 | + 'first_name' => isset($params->first_name) ? $params->first_name : null, |
|
122 | + 'last_name' => isset($params->last_name) ? $params->last_name : null, |
|
123 | + 'local_time_window_start' => isset($params->local_time_window_start) ? $params->local_time_window_start : null, |
|
124 | + 'local_time_window_end' => isset($params->local_time_window_end) ? $params->local_time_window_end : null, |
|
125 | + 'local_time_window_start_2' => isset($params->local_time_window_start_2) ? $params->local_time_window_start_2 : null, |
|
126 | + 'local_time_window_end_2' => isset($params->local_time_window_end_2) ? $params->local_time_window_end_2 : null, |
|
127 | + 'address_email' => isset($params->address_email) ? $params->address_email : null, |
|
128 | + 'address_city' => isset($params->address_city) ? $params->address_city : null, |
|
129 | + 'address_state_id' => isset($params->address_state_id) ? $params->address_state_id : null, |
|
130 | + 'address_country_id' => isset($params->address_country_id) ? $params->address_country_id : null, |
|
131 | + 'address_zip' => isset($params->address_zip) ? $params->address_zip : null, |
|
132 | + 'address_custom_data' => isset($params->address_custom_data) ? $params->address_custom_data : null, |
|
133 | + 'schedule' => isset($params->schedule) ? $params->schedule : null, |
|
134 | + 'schedule_blacklist' => isset($params->schedule_blacklist) ? $params->schedule_blacklist : null, |
|
135 | + 'service_time' => isset($params->service_time) ? $params->service_time : null, |
|
136 | + 'local_timezone_string' => isset($params->local_timezone_string) ? $params->local_timezone_string : null, |
|
137 | + 'color' => isset($params->color) ? $params->color : null, |
|
138 | + 'address_icon' => isset($params->address_icon) ? $params->address_icon : null, |
|
139 | + 'address_stop_type' => isset($params->address_stop_type) ? $params->address_stop_type : null, |
|
140 | + 'address_cube' => isset($params->address_cube) ? $params->address_cube : null, |
|
141 | + 'address_pieces' => isset($params->address_pieces) ? $params->address_pieces : null, |
|
142 | + 'address_reference_no' => isset($params->address_reference_no) ? $params->address_reference_no : null, |
|
143 | + 'address_revenue' => isset($params->address_revenue) ? $params->address_revenue : null, |
|
144 | + 'address_weight' => isset($params->address_weight) ? $params->address_weight : null, |
|
145 | + 'address_priority' => isset($params->address_priority) ? $params->address_priority : null, |
|
146 | + 'address_customer_po' => isset($params->address_customer_po) ? $params->address_customer_po : null, |
|
147 | 147 | ) |
148 | 148 | )); |
149 | 149 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | 'method' => 'ADD', |
184 | 184 | 'query' => array( |
185 | 185 | 'first_name' => isset($params->first_name) ? $params->first_name : null, |
186 | - 'address_1' => isset($params->address_1) ? $params->address_1: null, |
|
186 | + 'address_1' => isset($params->address_1) ? $params->address_1 : null, |
|
187 | 187 | 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
188 | 188 | 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
189 | 189 | ) |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | |
195 | 195 | public static function validateScheduleMode($scheduleMode) |
196 | 196 | { |
197 | - $schedMmodes=array("daily","weekly","monthly","annually"); |
|
197 | + $schedMmodes = array("daily", "weekly", "monthly", "annually"); |
|
198 | 198 | |
199 | 199 | if (in_array($scheduleMode, $schedMmodes)) return TRUE; else return FALSE; |
200 | 200 | } |
201 | 201 | |
202 | 202 | public static function validateScheduleEnable($scheduleEnabled) |
203 | 203 | { |
204 | - $schedEnambles=array(TRUE,FALSE); |
|
204 | + $schedEnambles = array(TRUE, FALSE); |
|
205 | 205 | |
206 | 206 | if (in_array($scheduleEnabled, $schedEnambles)) return TRUE; else return FALSE; |
207 | 207 | } |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | |
218 | 218 | if (sizeof($weekdays)<1) return FALSE; |
219 | 219 | |
220 | - $isValid=TRUE; |
|
220 | + $isValid = TRUE; |
|
221 | 221 | |
222 | - for ($i=0; $i < sizeof($weekdays); $i++) { |
|
222 | + for ($i = 0; $i<sizeof($weekdays); $i++) { |
|
223 | 223 | if (is_numeric($weekdays[$i])) { |
224 | - $wday=intval($weekdays[$i]); |
|
225 | - if ($wday<1 || $wday>7) $isValid=FALSE; |
|
224 | + $wday = intval($weekdays[$i]); |
|
225 | + if ($wday<1 || $wday>7) $isValid = FALSE; |
|
226 | 226 | } |
227 | - else $isValid=FALSE; |
|
227 | + else $isValid = FALSE; |
|
228 | 228 | } |
229 | 229 | //echo $scheduleWeekDays.' --- '. $isValid."<br>"; |
230 | 230 | return $isValid; |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
234 | 234 | { |
235 | - $schedMonthlyMmodes=array("dates","nth"); |
|
235 | + $schedMonthlyMmodes = array("dates", "nth"); |
|
236 | 236 | |
237 | 237 | if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) return TRUE; else return FALSE; |
238 | 238 | } |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | |
244 | 244 | if (sizeof($monthlyDates)<1) return FALSE; |
245 | 245 | |
246 | - $isValid=TRUE; |
|
246 | + $isValid = TRUE; |
|
247 | 247 | |
248 | - for ($i=0; $i < sizeof($monthlyDates); $i++) { |
|
248 | + for ($i = 0; $i<sizeof($monthlyDates); $i++) { |
|
249 | 249 | if (is_numeric($monthlyDates[$i])) { |
250 | - $mday=intval($monthlyDates[$i]); |
|
251 | - if ($mday<1 || $mday>31) $isValid=FALSE; |
|
250 | + $mday = intval($monthlyDates[$i]); |
|
251 | + if ($mday<1 || $mday>31) $isValid = FALSE; |
|
252 | 252 | } |
253 | - else $isValid=FALSE; |
|
253 | + else $isValid = FALSE; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | return $isValid; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | { |
261 | 261 | if (!is_numeric($scheduleNthN)) return FALSE; |
262 | 262 | |
263 | - $schedNthNs=array(1,2,3,4,5,-1); |
|
263 | + $schedNthNs = array(1, 2, 3, 4, 5, -1); |
|
264 | 264 | if (in_array($scheduleNthN, $schedNthNs)) return TRUE; else return FALSE; |
265 | 265 | } |
266 | 266 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | { |
269 | 269 | if (!is_numeric($scheduleNthWhat)) return FALSE; |
270 | 270 | |
271 | - $schedNthWhats=array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
271 | + $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
272 | 272 | if (in_array($scheduleNthWhat, $schedNthWhats)) return TRUE; else return FALSE; |
273 | 273 | } |
274 | 274 | |
@@ -279,50 +279,50 @@ discard block |
||
279 | 279 | public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping) |
280 | 280 | { |
281 | 281 | $max_line_length = 512; |
282 | - $delemietr=','; |
|
282 | + $delemietr = ','; |
|
283 | 283 | |
284 | - $results=array(); |
|
285 | - $results['fail']=array(); |
|
286 | - $results['success']=array(); |
|
284 | + $results = array(); |
|
285 | + $results['fail'] = array(); |
|
286 | + $results['success'] = array(); |
|
287 | 287 | |
288 | 288 | $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
289 | 289 | if (!empty($columns)) { |
290 | - array_push($results['fail'],'Empty CSV table'); |
|
290 | + array_push($results['fail'], 'Empty CSV table'); |
|
291 | 291 | return ($results); |
292 | 292 | } |
293 | 293 | |
294 | - $iRow=1; |
|
294 | + $iRow = 1; |
|
295 | 295 | |
296 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) { |
|
297 | - if ($rows[$locationsFieldsMapping['cached_lat']] && $rows[$locationsFieldsMapping['cached_lng']] && $rows[$locationsFieldsMapping['address_1']] && array(null) !== $rows) { |
|
298 | - $curSchedule=""; |
|
299 | - $mode=""; |
|
296 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
297 | + if ($rows[$locationsFieldsMapping['cached_lat']] && $rows[$locationsFieldsMapping['cached_lng']] && $rows[$locationsFieldsMapping['address_1']] && array(null)!==$rows) { |
|
298 | + $curSchedule = ""; |
|
299 | + $mode = ""; |
|
300 | 300 | |
301 | 301 | if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
302 | 302 | if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
303 | - $curSchedule='"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
304 | - $mode=$rows[$locationsFieldsMapping['schedule_mode']]; |
|
303 | + $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
304 | + $mode = $rows[$locationsFieldsMapping['schedule_mode']]; |
|
305 | 305 | } |
306 | - else {array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); $curSchedule="";} |
|
306 | + else {array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); $curSchedule = ""; } |
|
307 | 307 | } |
308 | - else {array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); $curSchedule="";} |
|
308 | + else {array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); $curSchedule = ""; } |
|
309 | 309 | |
310 | 310 | if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
311 | 311 | if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
312 | - $curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
312 | + $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
313 | 313 | } |
314 | - else {array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set "); $curSchedule="";} |
|
314 | + else {array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set "); $curSchedule = ""; } |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
318 | 318 | if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
319 | - $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
319 | + $curSchedule .= '"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
320 | 320 | if ($mode=='daily') { |
321 | - $curSchedule=trim($curSchedule,','); |
|
322 | - $curSchedule.='}'; |
|
321 | + $curSchedule = trim($curSchedule, ','); |
|
322 | + $curSchedule .= '}'; |
|
323 | 323 | } |
324 | 324 | } |
325 | - else {array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); $curSchedule=""; } |
|
325 | + else {array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); $curSchedule = ""; } |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | if ($mode!='daily') { |
@@ -330,50 +330,50 @@ discard block |
||
330 | 330 | case 'weekly': |
331 | 331 | if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
332 | 332 | if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
333 | - $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
333 | + $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
334 | 334 | } |
335 | - else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $curSchedule="";} |
|
335 | + else {array_push($results['fail'], "$iRow --> Wrong weekdays"); $curSchedule = ""; } |
|
336 | 336 | } |
337 | - else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $curSchedule="";} |
|
337 | + else {array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); $curSchedule = ""; } |
|
338 | 338 | break; |
339 | 339 | case 'monthly': |
340 | - $monthlyMode=""; |
|
340 | + $monthlyMode = ""; |
|
341 | 341 | if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
342 | 342 | if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
343 | - $monthlyMode=$rows[$locationsFieldsMapping['monthly_mode']]; |
|
344 | - $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
343 | + $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
344 | + $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
345 | 345 | } |
346 | - else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $curSchedule="";} |
|
346 | + else {array_push($results['fail'], "$iRow --> Wrong monthly mode"); $curSchedule = ""; } |
|
347 | 347 | } |
348 | - else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $curSchedule="";} |
|
348 | + else {array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); $curSchedule = ""; } |
|
349 | 349 | |
350 | 350 | if ($monthlyMode!="") { |
351 | 351 | switch ($monthlyMode) { |
352 | 352 | case 'dates': |
353 | 353 | if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
354 | 354 | if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
355 | - $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
355 | + $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
356 | 356 | } |
357 | - else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $curSchedule="";} |
|
357 | + else {array_push($results['fail'], "$iRow --> Wrong monthly dates"); $curSchedule = ""; } |
|
358 | 358 | } |
359 | 359 | break; |
360 | 360 | case 'nth': |
361 | 361 | if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
362 | 362 | if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
363 | - $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
363 | + $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
364 | 364 | } |
365 | - else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $curSchedule="";} |
|
365 | + else {array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); $curSchedule = ""; } |
|
366 | 366 | } |
367 | - else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $curSchedule="";} |
|
367 | + else {array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); $curSchedule = ""; } |
|
368 | 368 | |
369 | 369 | if ($curSchedule!="") { |
370 | 370 | if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
371 | 371 | if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
372 | - $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
372 | + $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
373 | 373 | } |
374 | - else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $curSchedule="";} |
|
374 | + else {array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); $curSchedule = ""; } |
|
375 | 375 | } |
376 | - else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $curSchedule="";} |
|
376 | + else {array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); $curSchedule = ""; } |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | break; |
@@ -387,15 +387,15 @@ discard block |
||
387 | 387 | |
388 | 388 | } |
389 | 389 | |
390 | - if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") {$iRow++; continue;} |
|
390 | + if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") {$iRow++; continue; } |
|
391 | 391 | |
392 | - $curSchedule=strtolower($curSchedule); |
|
392 | + $curSchedule = strtolower($curSchedule); |
|
393 | 393 | |
394 | - $curSchedule='[{'.$curSchedule.'}]'; |
|
394 | + $curSchedule = '[{'.$curSchedule.'}]'; |
|
395 | 395 | |
396 | - $oSchedule= json_decode($curSchedule,TRUE); |
|
396 | + $oSchedule = json_decode($curSchedule, TRUE); |
|
397 | 397 | |
398 | - $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
398 | + $AdressBookLocationParameters = AddressBookLocation::fromArray(array( |
|
399 | 399 | "cached_lat" => $rows[$locationsFieldsMapping['cached_lat']], |
400 | 400 | "cached_lng" => $rows[$locationsFieldsMapping['cached_lng']], |
401 | 401 | "curbside_lat" => isset($locationsFieldsMapping['curbside_lat']) ? $rows[$locationsFieldsMapping['curbside_lat']] : null, |
@@ -433,11 +433,11 @@ discard block |
||
433 | 433 | "address_customer_po" => isset($locationsFieldsMapping['address_customer_po']) ? $rows[$locationsFieldsMapping['address_customer_po']] : null, |
434 | 434 | )); |
435 | 435 | |
436 | - $abContacts=new AddressBookLocation(); |
|
436 | + $abContacts = new AddressBookLocation(); |
|
437 | 437 | |
438 | - $abcResults=$abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
438 | + $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
439 | 439 | |
440 | - array_push($results['success'],"The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
440 | + array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
441 | 441 | |
442 | 442 | } |
443 | 443 |
@@ -196,35 +196,52 @@ discard block |
||
196 | 196 | { |
197 | 197 | $schedMmodes=array("daily","weekly","monthly","annually"); |
198 | 198 | |
199 | - if (in_array($scheduleMode, $schedMmodes)) return TRUE; else return FALSE; |
|
199 | + if (in_array($scheduleMode, $schedMmodes)) { |
|
200 | + return TRUE; |
|
201 | + } else { |
|
202 | + return FALSE; |
|
203 | + } |
|
200 | 204 | } |
201 | 205 | |
202 | 206 | public static function validateScheduleEnable($scheduleEnabled) |
203 | 207 | { |
204 | 208 | $schedEnambles=array(TRUE,FALSE); |
205 | 209 | |
206 | - if (in_array($scheduleEnabled, $schedEnambles)) return TRUE; else return FALSE; |
|
210 | + if (in_array($scheduleEnabled, $schedEnambles)) { |
|
211 | + return TRUE; |
|
212 | + } else { |
|
213 | + return FALSE; |
|
214 | + } |
|
207 | 215 | } |
208 | 216 | |
209 | 217 | public static function validateScheduleEvery($scheduleEvery) |
210 | 218 | { |
211 | - if (is_numeric($scheduleEvery)) return TRUE; else return FALSE; |
|
219 | + if (is_numeric($scheduleEvery)) { |
|
220 | + return TRUE; |
|
221 | + } else { |
|
222 | + return FALSE; |
|
223 | + } |
|
212 | 224 | } |
213 | 225 | |
214 | 226 | public static function validateScheduleWeekDays($scheduleWeekDays) |
215 | 227 | { |
216 | 228 | $weekdays = explode(',', $scheduleWeekDays); |
217 | 229 | |
218 | - if (sizeof($weekdays)<1) return FALSE; |
|
230 | + if (sizeof($weekdays)<1) { |
|
231 | + return FALSE; |
|
232 | + } |
|
219 | 233 | |
220 | 234 | $isValid=TRUE; |
221 | 235 | |
222 | 236 | for ($i=0; $i < sizeof($weekdays); $i++) { |
223 | 237 | if (is_numeric($weekdays[$i])) { |
224 | 238 | $wday=intval($weekdays[$i]); |
225 | - if ($wday<1 || $wday>7) $isValid=FALSE; |
|
239 | + if ($wday<1 || $wday>7) { |
|
240 | + $isValid=FALSE; |
|
241 | + } |
|
242 | + } else { |
|
243 | + $isValid=FALSE; |
|
226 | 244 | } |
227 | - else $isValid=FALSE; |
|
228 | 245 | } |
229 | 246 | //echo $scheduleWeekDays.' --- '. $isValid."<br>"; |
230 | 247 | return $isValid; |
@@ -234,23 +251,32 @@ discard block |
||
234 | 251 | { |
235 | 252 | $schedMonthlyMmodes=array("dates","nth"); |
236 | 253 | |
237 | - if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) return TRUE; else return FALSE; |
|
254 | + if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) { |
|
255 | + return TRUE; |
|
256 | + } else { |
|
257 | + return FALSE; |
|
258 | + } |
|
238 | 259 | } |
239 | 260 | |
240 | 261 | public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
241 | 262 | { |
242 | 263 | $monthlyDates = explode(',', $scheduleMonthlyDates); |
243 | 264 | |
244 | - if (sizeof($monthlyDates)<1) return FALSE; |
|
265 | + if (sizeof($monthlyDates)<1) { |
|
266 | + return FALSE; |
|
267 | + } |
|
245 | 268 | |
246 | 269 | $isValid=TRUE; |
247 | 270 | |
248 | 271 | for ($i=0; $i < sizeof($monthlyDates); $i++) { |
249 | 272 | if (is_numeric($monthlyDates[$i])) { |
250 | 273 | $mday=intval($monthlyDates[$i]); |
251 | - if ($mday<1 || $mday>31) $isValid=FALSE; |
|
274 | + if ($mday<1 || $mday>31) { |
|
275 | + $isValid=FALSE; |
|
276 | + } |
|
277 | + } else { |
|
278 | + $isValid=FALSE; |
|
252 | 279 | } |
253 | - else $isValid=FALSE; |
|
254 | 280 | } |
255 | 281 | |
256 | 282 | return $isValid; |
@@ -258,18 +284,30 @@ discard block |
||
258 | 284 | |
259 | 285 | public static function validateScheduleNthN($scheduleNthN) |
260 | 286 | { |
261 | - if (!is_numeric($scheduleNthN)) return FALSE; |
|
287 | + if (!is_numeric($scheduleNthN)) { |
|
288 | + return FALSE; |
|
289 | + } |
|
262 | 290 | |
263 | 291 | $schedNthNs=array(1,2,3,4,5,-1); |
264 | - if (in_array($scheduleNthN, $schedNthNs)) return TRUE; else return FALSE; |
|
292 | + if (in_array($scheduleNthN, $schedNthNs)) { |
|
293 | + return TRUE; |
|
294 | + } else { |
|
295 | + return FALSE; |
|
296 | + } |
|
265 | 297 | } |
266 | 298 | |
267 | 299 | public static function validateScheduleNthWhat($scheduleNthWhat) |
268 | 300 | { |
269 | - if (!is_numeric($scheduleNthWhat)) return FALSE; |
|
301 | + if (!is_numeric($scheduleNthWhat)) { |
|
302 | + return FALSE; |
|
303 | + } |
|
270 | 304 | |
271 | 305 | $schedNthWhats=array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
272 | - if (in_array($scheduleNthWhat, $schedNthWhats)) return TRUE; else return FALSE; |
|
306 | + if (in_array($scheduleNthWhat, $schedNthWhats)) { |
|
307 | + return TRUE; |
|
308 | + } else { |
|
309 | + return FALSE; |
|
310 | + } |
|
273 | 311 | } |
274 | 312 | |
275 | 313 | /* Function adds the locations (with/without schedule) from the CSV file. |
@@ -302,16 +340,13 @@ discard block |
||
302 | 340 | if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
303 | 341 | $curSchedule='"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
304 | 342 | $mode=$rows[$locationsFieldsMapping['schedule_mode']]; |
305 | - } |
|
306 | - else {array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); $curSchedule="";} |
|
307 | - } |
|
308 | - else {array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); $curSchedule="";} |
|
343 | + } else {array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); $curSchedule="";} |
|
344 | + } else {array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); $curSchedule="";} |
|
309 | 345 | |
310 | 346 | if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
311 | 347 | if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
312 | 348 | $curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
313 | - } |
|
314 | - else {array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set "); $curSchedule="";} |
|
349 | + } else {array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set "); $curSchedule="";} |
|
315 | 350 | } |
316 | 351 | |
317 | 352 | if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
@@ -321,8 +356,7 @@ discard block |
||
321 | 356 | $curSchedule=trim($curSchedule,','); |
322 | 357 | $curSchedule.='}'; |
323 | 358 | } |
324 | - } |
|
325 | - else {array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); $curSchedule=""; } |
|
359 | + } else {array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); $curSchedule=""; } |
|
326 | 360 | } |
327 | 361 | |
328 | 362 | if ($mode!='daily') { |
@@ -331,10 +365,8 @@ discard block |
||
331 | 365 | if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
332 | 366 | if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
333 | 367 | $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
334 | - } |
|
335 | - else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $curSchedule="";} |
|
336 | - } |
|
337 | - else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $curSchedule="";} |
|
368 | + } else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $curSchedule="";} |
|
369 | + } else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $curSchedule="";} |
|
338 | 370 | break; |
339 | 371 | case 'monthly': |
340 | 372 | $monthlyMode=""; |
@@ -342,10 +374,8 @@ discard block |
||
342 | 374 | if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
343 | 375 | $monthlyMode=$rows[$locationsFieldsMapping['monthly_mode']]; |
344 | 376 | $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
345 | - } |
|
346 | - else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $curSchedule="";} |
|
347 | - } |
|
348 | - else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $curSchedule="";} |
|
377 | + } else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $curSchedule="";} |
|
378 | + } else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $curSchedule="";} |
|
349 | 379 | |
350 | 380 | if ($monthlyMode!="") { |
351 | 381 | switch ($monthlyMode) { |
@@ -353,27 +383,22 @@ discard block |
||
353 | 383 | if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
354 | 384 | if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
355 | 385 | $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
356 | - } |
|
357 | - else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $curSchedule="";} |
|
386 | + } else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $curSchedule="";} |
|
358 | 387 | } |
359 | 388 | break; |
360 | 389 | case 'nth': |
361 | 390 | if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
362 | 391 | if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
363 | 392 | $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
364 | - } |
|
365 | - else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $curSchedule="";} |
|
366 | - } |
|
367 | - else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $curSchedule="";} |
|
393 | + } else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $curSchedule="";} |
|
394 | + } else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $curSchedule="";} |
|
368 | 395 | |
369 | 396 | if ($curSchedule!="") { |
370 | 397 | if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
371 | 398 | if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
372 | 399 | $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
373 | - } |
|
374 | - else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $curSchedule="";} |
|
375 | - } |
|
376 | - else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $curSchedule="";} |
|
400 | + } else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $curSchedule="";} |
|
401 | + } else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $curSchedule="";} |
|
377 | 402 | } |
378 | 403 | |
379 | 404 | break; |
@@ -59,6 +59,9 @@ |
||
59 | 59 | return $order; |
60 | 60 | } |
61 | 61 | |
62 | + /** |
|
63 | + * @param Order $params |
|
64 | + */ |
|
62 | 65 | public static function addOrder($params) |
63 | 66 | { |
64 | 67 | $response = Route4Me::makeRequst(array( |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | static public $apiUrlOpt = '/api.v4/optimization_problem.php'; |
11 | 11 | |
12 | 12 | public $address_1; |
13 | - public $address_2; |
|
13 | + public $address_2; |
|
14 | 14 | public $cached_lat; |
15 | 15 | public $cached_lng; |
16 | - public $curbside_lat; |
|
17 | - public $curbside_lng; |
|
16 | + public $curbside_lat; |
|
17 | + public $curbside_lng; |
|
18 | 18 | public $address_alias; |
19 | 19 | public $address_city; |
20 | 20 | public $EXT_FIELD_first_name; |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | public $EXT_FIELD_phone; |
24 | 24 | public $EXT_FIELD_custom_data; |
25 | 25 | |
26 | - public $color; |
|
27 | - public $order_icon; |
|
28 | - public $local_time_window_start; |
|
29 | - public $local_time_window_end; |
|
30 | - public $local_time_window_start_2; |
|
31 | - public $local_time_window_end_2; |
|
32 | - public $service_time; |
|
26 | + public $color; |
|
27 | + public $order_icon; |
|
28 | + public $local_time_window_start; |
|
29 | + public $local_time_window_end; |
|
30 | + public $local_time_window_start_2; |
|
31 | + public $local_time_window_end_2; |
|
32 | + public $service_time; |
|
33 | 33 | |
34 | - public $day_scheduled_for_YYMMDD; |
|
34 | + public $day_scheduled_for_YYMMDD; |
|
35 | 35 | |
36 | 36 | public $route_id; |
37 | 37 | public $redirect; |
@@ -50,56 +50,56 @@ discard block |
||
50 | 50 | |
51 | 51 | public static function fromArray(array $params) { |
52 | 52 | $order= new Order(); |
53 | - foreach($params as $key => $value) { |
|
54 | - if (property_exists($order, $key)) { |
|
55 | - $order->{$key} = $value; |
|
56 | - } |
|
53 | + foreach($params as $key => $value) { |
|
54 | + if (property_exists($order, $key)) { |
|
55 | + $order->{$key} = $value; |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | return $order; |
60 | 60 | } |
61 | 61 | |
62 | 62 | public static function addOrder($params) |
63 | - { |
|
64 | - $response = Route4Me::makeRequst(array( |
|
65 | - 'url' => self::$apiUrl, |
|
66 | - 'method' => 'POST', |
|
67 | - 'body' => array( |
|
63 | + { |
|
64 | + $response = Route4Me::makeRequst(array( |
|
65 | + 'url' => self::$apiUrl, |
|
66 | + 'method' => 'POST', |
|
67 | + 'body' => array( |
|
68 | 68 | 'address_1' => isset($params->address_1) ? $params->address_1: null, |
69 | 69 | 'address_2' => isset($params->address_2) ? $params->address_2: null, |
70 | - 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
|
71 | - 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
|
72 | - 'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null, |
|
73 | - 'curbside_lng' => isset($params->curbside_lng) ? $params->curbside_lng : null, |
|
74 | - 'color' => isset($params->color) ? $params->color : null, |
|
75 | - 'order_icon' => isset($params->order_icon) ? $params->order_icon : null, |
|
76 | - 'day_scheduled_for_YYMMDD' => isset($params->day_scheduled_for_YYMMDD) ? $params->day_scheduled_for_YYMMDD : null, |
|
77 | - 'address_alias' => isset($params->address_alias) ? $params->address_alias : null, |
|
78 | - 'address_city' => isset($params->address_city) ? $params->address_city: null, |
|
79 | - 'local_time_window_start' => isset($params->local_time_window_start) ? $params->local_time_window_start: null, |
|
80 | - 'local_time_window_end' => isset($params->local_time_window_end) ? $params->local_time_window_end: null, |
|
81 | - 'local_time_window_start_2' => isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null, |
|
82 | - 'local_time_window_end_2' => isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null, |
|
83 | - 'service_time' => isset($params->service_time) ? $params->service_time: null, |
|
84 | - 'EXT_FIELD_first_name' => isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name: null, |
|
85 | - 'EXT_FIELD_last_name' => isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name: null, |
|
86 | - 'EXT_FIELD_email' => isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email: null, |
|
87 | - 'EXT_FIELD_phone' => isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone: null, |
|
88 | - 'EXT_FIELD_custom_data' => isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data: null, |
|
70 | + 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
|
71 | + 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
|
72 | + 'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null, |
|
73 | + 'curbside_lng' => isset($params->curbside_lng) ? $params->curbside_lng : null, |
|
74 | + 'color' => isset($params->color) ? $params->color : null, |
|
75 | + 'order_icon' => isset($params->order_icon) ? $params->order_icon : null, |
|
76 | + 'day_scheduled_for_YYMMDD' => isset($params->day_scheduled_for_YYMMDD) ? $params->day_scheduled_for_YYMMDD : null, |
|
77 | + 'address_alias' => isset($params->address_alias) ? $params->address_alias : null, |
|
78 | + 'address_city' => isset($params->address_city) ? $params->address_city: null, |
|
79 | + 'local_time_window_start' => isset($params->local_time_window_start) ? $params->local_time_window_start: null, |
|
80 | + 'local_time_window_end' => isset($params->local_time_window_end) ? $params->local_time_window_end: null, |
|
81 | + 'local_time_window_start_2' => isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null, |
|
82 | + 'local_time_window_end_2' => isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null, |
|
83 | + 'service_time' => isset($params->service_time) ? $params->service_time: null, |
|
84 | + 'EXT_FIELD_first_name' => isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name: null, |
|
85 | + 'EXT_FIELD_last_name' => isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name: null, |
|
86 | + 'EXT_FIELD_email' => isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email: null, |
|
87 | + 'EXT_FIELD_phone' => isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone: null, |
|
88 | + 'EXT_FIELD_custom_data' => isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data: null, |
|
89 | 89 | ) |
90 | - )); |
|
90 | + )); |
|
91 | 91 | |
92 | 92 | return $response; |
93 | 93 | } |
94 | 94 | |
95 | 95 | public static function addOrder2Route($params,$body) |
96 | - { |
|
97 | - $response = Route4Me::makeRequst(array( |
|
98 | - 'url' => self::$apiUrlRoute, |
|
99 | - 'method' => 'PUT', |
|
100 | - 'query' => array( |
|
96 | + { |
|
97 | + $response = Route4Me::makeRequst(array( |
|
98 | + 'url' => self::$apiUrlRoute, |
|
99 | + 'method' => 'PUT', |
|
100 | + 'query' => array( |
|
101 | 101 | 'route_id' => isset($params->route_id) ? $params->route_id: null, |
102 | - 'redirect' => isset($params->redirect) ? $params->redirect : null |
|
102 | + 'redirect' => isset($params->redirect) ? $params->redirect : null |
|
103 | 103 | ), |
104 | 104 | 'body' => (array)$body |
105 | 105 | )); |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | } |
109 | 109 | |
110 | 110 | public static function addOrder2Destination($params,$body) |
111 | - { |
|
112 | - $response = Route4Me::makeRequst(array( |
|
113 | - 'url' => self::$apiUrlOpt, |
|
114 | - 'method' => 'PUT', |
|
115 | - 'query' => array( |
|
111 | + { |
|
112 | + $response = Route4Me::makeRequst(array( |
|
113 | + 'url' => self::$apiUrlOpt, |
|
114 | + 'method' => 'PUT', |
|
115 | + 'query' => array( |
|
116 | 116 | 'optimization_problem_id' => isset($params->optimization_problem_id) ? $params->optimization_problem_id: null, |
117 | - 'redirect' => isset($params->redirect) ? $params->redirect : null |
|
117 | + 'redirect' => isset($params->redirect) ? $params->redirect : null |
|
118 | 118 | ), |
119 | 119 | 'body' => (array)$body |
120 | 120 | )); |
@@ -123,58 +123,58 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | public static function getOrder($params) |
126 | - { |
|
127 | - $response = Route4Me::makeRequst(array( |
|
128 | - 'url' => self::$apiUrl, |
|
129 | - 'method' => 'GET', |
|
130 | - 'query' => array( |
|
126 | + { |
|
127 | + $response = Route4Me::makeRequst(array( |
|
128 | + 'url' => self::$apiUrl, |
|
129 | + 'method' => 'GET', |
|
130 | + 'query' => array( |
|
131 | 131 | 'order_id' => isset($params->order_id) ? $params->order_id: null, |
132 | 132 | ) |
133 | - )); |
|
133 | + )); |
|
134 | 134 | |
135 | 135 | return $response; |
136 | 136 | } |
137 | 137 | |
138 | 138 | public static function getOrders() |
139 | - { |
|
140 | - $response = Route4Me::makeRequst(array( |
|
141 | - 'url' => self::$apiUrl, |
|
142 | - 'method' => 'GET' |
|
143 | - )); |
|
139 | + { |
|
140 | + $response = Route4Me::makeRequst(array( |
|
141 | + 'url' => self::$apiUrl, |
|
142 | + 'method' => 'GET' |
|
143 | + )); |
|
144 | 144 | |
145 | 145 | return $response; |
146 | 146 | } |
147 | 147 | |
148 | 148 | public static function removeOrder($params) |
149 | - { |
|
150 | - $response = Route4Me::makeRequst(array( |
|
151 | - 'url' => self::$apiUrl, |
|
152 | - 'method' => 'DELETE', |
|
153 | - 'body' => array( |
|
149 | + { |
|
150 | + $response = Route4Me::makeRequst(array( |
|
151 | + 'url' => self::$apiUrl, |
|
152 | + 'method' => 'DELETE', |
|
153 | + 'body' => array( |
|
154 | 154 | 'order_ids' => isset($params->order_ids) ? $params->order_ids: null |
155 | 155 | ) |
156 | - )); |
|
156 | + )); |
|
157 | 157 | |
158 | 158 | return $response; |
159 | 159 | } |
160 | 160 | |
161 | 161 | public static function updateOrder($body) |
162 | - { |
|
163 | - $response = Route4Me::makeRequst(array( |
|
164 | - 'url' => self::$apiUrl, |
|
165 | - 'method' => 'PUT', |
|
166 | - 'body' => (array)$body |
|
167 | - )); |
|
162 | + { |
|
163 | + $response = Route4Me::makeRequst(array( |
|
164 | + 'url' => self::$apiUrl, |
|
165 | + 'method' => 'PUT', |
|
166 | + 'body' => (array)$body |
|
167 | + )); |
|
168 | 168 | |
169 | 169 | return $response; |
170 | 170 | } |
171 | 171 | |
172 | 172 | public static function searchOrder($params) |
173 | - { |
|
174 | - $response = Route4Me::makeRequst(array( |
|
175 | - 'url' => self::$apiUrl, |
|
176 | - 'method' => 'GET', |
|
177 | - 'query' => array( |
|
173 | + { |
|
174 | + $response = Route4Me::makeRequst(array( |
|
175 | + 'url' => self::$apiUrl, |
|
176 | + 'method' => 'GET', |
|
177 | + 'query' => array( |
|
178 | 178 | 'day_added_YYMMDD' => isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null, |
179 | 179 | 'scheduled_for_YYMMDD' => isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null, |
180 | 180 | 'fields' => isset($params->fields) ? $params->fields: null, |
@@ -182,129 +182,129 @@ discard block |
||
182 | 182 | 'limit' => isset($params->limit) ? $params->limit: null, |
183 | 183 | 'query' => isset($params->query) ? $params->query: null, |
184 | 184 | ) |
185 | - )); |
|
185 | + )); |
|
186 | 186 | |
187 | 187 | return $response; |
188 | 188 | } |
189 | 189 | |
190 | - public static function validateLatitude($lat) |
|
191 | - { |
|
192 | - if (!is_numeric($lat)) return false; |
|
190 | + public static function validateLatitude($lat) |
|
191 | + { |
|
192 | + if (!is_numeric($lat)) return false; |
|
193 | 193 | |
194 | - if ($lat>90 || $lat<-90) return false; |
|
194 | + if ($lat>90 || $lat<-90) return false; |
|
195 | 195 | |
196 | - return true; |
|
197 | - } |
|
196 | + return true; |
|
197 | + } |
|
198 | 198 | |
199 | - public static function validateLongitude($lng) |
|
200 | - { |
|
201 | - if (!is_numeric($lng)) return false; |
|
199 | + public static function validateLongitude($lng) |
|
200 | + { |
|
201 | + if (!is_numeric($lng)) return false; |
|
202 | 202 | |
203 | - if ($lng>180 || $lng<-180) return false; |
|
203 | + if ($lng>180 || $lng<-180) return false; |
|
204 | 204 | |
205 | - return true; |
|
206 | - } |
|
205 | + return true; |
|
206 | + } |
|
207 | 207 | |
208 | - public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
209 | - { |
|
210 | - $max_line_length = 512; |
|
211 | - $delemietr=','; |
|
208 | + public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
209 | + { |
|
210 | + $max_line_length = 512; |
|
211 | + $delemietr=','; |
|
212 | 212 | |
213 | - $results=array(); |
|
214 | - $results['fail']=array(); |
|
215 | - $results['success']=array(); |
|
213 | + $results=array(); |
|
214 | + $results['fail']=array(); |
|
215 | + $results['success']=array(); |
|
216 | 216 | |
217 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
217 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
218 | 218 | |
219 | - if (!empty($columns)) { |
|
220 | - array_push($results['fail'],'Empty CSV table'); |
|
221 | - return ($results); |
|
222 | - } |
|
219 | + if (!empty($columns)) { |
|
220 | + array_push($results['fail'],'Empty CSV table'); |
|
221 | + return ($results); |
|
222 | + } |
|
223 | 223 | |
224 | - $iRow=1; |
|
224 | + $iRow=1; |
|
225 | 225 | |
226 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) { |
|
227 | - if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null) !== $rows) { |
|
226 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) { |
|
227 | + if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null) !== $rows) { |
|
228 | 228 | |
229 | - $cached_lat=0.000; |
|
229 | + $cached_lat=0.000; |
|
230 | 230 | |
231 | - if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) { |
|
232 | - array_push($results['fail'],"$iRow --> Wrong cached_lat"); |
|
233 | - $iRow++; |
|
234 | - continue; |
|
235 | - } |
|
236 | - else $cached_lat=doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
231 | + if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) { |
|
232 | + array_push($results['fail'],"$iRow --> Wrong cached_lat"); |
|
233 | + $iRow++; |
|
234 | + continue; |
|
235 | + } |
|
236 | + else $cached_lat=doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
237 | 237 | |
238 | - $cached_lng=0.000; |
|
238 | + $cached_lng=0.000; |
|
239 | 239 | |
240 | - if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) { |
|
241 | - array_push($results['fail'],"$iRow --> Wrong cached_lng"); |
|
242 | - $iRow++; |
|
243 | - continue; |
|
244 | - } |
|
245 | - else $cached_lng=doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
240 | + if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) { |
|
241 | + array_push($results['fail'],"$iRow --> Wrong cached_lng"); |
|
242 | + $iRow++; |
|
243 | + continue; |
|
244 | + } |
|
245 | + else $cached_lng=doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
246 | 246 | |
247 | - if (isset($ordersFieldsMapping['curbside_lat'])) { |
|
248 | - if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) { |
|
249 | - array_push($results['fail'],"$iRow --> Wrong curbside_lat"); |
|
250 | - $iRow++; |
|
251 | - continue; |
|
252 | - } |
|
253 | - } |
|
247 | + if (isset($ordersFieldsMapping['curbside_lat'])) { |
|
248 | + if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) { |
|
249 | + array_push($results['fail'],"$iRow --> Wrong curbside_lat"); |
|
250 | + $iRow++; |
|
251 | + continue; |
|
252 | + } |
|
253 | + } |
|
254 | 254 | |
255 | - if (isset($ordersFieldsMapping['curbside_lng'])) { |
|
256 | - if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) { |
|
257 | - array_push($results['fail'],"$iRow --> Wrong curbside_lng"); |
|
258 | - $iRow++; |
|
259 | - continue; |
|
260 | - } |
|
261 | - } |
|
255 | + if (isset($ordersFieldsMapping['curbside_lng'])) { |
|
256 | + if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) { |
|
257 | + array_push($results['fail'],"$iRow --> Wrong curbside_lng"); |
|
258 | + $iRow++; |
|
259 | + continue; |
|
260 | + } |
|
261 | + } |
|
262 | 262 | |
263 | - $address=$rows[$ordersFieldsMapping['address_1']]; |
|
263 | + $address=$rows[$ordersFieldsMapping['address_1']]; |
|
264 | 264 | |
265 | - if (isset($ordersFieldsMapping['order_city'])) $address.=', '.$rows[$ordersFieldsMapping['order_city']]; |
|
266 | - if (isset($ordersFieldsMapping['order_state_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
267 | - if (isset($ordersFieldsMapping['order_zip_code'])) $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
268 | - if (isset($ordersFieldsMapping['order_country_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
265 | + if (isset($ordersFieldsMapping['order_city'])) $address.=', '.$rows[$ordersFieldsMapping['order_city']]; |
|
266 | + if (isset($ordersFieldsMapping['order_state_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
267 | + if (isset($ordersFieldsMapping['order_zip_code'])) $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
268 | + if (isset($ordersFieldsMapping['order_country_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
269 | 269 | |
270 | - echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
270 | + echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
271 | 271 | |
272 | - $orderParameters = Order::fromArray(array( |
|
273 | - "cached_lat" => $cached_lat, |
|
274 | - "cached_lng" => $cached_lng, |
|
275 | - "curbside_lat" => isset($ordersFieldsMapping['curbside_lat']) ? $rows[$ordersFieldsMapping['curbside_lat']] : null, |
|
276 | - "curbside_lng" => isset($ordersFieldsMapping['curbside_lng']) ? $rows[$ordersFieldsMapping['curbside_lng']] : null, |
|
277 | - "color" => isset($ordersFieldsMapping['color']) ? $rows[$ordersFieldsMapping['color']] : null, |
|
278 | - "day_scheduled_for_YYMMDD" => isset($ordersFieldsMapping['day_scheduled_for_YYMMDD']) ? $rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']] : null, |
|
279 | - "address_alias" => isset($ordersFieldsMapping['address_alias']) ? $rows[$ordersFieldsMapping['address_alias']] : null, |
|
280 | - "address_1" => $address, |
|
281 | - "address_2" => isset($ordersFieldsMapping['address_2']) ? $rows[$ordersFieldsMapping['address_2']] : null, |
|
282 | - "local_time_window_start" => isset($ordersFieldsMapping['local_time_window_start']) ? $rows[$ordersFieldsMapping['local_time_window_start']] : null, |
|
283 | - "local_time_window_end" => isset($ordersFieldsMapping['local_time_window_end']) ? $rows[$ordersFieldsMapping['local_time_window_end']] : null, |
|
284 | - "local_time_window_start_2" => isset($ordersFieldsMapping['local_time_window_start_2']) ? $rows[$ordersFieldsMapping['local_time_window_start_2']] : null, |
|
285 | - "local_time_window_end_2" => isset($ordersFieldsMapping['local_time_window_end_2']) ? $rows[$ordersFieldsMapping['local_time_window_end_2']] : null, |
|
286 | - "service_time" => isset($ordersFieldsMapping['service_time']) ? $rows[$ordersFieldsMapping['service_time']] : null, |
|
287 | - "EXT_FIELD_first_name" => isset($ordersFieldsMapping['EXT_FIELD_first_name']) ? $rows[$ordersFieldsMapping['EXT_FIELD_first_name']] : null, |
|
288 | - "EXT_FIELD_last_name" => isset($ordersFieldsMapping['EXT_FIELD_last_name']) ? $rows[$ordersFieldsMapping['EXT_FIELD_last_name']] : null, |
|
289 | - "EXT_FIELD_email" => isset($ordersFieldsMapping['EXT_FIELD_email']) ? $rows[$ordersFieldsMapping['EXT_FIELD_email']] : null, |
|
290 | - "EXT_FIELD_phone" => isset($ordersFieldsMapping['EXT_FIELD_phone']) ? $rows[$ordersFieldsMapping['EXT_FIELD_phone']] : null, |
|
291 | - "EXT_FIELD_custom_data" => isset($ordersFieldsMapping['EXT_FIELD_custom_data']) ? $rows[$ordersFieldsMapping['EXT_FIELD_custom_data']] : null, |
|
292 | - "order_icon" => isset($ordersFieldsMapping['order_icon']) ? $rows[$ordersFieldsMapping['order_icon']] : null, |
|
293 | - )); |
|
272 | + $orderParameters = Order::fromArray(array( |
|
273 | + "cached_lat" => $cached_lat, |
|
274 | + "cached_lng" => $cached_lng, |
|
275 | + "curbside_lat" => isset($ordersFieldsMapping['curbside_lat']) ? $rows[$ordersFieldsMapping['curbside_lat']] : null, |
|
276 | + "curbside_lng" => isset($ordersFieldsMapping['curbside_lng']) ? $rows[$ordersFieldsMapping['curbside_lng']] : null, |
|
277 | + "color" => isset($ordersFieldsMapping['color']) ? $rows[$ordersFieldsMapping['color']] : null, |
|
278 | + "day_scheduled_for_YYMMDD" => isset($ordersFieldsMapping['day_scheduled_for_YYMMDD']) ? $rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']] : null, |
|
279 | + "address_alias" => isset($ordersFieldsMapping['address_alias']) ? $rows[$ordersFieldsMapping['address_alias']] : null, |
|
280 | + "address_1" => $address, |
|
281 | + "address_2" => isset($ordersFieldsMapping['address_2']) ? $rows[$ordersFieldsMapping['address_2']] : null, |
|
282 | + "local_time_window_start" => isset($ordersFieldsMapping['local_time_window_start']) ? $rows[$ordersFieldsMapping['local_time_window_start']] : null, |
|
283 | + "local_time_window_end" => isset($ordersFieldsMapping['local_time_window_end']) ? $rows[$ordersFieldsMapping['local_time_window_end']] : null, |
|
284 | + "local_time_window_start_2" => isset($ordersFieldsMapping['local_time_window_start_2']) ? $rows[$ordersFieldsMapping['local_time_window_start_2']] : null, |
|
285 | + "local_time_window_end_2" => isset($ordersFieldsMapping['local_time_window_end_2']) ? $rows[$ordersFieldsMapping['local_time_window_end_2']] : null, |
|
286 | + "service_time" => isset($ordersFieldsMapping['service_time']) ? $rows[$ordersFieldsMapping['service_time']] : null, |
|
287 | + "EXT_FIELD_first_name" => isset($ordersFieldsMapping['EXT_FIELD_first_name']) ? $rows[$ordersFieldsMapping['EXT_FIELD_first_name']] : null, |
|
288 | + "EXT_FIELD_last_name" => isset($ordersFieldsMapping['EXT_FIELD_last_name']) ? $rows[$ordersFieldsMapping['EXT_FIELD_last_name']] : null, |
|
289 | + "EXT_FIELD_email" => isset($ordersFieldsMapping['EXT_FIELD_email']) ? $rows[$ordersFieldsMapping['EXT_FIELD_email']] : null, |
|
290 | + "EXT_FIELD_phone" => isset($ordersFieldsMapping['EXT_FIELD_phone']) ? $rows[$ordersFieldsMapping['EXT_FIELD_phone']] : null, |
|
291 | + "EXT_FIELD_custom_data" => isset($ordersFieldsMapping['EXT_FIELD_custom_data']) ? $rows[$ordersFieldsMapping['EXT_FIELD_custom_data']] : null, |
|
292 | + "order_icon" => isset($ordersFieldsMapping['order_icon']) ? $rows[$ordersFieldsMapping['order_icon']] : null, |
|
293 | + )); |
|
294 | 294 | |
295 | - $order = new Order(); |
|
295 | + $order = new Order(); |
|
296 | 296 | |
297 | - $orderResults = $order->addOrder($orderParameters); |
|
297 | + $orderResults = $order->addOrder($orderParameters); |
|
298 | 298 | |
299 | - array_push($results['success'],"The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
300 | - } |
|
301 | - else { |
|
302 | - array_push($results['fail'],"$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
303 | - } |
|
299 | + array_push($results['success'],"The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
300 | + } |
|
301 | + else { |
|
302 | + array_push($results['fail'],"$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
303 | + } |
|
304 | 304 | |
305 | - $iRow++; |
|
306 | - } |
|
307 | - } |
|
305 | + $iRow++; |
|
306 | + } |
|
307 | + } |
|
308 | 308 | |
309 | 309 | } |
310 | 310 |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | public $limit; |
47 | 47 | public $query; |
48 | 48 | |
49 | - public function __construct () { } |
|
49 | + public function __construct() { } |
|
50 | 50 | |
51 | 51 | public static function fromArray(array $params) { |
52 | - $order= new Order(); |
|
53 | - foreach($params as $key => $value) { |
|
52 | + $order = new Order(); |
|
53 | + foreach ($params as $key => $value) { |
|
54 | 54 | if (property_exists($order, $key)) { |
55 | 55 | $order->{$key} = $value; |
56 | 56 | } |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | 'url' => self::$apiUrl, |
66 | 66 | 'method' => 'POST', |
67 | 67 | 'body' => array( |
68 | - 'address_1' => isset($params->address_1) ? $params->address_1: null, |
|
69 | - 'address_2' => isset($params->address_2) ? $params->address_2: null, |
|
68 | + 'address_1' => isset($params->address_1) ? $params->address_1 : null, |
|
69 | + 'address_2' => isset($params->address_2) ? $params->address_2 : null, |
|
70 | 70 | 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
71 | 71 | 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
72 | 72 | 'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null, |
@@ -75,30 +75,30 @@ discard block |
||
75 | 75 | 'order_icon' => isset($params->order_icon) ? $params->order_icon : null, |
76 | 76 | 'day_scheduled_for_YYMMDD' => isset($params->day_scheduled_for_YYMMDD) ? $params->day_scheduled_for_YYMMDD : null, |
77 | 77 | 'address_alias' => isset($params->address_alias) ? $params->address_alias : null, |
78 | - 'address_city' => isset($params->address_city) ? $params->address_city: null, |
|
79 | - 'local_time_window_start' => isset($params->local_time_window_start) ? $params->local_time_window_start: null, |
|
80 | - 'local_time_window_end' => isset($params->local_time_window_end) ? $params->local_time_window_end: null, |
|
81 | - 'local_time_window_start_2' => isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null, |
|
82 | - 'local_time_window_end_2' => isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null, |
|
83 | - 'service_time' => isset($params->service_time) ? $params->service_time: null, |
|
84 | - 'EXT_FIELD_first_name' => isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name: null, |
|
85 | - 'EXT_FIELD_last_name' => isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name: null, |
|
86 | - 'EXT_FIELD_email' => isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email: null, |
|
87 | - 'EXT_FIELD_phone' => isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone: null, |
|
88 | - 'EXT_FIELD_custom_data' => isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data: null, |
|
78 | + 'address_city' => isset($params->address_city) ? $params->address_city : null, |
|
79 | + 'local_time_window_start' => isset($params->local_time_window_start) ? $params->local_time_window_start : null, |
|
80 | + 'local_time_window_end' => isset($params->local_time_window_end) ? $params->local_time_window_end : null, |
|
81 | + 'local_time_window_start_2' => isset($params->local_time_window_start_2) ? $params->local_time_window_start_2 : null, |
|
82 | + 'local_time_window_end_2' => isset($params->local_time_window_end_2) ? $params->local_time_window_end_2 : null, |
|
83 | + 'service_time' => isset($params->service_time) ? $params->service_time : null, |
|
84 | + 'EXT_FIELD_first_name' => isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name : null, |
|
85 | + 'EXT_FIELD_last_name' => isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name : null, |
|
86 | + 'EXT_FIELD_email' => isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email : null, |
|
87 | + 'EXT_FIELD_phone' => isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone : null, |
|
88 | + 'EXT_FIELD_custom_data' => isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data : null, |
|
89 | 89 | ) |
90 | 90 | )); |
91 | 91 | |
92 | 92 | return $response; |
93 | 93 | } |
94 | 94 | |
95 | - public static function addOrder2Route($params,$body) |
|
95 | + public static function addOrder2Route($params, $body) |
|
96 | 96 | { |
97 | 97 | $response = Route4Me::makeRequst(array( |
98 | 98 | 'url' => self::$apiUrlRoute, |
99 | 99 | 'method' => 'PUT', |
100 | 100 | 'query' => array( |
101 | - 'route_id' => isset($params->route_id) ? $params->route_id: null, |
|
101 | + 'route_id' => isset($params->route_id) ? $params->route_id : null, |
|
102 | 102 | 'redirect' => isset($params->redirect) ? $params->redirect : null |
103 | 103 | ), |
104 | 104 | 'body' => (array)$body |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | return $response; |
108 | 108 | } |
109 | 109 | |
110 | - public static function addOrder2Destination($params,$body) |
|
110 | + public static function addOrder2Destination($params, $body) |
|
111 | 111 | { |
112 | 112 | $response = Route4Me::makeRequst(array( |
113 | 113 | 'url' => self::$apiUrlOpt, |
114 | 114 | 'method' => 'PUT', |
115 | 115 | 'query' => array( |
116 | - 'optimization_problem_id' => isset($params->optimization_problem_id) ? $params->optimization_problem_id: null, |
|
116 | + 'optimization_problem_id' => isset($params->optimization_problem_id) ? $params->optimization_problem_id : null, |
|
117 | 117 | 'redirect' => isset($params->redirect) ? $params->redirect : null |
118 | 118 | ), |
119 | 119 | 'body' => (array)$body |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | 'url' => self::$apiUrl, |
129 | 129 | 'method' => 'GET', |
130 | 130 | 'query' => array( |
131 | - 'order_id' => isset($params->order_id) ? $params->order_id: null, |
|
131 | + 'order_id' => isset($params->order_id) ? $params->order_id : null, |
|
132 | 132 | ) |
133 | 133 | )); |
134 | 134 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | 'url' => self::$apiUrl, |
152 | 152 | 'method' => 'DELETE', |
153 | 153 | 'body' => array( |
154 | - 'order_ids' => isset($params->order_ids) ? $params->order_ids: null |
|
154 | + 'order_ids' => isset($params->order_ids) ? $params->order_ids : null |
|
155 | 155 | ) |
156 | 156 | )); |
157 | 157 | |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | 'url' => self::$apiUrl, |
176 | 176 | 'method' => 'GET', |
177 | 177 | 'query' => array( |
178 | - 'day_added_YYMMDD' => isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null, |
|
179 | - 'scheduled_for_YYMMDD' => isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null, |
|
180 | - 'fields' => isset($params->fields) ? $params->fields: null, |
|
181 | - 'offset' => isset($params->offset) ? $params->offset: null, |
|
182 | - 'limit' => isset($params->limit) ? $params->limit: null, |
|
183 | - 'query' => isset($params->query) ? $params->query: null, |
|
178 | + 'day_added_YYMMDD' => isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD : null, |
|
179 | + 'scheduled_for_YYMMDD' => isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD : null, |
|
180 | + 'fields' => isset($params->fields) ? $params->fields : null, |
|
181 | + 'offset' => isset($params->offset) ? $params->offset : null, |
|
182 | + 'limit' => isset($params->limit) ? $params->limit : null, |
|
183 | + 'query' => isset($params->query) ? $params->query : null, |
|
184 | 184 | ) |
185 | 185 | )); |
186 | 186 | |
@@ -208,45 +208,45 @@ discard block |
||
208 | 208 | public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
209 | 209 | { |
210 | 210 | $max_line_length = 512; |
211 | - $delemietr=','; |
|
211 | + $delemietr = ','; |
|
212 | 212 | |
213 | - $results=array(); |
|
214 | - $results['fail']=array(); |
|
215 | - $results['success']=array(); |
|
213 | + $results = array(); |
|
214 | + $results['fail'] = array(); |
|
215 | + $results['success'] = array(); |
|
216 | 216 | |
217 | 217 | $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
218 | 218 | |
219 | 219 | if (!empty($columns)) { |
220 | - array_push($results['fail'],'Empty CSV table'); |
|
220 | + array_push($results['fail'], 'Empty CSV table'); |
|
221 | 221 | return ($results); |
222 | 222 | } |
223 | 223 | |
224 | - $iRow=1; |
|
224 | + $iRow = 1; |
|
225 | 225 | |
226 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) { |
|
227 | - if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null) !== $rows) { |
|
226 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
227 | + if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
|
228 | 228 | |
229 | - $cached_lat=0.000; |
|
229 | + $cached_lat = 0.000; |
|
230 | 230 | |
231 | 231 | if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) { |
232 | - array_push($results['fail'],"$iRow --> Wrong cached_lat"); |
|
232 | + array_push($results['fail'], "$iRow --> Wrong cached_lat"); |
|
233 | 233 | $iRow++; |
234 | 234 | continue; |
235 | 235 | } |
236 | - else $cached_lat=doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
236 | + else $cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
237 | 237 | |
238 | - $cached_lng=0.000; |
|
238 | + $cached_lng = 0.000; |
|
239 | 239 | |
240 | 240 | if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) { |
241 | - array_push($results['fail'],"$iRow --> Wrong cached_lng"); |
|
241 | + array_push($results['fail'], "$iRow --> Wrong cached_lng"); |
|
242 | 242 | $iRow++; |
243 | 243 | continue; |
244 | 244 | } |
245 | - else $cached_lng=doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
245 | + else $cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
246 | 246 | |
247 | 247 | if (isset($ordersFieldsMapping['curbside_lat'])) { |
248 | 248 | if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) { |
249 | - array_push($results['fail'],"$iRow --> Wrong curbside_lat"); |
|
249 | + array_push($results['fail'], "$iRow --> Wrong curbside_lat"); |
|
250 | 250 | $iRow++; |
251 | 251 | continue; |
252 | 252 | } |
@@ -254,18 +254,18 @@ discard block |
||
254 | 254 | |
255 | 255 | if (isset($ordersFieldsMapping['curbside_lng'])) { |
256 | 256 | if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) { |
257 | - array_push($results['fail'],"$iRow --> Wrong curbside_lng"); |
|
257 | + array_push($results['fail'], "$iRow --> Wrong curbside_lng"); |
|
258 | 258 | $iRow++; |
259 | 259 | continue; |
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
263 | - $address=$rows[$ordersFieldsMapping['address_1']]; |
|
263 | + $address = $rows[$ordersFieldsMapping['address_1']]; |
|
264 | 264 | |
265 | - if (isset($ordersFieldsMapping['order_city'])) $address.=', '.$rows[$ordersFieldsMapping['order_city']]; |
|
266 | - if (isset($ordersFieldsMapping['order_state_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
267 | - if (isset($ordersFieldsMapping['order_zip_code'])) $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
268 | - if (isset($ordersFieldsMapping['order_country_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
265 | + if (isset($ordersFieldsMapping['order_city'])) $address .= ', '.$rows[$ordersFieldsMapping['order_city']]; |
|
266 | + if (isset($ordersFieldsMapping['order_state_id'])) $address .= ', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
267 | + if (isset($ordersFieldsMapping['order_zip_code'])) $address .= ', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
268 | + if (isset($ordersFieldsMapping['order_country_id'])) $address .= ', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
269 | 269 | |
270 | 270 | echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
271 | 271 | |
@@ -296,10 +296,10 @@ discard block |
||
296 | 296 | |
297 | 297 | $orderResults = $order->addOrder($orderParameters); |
298 | 298 | |
299 | - array_push($results['success'],"The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
299 | + array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
300 | 300 | } |
301 | 301 | else { |
302 | - array_push($results['fail'],"$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
302 | + array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | $iRow++; |
@@ -189,18 +189,26 @@ discard block |
||
189 | 189 | |
190 | 190 | public static function validateLatitude($lat) |
191 | 191 | { |
192 | - if (!is_numeric($lat)) return false; |
|
192 | + if (!is_numeric($lat)) { |
|
193 | + return false; |
|
194 | + } |
|
193 | 195 | |
194 | - if ($lat>90 || $lat<-90) return false; |
|
196 | + if ($lat>90 || $lat<-90) { |
|
197 | + return false; |
|
198 | + } |
|
195 | 199 | |
196 | 200 | return true; |
197 | 201 | } |
198 | 202 | |
199 | 203 | public static function validateLongitude($lng) |
200 | 204 | { |
201 | - if (!is_numeric($lng)) return false; |
|
205 | + if (!is_numeric($lng)) { |
|
206 | + return false; |
|
207 | + } |
|
202 | 208 | |
203 | - if ($lng>180 || $lng<-180) return false; |
|
209 | + if ($lng>180 || $lng<-180) { |
|
210 | + return false; |
|
211 | + } |
|
204 | 212 | |
205 | 213 | return true; |
206 | 214 | } |
@@ -232,8 +240,9 @@ discard block |
||
232 | 240 | array_push($results['fail'],"$iRow --> Wrong cached_lat"); |
233 | 241 | $iRow++; |
234 | 242 | continue; |
243 | + } else { |
|
244 | + $cached_lat=doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
235 | 245 | } |
236 | - else $cached_lat=doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
237 | 246 | |
238 | 247 | $cached_lng=0.000; |
239 | 248 | |
@@ -241,8 +250,9 @@ discard block |
||
241 | 250 | array_push($results['fail'],"$iRow --> Wrong cached_lng"); |
242 | 251 | $iRow++; |
243 | 252 | continue; |
253 | + } else { |
|
254 | + $cached_lng=doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
244 | 255 | } |
245 | - else $cached_lng=doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
246 | 256 | |
247 | 257 | if (isset($ordersFieldsMapping['curbside_lat'])) { |
248 | 258 | if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) { |
@@ -262,10 +272,18 @@ discard block |
||
262 | 272 | |
263 | 273 | $address=$rows[$ordersFieldsMapping['address_1']]; |
264 | 274 | |
265 | - if (isset($ordersFieldsMapping['order_city'])) $address.=', '.$rows[$ordersFieldsMapping['order_city']]; |
|
266 | - if (isset($ordersFieldsMapping['order_state_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
267 | - if (isset($ordersFieldsMapping['order_zip_code'])) $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
268 | - if (isset($ordersFieldsMapping['order_country_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
275 | + if (isset($ordersFieldsMapping['order_city'])) { |
|
276 | + $address.=', '.$rows[$ordersFieldsMapping['order_city']]; |
|
277 | + } |
|
278 | + if (isset($ordersFieldsMapping['order_state_id'])) { |
|
279 | + $address.=', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
280 | + } |
|
281 | + if (isset($ordersFieldsMapping['order_zip_code'])) { |
|
282 | + $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
283 | + } |
|
284 | + if (isset($ordersFieldsMapping['order_country_id'])) { |
|
285 | + $address.=', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
286 | + } |
|
269 | 287 | |
270 | 288 | echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
271 | 289 | |
@@ -297,8 +315,7 @@ discard block |
||
297 | 315 | $orderResults = $order->addOrder($orderParameters); |
298 | 316 | |
299 | 317 | array_push($results['success'],"The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
300 | - } |
|
301 | - else { |
|
318 | + } else { |
|
302 | 319 | array_push($results['fail'],"$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
303 | 320 | } |
304 | 321 |