@@ -4,17 +4,17 @@ |
||
4 | 4 | |
5 | 5 | class Common |
6 | 6 | { |
7 | - public static function getValue($array, $item, $default = null) |
|
8 | - { |
|
9 | - return (isset($array[$item])) ? $array[$item] : $default; |
|
10 | - } |
|
7 | + public static function getValue($array, $item, $default = null) |
|
8 | + { |
|
9 | + return (isset($array[$item])) ? $array[$item] : $default; |
|
10 | + } |
|
11 | 11 | |
12 | - public function toArray() |
|
13 | - { |
|
14 | - $params = array_filter(get_object_vars($this), function($item) { |
|
15 | - return ($item!==null) && !(is_array($item) && !count($item)); |
|
16 | - }); |
|
12 | + public function toArray() |
|
13 | + { |
|
14 | + $params = array_filter(get_object_vars($this), function($item) { |
|
15 | + return ($item!==null) && !(is_array($item) && !count($item)); |
|
16 | + }); |
|
17 | 17 | |
18 | - return $params; |
|
19 | - } |
|
18 | + return $params; |
|
19 | + } |
|
20 | 20 | } |
@@ -7,111 +7,111 @@ |
||
7 | 7 | |
8 | 8 | class AvoidanceZone extends Common |
9 | 9 | { |
10 | - public $territory_id; // Avoidance zone id |
|
11 | - public $territory_name; |
|
12 | - public $territory_color; |
|
13 | - public $orders; |
|
14 | - public $member_id; |
|
15 | - public $territory; // Territory parameters |
|
10 | + public $territory_id; // Avoidance zone id |
|
11 | + public $territory_name; |
|
12 | + public $territory_color; |
|
13 | + public $orders; |
|
14 | + public $member_id; |
|
15 | + public $territory; // Territory parameters |
|
16 | 16 | |
17 | - public static function fromArray(array $params) |
|
18 | - { |
|
19 | - if (!isset($params['territory_name'])) { |
|
20 | - throw new BadParam('Territory name must be provided'); |
|
21 | - } |
|
17 | + public static function fromArray(array $params) |
|
18 | + { |
|
19 | + if (!isset($params['territory_name'])) { |
|
20 | + throw new BadParam('Territory name must be provided'); |
|
21 | + } |
|
22 | 22 | |
23 | - if (!isset($params['territory_color'])) { |
|
24 | - throw new BadParam('Territory color must be provided'); |
|
25 | - } |
|
23 | + if (!isset($params['territory_color'])) { |
|
24 | + throw new BadParam('Territory color must be provided'); |
|
25 | + } |
|
26 | 26 | |
27 | - if (!isset($params['territory'])) { |
|
28 | - throw new BadParam('Territory must be provided'); |
|
29 | - } |
|
27 | + if (!isset($params['territory'])) { |
|
28 | + throw new BadParam('Territory must be provided'); |
|
29 | + } |
|
30 | 30 | |
31 | - $avoidanceZoneParameters = new AvoidanceZone(); |
|
31 | + $avoidanceZoneParameters = new AvoidanceZone(); |
|
32 | 32 | |
33 | - foreach($params as $key => $value) { |
|
34 | - if (property_exists($avoidanceZoneParameters, $key)) { |
|
35 | - $avoidanceZoneParameters->{$key} = $value; |
|
36 | - } |
|
37 | - } |
|
33 | + foreach($params as $key => $value) { |
|
34 | + if (property_exists($avoidanceZoneParameters, $key)) { |
|
35 | + $avoidanceZoneParameters->{$key} = $value; |
|
36 | + } |
|
37 | + } |
|
38 | 38 | |
39 | - return $avoidanceZoneParameters; |
|
40 | - } |
|
39 | + return $avoidanceZoneParameters; |
|
40 | + } |
|
41 | 41 | |
42 | - public static function getAvoidanceZone($territory_id) |
|
43 | - { |
|
44 | - $avoidanceZone = Route4Me::makeRequst(array( |
|
45 | - 'url' => Endpoint::AVOIDANCE_ZONE, |
|
46 | - 'method' => 'GET', |
|
47 | - 'query' => array( |
|
48 | - 'territory_id' => $territory_id |
|
49 | - ) |
|
50 | - )); |
|
42 | + public static function getAvoidanceZone($territory_id) |
|
43 | + { |
|
44 | + $avoidanceZone = Route4Me::makeRequst(array( |
|
45 | + 'url' => Endpoint::AVOIDANCE_ZONE, |
|
46 | + 'method' => 'GET', |
|
47 | + 'query' => array( |
|
48 | + 'territory_id' => $territory_id |
|
49 | + ) |
|
50 | + )); |
|
51 | 51 | |
52 | - return $avoidanceZone; |
|
53 | - } |
|
52 | + return $avoidanceZone; |
|
53 | + } |
|
54 | 54 | |
55 | - public static function getAvoidanceZones($params) |
|
56 | - { |
|
57 | - $avoidanceZones = Route4Me::makeRequst(array( |
|
58 | - 'url' => Endpoint::AVOIDANCE_ZONE, |
|
59 | - 'method' => 'GET', |
|
60 | - 'query' => array( |
|
61 | - 'offset' => isset($params->offset) ? $params->offset : null, |
|
62 | - 'limit' => isset($params->limit) ? $params->limit : null, |
|
63 | - ) |
|
64 | - )); |
|
55 | + public static function getAvoidanceZones($params) |
|
56 | + { |
|
57 | + $avoidanceZones = Route4Me::makeRequst(array( |
|
58 | + 'url' => Endpoint::AVOIDANCE_ZONE, |
|
59 | + 'method' => 'GET', |
|
60 | + 'query' => array( |
|
61 | + 'offset' => isset($params->offset) ? $params->offset : null, |
|
62 | + 'limit' => isset($params->limit) ? $params->limit : null, |
|
63 | + ) |
|
64 | + )); |
|
65 | 65 | |
66 | - return $avoidanceZones; |
|
67 | - } |
|
66 | + return $avoidanceZones; |
|
67 | + } |
|
68 | 68 | |
69 | - public static function addAvoidanceZone($params) |
|
70 | - { |
|
71 | - $terParams = array(); |
|
69 | + public static function addAvoidanceZone($params) |
|
70 | + { |
|
71 | + $terParams = array(); |
|
72 | 72 | |
73 | - if (isset($params->territory['type'])) { |
|
74 | - $terParams['type'] = $params->territory['type']; |
|
75 | - } |
|
73 | + if (isset($params->territory['type'])) { |
|
74 | + $terParams['type'] = $params->territory['type']; |
|
75 | + } |
|
76 | 76 | |
77 | - if (isset($params->territory['data'])) { |
|
78 | - $terParams['data'] = $params->territory['data']; |
|
79 | - } |
|
77 | + if (isset($params->territory['data'])) { |
|
78 | + $terParams['data'] = $params->territory['data']; |
|
79 | + } |
|
80 | 80 | |
81 | - $abContacts = Route4Me::makeRequst(array( |
|
82 | - 'url' => Endpoint::AVOIDANCE_ZONE, |
|
83 | - 'method' => 'POST', |
|
84 | - 'body' => array( |
|
85 | - 'territory_name' => isset($params->territory_name) ? $params->territory_name : null, |
|
86 | - 'territory_color' => isset($params->territory_color) ? $params->territory_color : null, |
|
87 | - 'territory' => $terParams |
|
88 | - ) |
|
89 | - )); |
|
81 | + $abContacts = Route4Me::makeRequst(array( |
|
82 | + 'url' => Endpoint::AVOIDANCE_ZONE, |
|
83 | + 'method' => 'POST', |
|
84 | + 'body' => array( |
|
85 | + 'territory_name' => isset($params->territory_name) ? $params->territory_name : null, |
|
86 | + 'territory_color' => isset($params->territory_color) ? $params->territory_color : null, |
|
87 | + 'territory' => $terParams |
|
88 | + ) |
|
89 | + )); |
|
90 | 90 | |
91 | - return $abContacts; |
|
92 | - } |
|
91 | + return $abContacts; |
|
92 | + } |
|
93 | 93 | |
94 | - public function deleteAvoidanceZone($territory_id) |
|
95 | - { |
|
96 | - $result = Route4Me::makeRequst(array( |
|
97 | - 'url' => Endpoint::AVOIDANCE_ZONE, |
|
98 | - 'method' => 'DELETEARRAY', |
|
99 | - 'query' => array( |
|
100 | - 'territory_id' => $territory_id |
|
101 | - ) |
|
102 | - )); |
|
94 | + public function deleteAvoidanceZone($territory_id) |
|
95 | + { |
|
96 | + $result = Route4Me::makeRequst(array( |
|
97 | + 'url' => Endpoint::AVOIDANCE_ZONE, |
|
98 | + 'method' => 'DELETEARRAY', |
|
99 | + 'query' => array( |
|
100 | + 'territory_id' => $territory_id |
|
101 | + ) |
|
102 | + )); |
|
103 | 103 | |
104 | - return $result; |
|
105 | - } |
|
104 | + return $result; |
|
105 | + } |
|
106 | 106 | |
107 | - public function updateAvoidanceZone($params) |
|
108 | - { |
|
109 | - $avoidanceZone = Route4Me::makeRequst(array( |
|
110 | - 'url' => Endpoint::AVOIDANCE_ZONE, |
|
111 | - 'method' => 'PUT', |
|
112 | - 'body' => $params, |
|
113 | - )); |
|
107 | + public function updateAvoidanceZone($params) |
|
108 | + { |
|
109 | + $avoidanceZone = Route4Me::makeRequst(array( |
|
110 | + 'url' => Endpoint::AVOIDANCE_ZONE, |
|
111 | + 'method' => 'PUT', |
|
112 | + 'body' => $params, |
|
113 | + )); |
|
114 | 114 | |
115 | - return $avoidanceZone; |
|
116 | - } |
|
115 | + return $avoidanceZone; |
|
116 | + } |
|
117 | 117 | } |
@@ -26,22 +26,22 @@ discard block |
||
26 | 26 | |
27 | 27 | $addresses = array(); |
28 | 28 | foreach ($json as $address) { |
29 | - $addresses[] = Address::fromArray($address); |
|
29 | + $addresses[] = Address::fromArray($address); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $parameters = RouteParameters::fromArray(array( |
33 | - "algorithm_type" => Algorithmtype::CVRP_TW_SD, |
|
34 | - "route_name" => "Multiple Depot, Multiple Driver with 24 Stops, Time Window", |
|
35 | - "route_date" => time() + 24*60*60, |
|
36 | - "route_time" => 60 * 60 * 7, |
|
37 | - "distance_unit" => DistanceUnit::MILES, |
|
38 | - "device_type" => DeviceType::WEB, |
|
39 | - "optimize" => OptimizationType::DISTANCE, |
|
40 | - "metric" => Metric::GEODESIC, |
|
41 | - "route_max_duration" => 86400, |
|
42 | - "travel_mode" => TravelMode::DRIVING, |
|
43 | - "vehicle_capacity" => 1, |
|
44 | - "vehicle_max_distance_mi" => 10000 |
|
33 | + "algorithm_type" => Algorithmtype::CVRP_TW_SD, |
|
34 | + "route_name" => "Multiple Depot, Multiple Driver with 24 Stops, Time Window", |
|
35 | + "route_date" => time() + 24*60*60, |
|
36 | + "route_time" => 60 * 60 * 7, |
|
37 | + "distance_unit" => DistanceUnit::MILES, |
|
38 | + "device_type" => DeviceType::WEB, |
|
39 | + "optimize" => OptimizationType::DISTANCE, |
|
40 | + "metric" => Metric::GEODESIC, |
|
41 | + "route_max_duration" => 86400, |
|
42 | + "travel_mode" => TravelMode::DRIVING, |
|
43 | + "vehicle_capacity" => 1, |
|
44 | + "vehicle_max_distance_mi" => 10000 |
|
45 | 45 | )); |
46 | 46 | |
47 | 47 | $optimizationParams = new OptimizationProblemParams; |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | $problem = OptimizationProblem::optimize($optimizationParams); |
52 | 52 | |
53 | 53 | foreach ((array)$problem as $key => $value) { |
54 | - if (is_string($value)) { |
|
55 | - echo $key." --> ".$value."<br>"; |
|
56 | - } else { |
|
57 | - echo "************ $key ************* <br>"; |
|
58 | - Route4Me::simplePrint((array)$value, true); |
|
59 | - echo "******************************* <br>"; |
|
60 | - } |
|
54 | + if (is_string($value)) { |
|
55 | + echo $key." --> ".$value."<br>"; |
|
56 | + } else { |
|
57 | + echo "************ $key ************* <br>"; |
|
58 | + Route4Me::simplePrint((array)$value, true); |
|
59 | + echo "******************************* <br>"; |
|
60 | + } |
|
61 | 61 | } |
@@ -26,18 +26,18 @@ |
||
26 | 26 | |
27 | 27 | $addresses = array(); |
28 | 28 | foreach ($json as $address) { |
29 | - $addresses[] = Address::fromArray($address); |
|
29 | + $addresses[] = Address::fromArray($address); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $parameters = RouteParameters::fromArray(array( |
33 | - "algorithm_type" => AlgorithmType::TSP, |
|
34 | - "distance_unit" => DistanceUnit::MILES, |
|
35 | - "device_type" => DeviceType::WEB, |
|
36 | - "optimize" => OptimizationType::DISTANCE, |
|
37 | - "travel_mode" => TravelMode::DRIVING, |
|
38 | - "route_max_duration" => 86400, |
|
39 | - "vehicle_capacity" => 1, |
|
40 | - "vehicle_max_distance_mi" => 10000 |
|
33 | + "algorithm_type" => AlgorithmType::TSP, |
|
34 | + "distance_unit" => DistanceUnit::MILES, |
|
35 | + "device_type" => DeviceType::WEB, |
|
36 | + "optimize" => OptimizationType::DISTANCE, |
|
37 | + "travel_mode" => TravelMode::DRIVING, |
|
38 | + "route_max_duration" => 86400, |
|
39 | + "vehicle_capacity" => 1, |
|
40 | + "vehicle_max_distance_mi" => 10000 |
|
41 | 41 | )); |
42 | 42 | |
43 | 43 | $optimizationParams = new OptimizationProblemParams; |
@@ -6,109 +6,109 @@ |
||
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 | - Route4Me::setBaseUrl(Endpoint::STREET_DATA); |
|
58 | + public static function getStreetData($params) |
|
59 | + { |
|
60 | + Route4Me::setBaseUrl(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::makeRequst(array( |
|
69 | - 'url' => $url_query, |
|
70 | - 'method' => 'GET', |
|
71 | - 'query' => $query |
|
72 | - )); |
|
68 | + $response = Route4Me::makeRequst(array( |
|
69 | + 'url' => $url_query, |
|
70 | + 'method' => 'GET', |
|
71 | + 'query' => $query |
|
72 | + )); |
|
73 | 73 | |
74 | - return $response; |
|
75 | - } |
|
74 | + return $response; |
|
75 | + } |
|
76 | 76 | |
77 | - public static function getZipCode($params) |
|
78 | - { |
|
79 | - Route4Me::setBaseUrl(Endpoint::STREET_DATA_ZIPCODE); |
|
77 | + public static function getZipCode($params) |
|
78 | + { |
|
79 | + Route4Me::setBaseUrl(Endpoint::STREET_DATA_ZIPCODE); |
|
80 | 80 | |
81 | - $allPathFields = array('zipcode', 'offset', 'limit'); |
|
81 | + $allPathFields = array('zipcode', 'offset', 'limit'); |
|
82 | 82 | |
83 | - $url_query = Route4Me::generateUrlPath($allPathFields, $params); |
|
83 | + $url_query = Route4Me::generateUrlPath($allPathFields, $params); |
|
84 | 84 | |
85 | - $query = array(); |
|
85 | + $query = array(); |
|
86 | 86 | |
87 | - $response = Route4Me::makeRequst(array( |
|
88 | - 'url' => $url_query, |
|
89 | - 'method' => 'GET', |
|
90 | - 'query' => $query |
|
91 | - )); |
|
87 | + $response = Route4Me::makeRequst(array( |
|
88 | + 'url' => $url_query, |
|
89 | + 'method' => 'GET', |
|
90 | + 'query' => $query |
|
91 | + )); |
|
92 | 92 | |
93 | - return $response; |
|
94 | - } |
|
93 | + return $response; |
|
94 | + } |
|
95 | 95 | |
96 | - public static function getService($params) |
|
97 | - { |
|
98 | - Route4Me::setBaseUrl(Endpoint::STREET_DATA_SERVICE); |
|
96 | + public static function getService($params) |
|
97 | + { |
|
98 | + Route4Me::setBaseUrl(Endpoint::STREET_DATA_SERVICE); |
|
99 | 99 | |
100 | - $allPathFields = array('zipcode', 'housenumber', 'offset', 'limit'); |
|
100 | + $allPathFields = array('zipcode', 'housenumber', 'offset', 'limit'); |
|
101 | 101 | |
102 | - $url_query = Route4Me::generateUrlPath($allPathFields, $params); |
|
102 | + $url_query = Route4Me::generateUrlPath($allPathFields, $params); |
|
103 | 103 | |
104 | - $query = array(); |
|
104 | + $query = array(); |
|
105 | 105 | |
106 | - $response = Route4Me::makeRequst(array( |
|
107 | - 'url' => $url_query, |
|
108 | - 'method' => 'GET', |
|
109 | - 'query' => $query |
|
110 | - )); |
|
106 | + $response = Route4Me::makeRequst(array( |
|
107 | + 'url' => $url_query, |
|
108 | + 'method' => 'GET', |
|
109 | + 'query' => $query |
|
110 | + )); |
|
111 | 111 | |
112 | - return $response; |
|
113 | - } |
|
112 | + return $response; |
|
113 | + } |
|
114 | 114 | } |
@@ -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', 'address_id'); |
|
94 | + public static function getAddressBookLocations($params) |
|
95 | + { |
|
96 | + $allQueryFields = array('limit', 'offset', 'address_id'); |
|
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 getRandomAddressBookLocation($params) |
|
108 | - { |
|
109 | - $ablocations = self::getAddressBookLocations($params); |
|
107 | + public static function getRandomAddressBookLocation($params) |
|
108 | + { |
|
109 | + $ablocations = self::getAddressBookLocations($params); |
|
110 | 110 | |
111 | - if (isset($ablocations["results"])) { |
|
112 | - $locationsSize = sizeof($ablocations["results"]); |
|
111 | + if (isset($ablocations["results"])) { |
|
112 | + $locationsSize = sizeof($ablocations["results"]); |
|
113 | 113 | |
114 | - if ($locationsSize>0) { |
|
115 | - $randomLocationIndex = rand(0, $locationsSize - 1); |
|
116 | - return $ablocations["results"][$randomLocationIndex]; |
|
117 | - } |
|
118 | - } |
|
114 | + if ($locationsSize>0) { |
|
115 | + $randomLocationIndex = rand(0, $locationsSize - 1); |
|
116 | + return $ablocations["results"][$randomLocationIndex]; |
|
117 | + } |
|
118 | + } |
|
119 | 119 | |
120 | - return null; |
|
121 | - } |
|
120 | + return null; |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * @param AddressBookLocation $params |
|
125 | - */ |
|
126 | - public static function addAdressBookLocation($params) |
|
127 | - { |
|
128 | - $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
123 | + /** |
|
124 | + * @param AddressBookLocation $params |
|
125 | + */ |
|
126 | + public static function addAdressBookLocation($params) |
|
127 | + { |
|
128 | + $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
129 | 129 | |
130 | - $response = Route4Me::makeRequst(array( |
|
131 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
132 | - 'method' => 'POST', |
|
133 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
134 | - )); |
|
130 | + $response = Route4Me::makeRequst(array( |
|
131 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
132 | + 'method' => 'POST', |
|
133 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
134 | + )); |
|
135 | 135 | |
136 | - return $response; |
|
137 | - } |
|
136 | + return $response; |
|
137 | + } |
|
138 | 138 | |
139 | - public function deleteAdressBookLocation($address_ids) |
|
140 | - { |
|
141 | - $result = Route4Me::makeRequst(array( |
|
142 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
143 | - 'method' => 'DELETEARRAY', |
|
144 | - 'query' => array( |
|
145 | - 'address_ids' => $address_ids |
|
146 | - ) |
|
147 | - )); |
|
139 | + public function deleteAdressBookLocation($address_ids) |
|
140 | + { |
|
141 | + $result = Route4Me::makeRequst(array( |
|
142 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
143 | + 'method' => 'DELETEARRAY', |
|
144 | + 'query' => array( |
|
145 | + 'address_ids' => $address_ids |
|
146 | + ) |
|
147 | + )); |
|
148 | 148 | |
149 | - return $result; |
|
150 | - } |
|
149 | + return $result; |
|
150 | + } |
|
151 | 151 | |
152 | - public function updateAdressBookLocation($params) |
|
153 | - { |
|
154 | - $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('in_route_count')); |
|
152 | + public function updateAdressBookLocation($params) |
|
153 | + { |
|
154 | + $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('in_route_count')); |
|
155 | 155 | |
156 | - $response = Route4Me::makeRequst(array( |
|
157 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
158 | - 'method' => 'PUT', |
|
159 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
160 | - )); |
|
156 | + $response = Route4Me::makeRequst(array( |
|
157 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
158 | + 'method' => 'PUT', |
|
159 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
160 | + )); |
|
161 | 161 | |
162 | - return $response; |
|
163 | - } |
|
162 | + return $response; |
|
163 | + } |
|
164 | 164 | |
165 | - public static function validateScheduleMode($scheduleMode) |
|
166 | - { |
|
167 | - $schedMmodes = array("daily", "weekly", "monthly", "annually"); |
|
165 | + public static function validateScheduleMode($scheduleMode) |
|
166 | + { |
|
167 | + $schedMmodes = array("daily", "weekly", "monthly", "annually"); |
|
168 | 168 | |
169 | - if (in_array($scheduleMode, $schedMmodes)) { |
|
170 | - return TRUE; |
|
171 | - } else { |
|
172 | - return FALSE; |
|
173 | - } |
|
174 | - } |
|
169 | + if (in_array($scheduleMode, $schedMmodes)) { |
|
170 | + return TRUE; |
|
171 | + } else { |
|
172 | + return FALSE; |
|
173 | + } |
|
174 | + } |
|
175 | 175 | |
176 | - public static function validateScheduleEnable($scheduleEnabled) |
|
177 | - { |
|
178 | - $schedEnables = array(TRUE, FALSE); |
|
176 | + public static function validateScheduleEnable($scheduleEnabled) |
|
177 | + { |
|
178 | + $schedEnables = array(TRUE, FALSE); |
|
179 | 179 | |
180 | - if (in_array($scheduleEnabled, $schedEnables)) { |
|
181 | - return TRUE; |
|
182 | - } else { |
|
183 | - return FALSE; |
|
184 | - } |
|
185 | - } |
|
180 | + if (in_array($scheduleEnabled, $schedEnables)) { |
|
181 | + return TRUE; |
|
182 | + } else { |
|
183 | + return FALSE; |
|
184 | + } |
|
185 | + } |
|
186 | 186 | |
187 | - public static function validateScheduleEvery($scheduleEvery) |
|
188 | - { |
|
189 | - if (is_numeric($scheduleEvery)) { |
|
190 | - return TRUE; |
|
191 | - } else { |
|
192 | - return FALSE; |
|
193 | - } |
|
194 | - } |
|
187 | + public static function validateScheduleEvery($scheduleEvery) |
|
188 | + { |
|
189 | + if (is_numeric($scheduleEvery)) { |
|
190 | + return TRUE; |
|
191 | + } else { |
|
192 | + return FALSE; |
|
193 | + } |
|
194 | + } |
|
195 | 195 | |
196 | - public static function validateScheduleWeekDays($scheduleWeekDays) |
|
197 | - { |
|
198 | - $weekdays = explode(',', $scheduleWeekDays); |
|
199 | - $weekdaysSize = sizeof($weekdays); |
|
196 | + public static function validateScheduleWeekDays($scheduleWeekDays) |
|
197 | + { |
|
198 | + $weekdays = explode(',', $scheduleWeekDays); |
|
199 | + $weekdaysSize = sizeof($weekdays); |
|
200 | 200 | |
201 | - if ($weekdaysSize<1) { |
|
202 | - return FALSE; |
|
203 | - } |
|
201 | + if ($weekdaysSize<1) { |
|
202 | + return FALSE; |
|
203 | + } |
|
204 | 204 | |
205 | - $isValid = TRUE; |
|
205 | + $isValid = TRUE; |
|
206 | 206 | |
207 | - for ($i = 0; $i<$weekdaysSize; $i++) { |
|
208 | - if (is_numeric($weekdays[$i])) { |
|
209 | - $wday = intval($weekdays[$i]); |
|
210 | - if ($wday<1 || $wday>7) { |
|
211 | - $isValid = FALSE; |
|
212 | - } |
|
213 | - } else { |
|
214 | - $isValid = FALSE; |
|
215 | - } |
|
216 | - } |
|
207 | + for ($i = 0; $i<$weekdaysSize; $i++) { |
|
208 | + if (is_numeric($weekdays[$i])) { |
|
209 | + $wday = intval($weekdays[$i]); |
|
210 | + if ($wday<1 || $wday>7) { |
|
211 | + $isValid = FALSE; |
|
212 | + } |
|
213 | + } else { |
|
214 | + $isValid = FALSE; |
|
215 | + } |
|
216 | + } |
|
217 | 217 | |
218 | - return $isValid; |
|
219 | - } |
|
218 | + return $isValid; |
|
219 | + } |
|
220 | 220 | |
221 | - public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
|
222 | - { |
|
223 | - $schedMonthlyMmodes = array("dates", "nth"); |
|
221 | + public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
|
222 | + { |
|
223 | + $schedMonthlyMmodes = array("dates", "nth"); |
|
224 | 224 | |
225 | - if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) { |
|
226 | - return TRUE; |
|
227 | - } else { |
|
228 | - return FALSE; |
|
229 | - } |
|
230 | - } |
|
225 | + if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) { |
|
226 | + return TRUE; |
|
227 | + } else { |
|
228 | + return FALSE; |
|
229 | + } |
|
230 | + } |
|
231 | 231 | |
232 | - public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
|
233 | - { |
|
234 | - $monthlyDates = explode(',', $scheduleMonthlyDates); |
|
235 | - $monthlyDatesSize = sizeof($monthlyDates); |
|
232 | + public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
|
233 | + { |
|
234 | + $monthlyDates = explode(',', $scheduleMonthlyDates); |
|
235 | + $monthlyDatesSize = sizeof($monthlyDates); |
|
236 | 236 | |
237 | - if ($monthlyDatesSize<1) { |
|
238 | - return FALSE; |
|
239 | - } |
|
237 | + if ($monthlyDatesSize<1) { |
|
238 | + return FALSE; |
|
239 | + } |
|
240 | 240 | |
241 | - $isValid = TRUE; |
|
241 | + $isValid = TRUE; |
|
242 | 242 | |
243 | - for ($i = 0; $i<$monthlyDatesSize; $i++) { |
|
244 | - if (is_numeric($monthlyDates[$i])) { |
|
245 | - $mday = intval($monthlyDates[$i]); |
|
246 | - if ($mday<1 || $mday>31) { |
|
247 | - $isValid = FALSE; |
|
248 | - } |
|
249 | - } else { |
|
250 | - $isValid = FALSE; |
|
251 | - } |
|
252 | - } |
|
243 | + for ($i = 0; $i<$monthlyDatesSize; $i++) { |
|
244 | + if (is_numeric($monthlyDates[$i])) { |
|
245 | + $mday = intval($monthlyDates[$i]); |
|
246 | + if ($mday<1 || $mday>31) { |
|
247 | + $isValid = FALSE; |
|
248 | + } |
|
249 | + } else { |
|
250 | + $isValid = FALSE; |
|
251 | + } |
|
252 | + } |
|
253 | 253 | |
254 | - return $isValid; |
|
255 | - } |
|
254 | + return $isValid; |
|
255 | + } |
|
256 | 256 | |
257 | - public static function validateScheduleNthN($scheduleNthN) |
|
258 | - { |
|
259 | - if (!is_numeric($scheduleNthN)) { |
|
260 | - return FALSE; |
|
261 | - } |
|
257 | + public static function validateScheduleNthN($scheduleNthN) |
|
258 | + { |
|
259 | + if (!is_numeric($scheduleNthN)) { |
|
260 | + return FALSE; |
|
261 | + } |
|
262 | 262 | |
263 | - $schedNthNs = array(1, 2, 3, 4, 5, -1); |
|
263 | + $schedNthNs = array(1, 2, 3, 4, 5, -1); |
|
264 | 264 | |
265 | - if (in_array($scheduleNthN, $schedNthNs)) { |
|
266 | - return TRUE; |
|
267 | - } else { |
|
268 | - return FALSE; |
|
269 | - } |
|
270 | - } |
|
265 | + if (in_array($scheduleNthN, $schedNthNs)) { |
|
266 | + return TRUE; |
|
267 | + } else { |
|
268 | + return FALSE; |
|
269 | + } |
|
270 | + } |
|
271 | 271 | |
272 | - public static function validateScheduleNthWhat($scheduleNthWhat) |
|
273 | - { |
|
274 | - if (!is_numeric($scheduleNthWhat)) { |
|
275 | - return FALSE; |
|
276 | - } |
|
272 | + public static function validateScheduleNthWhat($scheduleNthWhat) |
|
273 | + { |
|
274 | + if (!is_numeric($scheduleNthWhat)) { |
|
275 | + return FALSE; |
|
276 | + } |
|
277 | 277 | |
278 | - $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
278 | + $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
279 | 279 | |
280 | - if (in_array($scheduleNthWhat, $schedNthWhats)) { |
|
281 | - return TRUE; |
|
282 | - } else { |
|
283 | - return FALSE; |
|
284 | - } |
|
285 | - } |
|
280 | + if (in_array($scheduleNthWhat, $schedNthWhats)) { |
|
281 | + return TRUE; |
|
282 | + } else { |
|
283 | + return FALSE; |
|
284 | + } |
|
285 | + } |
|
286 | 286 | |
287 | - /** Function adds the locations (with/without schedule) from the CSV file. |
|
288 | - * $csvFileHandle - a file handler. |
|
289 | - * Returns array $results which contains two arrays: fail and succes. |
|
290 | - */ |
|
291 | - public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping) |
|
292 | - { |
|
293 | - $max_line_length = 512; |
|
294 | - $delemietr = ','; |
|
287 | + /** Function adds the locations (with/without schedule) from the CSV file. |
|
288 | + * $csvFileHandle - a file handler. |
|
289 | + * Returns array $results which contains two arrays: fail and succes. |
|
290 | + */ |
|
291 | + public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping) |
|
292 | + { |
|
293 | + $max_line_length = 512; |
|
294 | + $delemietr = ','; |
|
295 | 295 | |
296 | - $results = array(); |
|
297 | - $results['fail'] = array(); |
|
298 | - $results['success'] = array(); |
|
296 | + $results = array(); |
|
297 | + $results['fail'] = array(); |
|
298 | + $results['success'] = array(); |
|
299 | 299 | |
300 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
300 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
301 | 301 | |
302 | - $addressBookFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
302 | + $addressBookFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
303 | 303 | |
304 | - if (empty($columns)) { |
|
305 | - array_push($results['fail'], 'Empty CSV table'); |
|
306 | - return ($results); |
|
307 | - } |
|
304 | + if (empty($columns)) { |
|
305 | + array_push($results['fail'], 'Empty CSV table'); |
|
306 | + return ($results); |
|
307 | + } |
|
308 | 308 | |
309 | - $iRow = 1; |
|
309 | + $iRow = 1; |
|
310 | 310 | |
311 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
312 | - if (!isset($rows[$locationsFieldsMapping['cached_lat']]) || !isset($rows[$locationsFieldsMapping['cached_lng']]) |
|
313 | - || !isset($rows[$locationsFieldsMapping['address_1']]) || array(null)==$rows) { |
|
314 | - continue; |
|
315 | - } |
|
311 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
312 | + if (!isset($rows[$locationsFieldsMapping['cached_lat']]) || !isset($rows[$locationsFieldsMapping['cached_lng']]) |
|
313 | + || !isset($rows[$locationsFieldsMapping['address_1']]) || array(null)==$rows) { |
|
314 | + continue; |
|
315 | + } |
|
316 | 316 | |
317 | - $curSchedule = ""; |
|
318 | - $mode = ""; |
|
317 | + $curSchedule = ""; |
|
318 | + $mode = ""; |
|
319 | 319 | |
320 | - $failCount = sizeof($results['fail']); |
|
320 | + $failCount = sizeof($results['fail']); |
|
321 | 321 | |
322 | - if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
323 | - if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
324 | - $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
325 | - $mode = $rows[$locationsFieldsMapping['schedule_mode']]; |
|
326 | - } else { |
|
327 | - array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); |
|
328 | - } |
|
329 | - } else { |
|
330 | - array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); |
|
331 | - } |
|
322 | + if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
323 | + if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
324 | + $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
325 | + $mode = $rows[$locationsFieldsMapping['schedule_mode']]; |
|
326 | + } else { |
|
327 | + array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); |
|
328 | + } |
|
329 | + } else { |
|
330 | + array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); |
|
331 | + } |
|
332 | 332 | |
333 | - if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
334 | - if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
335 | - $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
336 | - } else { |
|
337 | - array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set "); |
|
338 | - } |
|
339 | - } |
|
333 | + if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
334 | + if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
335 | + $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
336 | + } else { |
|
337 | + array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set "); |
|
338 | + } |
|
339 | + } |
|
340 | 340 | |
341 | - if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
342 | - if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
343 | - $curSchedule .= '"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
344 | - if ($mode=='daily') { |
|
345 | - $curSchedule = trim($curSchedule, ','); |
|
346 | - $curSchedule .= '}'; |
|
347 | - } |
|
348 | - } else { |
|
349 | - array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); |
|
350 | - } |
|
351 | - } |
|
341 | + if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
342 | + if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
343 | + $curSchedule .= '"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
344 | + if ($mode=='daily') { |
|
345 | + $curSchedule = trim($curSchedule, ','); |
|
346 | + $curSchedule .= '}'; |
|
347 | + } |
|
348 | + } else { |
|
349 | + array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); |
|
350 | + } |
|
351 | + } |
|
352 | 352 | |
353 | - if ($mode!='daily') { |
|
354 | - switch ($mode) { |
|
355 | - case 'weekly': |
|
356 | - if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
357 | - if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
358 | - $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
359 | - } else { |
|
360 | - array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
361 | - } |
|
362 | - } else { |
|
363 | - array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
364 | - } |
|
365 | - break; |
|
366 | - case 'monthly': |
|
367 | - $monthlyMode = ""; |
|
368 | - if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
369 | - if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
370 | - $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
371 | - $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
372 | - } else { |
|
373 | - array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
374 | - } |
|
375 | - } else { |
|
376 | - array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
377 | - } |
|
353 | + if ($mode!='daily') { |
|
354 | + switch ($mode) { |
|
355 | + case 'weekly': |
|
356 | + if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
357 | + if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
358 | + $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
359 | + } else { |
|
360 | + array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
361 | + } |
|
362 | + } else { |
|
363 | + array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
364 | + } |
|
365 | + break; |
|
366 | + case 'monthly': |
|
367 | + $monthlyMode = ""; |
|
368 | + if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
369 | + if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
370 | + $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
371 | + $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
372 | + } else { |
|
373 | + array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
374 | + } |
|
375 | + } else { |
|
376 | + array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
377 | + } |
|
378 | 378 | |
379 | - if ($monthlyMode!="") { |
|
380 | - switch ($monthlyMode) { |
|
381 | - case 'dates': |
|
382 | - if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
383 | - if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
384 | - $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
385 | - } else { |
|
386 | - array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
387 | - } |
|
388 | - } |
|
389 | - break; |
|
390 | - case 'nth': |
|
391 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
392 | - if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
393 | - $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
394 | - } else { |
|
395 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
396 | - } |
|
397 | - } else { |
|
398 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
399 | - } |
|
379 | + if ($monthlyMode!="") { |
|
380 | + switch ($monthlyMode) { |
|
381 | + case 'dates': |
|
382 | + if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
383 | + if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
384 | + $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
385 | + } else { |
|
386 | + array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
387 | + } |
|
388 | + } |
|
389 | + break; |
|
390 | + case 'nth': |
|
391 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
392 | + if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
393 | + $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
394 | + } else { |
|
395 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
396 | + } |
|
397 | + } else { |
|
398 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
399 | + } |
|
400 | 400 | |
401 | - if ($curSchedule!="") { |
|
402 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
403 | - if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
404 | - $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
405 | - } else { |
|
406 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
407 | - } |
|
408 | - } else { |
|
409 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
410 | - } |
|
411 | - } |
|
412 | - break; |
|
413 | - } |
|
414 | - } |
|
415 | - break; |
|
416 | - default: |
|
417 | - $curSchedule = ""; |
|
418 | - break; |
|
419 | - } |
|
420 | - } |
|
401 | + if ($curSchedule!="") { |
|
402 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
403 | + if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
404 | + $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
405 | + } else { |
|
406 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
407 | + } |
|
408 | + } else { |
|
409 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
410 | + } |
|
411 | + } |
|
412 | + break; |
|
413 | + } |
|
414 | + } |
|
415 | + break; |
|
416 | + default: |
|
417 | + $curSchedule = ""; |
|
418 | + break; |
|
419 | + } |
|
420 | + } |
|
421 | 421 | |
422 | - if (sizeof($results['fail'])>$failCount) { |
|
423 | - $curSchedule = ""; |
|
424 | - } |
|
422 | + if (sizeof($results['fail'])>$failCount) { |
|
423 | + $curSchedule = ""; |
|
424 | + } |
|
425 | 425 | |
426 | - if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") { |
|
427 | - $iRow++; |
|
428 | - continue; |
|
429 | - } |
|
426 | + if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") { |
|
427 | + $iRow++; |
|
428 | + continue; |
|
429 | + } |
|
430 | 430 | |
431 | - $curSchedule = strtolower($curSchedule); |
|
431 | + $curSchedule = strtolower($curSchedule); |
|
432 | 432 | |
433 | - $curSchedule = '[{'.$curSchedule.'}]'; |
|
433 | + $curSchedule = '[{'.$curSchedule.'}]'; |
|
434 | 434 | |
435 | - $oSchedule = json_decode($curSchedule, TRUE); |
|
435 | + $oSchedule = json_decode($curSchedule, TRUE); |
|
436 | 436 | |
437 | - $parametersArray = array(); |
|
437 | + $parametersArray = array(); |
|
438 | 438 | |
439 | - foreach ($addressBookFields as $addressBookField) { |
|
440 | - if (isset($locationsFieldsMapping[$addressBookField])) { |
|
441 | - $parametersArray[$addressBookField] = $rows[$locationsFieldsMapping[$addressBookField]]; |
|
442 | - } |
|
443 | - } |
|
439 | + foreach ($addressBookFields as $addressBookField) { |
|
440 | + if (isset($locationsFieldsMapping[$addressBookField])) { |
|
441 | + $parametersArray[$addressBookField] = $rows[$locationsFieldsMapping[$addressBookField]]; |
|
442 | + } |
|
443 | + } |
|
444 | 444 | |
445 | - $AdressBookLocationParameters = AddressBookLocation::fromArray($parametersArray); |
|
445 | + $AdressBookLocationParameters = AddressBookLocation::fromArray($parametersArray); |
|
446 | 446 | |
447 | - $abContacts = new AddressBookLocation(); |
|
447 | + $abContacts = new AddressBookLocation(); |
|
448 | 448 | |
449 | - $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
449 | + $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
450 | 450 | |
451 | - array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
452 | - } |
|
451 | + array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
452 | + } |
|
453 | 453 | |
454 | - return $results; |
|
455 | - } |
|
454 | + return $results; |
|
455 | + } |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | \ No newline at end of file |
@@ -26,20 +26,20 @@ |
||
26 | 26 | |
27 | 27 | $addresses = array(); |
28 | 28 | foreach ($json as $address) { |
29 | - $addresses[] = Address::fromArray($address); |
|
29 | + $addresses[] = Address::fromArray($address); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $parameters = RouteParameters::fromArray(array( |
33 | - "algorithm_type" => AlgorithmType::CVRP_TW_SD, |
|
34 | - "distance_unit" => DistanceUnit::MILES, |
|
35 | - "device_type" => DeviceType::WEB, |
|
36 | - "optimize" => OptimizationType::DISTANCE, |
|
37 | - "metric" => Metric::GEODESIC, |
|
38 | - "route_max_duration" => 86400 * 2, |
|
39 | - "travel_mode" => TravelMode::DRIVING, |
|
40 | - "vehicle_capacity" => 50, |
|
41 | - "vehicle_max_distance_mi" => 10000, |
|
42 | - "parts" => 50 |
|
33 | + "algorithm_type" => AlgorithmType::CVRP_TW_SD, |
|
34 | + "distance_unit" => DistanceUnit::MILES, |
|
35 | + "device_type" => DeviceType::WEB, |
|
36 | + "optimize" => OptimizationType::DISTANCE, |
|
37 | + "metric" => Metric::GEODESIC, |
|
38 | + "route_max_duration" => 86400 * 2, |
|
39 | + "travel_mode" => TravelMode::DRIVING, |
|
40 | + "vehicle_capacity" => 50, |
|
41 | + "vehicle_max_distance_mi" => 10000, |
|
42 | + "parts" => 50 |
|
43 | 43 | )); |
44 | 44 | |
45 | 45 | $optimizationParams = new OptimizationProblemParams; |
@@ -25,18 +25,18 @@ discard block |
||
25 | 25 | |
26 | 26 | $addresses = array(); |
27 | 27 | foreach ($json as $address) { |
28 | - $addresses[] = Address::fromArray($address); |
|
28 | + $addresses[] = Address::fromArray($address); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | $parameters = RouteParameters::fromArray(array( |
32 | - "algorithm_type" => Algorithmtype::TSP, |
|
33 | - "route_name" => "Single Driver Multiple TimeWindows 12 Stops", |
|
34 | - "route_date" => time() + 24 * 60 * 60, |
|
35 | - "route_time" => 5 * 3600 + 30 * 60, |
|
36 | - "distance_unit" => DistanceUnit::MILES, |
|
37 | - "device_type" => DeviceType::WEB, |
|
38 | - "optimize" => OptimizationType::DISTANCE, |
|
39 | - "metric" => Metric::GEODESIC |
|
32 | + "algorithm_type" => Algorithmtype::TSP, |
|
33 | + "route_name" => "Single Driver Multiple TimeWindows 12 Stops", |
|
34 | + "route_date" => time() + 24 * 60 * 60, |
|
35 | + "route_time" => 5 * 3600 + 30 * 60, |
|
36 | + "distance_unit" => DistanceUnit::MILES, |
|
37 | + "device_type" => DeviceType::WEB, |
|
38 | + "optimize" => OptimizationType::DISTANCE, |
|
39 | + "metric" => Metric::GEODESIC |
|
40 | 40 | )); |
41 | 41 | |
42 | 42 | $optimizationParams = new OptimizationProblemParams; |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | $problem = OptimizationProblem::optimize($optimizationParams); |
47 | 47 | |
48 | 48 | foreach ((array)$problem as $key => $value) { |
49 | - if (is_string($value)) { |
|
50 | - echo $key." --> ".$value."<br>"; |
|
51 | - } else { |
|
52 | - echo "************ $key ************* <br>"; |
|
53 | - Route4Me::simplePrint((array)$value, true); |
|
54 | - echo "******************************* <br>"; |
|
55 | - } |
|
49 | + if (is_string($value)) { |
|
50 | + echo $key." --> ".$value."<br>"; |
|
51 | + } else { |
|
52 | + echo "************ $key ************* <br>"; |
|
53 | + Route4Me::simplePrint((array)$value, true); |
|
54 | + echo "******************************* <br>"; |
|
55 | + } |
|
56 | 56 | } |
@@ -26,24 +26,24 @@ discard block |
||
26 | 26 | |
27 | 27 | $addresses = array(); |
28 | 28 | foreach ($json as $address) { |
29 | - $addresses[] = Address::fromArray($address); |
|
29 | + $addresses[] = Address::fromArray($address); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $parameters = RouteParameters::fromArray(array( |
33 | - "algorithm_type" => Algorithmtype::CVRP_TW_SD, |
|
34 | - "route_name" => "Single Depot, Multiple Driver, No Time Window", |
|
35 | - "route_date" => time() + 24 * 60 * 60, |
|
36 | - "route_time" => 60 * 60 * 7, |
|
37 | - "rt" => TRUE, |
|
38 | - "distance_unit" => DistanceUnit::MILES, |
|
39 | - "device_type" => DeviceType::WEB, |
|
40 | - "optimize" => OptimizationType::TIME, |
|
41 | - "metric" => Metric::GEODESIC, |
|
42 | - "route_max_duration" => 86400, |
|
43 | - "travel_mode" => TravelMode::DRIVING, |
|
44 | - "vehicle_capacity" => 20, |
|
45 | - "vehicle_max_distance_mi" => 99999, |
|
46 | - "parts" => 4 |
|
33 | + "algorithm_type" => Algorithmtype::CVRP_TW_SD, |
|
34 | + "route_name" => "Single Depot, Multiple Driver, No Time Window", |
|
35 | + "route_date" => time() + 24 * 60 * 60, |
|
36 | + "route_time" => 60 * 60 * 7, |
|
37 | + "rt" => TRUE, |
|
38 | + "distance_unit" => DistanceUnit::MILES, |
|
39 | + "device_type" => DeviceType::WEB, |
|
40 | + "optimize" => OptimizationType::TIME, |
|
41 | + "metric" => Metric::GEODESIC, |
|
42 | + "route_max_duration" => 86400, |
|
43 | + "travel_mode" => TravelMode::DRIVING, |
|
44 | + "vehicle_capacity" => 20, |
|
45 | + "vehicle_max_distance_mi" => 99999, |
|
46 | + "parts" => 4 |
|
47 | 47 | )); |
48 | 48 | |
49 | 49 | $optimizationParams = new OptimizationProblemParams; |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | $problem = OptimizationProblem::optimize($optimizationParams); |
54 | 54 | |
55 | 55 | foreach ((array)$problem as $key => $value) { |
56 | - if (is_string($value)) { |
|
57 | - echo $key." --> ".$value."<br>"; |
|
58 | - } else { |
|
59 | - echo "************ $key ************* <br>"; |
|
60 | - Route4Me::simplePrint((array)$value, true); |
|
61 | - echo "******************************* <br>"; |
|
62 | - } |
|
56 | + if (is_string($value)) { |
|
57 | + echo $key." --> ".$value."<br>"; |
|
58 | + } else { |
|
59 | + echo "************ $key ************* <br>"; |
|
60 | + Route4Me::simplePrint((array)$value, true); |
|
61 | + echo "******************************* <br>"; |
|
62 | + } |
|
63 | 63 | } |