@@ -69,10 +69,10 @@ discard block |
||
| 69 | 69 | 'url' => self::$apiUrl, |
| 70 | 70 | 'method' => 'POST', |
| 71 | 71 | 'query' => array( |
| 72 | - 'directions' => isset($params->directions) ? $params->directions: null, |
|
| 73 | - 'format' => isset($params->format) ? $params->format: null, |
|
| 74 | - 'route_path_output' => isset($params->route_path_output) ? $params->route_path_output: null, |
|
| 75 | - 'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url: null |
|
| 72 | + 'directions' => isset($params->directions) ? $params->directions : null, |
|
| 73 | + 'format' => isset($params->format) ? $params->format : null, |
|
| 74 | + 'route_path_output' => isset($params->route_path_output) ? $params->route_path_output : null, |
|
| 75 | + 'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url : null |
|
| 76 | 76 | ), |
| 77 | 77 | 'body' => array( |
| 78 | 78 | 'addresses' => $params->getAddressesArray(), |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | if (isset($optimize['optimizations'])) { |
| 103 | 103 | $problems = array(); |
| 104 | - foreach($optimize['optimizations'] as $problem) { |
|
| 104 | + foreach ($optimize['optimizations'] as $problem) { |
|
| 105 | 105 | $problems[] = OptimizationProblem::fromArray($problem); |
| 106 | 106 | } |
| 107 | 107 | return $problems; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | return $this->routes; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - public function getRandomOptimizationId($offset,$limit) |
|
| 147 | + public function getRandomOptimizationId($offset, $limit) |
|
| 148 | 148 | { |
| 149 | 149 | $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
| 150 | 150 | $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
@@ -156,16 +156,16 @@ discard block |
||
| 156 | 156 | )); |
| 157 | 157 | |
| 158 | 158 | $optimizations = array(); |
| 159 | - foreach($json as $optimization) { |
|
| 159 | + foreach ($json as $optimization) { |
|
| 160 | 160 | if (gettype($optimization)!="array") continue; |
| 161 | 161 | foreach ($optimization as $otp1) { |
| 162 | 162 | $optimizations[] = $otp1; |
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $num=rand(0,sizeof($optimizations)-1); |
|
| 166 | + $num = rand(0, sizeof($optimizations) - 1); |
|
| 167 | 167 | //echo "num=$num.<br>".sizeof($optimizations)."<br>"; |
| 168 | - $rOptimization=$optimizations[$num]; |
|
| 168 | + $rOptimization = $optimizations[$num]; |
|
| 169 | 169 | return $rOptimization; |
| 170 | 170 | } |
| 171 | 171 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | { |
| 174 | 174 | if ($opt_id==null) return null; |
| 175 | 175 | |
| 176 | - $params = array( "optimization_problem_id" => $opt_id ); |
|
| 176 | + $params = array("optimization_problem_id" => $opt_id); |
|
| 177 | 177 | |
| 178 | 178 | $optimization = (array)$this->get($params); |
| 179 | 179 | |
@@ -187,13 +187,13 @@ discard block |
||
| 187 | 187 | { |
| 188 | 188 | $addresses = (array)$this->getAddresses($opt_id); |
| 189 | 189 | |
| 190 | - if ($addresses == null) { |
|
| 190 | + if ($addresses==null) { |
|
| 191 | 191 | echo "There are no addresses in this optimization!.. Try again."; |
| 192 | 192 | return null; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - $num=rand(0,sizeof($addresses)-1); |
|
| 196 | - $rAddress=$addresses[$num]; |
|
| 195 | + $num = rand(0, sizeof($addresses) - 1); |
|
| 196 | + $rAddress = $addresses[$num]; |
|
| 197 | 197 | |
| 198 | 198 | return $rAddress; |
| 199 | 199 | } |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | //public $offset; |
| 33 | 33 | //public $limit; |
| 34 | 34 | |
| 35 | - public function __construct () { } |
|
| 35 | + public function __construct() { } |
|
| 36 | 36 | |
| 37 | 37 | public static function fromArray(array $params) { |
| 38 | 38 | $addressbooklocation = new AddressBookLocation(); |
| 39 | - foreach($params as $key => $value) { |
|
| 39 | + foreach ($params as $key => $value) { |
|
| 40 | 40 | if (property_exists($addressbooklocation, $key)) { |
| 41 | 41 | $addressbooklocation->{$key} = $value; |
| 42 | 42 | } |
@@ -61,14 +61,14 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | public static function searchRoutedLocation($params) |
| 63 | 63 | { |
| 64 | - $result= Route4Me::makeRequst(array( |
|
| 64 | + $result = Route4Me::makeRequst(array( |
|
| 65 | 65 | 'url' => self::$apiUrl, |
| 66 | 66 | 'method' => 'GET', |
| 67 | 67 | 'query' => array( |
| 68 | - 'display' => isset($params['display']) ? $params['display']: null, |
|
| 69 | - 'query' => isset($params['query']) ? $params['query']: null, |
|
| 70 | - 'fields' => isset($params['fields']) ? $params['fields']: null, |
|
| 71 | - 'limit' => isset($params['limit']) ? $params['limit']: null, |
|
| 68 | + 'display' => isset($params['display']) ? $params['display'] : null, |
|
| 69 | + 'query' => isset($params['query']) ? $params['query'] : null, |
|
| 70 | + 'fields' => isset($params['fields']) ? $params['fields'] : null, |
|
| 71 | + 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
| 72 | 72 | 'offset' => isset($params['offset']) ? $params['offset'] : null, |
| 73 | 73 | ) |
| 74 | 74 | )); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | 'url' => self::$apiUrl, |
| 83 | 83 | 'method' => 'GET', |
| 84 | 84 | 'query' => array( |
| 85 | - 'limit' => isset($params->limit) ? $params->limit: null, |
|
| 85 | + 'limit' => isset($params->limit) ? $params->limit : null, |
|
| 86 | 86 | 'offset' => isset($params->offset) ? $params->offset : null, |
| 87 | 87 | ) |
| 88 | 88 | )); |
@@ -109,42 +109,42 @@ discard block |
||
| 109 | 109 | 'url' => self::$apiUrl, |
| 110 | 110 | 'method' => 'POST', |
| 111 | 111 | 'body' => array( |
| 112 | - 'address_1' => isset($params->address_1) ? $params->address_1: null, |
|
| 113 | - 'address_2' => isset($params->address_2) ? $params->address_2: null, |
|
| 114 | - 'address_alias' => isset($params->address_alias) ? $params->address_alias: null, |
|
| 112 | + 'address_1' => isset($params->address_1) ? $params->address_1 : null, |
|
| 113 | + 'address_2' => isset($params->address_2) ? $params->address_2 : null, |
|
| 114 | + 'address_alias' => isset($params->address_alias) ? $params->address_alias : null, |
|
| 115 | 115 | 'first_name' => isset($params->first_name) ? $params->first_name : null, |
| 116 | 116 | 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
| 117 | 117 | 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
| 118 | 118 | 'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null, |
| 119 | 119 | 'curbside_lng' => isset($params->curbside_lng) ? $params->curbside_lng : null, |
| 120 | - 'address_phone_number' => isset($params->address_phone_number) ? $params->address_phone_number: null, |
|
| 121 | - 'address_group' => isset($params->address_group) ? $params->address_group: null, |
|
| 122 | - 'first_name' => isset($params->first_name) ? $params->first_name: null, |
|
| 123 | - 'last_name' => isset($params->last_name) ? $params->last_name: null, |
|
| 124 | - 'local_time_window_start' => isset($params->local_time_window_start) ? $params->local_time_window_start: null, |
|
| 125 | - 'local_time_window_end' => isset($params->local_time_window_end) ? $params->local_time_window_end: null, |
|
| 126 | - 'local_time_window_start_2' => isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null, |
|
| 127 | - 'local_time_window_end_2' => isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null, |
|
| 128 | - 'address_email' => isset($params->address_email) ? $params->address_email: null, |
|
| 129 | - 'address_city' => isset($params->address_city) ? $params->address_city: null, |
|
| 130 | - 'address_state_id' => isset($params->address_state_id) ? $params->address_state_id: null, |
|
| 131 | - 'address_country_id' => isset($params->address_country_id) ? $params->address_country_id: null, |
|
| 132 | - 'address_zip' => isset($params->address_zip) ? $params->address_zip: null, |
|
| 133 | - 'address_custom_data' => isset($params->address_custom_data) ? $params->address_custom_data: null, |
|
| 134 | - 'schedule' => isset($params->schedule) ? $params->schedule: null, |
|
| 135 | - 'schedule_blacklist' => isset($params->schedule_blacklist) ? $params->schedule_blacklist: null, |
|
| 136 | - 'service_time' => isset($params->service_time) ? $params->service_time: null, |
|
| 137 | - 'local_timezone_string' => isset($params->local_timezone_string) ? $params->local_timezone_string: null, |
|
| 138 | - 'color' => isset($params->color) ? $params->color: null, |
|
| 139 | - 'address_icon' => isset($params->address_icon) ? $params->address_icon: null, |
|
| 140 | - 'address_stop_type' => isset($params->address_stop_type) ? $params->address_stop_type: null, |
|
| 141 | - 'address_cube' => isset($params->address_cube) ? $params->address_cube: null, |
|
| 142 | - 'address_pieces' => isset($params->address_pieces) ? $params->address_pieces: null, |
|
| 143 | - 'address_reference_no' => isset($params->address_reference_no) ? $params->address_reference_no: null, |
|
| 144 | - 'address_revenue' => isset($params->address_revenue) ? $params->address_revenue: null, |
|
| 145 | - 'address_weight' => isset($params->address_weight) ? $params->address_weight: null, |
|
| 146 | - 'address_priority' => isset($params->address_priority) ? $params->address_priority: null, |
|
| 147 | - 'address_customer_po' => isset($params->address_customer_po) ? $params->address_customer_po: null, |
|
| 120 | + 'address_phone_number' => isset($params->address_phone_number) ? $params->address_phone_number : null, |
|
| 121 | + 'address_group' => isset($params->address_group) ? $params->address_group : null, |
|
| 122 | + 'first_name' => isset($params->first_name) ? $params->first_name : null, |
|
| 123 | + 'last_name' => isset($params->last_name) ? $params->last_name : null, |
|
| 124 | + 'local_time_window_start' => isset($params->local_time_window_start) ? $params->local_time_window_start : null, |
|
| 125 | + 'local_time_window_end' => isset($params->local_time_window_end) ? $params->local_time_window_end : null, |
|
| 126 | + 'local_time_window_start_2' => isset($params->local_time_window_start_2) ? $params->local_time_window_start_2 : null, |
|
| 127 | + 'local_time_window_end_2' => isset($params->local_time_window_end_2) ? $params->local_time_window_end_2 : null, |
|
| 128 | + 'address_email' => isset($params->address_email) ? $params->address_email : null, |
|
| 129 | + 'address_city' => isset($params->address_city) ? $params->address_city : null, |
|
| 130 | + 'address_state_id' => isset($params->address_state_id) ? $params->address_state_id : null, |
|
| 131 | + 'address_country_id' => isset($params->address_country_id) ? $params->address_country_id : null, |
|
| 132 | + 'address_zip' => isset($params->address_zip) ? $params->address_zip : null, |
|
| 133 | + 'address_custom_data' => isset($params->address_custom_data) ? $params->address_custom_data : null, |
|
| 134 | + 'schedule' => isset($params->schedule) ? $params->schedule : null, |
|
| 135 | + 'schedule_blacklist' => isset($params->schedule_blacklist) ? $params->schedule_blacklist : null, |
|
| 136 | + 'service_time' => isset($params->service_time) ? $params->service_time : null, |
|
| 137 | + 'local_timezone_string' => isset($params->local_timezone_string) ? $params->local_timezone_string : null, |
|
| 138 | + 'color' => isset($params->color) ? $params->color : null, |
|
| 139 | + 'address_icon' => isset($params->address_icon) ? $params->address_icon : null, |
|
| 140 | + 'address_stop_type' => isset($params->address_stop_type) ? $params->address_stop_type : null, |
|
| 141 | + 'address_cube' => isset($params->address_cube) ? $params->address_cube : null, |
|
| 142 | + 'address_pieces' => isset($params->address_pieces) ? $params->address_pieces : null, |
|
| 143 | + 'address_reference_no' => isset($params->address_reference_no) ? $params->address_reference_no : null, |
|
| 144 | + 'address_revenue' => isset($params->address_revenue) ? $params->address_revenue : null, |
|
| 145 | + 'address_weight' => isset($params->address_weight) ? $params->address_weight : null, |
|
| 146 | + 'address_priority' => isset($params->address_priority) ? $params->address_priority : null, |
|
| 147 | + 'address_customer_po' => isset($params->address_customer_po) ? $params->address_customer_po : null, |
|
| 148 | 148 | ) |
| 149 | 149 | )); |
| 150 | 150 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | 'method' => 'ADD', |
| 185 | 185 | 'query' => array( |
| 186 | 186 | 'first_name' => isset($params->first_name) ? $params->first_name : null, |
| 187 | - 'address_1' => isset($params->address_1) ? $params->address_1: null, |
|
| 187 | + 'address_1' => isset($params->address_1) ? $params->address_1 : null, |
|
| 188 | 188 | 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
| 189 | 189 | 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
| 190 | 190 | ) |
@@ -195,14 +195,14 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | public static function validateScheduleMode($scheduleMode) |
| 197 | 197 | { |
| 198 | - $schedMmodes=array("daily","weekly","monthly","annually"); |
|
| 198 | + $schedMmodes = array("daily", "weekly", "monthly", "annually"); |
|
| 199 | 199 | |
| 200 | 200 | if (in_array($scheduleMode, $schedMmodes)) return TRUE; else return FALSE; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | public static function validateScheduleEnable($scheduleEnabled) |
| 204 | 204 | { |
| 205 | - $schedEnambles=array(TRUE,FALSE); |
|
| 205 | + $schedEnambles = array(TRUE, FALSE); |
|
| 206 | 206 | |
| 207 | 207 | if (in_array($scheduleEnabled, $schedEnambles)) return TRUE; else return FALSE; |
| 208 | 208 | } |
@@ -218,14 +218,14 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | if (sizeof($weekdays)<1) return FALSE; |
| 220 | 220 | |
| 221 | - $isValid=TRUE; |
|
| 221 | + $isValid = TRUE; |
|
| 222 | 222 | |
| 223 | - for ($i=0; $i < sizeof($weekdays); $i++) { |
|
| 223 | + for ($i = 0; $i<sizeof($weekdays); $i++) { |
|
| 224 | 224 | if (is_numeric($weekdays[$i])) { |
| 225 | - $wday=intval($weekdays[$i]); |
|
| 226 | - if ($wday<1 || $wday>7) $isValid=FALSE; |
|
| 225 | + $wday = intval($weekdays[$i]); |
|
| 226 | + if ($wday<1 || $wday>7) $isValid = FALSE; |
|
| 227 | 227 | } |
| 228 | - else $isValid=FALSE; |
|
| 228 | + else $isValid = FALSE; |
|
| 229 | 229 | } |
| 230 | 230 | //echo $scheduleWeekDays.' --- '. $isValid."<br>"; |
| 231 | 231 | return $isValid; |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
| 235 | 235 | { |
| 236 | - $schedMonthlyMmodes=array("dates","nth"); |
|
| 236 | + $schedMonthlyMmodes = array("dates", "nth"); |
|
| 237 | 237 | |
| 238 | 238 | if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) return TRUE; else return FALSE; |
| 239 | 239 | } |
@@ -244,14 +244,14 @@ discard block |
||
| 244 | 244 | |
| 245 | 245 | if (sizeof($monthlyDates)<1) return FALSE; |
| 246 | 246 | |
| 247 | - $isValid=TRUE; |
|
| 247 | + $isValid = TRUE; |
|
| 248 | 248 | |
| 249 | - for ($i=0; $i < sizeof($monthlyDates); $i++) { |
|
| 249 | + for ($i = 0; $i<sizeof($monthlyDates); $i++) { |
|
| 250 | 250 | if (is_numeric($monthlyDates[$i])) { |
| 251 | - $mday=intval($monthlyDates[$i]); |
|
| 252 | - if ($mday<1 || $mday>31) $isValid=FALSE; |
|
| 251 | + $mday = intval($monthlyDates[$i]); |
|
| 252 | + if ($mday<1 || $mday>31) $isValid = FALSE; |
|
| 253 | 253 | } |
| 254 | - else $isValid=FALSE; |
|
| 254 | + else $isValid = FALSE; |
|
| 255 | 255 | } |
| 256 | 256 | //echo $scheduleMonthlyDates.' --- '. $isValid."<br>"; |
| 257 | 257 | return $isValid; |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | { |
| 262 | 262 | if (!is_numeric($scheduleNthN)) return FALSE; |
| 263 | 263 | |
| 264 | - $schedNthNs=array(1,2,3,4,5,-1); |
|
| 264 | + $schedNthNs = array(1, 2, 3, 4, 5, -1); |
|
| 265 | 265 | if (in_array($scheduleNthN, $schedNthNs)) return TRUE; else return FALSE; |
| 266 | 266 | } |
| 267 | 267 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | { |
| 270 | 270 | if (!is_numeric($scheduleNthWhat)) return FALSE; |
| 271 | 271 | |
| 272 | - $schedNthWhats=array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
| 272 | + $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
| 273 | 273 | if (in_array($scheduleNthWhat, $schedNthWhats)) return TRUE; else return FALSE; |
| 274 | 274 | } |
| 275 | 275 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
| 4 | +$vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
| 5 | 5 | |
| 6 | 6 | require $vdir.'/../vendor/autoload.php'; |
| 7 | 7 | |
@@ -17,113 +17,113 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | Route4Me::setApiKey('11111111111111111111111111111111'); |
| 19 | 19 | |
| 20 | -$source_file="addresses_1000.csv"; |
|
| 20 | +$source_file = "addresses_1000.csv"; |
|
| 21 | 21 | $max_line_length = 512; |
| 22 | -$delemietr=','; |
|
| 22 | +$delemietr = ','; |
|
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | /* Add Address Book Locations with schedules */ |
| 26 | 26 | |
| 27 | -if (($handle = fopen("$source_file", "r")) !== FALSE) { |
|
| 27 | +if (($handle = fopen("$source_file", "r"))!==FALSE) { |
|
| 28 | 28 | $columns = fgetcsv($handle, $max_line_length, $delemietr); |
| 29 | 29 | if (!$columns) { |
| 30 | 30 | $error['message'] = 'Empty'; |
| 31 | 31 | return ($error); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - $iRow=1; |
|
| 34 | + $iRow = 1; |
|
| 35 | 35 | |
| 36 | - while (($rows = fgetcsv($handle, $max_line_length, $delemietr)) !== false) { |
|
| 36 | + while (($rows = fgetcsv($handle, $max_line_length, $delemietr))!==false) { |
|
| 37 | 37 | //if ($iRow==1) {$iRow++; continue;} |
| 38 | 38 | |
| 39 | - if ($rows[0] && $rows[1] && $rows[3] && array(null) !== $rows) { // ignore blank lines |
|
| 39 | + if ($rows[0] && $rows[1] && $rows[3] && array(null)!==$rows) { // ignore blank lines |
|
| 40 | 40 | //$data1 = $rows[0].", ".$rows[1].", ".$rows[3]; |
| 41 | 41 | |
| 42 | - $schedule=""; |
|
| 43 | - $mode=""; |
|
| 42 | + $schedule = ""; |
|
| 43 | + $mode = ""; |
|
| 44 | 44 | |
| 45 | 45 | if (isset($rows[8])) { |
| 46 | 46 | if (AddressBookLocation::validateScheduleMode($rows[8])) { |
| 47 | - $schedule='"mode":"'.$rows[8].'",'; |
|
| 48 | - $mode=$rows[8]; |
|
| 47 | + $schedule = '"mode":"'.$rows[8].'",'; |
|
| 48 | + $mode = $rows[8]; |
|
| 49 | 49 | } |
| 50 | - else {echo "$iRow --> Wrong schedule mode parameter <br>"; $schedule="";} |
|
| 50 | + else {echo "$iRow --> Wrong schedule mode parameter <br>"; $schedule = ""; } |
|
| 51 | 51 | } |
| 52 | - else {echo "$iRow --> The schedule mode parameter is not set <br>"; $schedule="";} |
|
| 52 | + else {echo "$iRow --> The schedule mode parameter is not set <br>"; $schedule = ""; } |
|
| 53 | 53 | |
| 54 | - if ($schedule=="") {$iRow++; continue;} |
|
| 54 | + if ($schedule=="") {$iRow++; continue; } |
|
| 55 | 55 | |
| 56 | 56 | if (isset($rows[9])) { |
| 57 | 57 | if (AddressBookLocation::validateScheduleEnable($rows[9])) { |
| 58 | - $schedule.='"enabled":'.$rows[9].','; |
|
| 58 | + $schedule .= '"enabled":'.$rows[9].','; |
|
| 59 | 59 | } |
| 60 | - else {echo "$iRow --> The schedule enabled parameter is not set <br>"; $schedule="";} |
|
| 60 | + else {echo "$iRow --> The schedule enabled parameter is not set <br>"; $schedule = ""; } |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - if ($schedule=="") {$iRow++; continue;} |
|
| 63 | + if ($schedule=="") {$iRow++; continue; } |
|
| 64 | 64 | |
| 65 | 65 | if (isset($rows[10])) { |
| 66 | 66 | if (AddressBookLocation::validateScheduleEvery($rows[10])) { |
| 67 | - $schedule.='"'.$mode.'":{'.'"every":'.$rows[10].','; |
|
| 67 | + $schedule .= '"'.$mode.'":{'.'"every":'.$rows[10].','; |
|
| 68 | 68 | if ($mode=='daily') { |
| 69 | - $schedule=trim($schedule,','); |
|
| 70 | - $schedule.='}'; |
|
| 69 | + $schedule = trim($schedule, ','); |
|
| 70 | + $schedule .= '}'; |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | - else {echo "$iRow --> The parameter sched_every is not set <br>"; $schedule=""; } |
|
| 73 | + else {echo "$iRow --> The parameter sched_every is not set <br>"; $schedule = ""; } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if ($schedule=="") {$iRow++; continue;} |
|
| 76 | + if ($schedule=="") {$iRow++; continue; } |
|
| 77 | 77 | |
| 78 | 78 | if ($mode!='daily') { |
| 79 | 79 | switch ($mode) { |
| 80 | 80 | case 'weekly': |
| 81 | 81 | if (isset($rows[11])) { |
| 82 | 82 | if (AddressBookLocation::validateScheduleWeekDays($rows[11])) { |
| 83 | - $schedule.='"weekdays":['.$rows[11].']}'; |
|
| 83 | + $schedule .= '"weekdays":['.$rows[11].']}'; |
|
| 84 | 84 | } |
| 85 | - else {echo "$iRow --> Wrong weekdays <br>";$schedule="";} |
|
| 85 | + else {echo "$iRow --> Wrong weekdays <br>"; $schedule = ""; } |
|
| 86 | 86 | } |
| 87 | - else {echo "$iRow --> The parameters sched_weekdays is not set <br>"; $schedule="";} |
|
| 87 | + else {echo "$iRow --> The parameters sched_weekdays is not set <br>"; $schedule = ""; } |
|
| 88 | 88 | break; |
| 89 | 89 | case 'monthly': |
| 90 | - $monthlyMode=""; |
|
| 90 | + $monthlyMode = ""; |
|
| 91 | 91 | if (isset($rows[12])) { |
| 92 | 92 | if (AddressBookLocation::validateScheduleMonthlyMode($rows[12])) { |
| 93 | - $monthlyMode=$rows[12]; |
|
| 94 | - $schedule.='"mode": "'.$rows[12].'",'; |
|
| 93 | + $monthlyMode = $rows[12]; |
|
| 94 | + $schedule .= '"mode": "'.$rows[12].'",'; |
|
| 95 | 95 | } |
| 96 | - else {echo "$iRow --> Wrong monthly mode <br>"; $schedule="";} |
|
| 96 | + else {echo "$iRow --> Wrong monthly mode <br>"; $schedule = ""; } |
|
| 97 | 97 | } |
| 98 | - else {echo "$iRow --> The parameter sched_monthly_mode is not set <br>"; $schedule="";} |
|
| 98 | + else {echo "$iRow --> The parameter sched_monthly_mode is not set <br>"; $schedule = ""; } |
|
| 99 | 99 | |
| 100 | 100 | if ($monthlyMode!="") { |
| 101 | 101 | switch ($monthlyMode) { |
| 102 | 102 | case 'dates': |
| 103 | 103 | if (isset($rows[13])) { |
| 104 | 104 | if (AddressBookLocation::validateScheduleMonthlyDates($rows[13])) { |
| 105 | - $schedule.='"dates":['.$rows[13].']}'; |
|
| 105 | + $schedule .= '"dates":['.$rows[13].']}'; |
|
| 106 | 106 | } |
| 107 | - else {echo "$iRow --> Wrong monthly dates <br>"; $schedule="";} |
|
| 107 | + else {echo "$iRow --> Wrong monthly dates <br>"; $schedule = ""; } |
|
| 108 | 108 | } |
| 109 | 109 | break; |
| 110 | 110 | case 'nth': |
| 111 | 111 | if (isset($rows[16])) { |
| 112 | 112 | if (AddressBookLocation::validateScheduleNthN($rows[16])) { |
| 113 | - $schedule.='"nth":{"n":'.$rows[16].','; |
|
| 113 | + $schedule .= '"nth":{"n":'.$rows[16].','; |
|
| 114 | 114 | } |
| 115 | - else {echo "$iRow --> Wrong parameter sched_nth_n <br>"; $schedule="";} |
|
| 115 | + else {echo "$iRow --> Wrong parameter sched_nth_n <br>"; $schedule = ""; } |
|
| 116 | 116 | } |
| 117 | - else {echo "$iRow --> The parameter sched_nth_n is not set <br>"; $schedule="";} |
|
| 117 | + else {echo "$iRow --> The parameter sched_nth_n is not set <br>"; $schedule = ""; } |
|
| 118 | 118 | |
| 119 | 119 | if ($schedule!="") { |
| 120 | 120 | if (isset($rows[17])) { |
| 121 | 121 | if (AddressBookLocation::validateScheduleNthWhat($rows[17])) { |
| 122 | - $schedule.='"what":'.$rows[17].'}}'; |
|
| 122 | + $schedule .= '"what":'.$rows[17].'}}'; |
|
| 123 | 123 | } |
| 124 | - else {echo "$iRow --> Wrong parameter sched_nth_what <br>"; $schedule="";} |
|
| 124 | + else {echo "$iRow --> Wrong parameter sched_nth_what <br>"; $schedule = ""; } |
|
| 125 | 125 | } |
| 126 | - else {echo "$iRow --> The parameter sched_nth_what is not set <br>"; $schedule="";} |
|
| 126 | + else {echo "$iRow --> The parameter sched_nth_what is not set <br>"; $schedule = ""; } |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | break; |
@@ -137,18 +137,18 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if ($schedule=="") {$iRow++; continue;} |
|
| 140 | + if ($schedule=="") {$iRow++; continue; } |
|
| 141 | 141 | |
| 142 | - $schedule=strtolower($schedule); |
|
| 142 | + $schedule = strtolower($schedule); |
|
| 143 | 143 | |
| 144 | - $schedule='[{'.$schedule.'}]'; |
|
| 144 | + $schedule = '[{'.$schedule.'}]'; |
|
| 145 | 145 | |
| 146 | 146 | //echo "$iRow --> ".$schedule."<br>"; |
| 147 | - $oSchedule= json_decode($schedule,TRUE); |
|
| 147 | + $oSchedule = json_decode($schedule, TRUE); |
|
| 148 | 148 | |
| 149 | 149 | //echo "<br>"; var_dump($oSchedule); echo "<br>"; |
| 150 | 150 | |
| 151 | - $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
| 151 | + $AdressBookLocationParameters = AddressBookLocation::fromArray(array( |
|
| 152 | 152 | "cached_lat" => $rows[0], |
| 153 | 153 | "cached_lng" => $rows[1], |
| 154 | 154 | "address_alias" => $rows[2], |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | "schedule" => isset($oSchedule) ? $oSchedule : null, |
| 161 | 161 | )); |
| 162 | 162 | |
| 163 | - $abContacts=new AddressBookLocation(); |
|
| 163 | + $abContacts = new AddressBookLocation(); |
|
| 164 | 164 | |
| 165 | - $abcResults=$abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
| 165 | + $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
| 166 | 166 | |
| 167 | 167 | echo "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly <br>"; //temporarry |
| 168 | 168 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | /* Get Hybrid Optimization */ |
| 175 | 175 | |
| 176 | - $ep = time()+604800; |
|
| 176 | + $ep = time() + 604800; |
|
| 177 | 177 | $sched_date = date("Y-m-d", $ep); |
| 178 | 178 | |
| 179 | 179 | $hybridParams = array( |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | /* Add depots to the Hybrid Optimization */ |
| 195 | 195 | $depotfile = "depots.csv"; |
| 196 | 196 | |
| 197 | - if (($handle = fopen("$depotfile", "r")) !== FALSE) { |
|
| 197 | + if (($handle = fopen("$depotfile", "r"))!==FALSE) { |
|
| 198 | 198 | |
| 199 | 199 | $columns = fgetcsv($handle, $max_line_length, $delemietr); |
| 200 | 200 | |
@@ -208,15 +208,15 @@ discard block |
||
| 208 | 208 | 'delete_old_depots' => true, |
| 209 | 209 | ); |
| 210 | 210 | |
| 211 | - $iRow=1; |
|
| 211 | + $iRow = 1; |
|
| 212 | 212 | $depotAddresses = array(); |
| 213 | 213 | |
| 214 | - while (($rows = fgetcsv($handle, $max_line_length, $delemietr)) !== false) { |
|
| 215 | - if ($rows[0] && $rows[1] && $rows[3] && array(null) !== $rows) { |
|
| 216 | - $depotAddress['lat']= $rows[0]; |
|
| 217 | - $depotAddress['lng']= $rows[1]; |
|
| 218 | - $depotAddress['address']= $rows[3]; |
|
| 219 | - array_push($depotAddresses,$depotAddress); |
|
| 214 | + while (($rows = fgetcsv($handle, $max_line_length, $delemietr))!==false) { |
|
| 215 | + if ($rows[0] && $rows[1] && $rows[3] && array(null)!==$rows) { |
|
| 216 | + $depotAddress['lat'] = $rows[0]; |
|
| 217 | + $depotAddress['lng'] = $rows[1]; |
|
| 218 | + $depotAddress['address'] = $rows[3]; |
|
| 219 | + array_push($depotAddresses, $depotAddress); |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | |