@@ -6,333 +6,333 @@ |
||
6 | 6 | |
7 | 7 | class Order extends Common |
8 | 8 | { |
9 | - public $address_1; |
|
10 | - public $address_2; |
|
11 | - public $cached_lat; |
|
12 | - public $cached_lng; |
|
13 | - public $curbside_lat; |
|
14 | - public $curbside_lng; |
|
15 | - public $address_alias; |
|
16 | - public $address_city; |
|
17 | - public $EXT_FIELD_first_name; |
|
18 | - public $EXT_FIELD_last_name; |
|
19 | - public $EXT_FIELD_email; |
|
20 | - public $EXT_FIELD_phone; |
|
21 | - public $EXT_FIELD_custom_data; |
|
9 | + public $address_1; |
|
10 | + public $address_2; |
|
11 | + public $cached_lat; |
|
12 | + public $cached_lng; |
|
13 | + public $curbside_lat; |
|
14 | + public $curbside_lng; |
|
15 | + public $address_alias; |
|
16 | + public $address_city; |
|
17 | + public $EXT_FIELD_first_name; |
|
18 | + public $EXT_FIELD_last_name; |
|
19 | + public $EXT_FIELD_email; |
|
20 | + public $EXT_FIELD_phone; |
|
21 | + public $EXT_FIELD_custom_data; |
|
22 | 22 | |
23 | - public $color; |
|
24 | - public $order_icon; |
|
25 | - public $local_time_window_start; |
|
26 | - public $local_time_window_end; |
|
27 | - public $local_time_window_start_2; |
|
28 | - public $local_time_window_end_2; |
|
29 | - public $service_time; |
|
23 | + public $color; |
|
24 | + public $order_icon; |
|
25 | + public $local_time_window_start; |
|
26 | + public $local_time_window_end; |
|
27 | + public $local_time_window_start_2; |
|
28 | + public $local_time_window_end_2; |
|
29 | + public $service_time; |
|
30 | 30 | |
31 | - public $day_scheduled_for_YYMMDD; |
|
31 | + public $day_scheduled_for_YYMMDD; |
|
32 | 32 | |
33 | - public $route_id; |
|
34 | - public $redirect; |
|
35 | - public $optimization_problem_id; |
|
36 | - public $order_id; |
|
37 | - public $order_ids; |
|
33 | + public $route_id; |
|
34 | + public $redirect; |
|
35 | + public $optimization_problem_id; |
|
36 | + public $order_id; |
|
37 | + public $order_ids; |
|
38 | 38 | |
39 | - public $day_added_YYMMDD; |
|
40 | - public $scheduled_for_YYMMDD; |
|
41 | - public $fields; |
|
42 | - public $offset; |
|
43 | - public $limit; |
|
44 | - public $query; |
|
39 | + public $day_added_YYMMDD; |
|
40 | + public $scheduled_for_YYMMDD; |
|
41 | + public $fields; |
|
42 | + public $offset; |
|
43 | + public $limit; |
|
44 | + public $query; |
|
45 | 45 | |
46 | - public $created_timestamp; |
|
47 | - public $order_status_id; |
|
48 | - public $member_id; |
|
49 | - public $address_state_id; |
|
50 | - public $address_country_id; |
|
51 | - public $address_zip; |
|
52 | - public $in_route_count; |
|
53 | - public $last_visited_timestamp; |
|
54 | - public $last_routed_timestamp; |
|
55 | - public $local_timezone_string; |
|
56 | - public $is_validated; |
|
57 | - public $is_pending; |
|
58 | - public $is_accepted; |
|
59 | - public $is_started; |
|
60 | - public $is_completed; |
|
61 | - public $custom_user_fields; |
|
46 | + public $created_timestamp; |
|
47 | + public $order_status_id; |
|
48 | + public $member_id; |
|
49 | + public $address_state_id; |
|
50 | + public $address_country_id; |
|
51 | + public $address_zip; |
|
52 | + public $in_route_count; |
|
53 | + public $last_visited_timestamp; |
|
54 | + public $last_routed_timestamp; |
|
55 | + public $local_timezone_string; |
|
56 | + public $is_validated; |
|
57 | + public $is_pending; |
|
58 | + public $is_accepted; |
|
59 | + public $is_started; |
|
60 | + public $is_completed; |
|
61 | + public $custom_user_fields; |
|
62 | 62 | |
63 | - public $addresses = array(); |
|
63 | + public $addresses = array(); |
|
64 | 64 | |
65 | - public static function fromArray(array $params) { |
|
66 | - $order = new Order(); |
|
67 | - foreach ($params as $key => $value) { |
|
68 | - if (property_exists($order, $key)) { |
|
69 | - $order->{$key} = $value; |
|
70 | - } |
|
71 | - } |
|
65 | + public static function fromArray(array $params) { |
|
66 | + $order = new Order(); |
|
67 | + foreach ($params as $key => $value) { |
|
68 | + if (property_exists($order, $key)) { |
|
69 | + $order->{$key} = $value; |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | - return $order; |
|
74 | - } |
|
73 | + return $order; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param Order $params |
|
78 | - */ |
|
79 | - public static function addOrder($params) |
|
80 | - { |
|
81 | - $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', 'order_id', |
|
82 | - 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
76 | + /** |
|
77 | + * @param Order $params |
|
78 | + */ |
|
79 | + public static function addOrder($params) |
|
80 | + { |
|
81 | + $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', 'order_id', |
|
82 | + 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
83 | 83 | |
84 | - $allBodyFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
84 | + $allBodyFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
85 | 85 | |
86 | - $response = Route4Me::makeRequst(array( |
|
87 | - 'url' => Endpoint::ORDER_V4, |
|
88 | - 'method' => 'POST', |
|
89 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
90 | - )); |
|
86 | + $response = Route4Me::makeRequst(array( |
|
87 | + 'url' => Endpoint::ORDER_V4, |
|
88 | + 'method' => 'POST', |
|
89 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
90 | + )); |
|
91 | 91 | |
92 | - return $response; |
|
93 | - } |
|
92 | + return $response; |
|
93 | + } |
|
94 | 94 | |
95 | - public static function addOrder2Route($params) |
|
96 | - { |
|
97 | - $allQueryFields = array('route_id', 'redirect'); |
|
98 | - $allBodyFields = array('addresses'); |
|
95 | + public static function addOrder2Route($params) |
|
96 | + { |
|
97 | + $allQueryFields = array('route_id', 'redirect'); |
|
98 | + $allBodyFields = array('addresses'); |
|
99 | 99 | |
100 | - $response = Route4Me::makeRequst(array( |
|
101 | - 'url' => Endpoint::ROUTE_V4, |
|
102 | - 'method' => 'PUT', |
|
103 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
104 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
105 | - )); |
|
100 | + $response = Route4Me::makeRequst(array( |
|
101 | + 'url' => Endpoint::ROUTE_V4, |
|
102 | + 'method' => 'PUT', |
|
103 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
104 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
105 | + )); |
|
106 | 106 | |
107 | - return $response; |
|
108 | - } |
|
107 | + return $response; |
|
108 | + } |
|
109 | 109 | |
110 | - public static function addOrder2Optimization($params) |
|
111 | - { |
|
112 | - $allQueryFields = array('optimization_problem_id', 'redirect', 'device_type'); |
|
113 | - $allBodyFields = array('addresses'); |
|
110 | + public static function addOrder2Optimization($params) |
|
111 | + { |
|
112 | + $allQueryFields = array('optimization_problem_id', 'redirect', 'device_type'); |
|
113 | + $allBodyFields = array('addresses'); |
|
114 | 114 | |
115 | - $response = Route4Me::makeRequst(array( |
|
116 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
117 | - 'method' => 'PUT', |
|
118 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
119 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
120 | - )); |
|
115 | + $response = Route4Me::makeRequst(array( |
|
116 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
117 | + 'method' => 'PUT', |
|
118 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
119 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
120 | + )); |
|
121 | 121 | |
122 | - return $response; |
|
123 | - } |
|
122 | + return $response; |
|
123 | + } |
|
124 | 124 | |
125 | - public static function getOrder($params) |
|
126 | - { |
|
127 | - $allQueryFields = array('order_id', 'fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit'); |
|
125 | + public static function getOrder($params) |
|
126 | + { |
|
127 | + $allQueryFields = array('order_id', 'fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit'); |
|
128 | 128 | |
129 | - $response = Route4Me::makeRequst(array( |
|
130 | - 'url' => Endpoint::ORDER_V4, |
|
131 | - 'method' => 'GET', |
|
132 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
133 | - )); |
|
129 | + $response = Route4Me::makeRequst(array( |
|
130 | + 'url' => Endpoint::ORDER_V4, |
|
131 | + 'method' => 'GET', |
|
132 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
133 | + )); |
|
134 | 134 | |
135 | - return $response; |
|
136 | - } |
|
135 | + return $response; |
|
136 | + } |
|
137 | 137 | |
138 | - public static function getOrders($params) |
|
139 | - { |
|
140 | - $allQueryFields = array('offset', 'limit'); |
|
138 | + public static function getOrders($params) |
|
139 | + { |
|
140 | + $allQueryFields = array('offset', 'limit'); |
|
141 | 141 | |
142 | - $response = Route4Me::makeRequst(array( |
|
143 | - 'url' => Endpoint::ORDER_V4, |
|
144 | - 'method' => 'GET', |
|
145 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
146 | - )); |
|
142 | + $response = Route4Me::makeRequst(array( |
|
143 | + 'url' => Endpoint::ORDER_V4, |
|
144 | + 'method' => 'GET', |
|
145 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
146 | + )); |
|
147 | 147 | |
148 | - return $response; |
|
149 | - } |
|
148 | + return $response; |
|
149 | + } |
|
150 | 150 | |
151 | - public function getRandomOrderId($offset, $limit) |
|
152 | - { |
|
153 | - $randomOrder = $this->getRandomOrder($offset, $limit); |
|
151 | + public function getRandomOrderId($offset, $limit) |
|
152 | + { |
|
153 | + $randomOrder = $this->getRandomOrder($offset, $limit); |
|
154 | 154 | |
155 | - if (is_null($randomOrder)) { |
|
156 | - return null; |
|
157 | - } |
|
155 | + if (is_null($randomOrder)) { |
|
156 | + return null; |
|
157 | + } |
|
158 | 158 | |
159 | - if (!isset($randomOrder)) { |
|
160 | - return null; |
|
161 | - } |
|
159 | + if (!isset($randomOrder)) { |
|
160 | + return null; |
|
161 | + } |
|
162 | 162 | |
163 | - return $randomOrder['order_id']; |
|
164 | - } |
|
163 | + return $randomOrder['order_id']; |
|
164 | + } |
|
165 | 165 | |
166 | - public function getRandomOrder($offset, $limit) |
|
167 | - { |
|
168 | - $params = array('offset' => $offset, 'limit' => $limit); |
|
166 | + public function getRandomOrder($offset, $limit) |
|
167 | + { |
|
168 | + $params = array('offset' => $offset, 'limit' => $limit); |
|
169 | 169 | |
170 | - $orders = self::getOrders($params); |
|
170 | + $orders = self::getOrders($params); |
|
171 | 171 | |
172 | - if (is_null($orders)) { |
|
173 | - return null; |
|
174 | - } |
|
172 | + if (is_null($orders)) { |
|
173 | + return null; |
|
174 | + } |
|
175 | 175 | |
176 | - if (!isset($orders['results'])) { |
|
177 | - return null; |
|
178 | - } |
|
176 | + if (!isset($orders['results'])) { |
|
177 | + return null; |
|
178 | + } |
|
179 | 179 | |
180 | - $randomIndex = rand(0, sizeof($orders['results']) - 1); |
|
180 | + $randomIndex = rand(0, sizeof($orders['results']) - 1); |
|
181 | 181 | |
182 | - $order = $orders['results'][$randomIndex]; |
|
182 | + $order = $orders['results'][$randomIndex]; |
|
183 | 183 | |
184 | - return $order; |
|
185 | - } |
|
184 | + return $order; |
|
185 | + } |
|
186 | 186 | |
187 | - public static function removeOrder($params) |
|
188 | - { |
|
189 | - $allBodyFields = array('order_ids'); |
|
187 | + public static function removeOrder($params) |
|
188 | + { |
|
189 | + $allBodyFields = array('order_ids'); |
|
190 | 190 | |
191 | - $response = Route4Me::makeRequst(array( |
|
192 | - 'url' => Endpoint::ORDER_V4, |
|
193 | - 'method' => 'DELETE', |
|
194 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
195 | - )); |
|
191 | + $response = Route4Me::makeRequst(array( |
|
192 | + 'url' => Endpoint::ORDER_V4, |
|
193 | + 'method' => 'DELETE', |
|
194 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
195 | + )); |
|
196 | 196 | |
197 | - return $response; |
|
198 | - } |
|
197 | + return $response; |
|
198 | + } |
|
199 | 199 | |
200 | - public static function updateOrder($params) |
|
201 | - { |
|
202 | - $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', |
|
203 | - 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
200 | + public static function updateOrder($params) |
|
201 | + { |
|
202 | + $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', |
|
203 | + 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
204 | 204 | |
205 | - $allBodyFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
205 | + $allBodyFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
206 | 206 | |
207 | - $response = Route4Me::makeRequst(array( |
|
208 | - 'url' => Endpoint::ORDER_V4, |
|
209 | - 'method' => 'PUT', |
|
210 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
211 | - )); |
|
207 | + $response = Route4Me::makeRequst(array( |
|
208 | + 'url' => Endpoint::ORDER_V4, |
|
209 | + 'method' => 'PUT', |
|
210 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
211 | + )); |
|
212 | 212 | |
213 | - return $response; |
|
214 | - } |
|
213 | + return $response; |
|
214 | + } |
|
215 | 215 | |
216 | - public static function searchOrder($params) |
|
217 | - { |
|
218 | - $allQueryFields = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
216 | + public static function searchOrder($params) |
|
217 | + { |
|
218 | + $allQueryFields = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
219 | 219 | |
220 | - $response = Route4Me::makeRequst(array( |
|
221 | - 'url' => Endpoint::ORDER_V4, |
|
222 | - 'method' => 'GET', |
|
223 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
224 | - )); |
|
220 | + $response = Route4Me::makeRequst(array( |
|
221 | + 'url' => Endpoint::ORDER_V4, |
|
222 | + 'method' => 'GET', |
|
223 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
224 | + )); |
|
225 | 225 | |
226 | - return $response; |
|
227 | - } |
|
226 | + return $response; |
|
227 | + } |
|
228 | 228 | |
229 | - public static function validateCoordinate($coord) |
|
230 | - { |
|
231 | - $key = key($coord); |
|
229 | + public static function validateCoordinate($coord) |
|
230 | + { |
|
231 | + $key = key($coord); |
|
232 | 232 | |
233 | - if (!is_numeric($coord[$key])) { |
|
234 | - return false; |
|
235 | - } |
|
233 | + if (!is_numeric($coord[$key])) { |
|
234 | + return false; |
|
235 | + } |
|
236 | 236 | |
237 | - switch (variable) { |
|
238 | - case 'cached_lat': |
|
239 | - case 'curbside_lat': |
|
240 | - if ($lat>90 || $lat<-90) { |
|
241 | - return false; |
|
242 | - } |
|
243 | - break; |
|
244 | - case 'cached_lng': |
|
245 | - case 'curbside_lng': |
|
246 | - if ($lng>180 || $lng<-180) { |
|
247 | - return false; |
|
248 | - } |
|
249 | - break; |
|
250 | - } |
|
237 | + switch (variable) { |
|
238 | + case 'cached_lat': |
|
239 | + case 'curbside_lat': |
|
240 | + if ($lat>90 || $lat<-90) { |
|
241 | + return false; |
|
242 | + } |
|
243 | + break; |
|
244 | + case 'cached_lng': |
|
245 | + case 'curbside_lng': |
|
246 | + if ($lng>180 || $lng<-180) { |
|
247 | + return false; |
|
248 | + } |
|
249 | + break; |
|
250 | + } |
|
251 | 251 | |
252 | - return true; |
|
253 | - } |
|
252 | + return true; |
|
253 | + } |
|
254 | 254 | |
255 | - public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
256 | - { |
|
257 | - $max_line_length = 512; |
|
258 | - $delemietr = ','; |
|
255 | + public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
256 | + { |
|
257 | + $max_line_length = 512; |
|
258 | + $delemietr = ','; |
|
259 | 259 | |
260 | - $results = array(); |
|
261 | - $results['fail'] = array(); |
|
262 | - $results['success'] = array(); |
|
260 | + $results = array(); |
|
261 | + $results['fail'] = array(); |
|
262 | + $results['success'] = array(); |
|
263 | 263 | |
264 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
264 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
265 | 265 | |
266 | - $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', 'order_id', |
|
267 | - 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
266 | + $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', 'order_id', |
|
267 | + 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
268 | 268 | |
269 | - $allOrderFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
269 | + $allOrderFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
270 | 270 | |
271 | - if (!empty($columns)) { |
|
272 | - array_push($results['fail'],'Empty CSV table'); |
|
273 | - return ($results); |
|
274 | - } |
|
271 | + if (!empty($columns)) { |
|
272 | + array_push($results['fail'],'Empty CSV table'); |
|
273 | + return ($results); |
|
274 | + } |
|
275 | 275 | |
276 | - $iRow=1; |
|
276 | + $iRow=1; |
|
277 | 277 | |
278 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
279 | - if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
|
278 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
279 | + if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
|
280 | 280 | |
281 | - $cached_lat = 0.000; |
|
282 | - $cached_lng = 0.000; |
|
281 | + $cached_lat = 0.000; |
|
282 | + $cached_lng = 0.000; |
|
283 | 283 | |
284 | - foreach (array('cached_lat', 'cached_lng', 'curbside_lat', 'curbside_lng') as $coord) { |
|
285 | - if (!$this->validateCoordinate(array($coord => $rows[$ordersFieldsMapping[$coord]]))) { |
|
286 | - array_push($results['fail'], "$iRow --> Wrong "+$coord); |
|
287 | - $iRow++; |
|
288 | - continue; |
|
289 | - } else { |
|
290 | - switch ($coord) { |
|
291 | - case 'cached_lat': |
|
292 | - $cached_lat = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
293 | - break; |
|
294 | - case 'cached_lng': |
|
295 | - $cached_lng = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
296 | - break; |
|
297 | - } |
|
298 | - } |
|
299 | - } |
|
284 | + foreach (array('cached_lat', 'cached_lng', 'curbside_lat', 'curbside_lng') as $coord) { |
|
285 | + if (!$this->validateCoordinate(array($coord => $rows[$ordersFieldsMapping[$coord]]))) { |
|
286 | + array_push($results['fail'], "$iRow --> Wrong "+$coord); |
|
287 | + $iRow++; |
|
288 | + continue; |
|
289 | + } else { |
|
290 | + switch ($coord) { |
|
291 | + case 'cached_lat': |
|
292 | + $cached_lat = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
293 | + break; |
|
294 | + case 'cached_lng': |
|
295 | + $cached_lng = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
296 | + break; |
|
297 | + } |
|
298 | + } |
|
299 | + } |
|
300 | 300 | |
301 | - $address = $rows[$ordersFieldsMapping['address_1']]; |
|
301 | + $address = $rows[$ordersFieldsMapping['address_1']]; |
|
302 | 302 | |
303 | - foreach (array('order_city', 'order_state_id', 'order_zip_code', 'order_country_id') as $addressPart) { |
|
304 | - if (isset($ordersFieldsMapping[$addressPart])) { |
|
305 | - $address .= ', '.$rows[$ordersFieldsMapping[$addressPart]]; |
|
306 | - } |
|
307 | - } |
|
303 | + foreach (array('order_city', 'order_state_id', 'order_zip_code', 'order_country_id') as $addressPart) { |
|
304 | + if (isset($ordersFieldsMapping[$addressPart])) { |
|
305 | + $address .= ', '.$rows[$ordersFieldsMapping[$addressPart]]; |
|
306 | + } |
|
307 | + } |
|
308 | 308 | |
309 | - echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
309 | + echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
310 | 310 | |
311 | - $parametersArray = array(); |
|
311 | + $parametersArray = array(); |
|
312 | 312 | |
313 | - $parametersArray["cached_lat"] = $cached_lat; |
|
314 | - $parametersArray["cached_lng"] = $cached_lng; |
|
313 | + $parametersArray["cached_lat"] = $cached_lat; |
|
314 | + $parametersArray["cached_lng"] = $cached_lng; |
|
315 | 315 | |
316 | 316 | |
317 | - foreach ($allOrderFields as $orderField) { |
|
318 | - if (isset($ordersFieldsMapping[$orderField])) { |
|
319 | - $parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]]; |
|
320 | - } |
|
321 | - } |
|
317 | + foreach ($allOrderFields as $orderField) { |
|
318 | + if (isset($ordersFieldsMapping[$orderField])) { |
|
319 | + $parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]]; |
|
320 | + } |
|
321 | + } |
|
322 | 322 | |
323 | - $orderParameters = Order::fromArray($parametersArray); |
|
323 | + $orderParameters = Order::fromArray($parametersArray); |
|
324 | 324 | |
325 | - $order = new Order(); |
|
325 | + $order = new Order(); |
|
326 | 326 | |
327 | - $orderResults = $order->addOrder($orderParameters); |
|
327 | + $orderResults = $order->addOrder($orderParameters); |
|
328 | 328 | |
329 | - array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
330 | - } |
|
331 | - else { |
|
332 | - array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
333 | - } |
|
329 | + array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
330 | + } |
|
331 | + else { |
|
332 | + array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
333 | + } |
|
334 | 334 | |
335 | - $iRow++; |
|
336 | - } |
|
337 | - } |
|
335 | + $iRow++; |
|
336 | + } |
|
337 | + } |
|
338 | 338 | } |
@@ -235,18 +235,18 @@ discard block |
||
235 | 235 | } |
236 | 236 | |
237 | 237 | switch (variable) { |
238 | - case 'cached_lat': |
|
239 | - case 'curbside_lat': |
|
240 | - if ($lat>90 || $lat<-90) { |
|
241 | - return false; |
|
242 | - } |
|
243 | - break; |
|
244 | - case 'cached_lng': |
|
245 | - case 'curbside_lng': |
|
246 | - if ($lng>180 || $lng<-180) { |
|
247 | - return false; |
|
248 | - } |
|
249 | - break; |
|
238 | + case 'cached_lat': |
|
239 | + case 'curbside_lat': |
|
240 | + if ($lat>90 || $lat<-90) { |
|
241 | + return false; |
|
242 | + } |
|
243 | + break; |
|
244 | + case 'cached_lng': |
|
245 | + case 'curbside_lng': |
|
246 | + if ($lng>180 || $lng<-180) { |
|
247 | + return false; |
|
248 | + } |
|
249 | + break; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | return true; |
@@ -288,12 +288,12 @@ discard block |
||
288 | 288 | continue; |
289 | 289 | } else { |
290 | 290 | switch ($coord) { |
291 | - case 'cached_lat': |
|
292 | - $cached_lat = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
293 | - break; |
|
294 | - case 'cached_lng': |
|
295 | - $cached_lng = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
296 | - break; |
|
291 | + case 'cached_lat': |
|
292 | + $cached_lat = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
293 | + break; |
|
294 | + case 'cached_lng': |
|
295 | + $cached_lng = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
296 | + break; |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | public static function searchOrder($params) |
217 | 217 | { |
218 | - $allQueryFields = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
218 | + $allQueryFields = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit'); |
|
219 | 219 | |
220 | 220 | $response = Route4Me::makeRequst(array( |
221 | 221 | 'url' => Endpoint::ORDER_V4, |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | $allOrderFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
270 | 270 | |
271 | 271 | if (!empty($columns)) { |
272 | - array_push($results['fail'],'Empty CSV table'); |
|
272 | + array_push($results['fail'], 'Empty CSV table'); |
|
273 | 273 | return ($results); |
274 | 274 | } |
275 | 275 | |
276 | - $iRow=1; |
|
276 | + $iRow = 1; |
|
277 | 277 | |
278 | 278 | while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
279 | 279 | if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
@@ -327,8 +327,7 @@ |
||
327 | 327 | $orderResults = $order->addOrder($orderParameters); |
328 | 328 | |
329 | 329 | array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
330 | - } |
|
331 | - else { |
|
330 | + } else { |
|
332 | 331 | array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
333 | 332 | } |
334 | 333 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | public static function getTerritory($params) |
42 | 42 | { |
43 | - $allQueryFields = array('territory_id', 'addresses'); |
|
43 | + $allQueryFields = array('territory_id', 'addresses'); |
|
44 | 44 | |
45 | 45 | $territory = Route4Me::makeRequst(array( |
46 | 46 | 'url' => Endpoint::TERRITORY_V4, |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | public static function getTerritories($params) |
55 | 55 | { |
56 | - $allQueryFields = array('offset', 'limit', 'addresses'); |
|
56 | + $allQueryFields = array('offset', 'limit', 'addresses'); |
|
57 | 57 | |
58 | 58 | $response = Route4Me::makeRequst(array( |
59 | 59 | 'url' => Endpoint::TERRITORY_V4, |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | public static function addTerritory($params) |
68 | 68 | { |
69 | - $allBodyFields = array('territory_name', 'member_id', 'territory_color', 'territory'); |
|
69 | + $allBodyFields = array('territory_name', 'member_id', 'territory_color', 'territory'); |
|
70 | 70 | |
71 | 71 | $response = Route4Me::makeRequst(array( |
72 | 72 | 'url' => Endpoint::TERRITORY_V4, |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | |
93 | 93 | public function updateTerritory($params) |
94 | 94 | { |
95 | - $allQueryFields = array('territory_id'); |
|
96 | - $allBodyFields = array('territory_name', 'member_id', 'territory_color', 'territory'); |
|
95 | + $allQueryFields = array('territory_id'); |
|
96 | + $allBodyFields = array('territory_name', 'member_id', 'territory_color', 'territory'); |
|
97 | 97 | |
98 | 98 | $response = Route4Me::makeRequst(array( |
99 | 99 | 'url' => Endpoint::TERRITORY_V4, |
100 | 100 | 'method' => 'PUT', |
101 | 101 | 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
102 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
102 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
103 | 103 | )); |
104 | 104 | |
105 | 105 | return $response; |
@@ -6,157 +6,157 @@ |
||
6 | 6 | |
7 | 7 | class Vehicle extends Common |
8 | 8 | { |
9 | - public $vehicle_id; |
|
10 | - public $member_id; |
|
11 | - public $is_deleted; |
|
12 | - public $vehicle_alias; |
|
13 | - public $vehicle_vin; |
|
14 | - public $vehicle_reg_state_id; |
|
15 | - public $vehicle_reg_country_id; |
|
16 | - public $vehicle_license_plate; |
|
17 | - public $vehicle_type_id; |
|
18 | - public $vehicle_make; |
|
19 | - public $vehicle_model_year; |
|
20 | - public $vehicle_model; |
|
21 | - public $vehicle_year_acquired; |
|
22 | - public $vehicle_cost_new; |
|
23 | - public $purchased_new; |
|
24 | - public $license_start_date; |
|
25 | - public $license_end_date; |
|
26 | - public $vehicle_axle_count; |
|
27 | - public $is_operational; |
|
28 | - public $mpg_city; |
|
29 | - public $mpg_highway; |
|
30 | - public $fuel_type; |
|
31 | - public $height_inches; |
|
32 | - public $weight_lb; |
|
33 | - public $external_telematics_vehicle_id; |
|
34 | - public $has_trailer; |
|
35 | - public $heightInInches; |
|
36 | - public $lengthInInches; |
|
37 | - public $widthInInches; |
|
38 | - public $maxWeightPerAxleGroupInPounds; |
|
39 | - public $numAxles; |
|
40 | - public $weightInPounds; |
|
41 | - public $HazmatType; |
|
42 | - public $LowEmissionZonePref; |
|
43 | - public $Use53FootTrailerRouting; |
|
44 | - public $UseNationalNetwork; |
|
45 | - public $UseTruckRestrictions; |
|
46 | - public $AvoidFerries; |
|
47 | - public $DividedHighwayAvoidPreference; |
|
48 | - public $FreewayAvoidPreference; |
|
49 | - public $InternationalBordersOpen; |
|
50 | - public $TollRoadUsage; |
|
51 | - public $hwy_only; |
|
52 | - public $long_combination_vehicle; |
|
53 | - public $avoid_highways; |
|
54 | - public $side_street_adherence; |
|
55 | - public $truck_config; |
|
56 | - public $height_metric; |
|
57 | - public $length_metric; |
|
58 | - public $width_metric; |
|
59 | - public $weight_metric; |
|
60 | - public $max_weight_per_axle_group_metric; |
|
9 | + public $vehicle_id; |
|
10 | + public $member_id; |
|
11 | + public $is_deleted; |
|
12 | + public $vehicle_alias; |
|
13 | + public $vehicle_vin; |
|
14 | + public $vehicle_reg_state_id; |
|
15 | + public $vehicle_reg_country_id; |
|
16 | + public $vehicle_license_plate; |
|
17 | + public $vehicle_type_id; |
|
18 | + public $vehicle_make; |
|
19 | + public $vehicle_model_year; |
|
20 | + public $vehicle_model; |
|
21 | + public $vehicle_year_acquired; |
|
22 | + public $vehicle_cost_new; |
|
23 | + public $purchased_new; |
|
24 | + public $license_start_date; |
|
25 | + public $license_end_date; |
|
26 | + public $vehicle_axle_count; |
|
27 | + public $is_operational; |
|
28 | + public $mpg_city; |
|
29 | + public $mpg_highway; |
|
30 | + public $fuel_type; |
|
31 | + public $height_inches; |
|
32 | + public $weight_lb; |
|
33 | + public $external_telematics_vehicle_id; |
|
34 | + public $has_trailer; |
|
35 | + public $heightInInches; |
|
36 | + public $lengthInInches; |
|
37 | + public $widthInInches; |
|
38 | + public $maxWeightPerAxleGroupInPounds; |
|
39 | + public $numAxles; |
|
40 | + public $weightInPounds; |
|
41 | + public $HazmatType; |
|
42 | + public $LowEmissionZonePref; |
|
43 | + public $Use53FootTrailerRouting; |
|
44 | + public $UseNationalNetwork; |
|
45 | + public $UseTruckRestrictions; |
|
46 | + public $AvoidFerries; |
|
47 | + public $DividedHighwayAvoidPreference; |
|
48 | + public $FreewayAvoidPreference; |
|
49 | + public $InternationalBordersOpen; |
|
50 | + public $TollRoadUsage; |
|
51 | + public $hwy_only; |
|
52 | + public $long_combination_vehicle; |
|
53 | + public $avoid_highways; |
|
54 | + public $side_street_adherence; |
|
55 | + public $truck_config; |
|
56 | + public $height_metric; |
|
57 | + public $length_metric; |
|
58 | + public $width_metric; |
|
59 | + public $weight_metric; |
|
60 | + public $max_weight_per_axle_group_metric; |
|
61 | 61 | |
62 | - public function __construct () |
|
63 | - { |
|
64 | - Route4Me::setBaseUrl(Endpoint::WH_BASE_URL); |
|
65 | - } |
|
62 | + public function __construct () |
|
63 | + { |
|
64 | + Route4Me::setBaseUrl(Endpoint::WH_BASE_URL); |
|
65 | + } |
|
66 | 66 | |
67 | - public static function fromArray(array $params) { |
|
68 | - $vehicle= new Vehicle(); |
|
69 | - foreach($params as $key => $value) { |
|
70 | - if (property_exists($vehicle, $key)) { |
|
71 | - $vehicle->{$key} = $value; |
|
72 | - } |
|
73 | - } |
|
67 | + public static function fromArray(array $params) { |
|
68 | + $vehicle= new Vehicle(); |
|
69 | + foreach($params as $key => $value) { |
|
70 | + if (property_exists($vehicle, $key)) { |
|
71 | + $vehicle->{$key} = $value; |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - return $vehicle; |
|
76 | - } |
|
75 | + return $vehicle; |
|
76 | + } |
|
77 | 77 | |
78 | - public static function getVehicles($params) |
|
79 | - { |
|
80 | - $allQueryFields = array('with_pagination', 'page', 'perPage'); |
|
78 | + public static function getVehicles($params) |
|
79 | + { |
|
80 | + $allQueryFields = array('with_pagination', 'page', 'perPage'); |
|
81 | 81 | |
82 | - $response = Route4Me::makeRequst(array( |
|
83 | - 'url' => Endpoint::VEHICLE_V4, |
|
84 | - 'method' => 'GET', |
|
85 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
86 | - )); |
|
82 | + $response = Route4Me::makeRequst(array( |
|
83 | + 'url' => Endpoint::VEHICLE_V4, |
|
84 | + 'method' => 'GET', |
|
85 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
86 | + )); |
|
87 | 87 | |
88 | - return $response; |
|
89 | - } |
|
88 | + return $response; |
|
89 | + } |
|
90 | 90 | |
91 | - public function getRandomVehicleId($page,$perPage) |
|
92 | - { |
|
93 | - $params = array( |
|
94 | - 'page' => isset($page) ? $page : 1, |
|
95 | - 'perPage' => isset($perPage) ? $perPage : 10, |
|
96 | - 'with_pagination' => true |
|
97 | - ); |
|
91 | + public function getRandomVehicleId($page,$perPage) |
|
92 | + { |
|
93 | + $params = array( |
|
94 | + 'page' => isset($page) ? $page : 1, |
|
95 | + 'perPage' => isset($perPage) ? $perPage : 10, |
|
96 | + 'with_pagination' => true |
|
97 | + ); |
|
98 | 98 | |
99 | - $vehicles = $this->getVehicles($params); |
|
99 | + $vehicles = $this->getVehicles($params); |
|
100 | 100 | |
101 | - if (is_null($vehicles)) return null; |
|
102 | - if (!isset($vehicles['data'])) return null; |
|
103 | - if (sizeof($vehicles['data'])<1) return null; |
|
101 | + if (is_null($vehicles)) return null; |
|
102 | + if (!isset($vehicles['data'])) return null; |
|
103 | + if (sizeof($vehicles['data'])<1) return null; |
|
104 | 104 | |
105 | - $randomIndex = rand(0, sizeof($vehicles['data'])-1); |
|
105 | + $randomIndex = rand(0, sizeof($vehicles['data'])-1); |
|
106 | 106 | |
107 | - return $vehicles['data'][$randomIndex]['vehicle_id']; |
|
108 | - } |
|
107 | + return $vehicles['data'][$randomIndex]['vehicle_id']; |
|
108 | + } |
|
109 | 109 | |
110 | - public function getVehicleByID($vehicleID) |
|
111 | - { |
|
112 | - $response = Route4Me::makeRequst(array( |
|
113 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
114 | - 'method' => 'GET' |
|
115 | - )); |
|
110 | + public function getVehicleByID($vehicleID) |
|
111 | + { |
|
112 | + $response = Route4Me::makeRequst(array( |
|
113 | + 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
114 | + 'method' => 'GET' |
|
115 | + )); |
|
116 | 116 | |
117 | - return $response; |
|
118 | - } |
|
117 | + return $response; |
|
118 | + } |
|
119 | 119 | |
120 | - public function updateVehicle($params) |
|
121 | - { |
|
122 | - $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
120 | + public function updateVehicle($params) |
|
121 | + { |
|
122 | + $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
123 | 123 | |
124 | - $allBodyFields = Route4Me::getObjectProperties(new Vehicle(), array('vehicle_id')); |
|
124 | + $allBodyFields = Route4Me::getObjectProperties(new Vehicle(), array('vehicle_id')); |
|
125 | 125 | |
126 | - $response = Route4Me::makeRequst(array( |
|
127 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
128 | - 'method' => 'PUT', |
|
129 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
130 | - 'HTTPHEADER' => 'Content-Type: application/json' |
|
131 | - )); |
|
126 | + $response = Route4Me::makeRequst(array( |
|
127 | + 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
128 | + 'method' => 'PUT', |
|
129 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
130 | + 'HTTPHEADER' => 'Content-Type: application/json' |
|
131 | + )); |
|
132 | 132 | |
133 | - return $response; |
|
134 | - } |
|
133 | + return $response; |
|
134 | + } |
|
135 | 135 | |
136 | - public function createVehicle($params) |
|
137 | - { |
|
138 | - $allBodyFields = Route4Me::getObjectProperties(new Vehicle(), array('vehicle_id')); |
|
136 | + public function createVehicle($params) |
|
137 | + { |
|
138 | + $allBodyFields = Route4Me::getObjectProperties(new Vehicle(), array('vehicle_id')); |
|
139 | 139 | |
140 | - $response = Route4Me::makeRequst(array( |
|
141 | - 'url' => Endpoint::VEHICLE_V4, |
|
142 | - 'method' => 'POST', |
|
143 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
144 | - 'HTTPHEADER' => 'Content-Type: application/json' |
|
145 | - )); |
|
140 | + $response = Route4Me::makeRequst(array( |
|
141 | + 'url' => Endpoint::VEHICLE_V4, |
|
142 | + 'method' => 'POST', |
|
143 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
144 | + 'HTTPHEADER' => 'Content-Type: application/json' |
|
145 | + )); |
|
146 | 146 | |
147 | - return $response; |
|
148 | - } |
|
147 | + return $response; |
|
148 | + } |
|
149 | 149 | |
150 | - public function removeVehicle($params) |
|
151 | - { |
|
152 | - $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
150 | + public function removeVehicle($params) |
|
151 | + { |
|
152 | + $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
153 | 153 | |
154 | - $response = Route4Me::makeRequst(array( |
|
155 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
156 | - 'method' => 'DELETE', |
|
157 | - 'HTTPHEADER' => 'Content-Type: application/json' |
|
158 | - )); |
|
154 | + $response = Route4Me::makeRequst(array( |
|
155 | + 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
156 | + 'method' => 'DELETE', |
|
157 | + 'HTTPHEADER' => 'Content-Type: application/json' |
|
158 | + )); |
|
159 | 159 | |
160 | - return $response; |
|
161 | - } |
|
160 | + return $response; |
|
161 | + } |
|
162 | 162 | } |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | public $weight_metric; |
60 | 60 | public $max_weight_per_axle_group_metric; |
61 | 61 | |
62 | - public function __construct () |
|
62 | + public function __construct() |
|
63 | 63 | { |
64 | 64 | Route4Me::setBaseUrl(Endpoint::WH_BASE_URL); |
65 | 65 | } |
66 | 66 | |
67 | 67 | public static function fromArray(array $params) { |
68 | - $vehicle= new Vehicle(); |
|
69 | - foreach($params as $key => $value) { |
|
68 | + $vehicle = new Vehicle(); |
|
69 | + foreach ($params as $key => $value) { |
|
70 | 70 | if (property_exists($vehicle, $key)) { |
71 | 71 | $vehicle->{$key} = $value; |
72 | 72 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | return $response; |
89 | 89 | } |
90 | 90 | |
91 | - public function getRandomVehicleId($page,$perPage) |
|
91 | + public function getRandomVehicleId($page, $perPage) |
|
92 | 92 | { |
93 | 93 | $params = array( |
94 | 94 | 'page' => isset($page) ? $page : 1, |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | if (!isset($vehicles['data'])) return null; |
103 | 103 | if (sizeof($vehicles['data'])<1) return null; |
104 | 104 | |
105 | - $randomIndex = rand(0, sizeof($vehicles['data'])-1); |
|
105 | + $randomIndex = rand(0, sizeof($vehicles['data']) - 1); |
|
106 | 106 | |
107 | 107 | return $vehicles['data'][$randomIndex]['vehicle_id']; |
108 | 108 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | public function getVehicleByID($vehicleID) |
111 | 111 | { |
112 | 112 | $response = Route4Me::makeRequst(array( |
113 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
113 | + 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
114 | 114 | 'method' => 'GET' |
115 | 115 | )); |
116 | 116 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $allBodyFields = Route4Me::getObjectProperties(new Vehicle(), array('vehicle_id')); |
125 | 125 | |
126 | 126 | $response = Route4Me::makeRequst(array( |
127 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
127 | + 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
128 | 128 | 'method' => 'PUT', |
129 | 129 | 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
130 | 130 | 'HTTPHEADER' => 'Content-Type: application/json' |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
153 | 153 | |
154 | 154 | $response = Route4Me::makeRequst(array( |
155 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
155 | + 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
156 | 156 | 'method' => 'DELETE', |
157 | 157 | 'HTTPHEADER' => 'Content-Type: application/json' |
158 | 158 | )); |
@@ -98,9 +98,15 @@ |
||
98 | 98 | |
99 | 99 | $vehicles = $this->getVehicles($params); |
100 | 100 | |
101 | - if (is_null($vehicles)) return null; |
|
102 | - if (!isset($vehicles['data'])) return null; |
|
103 | - if (sizeof($vehicles['data'])<1) return null; |
|
101 | + if (is_null($vehicles)) { |
|
102 | + return null; |
|
103 | + } |
|
104 | + if (!isset($vehicles['data'])) { |
|
105 | + return null; |
|
106 | + } |
|
107 | + if (sizeof($vehicles['data'])<1) { |
|
108 | + return null; |
|
109 | + } |
|
104 | 110 | |
105 | 111 | $randomIndex = rand(0, sizeof($vehicles['data'])-1); |
106 | 112 |
@@ -6,106 +6,106 @@ |
||
6 | 6 | |
7 | 7 | class Geocoding extends Common |
8 | 8 | { |
9 | - public $strExportFormat; |
|
10 | - public $format; |
|
11 | - public $addresses; |
|
12 | - public $pk; |
|
13 | - public $offset; |
|
14 | - public $limit; |
|
15 | - public $housenumber; |
|
16 | - public $zipcode; |
|
9 | + public $strExportFormat; |
|
10 | + public $format; |
|
11 | + public $addresses; |
|
12 | + public $pk; |
|
13 | + public $offset; |
|
14 | + public $limit; |
|
15 | + public $housenumber; |
|
16 | + public $zipcode; |
|
17 | 17 | |
18 | - public static function fromArray(array $params) |
|
19 | - { |
|
20 | - $geocoding = new Geocoding(); |
|
18 | + public static function fromArray(array $params) |
|
19 | + { |
|
20 | + $geocoding = new Geocoding(); |
|
21 | 21 | |
22 | - foreach($params as $key => $value) { |
|
23 | - if (property_exists($geocoding, $key)) { |
|
24 | - $geocoding->{$key} = $value; |
|
25 | - } |
|
26 | - } |
|
22 | + foreach($params as $key => $value) { |
|
23 | + if (property_exists($geocoding, $key)) { |
|
24 | + $geocoding->{$key} = $value; |
|
25 | + } |
|
26 | + } |
|
27 | 27 | |
28 | - return $geocoding; |
|
29 | - } |
|
28 | + return $geocoding; |
|
29 | + } |
|
30 | 30 | |
31 | - public static function forwardGeocoding($params) |
|
32 | - { |
|
33 | - $allBodyFields = array('strExportFormat', 'addresses'); |
|
31 | + public static function forwardGeocoding($params) |
|
32 | + { |
|
33 | + $allBodyFields = array('strExportFormat', 'addresses'); |
|
34 | 34 | |
35 | - $fgCoding = Route4Me::makeRequst(array( |
|
36 | - 'url' => Endpoint::GEOCODER, |
|
37 | - 'method' => 'POST', |
|
38 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
39 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
40 | - )); |
|
35 | + $fgCoding = Route4Me::makeRequst(array( |
|
36 | + 'url' => Endpoint::GEOCODER, |
|
37 | + 'method' => 'POST', |
|
38 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
39 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
40 | + )); |
|
41 | 41 | |
42 | - return $fgCoding; |
|
43 | - } |
|
42 | + return $fgCoding; |
|
43 | + } |
|
44 | 44 | |
45 | - public static function reverseGeocoding($params) |
|
46 | - { |
|
47 | - $allQueryFields = array('format', 'addresses', 'detailed'); |
|
45 | + public static function reverseGeocoding($params) |
|
46 | + { |
|
47 | + $allQueryFields = array('format', 'addresses', 'detailed'); |
|
48 | 48 | |
49 | - $fgcoding = Route4Me::makeRequst(array( |
|
50 | - 'url' => Endpoint::GEOCODER, |
|
51 | - 'method' => 'POST', |
|
52 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
53 | - )); |
|
49 | + $fgcoding = Route4Me::makeRequst(array( |
|
50 | + 'url' => Endpoint::GEOCODER, |
|
51 | + 'method' => 'POST', |
|
52 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
53 | + )); |
|
54 | 54 | |
55 | - return $fgcoding; |
|
56 | - } |
|
55 | + return $fgcoding; |
|
56 | + } |
|
57 | 57 | |
58 | - public static function getStreetData($params) |
|
59 | - { |
|
60 | - $url_query = Endpoint::STREET_DATA; |
|
58 | + public static function getStreetData($params) |
|
59 | + { |
|
60 | + $url_query = Endpoint::STREET_DATA; |
|
61 | 61 | |
62 | - $allPathFields = array('pk', 'offset', 'limit'); |
|
62 | + $allPathFields = array('pk', 'offset', 'limit'); |
|
63 | 63 | |
64 | - $url_query .= Route4Me::generateUrlPath($allPathFields, $params); |
|
64 | + $url_query .= Route4Me::generateUrlPath($allPathFields, $params); |
|
65 | 65 | |
66 | - $query = array(); |
|
66 | + $query = array(); |
|
67 | 67 | |
68 | - $response = Route4Me::makeUrlRequst($url_query, array( |
|
69 | - 'method' => 'GET', |
|
70 | - 'query' => $query |
|
71 | - )); |
|
68 | + $response = Route4Me::makeUrlRequst($url_query, array( |
|
69 | + 'method' => 'GET', |
|
70 | + 'query' => $query |
|
71 | + )); |
|
72 | 72 | |
73 | - return $response; |
|
74 | - } |
|
73 | + return $response; |
|
74 | + } |
|
75 | 75 | |
76 | - public static function getZipCode($params) |
|
77 | - { |
|
78 | - $url_query = Endpoint::STREET_DATA_ZIPCODE; |
|
76 | + public static function getZipCode($params) |
|
77 | + { |
|
78 | + $url_query = Endpoint::STREET_DATA_ZIPCODE; |
|
79 | 79 | |
80 | - $allPathFields = array('zipcode', 'offset', 'limit'); |
|
80 | + $allPathFields = array('zipcode', 'offset', 'limit'); |
|
81 | 81 | |
82 | - $url_query .= Route4Me::generateUrlPath($allPathFields, $params); |
|
82 | + $url_query .= Route4Me::generateUrlPath($allPathFields, $params); |
|
83 | 83 | |
84 | - $query = array(); |
|
84 | + $query = array(); |
|
85 | 85 | |
86 | - $response = Route4Me::makeUrlRequst($url_query, array( |
|
87 | - 'method' => 'GET', |
|
88 | - 'query' => $query |
|
89 | - )); |
|
86 | + $response = Route4Me::makeUrlRequst($url_query, array( |
|
87 | + 'method' => 'GET', |
|
88 | + 'query' => $query |
|
89 | + )); |
|
90 | 90 | |
91 | - return $response; |
|
92 | - } |
|
91 | + return $response; |
|
92 | + } |
|
93 | 93 | |
94 | - public static function getService($params) |
|
95 | - { |
|
96 | - $url_query = Endpoint::STREET_DATA_SERVICE; |
|
94 | + public static function getService($params) |
|
95 | + { |
|
96 | + $url_query = Endpoint::STREET_DATA_SERVICE; |
|
97 | 97 | |
98 | - $allPathFields = array('zipcode', 'housenumber', 'offset', 'limit'); |
|
98 | + $allPathFields = array('zipcode', 'housenumber', 'offset', 'limit'); |
|
99 | 99 | |
100 | - $url_query .= Route4Me::generateUrlPath($allPathFields, $params); |
|
100 | + $url_query .= Route4Me::generateUrlPath($allPathFields, $params); |
|
101 | 101 | |
102 | - $query = array(); |
|
102 | + $query = array(); |
|
103 | 103 | |
104 | - $response = Route4Me::makeUrlRequst($url_query, array( |
|
105 | - 'method' => 'GET', |
|
106 | - 'query' => $query |
|
107 | - )); |
|
104 | + $response = Route4Me::makeUrlRequst($url_query, array( |
|
105 | + 'method' => 'GET', |
|
106 | + 'query' => $query |
|
107 | + )); |
|
108 | 108 | |
109 | - return $response; |
|
110 | - } |
|
109 | + return $response; |
|
110 | + } |
|
111 | 111 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | { |
20 | 20 | $geocoding = new Geocoding(); |
21 | 21 | |
22 | - foreach($params as $key => $value) { |
|
22 | + foreach ($params as $key => $value) { |
|
23 | 23 | if (property_exists($geocoding, $key)) { |
24 | 24 | $geocoding->{$key} = $value; |
25 | 25 | } |
@@ -9,409 +9,409 @@ |
||
9 | 9 | |
10 | 10 | class Route extends Common |
11 | 11 | { |
12 | - public $route_id; |
|
13 | - public $member_id; |
|
14 | - public $route_destination_id; |
|
15 | - public $optimization_problem_id; |
|
16 | - public $vehicle_alias; |
|
17 | - public $driver_alias; |
|
18 | - public $trip_distance; |
|
19 | - public $mpg; |
|
20 | - public $gas_price; |
|
21 | - public $route_duration_sec; |
|
22 | - public $destination_count; |
|
23 | - public $parameters; |
|
24 | - public $addresses = array(); |
|
25 | - public $links = array(); |
|
26 | - public $directions = array(); |
|
27 | - public $path = array(); |
|
28 | - public $tracking_history = array(); |
|
29 | - public $recipient_email; |
|
30 | - public $httpheaders; |
|
31 | - public $is_unrouted; |
|
32 | - public $time; |
|
12 | + public $route_id; |
|
13 | + public $member_id; |
|
14 | + public $route_destination_id; |
|
15 | + public $optimization_problem_id; |
|
16 | + public $vehicle_alias; |
|
17 | + public $driver_alias; |
|
18 | + public $trip_distance; |
|
19 | + public $mpg; |
|
20 | + public $gas_price; |
|
21 | + public $route_duration_sec; |
|
22 | + public $destination_count; |
|
23 | + public $parameters; |
|
24 | + public $addresses = array(); |
|
25 | + public $links = array(); |
|
26 | + public $directions = array(); |
|
27 | + public $path = array(); |
|
28 | + public $tracking_history = array(); |
|
29 | + public $recipient_email; |
|
30 | + public $httpheaders; |
|
31 | + public $is_unrouted; |
|
32 | + public $time; |
|
33 | 33 | |
34 | - public $dev_lat; |
|
35 | - public $dev_lng; |
|
34 | + public $dev_lat; |
|
35 | + public $dev_lng; |
|
36 | 36 | |
37 | - public $user_route_rating; |
|
38 | - public $member_email; |
|
39 | - public $member_first_name; |
|
40 | - public $member_last_name; |
|
41 | - public $channel_name; |
|
42 | - public $route_cost; |
|
43 | - public $route_revenue; |
|
44 | - public $net_revenue_per_distance_unit; |
|
45 | - public $created_timestamp; |
|
46 | - public $planned_total_route_duration; |
|
47 | - public $actual_travel_distance; |
|
48 | - public $actual_travel_time; |
|
49 | - public $actual_footsteps; |
|
50 | - public $working_time; |
|
51 | - public $driving_time; |
|
52 | - public $idling_time; |
|
53 | - public $paying_miles; |
|
54 | - public $geofence_polygon_type; |
|
55 | - public $geofence_polygon_size; |
|
56 | - public $notes; |
|
57 | - public $member_config_storage; |
|
37 | + public $user_route_rating; |
|
38 | + public $member_email; |
|
39 | + public $member_first_name; |
|
40 | + public $member_last_name; |
|
41 | + public $channel_name; |
|
42 | + public $route_cost; |
|
43 | + public $route_revenue; |
|
44 | + public $net_revenue_per_distance_unit; |
|
45 | + public $created_timestamp; |
|
46 | + public $planned_total_route_duration; |
|
47 | + public $actual_travel_distance; |
|
48 | + public $actual_travel_time; |
|
49 | + public $actual_footsteps; |
|
50 | + public $working_time; |
|
51 | + public $driving_time; |
|
52 | + public $idling_time; |
|
53 | + public $paying_miles; |
|
54 | + public $geofence_polygon_type; |
|
55 | + public $geofence_polygon_size; |
|
56 | + public $notes; |
|
57 | + public $member_config_storage; |
|
58 | 58 | |
59 | - public static function fromArray(array $params) |
|
60 | - { |
|
61 | - $route = new Route(); |
|
62 | - $route->route_id = Common::getValue($params, 'route_id'); |
|
63 | - $route->member_id = Common::getValue($params, 'member_id'); |
|
64 | - $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
65 | - $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); |
|
66 | - $route->driver_alias = Common::getValue($params, 'driver_alias'); |
|
67 | - $route->trip_distance = Common::getValue($params, 'trip_distance'); |
|
68 | - $route->mpg = Common::getValue($params, 'mpg'); |
|
69 | - $route->gas_price = Common::getValue($params, 'gas_price'); |
|
70 | - $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec'); |
|
71 | - $route->destination_count = Common::getvalue($params, 'destination_count'); |
|
72 | - $route->is_unrouted = Common::getvalue($params, 'is_unrouted'); |
|
59 | + public static function fromArray(array $params) |
|
60 | + { |
|
61 | + $route = new Route(); |
|
62 | + $route->route_id = Common::getValue($params, 'route_id'); |
|
63 | + $route->member_id = Common::getValue($params, 'member_id'); |
|
64 | + $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
65 | + $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); |
|
66 | + $route->driver_alias = Common::getValue($params, 'driver_alias'); |
|
67 | + $route->trip_distance = Common::getValue($params, 'trip_distance'); |
|
68 | + $route->mpg = Common::getValue($params, 'mpg'); |
|
69 | + $route->gas_price = Common::getValue($params, 'gas_price'); |
|
70 | + $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec'); |
|
71 | + $route->destination_count = Common::getvalue($params, 'destination_count'); |
|
72 | + $route->is_unrouted = Common::getvalue($params, 'is_unrouted'); |
|
73 | 73 | |
74 | - // Make RouteParameters |
|
75 | - if (isset($params['parameters'])) { |
|
76 | - $route->parameters = RouteParameters::fromArray($params['parameters']); |
|
77 | - } |
|
74 | + // Make RouteParameters |
|
75 | + if (isset($params['parameters'])) { |
|
76 | + $route->parameters = RouteParameters::fromArray($params['parameters']); |
|
77 | + } |
|
78 | 78 | |
79 | - if (isset($params['addresses'])) { |
|
80 | - $addresses = array(); |
|
81 | - foreach ($params['addresses'] as $address) { |
|
82 | - $addresses[] = Address::fromArray($address); |
|
83 | - } |
|
79 | + if (isset($params['addresses'])) { |
|
80 | + $addresses = array(); |
|
81 | + foreach ($params['addresses'] as $address) { |
|
82 | + $addresses[] = Address::fromArray($address); |
|
83 | + } |
|
84 | 84 | |
85 | - $route->addresses = $addresses; |
|
86 | - } |
|
85 | + $route->addresses = $addresses; |
|
86 | + } |
|
87 | 87 | |
88 | - $route->links = Common::getValue($params, 'links', array()); |
|
89 | - $route->directions = Common::getValue($params, 'directions', array()); |
|
90 | - $route->path = Common::getValue($params, 'path', array()); |
|
91 | - $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
88 | + $route->links = Common::getValue($params, 'links', array()); |
|
89 | + $route->directions = Common::getValue($params, 'directions', array()); |
|
90 | + $route->path = Common::getValue($params, 'path', array()); |
|
91 | + $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
92 | 92 | |
93 | - return $route; |
|
94 | - } |
|
93 | + return $route; |
|
94 | + } |
|
95 | 95 | |
96 | - public static function getRoutes($params = null) |
|
97 | - { |
|
98 | - $allQueryFields = array('route_id', 'route_path_output', 'query', 'directions', 'device_tracking_history', 'limit', 'offset'); |
|
96 | + public static function getRoutes($params = null) |
|
97 | + { |
|
98 | + $allQueryFields = array('route_id', 'route_path_output', 'query', 'directions', 'device_tracking_history', 'limit', 'offset'); |
|
99 | 99 | |
100 | - $result = Route4Me::makeRequst(array( |
|
101 | - 'url' => Endpoint::ROUTE_V4, |
|
102 | - 'method' => 'GET', |
|
103 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
104 | - )); |
|
100 | + $result = Route4Me::makeRequst(array( |
|
101 | + 'url' => Endpoint::ROUTE_V4, |
|
102 | + 'method' => 'GET', |
|
103 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
104 | + )); |
|
105 | 105 | |
106 | - if (isset($params['route_id'])) { |
|
107 | - return Route::fromArray($result); die(""); |
|
108 | - } else { |
|
109 | - $routes = array(); |
|
110 | - foreach ($result as $route) { |
|
111 | - $routes[] = Route::fromArray($route); |
|
112 | - } |
|
113 | - return $routes; |
|
114 | - } |
|
115 | - } |
|
106 | + if (isset($params['route_id'])) { |
|
107 | + return Route::fromArray($result); die(""); |
|
108 | + } else { |
|
109 | + $routes = array(); |
|
110 | + foreach ($result as $route) { |
|
111 | + $routes[] = Route::fromArray($route); |
|
112 | + } |
|
113 | + return $routes; |
|
114 | + } |
|
115 | + } |
|
116 | 116 | |
117 | - public function getRoutePoints($params) |
|
118 | - { |
|
119 | - $allQueryFields = array('route_id', 'route_path_output', 'compress_path_points', 'directions'); |
|
117 | + public function getRoutePoints($params) |
|
118 | + { |
|
119 | + $allQueryFields = array('route_id', 'route_path_output', 'compress_path_points', 'directions'); |
|
120 | 120 | |
121 | - $result = Route4Me::makeRequst(array( |
|
122 | - 'url' => Endpoint::ROUTE_V4, |
|
123 | - 'method' => 'GET', |
|
124 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
125 | - )); |
|
121 | + $result = Route4Me::makeRequst(array( |
|
122 | + 'url' => Endpoint::ROUTE_V4, |
|
123 | + 'method' => 'GET', |
|
124 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
125 | + )); |
|
126 | 126 | |
127 | - return $result; |
|
128 | - } |
|
127 | + return $result; |
|
128 | + } |
|
129 | 129 | |
130 | - public function duplicateRoute($route_id) |
|
131 | - { |
|
132 | - $result = Route4Me::makeRequst(array( |
|
133 | - 'url' => Endpoint::ROUTE_DUPLICATE, |
|
134 | - 'method' => 'GET', |
|
135 | - 'query' => array( |
|
136 | - 'route_id' => $route_id, |
|
137 | - 'to' => 'none', |
|
138 | - ) |
|
139 | - )); |
|
130 | + public function duplicateRoute($route_id) |
|
131 | + { |
|
132 | + $result = Route4Me::makeRequst(array( |
|
133 | + 'url' => Endpoint::ROUTE_DUPLICATE, |
|
134 | + 'method' => 'GET', |
|
135 | + 'query' => array( |
|
136 | + 'route_id' => $route_id, |
|
137 | + 'to' => 'none', |
|
138 | + ) |
|
139 | + )); |
|
140 | 140 | |
141 | - return $result; |
|
142 | - } |
|
141 | + return $result; |
|
142 | + } |
|
143 | 143 | |
144 | - public function resequenceRoute($params) |
|
145 | - { |
|
146 | - $allQueryFields = array('route_id', 'route_destination_id'); |
|
147 | - $allBodyFields = array('addresses'); |
|
144 | + public function resequenceRoute($params) |
|
145 | + { |
|
146 | + $allQueryFields = array('route_id', 'route_destination_id'); |
|
147 | + $allBodyFields = array('addresses'); |
|
148 | 148 | |
149 | - $result = Route4Me::makeRequst(array( |
|
150 | - 'url' => Endpoint::ROUTE_V4, |
|
151 | - 'method' => 'PUT', |
|
152 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
153 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
154 | - )); |
|
149 | + $result = Route4Me::makeRequst(array( |
|
150 | + 'url' => Endpoint::ROUTE_V4, |
|
151 | + 'method' => 'PUT', |
|
152 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
153 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
154 | + )); |
|
155 | 155 | |
156 | - return $result; |
|
157 | - } |
|
156 | + return $result; |
|
157 | + } |
|
158 | 158 | |
159 | - public function resequenceAllAddresses($params) |
|
160 | - { |
|
161 | - $allQueryFields = array('route_id', 'disable_optimization', 'optimize'); |
|
159 | + public function resequenceAllAddresses($params) |
|
160 | + { |
|
161 | + $allQueryFields = array('route_id', 'disable_optimization', 'optimize'); |
|
162 | 162 | |
163 | - $result = Route4Me::makeRequst(array( |
|
164 | - 'url' => Endpoint::REOPTIMIZE_V3_2, |
|
165 | - 'method' => 'GET', |
|
166 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
167 | - )); |
|
163 | + $result = Route4Me::makeRequst(array( |
|
164 | + 'url' => Endpoint::REOPTIMIZE_V3_2, |
|
165 | + 'method' => 'GET', |
|
166 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
167 | + )); |
|
168 | 168 | |
169 | - return $result; |
|
170 | - } |
|
169 | + return $result; |
|
170 | + } |
|
171 | 171 | |
172 | - public function mergeRoutes($params) |
|
173 | - { |
|
174 | - $allBodyFields = array('route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng'); |
|
172 | + public function mergeRoutes($params) |
|
173 | + { |
|
174 | + $allBodyFields = array('route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng'); |
|
175 | 175 | |
176 | - $result = Route4Me::makeRequst(array( |
|
177 | - 'url' => Endpoint::ROUTES_MERGE, |
|
178 | - 'method' => 'POST', |
|
179 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
180 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
181 | - )); |
|
176 | + $result = Route4Me::makeRequst(array( |
|
177 | + 'url' => Endpoint::ROUTES_MERGE, |
|
178 | + 'method' => 'POST', |
|
179 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
180 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
181 | + )); |
|
182 | 182 | |
183 | - return $result; |
|
184 | - } |
|
183 | + return $result; |
|
184 | + } |
|
185 | 185 | |
186 | - public function shareRoute($params) |
|
187 | - { |
|
188 | - $allQueryFields = array('route_id', 'response_format'); |
|
189 | - $allBodyFields = array('recipient_email'); |
|
186 | + public function shareRoute($params) |
|
187 | + { |
|
188 | + $allQueryFields = array('route_id', 'response_format'); |
|
189 | + $allBodyFields = array('recipient_email'); |
|
190 | 190 | |
191 | - $result = Route4Me::makeRequst(array( |
|
192 | - 'url' => Endpoint::ROUTE_SHARE, |
|
193 | - 'method' => 'POST', |
|
194 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
195 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
196 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
197 | - )); |
|
191 | + $result = Route4Me::makeRequst(array( |
|
192 | + 'url' => Endpoint::ROUTE_SHARE, |
|
193 | + 'method' => 'POST', |
|
194 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
195 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
196 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
197 | + )); |
|
198 | 198 | |
199 | - return $result; |
|
200 | - } |
|
199 | + return $result; |
|
200 | + } |
|
201 | 201 | |
202 | - // Returns random route_id from existing routes between $offset and $offset+$limit |
|
203 | - public function getRandomRouteId($offset, $limit) |
|
204 | - { |
|
205 | - $params = array( |
|
206 | - 'offset' => !is_null($offset) ? $offset : 0, |
|
207 | - 'limit' => !is_null($limit) ? $limit : 30 |
|
208 | - ); |
|
202 | + // Returns random route_id from existing routes between $offset and $offset+$limit |
|
203 | + public function getRandomRouteId($offset, $limit) |
|
204 | + { |
|
205 | + $params = array( |
|
206 | + 'offset' => !is_null($offset) ? $offset : 0, |
|
207 | + 'limit' => !is_null($limit) ? $limit : 30 |
|
208 | + ); |
|
209 | 209 | |
210 | - $routes = $this->getRoutes($params); |
|
210 | + $routes = $this->getRoutes($params); |
|
211 | 211 | |
212 | - if (is_null($routes) || sizeof($routes)<1) { |
|
213 | - echo "<br> There are no routes in the account. Please, create the routes first. <br>"; |
|
214 | - return null; |
|
215 | - } |
|
212 | + if (is_null($routes) || sizeof($routes)<1) { |
|
213 | + echo "<br> There are no routes in the account. Please, create the routes first. <br>"; |
|
214 | + return null; |
|
215 | + } |
|
216 | 216 | |
217 | - $randomIndex = rand(0, sizeof($routes) - 1); |
|
217 | + $randomIndex = rand(0, sizeof($routes) - 1); |
|
218 | 218 | |
219 | - return $routes[$randomIndex]->route_id; |
|
220 | - } |
|
219 | + return $routes[$randomIndex]->route_id; |
|
220 | + } |
|
221 | 221 | |
222 | - public function update() |
|
223 | - { |
|
224 | - $route = Route4Me::makeRequst(array( |
|
225 | - 'url' => Endpoint::ROUTE_V4, |
|
226 | - 'method' => 'PUT', |
|
227 | - 'query' => array( |
|
228 | - 'route_id' => isset($this->route_id) ? $this->route_id : null |
|
229 | - ), |
|
230 | - 'body' => array( |
|
231 | - 'parameters' => $this->parameters, |
|
232 | - ), |
|
233 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
234 | - )); |
|
222 | + public function update() |
|
223 | + { |
|
224 | + $route = Route4Me::makeRequst(array( |
|
225 | + 'url' => Endpoint::ROUTE_V4, |
|
226 | + 'method' => 'PUT', |
|
227 | + 'query' => array( |
|
228 | + 'route_id' => isset($this->route_id) ? $this->route_id : null |
|
229 | + ), |
|
230 | + 'body' => array( |
|
231 | + 'parameters' => $this->parameters, |
|
232 | + ), |
|
233 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
234 | + )); |
|
235 | 235 | |
236 | - return Route::fromArray($route); |
|
237 | - } |
|
236 | + return Route::fromArray($route); |
|
237 | + } |
|
238 | 238 | |
239 | - public function updateAddress($address = null) |
|
240 | - { |
|
241 | - $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) |
|
242 | - : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); |
|
239 | + public function updateAddress($address = null) |
|
240 | + { |
|
241 | + $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) |
|
242 | + : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); |
|
243 | 243 | |
244 | - $result = Route4Me::makeRequst(array( |
|
245 | - 'url' => Endpoint::ADDRESS_V4, |
|
246 | - 'method' => 'PUT', |
|
247 | - 'query' => array( |
|
248 | - 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
249 | - 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
250 | - ), |
|
251 | - 'body' => $body, |
|
252 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
253 | - )); |
|
244 | + $result = Route4Me::makeRequst(array( |
|
245 | + 'url' => Endpoint::ADDRESS_V4, |
|
246 | + 'method' => 'PUT', |
|
247 | + 'query' => array( |
|
248 | + 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
249 | + 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
250 | + ), |
|
251 | + 'body' => $body, |
|
252 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
253 | + )); |
|
254 | 254 | |
255 | - return $result; |
|
256 | - } |
|
255 | + return $result; |
|
256 | + } |
|
257 | 257 | |
258 | - public function updateRouteAddress() |
|
259 | - { |
|
260 | - $result = Route4Me::makeRequst(array( |
|
261 | - 'url' => Endpoint::ADDRESS_V4, |
|
262 | - 'method' => 'PUT', |
|
263 | - 'query' => array( |
|
264 | - 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
265 | - 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
266 | - ), |
|
267 | - 'body' => array( |
|
268 | - "parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null, |
|
269 | - "addresses" => isset($this->addresses) ? $this->addresses : null |
|
270 | - ), |
|
271 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
272 | - )); |
|
258 | + public function updateRouteAddress() |
|
259 | + { |
|
260 | + $result = Route4Me::makeRequst(array( |
|
261 | + 'url' => Endpoint::ADDRESS_V4, |
|
262 | + 'method' => 'PUT', |
|
263 | + 'query' => array( |
|
264 | + 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
265 | + 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
266 | + ), |
|
267 | + 'body' => array( |
|
268 | + "parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null, |
|
269 | + "addresses" => isset($this->addresses) ? $this->addresses : null |
|
270 | + ), |
|
271 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
272 | + )); |
|
273 | 273 | |
274 | - return $result; |
|
275 | - } |
|
274 | + return $result; |
|
275 | + } |
|
276 | 276 | |
277 | - public function addAddresses($params) |
|
278 | - { |
|
279 | - $allQueryFields = array('route_id'); |
|
280 | - $allBodyFields = array('addresses'); |
|
277 | + public function addAddresses($params) |
|
278 | + { |
|
279 | + $allQueryFields = array('route_id'); |
|
280 | + $allBodyFields = array('addresses'); |
|
281 | 281 | |
282 | - $route = Route4Me::makeRequst(array( |
|
283 | - 'url' => Endpoint::ROUTE_V4, |
|
284 | - 'method' => 'PUT', |
|
285 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
286 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
287 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
288 | - )); |
|
282 | + $route = Route4Me::makeRequst(array( |
|
283 | + 'url' => Endpoint::ROUTE_V4, |
|
284 | + 'method' => 'PUT', |
|
285 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
286 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
287 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
288 | + )); |
|
289 | 289 | |
290 | - return Route::fromArray($route); |
|
291 | - } |
|
290 | + return Route::fromArray($route); |
|
291 | + } |
|
292 | 292 | |
293 | - public function insertAddressOptimalPosition(array $params) |
|
294 | - { |
|
295 | - $allQueryFields = array('route_id'); |
|
296 | - $allBodyFields = array('addresses', 'optimal_position'); |
|
293 | + public function insertAddressOptimalPosition(array $params) |
|
294 | + { |
|
295 | + $allQueryFields = array('route_id'); |
|
296 | + $allBodyFields = array('addresses', 'optimal_position'); |
|
297 | 297 | |
298 | - $route = Route4Me::makeRequst(array( |
|
299 | - 'url' => Endpoint::ROUTE_V4, |
|
300 | - 'method' => 'PUT', |
|
301 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
302 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
303 | - )); |
|
298 | + $route = Route4Me::makeRequst(array( |
|
299 | + 'url' => Endpoint::ROUTE_V4, |
|
300 | + 'method' => 'PUT', |
|
301 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
302 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
303 | + )); |
|
304 | 304 | |
305 | - return Route::fromArray($route); |
|
306 | - } |
|
305 | + return Route::fromArray($route); |
|
306 | + } |
|
307 | 307 | |
308 | - public function addNoteFile($params) |
|
309 | - { |
|
310 | - $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
311 | - $rpath = realpath($fname); |
|
308 | + public function addNoteFile($params) |
|
309 | + { |
|
310 | + $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
311 | + $rpath = realpath($fname); |
|
312 | 312 | |
313 | - $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type'); |
|
314 | - $allBodyFields = array('strUpdateType', 'strFilename', 'strNoteContents'); |
|
313 | + $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type'); |
|
314 | + $allBodyFields = array('strUpdateType', 'strFilename', 'strNoteContents'); |
|
315 | 315 | |
316 | - $result = Route4Me::makeRequst(array( |
|
317 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
318 | - 'method' => 'POST', |
|
319 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
320 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
321 | - 'FILE' => $rpath, |
|
322 | - 'HTTPHEADER' => array( |
|
323 | - 'Content-Type: application/x-www-form-urlencoded' |
|
324 | - ) |
|
325 | - )); |
|
316 | + $result = Route4Me::makeRequst(array( |
|
317 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
318 | + 'method' => 'POST', |
|
319 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
320 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
321 | + 'FILE' => $rpath, |
|
322 | + 'HTTPHEADER' => array( |
|
323 | + 'Content-Type: application/x-www-form-urlencoded' |
|
324 | + ) |
|
325 | + )); |
|
326 | 326 | |
327 | - return $result; |
|
328 | - } |
|
327 | + return $result; |
|
328 | + } |
|
329 | 329 | |
330 | - public function deleteRoutes($route_id) |
|
331 | - { |
|
332 | - $result = Route4Me::makeRequst(array( |
|
333 | - 'url' => Endpoint::ROUTES_DELETE, |
|
334 | - 'method' => 'DELETE', |
|
335 | - 'query' => array( |
|
336 | - 'route_id' => $route_id, |
|
337 | - ) |
|
338 | - )); |
|
330 | + public function deleteRoutes($route_id) |
|
331 | + { |
|
332 | + $result = Route4Me::makeRequst(array( |
|
333 | + 'url' => Endpoint::ROUTES_DELETE, |
|
334 | + 'method' => 'DELETE', |
|
335 | + 'query' => array( |
|
336 | + 'route_id' => $route_id, |
|
337 | + ) |
|
338 | + )); |
|
339 | 339 | |
340 | - return $result; |
|
341 | - } |
|
340 | + return $result; |
|
341 | + } |
|
342 | 342 | |
343 | - public function GetAddressesFromRoute($route_id) |
|
344 | - { |
|
345 | - $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
343 | + public function GetAddressesFromRoute($route_id) |
|
344 | + { |
|
345 | + $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
346 | 346 | |
347 | - if (isset($route1)) { |
|
348 | - return $route1->addresses; |
|
349 | - } else { |
|
350 | - return null; |
|
351 | - } |
|
352 | - } |
|
347 | + if (isset($route1)) { |
|
348 | + return $route1->addresses; |
|
349 | + } else { |
|
350 | + return null; |
|
351 | + } |
|
352 | + } |
|
353 | 353 | |
354 | - public function GetRandomAddressFromRoute($route_id) |
|
355 | - { |
|
356 | - $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
354 | + public function GetRandomAddressFromRoute($route_id) |
|
355 | + { |
|
356 | + $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
357 | 357 | |
358 | - if (isset($route1)) { |
|
359 | - $addresses = $route1->addresses; |
|
358 | + if (isset($route1)) { |
|
359 | + $addresses = $route1->addresses; |
|
360 | 360 | |
361 | - $rnd = rand(0, sizeof($addresses) - 1); |
|
361 | + $rnd = rand(0, sizeof($addresses) - 1); |
|
362 | 362 | |
363 | - return $addresses[$rnd]; |
|
364 | - } else { |
|
365 | - return null; |
|
366 | - } |
|
367 | - } |
|
363 | + return $addresses[$rnd]; |
|
364 | + } else { |
|
365 | + return null; |
|
366 | + } |
|
367 | + } |
|
368 | 368 | |
369 | - public function getRouteId() |
|
370 | - { |
|
371 | - return $this->route_id; |
|
372 | - } |
|
369 | + public function getRouteId() |
|
370 | + { |
|
371 | + return $this->route_id; |
|
372 | + } |
|
373 | 373 | |
374 | - public function getOptimizationId() |
|
375 | - { |
|
376 | - return $this->optimization_problem_id; |
|
377 | - } |
|
374 | + public function getOptimizationId() |
|
375 | + { |
|
376 | + return $this->optimization_problem_id; |
|
377 | + } |
|
378 | 378 | |
379 | - public function GetLastLocation(array $params) |
|
380 | - { |
|
381 | - $allQueryFields = array('route_id', 'device_tracking_history'); |
|
379 | + public function GetLastLocation(array $params) |
|
380 | + { |
|
381 | + $allQueryFields = array('route_id', 'device_tracking_history'); |
|
382 | 382 | |
383 | - $route = Route4Me::makeRequst(array( |
|
384 | - 'url' => Endpoint::ROUTE_V4, |
|
385 | - 'method' => 'GET', |
|
386 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
387 | - )); |
|
383 | + $route = Route4Me::makeRequst(array( |
|
384 | + 'url' => Endpoint::ROUTE_V4, |
|
385 | + 'method' => 'GET', |
|
386 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
387 | + )); |
|
388 | 388 | |
389 | - return Route::fromArray($route); |
|
390 | - } |
|
389 | + return Route::fromArray($route); |
|
390 | + } |
|
391 | 391 | |
392 | - public function GetTrackingHistoryFromTimeRange(array $params) |
|
393 | - { |
|
394 | - $allQueryFields = array('route_id', 'format', 'time_period', 'start_date', 'end_date'); |
|
392 | + public function GetTrackingHistoryFromTimeRange(array $params) |
|
393 | + { |
|
394 | + $allQueryFields = array('route_id', 'format', 'time_period', 'start_date', 'end_date'); |
|
395 | 395 | |
396 | - $route = Route4Me::makeRequst(array( |
|
397 | - 'url' => Endpoint::GET_DEVICE_LOCATION, |
|
398 | - 'method' => 'GET', |
|
399 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
400 | - )); |
|
396 | + $route = Route4Me::makeRequst(array( |
|
397 | + 'url' => Endpoint::GET_DEVICE_LOCATION, |
|
398 | + 'method' => 'GET', |
|
399 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
400 | + )); |
|
401 | 401 | |
402 | - return $route; |
|
403 | - } |
|
402 | + return $route; |
|
403 | + } |
|
404 | 404 | |
405 | - public function GetAssetTracking(array $params) |
|
406 | - { |
|
407 | - $allQueryFields = array('tracking'); |
|
405 | + public function GetAssetTracking(array $params) |
|
406 | + { |
|
407 | + $allQueryFields = array('tracking'); |
|
408 | 408 | |
409 | - $route = Route4Me::makeRequst(array( |
|
410 | - 'url' => Endpoint::STATUS_V4, |
|
411 | - 'method' => 'GET', |
|
412 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
413 | - )); |
|
409 | + $route = Route4Me::makeRequst(array( |
|
410 | + 'url' => Endpoint::STATUS_V4, |
|
411 | + 'method' => 'GET', |
|
412 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
413 | + )); |
|
414 | 414 | |
415 | - return $route; |
|
416 | - } |
|
415 | + return $route; |
|
416 | + } |
|
417 | 417 | } |
@@ -171,7 +171,7 @@ |
||
171 | 171 | |
172 | 172 | public function mergeRoutes($params) |
173 | 173 | { |
174 | - $allBodyFields = array('route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng'); |
|
174 | + $allBodyFields = array('route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng'); |
|
175 | 175 | |
176 | 176 | $result = Route4Me::makeRequst(array( |
177 | 177 | 'url' => Endpoint::ROUTES_MERGE, |
@@ -6,320 +6,320 @@ |
||
6 | 6 | |
7 | 7 | class Member extends Common |
8 | 8 | { |
9 | - public $device_id; |
|
10 | - public $device_type; |
|
11 | - public $format; |
|
9 | + public $device_id; |
|
10 | + public $device_type; |
|
11 | + public $format; |
|
12 | 12 | |
13 | - public $strEmail; |
|
14 | - public $strPassword; |
|
15 | - public $strPassword_1; |
|
16 | - public $strPassword_2; |
|
17 | - public $strFirstName; |
|
18 | - public $strLastName; |
|
19 | - public $strIndustry; |
|
20 | - public $chkTerms; |
|
21 | - public $plan; |
|
13 | + public $strEmail; |
|
14 | + public $strPassword; |
|
15 | + public $strPassword_1; |
|
16 | + public $strPassword_2; |
|
17 | + public $strFirstName; |
|
18 | + public $strLastName; |
|
19 | + public $strIndustry; |
|
20 | + public $chkTerms; |
|
21 | + public $plan; |
|
22 | 22 | |
23 | - public $session_guid; |
|
24 | - public $member_id; |
|
23 | + public $session_guid; |
|
24 | + public $member_id; |
|
25 | 25 | |
26 | - public $email_address; |
|
27 | - public $first_name; |
|
28 | - public $last_name; |
|
29 | - public $phone_number; |
|
30 | - public $company_name; |
|
31 | - public $webiinar_date; |
|
26 | + public $email_address; |
|
27 | + public $first_name; |
|
28 | + public $last_name; |
|
29 | + public $phone_number; |
|
30 | + public $company_name; |
|
31 | + public $webiinar_date; |
|
32 | 32 | |
33 | - public $subscription_name; |
|
34 | - public $token; |
|
35 | - public $payload; |
|
33 | + public $subscription_name; |
|
34 | + public $token; |
|
35 | + public $payload; |
|
36 | 36 | |
37 | - public $HIDE_ROUTED_ADDRESSES; |
|
38 | - public $member_phone; |
|
39 | - public $member_zipcode; |
|
40 | - public $route_count; |
|
41 | - public $member_email; |
|
42 | - public $HIDE_VISITED_ADDRESSES; |
|
43 | - public $READONLY_USER; |
|
44 | - public $member_type; |
|
45 | - public $date_of_birth; |
|
46 | - public $member_first_name; |
|
47 | - public $member_password; |
|
48 | - public $HIDE_NONFUTURE_ROUTES; |
|
49 | - public $member_last_name; |
|
50 | - public $SHOW_ALL_VEHICLES; |
|
51 | - public $SHOW_ALL_DRIVERS; |
|
37 | + public $HIDE_ROUTED_ADDRESSES; |
|
38 | + public $member_phone; |
|
39 | + public $member_zipcode; |
|
40 | + public $route_count; |
|
41 | + public $member_email; |
|
42 | + public $HIDE_VISITED_ADDRESSES; |
|
43 | + public $READONLY_USER; |
|
44 | + public $member_type; |
|
45 | + public $date_of_birth; |
|
46 | + public $member_first_name; |
|
47 | + public $member_password; |
|
48 | + public $HIDE_NONFUTURE_ROUTES; |
|
49 | + public $member_last_name; |
|
50 | + public $SHOW_ALL_VEHICLES; |
|
51 | + public $SHOW_ALL_DRIVERS; |
|
52 | 52 | |
53 | - public $config_key; |
|
54 | - public $config_value; |
|
53 | + public $config_key; |
|
54 | + public $config_value; |
|
55 | 55 | |
56 | - public $preferred_units; |
|
57 | - public $preferred_language; |
|
58 | - public $timezone; |
|
59 | - public $OWNER_MEMBER_ID; |
|
60 | - public $user_reg_state_id; |
|
61 | - public $user_reg_country_id; |
|
62 | - public $member_picture; |
|
63 | - public $api_key; |
|
64 | - public $custom_data; |
|
56 | + public $preferred_units; |
|
57 | + public $preferred_language; |
|
58 | + public $timezone; |
|
59 | + public $OWNER_MEMBER_ID; |
|
60 | + public $user_reg_state_id; |
|
61 | + public $user_reg_country_id; |
|
62 | + public $member_picture; |
|
63 | + public $api_key; |
|
64 | + public $custom_data; |
|
65 | 65 | |
66 | - public static function fromArray(array $params) |
|
67 | - { |
|
68 | - $member= new Member(); |
|
69 | - |
|
70 | - foreach($params as $key => $value) { |
|
71 | - if (property_exists($member, $key)) { |
|
72 | - $member->{$key} = $value; |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - return $member; |
|
77 | - } |
|
66 | + public static function fromArray(array $params) |
|
67 | + { |
|
68 | + $member= new Member(); |
|
69 | + |
|
70 | + foreach($params as $key => $value) { |
|
71 | + if (property_exists($member, $key)) { |
|
72 | + $member->{$key} = $value; |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + return $member; |
|
77 | + } |
|
78 | 78 | |
79 | - public static function getUsers() |
|
80 | - { |
|
81 | - $response = Route4Me::makeRequst(array( |
|
82 | - 'url' => Endpoint::USER_V4, |
|
83 | - 'method' => 'GET' |
|
84 | - )); |
|
79 | + public static function getUsers() |
|
80 | + { |
|
81 | + $response = Route4Me::makeRequst(array( |
|
82 | + 'url' => Endpoint::USER_V4, |
|
83 | + 'method' => 'GET' |
|
84 | + )); |
|
85 | 85 | |
86 | - return $response; |
|
87 | - } |
|
86 | + return $response; |
|
87 | + } |
|
88 | 88 | |
89 | - public static function getUser($params) |
|
90 | - { |
|
91 | - $response = Route4Me::makeRequst(array( |
|
92 | - 'url' => Endpoint::USER_V4, |
|
93 | - 'method' => 'GET', |
|
94 | - 'query' => array( |
|
95 | - 'member_id' => isset($params['member_id']) ? $params['member_id'] : null |
|
96 | - ) |
|
97 | - )); |
|
89 | + public static function getUser($params) |
|
90 | + { |
|
91 | + $response = Route4Me::makeRequst(array( |
|
92 | + 'url' => Endpoint::USER_V4, |
|
93 | + 'method' => 'GET', |
|
94 | + 'query' => array( |
|
95 | + 'member_id' => isset($params['member_id']) ? $params['member_id'] : null |
|
96 | + ) |
|
97 | + )); |
|
98 | 98 | |
99 | - return $response; |
|
100 | - } |
|
99 | + return $response; |
|
100 | + } |
|
101 | 101 | |
102 | - public static function getUserLocations($param) |
|
103 | - { |
|
104 | - $response = Route4Me::makeRequst(array( |
|
105 | - 'url' => Endpoint::VIEW_USER_LOCATIONS, |
|
106 | - 'method' => 'GET', |
|
107 | - 'query' => array( |
|
108 | - 'query' => $param |
|
109 | - ) |
|
110 | - )); |
|
102 | + public static function getUserLocations($param) |
|
103 | + { |
|
104 | + $response = Route4Me::makeRequst(array( |
|
105 | + 'url' => Endpoint::VIEW_USER_LOCATIONS, |
|
106 | + 'method' => 'GET', |
|
107 | + 'query' => array( |
|
108 | + 'query' => $param |
|
109 | + ) |
|
110 | + )); |
|
111 | 111 | |
112 | - return $response; |
|
113 | - } |
|
112 | + return $response; |
|
113 | + } |
|
114 | 114 | |
115 | - public static function addDeviceRecord($params) |
|
116 | - { |
|
117 | - $allQueryFields = array('device_id', 'device_type'); |
|
118 | - $allBodyFields = array('device_id', 'device_type', 'format'); |
|
119 | - |
|
120 | - $response = Route4Me::makeRequst(array( |
|
121 | - 'url' => Endpoint::VERIFY_DEVICE_LICENSE, |
|
122 | - 'method' => 'POST', |
|
123 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
124 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
125 | - )); |
|
126 | - |
|
127 | - return $response; |
|
128 | - } |
|
115 | + public static function addDeviceRecord($params) |
|
116 | + { |
|
117 | + $allQueryFields = array('device_id', 'device_type'); |
|
118 | + $allBodyFields = array('device_id', 'device_type', 'format'); |
|
119 | + |
|
120 | + $response = Route4Me::makeRequst(array( |
|
121 | + 'url' => Endpoint::VERIFY_DEVICE_LICENSE, |
|
122 | + 'method' => 'POST', |
|
123 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
124 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
125 | + )); |
|
126 | + |
|
127 | + return $response; |
|
128 | + } |
|
129 | 129 | |
130 | - public static function createMember($params) |
|
131 | - { |
|
132 | - $excludeFields = array('session_guid', 'member_id', 'token', 'payload', 'webiinar_date', |
|
133 | - 'company_name', 'config_key', 'config_value', 'api_key'); |
|
130 | + public static function createMember($params) |
|
131 | + { |
|
132 | + $excludeFields = array('session_guid', 'member_id', 'token', 'payload', 'webiinar_date', |
|
133 | + 'company_name', 'config_key', 'config_value', 'api_key'); |
|
134 | 134 | |
135 | - $allBodyFields = Route4Me::getObjectProperties(new Member(), $excludeFields); |
|
135 | + $allBodyFields = Route4Me::getObjectProperties(new Member(), $excludeFields); |
|
136 | 136 | |
137 | - $response = Route4Me::makeRequst(array( |
|
138 | - 'url' => Endpoint::USER_V4, |
|
139 | - 'method' => 'POST', |
|
140 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
141 | - )); |
|
142 | - |
|
143 | - return $response; |
|
144 | - } |
|
137 | + $response = Route4Me::makeRequst(array( |
|
138 | + 'url' => Endpoint::USER_V4, |
|
139 | + 'method' => 'POST', |
|
140 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
141 | + )); |
|
142 | + |
|
143 | + return $response; |
|
144 | + } |
|
145 | 145 | |
146 | - public static function getRandomMemberByType($memberType) |
|
147 | - { |
|
148 | - $members = self::getUsers(); |
|
146 | + public static function getRandomMemberByType($memberType) |
|
147 | + { |
|
148 | + $members = self::getUsers(); |
|
149 | 149 | |
150 | - if (is_null($members)) return null; |
|
151 | - if (!isset($members['results'])) return null; |
|
150 | + if (is_null($members)) return null; |
|
151 | + if (!isset($members['results'])) return null; |
|
152 | 152 | |
153 | - $memberIDs = array(); |
|
153 | + $memberIDs = array(); |
|
154 | 154 | |
155 | - foreach ($members['results'] as $memb) { |
|
156 | - if (isset($memb['member_id']) && isset($memb['member_type'])) { |
|
157 | - if ($memberType==$memb['member_type']) $memberIDs[]=$memb['member_id']; |
|
158 | - } |
|
159 | - } |
|
155 | + foreach ($members['results'] as $memb) { |
|
156 | + if (isset($memb['member_id']) && isset($memb['member_type'])) { |
|
157 | + if ($memberType==$memb['member_type']) $memberIDs[]=$memb['member_id']; |
|
158 | + } |
|
159 | + } |
|
160 | 160 | |
161 | - if (sizeof($memberIDs)<1) return null; |
|
161 | + if (sizeof($memberIDs)<1) return null; |
|
162 | 162 | |
163 | - $randomIndex = rand(0, sizeof($memberIDs)-1); |
|
163 | + $randomIndex = rand(0, sizeof($memberIDs)-1); |
|
164 | 164 | |
165 | - return $memberIDs[$randomIndex]; |
|
166 | - } |
|
165 | + return $memberIDs[$randomIndex]; |
|
166 | + } |
|
167 | 167 | |
168 | 168 | |
169 | - public static function updateMember($body) |
|
170 | - { |
|
171 | - $excludeFields = array('session_guid', 'token', 'payload', 'webiinar_date', |
|
172 | - 'company_name', 'config_key', 'config_value', 'api_key'); |
|
169 | + public static function updateMember($body) |
|
170 | + { |
|
171 | + $excludeFields = array('session_guid', 'token', 'payload', 'webiinar_date', |
|
172 | + 'company_name', 'config_key', 'config_value', 'api_key'); |
|
173 | 173 | |
174 | - $allBodyFields = Route4Me::getObjectProperties(new Member(), $excludeFields); |
|
174 | + $allBodyFields = Route4Me::getObjectProperties(new Member(), $excludeFields); |
|
175 | 175 | |
176 | - $response = Route4Me::makeRequst(array( |
|
177 | - 'url' => Endpoint::USER_V4, |
|
178 | - 'method' => 'PUT', |
|
179 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $body) |
|
180 | - )); |
|
176 | + $response = Route4Me::makeRequst(array( |
|
177 | + 'url' => Endpoint::USER_V4, |
|
178 | + 'method' => 'PUT', |
|
179 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $body) |
|
180 | + )); |
|
181 | 181 | |
182 | - return $response; |
|
183 | - } |
|
182 | + return $response; |
|
183 | + } |
|
184 | 184 | |
185 | - public static function deleteMember($body) |
|
186 | - { |
|
187 | - $response = Route4Me::makeRequst(array( |
|
188 | - 'url' => Endpoint::USER_V4, |
|
189 | - 'method' => 'DELETE', |
|
190 | - 'body' => array( |
|
191 | - 'member_id' => isset($body->member_id) ? $body->member_id : null |
|
192 | - ) |
|
185 | + public static function deleteMember($body) |
|
186 | + { |
|
187 | + $response = Route4Me::makeRequst(array( |
|
188 | + 'url' => Endpoint::USER_V4, |
|
189 | + 'method' => 'DELETE', |
|
190 | + 'body' => array( |
|
191 | + 'member_id' => isset($body->member_id) ? $body->member_id : null |
|
192 | + ) |
|
193 | 193 | |
194 | - )); |
|
194 | + )); |
|
195 | 195 | |
196 | - return $response; |
|
197 | - } |
|
196 | + return $response; |
|
197 | + } |
|
198 | 198 | |
199 | - public static function newAccountRegistration($params) |
|
200 | - { |
|
201 | - $allQueryFields = array('plan'); |
|
202 | - $allBodyFields = array('strEmail', 'strPassword_1', 'strPassword_2', 'strFirstName', |
|
203 | - 'strLastName', 'format', 'strIndustry', 'chkTerms', |
|
204 | - 'device_type', 'strSubAccountType', 'blDisableMarketing', 'blDisableAccountActivationEmail'); |
|
205 | - |
|
206 | - $response = Route4Me::makeRequst(array( |
|
207 | - 'url' => Endpoint::REGISTER_ACTION, |
|
208 | - 'method' => 'POST', |
|
209 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
210 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
211 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
212 | - )); |
|
213 | - |
|
214 | - return $response; |
|
215 | - } |
|
199 | + public static function newAccountRegistration($params) |
|
200 | + { |
|
201 | + $allQueryFields = array('plan'); |
|
202 | + $allBodyFields = array('strEmail', 'strPassword_1', 'strPassword_2', 'strFirstName', |
|
203 | + 'strLastName', 'format', 'strIndustry', 'chkTerms', |
|
204 | + 'device_type', 'strSubAccountType', 'blDisableMarketing', 'blDisableAccountActivationEmail'); |
|
205 | + |
|
206 | + $response = Route4Me::makeRequst(array( |
|
207 | + 'url' => Endpoint::REGISTER_ACTION, |
|
208 | + 'method' => 'POST', |
|
209 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
210 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
211 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
212 | + )); |
|
213 | + |
|
214 | + return $response; |
|
215 | + } |
|
216 | 216 | |
217 | - public static function validateSession($params) |
|
218 | - { |
|
219 | - $allQueryFields = array('session_guid', 'member_id', 'format'); |
|
220 | - |
|
221 | - $response = Route4Me::makeRequst(array( |
|
222 | - 'url' => Endpoint::VALIDATE_SESSION, |
|
223 | - 'method' => 'GET', |
|
224 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
225 | - )); |
|
226 | - |
|
227 | - return $response; |
|
228 | - } |
|
217 | + public static function validateSession($params) |
|
218 | + { |
|
219 | + $allQueryFields = array('session_guid', 'member_id', 'format'); |
|
220 | + |
|
221 | + $response = Route4Me::makeRequst(array( |
|
222 | + 'url' => Endpoint::VALIDATE_SESSION, |
|
223 | + 'method' => 'GET', |
|
224 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
225 | + )); |
|
226 | + |
|
227 | + return $response; |
|
228 | + } |
|
229 | 229 | |
230 | - public static function memberAuthentication($params) |
|
231 | - { |
|
232 | - $allBodyFields = array('strEmail', 'strPassword', 'format'); |
|
233 | - |
|
234 | - $response = Route4Me::makeRequst(array( |
|
235 | - 'url' => Endpoint::AUTHENTICATE, |
|
236 | - 'method' => 'POST', |
|
237 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
238 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
239 | - )); |
|
240 | - |
|
241 | - return $response; |
|
242 | - } |
|
230 | + public static function memberAuthentication($params) |
|
231 | + { |
|
232 | + $allBodyFields = array('strEmail', 'strPassword', 'format'); |
|
233 | + |
|
234 | + $response = Route4Me::makeRequst(array( |
|
235 | + 'url' => Endpoint::AUTHENTICATE, |
|
236 | + 'method' => 'POST', |
|
237 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
238 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
239 | + )); |
|
240 | + |
|
241 | + return $response; |
|
242 | + } |
|
243 | 243 | |
244 | - public static function webinarRegistration($params) |
|
245 | - { |
|
246 | - $allBodyFields = array('email_address', 'first_name', 'last_name', 'phone_number', |
|
247 | - 'company_name', 'member_id', 'webiinar_date'); |
|
248 | - |
|
249 | - $response = Route4Me::makeRequst(array( |
|
250 | - 'url' => Endpoint::WEBINAR_REGISTER, |
|
251 | - 'method' => 'POST', |
|
252 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
253 | - )); |
|
254 | - |
|
255 | - return $response; |
|
256 | - } |
|
244 | + public static function webinarRegistration($params) |
|
245 | + { |
|
246 | + $allBodyFields = array('email_address', 'first_name', 'last_name', 'phone_number', |
|
247 | + 'company_name', 'member_id', 'webiinar_date'); |
|
248 | + |
|
249 | + $response = Route4Me::makeRequst(array( |
|
250 | + 'url' => Endpoint::WEBINAR_REGISTER, |
|
251 | + 'method' => 'POST', |
|
252 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
253 | + )); |
|
254 | + |
|
255 | + return $response; |
|
256 | + } |
|
257 | 257 | |
258 | - public static function purchaseUserLicense($params) |
|
259 | - { |
|
260 | - $allQueryFields = array('device_id'); |
|
261 | - $allBodyFields = array('member_id', 'session_guid', 'device_id', 'device_type', |
|
262 | - 'subscription_name', 'token', 'payload', 'format'); |
|
263 | - |
|
264 | - $response = Route4Me::makeRequst(array( |
|
265 | - 'url' => Endpoint::USER_LICENSE, |
|
266 | - 'method' => 'POST', |
|
267 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
268 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
269 | - )); |
|
270 | - |
|
271 | - return $response; |
|
272 | - } |
|
258 | + public static function purchaseUserLicense($params) |
|
259 | + { |
|
260 | + $allQueryFields = array('device_id'); |
|
261 | + $allBodyFields = array('member_id', 'session_guid', 'device_id', 'device_type', |
|
262 | + 'subscription_name', 'token', 'payload', 'format'); |
|
263 | + |
|
264 | + $response = Route4Me::makeRequst(array( |
|
265 | + 'url' => Endpoint::USER_LICENSE, |
|
266 | + 'method' => 'POST', |
|
267 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
268 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
269 | + )); |
|
270 | + |
|
271 | + return $response; |
|
272 | + } |
|
273 | 273 | |
274 | - public static function newMemberConfigKey($params) |
|
275 | - { |
|
276 | - $allBodyFields = array('config_key', 'config_value'); |
|
277 | - |
|
278 | - $response = Route4Me::makeRequst(array( |
|
279 | - 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
280 | - 'method' => 'POST', |
|
281 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
282 | - )); |
|
283 | - |
|
284 | - return $response; |
|
285 | - } |
|
274 | + public static function newMemberConfigKey($params) |
|
275 | + { |
|
276 | + $allBodyFields = array('config_key', 'config_value'); |
|
277 | + |
|
278 | + $response = Route4Me::makeRequst(array( |
|
279 | + 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
280 | + 'method' => 'POST', |
|
281 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
282 | + )); |
|
283 | + |
|
284 | + return $response; |
|
285 | + } |
|
286 | 286 | |
287 | - public static function removeMemberConfigKey($params) |
|
288 | - { |
|
289 | - $allBodyFields = array('config_key'); |
|
290 | - |
|
291 | - $response = Route4Me::makeRequst(array( |
|
292 | - 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
293 | - 'method' => 'DELETE', |
|
294 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
295 | - )); |
|
296 | - |
|
297 | - return $response; |
|
298 | - } |
|
287 | + public static function removeMemberConfigKey($params) |
|
288 | + { |
|
289 | + $allBodyFields = array('config_key'); |
|
290 | + |
|
291 | + $response = Route4Me::makeRequst(array( |
|
292 | + 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
293 | + 'method' => 'DELETE', |
|
294 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
295 | + )); |
|
296 | + |
|
297 | + return $response; |
|
298 | + } |
|
299 | 299 | |
300 | - public static function getMemberConfigData($params) |
|
301 | - { |
|
302 | - $allQueryFields = array('config_key'); |
|
303 | - |
|
304 | - $response = Route4Me::makeRequst(array( |
|
305 | - 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
306 | - 'method' => 'GET', |
|
307 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
308 | - )); |
|
309 | - |
|
310 | - return $response; |
|
311 | - } |
|
300 | + public static function getMemberConfigData($params) |
|
301 | + { |
|
302 | + $allQueryFields = array('config_key'); |
|
303 | + |
|
304 | + $response = Route4Me::makeRequst(array( |
|
305 | + 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
306 | + 'method' => 'GET', |
|
307 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
308 | + )); |
|
309 | + |
|
310 | + return $response; |
|
311 | + } |
|
312 | 312 | |
313 | - public static function updateMemberConfigKey($params) |
|
314 | - { |
|
315 | - $allBodyFields = array('config_key', 'config_value'); |
|
316 | - |
|
317 | - $response = Route4Me::makeRequst(array( |
|
318 | - 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
319 | - 'method' => 'PUT', |
|
320 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
321 | - )); |
|
322 | - |
|
323 | - return $response; |
|
324 | - } |
|
313 | + public static function updateMemberConfigKey($params) |
|
314 | + { |
|
315 | + $allBodyFields = array('config_key', 'config_value'); |
|
316 | + |
|
317 | + $response = Route4Me::makeRequst(array( |
|
318 | + 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
319 | + 'method' => 'PUT', |
|
320 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
321 | + )); |
|
322 | + |
|
323 | + return $response; |
|
324 | + } |
|
325 | 325 | } |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | |
66 | 66 | public static function fromArray(array $params) |
67 | 67 | { |
68 | - $member= new Member(); |
|
68 | + $member = new Member(); |
|
69 | 69 | |
70 | - foreach($params as $key => $value) { |
|
70 | + foreach ($params as $key => $value) { |
|
71 | 71 | if (property_exists($member, $key)) { |
72 | 72 | $member->{$key} = $value; |
73 | 73 | } |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | |
155 | 155 | foreach ($members['results'] as $memb) { |
156 | 156 | if (isset($memb['member_id']) && isset($memb['member_type'])) { |
157 | - if ($memberType==$memb['member_type']) $memberIDs[]=$memb['member_id']; |
|
157 | + if ($memberType==$memb['member_type']) $memberIDs[] = $memb['member_id']; |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | 161 | if (sizeof($memberIDs)<1) return null; |
162 | 162 | |
163 | - $randomIndex = rand(0, sizeof($memberIDs)-1); |
|
163 | + $randomIndex = rand(0, sizeof($memberIDs) - 1); |
|
164 | 164 | |
165 | 165 | return $memberIDs[$randomIndex]; |
166 | 166 | } |
@@ -6,452 +6,452 @@ |
||
6 | 6 | |
7 | 7 | class AddressBookLocation extends Common |
8 | 8 | { |
9 | - public $address_id; |
|
10 | - public $address_group; |
|
11 | - public $address_alias; |
|
12 | - public $address_1; |
|
13 | - public $address_2; |
|
14 | - public $first_name; |
|
15 | - public $last_name; |
|
16 | - public $address_email; |
|
17 | - public $address_phone_number; |
|
18 | - public $address_city; |
|
19 | - public $address_state_id; |
|
20 | - public $address_country_id; |
|
21 | - public $address_zip; |
|
22 | - public $cached_lat; |
|
23 | - public $cached_lng; |
|
24 | - public $curbside_lat; |
|
25 | - public $curbside_lng; |
|
26 | - public $color; |
|
27 | - public $address_custom_data; |
|
28 | - public $schedule; |
|
9 | + public $address_id; |
|
10 | + public $address_group; |
|
11 | + public $address_alias; |
|
12 | + public $address_1; |
|
13 | + public $address_2; |
|
14 | + public $first_name; |
|
15 | + public $last_name; |
|
16 | + public $address_email; |
|
17 | + public $address_phone_number; |
|
18 | + public $address_city; |
|
19 | + public $address_state_id; |
|
20 | + public $address_country_id; |
|
21 | + public $address_zip; |
|
22 | + public $cached_lat; |
|
23 | + public $cached_lng; |
|
24 | + public $curbside_lat; |
|
25 | + public $curbside_lng; |
|
26 | + public $color; |
|
27 | + public $address_custom_data; |
|
28 | + public $schedule; |
|
29 | 29 | |
30 | - public $created_timestamp; |
|
31 | - public $member_id; |
|
32 | - public $schedule_blacklist; |
|
33 | - public $in_route_count; |
|
34 | - public $last_visited_timestamp; |
|
35 | - public $last_routed_timestamp; |
|
36 | - public $local_time_window_start; |
|
37 | - public $local_time_window_end; |
|
38 | - public $local_time_window_start_2; |
|
39 | - public $local_time_window_end_2; |
|
40 | - public $service_time; |
|
41 | - public $local_timezone_string; |
|
42 | - public $address_icon; |
|
43 | - public $address_stop_type; |
|
44 | - public $address_cube; |
|
45 | - public $address_pieces; |
|
46 | - public $address_reference_no; |
|
47 | - public $address_revenue; |
|
48 | - public $address_weight; |
|
49 | - public $address_priority; |
|
50 | - public $address_customer_po; |
|
30 | + public $created_timestamp; |
|
31 | + public $member_id; |
|
32 | + public $schedule_blacklist; |
|
33 | + public $in_route_count; |
|
34 | + public $last_visited_timestamp; |
|
35 | + public $last_routed_timestamp; |
|
36 | + public $local_time_window_start; |
|
37 | + public $local_time_window_end; |
|
38 | + public $local_time_window_start_2; |
|
39 | + public $local_time_window_end_2; |
|
40 | + public $service_time; |
|
41 | + public $local_timezone_string; |
|
42 | + public $address_icon; |
|
43 | + public $address_stop_type; |
|
44 | + public $address_cube; |
|
45 | + public $address_pieces; |
|
46 | + public $address_reference_no; |
|
47 | + public $address_revenue; |
|
48 | + public $address_weight; |
|
49 | + public $address_priority; |
|
50 | + public $address_customer_po; |
|
51 | 51 | |
52 | - public static function fromArray(array $params) |
|
53 | - { |
|
54 | - $addressbooklocation = new AddressBookLocation(); |
|
52 | + public static function fromArray(array $params) |
|
53 | + { |
|
54 | + $addressbooklocation = new AddressBookLocation(); |
|
55 | 55 | |
56 | - foreach ($params as $key => $value) { |
|
57 | - if (property_exists($addressbooklocation, $key)) { |
|
58 | - $addressbooklocation->{$key} = $value; |
|
59 | - } |
|
60 | - } |
|
56 | + foreach ($params as $key => $value) { |
|
57 | + if (property_exists($addressbooklocation, $key)) { |
|
58 | + $addressbooklocation->{$key} = $value; |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - return $addressbooklocation; |
|
63 | - } |
|
62 | + return $addressbooklocation; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | 66 | |
67 | - public static function getAddressBookLocation($addressId) |
|
68 | - { |
|
69 | - $ablocations = Route4Me::makeRequst(array( |
|
70 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
71 | - 'method' => 'GET', |
|
72 | - 'query' => array( |
|
73 | - 'query' => $addressId, |
|
74 | - 'limit' => 30 |
|
75 | - ) |
|
76 | - )); |
|
67 | + public static function getAddressBookLocation($addressId) |
|
68 | + { |
|
69 | + $ablocations = Route4Me::makeRequst(array( |
|
70 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
71 | + 'method' => 'GET', |
|
72 | + 'query' => array( |
|
73 | + 'query' => $addressId, |
|
74 | + 'limit' => 30 |
|
75 | + ) |
|
76 | + )); |
|
77 | 77 | |
78 | - return $ablocations; |
|
79 | - } |
|
78 | + return $ablocations; |
|
79 | + } |
|
80 | 80 | |
81 | - public static function searchAddressBookLocations($params) |
|
82 | - { |
|
83 | - $allQueryFields = array('display', 'query', 'fields', 'limit', 'offset'); |
|
81 | + public static function searchAddressBookLocations($params) |
|
82 | + { |
|
83 | + $allQueryFields = array('display', 'query', 'fields', 'limit', 'offset'); |
|
84 | 84 | |
85 | - $result = Route4Me::makeRequst(array( |
|
86 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
87 | - 'method' => 'GET', |
|
88 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
89 | - )); |
|
85 | + $result = Route4Me::makeRequst(array( |
|
86 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
87 | + 'method' => 'GET', |
|
88 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
89 | + )); |
|
90 | 90 | |
91 | - return $result; |
|
92 | - } |
|
91 | + return $result; |
|
92 | + } |
|
93 | 93 | |
94 | - public static function getAddressBookLocations($params) |
|
95 | - { |
|
96 | - $allQueryFields = array('limit', 'offset'); |
|
94 | + public static function getAddressBookLocations($params) |
|
95 | + { |
|
96 | + $allQueryFields = array('limit', 'offset'); |
|
97 | 97 | |
98 | - $ablocations = Route4Me::makeRequst(array( |
|
99 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
100 | - 'method' => 'GET', |
|
101 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
102 | - )); |
|
98 | + $ablocations = Route4Me::makeRequst(array( |
|
99 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
100 | + 'method' => 'GET', |
|
101 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
102 | + )); |
|
103 | 103 | |
104 | - return $ablocations; |
|
105 | - } |
|
104 | + return $ablocations; |
|
105 | + } |
|
106 | 106 | |
107 | - public static function getAddressBookLocationsByIDs($ids) |
|
108 | - { |
|
109 | - $ablocations = Route4Me::makeRequst(array( |
|
110 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
111 | - 'method' => 'GET', |
|
112 | - 'query' => array( |
|
113 | - 'address_id' => $ids |
|
114 | - ) |
|
115 | - )); |
|
107 | + public static function getAddressBookLocationsByIDs($ids) |
|
108 | + { |
|
109 | + $ablocations = Route4Me::makeRequst(array( |
|
110 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
111 | + 'method' => 'GET', |
|
112 | + 'query' => array( |
|
113 | + 'address_id' => $ids |
|
114 | + ) |
|
115 | + )); |
|
116 | 116 | |
117 | - return $ablocations; |
|
118 | - } |
|
117 | + return $ablocations; |
|
118 | + } |
|
119 | 119 | |
120 | - public static function getRandomAddressBookLocation($params) |
|
121 | - { |
|
122 | - $ablocations = self::getAddressBookLocations(array('offset' => 0, 'limit' => 20)); |
|
120 | + public static function getRandomAddressBookLocation($params) |
|
121 | + { |
|
122 | + $ablocations = self::getAddressBookLocations(array('offset' => 0, 'limit' => 20)); |
|
123 | 123 | |
124 | - if (isset($ablocations["results"])) { |
|
125 | - $locationsSize = sizeof($ablocations["results"]); |
|
124 | + if (isset($ablocations["results"])) { |
|
125 | + $locationsSize = sizeof($ablocations["results"]); |
|
126 | 126 | |
127 | - if ($locationsSize>0) { |
|
128 | - $randomLocationIndex = rand(0, $locationsSize - 1); |
|
129 | - return $ablocations["results"][$randomLocationIndex]; |
|
130 | - } |
|
131 | - } |
|
127 | + if ($locationsSize>0) { |
|
128 | + $randomLocationIndex = rand(0, $locationsSize - 1); |
|
129 | + return $ablocations["results"][$randomLocationIndex]; |
|
130 | + } |
|
131 | + } |
|
132 | 132 | |
133 | - return null; |
|
134 | - } |
|
133 | + return null; |
|
134 | + } |
|
135 | 135 | |
136 | - /** |
|
137 | - * @param AddressBookLocation $params |
|
138 | - */ |
|
139 | - public static function addAdressBookLocation($params) |
|
140 | - { |
|
141 | - $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
136 | + /** |
|
137 | + * @param AddressBookLocation $params |
|
138 | + */ |
|
139 | + public static function addAdressBookLocation($params) |
|
140 | + { |
|
141 | + $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
142 | 142 | |
143 | - $response = Route4Me::makeRequst(array( |
|
144 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
145 | - 'method' => 'POST', |
|
146 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
147 | - )); |
|
143 | + $response = Route4Me::makeRequst(array( |
|
144 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
145 | + 'method' => 'POST', |
|
146 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
147 | + )); |
|
148 | 148 | |
149 | - return $response; |
|
150 | - } |
|
149 | + return $response; |
|
150 | + } |
|
151 | 151 | |
152 | - public function deleteAdressBookLocation($address_ids) |
|
153 | - { |
|
154 | - $result = Route4Me::makeRequst(array( |
|
155 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
156 | - 'method' => 'DELETEARRAY', |
|
157 | - 'query' => array( |
|
158 | - 'address_ids' => $address_ids |
|
159 | - ) |
|
160 | - )); |
|
152 | + public function deleteAdressBookLocation($address_ids) |
|
153 | + { |
|
154 | + $result = Route4Me::makeRequst(array( |
|
155 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
156 | + 'method' => 'DELETEARRAY', |
|
157 | + 'query' => array( |
|
158 | + 'address_ids' => $address_ids |
|
159 | + ) |
|
160 | + )); |
|
161 | 161 | |
162 | - return $result; |
|
163 | - } |
|
162 | + return $result; |
|
163 | + } |
|
164 | 164 | |
165 | - public function updateAdressBookLocation($params) |
|
166 | - { |
|
167 | - $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('in_route_count')); |
|
165 | + public function updateAdressBookLocation($params) |
|
166 | + { |
|
167 | + $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('in_route_count')); |
|
168 | 168 | |
169 | - $response = Route4Me::makeRequst(array( |
|
170 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
171 | - 'method' => 'PUT', |
|
172 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
173 | - )); |
|
169 | + $response = Route4Me::makeRequst(array( |
|
170 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
171 | + 'method' => 'PUT', |
|
172 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
173 | + )); |
|
174 | 174 | |
175 | - return $response; |
|
176 | - } |
|
175 | + return $response; |
|
176 | + } |
|
177 | 177 | |
178 | - public static function validateScheduleMode($scheduleMode) |
|
179 | - { |
|
180 | - $schedMmodes = array("daily", "weekly", "monthly", "annually"); |
|
178 | + public static function validateScheduleMode($scheduleMode) |
|
179 | + { |
|
180 | + $schedMmodes = array("daily", "weekly", "monthly", "annually"); |
|
181 | 181 | |
182 | - if (in_array($scheduleMode, $schedMmodes)) { |
|
183 | - return TRUE; |
|
184 | - } else { |
|
185 | - return FALSE; |
|
186 | - } |
|
187 | - } |
|
182 | + if (in_array($scheduleMode, $schedMmodes)) { |
|
183 | + return TRUE; |
|
184 | + } else { |
|
185 | + return FALSE; |
|
186 | + } |
|
187 | + } |
|
188 | 188 | |
189 | - public static function validateScheduleEnable($scheduleEnabled) |
|
190 | - { |
|
191 | - $schedEnables = array(TRUE, FALSE); |
|
189 | + public static function validateScheduleEnable($scheduleEnabled) |
|
190 | + { |
|
191 | + $schedEnables = array(TRUE, FALSE); |
|
192 | 192 | |
193 | - if (in_array($scheduleEnabled, $schedEnables)) { |
|
194 | - return TRUE; |
|
195 | - } else { |
|
196 | - return FALSE; |
|
197 | - } |
|
198 | - } |
|
193 | + if (in_array($scheduleEnabled, $schedEnables)) { |
|
194 | + return TRUE; |
|
195 | + } else { |
|
196 | + return FALSE; |
|
197 | + } |
|
198 | + } |
|
199 | 199 | |
200 | - public static function validateScheduleEvery($scheduleEvery) |
|
201 | - { |
|
202 | - if (is_numeric($scheduleEvery)) { |
|
203 | - return TRUE; |
|
204 | - } else { |
|
205 | - return FALSE; |
|
206 | - } |
|
207 | - } |
|
200 | + public static function validateScheduleEvery($scheduleEvery) |
|
201 | + { |
|
202 | + if (is_numeric($scheduleEvery)) { |
|
203 | + return TRUE; |
|
204 | + } else { |
|
205 | + return FALSE; |
|
206 | + } |
|
207 | + } |
|
208 | 208 | |
209 | - public static function validateScheduleWeekDays($scheduleWeekDays) |
|
210 | - { |
|
211 | - $weekdays = explode(',', $scheduleWeekDays); |
|
209 | + public static function validateScheduleWeekDays($scheduleWeekDays) |
|
210 | + { |
|
211 | + $weekdays = explode(',', $scheduleWeekDays); |
|
212 | 212 | |
213 | - if (sizeof($weekdays)<1) return FALSE; |
|
213 | + if (sizeof($weekdays)<1) return FALSE; |
|
214 | 214 | |
215 | - $isValid = TRUE; |
|
215 | + $isValid = TRUE; |
|
216 | 216 | |
217 | - for ($i=0; $i<sizeof($weekdays); $i++) { |
|
218 | - if (is_numeric($weekdays[$i])) { |
|
219 | - $wday = intval($weekdays[$i]); |
|
220 | - if ($wday<1 || $wday>7) $isValid = FALSE; |
|
221 | - } else { |
|
222 | - $isValid = FALSE; |
|
223 | - } |
|
224 | - } |
|
217 | + for ($i=0; $i<sizeof($weekdays); $i++) { |
|
218 | + if (is_numeric($weekdays[$i])) { |
|
219 | + $wday = intval($weekdays[$i]); |
|
220 | + if ($wday<1 || $wday>7) $isValid = FALSE; |
|
221 | + } else { |
|
222 | + $isValid = FALSE; |
|
223 | + } |
|
224 | + } |
|
225 | 225 | |
226 | - return $isValid; |
|
227 | - } |
|
226 | + return $isValid; |
|
227 | + } |
|
228 | 228 | |
229 | - public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
|
230 | - { |
|
231 | - $schedMonthlyMmodes = array("dates", "nth"); |
|
229 | + public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
|
230 | + { |
|
231 | + $schedMonthlyMmodes = array("dates", "nth"); |
|
232 | 232 | |
233 | - if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) { |
|
234 | - return TRUE; |
|
235 | - } else { |
|
236 | - return FALSE; |
|
237 | - } |
|
238 | - } |
|
233 | + if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) { |
|
234 | + return TRUE; |
|
235 | + } else { |
|
236 | + return FALSE; |
|
237 | + } |
|
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 | - } else { |
|
253 | - $isValid = FALSE; |
|
254 | - } |
|
255 | - } |
|
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 | + } else { |
|
253 | + $isValid = FALSE; |
|
254 | + } |
|
255 | + } |
|
256 | 256 | |
257 | - return $isValid; |
|
258 | - } |
|
257 | + return $isValid; |
|
258 | + } |
|
259 | 259 | |
260 | - public static function validateScheduleNthN($scheduleNthN) |
|
261 | - { |
|
262 | - if (!is_numeric($scheduleNthN)) return FALSE; |
|
260 | + public static function validateScheduleNthN($scheduleNthN) |
|
261 | + { |
|
262 | + if (!is_numeric($scheduleNthN)) return FALSE; |
|
263 | 263 | |
264 | - $schedNthNs = array(1, 2, 3, 4, 5, -1); |
|
264 | + $schedNthNs = array(1, 2, 3, 4, 5, -1); |
|
265 | 265 | |
266 | - if (in_array($scheduleNthN, $schedNthNs)) { |
|
267 | - return TRUE; |
|
268 | - } else { |
|
269 | - return FALSE; |
|
270 | - } |
|
271 | - } |
|
266 | + if (in_array($scheduleNthN, $schedNthNs)) { |
|
267 | + return TRUE; |
|
268 | + } else { |
|
269 | + return FALSE; |
|
270 | + } |
|
271 | + } |
|
272 | 272 | |
273 | - public static function validateScheduleNthWhat($scheduleNthWhat) |
|
274 | - { |
|
275 | - if (!is_numeric($scheduleNthWhat)) return FALSE; |
|
273 | + public static function validateScheduleNthWhat($scheduleNthWhat) |
|
274 | + { |
|
275 | + if (!is_numeric($scheduleNthWhat)) return FALSE; |
|
276 | 276 | |
277 | - $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
277 | + $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
278 | 278 | |
279 | - if (in_array($scheduleNthWhat, $schedNthWhats)) { |
|
280 | - return TRUE; |
|
281 | - } else { |
|
282 | - return FALSE; |
|
283 | - } |
|
284 | - } |
|
279 | + if (in_array($scheduleNthWhat, $schedNthWhats)) { |
|
280 | + return TRUE; |
|
281 | + } else { |
|
282 | + return FALSE; |
|
283 | + } |
|
284 | + } |
|
285 | 285 | |
286 | - /** Function adds the locations (with/without schedule) from the CSV file. |
|
287 | - * $csvFileHandle - a file handler. |
|
288 | - * Returns array $results which contains two arrays: fail and succes. |
|
289 | - */ |
|
290 | - public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping) |
|
291 | - { |
|
292 | - $max_line_length = 512; |
|
293 | - $delemietr = ','; |
|
286 | + /** Function adds the locations (with/without schedule) from the CSV file. |
|
287 | + * $csvFileHandle - a file handler. |
|
288 | + * Returns array $results which contains two arrays: fail and succes. |
|
289 | + */ |
|
290 | + public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping) |
|
291 | + { |
|
292 | + $max_line_length = 512; |
|
293 | + $delemietr = ','; |
|
294 | 294 | |
295 | - $results = array(); |
|
296 | - $results['fail'] = array(); |
|
297 | - $results['success'] = array(); |
|
295 | + $results = array(); |
|
296 | + $results['fail'] = array(); |
|
297 | + $results['success'] = array(); |
|
298 | 298 | |
299 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
299 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
300 | 300 | |
301 | - $addressBookFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
301 | + $addressBookFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
302 | 302 | |
303 | - if (empty($columns)) { |
|
304 | - array_push($results['fail'], 'Empty CSV table'); |
|
305 | - return ($results); |
|
306 | - } |
|
303 | + if (empty($columns)) { |
|
304 | + array_push($results['fail'], 'Empty CSV table'); |
|
305 | + return ($results); |
|
306 | + } |
|
307 | 307 | |
308 | - $iRow = 1; |
|
308 | + $iRow = 1; |
|
309 | 309 | |
310 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
311 | - if (!isset($rows[$locationsFieldsMapping['cached_lat']]) || !isset($rows[$locationsFieldsMapping['cached_lng']]) |
|
312 | - || !isset($rows[$locationsFieldsMapping['address_1']]) || array(null)==$rows) { |
|
313 | - continue; |
|
314 | - } |
|
310 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
311 | + if (!isset($rows[$locationsFieldsMapping['cached_lat']]) || !isset($rows[$locationsFieldsMapping['cached_lng']]) |
|
312 | + || !isset($rows[$locationsFieldsMapping['address_1']]) || array(null)==$rows) { |
|
313 | + continue; |
|
314 | + } |
|
315 | 315 | |
316 | - $curSchedule = ""; |
|
317 | - $mode = ""; |
|
316 | + $curSchedule = ""; |
|
317 | + $mode = ""; |
|
318 | 318 | |
319 | - $failCount = sizeof($results['fail']); |
|
319 | + $failCount = sizeof($results['fail']); |
|
320 | 320 | |
321 | - if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
322 | - if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
323 | - $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
324 | - $mode = $rows[$locationsFieldsMapping['schedule_mode']]; |
|
325 | - } else { |
|
326 | - array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); |
|
327 | - } |
|
328 | - } else { |
|
329 | - array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); |
|
330 | - } |
|
321 | + if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
322 | + if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
323 | + $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
324 | + $mode = $rows[$locationsFieldsMapping['schedule_mode']]; |
|
325 | + } else { |
|
326 | + array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); |
|
327 | + } |
|
328 | + } else { |
|
329 | + array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); |
|
330 | + } |
|
331 | 331 | |
332 | - if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
333 | - if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
334 | - $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
335 | - } else { |
|
336 | - array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set "); |
|
337 | - } |
|
338 | - } |
|
332 | + if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
333 | + if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
334 | + $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
335 | + } else { |
|
336 | + array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set "); |
|
337 | + } |
|
338 | + } |
|
339 | 339 | |
340 | - if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
341 | - if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
342 | - $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
343 | - if ($mode=='daily') { |
|
344 | - $curSchedule = trim($curSchedule,','); |
|
345 | - $curSchedule.='}'; |
|
346 | - } |
|
347 | - } else { |
|
348 | - array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); |
|
349 | - } |
|
350 | - } |
|
340 | + if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
341 | + if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
342 | + $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
343 | + if ($mode=='daily') { |
|
344 | + $curSchedule = trim($curSchedule,','); |
|
345 | + $curSchedule.='}'; |
|
346 | + } |
|
347 | + } else { |
|
348 | + array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); |
|
349 | + } |
|
350 | + } |
|
351 | 351 | |
352 | - if ($mode!='daily') { |
|
353 | - switch ($mode) { |
|
354 | - case 'weekly': |
|
355 | - if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
356 | - if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
357 | - $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
358 | - } else { |
|
359 | - array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
360 | - } |
|
361 | - } else { |
|
362 | - array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
363 | - } |
|
364 | - break; |
|
365 | - case 'monthly': |
|
366 | - $monthlyMode = ""; |
|
367 | - if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
368 | - if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
369 | - $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
370 | - $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
371 | - } else { |
|
372 | - array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
373 | - } |
|
374 | - } else { |
|
375 | - array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
376 | - } |
|
352 | + if ($mode!='daily') { |
|
353 | + switch ($mode) { |
|
354 | + case 'weekly': |
|
355 | + if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
356 | + if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
357 | + $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
358 | + } else { |
|
359 | + array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
360 | + } |
|
361 | + } else { |
|
362 | + array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
363 | + } |
|
364 | + break; |
|
365 | + case 'monthly': |
|
366 | + $monthlyMode = ""; |
|
367 | + if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
368 | + if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
369 | + $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
370 | + $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
371 | + } else { |
|
372 | + array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
373 | + } |
|
374 | + } else { |
|
375 | + array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
376 | + } |
|
377 | 377 | |
378 | - if ($monthlyMode!="") { |
|
379 | - switch ($monthlyMode) { |
|
380 | - case 'dates': |
|
381 | - if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
382 | - if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
383 | - $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
384 | - } else { |
|
385 | - array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
386 | - } |
|
387 | - } |
|
388 | - break; |
|
389 | - case 'nth': |
|
390 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
391 | - if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
392 | - $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
393 | - } else { |
|
394 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
395 | - } |
|
396 | - } else { |
|
397 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
398 | - } |
|
378 | + if ($monthlyMode!="") { |
|
379 | + switch ($monthlyMode) { |
|
380 | + case 'dates': |
|
381 | + if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
382 | + if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
383 | + $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
384 | + } else { |
|
385 | + array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
386 | + } |
|
387 | + } |
|
388 | + break; |
|
389 | + case 'nth': |
|
390 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
391 | + if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
392 | + $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
393 | + } else { |
|
394 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
395 | + } |
|
396 | + } else { |
|
397 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
398 | + } |
|
399 | 399 | |
400 | - if ($curSchedule!="") { |
|
401 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
402 | - if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
403 | - $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
404 | - } else { |
|
405 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
406 | - } |
|
407 | - } else { |
|
408 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
409 | - } |
|
410 | - } |
|
411 | - break; |
|
412 | - } |
|
413 | - } |
|
414 | - break; |
|
415 | - default: |
|
416 | - $curSchedule = ""; |
|
417 | - break; |
|
418 | - } |
|
419 | - } |
|
400 | + if ($curSchedule!="") { |
|
401 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
402 | + if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
403 | + $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
404 | + } else { |
|
405 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
406 | + } |
|
407 | + } else { |
|
408 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
409 | + } |
|
410 | + } |
|
411 | + break; |
|
412 | + } |
|
413 | + } |
|
414 | + break; |
|
415 | + default: |
|
416 | + $curSchedule = ""; |
|
417 | + break; |
|
418 | + } |
|
419 | + } |
|
420 | 420 | |
421 | - if (sizeof($results['fail'])>$failCount) { |
|
422 | - $curSchedule = ""; |
|
423 | - } |
|
421 | + if (sizeof($results['fail'])>$failCount) { |
|
422 | + $curSchedule = ""; |
|
423 | + } |
|
424 | 424 | |
425 | - if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") { |
|
426 | - $iRow++; |
|
427 | - continue; |
|
428 | - } |
|
425 | + if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") { |
|
426 | + $iRow++; |
|
427 | + continue; |
|
428 | + } |
|
429 | 429 | |
430 | - $curSchedule = strtolower($curSchedule); |
|
430 | + $curSchedule = strtolower($curSchedule); |
|
431 | 431 | |
432 | - $curSchedule = '[{'.$curSchedule.'}]'; |
|
432 | + $curSchedule = '[{'.$curSchedule.'}]'; |
|
433 | 433 | |
434 | - $oSchedule = json_decode($curSchedule,TRUE); |
|
434 | + $oSchedule = json_decode($curSchedule,TRUE); |
|
435 | 435 | |
436 | - $parametersArray = array(); |
|
436 | + $parametersArray = array(); |
|
437 | 437 | |
438 | - foreach ($addressBookFields as $addressBookField) { |
|
439 | - if (isset($locationsFieldsMapping[$addressBookField])) { |
|
440 | - $parametersArray[$addressBookField] = $rows[$locationsFieldsMapping[$addressBookField]]; |
|
441 | - } |
|
442 | - } |
|
438 | + foreach ($addressBookFields as $addressBookField) { |
|
439 | + if (isset($locationsFieldsMapping[$addressBookField])) { |
|
440 | + $parametersArray[$addressBookField] = $rows[$locationsFieldsMapping[$addressBookField]]; |
|
441 | + } |
|
442 | + } |
|
443 | 443 | |
444 | - $AdressBookLocationParameters = AddressBookLocation::fromArray($parametersArray); |
|
444 | + $AdressBookLocationParameters = AddressBookLocation::fromArray($parametersArray); |
|
445 | 445 | |
446 | - $abContacts = new AddressBookLocation(); |
|
446 | + $abContacts = new AddressBookLocation(); |
|
447 | 447 | |
448 | - $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
448 | + $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
449 | 449 | |
450 | - array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
451 | - } |
|
450 | + array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
451 | + } |
|
452 | 452 | |
453 | - return $results; |
|
454 | - } |
|
453 | + return $results; |
|
454 | + } |
|
455 | 455 | |
456 | 456 | } |
457 | 457 | |
458 | 458 | \ No newline at end of file |
@@ -351,70 +351,70 @@ |
||
351 | 351 | |
352 | 352 | if ($mode!='daily') { |
353 | 353 | switch ($mode) { |
354 | - case 'weekly': |
|
355 | - if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
356 | - if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
357 | - $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
358 | - } else { |
|
359 | - array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
360 | - } |
|
354 | + case 'weekly': |
|
355 | + if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
356 | + if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
357 | + $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
361 | 358 | } else { |
362 | - array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
359 | + array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
363 | 360 | } |
364 | - break; |
|
365 | - case 'monthly': |
|
366 | - $monthlyMode = ""; |
|
367 | - if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
368 | - if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
369 | - $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
370 | - $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
371 | - } else { |
|
372 | - array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
373 | - } |
|
361 | + } else { |
|
362 | + array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
363 | + } |
|
364 | + break; |
|
365 | + case 'monthly': |
|
366 | + $monthlyMode = ""; |
|
367 | + if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
368 | + if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
369 | + $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
370 | + $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
374 | 371 | } else { |
375 | - array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
372 | + array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
376 | 373 | } |
374 | + } else { |
|
375 | + array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
376 | + } |
|
377 | 377 | |
378 | - if ($monthlyMode!="") { |
|
379 | - switch ($monthlyMode) { |
|
380 | - case 'dates': |
|
381 | - if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
382 | - if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
383 | - $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
384 | - } else { |
|
385 | - array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
386 | - } |
|
387 | - } |
|
388 | - break; |
|
389 | - case 'nth': |
|
390 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
391 | - if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
392 | - $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
393 | - } else { |
|
394 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
395 | - } |
|
396 | - } else { |
|
397 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
398 | - } |
|
378 | + if ($monthlyMode!="") { |
|
379 | + switch ($monthlyMode) { |
|
380 | + case 'dates': |
|
381 | + if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
382 | + if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
383 | + $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
384 | + } else { |
|
385 | + array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
386 | + } |
|
387 | + } |
|
388 | + break; |
|
389 | + case 'nth': |
|
390 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
391 | + if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
392 | + $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
393 | + } else { |
|
394 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
395 | + } |
|
396 | + } else { |
|
397 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
398 | + } |
|
399 | 399 | |
400 | - if ($curSchedule!="") { |
|
401 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
402 | - if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
403 | - $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
404 | - } else { |
|
405 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
406 | - } |
|
407 | - } else { |
|
408 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
409 | - } |
|
410 | - } |
|
411 | - break; |
|
400 | + if ($curSchedule!="") { |
|
401 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
402 | + if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
403 | + $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
404 | + } else { |
|
405 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
412 | 406 | } |
407 | + } else { |
|
408 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
409 | + } |
|
413 | 410 | } |
414 | 411 | break; |
415 | - default: |
|
416 | - $curSchedule = ""; |
|
412 | + } |
|
413 | + } |
|
417 | 414 | break; |
415 | + default: |
|
416 | + $curSchedule = ""; |
|
417 | + break; |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | |
215 | 215 | $isValid = TRUE; |
216 | 216 | |
217 | - for ($i=0; $i<sizeof($weekdays); $i++) { |
|
217 | + for ($i = 0; $i<sizeof($weekdays); $i++) { |
|
218 | 218 | if (is_numeric($weekdays[$i])) { |
219 | 219 | $wday = intval($weekdays[$i]); |
220 | 220 | if ($wday<1 || $wday>7) $isValid = FALSE; |
@@ -241,14 +241,14 @@ discard block |
||
241 | 241 | { |
242 | 242 | $monthlyDates = explode(',', $scheduleMonthlyDates); |
243 | 243 | |
244 | - if (sizeof($monthlyDates) <1) return FALSE; |
|
244 | + if (sizeof($monthlyDates)<1) return FALSE; |
|
245 | 245 | |
246 | 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 | 250 | $mday = intval($monthlyDates[$i]); |
251 | - if ($mday <1 || $mday > 31) $isValid = FALSE; |
|
251 | + if ($mday<1 || $mday>31) $isValid = FALSE; |
|
252 | 252 | } else { |
253 | 253 | $isValid = FALSE; |
254 | 254 | } |
@@ -339,10 +339,10 @@ discard block |
||
339 | 339 | |
340 | 340 | if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
341 | 341 | if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
342 | - $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
342 | + $curSchedule .= '"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
343 | 343 | if ($mode=='daily') { |
344 | - $curSchedule = trim($curSchedule,','); |
|
345 | - $curSchedule.='}'; |
|
344 | + $curSchedule = trim($curSchedule, ','); |
|
345 | + $curSchedule .= '}'; |
|
346 | 346 | } |
347 | 347 | } else { |
348 | 348 | array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | |
432 | 432 | $curSchedule = '[{'.$curSchedule.'}]'; |
433 | 433 | |
434 | - $oSchedule = json_decode($curSchedule,TRUE); |
|
434 | + $oSchedule = json_decode($curSchedule, TRUE); |
|
435 | 435 | |
436 | 436 | $parametersArray = array(); |
437 | 437 |
@@ -8,283 +8,283 @@ |
||
8 | 8 | |
9 | 9 | class Address extends Common |
10 | 10 | { |
11 | - public $route_destination_id; |
|
12 | - public $alias; |
|
13 | - public $member_id; |
|
14 | - public $address; |
|
15 | - public $addressUpdate; |
|
16 | - public $is_depot = false; |
|
17 | - public $lat; |
|
18 | - public $lng; |
|
19 | - public $route_id; |
|
20 | - public $original_route_id; |
|
21 | - public $optimization_problem_id; |
|
22 | - public $sequence_no; |
|
23 | - public $geocoded; |
|
24 | - public $preferred_geocoding; |
|
25 | - public $failed_geocoding; |
|
26 | - public $geocodings = array(); |
|
27 | - public $contact_id; |
|
28 | - public $is_visited; |
|
29 | - public $customer_po; |
|
30 | - public $invoice_no; |
|
31 | - public $reference_no; |
|
32 | - public $order_no; |
|
33 | - public $weight; |
|
34 | - public $cost; |
|
35 | - public $revenue; |
|
36 | - public $cube; |
|
37 | - public $pieces; |
|
38 | - public $email; |
|
39 | - public $phone; |
|
40 | - public $tracking_number; |
|
41 | - public $destination_note_count; |
|
42 | - public $drive_time_to_next_destination; |
|
43 | - public $distance_to_next_destination; |
|
44 | - public $generated_time_window_start; |
|
45 | - public $generated_time_window_end; |
|
46 | - public $time_window_start; |
|
47 | - public $time_window_end; |
|
48 | - public $time; |
|
49 | - public $notes; |
|
50 | - public $timestamp_last_visited; |
|
51 | - public $custom_fields = array(); |
|
52 | - public $manifest = array(); |
|
11 | + public $route_destination_id; |
|
12 | + public $alias; |
|
13 | + public $member_id; |
|
14 | + public $address; |
|
15 | + public $addressUpdate; |
|
16 | + public $is_depot = false; |
|
17 | + public $lat; |
|
18 | + public $lng; |
|
19 | + public $route_id; |
|
20 | + public $original_route_id; |
|
21 | + public $optimization_problem_id; |
|
22 | + public $sequence_no; |
|
23 | + public $geocoded; |
|
24 | + public $preferred_geocoding; |
|
25 | + public $failed_geocoding; |
|
26 | + public $geocodings = array(); |
|
27 | + public $contact_id; |
|
28 | + public $is_visited; |
|
29 | + public $customer_po; |
|
30 | + public $invoice_no; |
|
31 | + public $reference_no; |
|
32 | + public $order_no; |
|
33 | + public $weight; |
|
34 | + public $cost; |
|
35 | + public $revenue; |
|
36 | + public $cube; |
|
37 | + public $pieces; |
|
38 | + public $email; |
|
39 | + public $phone; |
|
40 | + public $tracking_number; |
|
41 | + public $destination_note_count; |
|
42 | + public $drive_time_to_next_destination; |
|
43 | + public $distance_to_next_destination; |
|
44 | + public $generated_time_window_start; |
|
45 | + public $generated_time_window_end; |
|
46 | + public $time_window_start; |
|
47 | + public $time_window_end; |
|
48 | + public $time; |
|
49 | + public $notes; |
|
50 | + public $timestamp_last_visited; |
|
51 | + public $custom_fields = array(); |
|
52 | + public $manifest = array(); |
|
53 | 53 | |
54 | - public $first_name; |
|
55 | - public $last_name; |
|
56 | - public $is_departed; |
|
57 | - public $timestamp_last_departed; |
|
58 | - public $order_id; |
|
59 | - public $priority; |
|
60 | - public $curbside_lat; |
|
61 | - public $curbside_lng; |
|
62 | - public $time_window_start_2; |
|
63 | - public $time_window_end_2; |
|
54 | + public $first_name; |
|
55 | + public $last_name; |
|
56 | + public $is_departed; |
|
57 | + public $timestamp_last_departed; |
|
58 | + public $order_id; |
|
59 | + public $priority; |
|
60 | + public $curbside_lat; |
|
61 | + public $curbside_lng; |
|
62 | + public $time_window_start_2; |
|
63 | + public $time_window_end_2; |
|
64 | 64 | |
65 | - public static function fromArray(array $params) |
|
66 | - { |
|
67 | - $address = new Address(); |
|
68 | - foreach ($params as $key => $value) { |
|
69 | - if (property_exists($address, $key)) { |
|
70 | - $address->{$key} = $value; |
|
71 | - } |
|
72 | - } |
|
65 | + public static function fromArray(array $params) |
|
66 | + { |
|
67 | + $address = new Address(); |
|
68 | + foreach ($params as $key => $value) { |
|
69 | + if (property_exists($address, $key)) { |
|
70 | + $address->{$key} = $value; |
|
71 | + } |
|
72 | + } |
|
73 | 73 | |
74 | - return $address; |
|
75 | - } |
|
74 | + return $address; |
|
75 | + } |
|
76 | 76 | |
77 | - public static function getAddress($routeId, $addressId) |
|
78 | - { |
|
79 | - $address = Route4Me::makeRequst(array( |
|
80 | - 'url' => Endpoint::ADDRESS_V4, |
|
81 | - 'method' => 'GET', |
|
82 | - 'query' => array( |
|
83 | - 'route_id' => $routeId, |
|
84 | - 'route_destination_id' => $addressId, |
|
85 | - ) |
|
86 | - )); |
|
77 | + public static function getAddress($routeId, $addressId) |
|
78 | + { |
|
79 | + $address = Route4Me::makeRequst(array( |
|
80 | + 'url' => Endpoint::ADDRESS_V4, |
|
81 | + 'method' => 'GET', |
|
82 | + 'query' => array( |
|
83 | + 'route_id' => $routeId, |
|
84 | + 'route_destination_id' => $addressId, |
|
85 | + ) |
|
86 | + )); |
|
87 | 87 | |
88 | - return Address::fromArray($address); |
|
89 | - } |
|
88 | + return Address::fromArray($address); |
|
89 | + } |
|
90 | 90 | |
91 | - /*Get notes from the specified route destination |
|
91 | + /*Get notes from the specified route destination |
|
92 | 92 | * Returns an address object with notes, if an address exists, otherwise - return null. |
93 | 93 | */ |
94 | - public static function GetAddressesNotes($noteParams) |
|
95 | - { |
|
96 | - $address = Route4Me::makeRequst(array( |
|
97 | - 'url' => Endpoint::ADDRESS_V4, |
|
98 | - 'method' => 'GET', |
|
99 | - 'query' => array( |
|
100 | - 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, |
|
101 | - 'route_destination_id' => isset($noteParams['route_destination_id']) |
|
102 | - ? $noteParams['route_destination_id'] : null, |
|
103 | - 'notes' => 1, |
|
104 | - ) |
|
105 | - )); |
|
94 | + public static function GetAddressesNotes($noteParams) |
|
95 | + { |
|
96 | + $address = Route4Me::makeRequst(array( |
|
97 | + 'url' => Endpoint::ADDRESS_V4, |
|
98 | + 'method' => 'GET', |
|
99 | + 'query' => array( |
|
100 | + 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, |
|
101 | + 'route_destination_id' => isset($noteParams['route_destination_id']) |
|
102 | + ? $noteParams['route_destination_id'] : null, |
|
103 | + 'notes' => 1, |
|
104 | + ) |
|
105 | + )); |
|
106 | 106 | |
107 | - return $address; |
|
108 | - } |
|
107 | + return $address; |
|
108 | + } |
|
109 | 109 | |
110 | - public function update() |
|
111 | - { |
|
112 | - $addressUpdate = Route4Me::makeRequst(array( |
|
113 | - 'url' => Endpoint::ADDRESS_V4, |
|
114 | - 'method' => 'PUT', |
|
115 | - 'body' => $this->toArray(), |
|
116 | - 'query' => array( |
|
117 | - 'route_id' => $this->route_id, |
|
118 | - 'route_destination_id' => $this->route_destination_id, |
|
119 | - ), |
|
120 | - )); |
|
110 | + public function update() |
|
111 | + { |
|
112 | + $addressUpdate = Route4Me::makeRequst(array( |
|
113 | + 'url' => Endpoint::ADDRESS_V4, |
|
114 | + 'method' => 'PUT', |
|
115 | + 'body' => $this->toArray(), |
|
116 | + 'query' => array( |
|
117 | + 'route_id' => $this->route_id, |
|
118 | + 'route_destination_id' => $this->route_destination_id, |
|
119 | + ), |
|
120 | + )); |
|
121 | 121 | |
122 | - return Address::fromArray($addressUpdate); |
|
123 | - } |
|
122 | + return Address::fromArray($addressUpdate); |
|
123 | + } |
|
124 | 124 | |
125 | - public function markAddress($params) |
|
126 | - { |
|
127 | - $allQueryFields = array('route_id', 'route_destination_id'); |
|
128 | - $allBodyFields = array('is_visited', 'is_departed'); |
|
125 | + public function markAddress($params) |
|
126 | + { |
|
127 | + $allQueryFields = array('route_id', 'route_destination_id'); |
|
128 | + $allBodyFields = array('is_visited', 'is_departed'); |
|
129 | 129 | |
130 | - $result = Route4Me::makeRequst(array( |
|
131 | - 'url' => Endpoint::ADDRESS_V4, |
|
132 | - 'method' => 'PUT', |
|
133 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
134 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
135 | - )); |
|
130 | + $result = Route4Me::makeRequst(array( |
|
131 | + 'url' => Endpoint::ADDRESS_V4, |
|
132 | + 'method' => 'PUT', |
|
133 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
134 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
135 | + )); |
|
136 | 136 | |
137 | - return $result; |
|
138 | - } |
|
137 | + return $result; |
|
138 | + } |
|
139 | 139 | |
140 | - public function markAsDeparted($params) |
|
141 | - { |
|
142 | - $allQueryFields = array('route_id', 'address_id', 'is_departed', 'member_id'); |
|
140 | + public function markAsDeparted($params) |
|
141 | + { |
|
142 | + $allQueryFields = array('route_id', 'address_id', 'is_departed', 'member_id'); |
|
143 | 143 | |
144 | - $address = Route4Me::makeRequst(array( |
|
145 | - 'url' => Endpoint::MARK_ADDRESS_DEPARTED, |
|
146 | - 'method' => 'PUT', |
|
147 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
148 | - )); |
|
144 | + $address = Route4Me::makeRequst(array( |
|
145 | + 'url' => Endpoint::MARK_ADDRESS_DEPARTED, |
|
146 | + 'method' => 'PUT', |
|
147 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
148 | + )); |
|
149 | 149 | |
150 | - return $address; |
|
151 | - } |
|
150 | + return $address; |
|
151 | + } |
|
152 | 152 | |
153 | - public function markAsVisited($params) |
|
154 | - { |
|
155 | - $allQueryFields = array('route_id', 'address_id', 'is_visited', 'member_id'); |
|
153 | + public function markAsVisited($params) |
|
154 | + { |
|
155 | + $allQueryFields = array('route_id', 'address_id', 'is_visited', 'member_id'); |
|
156 | 156 | |
157 | - $address = Route4Me::makeRequst(array( |
|
158 | - 'url' => Endpoint::UPDATE_ADDRESS_VISITED, |
|
159 | - 'method' => 'PUT', |
|
160 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
161 | - )); |
|
157 | + $address = Route4Me::makeRequst(array( |
|
158 | + 'url' => Endpoint::UPDATE_ADDRESS_VISITED, |
|
159 | + 'method' => 'PUT', |
|
160 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
161 | + )); |
|
162 | 162 | |
163 | - return $address; |
|
164 | - } |
|
163 | + return $address; |
|
164 | + } |
|
165 | 165 | |
166 | - public function deleteAddress() |
|
167 | - { |
|
168 | - $address = Route4Me::makeRequst(array( |
|
169 | - 'url' => Endpoint::ADDRESS_V4, |
|
170 | - 'method' => 'DELETE', |
|
171 | - 'query' => array( |
|
172 | - 'route_id' => $this->route_id, |
|
173 | - 'route_destination_id' => $this->route_destination_id, |
|
174 | - ) |
|
175 | - )); |
|
166 | + public function deleteAddress() |
|
167 | + { |
|
168 | + $address = Route4Me::makeRequst(array( |
|
169 | + 'url' => Endpoint::ADDRESS_V4, |
|
170 | + 'method' => 'DELETE', |
|
171 | + 'query' => array( |
|
172 | + 'route_id' => $this->route_id, |
|
173 | + 'route_destination_id' => $this->route_destination_id, |
|
174 | + ) |
|
175 | + )); |
|
176 | 176 | |
177 | - return (bool)$address['deleted']; |
|
178 | - } |
|
177 | + return (bool)$address['deleted']; |
|
178 | + } |
|
179 | 179 | |
180 | - public function moveDestinationToRoute($params) |
|
181 | - { |
|
182 | - $allBodyFields = array('to_route_id', 'route_destination_id', 'after_destination_id'); |
|
180 | + public function moveDestinationToRoute($params) |
|
181 | + { |
|
182 | + $allBodyFields = array('to_route_id', 'route_destination_id', 'after_destination_id'); |
|
183 | 183 | |
184 | - $result = Route4Me::makeRequst(array( |
|
185 | - 'url' => Endpoint::MOVE_ROUTE_DESTINATION, |
|
186 | - 'method' => 'POST', |
|
187 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
188 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
189 | - )); |
|
184 | + $result = Route4Me::makeRequst(array( |
|
185 | + 'url' => Endpoint::MOVE_ROUTE_DESTINATION, |
|
186 | + 'method' => 'POST', |
|
187 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
188 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
189 | + )); |
|
190 | 190 | |
191 | - return $result; |
|
192 | - } |
|
191 | + return $result; |
|
192 | + } |
|
193 | 193 | |
194 | - public function AddAddressNote($params) |
|
195 | - { |
|
196 | - $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type'); |
|
197 | - $allBodyFields = array('strNoteContents', 'strUpdateType'); |
|
194 | + public function AddAddressNote($params) |
|
195 | + { |
|
196 | + $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type'); |
|
197 | + $allBodyFields = array('strNoteContents', 'strUpdateType'); |
|
198 | 198 | |
199 | - $result = Route4Me::makeRequst(array( |
|
200 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
201 | - 'method' => 'POST', |
|
202 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
203 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
204 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
205 | - )); |
|
199 | + $result = Route4Me::makeRequst(array( |
|
200 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
201 | + 'method' => 'POST', |
|
202 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
203 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
204 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
205 | + )); |
|
206 | 206 | |
207 | - return $result; |
|
208 | - } |
|
207 | + return $result; |
|
208 | + } |
|
209 | 209 | |
210 | - public function AddNoteFile($params) |
|
211 | - { |
|
212 | - $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type', 'strUpdateType'); |
|
213 | - $allBodyFields = array('strFilename'); |
|
210 | + public function AddNoteFile($params) |
|
211 | + { |
|
212 | + $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type', 'strUpdateType'); |
|
213 | + $allBodyFields = array('strFilename'); |
|
214 | 214 | |
215 | - $result = Route4Me::fileUploadRequest(array( |
|
216 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
217 | - 'method' => 'POST', |
|
218 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
219 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
220 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
221 | - )); |
|
215 | + $result = Route4Me::fileUploadRequest(array( |
|
216 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
217 | + 'method' => 'POST', |
|
218 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
219 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
220 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
221 | + )); |
|
222 | 222 | |
223 | - return $result; |
|
224 | - } |
|
223 | + return $result; |
|
224 | + } |
|
225 | 225 | |
226 | - public function createCustomNoteType($params) |
|
227 | - { |
|
228 | - $allBodyFields = array('type', 'values'); |
|
226 | + public function createCustomNoteType($params) |
|
227 | + { |
|
228 | + $allBodyFields = array('type', 'values'); |
|
229 | 229 | |
230 | - $result = Route4Me::makeRequst(array( |
|
231 | - 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
232 | - 'method' => 'POST', |
|
233 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
234 | - )); |
|
230 | + $result = Route4Me::makeRequst(array( |
|
231 | + 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
232 | + 'method' => 'POST', |
|
233 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
234 | + )); |
|
235 | 235 | |
236 | - return $result; |
|
237 | - } |
|
236 | + return $result; |
|
237 | + } |
|
238 | 238 | |
239 | - public function removeCustomNoteType($params) |
|
240 | - { |
|
241 | - $result = Route4Me::makeRequst(array( |
|
242 | - 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
243 | - 'method' => 'DELETE', |
|
244 | - 'body' => array( |
|
245 | - 'id' => isset($params['id']) ? $params['id'] : null |
|
246 | - ) |
|
247 | - )); |
|
239 | + public function removeCustomNoteType($params) |
|
240 | + { |
|
241 | + $result = Route4Me::makeRequst(array( |
|
242 | + 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
243 | + 'method' => 'DELETE', |
|
244 | + 'body' => array( |
|
245 | + 'id' => isset($params['id']) ? $params['id'] : null |
|
246 | + ) |
|
247 | + )); |
|
248 | 248 | |
249 | - return $result; |
|
250 | - } |
|
249 | + return $result; |
|
250 | + } |
|
251 | 251 | |
252 | - public function getAllCustomNoteTypes() |
|
253 | - { |
|
254 | - $result = Route4Me::makeRequst(array( |
|
255 | - 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
256 | - 'method' => 'GET' |
|
257 | - )); |
|
252 | + public function getAllCustomNoteTypes() |
|
253 | + { |
|
254 | + $result = Route4Me::makeRequst(array( |
|
255 | + 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
256 | + 'method' => 'GET' |
|
257 | + )); |
|
258 | 258 | |
259 | - return $result; |
|
260 | - } |
|
259 | + return $result; |
|
260 | + } |
|
261 | 261 | |
262 | - public function addCustomNoteToRoute($params) |
|
263 | - { |
|
264 | - $customArray = array(); |
|
262 | + public function addCustomNoteToRoute($params) |
|
263 | + { |
|
264 | + $customArray = array(); |
|
265 | 265 | |
266 | - foreach ($params as $key => $value) { |
|
267 | - if (strpos($key, "custom_note_type")!==false) { |
|
268 | - $customArray[$key] = $value; |
|
269 | - } |
|
270 | - } |
|
266 | + foreach ($params as $key => $value) { |
|
267 | + if (strpos($key, "custom_note_type")!==false) { |
|
268 | + $customArray[$key] = $value; |
|
269 | + } |
|
270 | + } |
|
271 | 271 | |
272 | - $allQueryFields = array('route_id', 'address_id', 'format', 'dev_lat', 'dev_lng'); |
|
273 | - $allBodyFields = array('strUpdateType', 'strUpdateType', 'strNoteContents'); |
|
272 | + $allQueryFields = array('route_id', 'address_id', 'format', 'dev_lat', 'dev_lng'); |
|
273 | + $allBodyFields = array('strUpdateType', 'strUpdateType', 'strNoteContents'); |
|
274 | 274 | |
275 | - $result = Route4Me::makeRequst(array( |
|
276 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
277 | - 'method' => 'POST', |
|
278 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
279 | - 'body' => array_merge(Route4Me::generateRequestParameters($allBodyFields, $params), $customArray), |
|
280 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
281 | - )); |
|
275 | + $result = Route4Me::makeRequst(array( |
|
276 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
277 | + 'method' => 'POST', |
|
278 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
279 | + 'body' => array_merge(Route4Me::generateRequestParameters($allBodyFields, $params), $customArray), |
|
280 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
281 | + )); |
|
282 | 282 | |
283 | - return $result; |
|
284 | - } |
|
283 | + return $result; |
|
284 | + } |
|
285 | 285 | |
286 | - function getAddressId() |
|
287 | - { |
|
288 | - return $this->route_destination_id; |
|
289 | - } |
|
286 | + function getAddressId() |
|
287 | + { |
|
288 | + return $this->route_destination_id; |
|
289 | + } |
|
290 | 290 | } |
@@ -11,236 +11,236 @@ |
||
11 | 11 | |
12 | 12 | class OptimizationProblem extends Common |
13 | 13 | { |
14 | - public $optimization_problem_id; |
|
15 | - public $user_errors = array(); |
|
16 | - public $state; |
|
17 | - public $optimization_errors = array(); |
|
18 | - public $parameters; |
|
19 | - public $sent_to_background; |
|
20 | - public $created_timestamp; |
|
21 | - public $scheduled_for; |
|
22 | - public $optimization_completed_timestamp; |
|
23 | - public $addresses = array(); |
|
24 | - public $routes = array(); |
|
25 | - public $links = array(); |
|
26 | - |
|
27 | - function __construct() |
|
28 | - { |
|
29 | - $this->parameters = new RouteParameters; |
|
30 | - } |
|
31 | - |
|
32 | - public static function fromArray(array $params) |
|
33 | - { |
|
34 | - $problem = new OptimizationProblem; |
|
35 | - $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
36 | - $problem->user_errors = Common::getValue($params, 'user_errors', array()); |
|
37 | - $problem->state = Common::getValue($params, 'state', array()); |
|
38 | - $problem->sent_to_background = Common::getValue($params, 'sent_to_background', array()); |
|
39 | - $problem->links = Common::getValue($params, 'links', array()); |
|
40 | - |
|
41 | - if (isset($params['parameters'])) { |
|
42 | - $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
43 | - } |
|
44 | - |
|
45 | - if (isset($params['addresses'])) { |
|
46 | - $addresses = array(); |
|
14 | + public $optimization_problem_id; |
|
15 | + public $user_errors = array(); |
|
16 | + public $state; |
|
17 | + public $optimization_errors = array(); |
|
18 | + public $parameters; |
|
19 | + public $sent_to_background; |
|
20 | + public $created_timestamp; |
|
21 | + public $scheduled_for; |
|
22 | + public $optimization_completed_timestamp; |
|
23 | + public $addresses = array(); |
|
24 | + public $routes = array(); |
|
25 | + public $links = array(); |
|
26 | + |
|
27 | + function __construct() |
|
28 | + { |
|
29 | + $this->parameters = new RouteParameters; |
|
30 | + } |
|
31 | + |
|
32 | + public static function fromArray(array $params) |
|
33 | + { |
|
34 | + $problem = new OptimizationProblem; |
|
35 | + $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
36 | + $problem->user_errors = Common::getValue($params, 'user_errors', array()); |
|
37 | + $problem->state = Common::getValue($params, 'state', array()); |
|
38 | + $problem->sent_to_background = Common::getValue($params, 'sent_to_background', array()); |
|
39 | + $problem->links = Common::getValue($params, 'links', array()); |
|
40 | + |
|
41 | + if (isset($params['parameters'])) { |
|
42 | + $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
43 | + } |
|
44 | + |
|
45 | + if (isset($params['addresses'])) { |
|
46 | + $addresses = array(); |
|
47 | 47 | |
48 | - foreach ($params['addresses'] as $address) { |
|
49 | - $addresses[] = Address::fromArray($address); |
|
50 | - } |
|
48 | + foreach ($params['addresses'] as $address) { |
|
49 | + $addresses[] = Address::fromArray($address); |
|
50 | + } |
|
51 | 51 | |
52 | - $problem->addresses = $addresses; |
|
53 | - } |
|
52 | + $problem->addresses = $addresses; |
|
53 | + } |
|
54 | 54 | |
55 | - if (isset($params['routes'])) { |
|
56 | - $routes = array(); |
|
55 | + if (isset($params['routes'])) { |
|
56 | + $routes = array(); |
|
57 | 57 | |
58 | - foreach ($params['routes'] as $route) { |
|
59 | - $routes[] = Route::fromArray($route); |
|
60 | - } |
|
58 | + foreach ($params['routes'] as $route) { |
|
59 | + $routes[] = Route::fromArray($route); |
|
60 | + } |
|
61 | 61 | |
62 | - $problem->routes = $routes; |
|
63 | - } |
|
64 | - |
|
65 | - return $problem; |
|
66 | - } |
|
67 | - |
|
68 | - public static function optimize(OptimizationProblemParams $params) |
|
69 | - { |
|
70 | - $allQueryFields = array('redirect', 'directions', 'format', 'route_path_output', 'optimized_callback_url'); |
|
71 | - |
|
72 | - $optimize = Route4Me::makeRequst(array( |
|
73 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
74 | - 'method' => 'POST', |
|
75 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
76 | - 'body' => array( |
|
77 | - 'addresses' => $params->getAddressesArray(), |
|
78 | - 'parameters' => $params->getParametersArray() |
|
79 | - ) |
|
80 | - )); |
|
81 | - |
|
82 | - return OptimizationProblem::fromArray($optimize); |
|
83 | - } |
|
84 | - |
|
85 | - public static function get($params) |
|
86 | - { |
|
87 | - $allQueryFields = array('state', 'limit', 'format', 'offset', |
|
88 | - 'optimization_problem_id', 'wait_for_final_state'); |
|
89 | - |
|
90 | - $optimize = Route4Me::makeRequst(array( |
|
91 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
92 | - 'method' => 'GET', |
|
93 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
94 | - )); |
|
95 | - |
|
96 | - if (isset($optimize['optimizations'])) { |
|
97 | - $problems = array(); |
|
62 | + $problem->routes = $routes; |
|
63 | + } |
|
64 | + |
|
65 | + return $problem; |
|
66 | + } |
|
67 | + |
|
68 | + public static function optimize(OptimizationProblemParams $params) |
|
69 | + { |
|
70 | + $allQueryFields = array('redirect', 'directions', 'format', 'route_path_output', 'optimized_callback_url'); |
|
71 | + |
|
72 | + $optimize = Route4Me::makeRequst(array( |
|
73 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
74 | + 'method' => 'POST', |
|
75 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
76 | + 'body' => array( |
|
77 | + 'addresses' => $params->getAddressesArray(), |
|
78 | + 'parameters' => $params->getParametersArray() |
|
79 | + ) |
|
80 | + )); |
|
81 | + |
|
82 | + return OptimizationProblem::fromArray($optimize); |
|
83 | + } |
|
84 | + |
|
85 | + public static function get($params) |
|
86 | + { |
|
87 | + $allQueryFields = array('state', 'limit', 'format', 'offset', |
|
88 | + 'optimization_problem_id', 'wait_for_final_state'); |
|
89 | + |
|
90 | + $optimize = Route4Me::makeRequst(array( |
|
91 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
92 | + 'method' => 'GET', |
|
93 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
94 | + )); |
|
95 | + |
|
96 | + if (isset($optimize['optimizations'])) { |
|
97 | + $problems = array(); |
|
98 | 98 | |
99 | - foreach ($optimize['optimizations'] as $problem) { |
|
100 | - $problems[] = OptimizationProblem::fromArray($problem); |
|
101 | - } |
|
99 | + foreach ($optimize['optimizations'] as $problem) { |
|
100 | + $problems[] = OptimizationProblem::fromArray($problem); |
|
101 | + } |
|
102 | 102 | |
103 | - return $problems; |
|
104 | - } else { |
|
105 | - return OptimizationProblem::fromArray($optimize); |
|
106 | - } |
|
107 | - } |
|
108 | - |
|
109 | - public static function reoptimize($params) |
|
110 | - { |
|
111 | - $param = new OptimizationProblemParams; |
|
112 | - $param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null; |
|
113 | - $param->reoptimize = 1; |
|
114 | - |
|
115 | - return self::update((array)$param); |
|
116 | - } |
|
117 | - |
|
118 | - public static function update($params) |
|
119 | - { |
|
120 | - $allQueryFields = array('optimization_problem_id', 'reoptimize'); |
|
121 | - $allBodyFields = array('addresses'); |
|
122 | - |
|
123 | - $optimize = Route4Me::makeRequst(array( |
|
124 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
125 | - 'method' => 'PUT', |
|
126 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
127 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
128 | - )); |
|
129 | - |
|
130 | - return $optimize; |
|
131 | - } |
|
132 | - |
|
133 | - public function getOptimizationId() |
|
134 | - { |
|
135 | - return $this->optimization_problem_id; |
|
136 | - } |
|
137 | - |
|
138 | - public function getRoutes() |
|
139 | - { |
|
140 | - return $this->routes; |
|
141 | - } |
|
103 | + return $problems; |
|
104 | + } else { |
|
105 | + return OptimizationProblem::fromArray($optimize); |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + public static function reoptimize($params) |
|
110 | + { |
|
111 | + $param = new OptimizationProblemParams; |
|
112 | + $param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null; |
|
113 | + $param->reoptimize = 1; |
|
114 | + |
|
115 | + return self::update((array)$param); |
|
116 | + } |
|
117 | + |
|
118 | + public static function update($params) |
|
119 | + { |
|
120 | + $allQueryFields = array('optimization_problem_id', 'reoptimize'); |
|
121 | + $allBodyFields = array('addresses'); |
|
122 | + |
|
123 | + $optimize = Route4Me::makeRequst(array( |
|
124 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
125 | + 'method' => 'PUT', |
|
126 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
127 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
128 | + )); |
|
129 | + |
|
130 | + return $optimize; |
|
131 | + } |
|
132 | + |
|
133 | + public function getOptimizationId() |
|
134 | + { |
|
135 | + return $this->optimization_problem_id; |
|
136 | + } |
|
137 | + |
|
138 | + public function getRoutes() |
|
139 | + { |
|
140 | + return $this->routes; |
|
141 | + } |
|
142 | 142 | |
143 | - public function getRandomOptimizationId($offset, $limit) |
|
144 | - { |
|
145 | - $optimizations = self::get(array('offset' => $offset, 'limit' => $limit)); |
|
143 | + public function getRandomOptimizationId($offset, $limit) |
|
144 | + { |
|
145 | + $optimizations = self::get(array('offset' => $offset, 'limit' => $limit)); |
|
146 | 146 | |
147 | - $rOptimization = $optimizations[rand(0,sizeof($optimizations)-1)]; |
|
148 | - |
|
149 | - if(!isset($rOptimization->optimization_problem_id)) { |
|
150 | - if (sizeof($optimizations)>9) { |
|
151 | - $this->getRandomOptimizationId($offset, $limit); |
|
152 | - } else { |
|
153 | - return null; |
|
154 | - } |
|
155 | - } |
|
147 | + $rOptimization = $optimizations[rand(0,sizeof($optimizations)-1)]; |
|
148 | + |
|
149 | + if(!isset($rOptimization->optimization_problem_id)) { |
|
150 | + if (sizeof($optimizations)>9) { |
|
151 | + $this->getRandomOptimizationId($offset, $limit); |
|
152 | + } else { |
|
153 | + return null; |
|
154 | + } |
|
155 | + } |
|
156 | 156 | |
157 | - return $rOptimization->optimization_problem_id; |
|
158 | - } |
|
157 | + return $rOptimization->optimization_problem_id; |
|
158 | + } |
|
159 | 159 | |
160 | - public function getAddresses($opt_id) |
|
161 | - { |
|
162 | - if ($opt_id==null) { |
|
163 | - return null; |
|
164 | - } |
|
160 | + public function getAddresses($opt_id) |
|
161 | + { |
|
162 | + if ($opt_id==null) { |
|
163 | + return null; |
|
164 | + } |
|
165 | 165 | |
166 | - $params = array("optimization_problem_id" => $opt_id ); |
|
166 | + $params = array("optimization_problem_id" => $opt_id ); |
|
167 | 167 | |
168 | - $optimization = (array)$this->get($params); |
|
168 | + $optimization = (array)$this->get($params); |
|
169 | 169 | |
170 | - $addresses = $optimization["addresses"]; |
|
170 | + $addresses = $optimization["addresses"]; |
|
171 | 171 | |
172 | - return $addresses; |
|
173 | - } |
|
172 | + return $addresses; |
|
173 | + } |
|
174 | 174 | |
175 | - public function getRandomAddressFromOptimization($opt_id) |
|
176 | - { |
|
177 | - $addresses = (array)$this->getAddresses($opt_id); |
|
175 | + public function getRandomAddressFromOptimization($opt_id) |
|
176 | + { |
|
177 | + $addresses = (array)$this->getAddresses($opt_id); |
|
178 | 178 | |
179 | - if ($addresses==null) { |
|
180 | - echo "There are no addresses in this optimization!.. Try again."; |
|
181 | - return null; |
|
182 | - } |
|
179 | + if ($addresses==null) { |
|
180 | + echo "There are no addresses in this optimization!.. Try again."; |
|
181 | + return null; |
|
182 | + } |
|
183 | 183 | |
184 | - $num = rand(0, sizeof($addresses)-1); |
|
184 | + $num = rand(0, sizeof($addresses)-1); |
|
185 | 185 | |
186 | - $rAddress = $addresses[$num]; |
|
186 | + $rAddress = $addresses[$num]; |
|
187 | 187 | |
188 | - return $rAddress; |
|
189 | - } |
|
188 | + return $rAddress; |
|
189 | + } |
|
190 | 190 | |
191 | - public function removeAddress($params) |
|
192 | - { |
|
193 | - $allQueryFields = array('optimization_problem_id', 'route_destination_id'); |
|
194 | - |
|
195 | - $response = Route4Me::makeRequst(array( |
|
196 | - 'url' => Endpoint::ADDRESS_V4, |
|
197 | - 'method' => 'DELETE', |
|
198 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
199 | - )); |
|
200 | - |
|
201 | - return $response; |
|
202 | - } |
|
191 | + public function removeAddress($params) |
|
192 | + { |
|
193 | + $allQueryFields = array('optimization_problem_id', 'route_destination_id'); |
|
194 | + |
|
195 | + $response = Route4Me::makeRequst(array( |
|
196 | + 'url' => Endpoint::ADDRESS_V4, |
|
197 | + 'method' => 'DELETE', |
|
198 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
199 | + )); |
|
200 | + |
|
201 | + return $response; |
|
202 | + } |
|
203 | 203 | |
204 | - public function removeOptimization($params) |
|
205 | - { |
|
206 | - $allQueryFields = array('redirect'); |
|
207 | - $allBodyFields = array('optimization_problem_ids'); |
|
208 | - |
|
209 | - $response = Route4Me::makeRequst(array( |
|
210 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
211 | - 'method' => 'DELETE', |
|
212 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
213 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
214 | - )); |
|
215 | - |
|
216 | - return $response; |
|
217 | - } |
|
204 | + public function removeOptimization($params) |
|
205 | + { |
|
206 | + $allQueryFields = array('redirect'); |
|
207 | + $allBodyFields = array('optimization_problem_ids'); |
|
208 | + |
|
209 | + $response = Route4Me::makeRequst(array( |
|
210 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
211 | + 'method' => 'DELETE', |
|
212 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
213 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
214 | + )); |
|
215 | + |
|
216 | + return $response; |
|
217 | + } |
|
218 | 218 | |
219 | - public function getHybridOptimization($params) |
|
220 | - { |
|
221 | - $allQueryFields = array('target_date_string', 'timezone_offset_minutes'); |
|
222 | - |
|
223 | - $optimize = Route4Me::makeRequst(array( |
|
224 | - 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
225 | - 'method' => 'GET', |
|
226 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
227 | - )); |
|
228 | - |
|
229 | - return $optimize; |
|
230 | - } |
|
219 | + public function getHybridOptimization($params) |
|
220 | + { |
|
221 | + $allQueryFields = array('target_date_string', 'timezone_offset_minutes'); |
|
222 | + |
|
223 | + $optimize = Route4Me::makeRequst(array( |
|
224 | + 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
225 | + 'method' => 'GET', |
|
226 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
227 | + )); |
|
228 | + |
|
229 | + return $optimize; |
|
230 | + } |
|
231 | 231 | |
232 | - Public function addDepotsToHybrid($params) |
|
233 | - { |
|
234 | - $allQueryFields = array('optimization_problem_id'); |
|
235 | - $allBodyFields = array('optimization_problem_id', 'delete_old_depots', 'new_depots'); |
|
236 | - |
|
237 | - $depots = Route4Me::makeRequst(array( |
|
238 | - 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
239 | - 'method' => 'POST', |
|
240 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
241 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
242 | - )); |
|
243 | - |
|
244 | - return $depots; |
|
245 | - } |
|
232 | + Public function addDepotsToHybrid($params) |
|
233 | + { |
|
234 | + $allQueryFields = array('optimization_problem_id'); |
|
235 | + $allBodyFields = array('optimization_problem_id', 'delete_old_depots', 'new_depots'); |
|
236 | + |
|
237 | + $depots = Route4Me::makeRequst(array( |
|
238 | + 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
239 | + 'method' => 'POST', |
|
240 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
241 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
242 | + )); |
|
243 | + |
|
244 | + return $depots; |
|
245 | + } |
|
246 | 246 | } |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | { |
145 | 145 | $optimizations = self::get(array('offset' => $offset, 'limit' => $limit)); |
146 | 146 | |
147 | - $rOptimization = $optimizations[rand(0,sizeof($optimizations)-1)]; |
|
147 | + $rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)]; |
|
148 | 148 | |
149 | - if(!isset($rOptimization->optimization_problem_id)) { |
|
149 | + if (!isset($rOptimization->optimization_problem_id)) { |
|
150 | 150 | if (sizeof($optimizations)>9) { |
151 | 151 | $this->getRandomOptimizationId($offset, $limit); |
152 | 152 | } else { |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | return null; |
164 | 164 | } |
165 | 165 | |
166 | - $params = array("optimization_problem_id" => $opt_id ); |
|
166 | + $params = array("optimization_problem_id" => $opt_id); |
|
167 | 167 | |
168 | 168 | $optimization = (array)$this->get($params); |
169 | 169 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | return null; |
182 | 182 | } |
183 | 183 | |
184 | - $num = rand(0, sizeof($addresses)-1); |
|
184 | + $num = rand(0, sizeof($addresses) - 1); |
|
185 | 185 | |
186 | 186 | $rAddress = $addresses[$num]; |
187 | 187 |