@@ -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 | |