GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( e93048...2c5e37 )
by Oleg
02:40
created
src/Route4Me/Route4Me.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 
45 45
 		$rpath = realpath($fname);
46 46
 		
47
-		$fp=fopen(realpath($fname),"r");
47
+		$fp = fopen(realpath($fname), "r");
48 48
 		
49
-		$url = self::$baseUrl.$options['url'] . '?' . http_build_query(array_merge(
50
-            array( 'api_key' => self::getApiKey()), $query)
49
+		$url = self::$baseUrl.$options['url'].'?'.http_build_query(array_merge(
50
+            array('api_key' => self::getApiKey()), $query)
51 51
         );
52 52
 		
53 53
 		//self::simplePrint($body);die("");
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		//echo "code = $code <br>";
82 82
 		$json = json_decode($result, true);
83 83
 		//var_dump($json); die("");
84
-        if (200 == $code) {
84
+        if (200==$code) {
85 85
             return $json;
86 86
         } elseif (isset($json['errors'])) {
87 87
             throw new ApiError(implode(', ', $json['errors']));
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     public static function makeRequst($options) {
94 94
         $errorHandler = new myErrorHandler();
95 95
     
96
-        $old_error_handler = set_error_handler(array( $errorHandler, "proc_error"));
96
+        $old_error_handler = set_error_handler(array($errorHandler, "proc_error"));
97 97
         $method = isset($options['method']) ? $options['method'] : 'GET';
98 98
         $query = isset($options['query']) ?
99 99
             array_filter($options['query']) : array();
@@ -106,26 +106,26 @@  discard block
 block discarded – undo
106 106
         );
107 107
         
108 108
         if (isset($options['HTTPHEADER'])) {
109
-            $headers[]=$options['HTTPHEADER'];
109
+            $headers[] = $options['HTTPHEADER'];
110 110
         }
111 111
 
112 112
 		if (isset($options['HTTPHEADERS'])) {
113
-		    foreach ($options['HTTPHEADERS'] As $header) $headers[]=$header;
113
+		    foreach ($options['HTTPHEADERS'] As $header) $headers[] = $header;
114 114
         }
115 115
         //self::simplePrint($headers); die("");
116 116
         $ch = curl_init();
117
-        $url = $options['url'] . '?' . http_build_query(array_merge(
118
-            $query, array( 'api_key' => self::getApiKey())
117
+        $url = $options['url'].'?'.http_build_query(array_merge(
118
+            $query, array('api_key' => self::getApiKey())
119 119
         ));
120 120
 		//var_dump($body); echo "<br><br>";
121 121
 		//$jfile=json_encode($body); echo "<br><br>".$jfile; die("STOPPPP");
122 122
 
123 123
         //self::simplePrint($headers); die("");
124
-		$baseUrl=self::getBaseUrl();
124
+		$baseUrl = self::getBaseUrl();
125 125
 		
126
-		if (strpos($url,'move_route_destination')>0) $baseUrl='https://www.route4me.com';
126
+		if (strpos($url, 'move_route_destination')>0) $baseUrl = 'https://www.route4me.com';
127 127
         $curlOpts = arraY(
128
-            CURLOPT_URL            => $baseUrl. $url,
128
+            CURLOPT_URL            => $baseUrl.$url,
129 129
             CURLOPT_RETURNTRANSFER => true,
130 130
             CURLOPT_TIMEOUT        => 60,
131 131
             CURLOPT_FOLLOWLOCATION => true,
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
 		//echo "url=".$baseUrl.$url."<br>";die("");
138 138
         curl_setopt_array($ch, $curlOpts);
139 139
 		
140
-		if ($file !=null) {
140
+		if ($file!=null) {
141 141
 			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
142
-			$fp=fopen($file,'r');
143
-			curl_setopt($ch, CURLOPT_INFILE , $fp);
142
+			$fp = fopen($file, 'r');
143
+			curl_setopt($ch, CURLOPT_INFILE, $fp);
144 144
 			curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file));
145 145
 		}
146 146
 		
147
-        switch($method) {
147
+        switch ($method) {
148 148
         case 'DELETE':
149 149
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
150 150
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 			break;
170 170
         case 'POST':
171 171
 			if (isset($query)) {
172
-            	curl_setopt($ch,  CURLOPT_POSTFIELDS, json_encode($query)); 
172
+            	curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); 
173 173
 			}
174 174
             
175 175
 			//echo "<br><br>". json_encode($body); 
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 
184 184
         $result = curl_exec($ch);
185 185
 		//var_dump($result); die("");
186
-		$isxml=FALSE;
187
-		$jxml="";
186
+		$isxml = FALSE;
187
+		$jxml = "";
188 188
 		if (strpos($result, '<?xml')>-1)
189 189
 		{
190 190
 			$xml = simplexml_load_string($result);
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         curl_close($ch);
197 197
 		//echo "code -> $code <br>";
198 198
 		
199
-        if (200 == $code) {
199
+        if (200==$code) {
200 200
             if ($isxml) {
201 201
                 $json = $jxml;
202 202
             } else $json = json_decode($result, true);
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             } else {
207 207
                 return $json;
208 208
             }
209
-        }  elseif (409 == $code) {
209
+        }  elseif (409==$code) {
210 210
             
211 211
             //throw new ApiError('Wrong API key');
212 212
         } else {
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		
237 237
 		curl_setopt_array($ch, $curlOpts);
238 238
 		
239
-        switch($method) {
239
+        switch ($method) {
240 240
         case 'DELETE':
241 241
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
242 242
 
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 
275 275
 		$result = curl_exec($ch);
276 276
         
277
-		$isxml=FALSE;
278
-		$jxml="";
277
+		$isxml = FALSE;
278
+		$jxml = "";
279 279
 		if (strpos($result, '<?xml')>-1)
280 280
 		{
281 281
 			$xml = simplexml_load_string($result);
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 		} else $json = json_decode($result, true);
292 292
 		
293 293
 		
294
-        if (200 == $code) {
294
+        if (200==$code) {
295 295
             return $json;
296 296
         } elseif (isset($json['errors'])) {
297 297
             throw new ApiError(implode(', ', $json['errors']));
Please login to merge, or discard this patch.
src/Route4Me/Order.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
 		public $limit;
47 47
 		public $query;
48 48
 		
49
-		public function __construct () {  }
49
+		public function __construct() {  }
50 50
 		
51 51
 		public static function fromArray(array $params) {
52
-			$order= new Order();
53
-	        foreach($params as $key => $value) {
52
+			$order = new Order();
53
+	        foreach ($params as $key => $value) {
54 54
 	            if (property_exists($order, $key)) {
55 55
 	                $order->{$key} = $value;
56 56
 	            }
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 	            'url'    => self::$apiUrl,
66 66
 	            'method' => 'POST',
67 67
 	            'body'  => array(
68
-					'address_1' => 	isset($params->address_1) ? $params->address_1: null,
69
-					'address_2' =>     isset($params->address_2) ? $params->address_2: null,
68
+					'address_1' => 	isset($params->address_1) ? $params->address_1 : null,
69
+					'address_2' =>     isset($params->address_2) ? $params->address_2 : null,
70 70
 	                'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
71 71
 	                'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
72 72
 	                'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null,
@@ -75,30 +75,30 @@  discard block
 block discarded – undo
75 75
 	                'order_icon' => isset($params->order_icon) ? $params->order_icon : null,
76 76
 	                'day_scheduled_for_YYMMDD' => isset($params->day_scheduled_for_YYMMDD) ? $params->day_scheduled_for_YYMMDD : null,
77 77
 	                'address_alias' => isset($params->address_alias) ? $params->address_alias : null,
78
-	                'address_city' => 	isset($params->address_city) ? $params->address_city: null,
79
-	                'local_time_window_start' =>  isset($params->local_time_window_start) ? $params->local_time_window_start: null,
80
-	                'local_time_window_end' =>  isset($params->local_time_window_end) ? $params->local_time_window_end: null,
81
-	                'local_time_window_start_2' =>  isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null,
82
-	                'local_time_window_end_2' =>  isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null,
83
-	                'service_time' =>  isset($params->service_time) ? $params->service_time: null,
84
-	                'EXT_FIELD_first_name' => 	isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name: null,
85
-	                'EXT_FIELD_last_name' => 	isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name: null,
86
-	                'EXT_FIELD_email' => 	isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email: null,
87
-	                'EXT_FIELD_phone' => 	isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone: null,
88
-	                'EXT_FIELD_custom_data' => 	isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data: null,
78
+	                'address_city' => 	isset($params->address_city) ? $params->address_city : null,
79
+	                'local_time_window_start' =>  isset($params->local_time_window_start) ? $params->local_time_window_start : null,
80
+	                'local_time_window_end' =>  isset($params->local_time_window_end) ? $params->local_time_window_end : null,
81
+	                'local_time_window_start_2' =>  isset($params->local_time_window_start_2) ? $params->local_time_window_start_2 : null,
82
+	                'local_time_window_end_2' =>  isset($params->local_time_window_end_2) ? $params->local_time_window_end_2 : null,
83
+	                'service_time' =>  isset($params->service_time) ? $params->service_time : null,
84
+	                'EXT_FIELD_first_name' => 	isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name : null,
85
+	                'EXT_FIELD_last_name' => 	isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name : null,
86
+	                'EXT_FIELD_email' => 	isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email : null,
87
+	                'EXT_FIELD_phone' => 	isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone : null,
88
+	                'EXT_FIELD_custom_data' => 	isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data : null,
89 89
 				)
90 90
 	        ));
91 91
 
92 92
 			return $response;
93 93
 		}
94 94
 
95
-		public static function addOrder2Route($params,$body)
95
+		public static function addOrder2Route($params, $body)
96 96
 	    {
97 97
 	    	$response = Route4Me::makeRequst(array(
98 98
 	            'url'    => self::$apiUrlRoute,
99 99
 	            'method' => 'PUT',
100 100
 	            'query'  => array(
101
-					'route_id' => 	isset($params->route_id) ? $params->route_id: null,
101
+					'route_id' => 	isset($params->route_id) ? $params->route_id : null,
102 102
 	                'redirect' => isset($params->redirect) ? $params->redirect : null
103 103
 				),
104 104
 				'body'  => (array)$body
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 			return $response;
108 108
 		}
109 109
 		
110
-		public static function addOrder2Destination($params,$body)
110
+		public static function addOrder2Destination($params, $body)
111 111
 	    {
112 112
 	    	$response = Route4Me::makeRequst(array(
113 113
 	            'url'    => self::$apiUrlOpt,
114 114
 	            'method' => 'PUT',
115 115
 	            'query'  => array(
116
-					'optimization_problem_id' => 	isset($params->optimization_problem_id) ? $params->optimization_problem_id: null,
116
+					'optimization_problem_id' => 	isset($params->optimization_problem_id) ? $params->optimization_problem_id : null,
117 117
 	                'redirect' => isset($params->redirect) ? $params->redirect : null
118 118
 				),
119 119
 				'body'  => (array)$body
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	            'url'    => self::$apiUrl,
129 129
 	            'method' => 'GET',
130 130
 	            'query'  => array(
131
-					'order_id' => 	isset($params->order_id) ? $params->order_id: null,
131
+					'order_id' => 	isset($params->order_id) ? $params->order_id : null,
132 132
 				)
133 133
 	        ));
134 134
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	            'url'    => self::$apiUrl,
152 152
 	            'method' => 'DELETE',
153 153
 	            'body'  => array(
154
-					'order_ids' => 	isset($params->order_ids) ? $params->order_ids: null
154
+					'order_ids' => 	isset($params->order_ids) ? $params->order_ids : null
155 155
 				)
156 156
 	        ));
157 157
 
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
 	            'url'    => self::$apiUrl,
176 176
 	            'method' => 'GET',
177 177
 	            'query'  => array(
178
-					'day_added_YYMMDD' => 	isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null,
179
-					'scheduled_for_YYMMDD' => 	isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null,
180
-					'fields' => 	isset($params->fields) ? $params->fields: null,
181
-					'offset' => 	isset($params->offset) ? $params->offset: null,
182
-					'limit' => 	isset($params->limit) ? $params->limit: null,
183
-					'query' => 	isset($params->query) ? $params->query: null,
178
+					'day_added_YYMMDD' => 	isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD : null,
179
+					'scheduled_for_YYMMDD' => 	isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD : null,
180
+					'fields' => 	isset($params->fields) ? $params->fields : null,
181
+					'offset' => 	isset($params->offset) ? $params->offset : null,
182
+					'limit' => 	isset($params->limit) ? $params->limit : null,
183
+					'query' => 	isset($params->query) ? $params->query : null,
184 184
 				)
185 185
 	        ));
186 186
 
@@ -208,46 +208,46 @@  discard block
 block discarded – undo
208 208
         public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping)
209 209
         {
210 210
             $max_line_length = 512;
211
-            $delemietr=',';
211
+            $delemietr = ',';
212 212
             
213
-            $results['fail']=array();
214
-            $results['success']=array();
213
+            $results['fail'] = array();
214
+            $results['success'] = array();
215 215
             
216 216
             $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
217 217
             
218 218
             if (!$columns) {
219
-                 array_push($results['fail'],'Empty CSV table');
219
+                 array_push($results['fail'], 'Empty CSV table');
220 220
                  return ($results);
221 221
             }
222 222
                      
223
-            $iRow=1;
223
+            $iRow = 1;
224 224
             
225
-            while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) {
226
-                if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null) !== $rows) {
225
+            while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) {
226
+                if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) {
227 227
                     
228
-                    $cached_lat=0.000;
228
+                    $cached_lat = 0.000;
229 229
                     
230 230
                     if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) {
231
-                        array_push($results['fail'],"$iRow --> Wrong cached_lat"); 
231
+                        array_push($results['fail'], "$iRow --> Wrong cached_lat"); 
232 232
                         $iRow++;
233 233
                         continue;
234 234
                     }
235
-                    else $cached_lat=doubleval($rows[$ordersFieldsMapping['cached_lat']]);
235
+                    else $cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]);
236 236
                     
237
-                    $cached_lng=0.000;
237
+                    $cached_lng = 0.000;
238 238
                     
239 239
                     if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) {
240
-                        array_push($results['fail'],"$iRow --> Wrong cached_lng"); 
240
+                        array_push($results['fail'], "$iRow --> Wrong cached_lng"); 
241 241
                         $iRow++;
242 242
                         continue;
243 243
                     }
244
-                    else $cached_lng=doubleval($rows[$ordersFieldsMapping['cached_lng']]);
244
+                    else $cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]);
245 245
                     
246 246
                     
247 247
                     
248 248
                     if (isset($ordersFieldsMapping['curbside_lat'])) {
249 249
                         if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) {
250
-                            array_push($results['fail'],"$iRow --> Wrong curbside_lat"); 
250
+                            array_push($results['fail'], "$iRow --> Wrong curbside_lat"); 
251 251
                             $iRow++;
252 252
                             continue;
253 253
                         }
@@ -255,18 +255,18 @@  discard block
 block discarded – undo
255 255
                     
256 256
                     if (isset($ordersFieldsMapping['curbside_lng'])) {
257 257
                         if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) {
258
-                            array_push($results['fail'],"$iRow --> Wrong curbside_lng"); 
258
+                            array_push($results['fail'], "$iRow --> Wrong curbside_lng"); 
259 259
                             $iRow++;
260 260
                             continue;
261 261
                         }
262 262
                     }
263 263
                     
264
-                    $address=$rows[$ordersFieldsMapping['address_1']];
264
+                    $address = $rows[$ordersFieldsMapping['address_1']];
265 265
                     
266
-                    if (isset($ordersFieldsMapping['order_city'])) $address.=', '.$rows[$ordersFieldsMapping['order_city']];
267
-                    if (isset($ordersFieldsMapping['order_state_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_state_id']];
268
-                    if (isset($ordersFieldsMapping['order_zip_code'])) $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']];
269
-                    if (isset($ordersFieldsMapping['order_country_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_country_id']];
266
+                    if (isset($ordersFieldsMapping['order_city'])) $address .= ', '.$rows[$ordersFieldsMapping['order_city']];
267
+                    if (isset($ordersFieldsMapping['order_state_id'])) $address .= ', '.$rows[$ordersFieldsMapping['order_state_id']];
268
+                    if (isset($ordersFieldsMapping['order_zip_code'])) $address .= ', '.$rows[$ordersFieldsMapping['order_zip_code']];
269
+                    if (isset($ordersFieldsMapping['order_country_id'])) $address .= ', '.$rows[$ordersFieldsMapping['order_country_id']];
270 270
                     
271 271
                     echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>";
272 272
                     
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
                     
298 298
                     $orderResults = $order->addOrder($orderParameters);
299 299
                     
300
-                    array_push($results['success'],"The order with order_id = ".strval($orderResults["order_id"])." added successfuly.");
300
+                    array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly.");
301 301
                 }
302 302
                 else {
303
-                    array_push($results['fail'],"$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); 
303
+                    array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); 
304 304
                 }
305 305
                 
306 306
                 $iRow++;
Please login to merge, or discard this patch.
src/Route4Me/AddressBookLocation.php 1 patch
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,41 +109,41 @@  discard block
 block discarded – undo
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
 	                'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
116 116
 	                'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
117 117
 	                'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null,
118 118
                     'curbside_lng' => isset($params->curbside_lng) ? $params->curbside_lng : null,
119
-	                'address_phone_number' =>    isset($params->address_phone_number) ? $params->address_phone_number: null,
120
-	                'address_group' =>    isset($params->address_group) ? $params->address_group: null,
121
-	                'first_name' =>    isset($params->first_name) ? $params->first_name: null,
122
-	                'last_name' =>    isset($params->last_name) ? $params->last_name: null,
123
-                    'local_time_window_start' =>    isset($params->local_time_window_start) ? $params->local_time_window_start: null,
124
-                    'local_time_window_end' =>    isset($params->local_time_window_end) ? $params->local_time_window_end: null,
125
-                    'local_time_window_start_2' =>    isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null,
126
-                    'local_time_window_end_2' =>    isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null,
127
-	                'address_email' =>    isset($params->address_email) ? $params->address_email: null,
128
-	                'address_city' =>    isset($params->address_city) ? $params->address_city: null,
129
-	                'address_state_id' =>    isset($params->address_state_id) ? $params->address_state_id: null,
130
-	                'address_country_id' =>    isset($params->address_country_id) ? $params->address_country_id: null,
131
-	                'address_zip' =>    isset($params->address_zip) ? $params->address_zip: null,
132
-	                'address_custom_data' =>    isset($params->address_custom_data) ? $params->address_custom_data: null,
133
-	                'schedule' =>    isset($params->schedule) ? $params->schedule: null,
134
-	                'schedule_blacklist' =>    isset($params->schedule_blacklist) ? $params->schedule_blacklist: null,
135
-	                'service_time' =>    isset($params->service_time) ? $params->service_time: null,
136
-	                'local_timezone_string' =>    isset($params->local_timezone_string) ? $params->local_timezone_string: null,
137
-	                'color' =>    isset($params->color) ? $params->color: null,
138
-	                'address_icon' =>    isset($params->address_icon) ? $params->address_icon: null,
139
-	                'address_stop_type' =>    isset($params->address_stop_type) ? $params->address_stop_type: null,
140
-	                'address_cube' =>    isset($params->address_cube) ? $params->address_cube: null,
141
-	                'address_pieces' =>    isset($params->address_pieces) ? $params->address_pieces: null,
142
-	                'address_reference_no' =>    isset($params->address_reference_no) ? $params->address_reference_no: null,
143
-	                'address_revenue' =>    isset($params->address_revenue) ? $params->address_revenue: null,
144
-	                'address_weight' =>    isset($params->address_weight) ? $params->address_weight: null,
145
-	                'address_priority' =>    isset($params->address_priority) ? $params->address_priority: null,
146
-	                'address_customer_po' =>    isset($params->address_customer_po) ? $params->address_customer_po: null,
119
+	                'address_phone_number' =>    isset($params->address_phone_number) ? $params->address_phone_number : null,
120
+	                'address_group' =>    isset($params->address_group) ? $params->address_group : null,
121
+	                'first_name' =>    isset($params->first_name) ? $params->first_name : null,
122
+	                'last_name' =>    isset($params->last_name) ? $params->last_name : null,
123
+                    'local_time_window_start' =>    isset($params->local_time_window_start) ? $params->local_time_window_start : null,
124
+                    'local_time_window_end' =>    isset($params->local_time_window_end) ? $params->local_time_window_end : null,
125
+                    'local_time_window_start_2' =>    isset($params->local_time_window_start_2) ? $params->local_time_window_start_2 : null,
126
+                    'local_time_window_end_2' =>    isset($params->local_time_window_end_2) ? $params->local_time_window_end_2 : null,
127
+	                'address_email' =>    isset($params->address_email) ? $params->address_email : null,
128
+	                'address_city' =>    isset($params->address_city) ? $params->address_city : null,
129
+	                'address_state_id' =>    isset($params->address_state_id) ? $params->address_state_id : null,
130
+	                'address_country_id' =>    isset($params->address_country_id) ? $params->address_country_id : null,
131
+	                'address_zip' =>    isset($params->address_zip) ? $params->address_zip : null,
132
+	                'address_custom_data' =>    isset($params->address_custom_data) ? $params->address_custom_data : null,
133
+	                'schedule' =>    isset($params->schedule) ? $params->schedule : null,
134
+	                'schedule_blacklist' =>    isset($params->schedule_blacklist) ? $params->schedule_blacklist : null,
135
+	                'service_time' =>    isset($params->service_time) ? $params->service_time : null,
136
+	                'local_timezone_string' =>    isset($params->local_timezone_string) ? $params->local_timezone_string : null,
137
+	                'color' =>    isset($params->color) ? $params->color : null,
138
+	                'address_icon' =>    isset($params->address_icon) ? $params->address_icon : null,
139
+	                'address_stop_type' =>    isset($params->address_stop_type) ? $params->address_stop_type : null,
140
+	                'address_cube' =>    isset($params->address_cube) ? $params->address_cube : null,
141
+	                'address_pieces' =>    isset($params->address_pieces) ? $params->address_pieces : null,
142
+	                'address_reference_no' =>    isset($params->address_reference_no) ? $params->address_reference_no : null,
143
+	                'address_revenue' =>    isset($params->address_revenue) ? $params->address_revenue : null,
144
+	                'address_weight' =>    isset($params->address_weight) ? $params->address_weight : null,
145
+	                'address_priority' =>    isset($params->address_priority) ? $params->address_priority : null,
146
+	                'address_customer_po' =>    isset($params->address_customer_po) ? $params->address_customer_po : null,
147 147
 	            )
148 148
 	        ));
149 149
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	            'method' => 'ADD',
184 184
 	            'query'  => array(
185 185
 	                'first_name' => isset($params->first_name) ? $params->first_name : null,
186
-	                'address_1' => isset($params->address_1) ? $params->address_1: null,
186
+	                'address_1' => isset($params->address_1) ? $params->address_1 : null,
187 187
 	                'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
188 188
 	                'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
189 189
 	            )
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
         
195 195
         public static function validateScheduleMode($scheduleMode)
196 196
         {
197
-            $schedMmodes=array("daily","weekly","monthly","annually");
197
+            $schedMmodes = array("daily", "weekly", "monthly", "annually");
198 198
             
199 199
             if (in_array($scheduleMode, $schedMmodes)) return TRUE; else return FALSE;
200 200
         }
201 201
         
202 202
         public static function validateScheduleEnable($scheduleEnabled)
203 203
         {
204
-            $schedEnambles=array(TRUE,FALSE);
204
+            $schedEnambles = array(TRUE, FALSE);
205 205
             
206 206
             if (in_array($scheduleEnabled, $schedEnambles)) return TRUE; else return FALSE;
207 207
         }
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
             
218 218
             if (sizeof($weekdays)<1) return FALSE;
219 219
             
220
-            $isValid=TRUE;
220
+            $isValid = TRUE;
221 221
             
222
-            for ($i=0; $i < sizeof($weekdays); $i++) { 
222
+            for ($i = 0; $i<sizeof($weekdays); $i++) { 
223 223
                 if (is_numeric($weekdays[$i])) {
224
-                    $wday=intval($weekdays[$i]);
225
-                    if ($wday<1 || $wday>7) $isValid=FALSE;
224
+                    $wday = intval($weekdays[$i]);
225
+                    if ($wday<1 || $wday>7) $isValid = FALSE;
226 226
                 }
227
-                else $isValid=FALSE;
227
+                else $isValid = FALSE;
228 228
             }
229 229
             //echo $scheduleWeekDays.' --- '. $isValid."<br>";
230 230
             return $isValid;
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
         
233 233
         public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
234 234
         {
235
-            $schedMonthlyMmodes=array("dates","nth");
235
+            $schedMonthlyMmodes = array("dates", "nth");
236 236
             
237 237
             if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) return TRUE; else return FALSE;
238 238
         }
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
             
244 244
             if (sizeof($monthlyDates)<1) return FALSE;
245 245
             
246
-            $isValid=TRUE;
246
+            $isValid = TRUE;
247 247
             
248
-            for ($i=0; $i < sizeof($monthlyDates); $i++) { 
248
+            for ($i = 0; $i<sizeof($monthlyDates); $i++) { 
249 249
                 if (is_numeric($monthlyDates[$i])) {
250
-                    $mday=intval($monthlyDates[$i]);
251
-                    if ($mday<1 || $mday>31) $isValid=FALSE;
250
+                    $mday = intval($monthlyDates[$i]);
251
+                    if ($mday<1 || $mday>31) $isValid = FALSE;
252 252
                 }
253
-                else $isValid=FALSE;
253
+                else $isValid = FALSE;
254 254
             }
255 255
 
256 256
             return $isValid;
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
         {
261 261
             if (!is_numeric($scheduleNthN)) return FALSE;
262 262
             
263
-            $schedNthNs=array(1,2,3,4,5,-1);
263
+            $schedNthNs = array(1, 2, 3, 4, 5, -1);
264 264
             if (in_array($scheduleNthN, $schedNthNs)) return TRUE; else return FALSE;
265 265
         }
266 266
         
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
         {
269 269
             if (!is_numeric($scheduleNthWhat)) return FALSE;
270 270
             
271
-            $schedNthWhats=array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
271
+            $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
272 272
             if (in_array($scheduleNthWhat, $schedNthWhats)) return TRUE; else return FALSE;
273 273
         }
274 274
         
@@ -279,49 +279,49 @@  discard block
 block discarded – undo
279 279
         public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping)
280 280
         {
281 281
             $max_line_length = 512;
282
-            $delemietr=',';
282
+            $delemietr = ',';
283 283
             
284
-            $results['fail']=array();
285
-            $results['success']=array();
284
+            $results['fail'] = array();
285
+            $results['success'] = array();
286 286
             
287 287
             $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
288 288
             if (!$columns) {
289
-                array_push($results['fail'],'Empty CSV table');
289
+                array_push($results['fail'], 'Empty CSV table');
290 290
                 return ($results);
291 291
             }
292 292
                      
293
-            $iRow=1;
293
+            $iRow = 1;
294 294
             
295
-            while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) {
296
-                if ($rows[$locationsFieldsMapping['cached_lat']] && $rows[$locationsFieldsMapping['cached_lng']] && $rows[$locationsFieldsMapping['address_1']] && array(null) !== $rows) {
297
-                    $schedule="";
298
-                    $mode="";
295
+            while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) {
296
+                if ($rows[$locationsFieldsMapping['cached_lat']] && $rows[$locationsFieldsMapping['cached_lng']] && $rows[$locationsFieldsMapping['address_1']] && array(null)!==$rows) {
297
+                    $schedule = "";
298
+                    $mode = "";
299 299
                     
300 300
                     if (isset($rows[$locationsFieldsMapping['schedule_mode']])) {
301 301
                         if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) {
302
-                            $schedule='"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; 
303
-                            $mode=$rows[$locationsFieldsMapping['schedule_mode']];
302
+                            $schedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; 
303
+                            $mode = $rows[$locationsFieldsMapping['schedule_mode']];
304 304
                         }
305
-                        else {array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); $schedule="";}
305
+                        else {array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); $schedule = ""; }
306 306
                     }
307
-                    else {array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); $schedule="";}
307
+                    else {array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); $schedule = ""; }
308 308
                     
