@@ -143,6 +143,9 @@ |
||
143 | 143 | return null; |
144 | 144 | } |
145 | 145 | |
146 | + /** |
|
147 | + * @param AddressBookLocation $params |
|
148 | + */ |
|
146 | 149 | public static function addAdressBookLocation($params) |
147 | 150 | { |
148 | 151 | $body = array(); |
@@ -149,7 +149,9 @@ discard block |
||
149 | 149 | $abLocations = new AddressBookLocation(); |
150 | 150 | |
151 | 151 | foreach($params as $key => $value) { |
152 | - if ($key == "address_id") continue; |
|
152 | + if ($key == "address_id") { |
|
153 | + continue; |
|
154 | + } |
|
153 | 155 | if (property_exists($abLocations, $key)) { |
154 | 156 | if (isset($params->{$key})) { |
155 | 157 | $body[$key] = $params->{$key}; |
@@ -221,44 +223,52 @@ discard block |
||
221 | 223 | { |
222 | 224 | $schedMmodes = array("daily","weekly","monthly","annually"); |
223 | 225 | |
224 | - if (in_array($scheduleMode, $schedMmodes)) |
|
225 | - return TRUE; |
|
226 | - else |
|
227 | - return FALSE; |
|
226 | + if (in_array($scheduleMode, $schedMmodes)) { |
|
227 | + return TRUE; |
|
228 | + } else { |
|
229 | + return FALSE; |
|
230 | + } |
|
228 | 231 | } |
229 | 232 | |
230 | 233 | public static function validateScheduleEnable($scheduleEnabled) |
231 | 234 | { |
232 | 235 | $schedEnambles = array(TRUE,FALSE); |
233 | 236 | |
234 | - if (in_array($scheduleEnabled, $schedEnambles)) |
|
235 | - return TRUE; |
|
236 | - else |
|
237 | - return FALSE; |
|
237 | + if (in_array($scheduleEnabled, $schedEnambles)) { |
|
238 | + return TRUE; |
|
239 | + } else { |
|
240 | + return FALSE; |
|
241 | + } |
|
238 | 242 | } |
239 | 243 | |
240 | 244 | public static function validateScheduleEvery($scheduleEvery) |
241 | 245 | { |
242 | - if (is_numeric($scheduleEvery)) |
|
243 | - return TRUE; |
|
244 | - else |
|
245 | - return FALSE; |
|
246 | + if (is_numeric($scheduleEvery)) { |
|
247 | + return TRUE; |
|
248 | + } else { |
|
249 | + return FALSE; |
|
250 | + } |
|
246 | 251 | } |
247 | 252 | |
248 | 253 | public static function validateScheduleWeekDays($scheduleWeekDays) |
249 | 254 | { |
250 | 255 | $weekdays = explode(',', $scheduleWeekDays); |
251 | 256 | |
252 | - if (sizeof($weekdays) < 1) return FALSE; |
|
257 | + if (sizeof($weekdays) < 1) { |
|
258 | + return FALSE; |
|
259 | + } |
|
253 | 260 | |
254 | 261 | $isValid = TRUE; |
255 | 262 | |
256 | 263 | for ($i=0; $i < sizeof($weekdays); $i++) { |
257 | 264 | if (is_numeric($weekdays[$i])) { |
258 | 265 | $wday = intval($weekdays[$i]); |
259 | - if ($wday < 1 || $wday > 7) $isValid = FALSE; |
|
266 | + if ($wday < 1 || $wday > 7) { |
|
267 | + $isValid = FALSE; |
|
268 | + } |
|
269 | + } else { |
|
270 | + $isValid = FALSE; |
|
260 | 271 | } |
261 | - else $isValid = FALSE; |
|
262 | 272 | } |
263 | 273 | |
264 | 274 | return $isValid; |
@@ -268,26 +278,32 @@ discard block |
||
268 | 278 | { |
269 | 279 | $schedMonthlyMmodes = array("dates","nth"); |
270 | 280 | |
271 | - if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) |
|
272 | - return TRUE; |
|
273 | - else |
|
274 | - return FALSE; |
|
281 | + if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) { |
|
282 | + return TRUE; |
|
283 | + } else { |
|
284 | + return FALSE; |
|
285 | + } |
|
275 | 286 | } |
276 | 287 | |
277 | 288 | public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
278 | 289 | { |
279 | 290 | $monthlyDates = explode(',', $scheduleMonthlyDates); |
280 | 291 | |
281 | - if (sizeof($monthlyDates) <1) return FALSE; |
|
292 | + if (sizeof($monthlyDates) <1) { |
|
293 | + return FALSE; |
|
294 | + } |
|
282 | 295 | |
283 | 296 | $isValid = TRUE; |
284 | 297 | |
285 | 298 | for ($i=0; $i < sizeof($monthlyDates); $i++) { |
286 | 299 | if (is_numeric($monthlyDates[$i])) { |
287 | 300 | $mday = intval($monthlyDates[$i]); |
288 | - if ($mday <1 || $mday > 31) $isValid = FALSE; |
|
301 | + if ($mday <1 || $mday > 31) { |
|
302 | + $isValid = FALSE; |
|
303 | + } |
|
304 | + } else { |
|
305 | + $isValid = FALSE; |
|
289 | 306 | } |
290 | - else $isValid = FALSE; |
|
291 | 307 | } |
292 | 308 | |
293 | 309 | return $isValid; |
@@ -295,26 +311,32 @@ discard block |
||
295 | 311 | |
296 | 312 | public static function validateScheduleNthN($scheduleNthN) |
297 | 313 | { |
298 | - if (!is_numeric($scheduleNthN)) return FALSE; |
|
314 | + if (!is_numeric($scheduleNthN)) { |
|
315 | + return FALSE; |
|
316 | + } |
|
299 | 317 | |
300 | 318 | $schedNthNs = array(1,2,3,4,5,-1); |
301 | 319 | |
302 | - if (in_array($scheduleNthN, $schedNthNs)) |
|
303 | - return TRUE; |
|
304 | - else |
|
305 | - return FALSE; |
|
320 | + if (in_array($scheduleNthN, $schedNthNs)) { |
|
321 | + return TRUE; |
|
322 | + } else { |
|
323 | + return FALSE; |
|
324 | + } |
|
306 | 325 | } |
307 | 326 | |
308 | 327 | public static function validateScheduleNthWhat($scheduleNthWhat) |
309 | 328 | { |
310 | - if (!is_numeric($scheduleNthWhat)) return FALSE; |
|
329 | + if (!is_numeric($scheduleNthWhat)) { |
|
330 | + return FALSE; |
|
331 | + } |
|
311 | 332 | |
312 | 333 | $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
313 | 334 | |
314 | - if (in_array($scheduleNthWhat, $schedNthWhats)) |
|
315 | - return TRUE; |
|
316 | - else |
|
317 | - return FALSE; |
|
335 | + if (in_array($scheduleNthWhat, $schedNthWhats)) { |
|
336 | + return TRUE; |
|
337 | + } else { |
|
338 | + return FALSE; |
|
339 | + } |
|
318 | 340 | } |
319 | 341 | |
320 | 342 | /* Function adds the locations (with/without schedule) from the CSV file. |
@@ -71,6 +71,9 @@ |
||
71 | 71 | return $order; |
72 | 72 | } |
73 | 73 | |
74 | + /** |
|
75 | + * @param Order $params |
|
76 | + */ |
|
74 | 77 | public static function addOrder($params) |
75 | 78 | { |
76 | 79 | $response = Route4Me::makeRequst(array( |
@@ -185,8 +185,12 @@ discard block |
||
185 | 185 | |
186 | 186 | $orders = self::getOrders($params); |
187 | 187 | |
188 | - if (is_null($orders)) return null; |
|
189 | - if (!isset($orders['results'])) return null; |
|
188 | + if (is_null($orders)) { |
|
189 | + return null; |
|
190 | + } |
|
191 | + if (!isset($orders['results'])) { |
|
192 | + return null; |
|
193 | + } |
|
190 | 194 | |
191 | 195 | $randomIndex = rand(0, sizeof($orders['results'])-1); |
192 | 196 | |
@@ -201,8 +205,12 @@ discard block |
||
201 | 205 | |
202 | 206 | $orders = self::getOrders($params); |
203 | 207 | |
204 | - if (is_null($orders)) return null; |
|
205 | - if (!isset($orders['results'])) return null; |
|
208 | + if (is_null($orders)) { |
|
209 | + return null; |
|
210 | + } |
|
211 | + if (!isset($orders['results'])) { |
|
212 | + return null; |
|
213 | + } |
|
206 | 214 | |
207 | 215 | $randomIndex = rand(0, sizeof($orders['results'])-1); |
208 | 216 | |
@@ -255,18 +263,26 @@ discard block |
||
255 | 263 | |
256 | 264 | public static function validateLatitude($lat) |
257 | 265 | { |
258 | - if (!is_numeric($lat)) return false; |
|
266 | + if (!is_numeric($lat)) { |
|
267 | + return false; |
|
268 | + } |
|
259 | 269 | |
260 | - if ($lat>90 || $lat<-90) return false; |
|
270 | + if ($lat>90 || $lat<-90) { |
|
271 | + return false; |
|
272 | + } |
|
261 | 273 | |
262 | 274 | return true; |
263 | 275 | } |
264 | 276 | |
265 | 277 | public static function validateLongitude($lng) |
266 | 278 | { |
267 | - if (!is_numeric($lng)) return false; |
|
279 | + if (!is_numeric($lng)) { |
|
280 | + return false; |
|
281 | + } |
|
268 | 282 | |
269 | - if ($lng>180 || $lng<-180) return false; |
|
283 | + if ($lng>180 || $lng<-180) { |
|
284 | + return false; |
|
285 | + } |
|
270 | 286 | |
271 | 287 | return true; |
272 | 288 | } |
@@ -298,8 +314,9 @@ discard block |
||
298 | 314 | array_push($results['fail'],"$iRow --> Wrong cached_lat"); |
299 | 315 | $iRow++; |
300 | 316 | continue; |
317 | + } else { |
|
318 | + $cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
301 | 319 | } |
302 | - else $cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
303 | 320 | |
304 | 321 | $cached_lng = 0.000; |
305 | 322 | |
@@ -307,8 +324,9 @@ discard block |
||
307 | 324 | array_push($results['fail'],"$iRow --> Wrong cached_lng"); |
308 | 325 | $iRow++; |
309 | 326 | continue; |
327 | + } else { |
|
328 | + $cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
310 | 329 | } |
311 | - else $cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
312 | 330 | |
313 | 331 | if (isset($ordersFieldsMapping['curbside_lat'])) { |
314 | 332 | if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) { |
@@ -328,10 +346,18 @@ discard block |
||
328 | 346 | |
329 | 347 | $address = $rows[$ordersFieldsMapping['address_1']]; |
330 | 348 | |
331 | - if (isset($ordersFieldsMapping['order_city'])) $address.=', '.$rows[$ordersFieldsMapping['order_city']]; |
|
332 | - if (isset($ordersFieldsMapping['order_state_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
333 | - if (isset($ordersFieldsMapping['order_zip_code'])) $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
334 | - if (isset($ordersFieldsMapping['order_country_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
349 | + if (isset($ordersFieldsMapping['order_city'])) { |
|
350 | + $address.=', '.$rows[$ordersFieldsMapping['order_city']]; |
|
351 | + } |
|
352 | + if (isset($ordersFieldsMapping['order_state_id'])) { |
|
353 | + $address.=', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
354 | + } |
|
355 | + if (isset($ordersFieldsMapping['order_zip_code'])) { |
|
356 | + $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
357 | + } |
|
358 | + if (isset($ordersFieldsMapping['order_country_id'])) { |
|
359 | + $address.=', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
360 | + } |
|
335 | 361 | |
336 | 362 | echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
337 | 363 | |
@@ -374,8 +400,7 @@ discard block |
||
374 | 400 | $orderResults = $order->addOrder($orderParameters); |
375 | 401 | |
376 | 402 | array_push($results['success'],"The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
377 | - } |
|
378 | - else { |
|
403 | + } else { |
|
379 | 404 | array_push($results['fail'],"$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
380 | 405 | } |
381 | 406 |
@@ -200,6 +200,9 @@ |
||
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | + /** |
|
204 | + * @param \SimpleXMLElement $object |
|
205 | + */ |
|
203 | 206 | public static function object2array($object) |
204 | 207 | { |
205 | 208 | return @json_decode(@json_encode($object),1); |
@@ -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 = function_exists('curl_file_create') ? curl_file_create(realpath($fname)) : '@'.realpath($fname); |
46 | 50 | |
@@ -105,7 +109,9 @@ discard block |
||
105 | 109 | } |
106 | 110 | |
107 | 111 | if (isset($options['HTTPHEADERS'])) { |
108 | - foreach ($options['HTTPHEADERS'] As $header) $headers[]=$header; |
|
112 | + foreach ($options['HTTPHEADERS'] As $header) { |
|
113 | + $headers[]=$header; |
|
114 | + } |
|
109 | 115 | } |
110 | 116 | |
111 | 117 | $ch = curl_init(); |
@@ -158,7 +164,9 @@ discard block |
||
158 | 164 | if (isset($body)) { |
159 | 165 | $bodyData = json_encode($body); |
160 | 166 | if (isset($options['HTTPHEADER'])) { |
161 | - if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) $bodyData = $body; |
|
167 | + if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) { |
|
168 | + $bodyData = $body; |
|
169 | + } |
|
162 | 170 | } |
163 | 171 | |
164 | 172 | curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
@@ -186,14 +194,16 @@ discard block |
||
186 | 194 | if (200 == $code) { |
187 | 195 | if ($isxml) { |
188 | 196 | $json = $jxml; |
189 | - } else $json = json_decode($result, true); |
|
197 | + } else { |
|
198 | + $json = json_decode($result, true); |
|
199 | + } |
|
190 | 200 | |
191 | 201 | if (isset($json['errors'])) { |
192 | 202 | throw new ApiError(implode(', ', $json['errors'])); |
193 | 203 | } else { |
194 | 204 | return $json; |
195 | 205 | } |
196 | - } elseif (409 == $code) { |
|
206 | + } elseif (409 == $code) { |
|
197 | 207 | throw new ApiError('Wrong API key'); |
198 | 208 | } else { |
199 | 209 | throw new ApiError('Something wrong'); |
@@ -278,7 +288,9 @@ discard block |
||
278 | 288 | |
279 | 289 | if ($isxml) { |
280 | 290 | $json = $jxml; |
281 | - } else $json = json_decode($result, true); |
|
291 | + } else { |
|
292 | + $json = json_decode($result, true); |
|
293 | + } |
|
282 | 294 | |
283 | 295 | if (200 == $code) { |
284 | 296 | return $json; |
@@ -319,7 +331,9 @@ discard block |
||
319 | 331 | echo $key1." --> "."Object <br>"; |
320 | 332 | } |
321 | 333 | } else { |
322 | - if (!is_null($result1)) echo $key1." --> ".$result1."<br>"; |
|
334 | + if (!is_null($result1)) { |
|
335 | + echo $key1." --> ".$result1."<br>"; |
|
336 | + } |
|
323 | 337 | } |
324 | 338 | } |
325 | 339 | } |
@@ -334,7 +348,9 @@ discard block |
||
334 | 348 | echo $key." --> "."Object <br>"; |
335 | 349 | } |
336 | 350 | } else { |
337 | - if (!is_null($result)) echo $key." --> ".$result."<br>"; |
|
351 | + if (!is_null($result)) { |
|
352 | + echo $key." --> ".$result."<br>"; |
|
353 | + } |
|
338 | 354 | } |
339 | 355 | |
340 | 356 | } |
@@ -57,9 +57,10 @@ |
||
57 | 57 | |
58 | 58 | $result = $route->GetLastLocation($params); |
59 | 59 | |
60 | -if (isset($result->tracking_history)) |
|
61 | -foreach ($result->tracking_history as $history) { |
|
60 | +if (isset($result->tracking_history)) { |
|
61 | + foreach ($result->tracking_history as $history) { |
|
62 | 62 | echo "Speed --> ".$history['s']."<br>"; |
63 | +} |
|
63 | 64 | echo "course --> ".$history['d']."<br>"; |
64 | 65 | echo "Timestamp --> ".$history['ts_friendly']."<br>"; |
65 | 66 | echo "Latitude --> ".$history['lt']."<br>"; |
@@ -54,8 +54,7 @@ |
||
54 | 54 | if (is_string($value)) |
55 | 55 | { |
56 | 56 | echo $key." --> ".$value."<br>"; |
57 | - } |
|
58 | - else |
|
57 | + } else |
|
59 | 58 | { |
60 | 59 | echo "************ $key ************* <br>"; |
61 | 60 | Route4Me::simplePrint((array)$value, true); |
@@ -19,7 +19,8 @@ |
||
19 | 19 | |
20 | 20 | $fgResult = $fGeoCoding->forwardGeocoding($geocodingParameters); |
21 | 21 | |
22 | -if ($geocodingParameters['strExportFormat'] == 'json') |
|
22 | +if ($geocodingParameters['strExportFormat'] == 'json') { |
|
23 | 23 | Route4Me::simplePrint($fgResult); |
24 | -else |
|
24 | +} else { |
|
25 | 25 | Route4Me::simplePrint($fgResult['destination']); |
26 | +} |
@@ -24,7 +24,7 @@ |
||
24 | 24 | Route4Me::simplePrint($dest); |
25 | 25 | echo "<br>"; |
26 | 26 | } |
27 | -} else { |
|
27 | +} else { |
|
28 | 28 | foreach ($fgResult['destination'] as $dest) { |
29 | 29 | Route4Me::simplePrint($dest); |
30 | 30 | echo "<br>"; |
@@ -59,5 +59,7 @@ |
||
59 | 59 | echo "========== Notes ==================<br>"; |
60 | 60 | echo "note_id --> ".$note['note_id']."<br>"; |
61 | 61 | $content = isset($note['contents']) ? $note['contents'] : ""; |
62 | - if (strlen($content)>0) echo "contents --> $content"."<br>"; |
|
63 | -} |
|
62 | + if (strlen($content)>0) { |
|
63 | + echo "contents --> $content"."<br>"; |
|
64 | + } |
|
65 | + } |
@@ -24,8 +24,7 @@ |
||
24 | 24 | if (is_array($value)) |
25 | 25 | { |
26 | 26 | Route4Me::simplePrint($value); |
27 | - } |
|
28 | - else |
|
27 | + } else |
|
29 | 28 | { |
30 | 29 | echo "$key => $value <br>"; |
31 | 30 | } |