@@ -5,7 +5,6 @@ |
||
| 5 | 5 | require $root . '/vendor/autoload.php'; |
| 6 | 6 | |
| 7 | 7 | use Route4Me\OptimizationProblem; |
| 8 | -use Route4Me\Route; |
|
| 9 | 8 | use Route4Me\Route4Me; |
| 10 | 9 | |
| 11 | 10 | /* The example demonstrates process of creating a Hybrid Optimization using scheduling addresses and orders. |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root = realpath(dirname(__FILE__) . '/../../'); |
|
| 5 | -require $root . '/vendor/autoload.php'; |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | +require $root.'/vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | use Route4Me\OptimizationProblem; |
| 8 | 8 | use Route4Me\Route; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $locationsFieldsMapping['monthly_nth_n'] = 16; |
| 45 | 45 | $locationsFieldsMapping['monthly_nth_wwhat'] = 17; |
| 46 | 46 | |
| 47 | -if (($handle = fopen("$source_file", "r")) !== FALSE) { |
|
| 47 | +if (($handle = fopen("$source_file", "r"))!==FALSE) { |
|
| 48 | 48 | $oAbook = new AddressBookLocation(); |
| 49 | 49 | |
| 50 | 50 | $results = $oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $ordersFieldsMapping['EXT_FIELD_phone'] = 7; |
| 79 | 79 | $ordersFieldsMapping['day_scheduled_for_YYMMDD'] = 8; |
| 80 | 80 | |
| 81 | -if (($handle = fopen("$orders_file", "r")) !== FALSE) { |
|
| 81 | +if (($handle = fopen("$orders_file", "r"))!==FALSE) { |
|
| 82 | 82 | $order = new Order(); |
| 83 | 83 | $results = $order->addOrdersFromCsvFile($handle, $ordersFieldsMapping); |
| 84 | 84 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | /* Get Hybrid Optimization */ |
| 99 | 99 | |
| 100 | -$ep = time()+604800; |
|
| 100 | +$ep = time() + 604800; |
|
| 101 | 101 | $sched_date = date("Y-m-d", $ep); |
| 102 | 102 | |
| 103 | 103 | $hybridParams = array( |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | /* Add depots to the Hybrid Optimization */ |
| 118 | 118 | $depotfile = "depots.csv"; |
| 119 | 119 | |
| 120 | - if (($handle = fopen("$depotfile", "r")) !== FALSE) { |
|
| 120 | + if (($handle = fopen("$depotfile", "r"))!==FALSE) { |
|
| 121 | 121 | $columns = fgetcsv($handle, $max_line_length, $delemietr); |
| 122 | 122 | |
| 123 | 123 | if (!$columns) { |
@@ -133,12 +133,12 @@ discard block |
||
| 133 | 133 | $iRow = 1; |
| 134 | 134 | $depotAddresses = array(); |
| 135 | 135 | |
| 136 | - while (($rows = fgetcsv($handle, $max_line_length, $delemietr)) !== false) { |
|
| 137 | - if ($rows[0] && $rows[1] && $rows[3] && array(null) !== $rows) { |
|
| 136 | + while (($rows = fgetcsv($handle, $max_line_length, $delemietr))!==false) { |
|
| 137 | + if ($rows[0] && $rows[1] && $rows[3] && array(null)!==$rows) { |
|
| 138 | 138 | $depotAddress['lat'] = $rows[0]; |
| 139 | 139 | $depotAddress['lng'] = $rows[1]; |
| 140 | 140 | $depotAddress['address'] = $rows[3]; |
| 141 | - array_push($depotAddresses,$depotAddress); |
|
| 141 | + array_push($depotAddresses, $depotAddress); |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | /* Reoptimize hybrid optimization */ |
| 154 | 154 | |
| 155 | - if ($resultDepots != null) { |
|
| 155 | + if ($resultDepots!=null) { |
|
| 156 | 156 | $problemParams = array( |
| 157 | 157 | 'optimization_problem_id' => $optid |
| 158 | 158 | ); |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Route4Me\Exception\BadParam; |
| 5 | 5 | use Route4Me\Route4Me; |
| 6 | -use GuzzleHttp\Client; |
|
| 7 | 6 | use Route4Me\Common; |
| 8 | 7 | use Route4Me\Enum\Endpoint; |
| 9 | 8 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | }*/ |
| 79 | 79 | |
| 80 | 80 | $address = new Address(); |
| 81 | - foreach($params as $key => $value) { |
|
| 81 | + foreach ($params as $key => $value) { |
|
| 82 | 82 | if (property_exists($address, $key)) { |
| 83 | 83 | $address->{$key} = $value; |
| 84 | 84 | } |
@@ -156,10 +156,10 @@ discard block |
||
| 156 | 156 | 'url' => Endpoint::MARK_ADDRESS_DEPARTED, |
| 157 | 157 | 'method' => 'GET', |
| 158 | 158 | 'query' => array( |
| 159 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
| 160 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
| 161 | - 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
| 162 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
| 159 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 160 | + 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
| 161 | + 'is_departed' => isset($params['is_departed']) ? $params['is_departed'] : null, |
|
| 162 | + 'member_id' => isset($params['member_id']) ? $params['member_id'] : null, |
|
| 163 | 163 | ), |
| 164 | 164 | )); |
| 165 | 165 | |
@@ -303,8 +303,8 @@ discard block |
||
| 303 | 303 | foreach ($params as $key => $value) { |
| 304 | 304 | $kpos = strpos($key, "custom_note_type"); |
| 305 | 305 | |
| 306 | - if ($kpos !== false) { |
|
| 307 | - $customArray[$key]=$value; |
|
| 306 | + if ($kpos!==false) { |
|
| 307 | + $customArray[$key] = $value; |
|
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | |
@@ -7,7 +7,6 @@ |
||
| 7 | 7 | use Route4Me\OptimizationProblemParams; |
| 8 | 8 | use Route4Me\Route; |
| 9 | 9 | use Route4Me\Route4Me; |
| 10 | -use GuzzleHttp\Client; |
|
| 11 | 10 | use Route4Me\Enum\Endpoint; |
| 12 | 11 | |
| 13 | 12 | class OptimizationProblem extends Common |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
| 94 | 94 | 'method' => 'GET', |
| 95 | 95 | 'query' => array( |
| 96 | - 'state' => isset($params['state']) ? $params['state'] : null, |
|
| 97 | - 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
| 96 | + 'state' => isset($params['state']) ? $params['state'] : null, |
|
| 97 | + 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
| 98 | 98 | 'offset' => isset($params['offset']) ? $params['offset'] : null, |
| 99 | 99 | 'optimization_problem_id' => isset($params['optimization_problem_id']) |
| 100 | 100 | ? $params['optimization_problem_id'] : null, |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | if (isset($optimize['optimizations'])) { |
| 107 | 107 | $problems = array(); |
| 108 | 108 | |
| 109 | - foreach($optimize['optimizations'] as $problem) { |
|
| 109 | + foreach ($optimize['optimizations'] as $problem) { |
|
| 110 | 110 | $problems[] = OptimizationProblem::fromArray($problem); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | return $this->routes; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - public function getRandomOptimizationId($offset,$limit) |
|
| 154 | + public function getRandomOptimizationId($offset, $limit) |
|
| 155 | 155 | { |
| 156 | 156 | $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
| 157 | 157 | $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | )); |
| 164 | 164 | |
| 165 | 165 | $optimizations = array(); |
| 166 | - foreach($json as $optimization) { |
|
| 166 | + foreach ($json as $optimization) { |
|
| 167 | 167 | if (gettype($optimization)!="array") continue; |
| 168 | 168 | |
| 169 | 169 | foreach ($optimization as $otp1) { |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - $num = rand(0,sizeof($optimizations)-1); |
|
| 174 | + $num = rand(0, sizeof($optimizations) - 1); |
|
| 175 | 175 | |
| 176 | 176 | $rOptimization = $optimizations[$num]; |
| 177 | 177 | |
@@ -180,9 +180,9 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | public function getAddresses($opt_id) |
| 182 | 182 | { |
| 183 | - if ($opt_id == null) return null; |
|
| 183 | + if ($opt_id==null) return null; |
|
| 184 | 184 | |
| 185 | - $params = array( "optimization_problem_id" => $opt_id ); |
|
| 185 | + $params = array("optimization_problem_id" => $opt_id); |
|
| 186 | 186 | |
| 187 | 187 | $optimization = (array)$this->get($params); |
| 188 | 188 | |
@@ -195,12 +195,12 @@ discard block |
||
| 195 | 195 | { |
| 196 | 196 | $addresses = (array)$this->getAddresses($opt_id); |
| 197 | 197 | |
| 198 | - if ($addresses == null) { |
|
| 198 | + if ($addresses==null) { |
|
| 199 | 199 | echo "There are no addresses in this optimization!.. Try again."; |
| 200 | 200 | return null; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - $num = rand(0,sizeof($addresses)-1); |
|
| 203 | + $num = rand(0, sizeof($addresses) - 1); |
|
| 204 | 204 | |
| 205 | 205 | $rAddress = $addresses[$num]; |
| 206 | 206 | |
@@ -3,10 +3,8 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Route4Me\Common; |
| 5 | 5 | use Route4Me\Address; |
| 6 | -use Route4Me\Exception\BadParam; |
|
| 7 | 6 | use Route4Me\RouteParameters; |
| 8 | 7 | use Route4Me\Route4Me; |
| 9 | -use GuzzleHttp\Client; |
|
| 10 | 8 | use Route4Me\Enum\Endpoint; |
| 11 | 9 | |
| 12 | 10 | class Route extends Common |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | return $route; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public static function getRoutes($routeId=null, $params=null) |
|
| 98 | + public static function getRoutes($routeId = null, $params = null) |
|
| 99 | 99 | { |
| 100 | 100 | $result = Route4Me::makeRequst(array( |
| 101 | 101 | 'url' => Endpoint::ROUTE_V4, |
| 102 | 102 | 'method' => 'GET', |
| 103 | 103 | 'query' => array( |
| 104 | 104 | 'api_key' => Route4Me::getApiKey(), |
| 105 | - 'route_id' => !is_null($routeId) ? implode(',', (array) $routeId) : null, |
|
| 105 | + 'route_id' => !is_null($routeId) ? implode(',', (array)$routeId) : null, |
|
| 106 | 106 | 'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null, |
| 107 | 107 | 'query' => isset($params['query']) ? $params['query'] : null, |
| 108 | 108 | 'directions' => isset($params['directions']) ? $params['directions'] : null, |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | return Route::fromArray($result); die(""); |
| 117 | 117 | } else { |
| 118 | 118 | $routes = array(); |
| 119 | - foreach($result as $route) { |
|
| 119 | + foreach ($result as $route) { |
|
| 120 | 120 | $routes[] = Route::fromArray($route); |
| 121 | 121 | } |
| 122 | 122 | return $routes; |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | // Returns random route_id from existing routes between $offset and $offset+$limit |
| 233 | - public function getRandomRouteId($offset,$limit) |
|
| 233 | + public function getRandomRouteId($offset, $limit) |
|
| 234 | 234 | { |
| 235 | 235 | $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
| 236 | 236 | $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
@@ -244,12 +244,12 @@ discard block |
||
| 244 | 244 | if (sizeof($json)>0) { |
| 245 | 245 | $routes = array(); |
| 246 | 246 | |
| 247 | - foreach($json as $route) { |
|
| 247 | + foreach ($json as $route) { |
|
| 248 | 248 | $routes[] = Route::fromArray($route); |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - $num=rand(0,sizeof($routes)-1); |
|
| 252 | - $rRoute=(array)$routes[$num]; |
|
| 251 | + $num = rand(0, sizeof($routes) - 1); |
|
| 252 | + $rRoute = (array)$routes[$num]; |
|
| 253 | 253 | |
| 254 | 254 | if (is_array($rRoute)) { |
| 255 | 255 | return $rRoute["route_id"]; |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | 'query' => array( |
| 271 | 271 | 'route_id' => isset($this->route_id) ? $this->route_id : null |
| 272 | 272 | ), |
| 273 | - 'body' => array ( |
|
| 273 | + 'body' => array( |
|
| 274 | 274 | 'parameters' => $this->parameters, |
| 275 | 275 | ), |
| 276 | 276 | 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | return Route::fromArray($route); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - public function updateAddress($address=null) |
|
| 282 | + public function updateAddress($address = null) |
|
| 283 | 283 | { |
| 284 | 284 | $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) |
| 285 | 285 | : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
| 359 | 359 | $rpath = realpath($fname); |
| 360 | 360 | |
| 361 | - $result= Route4Me::makeRequst(array( |
|
| 361 | + $result = Route4Me::makeRequst(array( |
|
| 362 | 362 | 'url' => Endpoint::ROUTE_NOTES_ADD, |
| 363 | 363 | 'method' => 'POST', |
| 364 | 364 | 'query' => array( |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | $result = Route4Me::makeRequst(array( |
| 391 | 391 | 'url' => Endpoint::ROUTE_V4, |
| 392 | 392 | 'method' => 'DELETE', |
| 393 | - 'query' => array( 'route_id' => $route_id ) |
|
| 393 | + 'query' => array('route_id' => $route_id) |
|
| 394 | 394 | )); |
| 395 | 395 | |
| 396 | 396 | $result = Route4Me::makeRequst(array( |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | |
| 408 | 408 | public function GetAddressesFromRoute($route_id) |
| 409 | 409 | { |
| 410 | - $route1=Route::getRoutes($route_id,null); |
|
| 410 | + $route1 = Route::getRoutes($route_id, null); |
|
| 411 | 411 | if (isset($route1)) { |
| 412 | 412 | return $route1->addresses; |
| 413 | 413 | } else { |
@@ -417,12 +417,12 @@ discard block |
||
| 417 | 417 | |
| 418 | 418 | public function GetRandomAddressFromRoute($route_id) |
| 419 | 419 | { |
| 420 | - $route1 = Route::getRoutes($route_id,null); |
|
| 420 | + $route1 = Route::getRoutes($route_id, null); |
|
| 421 | 421 | |
| 422 | 422 | if (isset($route1)) { |
| 423 | 423 | $addresses = $route1->addresses; |
| 424 | 424 | |
| 425 | - $rnd = rand(0,sizeof($addresses)-1); |
|
| 425 | + $rnd = rand(0, sizeof($addresses) - 1); |
|
| 426 | 426 | |
| 427 | 427 | return $addresses[$rnd]; |
| 428 | 428 | |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | 5 | require $root.'/vendor/autoload.php'; |
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root = realpath(dirname(__FILE__) . '/../../'); |
|
| 5 | -require $root . '/vendor/autoload.php'; |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | +require $root.'/vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
| 8 | 8 | use Route4Me\Route; |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | 5 | require $root.'/vendor/autoload.php'; |
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root = realpath(dirname(__FILE__) . '/../../'); |
|
| 5 | -require $root . '/vendor/autoload.php'; |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | +require $root.'/vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
| 8 | 8 | use Route4Me\Route; |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | 5 | require $root.'/vendor/autoload.php'; |
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
@@ -26,10 +26,10 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | $results = $activities->sendUserMessage($postParameters); |
| 28 | 28 | |
| 29 | -$msg = isset($results["status"]) != null |
|
| 29 | +$msg = isset($results["status"])!=null |
|
| 30 | 30 | ? ($results["status"]==1 ? "The user message was sent to the route " : "he user message could not sent to the route ") |
| 31 | 31 | : "The user message could not sent to the route "; |
| 32 | 32 | |
| 33 | -$msg.=" with route_id=".$route_id; |
|
| 33 | +$msg .= " with route_id=".$route_id; |
|
| 34 | 34 | |
| 35 | 35 | echo "<br> $msg <br>"; |