309 309
                     if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) {
310 310
                         if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { 
311
-                            $schedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
311
+                            $schedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
312 312
                         }
313
-                        else {array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set ");  $schedule="";}
313
+                        else {array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set "); $schedule = ""; }
314 314
                     }
315 315
                     
316 316
                     if (isset($rows[$locationsFieldsMapping['schedule_every']])) {
317 317
                         if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) {
318
-                            $schedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
318
+                            $schedule .= '"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
319 319
                             if ($mode=='daily') {
320
-                                $schedule=trim($schedule,',');
321
-                                $schedule.='}';
320
+                                $schedule = trim($schedule, ',');
321
+                                $schedule .= '}';
322 322
                             }
323 323
                         }
324
-                        else {array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); $schedule=""; }
324
+                        else {array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); $schedule = ""; }
325 325
                     }
326 326
                     
327 327
                     if ($mode!='daily') {
@@ -329,50 +329,50 @@  discard block
 block discarded – undo
329 329
                             case 'weekly':
330 330
                                 if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
331 331
                                     if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
332
-                                         $schedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
332
+                                         $schedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
333 333
                                     }
334
-                                    else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $schedule="";}
334
+                                    else {array_push($results['fail'], "$iRow --> Wrong weekdays"); $schedule = ""; }
335 335
                                 }
