@@ -582,70 +582,70 @@ |
||
582 | 582 | |
583 | 583 | if ('daily' != $mode) { |
584 | 584 | switch ($mode) { |
585 | - case 'weekly': |
|
586 | - if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
587 | - if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
588 | - $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
589 | - } else { |
|
590 | - array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
591 | - } |
|
585 | + case 'weekly': |
|
586 | + if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
587 | + if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
588 | + $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
589 | + } else { |
|
590 | + array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
591 | + } |
|
592 | + } else { |
|
593 | + array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
594 | + } |
|
595 | + break; |
|
596 | + case 'monthly': |
|
597 | + $monthlyMode = ''; |
|
598 | + if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
599 | + if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
600 | + $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
601 | + $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
592 | 602 | } else { |
593 | - array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
603 | + array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
604 | + } |
|
605 | + } else { |
|
606 | + array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
607 | + } |
|
608 | + |
|
609 | + if ('' != $monthlyMode) { |
|
610 | + switch ($monthlyMode) { |
|
611 | + case 'dates': |
|
612 | + if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
613 | + if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
614 | + $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
615 | + } else { |
|
616 | + array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
617 | + } |
|
594 | 618 | } |
595 | 619 | break; |
596 | - case 'monthly': |
|
597 | - $monthlyMode = ''; |
|
598 | - if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
599 | - if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
600 | - $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
601 | - $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
602 | - } else { |
|
603 | - array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
604 | - } |
|
620 | + case 'nth': |
|
621 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
622 | + if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
623 | + $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
605 | 624 | } else { |
606 | - array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
625 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
626 | + } |
|
627 | + } else { |
|
628 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
607 | 629 | } |
608 | 630 | |
609 | - if ('' != $monthlyMode) { |
|
610 | - switch ($monthlyMode) { |
|
611 | - case 'dates': |
|
612 | - if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
613 | - if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
614 | - $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
615 | - } else { |
|
616 | - array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
617 | - } |
|
618 | - } |
|
619 | - break; |
|
620 | - case 'nth': |
|
621 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
622 | - if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
623 | - $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
624 | - } else { |
|
625 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
626 | - } |
|
627 | - } else { |
|
628 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
629 | - } |
|
630 | - |
|
631 | - if ('' != $curSchedule) { |
|
632 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_what']])) { |
|
633 | - if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_what']])) { |
|
634 | - $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_what']].'}}'; |
|
635 | - } else { |
|
636 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
637 | - } |
|
638 | - } else { |
|
639 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
640 | - } |
|
641 | - } |
|
642 | - break; |
|
631 | + if ('' != $curSchedule) { |
|
632 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_what']])) { |
|
633 | + if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_what']])) { |
|
634 | + $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_what']].'}}'; |
|
635 | + } else { |
|
636 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
643 | 637 | } |
638 | + } else { |
|
639 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
640 | + } |
|
644 | 641 | } |
645 | 642 | break; |
646 | - default: |
|
647 | - $curSchedule = ''; |
|
643 | + } |
|
644 | + } |
|
648 | 645 | break; |
646 | + default: |
|
647 | + $curSchedule = ''; |
|
648 | + break; |
|
649 | 649 | } |
650 | 650 | } |
651 | 651 |
@@ -209,16 +209,16 @@ |
||
209 | 209 | |
210 | 210 | foreach ($device->Attributes as $attr) { |
211 | 211 | switch ($attr->AttributeDisplayName) { |
212 | - case 'desc': |
|
213 | - $this->_doorName = $attr->Value; |
|
214 | - break; |
|
215 | - case 'doorstate': |
|
216 | - $this->_doorState = $attr->Value; |
|
217 | - // UpdatedTime is a timestamp in ms, so we truncate |
|
218 | - $this->_doorStateTime = (int) $attr->UpdatedTime / 1000; |
|
219 | - break; |
|
220 | - default: |
|
221 | - continue; |
|
212 | + case 'desc': |
|
213 | + $this->_doorName = $attr->Value; |
|
214 | + break; |
|
215 | + case 'doorstate': |
|
216 | + $this->_doorState = $attr->Value; |
|
217 | + // UpdatedTime is a timestamp in ms, so we truncate |
|
218 | + $this->_doorStateTime = (int) $attr->UpdatedTime / 1000; |
|
219 | + break; |
|
220 | + default: |
|
221 | + continue; |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | } |
@@ -119,44 +119,44 @@ |
||
119 | 119 | curl_setopt($ch, CURLOPT_POSTFIELDS, $body); |
120 | 120 | } else { |
121 | 121 | switch ($method) { |
122 | - case 'DELETE': |
|
123 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
124 | - break; |
|
125 | - case 'DELETEARRAY': |
|
126 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
127 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
128 | - break; |
|
129 | - case 'PUT': |
|
130 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
131 | - break; |
|
132 | - case 'POST': |
|
133 | - if (isset($body)) { |
|
134 | - if (isset($options['HTTPHEADER']) |
|
135 | - && strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
136 | - $bodyData = $body; |
|
137 | - } else { |
|
138 | - $bodyData = json_encode($body); |
|
139 | - } |
|
140 | - curl_setopt($ch, CURLOPT_POST, 1); |
|
141 | - curl_setopt($ch, CURLOPT_POSTREDIR, 7); |
|
142 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
143 | - } |
|
144 | - break; |
|
145 | - case 'ADD': |
|
146 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
147 | - break; |
|
148 | - case 'PATCH': |
|
149 | - if (isset($body)) { |
|
122 | + case 'DELETE': |
|
123 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
124 | + break; |
|
125 | + case 'DELETEARRAY': |
|
126 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
127 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
128 | + break; |
|
129 | + case 'PUT': |
|
130 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
131 | + break; |
|
132 | + case 'POST': |
|
133 | + if (isset($body)) { |
|
134 | + if (isset($options['HTTPHEADER']) |
|
135 | + && strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
136 | + $bodyData = $body; |
|
137 | + } else { |
|
150 | 138 | $bodyData = json_encode($body); |
151 | - if (isset($options['HTTPHEADER'])) { |
|
152 | - if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
153 | - $bodyData = $body; |
|
154 | - } |
|
139 | + } |
|
140 | + curl_setopt($ch, CURLOPT_POST, 1); |
|
141 | + curl_setopt($ch, CURLOPT_POSTREDIR, 7); |
|
142 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
143 | + } |
|
144 | + break; |
|
145 | + case 'ADD': |
|
146 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
147 | + break; |
|
148 | + case 'PATCH': |
|
149 | + if (isset($body)) { |
|
150 | + $bodyData = json_encode($body); |
|
151 | + if (isset($options['HTTPHEADER'])) { |
|
152 | + if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
153 | + $bodyData = $body; |
|
155 | 154 | } |
156 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); |
|
157 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
158 | 155 | } |
159 | - break; |
|
156 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); |
|
157 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
158 | + } |
|
159 | + break; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | if (is_numeric(array_search($method, ['DELETE', 'PUT']))) { |
@@ -221,18 +221,18 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | switch ($key) { |
224 | - case 'cached_lat': |
|
225 | - case 'curbside_lat': |
|
226 | - if ($coord[$key] > 90 || $coord[$key] < -90) { |
|
227 | - return false; |
|
228 | - } |
|
229 | - break; |
|
230 | - case 'cached_lng': |
|
231 | - case 'curbside_lng': |
|
232 | - if ($coord[$key] > 180 || $coord[$key] < -180) { |
|
233 | - return false; |
|
234 | - } |
|
235 | - break; |
|
224 | + case 'cached_lat': |
|
225 | + case 'curbside_lat': |
|
226 | + if ($coord[$key] > 90 || $coord[$key] < -90) { |
|
227 | + return false; |
|
228 | + } |
|
229 | + break; |
|
230 | + case 'cached_lng': |
|
231 | + case 'curbside_lng': |
|
232 | + if ($coord[$key] > 180 || $coord[$key] < -180) { |
|
233 | + return false; |
|
234 | + } |
|
235 | + break; |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | return true; |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | continue; |
275 | 275 | } else { |
276 | 276 | switch ($coord) { |
277 | - case 'cached_lat': |
|
278 | - $cached_lat = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
279 | - break; |
|
280 | - case 'cached_lng': |
|
281 | - $cached_lng = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
282 | - break; |
|
277 | + case 'cached_lat': |
|
278 | + $cached_lat = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
279 | + break; |
|
280 | + case 'cached_lng': |
|
281 | + $cached_lng = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
282 | + break; |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | } |