@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | |
4 | 4 | $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
5 | 5 | |
6 | - require $vdir.'/../vendor/autoload.php'; |
|
6 | + require $vdir.'/../vendor/autoload.php'; |
|
7 | 7 | |
8 | 8 | use Route4Me\Route4Me; |
9 | 9 | use Route4Me\Route; |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | foreach ($notes['notes'] as $note) { |
49 | 49 | echo "========== Notes ==================<br>"; |
50 | 50 | echo "note_id --> ".$note['note_id']."<br>"; |
51 | - $content = isset($note['contents']) ? $note['contents'] : ""; |
|
52 | - if (strlen($content)>0) echo "contents --> $content"."<br>"; |
|
51 | + $content = isset($note['contents']) ? $note['contents'] : ""; |
|
52 | + if (strlen($content)>0) echo "contents --> $content"."<br>"; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | //var_dump($notes); |
@@ -49,7 +49,9 @@ |
||
49 | 49 | echo "========== Notes ==================<br>"; |
50 | 50 | echo "note_id --> ".$note['note_id']."<br>"; |
51 | 51 | $content = isset($note['contents']) ? $note['contents'] : ""; |
52 | - if (strlen($content)>0) echo "contents --> $content"."<br>"; |
|
52 | + if (strlen($content)>0) { |
|
53 | + echo "contents --> $content"."<br>"; |
|
54 | + } |
|
53 | 55 | } |
54 | 56 | |
55 | 57 | //var_dump($notes); |
@@ -9,55 +9,55 @@ discard block |
||
9 | 9 | |
10 | 10 | class Address extends Common |
11 | 11 | { |
12 | - static public $apiUrl = '/api.v4/address.php'; |
|
12 | + static public $apiUrl = '/api.v4/address.php'; |
|
13 | 13 | static public $apiUrlMove='/actions/route/move_route_destination.php'; |
14 | 14 | static public $apiUrDeparted='/api/route/mark_address_departed.php'; |
15 | 15 | static public $apiUrVisited='/actions/address/update_address_visited.php'; |
16 | 16 | |
17 | - public $route_destination_id; |
|
18 | - public $alias; |
|
19 | - public $member_id; |
|
20 | - public $address; |
|
21 | - public $is_depot = false; |
|
22 | - public $lat; |
|
23 | - public $lng; |
|
24 | - public $route_id; |
|
25 | - public $original_route_id; |
|
26 | - public $optimization_problem_id; |
|
27 | - public $sequence_no; |
|
28 | - public $geocoded; |
|
29 | - public $preferred_geocoding; |
|
30 | - public $failed_geocoding; |
|
31 | - public $geocodings = array(); |
|
32 | - public $contact_id; |
|
33 | - public $is_visited; |
|
34 | - public $customer_po; |
|
35 | - public $invoice_no; |
|
36 | - public $reference_no; |
|
37 | - public $order_no; |
|
38 | - public $weight; |
|
39 | - public $cost; |
|
40 | - public $revenue; |
|
41 | - public $cube; |
|
42 | - public $pieces; |
|
43 | - public $email; |
|
44 | - public $phone; |
|
45 | - public $destination_note_count; |
|
46 | - public $drive_time_to_next_destination; |
|
47 | - public $distance_to_next_destination; |
|
48 | - public $generated_time_window_start; |
|
49 | - public $generated_time_window_end; |
|
50 | - public $time_window_start; |
|
51 | - public $time_window_end; |
|
52 | - public $time; |
|
17 | + public $route_destination_id; |
|
18 | + public $alias; |
|
19 | + public $member_id; |
|
20 | + public $address; |
|
21 | + public $is_depot = false; |
|
22 | + public $lat; |
|
23 | + public $lng; |
|
24 | + public $route_id; |
|
25 | + public $original_route_id; |
|
26 | + public $optimization_problem_id; |
|
27 | + public $sequence_no; |
|
28 | + public $geocoded; |
|
29 | + public $preferred_geocoding; |
|
30 | + public $failed_geocoding; |
|
31 | + public $geocodings = array(); |
|
32 | + public $contact_id; |
|
33 | + public $is_visited; |
|
34 | + public $customer_po; |
|
35 | + public $invoice_no; |
|
36 | + public $reference_no; |
|
37 | + public $order_no; |
|
38 | + public $weight; |
|
39 | + public $cost; |
|
40 | + public $revenue; |
|
41 | + public $cube; |
|
42 | + public $pieces; |
|
43 | + public $email; |
|
44 | + public $phone; |
|
45 | + public $destination_note_count; |
|
46 | + public $drive_time_to_next_destination; |
|
47 | + public $distance_to_next_destination; |
|
48 | + public $generated_time_window_start; |
|
49 | + public $generated_time_window_end; |
|
50 | + public $time_window_start; |
|
51 | + public $time_window_end; |
|
52 | + public $time; |
|
53 | 53 | public $notes; |
54 | - public $timestamp_last_visited; |
|
55 | - public $custom_fields = array(); |
|
56 | - public $manifest = array(); |
|
54 | + public $timestamp_last_visited; |
|
55 | + public $custom_fields = array(); |
|
56 | + public $manifest = array(); |
|
57 | 57 | |
58 | - public static function fromArray(array $params) |
|
59 | - { |
|
60 | - /*if (!isset($params['address'])) { |
|
58 | + public static function fromArray(array $params) |
|
59 | + { |
|
60 | + /*if (!isset($params['address'])) { |
|
61 | 61 | throw new BadParam('address must be provided'); |
62 | 62 | } |
63 | 63 | |
@@ -69,142 +69,142 @@ discard block |
||
69 | 69 | throw new BadParam('lng must be provided'); |
70 | 70 | }*/ |
71 | 71 | |
72 | - $address = new Address(); |
|
73 | - foreach($params as $key => $value) { |
|
74 | - if (property_exists($address, $key)) { |
|
75 | - $address->{$key} = $value; |
|
76 | - } |
|
77 | - } |
|
72 | + $address = new Address(); |
|
73 | + foreach($params as $key => $value) { |
|
74 | + if (property_exists($address, $key)) { |
|
75 | + $address->{$key} = $value; |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + return $address; |
|
80 | + } |
|
78 | 81 | |
79 | - return $address; |
|
80 | - } |
|
81 | - |
|
82 | - public static function getAddress($routeId, $addressId) |
|
83 | - { |
|
84 | - $address = Route4Me::makeRequst(array( |
|
85 | - 'url' => self::$apiUrl, |
|
86 | - 'method' => 'GET', |
|
87 | - 'query' => array( |
|
88 | - 'route_id' => $routeId, |
|
89 | - 'route_destination_id' => $addressId, |
|
90 | - ) |
|
91 | - )); |
|
92 | - |
|
93 | - return Address::fromArray($address); |
|
94 | - } |
|
82 | + public static function getAddress($routeId, $addressId) |
|
83 | + { |
|
84 | + $address = Route4Me::makeRequst(array( |
|
85 | + 'url' => self::$apiUrl, |
|
86 | + 'method' => 'GET', |
|
87 | + 'query' => array( |
|
88 | + 'route_id' => $routeId, |
|
89 | + 'route_destination_id' => $addressId, |
|
90 | + ) |
|
91 | + )); |
|
92 | + |
|
93 | + return Address::fromArray($address); |
|
94 | + } |
|
95 | 95 | |
96 | 96 | /*Get notes from the specified route destination |
97 | 97 | * Returns an address object with notes, if an address exists, otherwise - return null. |
98 | 98 | */ |
99 | - public static function GetAddressesNotes($noteParams) |
|
100 | - { |
|
101 | - $address = Route4Me::makeRequst(array( |
|
102 | - 'url' => self::$apiUrl, |
|
103 | - 'method' => 'GET', |
|
104 | - 'query' => array( |
|
105 | - 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id']: null, |
|
106 | - 'route_destination_id' => isset($noteParams['route_destination_id']) ? $noteParams['route_destination_id'] : null, |
|
107 | - 'notes' => 1, |
|
108 | - ) |
|
109 | - )); |
|
110 | - |
|
111 | - return $address; |
|
112 | - } |
|
113 | - |
|
114 | - public function update() |
|
115 | - { |
|
116 | - $address = Route4Me::makeRequst(array( |
|
117 | - 'url' => self::$apiUrl, |
|
118 | - 'method' => 'PUT', |
|
119 | - 'body' => $this->toArray(), |
|
120 | - 'query' => array( |
|
121 | - 'route_id' => $this->route_id, |
|
122 | - 'route_destination_id' => $this->route_destination_id, |
|
123 | - ), |
|
124 | - )); |
|
125 | - |
|
126 | - return Address::fromArray($address); |
|
127 | - } |
|
99 | + public static function GetAddressesNotes($noteParams) |
|
100 | + { |
|
101 | + $address = Route4Me::makeRequst(array( |
|
102 | + 'url' => self::$apiUrl, |
|
103 | + 'method' => 'GET', |
|
104 | + 'query' => array( |
|
105 | + 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id']: null, |
|
106 | + 'route_destination_id' => isset($noteParams['route_destination_id']) ? $noteParams['route_destination_id'] : null, |
|
107 | + 'notes' => 1, |
|
108 | + ) |
|
109 | + )); |
|
110 | + |
|
111 | + return $address; |
|
112 | + } |
|
113 | + |
|
114 | + public function update() |
|
115 | + { |
|
116 | + $address = Route4Me::makeRequst(array( |
|
117 | + 'url' => self::$apiUrl, |
|
118 | + 'method' => 'PUT', |
|
119 | + 'body' => $this->toArray(), |
|
120 | + 'query' => array( |
|
121 | + 'route_id' => $this->route_id, |
|
122 | + 'route_destination_id' => $this->route_destination_id, |
|
123 | + ), |
|
124 | + )); |
|
125 | + |
|
126 | + return Address::fromArray($address); |
|
127 | + } |
|
128 | 128 | |
129 | 129 | public function markAddress($params, $body) |
130 | - { |
|
131 | - $result = Route4Me::makeRequst(array( |
|
132 | - 'url' => self::$apiUrl, |
|
133 | - 'method' => 'PUT', |
|
134 | - 'query' => array( |
|
135 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
136 | - 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
137 | - ), |
|
138 | - 'body' => $body |
|
139 | - )); |
|
140 | - |
|
141 | - return $result; |
|
142 | - } |
|
130 | + { |
|
131 | + $result = Route4Me::makeRequst(array( |
|
132 | + 'url' => self::$apiUrl, |
|
133 | + 'method' => 'PUT', |
|
134 | + 'query' => array( |
|
135 | + 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
136 | + 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
137 | + ), |
|
138 | + 'body' => $body |
|
139 | + )); |
|
140 | + |
|
141 | + return $result; |
|
142 | + } |
|
143 | 143 | |
144 | 144 | public function markAsDeparted($params) |
145 | 145 | { |
146 | 146 | $address = Route4Me::makeRequst(array( |
147 | - 'url' => self::$apiUrDeparted, |
|
148 | - 'method' => 'GET', |
|
149 | - 'query' => array( |
|
150 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
151 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
152 | - 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
153 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
154 | - ), |
|
155 | - )); |
|
156 | - |
|
157 | - return $address; |
|
147 | + 'url' => self::$apiUrDeparted, |
|
148 | + 'method' => 'GET', |
|
149 | + 'query' => array( |
|
150 | + 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
151 | + 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
152 | + 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
153 | + 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
154 | + ), |
|
155 | + )); |
|
156 | + |
|
157 | + return $address; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | public function markAsVisited($params) |
161 | 161 | { |
162 | 162 | $address = Route4Me::makeRequst(array( |
163 | - 'url' => self::$apiUrVisited, |
|
164 | - 'method' => 'GET', |
|
165 | - 'query' => array( |
|
166 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
167 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
168 | - 'is_visited' => isset($params['is_visited']) ? $params['is_visited']: null, |
|
169 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
170 | - ), |
|
171 | - )); |
|
172 | - |
|
173 | - return $address; |
|
163 | + 'url' => self::$apiUrVisited, |
|
164 | + 'method' => 'GET', |
|
165 | + 'query' => array( |
|
166 | + 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
167 | + 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
168 | + 'is_visited' => isset($params['is_visited']) ? $params['is_visited']: null, |
|
169 | + 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
170 | + ), |
|
171 | + )); |
|
172 | + |
|
173 | + return $address; |
|
174 | 174 | } |
175 | 175 | |
176 | - public function delete() |
|
177 | - { |
|
178 | - $address = Route4Me::makeRequst(array( |
|
179 | - 'url' => self::$apiUrl, |
|
180 | - 'method' => 'DELETE', |
|
181 | - 'query' => array( |
|
182 | - 'route_id' => $this->route_id, |
|
183 | - 'route_destination_id' => $this->route_destination_id, |
|
184 | - ) |
|
185 | - )); |
|
186 | - |
|
187 | - return (bool)$address['deleted']; |
|
188 | - } |
|
176 | + public function delete() |
|
177 | + { |
|
178 | + $address = Route4Me::makeRequst(array( |
|
179 | + 'url' => self::$apiUrl, |
|
180 | + 'method' => 'DELETE', |
|
181 | + 'query' => array( |
|
182 | + 'route_id' => $this->route_id, |
|
183 | + 'route_destination_id' => $this->route_destination_id, |
|
184 | + ) |
|
185 | + )); |
|
186 | + |
|
187 | + return (bool)$address['deleted']; |
|
188 | + } |
|
189 | 189 | |
190 | 190 | public function MoveDestinationToRoute($params) |
191 | 191 | { |
192 | 192 | $result = Route4Me::makeRequst(array( |
193 | - 'url' => self::$apiUrlMove, |
|
194 | - 'method' => 'POST', |
|
195 | - 'query' => array( |
|
196 | - 'to_route_id' => isset($params['to_route_id']) ? $params['to_route_id'] : null, |
|
197 | - 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
198 | - 'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null |
|
199 | - ) |
|
200 | - )); |
|
201 | - |
|
202 | - return $result; |
|
193 | + 'url' => self::$apiUrlMove, |
|
194 | + 'method' => 'POST', |
|
195 | + 'query' => array( |
|
196 | + 'to_route_id' => isset($params['to_route_id']) ? $params['to_route_id'] : null, |
|
197 | + 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
198 | + 'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null |
|
199 | + ) |
|
200 | + )); |
|
201 | + |
|
202 | + return $result; |
|
203 | 203 | |
204 | 204 | } |
205 | 205 | |
206 | - function getAddressId() |
|
207 | - { |
|
208 | - return $this->route_destination_id; |
|
209 | - } |
|
206 | + function getAddressId() |
|
207 | + { |
|
208 | + return $this->route_destination_id; |
|
209 | + } |
|
210 | 210 | } |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | class Address extends Common |
11 | 11 | { |
12 | 12 | static public $apiUrl = '/api.v4/address.php'; |
13 | - static public $apiUrlMove='/actions/route/move_route_destination.php'; |
|
14 | - static public $apiUrDeparted='/api/route/mark_address_departed.php'; |
|
15 | - static public $apiUrVisited='/actions/address/update_address_visited.php'; |
|
13 | + static public $apiUrlMove = '/actions/route/move_route_destination.php'; |
|
14 | + static public $apiUrDeparted = '/api/route/mark_address_departed.php'; |
|
15 | + static public $apiUrVisited = '/actions/address/update_address_visited.php'; |
|
16 | 16 | |
17 | 17 | public $route_destination_id; |
18 | 18 | public $alias; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | }*/ |
71 | 71 | |
72 | 72 | $address = new Address(); |
73 | - foreach($params as $key => $value) { |
|
73 | + foreach ($params as $key => $value) { |
|
74 | 74 | if (property_exists($address, $key)) { |
75 | 75 | $address->{$key} = $value; |
76 | 76 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | 'url' => self::$apiUrl, |
103 | 103 | 'method' => 'GET', |
104 | 104 | 'query' => array( |
105 | - 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id']: null, |
|
105 | + 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, |
|
106 | 106 | 'route_destination_id' => isset($noteParams['route_destination_id']) ? $noteParams['route_destination_id'] : null, |
107 | 107 | 'notes' => 1, |
108 | 108 | ) |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | 'url' => self::$apiUrl, |
133 | 133 | 'method' => 'PUT', |
134 | 134 | 'query' => array( |
135 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
135 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
136 | 136 | 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
137 | 137 | ), |
138 | 138 | 'body' => $body |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | 'url' => self::$apiUrDeparted, |
148 | 148 | 'method' => 'GET', |
149 | 149 | 'query' => array( |
150 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
151 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
152 | - 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
153 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
150 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
151 | + 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
152 | + 'is_departed' => isset($params['is_departed']) ? $params['is_departed'] : null, |
|
153 | + 'member_id' => isset($params['member_id']) ? $params['member_id'] : null, |
|
154 | 154 | ), |
155 | 155 | )); |
156 | 156 | |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | 'url' => self::$apiUrVisited, |
164 | 164 | 'method' => 'GET', |
165 | 165 | 'query' => array( |
166 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
167 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
168 | - 'is_visited' => isset($params['is_visited']) ? $params['is_visited']: null, |
|
169 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
166 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
167 | + 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
168 | + 'is_visited' => isset($params['is_visited']) ? $params['is_visited'] : null, |
|
169 | + 'member_id' => isset($params['member_id']) ? $params['member_id'] : null, |
|
170 | 170 | ), |
171 | 171 | )); |
172 | 172 |