336
-                                else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $schedule="";}
336
+                                else {array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); $schedule = ""; }
337 337
                                 break;
338 338
                             case 'monthly':
339
-                                $monthlyMode="";
339
+                                $monthlyMode = "";
340 340
                                 if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
341 341
                                     if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
342
-                                         $monthlyMode=$rows[$locationsFieldsMapping['monthly_mode']];
343
-                                         $schedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
342
+                                         $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']];
343
+                                         $schedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
344 344
                                     }
345
-                                    else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $schedule="";}
345
+                                    else {array_push($results['fail'], "$iRow --> Wrong monthly mode"); $schedule = ""; }
346 346
                                 }
347
-                                else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $schedule="";}
347
+                                else {array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); $schedule = ""; }
348 348
                                 
349 349
                                 if ($monthlyMode!="") {
350 350
                                     switch ($monthlyMode) {
351 351
                                         case 'dates':
352 352
                                             if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
353 353
                                                 if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
354
-                                                     $schedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
354
+                                                     $schedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
355 355
                                                 }
356
-                                                else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $schedule="";}
356
+                                                else {array_push($results['fail'], "$iRow --> Wrong monthly dates"); $schedule = ""; }
357 357
                                             }
358 358
                                             break;
359 359
                                         case 'nth':
360 360
                                             if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
361 361
                                                 if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
362
-                                                     $schedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
362
+                                                     $schedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
363 363
                                                 }
364
-                                                else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $schedule="";}
364
+                                                else {array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); $schedule = ""; }
365 365
                                             }
366
-                                            else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $schedule="";}
366
+                                            else {array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); $schedule = ""; }
367 367
                                             
368 368
                                             if ($schedule!="") {
369 369
                                                 if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
370 370
                                                     if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
371
-                                                         $schedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
371
+                                                         $schedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
372 372
                                                     }
373
-                                                    else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $schedule="";}
373
+                                                    else {array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); $schedule = ""; }
374 374
                                                 }
375
-                                                else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $schedule="";}
375
+                                                else {array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); $schedule = ""; }
376 376
                                             }
377 377
                                             
378 378
                                             break;
@@ -386,15 +386,15 @@  discard block
 block discarded – undo
386 386
                         
387 387
                     }
388 388
 
389
-                    if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $schedule=="") {$iRow++; continue;}
389
+                    if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $schedule=="") {$iRow++; continue; }
390 390
                     
391
-                    $schedule=strtolower($schedule);
391
+                    $schedule = strtolower($schedule);
392 392
                     
393
-                    $schedule='[{'.$schedule.'}]';
393
+                    $schedule = '[{'.$schedule.'}]';
394 394
 
395
-                    $oSchedule= json_decode($schedule,TRUE);
395
+                    $oSchedule = json_decode($schedule, TRUE);
396 396
                     
397
-                    $AdressBookLocationParameters=AddressBookLocation::fromArray(array(
397
+                    $AdressBookLocationParameters = AddressBookLocation::fromArray(array(
398 398
                         "cached_lat"    => $rows[$locationsFieldsMapping['cached_lat']],
399 399
                         "cached_lng"    => $rows[$locationsFieldsMapping['cached_lng']],
400 400
                         "curbside_lat"     => isset($locationsFieldsMapping['curbside_lat']) ? $rows[$locationsFieldsMapping['curbside_lat']] : null,
@@ -432,11 +432,11 @@  discard block
 block discarded – undo
432 432
                         "address_customer_po"  => isset($locationsFieldsMapping['address_customer_po']) ? $rows[$locationsFieldsMapping['address_customer_po']] : null,
433 433
                     ));
434 434
                     
435
-                    $abContacts=new AddressBookLocation();
435
+                    $abContacts = new AddressBookLocation();
436 436
     
437
-                    $abcResults=$abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry
437
+                    $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry
438 438
                     
439
-                    array_push($results['success'],"The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly.");
439
+                    array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly.");
440 440
 
441 441
                 }
442 442
                 
Please login to merge, or discard this patch.
examples/Optimizations/hybridOptimization.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
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,35 +17,35 @@  discard block
 block discarded – undo
17 17
 
18 18
 Route4Me::setApiKey('bd48828717021141485a701453273458');
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 from a CSV file */
26 26
 
27 27
 /* Mapping of a CSV file with the address book locations - which of the CSV table column is corresponding to which of the Address Book's field*/
28
-$locationsFieldsMapping['cached_lat']=0;
29
-$locationsFieldsMapping['cached_lng']=1;
30
-$locationsFieldsMapping['address_alias']=2;
31
-$locationsFieldsMapping['address_1']=3;
32
-$locationsFieldsMapping['address_city']=4;
33
-$locationsFieldsMapping['address_state_id']=5;
34
-$locationsFieldsMapping['address_zip']=6;
35
-$locationsFieldsMapping['address_phone_number']=7;
36
-$locationsFieldsMapping['schedule_mode']=8;
37
-$locationsFieldsMapping['schedule_enabled']=9;
38
-$locationsFieldsMapping['schedule_every']=10;
39
-$locationsFieldsMapping['schedule_weekdays']=11;
40
-$locationsFieldsMapping['monthly_mode']=12;
41
-$locationsFieldsMapping['monthly_dates']=13;
42
-$locationsFieldsMapping['monthly_nth_n']=16;
43
-$locationsFieldsMapping['monthly_nth_wwhat']=17;
44
-
45
-if (($handle = fopen("$source_file", "r")) !== FALSE) {
28
+$locationsFieldsMapping['cached_lat'] = 0;
29
+$locationsFieldsMapping['cached_lng'] = 1;
30
+$locationsFieldsMapping['address_alias'] = 2;
31
+$locationsFieldsMapping['address_1'] = 3;
32
+$locationsFieldsMapping['address_city'] = 4;
33
+$locationsFieldsMapping['address_state_id'] = 5;
34
+$locationsFieldsMapping['address_zip'] = 6;
35
+$locationsFieldsMapping['address_phone_number'] = 7;
36
+$locationsFieldsMapping['schedule_mode'] = 8;
37
+$locationsFieldsMapping['schedule_enabled'] = 9;
38
+$locationsFieldsMapping['schedule_every'] = 10;
39
+$locationsFieldsMapping['schedule_weekdays'] = 11;
40
+$locationsFieldsMapping['monthly_mode'] = 12;
41
+$locationsFieldsMapping['monthly_dates'] = 13;
42
+$locationsFieldsMapping['monthly_nth_n'] = 16;
43
+$locationsFieldsMapping['monthly_nth_wwhat'] = 17;
44
+
45
+if (($handle = fopen("$source_file", "r"))!==FALSE) {
46 46
         $oAbook = new AddressBookLocation();
47 47
 
48
-        $results=$oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping); //Temporarry
48
+        $results = $oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping); //Temporarry
49 49
         
50 50
         echo "Errors: <br><br>";
51 51
         foreach ($results['fail'] as $evalue) {
@@ -61,23 +61,23 @@  discard block
 block discarded – undo
61 61
 
62 62
 /* Add orders with schedules from a CSV file  */
63 63
 
64
-$orders_file="orders_baton.csv";
64
+$orders_file = "orders_baton.csv";
65 65
 
66 66
 /* Mapping of a CSV file with the orders - which of the CSV table column is corresponding to which of the Order's field */
67 67
 
68
-$ordersFieldsMapping['cached_lat']=1;
69
-$ordersFieldsMapping['cached_lng']=0;
70
-$ordersFieldsMapping['address_alias']=2;
71
-$ordersFieldsMapping['address_1']=3;
72
-$ordersFieldsMapping['order_city']=4;
73
-$ordersFieldsMapping['order_state_id']=5;
74
-$ordersFieldsMapping['order_zip_code']=6;
75
-$ordersFieldsMapping['EXT_FIELD_phone']=7;
76
-$ordersFieldsMapping['day_scheduled_for_YYMMDD']=8;
77
-
78
-if (($handle = fopen("$orders_file", "r")) !== FALSE) {
68
+$ordersFieldsMapping['cached_lat'] = 1;
69
+$ordersFieldsMapping['cached_lng'] = 0;
70
+$ordersFieldsMapping['address_alias'] = 2;
71
+$ordersFieldsMapping['address_1'] = 3;
72
+$ordersFieldsMapping['order_city'] = 4;
73
+$ordersFieldsMapping['order_state_id'] = 5;
74
+$ordersFieldsMapping['order_zip_code'] = 6;
75
+$ordersFieldsMapping['EXT_FIELD_phone'] = 7;
76
+$ordersFieldsMapping['day_scheduled_for_YYMMDD'] = 8;
77
+
78
+if (($handle = fopen("$orders_file", "r"))!==FALSE) {
79 79
         $order = new Order();
80
-        $results=$order->addOrdersFromCsvFile($handle, $ordersFieldsMapping);
80
+        $results = $order->addOrdersFromCsvFile($handle, $ordersFieldsMapping);
81 81
         
82 82
         echo "Errors: <br><br>";
83 83
         foreach ($results['fail'] as $evalue) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
 /* Get Hybrid Optimization */
95 95
 
96
-    $ep = time()+604800;
96
+    $ep = time() + 604800;
97 97
     $sched_date = date("Y-m-d", $ep);
98 98
 
99 99
     $hybridParams = array(
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             /* Add depots to the Hybrid Optimization */
115 115
             $depotfile = "depots.csv";
116 116
             
117
-            if (($handle = fopen("$depotfile", "r")) !== FALSE) {
117
+            if (($handle = fopen("$depotfile", "r"))!==FALSE) {
118 118
                 
119 119
                 $columns = fgetcsv($handle, $max_line_length, $delemietr);
120 120
                 
@@ -128,15 +128,15 @@  discard block
 block discarded – undo
128 128
                     'delete_old_depots'  => true,
129 129
                 );
130 130
                 
131
-                $iRow=1;
131
+                $iRow = 1;
132 132
                 $depotAddresses = array();
133 133
                 
134
-                while (($rows = fgetcsv($handle, $max_line_length, $delemietr)) !== false) {
135
-                    if ($rows[0] && $rows[1] && $rows[3] && array(null) !== $rows) {
136
-                        $depotAddress['lat']= $rows[0];
137
-                        $depotAddress['lng']= $rows[1];
138
-                        $depotAddress['address']= $rows[3];   
139
-                        array_push($depotAddresses,$depotAddress);
134
+                while (($rows = fgetcsv($handle, $max_line_length, $delemietr))!==false) {
135
+                    if ($rows[0] && $rows[1] && $rows[3] && array(null)!==$rows) {
136
+                        $depotAddress['lat'] = $rows[0];
137
+                        $depotAddress['lng'] = $rows[1];
138
+                        $depotAddress['address'] = $rows[3];   
139
+                        array_push($depotAddresses, $depotAddress);
140 140
                     }
141 141
                 }
142 142
                 
Please login to merge, or discard this patch.