@@ -51,8 +51,7 @@ |
||
51 | 51 | if (is_string($value)) |
52 | 52 | { |
53 | 53 | echo $key." --> ".$value."<br>"; |
54 | - } |
|
55 | - else |
|
54 | + } else |
|
56 | 55 | { |
57 | 56 | echo "************ $key ************* <br>"; |
58 | 57 | Route4Me::simplePrint((array)$value); |
@@ -25,8 +25,7 @@ |
||
25 | 25 | if (is_array($value)) |
26 | 26 | { |
27 | 27 | Route4Me::simplePrint($value); |
28 | - } |
|
29 | - else |
|
28 | + } else |
|
30 | 29 | { |
31 | 30 | echo "$key => $value <br>"; |
32 | 31 | } |
@@ -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 |
@@ -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; |
@@ -49,7 +49,9 @@ |
||
49 | 49 | echo "========== Notes ==================<br>"; |
50 | 50 | echo "note_id --> ".$note['note_id']."<br>"; |
51 | 51 | $content = isset($note['contents']) ? $note['contents'] : ""; |
52 | - if (strlen($content)>0) echo "contents --> $content"."<br>"; |
|
52 | + if (strlen($content)>0) { |
|
53 | + echo "contents --> $content"."<br>"; |
|
54 | + } |
|
53 | 55 | } |
54 | 56 | |
55 | 57 | //var_dump($notes); |
@@ -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) { |
@@ -252,9 +252,12 @@ |
||
252 | 252 | if (is_array($rRoute)) |
253 | 253 | { |
254 | 254 | return $rRoute["route_id"]; |
255 | + } else { |
|
256 | + return null; |
|
255 | 257 | } |
256 | - else return null; |
|
257 | - } else return null; |
|
258 | + } else { |
|
259 | + return null; |
|
260 | + } |
|
258 | 261 | |
259 | 262 | |
260 | 263 | } |