@@ -14,10 +14,10 @@ discard block |
||
14 | 14 | Route4Me::setApiKey('11111111111111111111111111111111'); |
15 | 15 | |
16 | 16 | $AddressBookLocationParameters = AddressBookLocation::fromArray(array( |
17 | - "first_name" => "Test FirstName ".strval(rand(10000, 99999)), |
|
18 | - "address_1" => "Test Address1 ".strval(rand(10000, 99999)), |
|
19 | - "cached_lat" => 38.024654, |
|
20 | - "cached_lng" => -77.338814 |
|
17 | + "first_name" => "Test FirstName ".strval(rand(10000, 99999)), |
|
18 | + "address_1" => "Test Address1 ".strval(rand(10000, 99999)), |
|
19 | + "cached_lat" => 38.024654, |
|
20 | + "cached_lng" => -77.338814 |
|
21 | 21 | )); |
22 | 22 | |
23 | 23 | $abContacts = new AddressBookLocation(); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $address_id = -1; |
28 | 28 | |
29 | 29 | if (isset($createdContact['address_id'])) { |
30 | - $address_id = $createdContact["address_id"]; |
|
30 | + $address_id = $createdContact["address_id"]; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | assert($address_id!=-1, "Creating of Address Book Location was failed. Try again!.. <br>"); |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | // Example refers to getting the address book locations |
14 | 14 | |
15 | 15 | $AddressBookLocationParameters = array( |
16 | - "limit" => 30, |
|
17 | - "offset" => 0 |
|
16 | + "limit" => 30, |
|
17 | + "offset" => 0 |
|
18 | 18 | ); |
19 | 19 | |
20 | 20 | $abContacts = new AddressBookLocation(); |
@@ -25,5 +25,5 @@ discard block |
||
25 | 25 | |
26 | 26 | foreach ($results as $result) { |
27 | 27 | Route4Me::simplePrint($result); |
28 | - echo "<br>"; |
|
28 | + echo "<br>"; |
|
29 | 29 | } |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | Route4Me::setApiKey('11111111111111111111111111111111'); |
14 | 14 | |
15 | 15 | $AddressBookLocationParameters = AddressBookLocation::fromArray(array( |
16 | - "first_name" => "Test FirstName ".strval(rand(10000, 99999)), |
|
17 | - "address_1" => "Test Address1 ".strval(rand(10000, 99999)), |
|
18 | - "cached_lat" => 38.024654, |
|
19 | - "cached_lng" => -77.338814 |
|
16 | + "first_name" => "Test FirstName ".strval(rand(10000, 99999)), |
|
17 | + "address_1" => "Test Address1 ".strval(rand(10000, 99999)), |
|
18 | + "cached_lat" => 38.024654, |
|
19 | + "cached_lng" => -77.338814 |
|
20 | 20 | )); |
21 | 21 | |
22 | 22 | $abLocation = new AddressBookLocation(); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | assert(isset($abcResult['address_id']), "Cannot create an address book location. <br><br>"); |
29 | 29 | |
30 | 30 | if (isset($abcResult["address_id"])) { |
31 | - $address_id = $abcResult["address_id"]; |
|
31 | + $address_id = $abcResult["address_id"]; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | assert($address_id!=-1, "Cannot create an address book location. <br><br>"); |
@@ -6,78 +6,78 @@ |
||
6 | 6 | |
7 | 7 | class ActivityParameters extends Common |
8 | 8 | { |
9 | - public $route_id; |
|
10 | - public $device_id; |
|
11 | - public $member_id; |
|
12 | - public $team; |
|
13 | - public $limit; |
|
14 | - public $offset; |
|
15 | - public $start; |
|
16 | - public $end; |
|
17 | - public $activity_type; |
|
18 | - public $activity_message; |
|
9 | + public $route_id; |
|
10 | + public $device_id; |
|
11 | + public $member_id; |
|
12 | + public $team; |
|
13 | + public $limit; |
|
14 | + public $offset; |
|
15 | + public $start; |
|
16 | + public $end; |
|
17 | + public $activity_type; |
|
18 | + public $activity_message; |
|
19 | 19 | |
20 | - public $activity_id; |
|
21 | - public $activity_timestamp; |
|
22 | - public $route_destination_id; |
|
23 | - public $note_id; |
|
24 | - public $member; |
|
25 | - public $note_type; |
|
26 | - public $note_contents; |
|
27 | - public $route_name; |
|
28 | - public $note_file; |
|
29 | - public $destination_name; |
|
30 | - public $destination_alias; |
|
20 | + public $activity_id; |
|
21 | + public $activity_timestamp; |
|
22 | + public $route_destination_id; |
|
23 | + public $note_id; |
|
24 | + public $member; |
|
25 | + public $note_type; |
|
26 | + public $note_contents; |
|
27 | + public $route_name; |
|
28 | + public $note_file; |
|
29 | + public $destination_name; |
|
30 | + public $destination_alias; |
|
31 | 31 | |
32 | - public static function fromArray(array $params) |
|
33 | - { |
|
34 | - $activityparameters = new ActivityParameters(); |
|
32 | + public static function fromArray(array $params) |
|
33 | + { |
|
34 | + $activityparameters = new ActivityParameters(); |
|
35 | 35 | |
36 | - foreach ($params as $key => $value) { |
|
37 | - if (property_exists($activityparameters, $key)) { |
|
38 | - $activityparameters->{$key} = $value; |
|
39 | - } |
|
40 | - } |
|
36 | + foreach ($params as $key => $value) { |
|
37 | + if (property_exists($activityparameters, $key)) { |
|
38 | + $activityparameters->{$key} = $value; |
|
39 | + } |
|
40 | + } |
|
41 | 41 | |
42 | - return $activityparameters; |
|
43 | - } |
|
42 | + return $activityparameters; |
|
43 | + } |
|
44 | 44 | |
45 | - public static function getActivities($params) |
|
46 | - { |
|
47 | - $allQueryFields = array('route_id', 'team', 'limit', 'offset', 'start'); |
|
45 | + public static function getActivities($params) |
|
46 | + { |
|
47 | + $allQueryFields = array('route_id', 'team', 'limit', 'offset', 'start'); |
|
48 | 48 | |
49 | - $activity = Route4Me::makeRequst(array( |
|
50 | - 'url' => Endpoint::GET_ACTIVITIES, |
|
51 | - 'method' => 'GET', |
|
52 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
53 | - )); |
|
49 | + $activity = Route4Me::makeRequst(array( |
|
50 | + 'url' => Endpoint::GET_ACTIVITIES, |
|
51 | + 'method' => 'GET', |
|
52 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
53 | + )); |
|
54 | 54 | |
55 | - return $activity; |
|
56 | - } |
|
55 | + return $activity; |
|
56 | + } |
|
57 | 57 | |
58 | - public static function searchActivities($params) |
|
59 | - { |
|
60 | - $allQueryFields = array('route_id', 'limit', 'offset', 'activity_type'); |
|
58 | + public static function searchActivities($params) |
|
59 | + { |
|
60 | + $allQueryFields = array('route_id', 'limit', 'offset', 'activity_type'); |
|
61 | 61 | |
62 | - $activity = Route4Me::makeRequst(array( |
|
63 | - 'url' => Endpoint::GET_ACTIVITIES, |
|
64 | - 'method' => 'GET', |
|
65 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
66 | - )); |
|
62 | + $activity = Route4Me::makeRequst(array( |
|
63 | + 'url' => Endpoint::GET_ACTIVITIES, |
|
64 | + 'method' => 'GET', |
|
65 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
66 | + )); |
|
67 | 67 | |
68 | - return $activity; |
|
69 | - } |
|
68 | + return $activity; |
|
69 | + } |
|
70 | 70 | |
71 | - public static function sendUserMessage($params) |
|
72 | - { |
|
73 | - $allBodyFields = array('activity_type', 'activity_message', 'route_id'); |
|
71 | + public static function sendUserMessage($params) |
|
72 | + { |
|
73 | + $allBodyFields = array('activity_type', 'activity_message', 'route_id'); |
|
74 | 74 | |
75 | - $result = Route4Me::makeRequst(array( |
|
76 | - 'url' => Endpoint::ACTIVITY_FEED, |
|
77 | - 'method' => 'POST', |
|
78 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
79 | - )); |
|
75 | + $result = Route4Me::makeRequst(array( |
|
76 | + 'url' => Endpoint::ACTIVITY_FEED, |
|
77 | + 'method' => 'POST', |
|
78 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
79 | + )); |
|
80 | 80 | |
81 | - return $result; |
|
82 | - } |
|
81 | + return $result; |
|
82 | + } |
|
83 | 83 | } |
@@ -44,21 +44,21 @@ discard block |
||
44 | 44 | $locationsFieldsMapping['monthly_nth_what'] = 17; |
45 | 45 | |
46 | 46 | if (($handle = fopen("$source_file", "r"))!==FALSE) { |
47 | - $oAbook = new AddressBookLocation(); |
|
47 | + $oAbook = new AddressBookLocation(); |
|
48 | 48 | |
49 | - $results = $oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping); |
|
49 | + $results = $oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping); |
|
50 | 50 | |
51 | - echo "Errors: <br><br>"; |
|
51 | + echo "Errors: <br><br>"; |
|
52 | 52 | |
53 | - foreach ($results['fail'] as $evalue) { |
|
54 | - echo $evalue."<br>"; |
|
55 | - } |
|
53 | + foreach ($results['fail'] as $evalue) { |
|
54 | + echo $evalue."<br>"; |
|
55 | + } |
|
56 | 56 | |
57 | - echo "Successes: <br><br>"; |
|
57 | + echo "Successes: <br><br>"; |
|
58 | 58 | |
59 | - foreach ($results['success'] as $svalue) { |
|
60 | - echo $svalue."<br>"; |
|
61 | - } |
|
59 | + foreach ($results['success'] as $svalue) { |
|
60 | + echo $svalue."<br>"; |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /* Add orders with schedules from a CSV file */ |
@@ -78,20 +78,20 @@ discard block |
||
78 | 78 | $ordersFieldsMapping['day_scheduled_for_YYMMDD'] = 8; |
79 | 79 | |
80 | 80 | if (($handle = fopen("$orders_file", "r"))!==FALSE) { |
81 | - $order = new Order(); |
|
82 | - $results = $order->addOrdersFromCsvFile($handle, $ordersFieldsMapping); |
|
81 | + $order = new Order(); |
|
82 | + $results = $order->addOrdersFromCsvFile($handle, $ordersFieldsMapping); |
|
83 | 83 | |
84 | - echo "Errors: <br><br>"; |
|
84 | + echo "Errors: <br><br>"; |
|
85 | 85 | |
86 | - foreach ($results['fail'] as $evalue) { |
|
87 | - echo $evalue."<br>"; |
|
88 | - } |
|
86 | + foreach ($results['fail'] as $evalue) { |
|
87 | + echo $evalue."<br>"; |
|
88 | + } |
|
89 | 89 | |
90 | - echo "Successes: <br><br>"; |
|
90 | + echo "Successes: <br><br>"; |
|
91 | 91 | |
92 | - foreach ($results['success'] as $svalue) { |
|
93 | - echo $svalue."<br>"; |
|
94 | - } |
|
92 | + foreach ($results['success'] as $svalue) { |
|
93 | + echo $svalue."<br>"; |
|
94 | + } |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /* Get Hybrid Optimization */ |
@@ -100,63 +100,63 @@ discard block |
||
100 | 100 | $sched_date = date("Y-m-d", $ep); |
101 | 101 | |
102 | 102 | $hybridParams = array( |
103 | - "target_date_string" => $sched_date, |
|
104 | - "timezone_offset_minutes" => 480 |
|
103 | + "target_date_string" => $sched_date, |
|
104 | + "timezone_offset_minutes" => 480 |
|
105 | 105 | ); |
106 | 106 | |
107 | 107 | $optimization = new OptimizationProblem(); |
108 | 108 | $hybridOptimization = $optimization->getHybridOptimization($hybridParams); |
109 | 109 | |
110 | 110 | if ($hybridOptimization!=null) { |
111 | - if (isset($hybridOptimization['optimization_problem_id'])) { |
|
112 | - $optid = $hybridOptimization['optimization_problem_id']; |
|
111 | + if (isset($hybridOptimization['optimization_problem_id'])) { |
|
112 | + $optid = $hybridOptimization['optimization_problem_id']; |
|
113 | 113 | |
114 | - echo "Hibrid optimization with optimization_problem_id = $optid <br><br>"; |
|
114 | + echo "Hibrid optimization with optimization_problem_id = $optid <br><br>"; |
|
115 | 115 | |
116 | - /* Add depots to the Hybrid Optimization */ |
|
117 | - $depotfile = "depots.csv"; |
|
116 | + /* Add depots to the Hybrid Optimization */ |
|
117 | + $depotfile = "depots.csv"; |
|
118 | 118 | |
119 | - if (($handle = fopen("$depotfile", "r"))!==FALSE) { |
|
120 | - $columns = fgetcsv($handle, $max_line_length, $delimiter); |
|
119 | + if (($handle = fopen("$depotfile", "r"))!==FALSE) { |
|
120 | + $columns = fgetcsv($handle, $max_line_length, $delimiter); |
|
121 | 121 | |
122 | - if (empty($columns)) { |
|
123 | - $error['message'] = 'Empty'; |
|
124 | - return ($error); |
|
125 | - } |
|
122 | + if (empty($columns)) { |
|
123 | + $error['message'] = 'Empty'; |
|
124 | + return ($error); |
|
125 | + } |
|
126 | 126 | |
127 | - $depotsParams = array( |
|
128 | - 'optimization_problem_id' => $optid, |
|
129 | - 'delete_old_depots' => true, |
|
130 | - ); |
|
127 | + $depotsParams = array( |
|
128 | + 'optimization_problem_id' => $optid, |
|
129 | + 'delete_old_depots' => true, |
|
130 | + ); |
|
131 | 131 | |
132 | - $iRow = 1; |
|
133 | - $depotAddresses = array(); |
|
132 | + $iRow = 1; |
|
133 | + $depotAddresses = array(); |
|
134 | 134 | |
135 | - while (($rows = fgetcsv($handle, $max_line_length, $delimiter))!==false) { |
|
136 | - if ($rows[0] && $rows[1] && $rows[3] && array(null)!==$rows) { |
|
137 | - $depotAddress['lat'] = $rows[0]; |
|
138 | - $depotAddress['lng'] = $rows[1]; |
|
139 | - $depotAddress['address'] = $rows[3]; |
|
140 | - array_push($depotAddresses, $depotAddress); |
|
141 | - } |
|
142 | - } |
|
135 | + while (($rows = fgetcsv($handle, $max_line_length, $delimiter))!==false) { |
|
136 | + if ($rows[0] && $rows[1] && $rows[3] && array(null)!==$rows) { |
|
137 | + $depotAddress['lat'] = $rows[0]; |
|
138 | + $depotAddress['lng'] = $rows[1]; |
|
139 | + $depotAddress['address'] = $rows[3]; |
|
140 | + array_push($depotAddresses, $depotAddress); |
|
141 | + } |
|
142 | + } |
|
143 | 143 | |
144 | - $depotsParams['new_depots'] = $depotAddresses; |
|
144 | + $depotsParams['new_depots'] = $depotAddresses; |
|
145 | 145 | |
146 | - $optProblem = new OptimizationProblem(); |
|
146 | + $optProblem = new OptimizationProblem(); |
|
147 | 147 | |
148 | - $resultDepots = $optProblem->addDepotsToHybrid($depotsParams); |
|
148 | + $resultDepots = $optProblem->addDepotsToHybrid($depotsParams); |
|
149 | 149 | |
150 | - /* Reoptimize hybrid optimization */ |
|
150 | + /* Reoptimize hybrid optimization */ |
|
151 | 151 | |
152 | - if ($resultDepots!=null) { |
|
153 | - $problemParams = array( |
|
154 | - 'optimization_problem_id' => $optid |
|
155 | - ); |
|
156 | - $problem = OptimizationProblem::reoptimize($problemParams); |
|
152 | + if ($resultDepots!=null) { |
|
153 | + $problemParams = array( |
|
154 | + 'optimization_problem_id' => $optid |
|
155 | + ); |
|
156 | + $problem = OptimizationProblem::reoptimize($problemParams); |
|
157 | 157 | |
158 | - Route4Me::simplePrint($problem); |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
158 | + Route4Me::simplePrint($problem); |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | 162 | } |