@@ -18,14 +18,14 @@ |
||
18 | 18 | |
19 | 19 | $territoryParams['type'] = TerritoryTypes::CIRCLE; |
20 | 20 | $territoryParams['data'] = array( |
21 | - "37.569752822786455,-77.47833251953125", |
|
22 | - "5000" |
|
21 | + "37.569752822786455,-77.47833251953125", |
|
22 | + "5000" |
|
23 | 23 | ); |
24 | 24 | |
25 | 25 | $TerritoryParameters = Territory::fromArray(array( |
26 | - "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | - "territory_color" => "ff7700", |
|
28 | - "territory" => $territoryParams |
|
26 | + "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | + "territory_color" => "ff7700", |
|
28 | + "territory" => $territoryParams |
|
29 | 29 | )); |
30 | 30 | |
31 | 31 | $territory = new Territory(); |
@@ -16,14 +16,14 @@ |
||
16 | 16 | |
17 | 17 | $territoryParams['type'] = TerritoryTypes::RECT; |
18 | 18 | $territoryParams['data'] = array( |
19 | - "43.51668853502909,-109.3798828125", |
|
20 | - "46.98025235521883,-101.865234375" |
|
19 | + "43.51668853502909,-109.3798828125", |
|
20 | + "46.98025235521883,-101.865234375" |
|
21 | 21 | ); |
22 | 22 | |
23 | 23 | $TerritoryParameters = Territory::fromArray(array( |
24 | - "territory_name" => "Test Rectangular Territory ".strval(rand(10000,99999)), |
|
25 | - "territory_color" => "ff7700", |
|
26 | - "territory" => $territoryParams |
|
24 | + "territory_name" => "Test Rectangular Territory ".strval(rand(10000,99999)), |
|
25 | + "territory_color" => "ff7700", |
|
26 | + "territory" => $territoryParams |
|
27 | 27 | )); |
28 | 28 | |
29 | 29 | $territory = new Territory(); |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | |
19 | 19 | $territoryParams['type'] = TerritoryTypes::CIRCLE; |
20 | 20 | $territoryParams['data'] = array( |
21 | - "37.569752822786455,-77.47833251953125", |
|
22 | - "5000" |
|
21 | + "37.569752822786455,-77.47833251953125", |
|
22 | + "5000" |
|
23 | 23 | ); |
24 | 24 | |
25 | 25 | $TerritoryParameters = Territory::fromArray(array( |
26 | - "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | - "territory_color" => "ff7700", |
|
28 | - "territory" => $territoryParams |
|
26 | + "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | + "territory_color" => "ff7700", |
|
28 | + "territory" => $territoryParams |
|
29 | 29 | )); |
30 | 30 | |
31 | 31 | $result = (array)$territory->addTerritory($TerritoryParameters); |
@@ -38,18 +38,18 @@ discard block |
||
38 | 38 | |
39 | 39 | // Update territory |
40 | 40 | $territoryParameters = array ( |
41 | - "type" => TerritoryTypes::RECT, |
|
42 | - "data" => array( |
|
43 | - "29.6600127358956,-95.6593322753906", |
|
44 | - "29.8966150753098,-95.3146362304688" |
|
45 | - ) |
|
41 | + "type" => TerritoryTypes::RECT, |
|
42 | + "data" => array( |
|
43 | + "29.6600127358956,-95.6593322753906", |
|
44 | + "29.8966150753098,-95.3146362304688" |
|
45 | + ) |
|
46 | 46 | ); |
47 | 47 | |
48 | 48 | $TerritoryParameters = Territory::fromArray(array( |
49 | - "territory_id" => $territory_id, |
|
50 | - "territory_name" => "Test Territory Updated as rectangle", |
|
51 | - "territory_color" => "ff5500", |
|
52 | - "territory" => $territoryParameters |
|
49 | + "territory_id" => $territory_id, |
|
50 | + "territory_name" => "Test Territory Updated as rectangle", |
|
51 | + "territory_color" => "ff5500", |
|
52 | + "territory" => $territoryParameters |
|
53 | 53 | )); |
54 | 54 | |
55 | 55 | $result1 = $territory->updateTerritory($TerritoryParameters); |
@@ -16,21 +16,21 @@ |
||
16 | 16 | |
17 | 17 | $territoryParams['type'] = TerritoryTypes::POLY; |
18 | 18 | $territoryParams['data'] = array( |
19 | - "37.769752822786455,-77.67833251953125", |
|
20 | - "37.75886716305343,-77.68974800109863", |
|
21 | - "37.74763966054455,-77.6917221069336", |
|
22 | - "37.74655084306813,-77.68863220214844", |
|
23 | - "37.7502255383101,-77.68125076293945", |
|
24 | - "37.74797991274437,-77.67498512268066", |
|
25 | - "37.73327960206065,-77.6411678314209", |
|
26 | - "37.74430510679532,-77.63172645568848", |
|
27 | - "37.76641925847049,-77.66846199035645" |
|
19 | + "37.769752822786455,-77.67833251953125", |
|
20 | + "37.75886716305343,-77.68974800109863", |
|
21 | + "37.74763966054455,-77.6917221069336", |
|
22 | + "37.74655084306813,-77.68863220214844", |
|
23 | + "37.7502255383101,-77.68125076293945", |
|
24 | + "37.74797991274437,-77.67498512268066", |
|
25 | + "37.73327960206065,-77.6411678314209", |
|
26 | + "37.74430510679532,-77.63172645568848", |
|
27 | + "37.76641925847049,-77.66846199035645" |
|
28 | 28 | ); |
29 | 29 | |
30 | 30 | $TerritoryParameters=Territory::fromArray(array( |
31 | - "territory_name" => "Test Polygonian Territory ".strval(rand(10000,99999)), |
|
32 | - "territory_color" => "ff7700", |
|
33 | - "territory" => $territoryParams |
|
31 | + "territory_name" => "Test Polygonian Territory ".strval(rand(10000,99999)), |
|
32 | + "territory_color" => "ff7700", |
|
33 | + "territory" => $territoryParams |
|
34 | 34 | )); |
35 | 35 | |
36 | 36 | $territory = new Territory(); |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | |
19 | 19 | $territoryParams['type'] = TerritoryTypes::CIRCLE; |
20 | 20 | $territoryParams['data'] = array( |
21 | - "37.569752822786455,-77.47833251953125", |
|
22 | - "5000" |
|
21 | + "37.569752822786455,-77.47833251953125", |
|
22 | + "5000" |
|
23 | 23 | ); |
24 | 24 | |
25 | 25 | $TerritoryParameters = Territory::fromArray(array( |
26 | - "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | - "territory_color" => "ff7700", |
|
28 | - "territory" => $territoryParams |
|
26 | + "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | + "territory_color" => "ff7700", |
|
28 | + "territory" => $territoryParams |
|
29 | 29 | )); |
30 | 30 | |
31 | 31 | $territory = new Territory(); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | echo "------------------------------------------------------------------------<br><br>"; |
42 | 42 | |
43 | 43 | $params = array( |
44 | - "territory_id" => $territory_id |
|
44 | + "territory_id" => $territory_id |
|
45 | 45 | ); |
46 | 46 | |
47 | 47 | $result1 = $territory->getTerritory($params); |
@@ -14,14 +14,14 @@ |
||
14 | 14 | |
15 | 15 | $territoryParams['type'] = TerritoryTypes::CIRCLE; |
16 | 16 | $territoryParams['data'] = array( |
17 | - "37.569752822786455,-77.47833251953125", |
|
18 | - "5000" |
|
17 | + "37.569752822786455,-77.47833251953125", |
|
18 | + "5000" |
|
19 | 19 | ); |
20 | 20 | |
21 | 21 | $TerritoryParameters = Territory::fromArray(array( |
22 | - "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
23 | - "territory_color" => "ff7700", |
|
24 | - "territory" => $territoryParams |
|
22 | + "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
23 | + "territory_color" => "ff7700", |
|
24 | + "territory" => $territoryParams |
|
25 | 25 | )); |
26 | 26 | |
27 | 27 | $territory = new Territory(); |
@@ -11,271 +11,271 @@ |
||
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(); |
|
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 | 26 | |
27 | - function __construct() |
|
28 | - { |
|
29 | - $this->parameters = new RouteParameters; |
|
30 | - } |
|
27 | + function __construct() |
|
28 | + { |
|
29 | + $this->parameters = new RouteParameters; |
|
30 | + } |
|
31 | 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()); |
|
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 | 40 | |
41 | - if (isset($params['parameters'])) { |
|
42 | - $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
43 | - } |
|
41 | + if (isset($params['parameters'])) { |
|
42 | + $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
43 | + } |
|
44 | 44 | |
45 | - if (isset($params['addresses'])) { |
|
46 | - $addresses = array(); |
|
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 | - } |
|
62 | + $problem->routes = $routes; |
|
63 | + } |
|
64 | 64 | |
65 | - return $problem; |
|
66 | - } |
|
65 | + return $problem; |
|
66 | + } |
|
67 | 67 | |
68 | - public static function optimize(OptimizationProblemParams $params) |
|
69 | - { |
|
70 | - $optimize = Route4Me::makeRequst(array( |
|
71 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
72 | - 'method' => 'POST', |
|
73 | - 'query' => array( |
|
74 | - 'redirect' => isset($params->redirect) ? $params->redirect : null, |
|
75 | - 'directions' => isset($params->directions) ? $params->directions : null, |
|
76 | - 'format' => isset($params->format) ? $params->format : null, |
|
77 | - 'route_path_output' => isset($params->route_path_output) ? $params->route_path_output : null, |
|
78 | - 'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url : null |
|
79 | - ), |
|
80 | - 'body' => array( |
|
81 | - 'addresses' => $params->getAddressesArray(), |
|
82 | - 'parameters' => $params->getParametersArray() |
|
83 | - ) |
|
84 | - )); |
|
68 | + public static function optimize(OptimizationProblemParams $params) |
|
69 | + { |
|
70 | + $optimize = Route4Me::makeRequst(array( |
|
71 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
72 | + 'method' => 'POST', |
|
73 | + 'query' => array( |
|
74 | + 'redirect' => isset($params->redirect) ? $params->redirect : null, |
|
75 | + 'directions' => isset($params->directions) ? $params->directions : null, |
|
76 | + 'format' => isset($params->format) ? $params->format : null, |
|
77 | + 'route_path_output' => isset($params->route_path_output) ? $params->route_path_output : null, |
|
78 | + 'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url : null |
|
79 | + ), |
|
80 | + 'body' => array( |
|
81 | + 'addresses' => $params->getAddressesArray(), |
|
82 | + 'parameters' => $params->getParametersArray() |
|
83 | + ) |
|
84 | + )); |
|
85 | 85 | |
86 | - return OptimizationProblem::fromArray($optimize); |
|
87 | - } |
|
86 | + return OptimizationProblem::fromArray($optimize); |
|
87 | + } |
|
88 | 88 | |
89 | - public static function get($params) |
|
90 | - { |
|
91 | - $optimize = Route4Me::makeRequst(array( |
|
92 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
93 | - 'method' => 'GET', |
|
94 | - 'query' => array( |
|
95 | - 'state' => isset($params['state']) ? $params['state'] : null, |
|
96 | - 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
97 | - 'offset' => isset($params['offset']) ? $params['offset'] : null, |
|
98 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
99 | - ? $params['optimization_problem_id'] : null, |
|
100 | - 'wait_for_final_state' => isset($params['wait_for_final_state']) |
|
101 | - ? $params['wait_for_final_state'] : null, |
|
102 | - ) |
|
103 | - )); |
|
89 | + public static function get($params) |
|
90 | + { |
|
91 | + $optimize = Route4Me::makeRequst(array( |
|
92 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
93 | + 'method' => 'GET', |
|
94 | + 'query' => array( |
|
95 | + 'state' => isset($params['state']) ? $params['state'] : null, |
|
96 | + 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
97 | + 'offset' => isset($params['offset']) ? $params['offset'] : null, |
|
98 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
99 | + ? $params['optimization_problem_id'] : null, |
|
100 | + 'wait_for_final_state' => isset($params['wait_for_final_state']) |
|
101 | + ? $params['wait_for_final_state'] : null, |
|
102 | + ) |
|
103 | + )); |
|
104 | 104 | |
105 | - if (isset($optimize['optimizations'])) { |
|
106 | - $problems = array(); |
|
105 | + if (isset($optimize['optimizations'])) { |
|
106 | + $problems = array(); |
|
107 | 107 | |
108 | - foreach ($optimize['optimizations'] as $problem) { |
|
109 | - $problems[] = OptimizationProblem::fromArray($problem); |
|
110 | - } |
|
108 | + foreach ($optimize['optimizations'] as $problem) { |
|
109 | + $problems[] = OptimizationProblem::fromArray($problem); |
|
110 | + } |
|
111 | 111 | |
112 | - return $problems; |
|
113 | - } else { |
|
114 | - return OptimizationProblem::fromArray($optimize); |
|
115 | - } |
|
116 | - } |
|
112 | + return $problems; |
|
113 | + } else { |
|
114 | + return OptimizationProblem::fromArray($optimize); |
|
115 | + } |
|
116 | + } |
|
117 | 117 | |
118 | - public static function reoptimize($params) |
|
119 | - { |
|
120 | - $param = new OptimizationProblemParams; |
|
121 | - $param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null; |
|
122 | - $param->reoptimize = 1; |
|
118 | + public static function reoptimize($params) |
|
119 | + { |
|
120 | + $param = new OptimizationProblemParams; |
|
121 | + $param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null; |
|
122 | + $param->reoptimize = 1; |
|
123 | 123 | |
124 | - return self::update((array)$param); |
|
125 | - } |
|
124 | + return self::update((array)$param); |
|
125 | + } |
|
126 | 126 | |
127 | - public static function update($params) |
|
128 | - { |
|
129 | - $optimize = Route4Me::makeRequst(array( |
|
130 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
131 | - 'method' => 'PUT', |
|
132 | - 'query' => array( |
|
133 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
134 | - ? $params['optimization_problem_id'] : null, |
|
135 | - 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
136 | - 'reoptimize' => isset($params['reoptimize']) ? $params['reoptimize'] : null, |
|
137 | - ) |
|
138 | - )); |
|
127 | + public static function update($params) |
|
128 | + { |
|
129 | + $optimize = Route4Me::makeRequst(array( |
|
130 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
131 | + 'method' => 'PUT', |
|
132 | + 'query' => array( |
|
133 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
134 | + ? $params['optimization_problem_id'] : null, |
|
135 | + 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
136 | + 'reoptimize' => isset($params['reoptimize']) ? $params['reoptimize'] : null, |
|
137 | + ) |
|
138 | + )); |
|
139 | 139 | |
140 | - return $optimize; |
|
141 | - } |
|
140 | + return $optimize; |
|
141 | + } |
|
142 | 142 | |
143 | - public function getOptimizationId() |
|
144 | - { |
|
145 | - return $this->optimization_problem_id; |
|
146 | - } |
|
143 | + public function getOptimizationId() |
|
144 | + { |
|
145 | + return $this->optimization_problem_id; |
|
146 | + } |
|
147 | 147 | |
148 | - public function getRoutes() |
|
149 | - { |
|
150 | - return $this->routes; |
|
151 | - } |
|
148 | + public function getRoutes() |
|
149 | + { |
|
150 | + return $this->routes; |
|
151 | + } |
|
152 | 152 | |
153 | - public function getRandomOptimizationId($offset, $limit) |
|
154 | - { |
|
155 | - $query['limit'] = !is_null($limit) ? $limit : 30; |
|
156 | - $query['offset'] = !is_null($offset) ? $offset : 0; |
|
153 | + public function getRandomOptimizationId($offset, $limit) |
|
154 | + { |
|
155 | + $query['limit'] = !is_null($limit) ? $limit : 30; |
|
156 | + $query['offset'] = !is_null($offset) ? $offset : 0; |
|
157 | 157 | |
158 | - $json = Route4Me::makeRequst(array( |
|
159 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
160 | - 'method' => 'GET', |
|
161 | - 'query' => $query |
|
162 | - )); |
|
158 | + $json = Route4Me::makeRequst(array( |
|
159 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
160 | + 'method' => 'GET', |
|
161 | + 'query' => $query |
|
162 | + )); |
|
163 | 163 | |
164 | - $optimizations = array(); |
|
165 | - foreach ($json as $optimization) { |
|
166 | - if (gettype($optimization)!="array") { |
|
167 | - continue; |
|
168 | - } |
|
164 | + $optimizations = array(); |
|
165 | + foreach ($json as $optimization) { |
|
166 | + if (gettype($optimization)!="array") { |
|
167 | + continue; |
|
168 | + } |
|
169 | 169 | |
170 | - foreach ($optimization as $otp1) { |
|
171 | - $optimizations[] = $otp1; |
|
172 | - } |
|
173 | - } |
|
170 | + foreach ($optimization as $otp1) { |
|
171 | + $optimizations[] = $otp1; |
|
172 | + } |
|
173 | + } |
|
174 | 174 | |
175 | - $num = rand(0,sizeof($optimizations)-1); |
|
175 | + $num = rand(0,sizeof($optimizations)-1); |
|
176 | 176 | |
177 | - $rOptimization = $optimizations[$num]; |
|
177 | + $rOptimization = $optimizations[$num]; |
|
178 | 178 | |
179 | - return $rOptimization['optimization_problem_id']; |
|
180 | - } |
|
179 | + return $rOptimization['optimization_problem_id']; |
|
180 | + } |
|
181 | 181 | |
182 | - public function getAddresses($opt_id) |
|
183 | - { |
|
184 | - if ($opt_id==null) { |
|
185 | - return null; |
|
186 | - } |
|
182 | + public function getAddresses($opt_id) |
|
183 | + { |
|
184 | + if ($opt_id==null) { |
|
185 | + return null; |
|
186 | + } |
|
187 | 187 | |
188 | - $params = array("optimization_problem_id" => $opt_id ); |
|
188 | + $params = array("optimization_problem_id" => $opt_id ); |
|
189 | 189 | |
190 | - $optimization = (array)$this->get($params); |
|
190 | + $optimization = (array)$this->get($params); |
|
191 | 191 | |
192 | - $addresses = $optimization["addresses"]; |
|
192 | + $addresses = $optimization["addresses"]; |
|
193 | 193 | |
194 | - return $addresses; |
|
195 | - } |
|
194 | + return $addresses; |
|
195 | + } |
|
196 | 196 | |
197 | - public function getRandomAddressFromOptimization($opt_id) |
|
198 | - { |
|
199 | - $addresses = (array)$this->getAddresses($opt_id); |
|
197 | + public function getRandomAddressFromOptimization($opt_id) |
|
198 | + { |
|
199 | + $addresses = (array)$this->getAddresses($opt_id); |
|
200 | 200 | |
201 | - if ($addresses==null) { |
|
202 | - echo "There are no addresses in this optimization!.. Try again."; |
|
203 | - return null; |
|
204 | - } |
|
201 | + if ($addresses==null) { |
|
202 | + echo "There are no addresses in this optimization!.. Try again."; |
|
203 | + return null; |
|
204 | + } |
|
205 | 205 | |
206 | - $num = rand(0, sizeof($addresses)-1); |
|
206 | + $num = rand(0, sizeof($addresses)-1); |
|
207 | 207 | |
208 | - $rAddress = $addresses[$num]; |
|
208 | + $rAddress = $addresses[$num]; |
|
209 | 209 | |
210 | - return $rAddress; |
|
211 | - } |
|
210 | + return $rAddress; |
|
211 | + } |
|
212 | 212 | |
213 | - public function removeAddress($params) |
|
214 | - { |
|
215 | - $response = Route4Me::makeRequst(array( |
|
216 | - 'url' => Endpoint::ADDRESS_V4, |
|
217 | - 'method' => 'DELETE', |
|
218 | - 'query' => array( |
|
219 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
220 | - ? $params['optimization_problem_id'] : null, |
|
221 | - 'route_destination_id' => isset($params['route_destination_id']) |
|
222 | - ? $params['route_destination_id'] : null, |
|
223 | - ) |
|
224 | - )); |
|
213 | + public function removeAddress($params) |
|
214 | + { |
|
215 | + $response = Route4Me::makeRequst(array( |
|
216 | + 'url' => Endpoint::ADDRESS_V4, |
|
217 | + 'method' => 'DELETE', |
|
218 | + 'query' => array( |
|
219 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
220 | + ? $params['optimization_problem_id'] : null, |
|
221 | + 'route_destination_id' => isset($params['route_destination_id']) |
|
222 | + ? $params['route_destination_id'] : null, |
|
223 | + ) |
|
224 | + )); |
|
225 | 225 | |
226 | - return $response; |
|
227 | - } |
|
226 | + return $response; |
|
227 | + } |
|
228 | 228 | |
229 | - public function removeOptimization($params) |
|
230 | - { |
|
231 | - $response = Route4Me::makeRequst(array( |
|
232 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
233 | - 'method' => 'DELETE', |
|
234 | - 'query' => array( |
|
235 | - 'redirect' => isset($params['redirect']) ? $params['redirect'] : null, |
|
236 | - ), |
|
237 | - 'body' => array( |
|
238 | - 'optimization_problem_ids' => isset($params['optimization_problem_ids']) |
|
239 | - ? $params['optimization_problem_ids'] : null, |
|
240 | - ) |
|
241 | - )); |
|
229 | + public function removeOptimization($params) |
|
230 | + { |
|
231 | + $response = Route4Me::makeRequst(array( |
|
232 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
233 | + 'method' => 'DELETE', |
|
234 | + 'query' => array( |
|
235 | + 'redirect' => isset($params['redirect']) ? $params['redirect'] : null, |
|
236 | + ), |
|
237 | + 'body' => array( |
|
238 | + 'optimization_problem_ids' => isset($params['optimization_problem_ids']) |
|
239 | + ? $params['optimization_problem_ids'] : null, |
|
240 | + ) |
|
241 | + )); |
|
242 | 242 | |
243 | - return $response; |
|
244 | - } |
|
243 | + return $response; |
|
244 | + } |
|
245 | 245 | |
246 | - public function getHybridOptimization($params) |
|
247 | - { |
|
248 | - $optimize = Route4Me::makeRequst(array( |
|
249 | - 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
250 | - 'method' => 'GET', |
|
251 | - 'query' => array( |
|
252 | - 'target_date_string' => isset($params['target_date_string']) |
|
253 | - ? $params['target_date_string'] : null, |
|
254 | - 'timezone_offset_minutes' => isset($params['timezone_offset_minutes']) |
|
255 | - ? $params['timezone_offset_minutes'] : null |
|
256 | - ) |
|
257 | - )); |
|
246 | + public function getHybridOptimization($params) |
|
247 | + { |
|
248 | + $optimize = Route4Me::makeRequst(array( |
|
249 | + 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
250 | + 'method' => 'GET', |
|
251 | + 'query' => array( |
|
252 | + 'target_date_string' => isset($params['target_date_string']) |
|
253 | + ? $params['target_date_string'] : null, |
|
254 | + 'timezone_offset_minutes' => isset($params['timezone_offset_minutes']) |
|
255 | + ? $params['timezone_offset_minutes'] : null |
|
256 | + ) |
|
257 | + )); |
|
258 | 258 | |
259 | - return $optimize; |
|
260 | - } |
|
259 | + return $optimize; |
|
260 | + } |
|
261 | 261 | |
262 | - Public function addDepotsToHybrid($params) |
|
263 | - { |
|
264 | - $depots = Route4Me::makeRequst(array( |
|
265 | - 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
266 | - 'method' => 'POST', |
|
267 | - 'query' => array( |
|
268 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
269 | - ? $params['optimization_problem_id'] : null, |
|
270 | - ), |
|
271 | - 'body' => array( |
|
272 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
273 | - ? $params['optimization_problem_id'] : null, |
|
274 | - 'delete_old_depots' => isset($params['delete_old_depots']) ? $params['delete_old_depots'] : null, |
|
275 | - 'new_depots' => isset($params['new_depots']) ? $params['new_depots'] : null, |
|
276 | - ) |
|
277 | - )); |
|
262 | + Public function addDepotsToHybrid($params) |
|
263 | + { |
|
264 | + $depots = Route4Me::makeRequst(array( |
|
265 | + 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
266 | + 'method' => 'POST', |
|
267 | + 'query' => array( |
|
268 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
269 | + ? $params['optimization_problem_id'] : null, |
|
270 | + ), |
|
271 | + 'body' => array( |
|
272 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
273 | + ? $params['optimization_problem_id'] : null, |
|
274 | + 'delete_old_depots' => isset($params['delete_old_depots']) ? $params['delete_old_depots'] : null, |
|
275 | + 'new_depots' => isset($params['new_depots']) ? $params['new_depots'] : null, |
|
276 | + ) |
|
277 | + )); |
|
278 | 278 | |
279 | - return $depots; |
|
280 | - } |
|
279 | + return $depots; |
|
280 | + } |
|
281 | 281 | } |
@@ -6,378 +6,378 @@ |
||
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 static function fromArray(array $params) { |
|
64 | - $order = new Order(); |
|
65 | - foreach ($params as $key => $value) { |
|
66 | - if (property_exists($order, $key)) { |
|
67 | - $order->{$key} = $value; |
|
68 | - } |
|
69 | - } |
|
63 | + public static function fromArray(array $params) { |
|
64 | + $order = new Order(); |
|
65 | + foreach ($params as $key => $value) { |
|
66 | + if (property_exists($order, $key)) { |
|
67 | + $order->{$key} = $value; |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | - return $order; |
|
72 | - } |
|
71 | + return $order; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @param Order $params |
|
76 | - */ |
|
77 | - public static function addOrder($params) |
|
78 | - { |
|
79 | - $body = array(); |
|
74 | + /** |
|
75 | + * @param Order $params |
|
76 | + */ |
|
77 | + public static function addOrder($params) |
|
78 | + { |
|
79 | + $body = array(); |
|
80 | 80 | |
81 | - $allAddOrderParameters = array('address_1', 'address_2', 'member_id', 'cached_lat', 'cached_lng', 'curbside_lat', |
|
82 | - 'curbside_lng', 'color', 'order_icon', 'day_scheduled_for_YYMMDD', 'address_alias', 'address_city', 'address_state_id', |
|
83 | - 'address_country_id', 'address_zip', 'local_time_window_start', 'local_time_window_end', 'local_time_window_start_2', |
|
84 | - 'local_time_window_end_2', 'service_time', 'local_timezone_string', 'EXT_FIELD_first_name', 'EXT_FIELD_last_name', |
|
85 | - 'EXT_FIELD_email', 'EXT_FIELD_phone', 'EXT_FIELD_custom_data', 'is_validated', 'is_pending', 'is_accepted', 'is_started', |
|
86 | - 'is_completed', 'custom_user_fields'); |
|
81 | + $allAddOrderParameters = array('address_1', 'address_2', 'member_id', 'cached_lat', 'cached_lng', 'curbside_lat', |
|
82 | + 'curbside_lng', 'color', 'order_icon', 'day_scheduled_for_YYMMDD', 'address_alias', 'address_city', 'address_state_id', |
|
83 | + 'address_country_id', 'address_zip', 'local_time_window_start', 'local_time_window_end', 'local_time_window_start_2', |
|
84 | + 'local_time_window_end_2', 'service_time', 'local_timezone_string', 'EXT_FIELD_first_name', 'EXT_FIELD_last_name', |
|
85 | + 'EXT_FIELD_email', 'EXT_FIELD_phone', 'EXT_FIELD_custom_data', 'is_validated', 'is_pending', 'is_accepted', 'is_started', |
|
86 | + 'is_completed', 'custom_user_fields'); |
|
87 | 87 | |
88 | - foreach ($allAddOrderParameters as $addOrderParameter) { |
|
89 | - if (isset($params->{$addOrderParameter})) $body[$addOrderParameter] = $params->{$addOrderParameter}; |
|
90 | - } |
|
88 | + foreach ($allAddOrderParameters as $addOrderParameter) { |
|
89 | + if (isset($params->{$addOrderParameter})) $body[$addOrderParameter] = $params->{$addOrderParameter}; |
|
90 | + } |
|
91 | 91 | |
92 | - $response = Route4Me::makeRequst(array( |
|
93 | - 'url' => Endpoint::ORDER_V4, |
|
94 | - 'method' => 'POST', |
|
95 | - 'body' => $body |
|
96 | - )); |
|
92 | + $response = Route4Me::makeRequst(array( |
|
93 | + 'url' => Endpoint::ORDER_V4, |
|
94 | + 'method' => 'POST', |
|
95 | + 'body' => $body |
|
96 | + )); |
|
97 | 97 | |
98 | - return $response; |
|
99 | - } |
|
98 | + return $response; |
|
99 | + } |
|
100 | 100 | |
101 | - public static function addOrder2Route($params, $body) |
|
102 | - { |
|
103 | - $response = Route4Me::makeRequst(array( |
|
104 | - 'url' => Endpoint::ROUTE_V4, |
|
105 | - 'method' => 'PUT', |
|
106 | - 'query' => array( |
|
107 | - 'route_id' => isset($params->route_id) ? $params->route_id : null, |
|
108 | - 'redirect' => isset($params->redirect) ? $params->redirect : null |
|
109 | - ), |
|
110 | - 'body' => (array)$body |
|
111 | - )); |
|
101 | + public static function addOrder2Route($params, $body) |
|
102 | + { |
|
103 | + $response = Route4Me::makeRequst(array( |
|
104 | + 'url' => Endpoint::ROUTE_V4, |
|
105 | + 'method' => 'PUT', |
|
106 | + 'query' => array( |
|
107 | + 'route_id' => isset($params->route_id) ? $params->route_id : null, |
|
108 | + 'redirect' => isset($params->redirect) ? $params->redirect : null |
|
109 | + ), |
|
110 | + 'body' => (array)$body |
|
111 | + )); |
|
112 | 112 | |
113 | - return $response; |
|
114 | - } |
|
113 | + return $response; |
|
114 | + } |
|
115 | 115 | |
116 | - public static function addOrder2Optimization($params, $body) |
|
117 | - { |
|
118 | - $response = Route4Me::makeRequst(array( |
|
119 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
120 | - 'method' => 'PUT', |
|
121 | - 'query' => array( |
|
122 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null, |
|
123 | - 'redirect' => isset($params['redirect']) ? $params['redirect'] : null, |
|
124 | - 'device_type' => isset($params['device_type']) ? $params['device_type'] : null |
|
125 | - ), |
|
126 | - 'body' => (array)$body |
|
127 | - )); |
|
116 | + public static function addOrder2Optimization($params, $body) |
|
117 | + { |
|
118 | + $response = Route4Me::makeRequst(array( |
|
119 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
120 | + 'method' => 'PUT', |
|
121 | + 'query' => array( |
|
122 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null, |
|
123 | + 'redirect' => isset($params['redirect']) ? $params['redirect'] : null, |
|
124 | + 'device_type' => isset($params['device_type']) ? $params['device_type'] : null |
|
125 | + ), |
|
126 | + 'body' => (array)$body |
|
127 | + )); |
|
128 | 128 | |
129 | - return $response; |
|
130 | - } |
|
129 | + return $response; |
|
130 | + } |
|
131 | 131 | |
132 | - public static function getOrder($params) |
|
133 | - { |
|
134 | - $query = array(); |
|
135 | - $allGetParameters = array('order_id', 'fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
132 | + public static function getOrder($params) |
|
133 | + { |
|
134 | + $query = array(); |
|
135 | + $allGetParameters = array('order_id', 'fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
136 | 136 | |
137 | - foreach ($allGetParameters as $getParameter) { |
|
138 | - if (isset($params->{$getParameter})) $query[$getParameter] = $params->{$getParameter}; |
|
139 | - } |
|
137 | + foreach ($allGetParameters as $getParameter) { |
|
138 | + if (isset($params->{$getParameter})) $query[$getParameter] = $params->{$getParameter}; |
|
139 | + } |
|
140 | 140 | |
141 | - $response = Route4Me::makeRequst(array( |
|
142 | - 'url' => Endpoint::ORDER_V4, |
|
143 | - 'method' => 'GET', |
|
144 | - 'query' => $query |
|
145 | - )); |
|
141 | + $response = Route4Me::makeRequst(array( |
|
142 | + 'url' => Endpoint::ORDER_V4, |
|
143 | + 'method' => 'GET', |
|
144 | + 'query' => $query |
|
145 | + )); |
|
146 | 146 | |
147 | - return $response; |
|
148 | - } |
|
147 | + return $response; |
|
148 | + } |
|
149 | 149 | |
150 | - public static function getOrders($params) |
|
151 | - { |
|
152 | - $response = Route4Me::makeRequst(array( |
|
153 | - 'url' => Endpoint::ORDER_V4, |
|
154 | - 'method' => 'GET', |
|
155 | - 'query' => array( |
|
156 | - 'offset' => isset($params->offset) ? $params->offset : null, |
|
157 | - 'limit' => isset($params->limit) ? $params->limit : null |
|
158 | - ) |
|
159 | - )); |
|
150 | + public static function getOrders($params) |
|
151 | + { |
|
152 | + $response = Route4Me::makeRequst(array( |
|
153 | + 'url' => Endpoint::ORDER_V4, |
|
154 | + 'method' => 'GET', |
|
155 | + 'query' => array( |
|
156 | + 'offset' => isset($params->offset) ? $params->offset : null, |
|
157 | + 'limit' => isset($params->limit) ? $params->limit : null |
|
158 | + ) |
|
159 | + )); |
|
160 | 160 | |
161 | - return $response; |
|
162 | - } |
|
161 | + return $response; |
|
162 | + } |
|
163 | 163 | |
164 | - public function getRandomOrderId($offset, $limit) |
|
165 | - { |
|
166 | - $params = array('offset' => $offset, 'limit' => $limit); |
|
164 | + public function getRandomOrderId($offset, $limit) |
|
165 | + { |
|
166 | + $params = array('offset' => $offset, 'limit' => $limit); |
|
167 | 167 | |
168 | - $orders = self::getOrders($params); |
|
168 | + $orders = self::getOrders($params); |
|
169 | 169 | |
170 | - if (is_null($orders)) { |
|
171 | - return null; |
|
172 | - } |
|
170 | + if (is_null($orders)) { |
|
171 | + return null; |
|
172 | + } |
|
173 | 173 | |
174 | - if (!isset($orders['results'])) { |
|
175 | - return null; |
|
176 | - } |
|
174 | + if (!isset($orders['results'])) { |
|
175 | + return null; |
|
176 | + } |
|
177 | 177 | |
178 | - $randomIndex = rand(0, sizeof($orders['results']) - 1); |
|
178 | + $randomIndex = rand(0, sizeof($orders['results']) - 1); |
|
179 | 179 | |
180 | - $order = $orders['results'][$randomIndex]; |
|
180 | + $order = $orders['results'][$randomIndex]; |
|
181 | 181 | |
182 | - return $order['order_id']; |
|
183 | - } |
|
182 | + return $order['order_id']; |
|
183 | + } |
|
184 | 184 | |
185 | - public function getRandomOrder($offset, $limit) |
|
186 | - { |
|
187 | - $params = array('offset' => $offset, 'limit' => $limit); |
|
185 | + public function getRandomOrder($offset, $limit) |
|
186 | + { |
|
187 | + $params = array('offset' => $offset, 'limit' => $limit); |
|
188 | 188 | |
189 | - $orders = self::getOrders($params); |
|
189 | + $orders = self::getOrders($params); |
|
190 | 190 | |
191 | - if (is_null($orders)) { |
|
192 | - return null; |
|
193 | - } |
|
191 | + if (is_null($orders)) { |
|
192 | + return null; |
|
193 | + } |
|
194 | 194 | |
195 | - if (!isset($orders['results'])) { |
|
196 | - return null; |
|
197 | - } |
|
195 | + if (!isset($orders['results'])) { |
|
196 | + return null; |
|
197 | + } |
|
198 | 198 | |
199 | - $randomIndex = rand(0, sizeof($orders['results']) - 1); |
|
199 | + $randomIndex = rand(0, sizeof($orders['results']) - 1); |
|
200 | 200 | |
201 | - $order = $orders['results'][$randomIndex]; |
|
201 | + $order = $orders['results'][$randomIndex]; |
|
202 | 202 | |
203 | - return $order; |
|
204 | - } |
|
203 | + return $order; |
|
204 | + } |
|
205 | 205 | |
206 | - public static function removeOrder($params) |
|
207 | - { |
|
208 | - $response = Route4Me::makeRequst(array( |
|
209 | - 'url' => Endpoint::ORDER_V4, |
|
210 | - 'method' => 'DELETE', |
|
211 | - 'body' => array( |
|
212 | - 'order_ids' => isset($params->order_ids) ? $params->order_ids : null |
|
213 | - ) |
|
214 | - )); |
|
206 | + public static function removeOrder($params) |
|
207 | + { |
|
208 | + $response = Route4Me::makeRequst(array( |
|
209 | + 'url' => Endpoint::ORDER_V4, |
|
210 | + 'method' => 'DELETE', |
|
211 | + 'body' => array( |
|
212 | + 'order_ids' => isset($params->order_ids) ? $params->order_ids : null |
|
213 | + ) |
|
214 | + )); |
|
215 | 215 | |
216 | - return $response; |
|
217 | - } |
|
216 | + return $response; |
|
217 | + } |
|
218 | 218 | |
219 | - public static function updateOrder($body) |
|
220 | - { |
|
221 | - $response = Route4Me::makeRequst(array( |
|
222 | - 'url' => Endpoint::ORDER_V4, |
|
223 | - 'method' => 'PUT', |
|
224 | - 'body' => (array)$body |
|
225 | - )); |
|
219 | + public static function updateOrder($body) |
|
220 | + { |
|
221 | + $response = Route4Me::makeRequst(array( |
|
222 | + 'url' => Endpoint::ORDER_V4, |
|
223 | + 'method' => 'PUT', |
|
224 | + 'body' => (array)$body |
|
225 | + )); |
|
226 | 226 | |
227 | - return $response; |
|
228 | - } |
|
227 | + return $response; |
|
228 | + } |
|
229 | 229 | |
230 | - public static function searchOrder($params) |
|
231 | - { |
|
232 | - $query = array(); |
|
233 | - $allSearchParameters = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
230 | + public static function searchOrder($params) |
|
231 | + { |
|
232 | + $query = array(); |
|
233 | + $allSearchParameters = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
234 | 234 | |
235 | - foreach ($allSearchParameters as $searchParameter) { |
|
236 | - if (isset($params->{$searchParameter})) $query[$searchParameter] = $params->{$searchParameter}; |
|
237 | - } |
|
235 | + foreach ($allSearchParameters as $searchParameter) { |
|
236 | + if (isset($params->{$searchParameter})) $query[$searchParameter] = $params->{$searchParameter}; |
|
237 | + } |
|
238 | 238 | |
239 | - $response = Route4Me::makeRequst(array( |
|
240 | - 'url' => Endpoint::ORDER_V4, |
|
241 | - 'method' => 'GET', |
|
242 | - 'query' => $query |
|
243 | - )); |
|
239 | + $response = Route4Me::makeRequst(array( |
|
240 | + 'url' => Endpoint::ORDER_V4, |
|
241 | + 'method' => 'GET', |
|
242 | + 'query' => $query |
|
243 | + )); |
|
244 | 244 | |
245 | - return $response; |
|
246 | - } |
|
245 | + return $response; |
|
246 | + } |
|
247 | 247 | |
248 | - public static function validateLatitude($lat) |
|
249 | - { |
|
250 | - if (!is_numeric($lat)) { |
|
251 | - return false; |
|
252 | - } |
|
248 | + public static function validateLatitude($lat) |
|
249 | + { |
|
250 | + if (!is_numeric($lat)) { |
|
251 | + return false; |
|
252 | + } |
|
253 | 253 | |
254 | - if ($lat>90 || $lat<-90) { |
|
255 | - return false; |
|
256 | - } |
|
254 | + if ($lat>90 || $lat<-90) { |
|
255 | + return false; |
|
256 | + } |
|
257 | 257 | |
258 | - return true; |
|
259 | - } |
|
258 | + return true; |
|
259 | + } |
|
260 | 260 | |
261 | - public static function validateLongitude($lng) |
|
262 | - { |
|
263 | - if (!is_numeric($lng)) { |
|
264 | - return false; |
|
265 | - } |
|
261 | + public static function validateLongitude($lng) |
|
262 | + { |
|
263 | + if (!is_numeric($lng)) { |
|
264 | + return false; |
|
265 | + } |
|
266 | 266 | |
267 | - if ($lng>180 || $lng<-180) { |
|
268 | - return false; |
|
269 | - } |
|
267 | + if ($lng>180 || $lng<-180) { |
|
268 | + return false; |
|
269 | + } |
|
270 | 270 | |
271 | - return true; |
|
272 | - } |
|
271 | + return true; |
|
272 | + } |
|
273 | 273 | |
274 | - public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
275 | - { |
|
276 | - $max_line_length = 512; |
|
277 | - $delemietr = ','; |
|
274 | + public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
275 | + { |
|
276 | + $max_line_length = 512; |
|
277 | + $delemietr = ','; |
|
278 | 278 | |
279 | - $results = array(); |
|
280 | - $results['fail'] = array(); |
|
281 | - $results['success'] = array(); |
|
279 | + $results = array(); |
|
280 | + $results['fail'] = array(); |
|
281 | + $results['success'] = array(); |
|
282 | 282 | |
283 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
283 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
284 | 284 | |
285 | - $allOrderFields = array("curbside_lat","curbside_lng","color","day_scheduled_for_YYMMDD", |
|
286 | - "address_alias","address_1","address_2","local_time_window_start","local_time_window_end","local_time_window_start_2", |
|
287 | - "local_time_window_end_2","service_time","EXT_FIELD_first_name","EXT_FIELD_last_name","EXT_FIELD_email","EXT_FIELD_phone", |
|
288 | - "EXT_FIELD_custom_data","order_icon"); |
|
285 | + $allOrderFields = array("curbside_lat","curbside_lng","color","day_scheduled_for_YYMMDD", |
|
286 | + "address_alias","address_1","address_2","local_time_window_start","local_time_window_end","local_time_window_start_2", |
|
287 | + "local_time_window_end_2","service_time","EXT_FIELD_first_name","EXT_FIELD_last_name","EXT_FIELD_email","EXT_FIELD_phone", |
|
288 | + "EXT_FIELD_custom_data","order_icon"); |
|
289 | 289 | |
290 | - if (!empty($columns)) { |
|
291 | - array_push($results['fail'],'Empty CSV table'); |
|
292 | - return ($results); |
|
293 | - } |
|
290 | + if (!empty($columns)) { |
|
291 | + array_push($results['fail'],'Empty CSV table'); |
|
292 | + return ($results); |
|
293 | + } |
|
294 | 294 | |
295 | - $iRow=1; |
|
295 | + $iRow=1; |
|
296 | 296 | |
297 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
298 | - if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
|
297 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
298 | + if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
|
299 | 299 | |
300 | - $cached_lat = 0.000; |
|
300 | + $cached_lat = 0.000; |
|
301 | 301 | |
302 | - if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) { |
|
303 | - array_push($results['fail'], "$iRow --> Wrong cached_lat"); |
|
304 | - $iRow++; |
|
305 | - continue; |
|
306 | - } else { |
|
307 | - $cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
308 | - } |
|
302 | + if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) { |
|
303 | + array_push($results['fail'], "$iRow --> Wrong cached_lat"); |
|
304 | + $iRow++; |
|
305 | + continue; |
|
306 | + } else { |
|
307 | + $cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
308 | + } |
|
309 | 309 | |
310 | - $cached_lng = 0.000; |
|
310 | + $cached_lng = 0.000; |
|
311 | 311 | |
312 | - if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) { |
|
313 | - array_push($results['fail'], "$iRow --> Wrong cached_lng"); |
|
314 | - $iRow++; |
|
315 | - continue; |
|
316 | - } else { |
|
317 | - $cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
318 | - } |
|
312 | + if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) { |
|
313 | + array_push($results['fail'], "$iRow --> Wrong cached_lng"); |
|
314 | + $iRow++; |
|
315 | + continue; |
|
316 | + } else { |
|
317 | + $cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
318 | + } |
|
319 | 319 | |
320 | - if (isset($ordersFieldsMapping['curbside_lat'])) { |
|
321 | - if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) { |
|
322 | - array_push($results['fail'], "$iRow --> Wrong curbside_lat"); |
|
323 | - $iRow++; |
|
324 | - continue; |
|
325 | - } |
|
326 | - } |
|
320 | + if (isset($ordersFieldsMapping['curbside_lat'])) { |
|
321 | + if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) { |
|
322 | + array_push($results['fail'], "$iRow --> Wrong curbside_lat"); |
|
323 | + $iRow++; |
|
324 | + continue; |
|
325 | + } |
|
326 | + } |
|
327 | 327 | |
328 | - if (isset($ordersFieldsMapping['curbside_lng'])) { |
|
329 | - if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) { |
|
330 | - array_push($results['fail'], "$iRow --> Wrong curbside_lng"); |
|
331 | - $iRow++; |
|
332 | - continue; |
|
333 | - } |
|
334 | - } |
|
328 | + if (isset($ordersFieldsMapping['curbside_lng'])) { |
|
329 | + if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) { |
|
330 | + array_push($results['fail'], "$iRow --> Wrong curbside_lng"); |
|
331 | + $iRow++; |
|
332 | + continue; |
|
333 | + } |
|
334 | + } |
|
335 | 335 | |
336 | - $address = $rows[$ordersFieldsMapping['address_1']]; |
|
336 | + $address = $rows[$ordersFieldsMapping['address_1']]; |
|
337 | 337 | |
338 | - if (isset($ordersFieldsMapping['order_city'])) { |
|
339 | - $address.=', '.$rows[$ordersFieldsMapping['order_city']]; |
|
340 | - } |
|
338 | + if (isset($ordersFieldsMapping['order_city'])) { |
|
339 | + $address.=', '.$rows[$ordersFieldsMapping['order_city']]; |
|
340 | + } |
|
341 | 341 | |
342 | - if (isset($ordersFieldsMapping['order_state_id'])) { |
|
343 | - $address.=', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
344 | - } |
|
342 | + if (isset($ordersFieldsMapping['order_state_id'])) { |
|
343 | + $address.=', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
344 | + } |
|
345 | 345 | |
346 | - if (isset($ordersFieldsMapping['order_zip_code'])) { |
|
347 | - $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
348 | - } |
|
346 | + if (isset($ordersFieldsMapping['order_zip_code'])) { |
|
347 | + $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
348 | + } |
|
349 | 349 | |
350 | - if (isset($ordersFieldsMapping['order_country_id'])) { |
|
351 | - $address.=', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
352 | - } |
|
350 | + if (isset($ordersFieldsMapping['order_country_id'])) { |
|
351 | + $address.=', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
352 | + } |
|
353 | 353 | |
354 | - echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
354 | + echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
355 | 355 | |
356 | - $parametersArray = array(); |
|
356 | + $parametersArray = array(); |
|
357 | 357 | |
358 | - $parametersArray["cached_lat"] = $cached_lat; |
|
359 | - $parametersArray["cached_lng"] = $cached_lng; |
|
358 | + $parametersArray["cached_lat"] = $cached_lat; |
|
359 | + $parametersArray["cached_lng"] = $cached_lng; |
|
360 | 360 | |
361 | 361 | |
362 | - foreach ($allOrderFields as $orderField) { |
|
363 | - if (isset($ordersFieldsMapping[$orderField])) { |
|
364 | - $parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]]; |
|
365 | - } |
|
366 | - } |
|
362 | + foreach ($allOrderFields as $orderField) { |
|
363 | + if (isset($ordersFieldsMapping[$orderField])) { |
|
364 | + $parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]]; |
|
365 | + } |
|
366 | + } |
|
367 | 367 | |
368 | - $orderParameters = Order::fromArray($parametersArray); |
|
368 | + $orderParameters = Order::fromArray($parametersArray); |
|
369 | 369 | |
370 | - $order = new Order(); |
|
370 | + $order = new Order(); |
|
371 | 371 | |
372 | - $orderResults = $order->addOrder($orderParameters); |
|
372 | + $orderResults = $order->addOrder($orderParameters); |
|
373 | 373 | |
374 | - array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
375 | - } |
|
376 | - else { |
|
377 | - array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
378 | - } |
|
374 | + array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
375 | + } |
|
376 | + else { |
|
377 | + array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
378 | + } |
|
379 | 379 | |
380 | - $iRow++; |
|
381 | - } |
|
382 | - } |
|
380 | + $iRow++; |
|
381 | + } |
|
382 | + } |
|
383 | 383 | } |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | |
70 | 70 | public static function addTerritory($params) |
71 | 71 | { |
72 | - $terParams = array(); |
|
72 | + $terParams = array(); |
|
73 | 73 | |
74 | - if (isset($params->territory['type'])) $terParams['type'] = $params->territory['type']; |
|
75 | - if (isset($params->territory['data'])) $terParams['data'] = $params->territory['data']; |
|
74 | + if (isset($params->territory['type'])) $terParams['type'] = $params->territory['type']; |
|
75 | + if (isset($params->territory['data'])) $terParams['data'] = $params->territory['data']; |
|
76 | 76 | |
77 | 77 | $response = Route4Me::makeRequst(array( |
78 | 78 | 'url' => Endpoint::TERRITORY_V4, |
@@ -102,19 +102,19 @@ discard block |
||
102 | 102 | |
103 | 103 | public function updateTerritory($params) |
104 | 104 | { |
105 | - //var_dump($params); die(""); |
|
105 | + //var_dump($params); die(""); |
|
106 | 106 | $response = Route4Me::makeRequst(array( |
107 | 107 | 'url' => Endpoint::TERRITORY_V4, |
108 | 108 | 'method' => 'PUT', |
109 | 109 | 'query' => array( |
110 | - 'territory_id' => isset($params->territory_id) ? $params->territory_id : null |
|
111 | - ), |
|
112 | - 'body' => array( |
|
113 | - 'territory_name' => isset($params->territory_name) ? $params->territory_name : null, |
|
114 | - 'member_id' => isset($params->member_id) ? $params->member_id : null, |
|
115 | - 'territory_color' => isset($params->territory_color) ? $params->territory_color : null, |
|
116 | - 'territory' => isset($params->territory) ? $params->territory : null |
|
117 | - ) |
|
110 | + 'territory_id' => isset($params->territory_id) ? $params->territory_id : null |
|
111 | + ), |
|
112 | + 'body' => array( |
|
113 | + 'territory_name' => isset($params->territory_name) ? $params->territory_name : null, |
|
114 | + 'member_id' => isset($params->member_id) ? $params->member_id : null, |
|
115 | + 'territory_color' => isset($params->territory_color) ? $params->territory_color : null, |
|
116 | + 'territory' => isset($params->territory) ? $params->territory : null |
|
117 | + ) |
|
118 | 118 | |
119 | 119 | )); |
120 | 120 |