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/Order.php 1 patch
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
 		static public $apiUrlOpt = '/api.v4/optimization_problem.php';
11 11
 		
12 12
 		public $address_1;
13
-        public $address_2;
13
+		public $address_2;
14 14
 		public $cached_lat;
15 15
 		public $cached_lng;
16
-        public $curbside_lat;
17
-        public $curbside_lng;
16
+		public $curbside_lat;
17
+		public $curbside_lng;
18 18
 		public $address_alias;
19 19
 		public $address_city;
20 20
 		public $EXT_FIELD_first_name;
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
 		public $EXT_FIELD_phone;
24 24
 		public $EXT_FIELD_custom_data;
25 25
         
26
-        public $color;
27
-        public $order_icon;
28
-        public $local_time_window_start;
29
-        public $local_time_window_end;
30
-        public $local_time_window_start_2;
31
-        public $local_time_window_end_2;
32
-        public $service_time;
26
+		public $color;
27
+		public $order_icon;
28
+		public $local_time_window_start;
29
+		public $local_time_window_end;
30
+		public $local_time_window_start_2;
31
+		public $local_time_window_end_2;
32
+		public $service_time;
33 33
         
34
-        public $day_scheduled_for_YYMMDD;
34
+		public $day_scheduled_for_YYMMDD;
35 35
 		
36 36
 		public $route_id;
37 37
 		public $redirect;
@@ -50,56 +50,56 @@  discard block
 block discarded – undo
50 50
 		
51 51
 		public static function fromArray(array $params) {
52 52
 			$order= new Order();
53
-	        foreach($params as $key => $value) {
54
-	            if (property_exists($order, $key)) {
55
-	                $order->{$key} = $value;
56
-	            }
53
+			foreach($params as $key => $value) {
54
+				if (property_exists($order, $key)) {
55
+					$order->{$key} = $value;
56
+				}
57 57
 			}
58 58
 			
59 59
 			return $order;
60 60
 		}
61 61
 		
62 62
 		public static function addOrder($params)
63
-	    {
64
-	    	$response = Route4Me::makeRequst(array(
65
-	            'url'    => self::$apiUrl,
66
-	            'method' => 'POST',
67
-	            'body'  => array(
63
+		{
64
+			$response = Route4Me::makeRequst(array(
65
+				'url'    => self::$apiUrl,
66
+				'method' => 'POST',
67
+				'body'  => array(
68 68
 					'address_1' => 	isset($params->address_1) ? $params->address_1: null,
69 69
 					'address_2' =>     isset($params->address_2) ? $params->address_2: null,
70
-	                'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
71
-	                'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
72
-	                'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null,
73
-                    'curbside_lng' => isset($params->curbside_lng) ? $params->curbside_lng : null,
74
-	                'color' => isset($params->color) ? $params->color : null,
75
-	                'order_icon' => isset($params->order_icon) ? $params->order_icon : null,
76
-	                'day_scheduled_for_YYMMDD' => isset($params->day_scheduled_for_YYMMDD) ? $params->day_scheduled_for_YYMMDD : null,
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,
70
+					'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
71
+					'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
72
+					'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null,
73
+					'curbside_lng' => isset($params->curbside_lng) ? $params->curbside_lng : null,
74
+					'color' => isset($params->color) ? $params->color : null,
75
+					'order_icon' => isset($params->order_icon) ? $params->order_icon : null,
76
+					'day_scheduled_for_YYMMDD' => isset($params->day_scheduled_for_YYMMDD) ? $params->day_scheduled_for_YYMMDD : null,
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,
89 89
 				)
90
-	        ));
90
+			));
91 91
 
92 92
 			return $response;
93 93
 		}
94 94
 
95 95
 		public static function addOrder2Route($params,$body)
96
-	    {
97
-	    	$response = Route4Me::makeRequst(array(
98
-	            'url'    => self::$apiUrlRoute,
99
-	            'method' => 'PUT',
100
-	            'query'  => array(
96
+		{
97
+			$response = Route4Me::makeRequst(array(
98
+				'url'    => self::$apiUrlRoute,
99
+				'method' => 'PUT',
100
+				'query'  => array(
101 101
 					'route_id' => 	isset($params->route_id) ? $params->route_id: null,
102
-	                'redirect' => isset($params->redirect) ? $params->redirect : null
102
+					'redirect' => isset($params->redirect) ? $params->redirect : null
103 103
 				),
104 104
 				'body'  => (array)$body
105 105
 			));
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
 		}
109 109
 		
110 110
 		public static function addOrder2Destination($params,$body)
111
-	    {
112
-	    	$response = Route4Me::makeRequst(array(
113
-	            'url'    => self::$apiUrlOpt,
114
-	            'method' => 'PUT',
115
-	            'query'  => array(
111
+		{
112
+			$response = Route4Me::makeRequst(array(
113
+				'url'    => self::$apiUrlOpt,
114
+				'method' => 'PUT',
115
+				'query'  => array(
116 116
 					'optimization_problem_id' => 	isset($params->optimization_problem_id) ? $params->optimization_problem_id: null,
117
-	                'redirect' => isset($params->redirect) ? $params->redirect : null
117
+					'redirect' => isset($params->redirect) ? $params->redirect : null
118 118
 				),
119 119
 				'body'  => (array)$body
120 120
 			));
@@ -123,58 +123,58 @@  discard block
 block discarded – undo
123 123
 		}
124 124
 		
125 125
 		public static function getOrder($params)
126
-	    {
127
-	    	$response = Route4Me::makeRequst(array(
128
-	            'url'    => self::$apiUrl,
129
-	            'method' => 'GET',
130
-	            'query'  => array(
126
+		{
127
+			$response = Route4Me::makeRequst(array(
128
+				'url'    => self::$apiUrl,
129
+				'method' => 'GET',
130
+				'query'  => array(
131 131
 					'order_id' => 	isset($params->order_id) ? $params->order_id: null,
132 132
 				)
133
-	        ));
133
+			));
134 134
 
135 135
 			return $response;
136 136
 		}
137 137
 		
138 138
 		public static function getOrders()
139
-	    {
140
-	    	$response = Route4Me::makeRequst(array(
141
-	            'url'    => self::$apiUrl,
142
-	            'method' => 'GET'
143
-	        ));
139
+		{
140
+			$response = Route4Me::makeRequst(array(
141
+				'url'    => self::$apiUrl,
142
+				'method' => 'GET'
143
+			));
144 144
 
145 145
 			return $response;
146 146
 		}
147 147
 		
148 148
 		public static function removeOrder($params)
149
-	    {
150
-	    	$response = Route4Me::makeRequst(array(
151
-	            'url'    => self::$apiUrl,
152
-	            'method' => 'DELETE',
153
-	            'body'  => array(
149
+		{
150
+			$response = Route4Me::makeRequst(array(
151
+				'url'    => self::$apiUrl,
152
+				'method' => 'DELETE',
153
+				'body'  => array(
154 154
 					'order_ids' => 	isset($params->order_ids) ? $params->order_ids: null
155 155
 				)
156
-	        ));
156
+			));
157 157
 
158 158
 			return $response;
159 159
 		}
160 160
 		
161 161
 		public static function updateOrder($body)
162
-	    {
163
-	    	$response = Route4Me::makeRequst(array(
164
-	            'url'    => self::$apiUrl,
165
-	            'method' => 'PUT',
166
-	            'body'  => (array)$body
167
-	        ));
162
+		{
163
+			$response = Route4Me::makeRequst(array(
164
+				'url'    => self::$apiUrl,
165
+				'method' => 'PUT',
166
+				'body'  => (array)$body
167
+			));
168 168
 
169 169
 			return $response;
170 170
 		}
171 171
 		
172 172
 		public static function searchOrder($params)
173
-	    {
174
-	    	$response = Route4Me::makeRequst(array(
175
-	            'url'    => self::$apiUrl,
176
-	            'method' => 'GET',
177
-	            'query'  => array(
173
+		{
174
+			$response = Route4Me::makeRequst(array(
175
+				'url'    => self::$apiUrl,
176
+				'method' => 'GET',
177
+				'query'  => array(
178 178
 					'day_added_YYMMDD' => 	isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null,
179 179
 					'scheduled_for_YYMMDD' => 	isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null,
180 180
 					'fields' => 	isset($params->fields) ? $params->fields: null,
@@ -182,130 +182,130 @@  discard block
 block discarded – undo
182 182
 					'limit' => 	isset($params->limit) ? $params->limit: null,
183 183
 					'query' => 	isset($params->query) ? $params->query: null,
184 184
 				)
185
-	        ));
185
+			));
186 186
 
187 187
 			return $response;
188 188
 		}
189 189
         
190
-        public static function validateLatitude($lat)
191
-        {
192
-            if (!is_numeric($lat)) return false;
190
+		public static function validateLatitude($lat)
191
+		{
192
+			if (!is_numeric($lat)) return false;
193 193
             
194
-            if ($lat>90 || $lat<-90) return false;
194
+			if ($lat>90 || $lat<-90) return false;
195 195
             
196
-            return true;
197
-        }
196
+			return true;
197
+		}
198 198
         
199
-        public static function validateLongitude($lng)
200
-        {
201
-            if (!is_numeric($lng)) return false;
199
+		public static function validateLongitude($lng)
200
+		{
201
+			if (!is_numeric($lng)) return false;
202 202
             
203
-            if ($lng>180 || $lng<-180) return false;
203
+			if ($lng>180 || $lng<-180) return false;
204 204
             
205
-            return true;
206
-        }
205
+			return true;
206
+		}
207 207
         
208
-        public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping)
209
-        {
210
-            $max_line_length = 512;
211
-            $delemietr=',';
208
+		public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping)
209
+		{
210
+			$max_line_length = 512;
211
+			$delemietr=',';
212 212
             
213
-            $results['fail']=array();
214
-            $results['success']=array();
213
+			$results['fail']=array();
214
+			$results['success']=array();
215 215
             
216
-            $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
216
+			$columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
217 217
             
218
-            if (!$columns) {
219
-                 array_push($results['fail'],'Empty CSV table');
220
-                 return ($results);
221
-            }
218
+			if (!$columns) {
219
+				 array_push($results['fail'],'Empty CSV table');
220
+				 return ($results);
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
-                    if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) {
231
-                        array_push($results['fail'],"$iRow --> Wrong cached_lat"); 
232
-                        $iRow++;
233
-                        continue;
234
-                    }
235
-                    else $cached_lat=doubleval($rows[$ordersFieldsMapping['cached_lat']]);
230
+					if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) {
231
+						array_push($results['fail'],"$iRow --> Wrong cached_lat"); 
232
+						$iRow++;
233
+						continue;
234
+					}
235
+					else $cached_lat=doubleval($rows[$ordersFieldsMapping['cached_lat']]);
236 236
                     
237
-                    $cached_lng=0.000;
237
+					$cached_lng=0.000;
238 238
                     
239
-                    if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) {
240
-                        array_push($results['fail'],"$iRow --> Wrong cached_lng"); 
241
-                        $iRow++;
242
-                        continue;
243
-                    }
244
-                    else $cached_lng=doubleval($rows[$ordersFieldsMapping['cached_lng']]);
239
+					if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) {
240
+						array_push($results['fail'],"$iRow --> Wrong cached_lng"); 
241
+						$iRow++;
242
+						continue;
243
+					}
244
+					else $cached_lng=doubleval($rows[$ordersFieldsMapping['cached_lng']]);
245 245
                     
246 246
                     
247 247
                     
248
-                    if (isset($ordersFieldsMapping['curbside_lat'])) {
249
-                        if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) {
250
-                            array_push($results['fail'],"$iRow --> Wrong curbside_lat"); 
251
-                            $iRow++;
252
-                            continue;
253
-                        }
254
-                    }
248
+					if (isset($ordersFieldsMapping['curbside_lat'])) {
249
+						if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) {
250
+							array_push($results['fail'],"$iRow --> Wrong curbside_lat"); 
251
+							$iRow++;
252
+							continue;
253
+						}
254
+					}
255 255
                     
256
-                    if (isset($ordersFieldsMapping['curbside_lng'])) {
257
-                        if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) {
258
-                            array_push($results['fail'],"$iRow --> Wrong curbside_lng"); 
259
-                            $iRow++;
260
-                            continue;
261
-                        }
262
-                    }
256
+					if (isset($ordersFieldsMapping['curbside_lng'])) {
257
+						if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) {
258
+							array_push($results['fail'],"$iRow --> Wrong curbside_lng"); 
259
+							$iRow++;
260
+							continue;
261
+						}
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
-                    echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>";
271
+					echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>";
272 272
                     
273
-                    $orderParameters = Order::fromArray(array(
274
-                        "cached_lat"    => $cached_lat,
275
-                        "cached_lng"    => $cached_lng,
276
-                        "curbside_lat"     => isset($ordersFieldsMapping['curbside_lat']) ? $rows[$ordersFieldsMapping['curbside_lat']] : null,
277
-                        "curbside_lng"     => isset($ordersFieldsMapping['curbside_lng']) ? $rows[$ordersFieldsMapping['curbside_lng']] : null,
278
-                        "color"     => isset($ordersFieldsMapping['color']) ? $rows[$ordersFieldsMapping['color']] : null,
279
-                        "day_scheduled_for_YYMMDD"     => isset($ordersFieldsMapping['day_scheduled_for_YYMMDD']) ? $rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']] : null,
280
-                        "address_alias"     => isset($ordersFieldsMapping['address_alias']) ? $rows[$ordersFieldsMapping['address_alias']] : null,
281
-                        "address_1"     => $address,
282
-                        "address_2"     => isset($ordersFieldsMapping['address_2']) ? $rows[$ordersFieldsMapping['address_2']] : null,
283
-                        "local_time_window_start"     => isset($ordersFieldsMapping['local_time_window_start']) ? $rows[$ordersFieldsMapping['local_time_window_start']] : null,
284
-                        "local_time_window_end"     => isset($ordersFieldsMapping['local_time_window_end']) ? $rows[$ordersFieldsMapping['local_time_window_end']] : null,
285
-                        "local_time_window_start_2"     => isset($ordersFieldsMapping['local_time_window_start_2']) ? $rows[$ordersFieldsMapping['local_time_window_start_2']] : null,
286
-                        "local_time_window_end_2"     => isset($ordersFieldsMapping['local_time_window_end_2']) ? $rows[$ordersFieldsMapping['local_time_window_end_2']] : null,
287
-                        "service_time"     => isset($ordersFieldsMapping['service_time']) ? $rows[$ordersFieldsMapping['service_time']] : null,
288
-                        "EXT_FIELD_first_name"     => isset($ordersFieldsMapping['EXT_FIELD_first_name']) ? $rows[$ordersFieldsMapping['EXT_FIELD_first_name']] : null,
289
-                        "EXT_FIELD_last_name"     => isset($ordersFieldsMapping['EXT_FIELD_last_name']) ? $rows[$ordersFieldsMapping['EXT_FIELD_last_name']] : null,
290
-                        "EXT_FIELD_email"     => isset($ordersFieldsMapping['EXT_FIELD_email']) ? $rows[$ordersFieldsMapping['EXT_FIELD_email']] : null,
291
-                        "EXT_FIELD_phone"     => isset($ordersFieldsMapping['EXT_FIELD_phone']) ? $rows[$ordersFieldsMapping['EXT_FIELD_phone']] : null,
292
-                        "EXT_FIELD_custom_data"     => isset($ordersFieldsMapping['EXT_FIELD_custom_data']) ? $rows[$ordersFieldsMapping['EXT_FIELD_custom_data']] : null,
293
-                        "order_icon"     => isset($ordersFieldsMapping['order_icon']) ? $rows[$ordersFieldsMapping['order_icon']] : null,
294
-                    ));
273
+					$orderParameters = Order::fromArray(array(
274
+						"cached_lat"    => $cached_lat,
275
+						"cached_lng"    => $cached_lng,
276
+						"curbside_lat"     => isset($ordersFieldsMapping['curbside_lat']) ? $rows[$ordersFieldsMapping['curbside_lat']] : null,
277
+						"curbside_lng"     => isset($ordersFieldsMapping['curbside_lng']) ? $rows[$ordersFieldsMapping['curbside_lng']] : null,
278
+						"color"     => isset($ordersFieldsMapping['color']) ? $rows[$ordersFieldsMapping['color']] : null,
279
+						"day_scheduled_for_YYMMDD"     => isset($ordersFieldsMapping['day_scheduled_for_YYMMDD']) ? $rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']] : null,
280
+						"address_alias"     => isset($ordersFieldsMapping['address_alias']) ? $rows[$ordersFieldsMapping['address_alias']] : null,
281
+						"address_1"     => $address,
282
+						"address_2"     => isset($ordersFieldsMapping['address_2']) ? $rows[$ordersFieldsMapping['address_2']] : null,
283
+						"local_time_window_start"     => isset($ordersFieldsMapping['local_time_window_start']) ? $rows[$ordersFieldsMapping['local_time_window_start']] : null,
284
+						"local_time_window_end"     => isset($ordersFieldsMapping['local_time_window_end']) ? $rows[$ordersFieldsMapping['local_time_window_end']] : null,
285
+						"local_time_window_start_2"     => isset($ordersFieldsMapping['local_time_window_start_2']) ? $rows[$ordersFieldsMapping['local_time_window_start_2']] : null,
286
+						"local_time_window_end_2"     => isset($ordersFieldsMapping['local_time_window_end_2']) ? $rows[$ordersFieldsMapping['local_time_window_end_2']] : null,
287
+						"service_time"     => isset($ordersFieldsMapping['service_time']) ? $rows[$ordersFieldsMapping['service_time']] : null,
288
+						"EXT_FIELD_first_name"     => isset($ordersFieldsMapping['EXT_FIELD_first_name']) ? $rows[$ordersFieldsMapping['EXT_FIELD_first_name']] : null,
289
+						"EXT_FIELD_last_name"     => isset($ordersFieldsMapping['EXT_FIELD_last_name']) ? $rows[$ordersFieldsMapping['EXT_FIELD_last_name']] : null,
290
+						"EXT_FIELD_email"     => isset($ordersFieldsMapping['EXT_FIELD_email']) ? $rows[$ordersFieldsMapping['EXT_FIELD_email']] : null,
291
+						"EXT_FIELD_phone"     => isset($ordersFieldsMapping['EXT_FIELD_phone']) ? $rows[$ordersFieldsMapping['EXT_FIELD_phone']] : null,
292
+						"EXT_FIELD_custom_data"     => isset($ordersFieldsMapping['EXT_FIELD_custom_data']) ? $rows[$ordersFieldsMapping['EXT_FIELD_custom_data']] : null,
293
+						"order_icon"     => isset($ordersFieldsMapping['order_icon']) ? $rows[$ordersFieldsMapping['order_icon']] : null,
294
+					));
295 295
                     
296
-                    $order = new Order();
296
+					$order = new Order();
297 297
                     
298
-                    $orderResults = $order->addOrder($orderParameters);
298
+					$orderResults = $order->addOrder($orderParameters);
299 299
                     
300
-                    array_push($results['success'],"The order with order_id = ".strval($orderResults["order_id"])." added successfuly.");
301
-                }
302
-                else {
303
-                    array_push($results['fail'],"$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); 
304
-                }
300
+					array_push($results['success'],"The order with order_id = ".strval($orderResults["order_id"])." added successfuly.");
301
+				}
302
+				else {
303
+					array_push($results['fail'],"$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); 
304
+				}
305 305
                 
306
-                $iRow++;
307
-            }
308
-        }
306
+				$iRow++;
307
+			}
308
+		}
309 309
 
310 310
 	}
311 311
 	
Please login to merge, or discard this patch.
src/Route4Me/AddressBookLocation.php 1 patch
Indentation   +324 added lines, -324 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
 		public $address_zip;
24 24
 		public $cached_lat;
25 25
 		public $cached_lng;
26
-        public $curbside_lat;
27
-        public $curbside_lng;
26
+		public $curbside_lat;
27
+		public $curbside_lng;
28 28
 		public $color;
29
-        public $address_custom_data;
30
-        public $schedule;
29
+		public $address_custom_data;
30
+		public $schedule;
31 31
 		
32 32
 		//public $offset;
33 33
 		//public $limit;
@@ -36,414 +36,414 @@  discard block
 block discarded – undo
36 36
 		
37 37
 		public static function fromArray(array $params) {
38 38
 			$addressbooklocation = new AddressBookLocation();
39
-	        foreach($params as $key => $value) {
40
-	            if (property_exists($addressbooklocation, $key)) {
41
-	                $addressbooklocation->{$key} = $value;
42
-	            }
39
+			foreach($params as $key => $value) {
40
+				if (property_exists($addressbooklocation, $key)) {
41
+					$addressbooklocation->{$key} = $value;
42
+				}
43 43
 			}
44 44
 			
45 45
 			return $addressbooklocation;
46 46
 		}
47 47
 		
48 48
 		public static function getAddressBookLocation($addressId)
49
-	    {
50
-	    	$ablocations = Route4Me::makeRequst(array(
51
-	            'url'    => self::$apiUrl,
52
-	            'method' => 'GET',
53
-	            'query'  => array(
54
-	                'query' => $addressId,
55
-	                'limit' => 30
56
-	            )
57
-	        ));
49
+		{
50
+			$ablocations = Route4Me::makeRequst(array(
51
+				'url'    => self::$apiUrl,
52
+				'method' => 'GET',
53
+				'query'  => array(
54
+					'query' => $addressId,
55
+					'limit' => 30
56
+				)
57
+			));
58 58
 
59 59
 			return $ablocations;
60 60
 		}
61 61
 		
62 62
 		public static function searchRoutedLocation($params)
63
-	    {
64
-	    	$result= Route4Me::makeRequst(array(
65
-	            'url'    => self::$apiUrl,
66
-	            'method' => 'GET',
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,
72
-	                'offset' => isset($params['offset']) ? $params['offset'] : null,
73
-	            )
74
-	        ));
63
+		{
64
+			$result= Route4Me::makeRequst(array(
65
+				'url'    => self::$apiUrl,
66
+				'method' => 'GET',
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,
72
+					'offset' => isset($params['offset']) ? $params['offset'] : null,
73
+				)
74
+			));
75 75
 
76 76
 			return $result;
77 77
 		}
78 78
 		
79 79
 		public static function getAddressBookLocations($params)
80
-	    {
81
-	    	$ablocations = Route4Me::makeRequst(array(
82
-	            'url'    => self::$apiUrl,
83
-	            'method' => 'GET',
84
-	            'query'  => array(
85
-	                'limit' => isset($params->limit) ? $params->limit: null,
86
-	                'offset' => isset($params->offset) ? $params->offset : null,
87
-	            )
88
-	        ));
80
+		{
81
+			$ablocations = Route4Me::makeRequst(array(
82
+				'url'    => self::$apiUrl,
83
+				'method' => 'GET',
84
+				'query'  => array(
85
+					'limit' => isset($params->limit) ? $params->limit: null,
86
+					'offset' => isset($params->offset) ? $params->offset : null,
87
+				)
88
+			));
89 89
 
90 90
 			return $ablocations;
91 91
 		}
92 92
 		
93 93
 		public static function getAddressBookLocationsByIds($ids)
94
-	    {
95
-	    	$ablocations = Route4Me::makeRequst(array(
96
-	            'url'    => self::$apiUrl,
97
-	            'method' => 'GET',
98
-	            'query'  => array(
99
-	                'address_id' => $ids
100
-	            )
101
-	        ));
94
+		{
95
+			$ablocations = Route4Me::makeRequst(array(
96
+				'url'    => self::$apiUrl,
97
+				'method' => 'GET',
98
+				'query'  => array(
99
+					'address_id' => $ids
100
+				)
101
+			));
102 102
 
103 103
 			return $ablocations;
104 104
 		}
105 105
 		
106 106
 		public static function addAdressBookLocation($params)
107
-	    {
108
-	    	$ablocations = Route4Me::makeRequst(array(
109
-	            'url'    => self::$apiUrl,
110
-	            'method' => 'POST',
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,
115
-	                'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
116
-	                'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
117
-	                'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null,
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,
147
-	            )
148
-	        ));
107
+		{
108
+			$ablocations = Route4Me::makeRequst(array(
109
+				'url'    => self::$apiUrl,
110
+				'method' => 'POST',
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,
115
+					'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
116
+					'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
117
+					'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null,
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,
147
+				)
148
+			));
149 149
 
150 150
 			return $ablocations;
151 151
 		}
152 152
 		
153 153
 		public function deleteAdressBookLocation($address_ids)
154
-	    {
155
-	        $address = Route4Me::makeRequst(array(
156
-	            'url'    => self::$apiUrl,
157
-	            'method' => 'DELETEARRAY',
158
-	            'query'  => array(
159
-	                'address_ids'     => $address_ids
160
-	            )
161
-	        ));
154
+		{
155
+			$address = Route4Me::makeRequst(array(
156
+				'url'    => self::$apiUrl,
157
+				'method' => 'DELETEARRAY',
158
+				'query'  => array(
159
+					'address_ids'     => $address_ids
160
+				)
161
+			));
162 162
 	
163
-	        return $address;
164
-	    }
163
+			return $address;
164
+		}
165 165
 		
166 166
 		public function updateAdressBookLocation($params)
167
-	    {
168
-	    	//echo "address_id --> ".$params["address_id"]."<br";
169
-	        $address = Route4Me::makeRequst(array(
170
-	            'url'    => self::$apiUrl,
171
-	            'method' => 'PUT',
172
-	            'query'   => $params,
167
+		{
168
+			//echo "address_id --> ".$params["address_id"]."<br";
169
+			$address = Route4Me::makeRequst(array(
170
+				'url'    => self::$apiUrl,
171
+				'method' => 'PUT',
172
+				'query'   => $params,
173 173
 
174
-	        ));
174
+			));
175 175
 	
176
-	        return $address;
177
-	    }
176
+			return $address;
177
+		}
178 178
 			
179 179
 		public static function get($params)
180
-	    {
181
-	    	$ablocations = Route4Me::makeRequst(array(
182
-	            'url'    => self::$apiUrl,
183
-	            'method' => 'ADD',
184
-	            'query'  => array(
185
-	                'first_name' => isset($params->first_name) ? $params->first_name : null,
186
-	                'address_1' => isset($params->address_1) ? $params->address_1: null,
187
-	                'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
188
-	                'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
189
-	            )
190
-	        ));
180
+		{
181
+			$ablocations = Route4Me::makeRequst(array(
182
+				'url'    => self::$apiUrl,
183
+				'method' => 'ADD',
184
+				'query'  => array(
185
+					'first_name' => isset($params->first_name) ? $params->first_name : null,
186
+					'address_1' => isset($params->address_1) ? $params->address_1: null,
187
+					'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
188
+					'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
189
+				)
190
+			));
191 191
 
192 192
 			return $ablocations;
193 193
 		}
194 194
         
195
-        public static function validateScheduleMode($scheduleMode)
196
-        {
197
-            $schedMmodes=array("daily","weekly","monthly","annually");
195
+		public static function validateScheduleMode($scheduleMode)
196
+		{
197
+			$schedMmodes=array("daily","weekly","monthly","annually");
198 198
             
199
-            if (in_array($scheduleMode, $schedMmodes)) return TRUE; else return FALSE;
200
-        }
199
+			if (in_array($scheduleMode, $schedMmodes)) return TRUE; else return FALSE;
200
+		}
201 201
         
202
-        public static function validateScheduleEnable($scheduleEnabled)
203
-        {
204
-            $schedEnambles=array(TRUE,FALSE);
202
+		public static function validateScheduleEnable($scheduleEnabled)
203
+		{
204
+			$schedEnambles=array(TRUE,FALSE);
205 205
             
206
-            if (in_array($scheduleEnabled, $schedEnambles)) return TRUE; else return FALSE;
207
-        }
206
+			if (in_array($scheduleEnabled, $schedEnambles)) return TRUE; else return FALSE;
207
+		}
208 208
         
209
-        public static function validateScheduleEvery($scheduleEvery)
210
-        {
211
-            if (is_numeric($scheduleEvery)) return TRUE; else return FALSE;
212
-        }
209
+		public static function validateScheduleEvery($scheduleEvery)
210
+		{
211
+			if (is_numeric($scheduleEvery)) return TRUE; else return FALSE;
212
+		}
213 213
         
214
-        public static function validateScheduleWeekDays($scheduleWeekDays)
215
-        {
216
-            $weekdays = explode(',', $scheduleWeekDays);
214
+		public static function validateScheduleWeekDays($scheduleWeekDays)
215
+		{
216
+			$weekdays = explode(',', $scheduleWeekDays);
217 217
             
218
-            if (sizeof($weekdays)<1) return FALSE;
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++) { 
223
-                if (is_numeric($weekdays[$i])) {
224
-                    $wday=intval($weekdays[$i]);
225
-                    if ($wday<1 || $wday>7) $isValid=FALSE;
226
-                }
227
-                else $isValid=FALSE;
228
-            }
229
-            //echo $scheduleWeekDays.' --- '. $isValid."<br>";
230
-            return $isValid;
231
-        }
222
+			for ($i=0; $i < sizeof($weekdays); $i++) { 
223
+				if (is_numeric($weekdays[$i])) {
224
+					$wday=intval($weekdays[$i]);
225
+					if ($wday<1 || $wday>7) $isValid=FALSE;
226
+				}
227
+				else $isValid=FALSE;
228
+			}
229
+			//echo $scheduleWeekDays.' --- '. $isValid."<br>";
230
+			return $isValid;
231
+		}
232 232
         
233
-        public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
234
-        {
235
-            $schedMonthlyMmodes=array("dates","nth");
233
+		public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
234
+		{
235
+			$schedMonthlyMmodes=array("dates","nth");
236 236
             
237
-            if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) return TRUE; else return FALSE;
238
-        }
237
+			if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) return TRUE; else return FALSE;
238
+		}
239 239
         
240
-        public static function validateScheduleMonthlyDates($scheduleMonthlyDates)
241
-        {
242
-            $monthlyDates = explode(',', $scheduleMonthlyDates);
240
+		public static function validateScheduleMonthlyDates($scheduleMonthlyDates)
241
+		{
242
+			$monthlyDates = explode(',', $scheduleMonthlyDates);
243 243
             
244
-            if (sizeof($monthlyDates)<1) return FALSE;
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++) { 
249
-                if (is_numeric($monthlyDates[$i])) {
250
-                    $mday=intval($monthlyDates[$i]);
251
-                    if ($mday<1 || $mday>31) $isValid=FALSE;
252
-                }
253
-                else $isValid=FALSE;
254
-            }
248
+			for ($i=0; $i < sizeof($monthlyDates); $i++) { 
249
+				if (is_numeric($monthlyDates[$i])) {
250
+					$mday=intval($monthlyDates[$i]);
251
+					if ($mday<1 || $mday>31) $isValid=FALSE;
252
+				}
253
+				else $isValid=FALSE;
254
+			}
255 255
 
256
-            return $isValid;
257
-        }
256
+			return $isValid;
257
+		}
258 258
         
259
-        public static function validateScheduleNthN($scheduleNthN)
260
-        {
261
-            if (!is_numeric($scheduleNthN)) return FALSE;
259
+		public static function validateScheduleNthN($scheduleNthN)
260
+		{
261
+			if (!is_numeric($scheduleNthN)) return FALSE;
262 262
             
263
-            $schedNthNs=array(1,2,3,4,5,-1);
264
-            if (in_array($scheduleNthN, $schedNthNs)) return TRUE; else return FALSE;
265
-        }
263
+			$schedNthNs=array(1,2,3,4,5,-1);
264
+			if (in_array($scheduleNthN, $schedNthNs)) return TRUE; else return FALSE;
265
+		}
266 266
         
267
-        public static function validateScheduleNthWhat($scheduleNthWhat)
268
-        {
269
-            if (!is_numeric($scheduleNthWhat)) return FALSE;
267
+		public static function validateScheduleNthWhat($scheduleNthWhat)
268
+		{
269
+			if (!is_numeric($scheduleNthWhat)) return FALSE;
270 270
             
271
-            $schedNthWhats=array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
272
-            if (in_array($scheduleNthWhat, $schedNthWhats)) return TRUE; else return FALSE;
273
-        }
271
+			$schedNthWhats=array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
272
+			if (in_array($scheduleNthWhat, $schedNthWhats)) return TRUE; else return FALSE;
273
+		}
274 274
         
275
-        /* Function adds the locations (with/without schedule) from the CSV file. 
275
+		/* Function adds the locations (with/without schedule) from the CSV file. 
276 276
          * $csvFileHandle - a file handler.
277 277
          * Returns array $results which contains two arrays: fail and succes.
278 278
          */
279
-        public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping)
280
-        {
281
-            $max_line_length = 512;
282
-            $delemietr=',';
279
+		public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping)
280
+		{
281
+			$max_line_length = 512;
282
+			$delemietr=',';
283 283
             
284
-            $results['fail']=array();
285
-            $results['success']=array();
284
+			$results['fail']=array();
285
+			$results['success']=array();
286 286
             
287
-            $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
288
-            if (!$columns) {
289
-                array_push($results['fail'],'Empty CSV table');
290
-                return ($results);
291
-            }
287
+			$columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
288
+			if (!$columns) {
289
+				array_push($results['fail'],'Empty CSV table');
290
+				return ($results);
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
-                    if (isset($rows[$locationsFieldsMapping['schedule_mode']])) {
301
-                        if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) {
302
-                            $schedule='"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; 
303
-                            $mode=$rows[$locationsFieldsMapping['schedule_mode']];
304
-                        }
305
-                        else {array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); $schedule="";}
306
-                    }
307
-                    else {array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); $schedule="";}
300
+					if (isset($rows[$locationsFieldsMapping['schedule_mode']])) {
301
+						if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) {
302
+							$schedule='"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; 
303
+							$mode=$rows[$locationsFieldsMapping['schedule_mode']];
304
+						}
305
+						else {array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); $schedule="";}
306
+					}
307
+					else {array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); $schedule="";}
308 308
                     
309
-                    if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) {
310
-                        if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { 
311
-                            $schedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
312
-                        }
313
-                        else {array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set ");  $schedule="";}
314
-                    }
309
+					if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) {
310
+						if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { 
311
+							$schedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
312
+						}
313
+						else {array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set ");  $schedule="";}
314
+					}
315 315
                     
316
-                    if (isset($rows[$locationsFieldsMapping['schedule_every']])) {
317
-                        if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) {
318
-                            $schedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
319
-                            if ($mode=='daily') {
320
-                                $schedule=trim($schedule,',');
321
-                                $schedule.='}';
322
-                            }
323
-                        }
324
-                        else {array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); $schedule=""; }
325
-                    }
316
+					if (isset($rows[$locationsFieldsMapping['schedule_every']])) {
317
+						if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) {
318
+							$schedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
319
+							if ($mode=='daily') {
320
+								$schedule=trim($schedule,',');
321
+								$schedule.='}';
322
+							}
323
+						}
324
+						else {array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); $schedule=""; }
325
+					}
326 326
                     
327
-                    if ($mode!='daily') {
328
-                        switch ($mode) {
329
-                            case 'weekly':
330
-                                if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
331
-                                    if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
332
-                                         $schedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
333
-                                    }
334
-                                    else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $schedule="";}
335
-                                }
336
-                                else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $schedule="";}
337
-                                break;
338
-                            case 'monthly':
339
-                                $monthlyMode="";
340
-                                if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
341
-                                    if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
342
-                                         $monthlyMode=$rows[$locationsFieldsMapping['monthly_mode']];
343
-                                         $schedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
344
-                                    }
345
-                                    else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $schedule="";}
346
-                                }
347
-                                else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $schedule="";}
327
+					if ($mode!='daily') {
328
+						switch ($mode) {
329
+							case 'weekly':
330
+								if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
331
+									if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
332
+										 $schedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
333
+									}
334
+									else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $schedule="";}
335
+								}
336
+								else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $schedule="";}
337
+								break;
338
+							case 'monthly':
339
+								$monthlyMode="";
340
+								if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
341
+									if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
342
+										 $monthlyMode=$rows[$locationsFieldsMapping['monthly_mode']];
343
+										 $schedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
344
+									}
345
+									else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $schedule="";}
346
+								}
347
+								else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $schedule="";}
348 348
                                 
349
-                                if ($monthlyMode!="") {
350
-                                    switch ($monthlyMode) {
351
-                                        case 'dates':
352
-                                            if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
353
-                                                if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
354
-                                                     $schedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
355
-                                                }
356
-                                                else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $schedule="";}
357
-                                            }
358
-                                            break;
359
-                                        case 'nth':
360
-                                            if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
361
-                                                if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
362
-                                                     $schedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
363
-                                                }
364
-                                                else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $schedule="";}
365
-                                            }
366
-                                            else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $schedule="";}
349
+								if ($monthlyMode!="") {
350
+									switch ($monthlyMode) {
351
+										case 'dates':
352
+											if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
353
+												if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
354
+													 $schedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
355
+												}
356
+												else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $schedule="";}
357
+											}
358
+											break;
359
+										case 'nth':
360
+											if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
361
+												if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
362
+													 $schedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
363
+												}
364
+												else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $schedule="";}
365
+											}
366
+											else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $schedule="";}
367 367
                                             
368
-                                            if ($schedule!="") {
369
-                                                if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
370
-                                                    if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
371
-                                                         $schedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
372
-                                                    }
373
-                                                    else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $schedule="";}
374
-                                                }
375
-                                                else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $schedule="";}
376
-                                            }
368
+											if ($schedule!="") {
369
+												if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
370
+													if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
371
+														 $schedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
372
+													}
373
+													else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $schedule="";}
374
+												}
375
+												else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $schedule="";}
376
+											}
377 377
                                             
378
-                                            break;
379
-                                    }
380
-                                }
381
-                                break;
382
-                            default:
383
-                                $schedule=="";
384
-                                break;
385
-                        }
378
+											break;
379
+									}
380
+								}
381
+								break;
382
+							default:
383
+								$schedule=="";
384
+								break;
385
+						}
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(
398
-                        "cached_lat"    => $rows[$locationsFieldsMapping['cached_lat']],
399
-                        "cached_lng"    => $rows[$locationsFieldsMapping['cached_lng']],
400
-                        "curbside_lat"     => isset($locationsFieldsMapping['curbside_lat']) ? $rows[$locationsFieldsMapping['curbside_lat']] : null,
401
-                        "curbside_lng"     => isset($locationsFieldsMapping['curbside_lng']) ? $rows[$locationsFieldsMapping['curbside_lng']] : null,
402
-                        "address_alias"     => isset($locationsFieldsMapping['address_alias']) ? $rows[$locationsFieldsMapping['address_alias']] : null,
403
-                        "address_1"     => $rows[$locationsFieldsMapping['address_1']],
404
-                        "address_2"     => isset($locationsFieldsMapping['address_2']) ? $rows[$locationsFieldsMapping['address_2']] : null,
405
-                        "address_city"     => isset($locationsFieldsMapping['address_city']) ? $rows[$locationsFieldsMapping['address_city']] : null,
406
-                        "address_state_id"     => isset($locationsFieldsMapping['address_state_id']) ? $rows[$locationsFieldsMapping['address_state_id']] : null,
407
-                        "address_zip"     => isset($locationsFieldsMapping['address_zip']) ? $rows[$locationsFieldsMapping['address_zip']] : null,
408
-                        "address_phone_number"  => isset($locationsFieldsMapping['address_phone_number']) ? $rows[$locationsFieldsMapping['address_phone_number']] : null,
409
-                        "schedule" => isset($oSchedule) ? $oSchedule : null,
410
-                        "address_group"  => isset($locationsFieldsMapping['address_group']) ? $rows[$locationsFieldsMapping['address_group']] : null,
411
-                        "first_name"  => isset($locationsFieldsMapping['first_name']) ? $rows[$locationsFieldsMapping['first_name']] : null,
412
-                        "last_name"  => isset($locationsFieldsMapping['last_name']) ? $rows[$locationsFieldsMapping['last_name']] : null,
413
-                        "local_time_window_start"  => isset($locationsFieldsMapping['local_time_window_start']) ? $rows[$locationsFieldsMapping['local_time_window_start']] : null,
414
-                        "local_time_window_end"  => isset($locationsFieldsMapping['local_time_window_end']) ? $rows[$locationsFieldsMapping['local_time_window_end']] : null,
415
-                        "local_time_window_start_2"  => isset($locationsFieldsMapping['local_time_window_start_2']) ? $rows[$locationsFieldsMapping['local_time_window_start_2']] : null,
416
-                        "local_time_window_end_2"  => isset($locationsFieldsMapping['local_time_window_end_2']) ? $rows[$locationsFieldsMapping['local_time_window_end_2']] : null,
417
-                        "address_email"  => isset($locationsFieldsMapping['address_email']) ? $rows[$locationsFieldsMapping['address_email']] : null,
418
-                        "address_country_id"  => isset($locationsFieldsMapping['address_country_id']) ? $rows[$locationsFieldsMapping['address_country_id']] : null,
419
-                        "address_custom_data"  => isset($locationsFieldsMapping['address_custom_data']) ? $rows[$locationsFieldsMapping['address_custom_data']] : null,
420
-                        "schedule_blacklist"  => isset($locationsFieldsMapping['schedule_blacklist']) ? $rows[$locationsFieldsMapping['schedule_blacklist']] : null,
421
-                        "service_time"  => isset($locationsFieldsMapping['service_time']) ? $rows[$locationsFieldsMapping['service_time']] : null,
422
-                        "local_timezone_string"  => isset($locationsFieldsMapping['local_timezone_string']) ? $rows[$locationsFieldsMapping['local_timezone_string']] : null,
423
-                        "color"  => isset($locationsFieldsMapping['color']) ? $rows[$locationsFieldsMapping['color']] : null,
424
-                        "address_icon"  => isset($locationsFieldsMapping['address_icon']) ? $rows[$locationsFieldsMapping['address_icon']] : null,
425
-                        "address_stop_type"  => isset($locationsFieldsMapping['address_stop_type']) ? $rows[$locationsFieldsMapping['address_stop_type']] : null,
426
-                        "address_cube"  => isset($locationsFieldsMapping['address_cube']) ? $rows[$locationsFieldsMapping['address_cube']] : null,
427
-                        "address_pieces"  => isset($locationsFieldsMapping['address_pieces']) ? $rows[$locationsFieldsMapping['address_pieces']] : null,
428
-                        "address_reference_no"  => isset($locationsFieldsMapping['address_reference_no']) ? $rows[$locationsFieldsMapping['address_reference_no']] : null,
429
-                        "address_revenue"  => isset($locationsFieldsMapping['address_revenue']) ? $rows[$locationsFieldsMapping['address_revenue']] : null,
430
-                        "address_weight"  => isset($locationsFieldsMapping['address_weight']) ? $rows[$locationsFieldsMapping['address_weight']] : null,
431
-                        "address_priority"  => isset($locationsFieldsMapping['address_priority']) ? $rows[$locationsFieldsMapping['address_priority']] : null,
432
-                        "address_customer_po"  => isset($locationsFieldsMapping['address_customer_po']) ? $rows[$locationsFieldsMapping['address_customer_po']] : null,
433
-                    ));
397
+					$AdressBookLocationParameters=AddressBookLocation::fromArray(array(
398
+						"cached_lat"    => $rows[$locationsFieldsMapping['cached_lat']],
399
+						"cached_lng"    => $rows[$locationsFieldsMapping['cached_lng']],
400
+						"curbside_lat"     => isset($locationsFieldsMapping['curbside_lat']) ? $rows[$locationsFieldsMapping['curbside_lat']] : null,
401
+						"curbside_lng"     => isset($locationsFieldsMapping['curbside_lng']) ? $rows[$locationsFieldsMapping['curbside_lng']] : null,
402
+						"address_alias"     => isset($locationsFieldsMapping['address_alias']) ? $rows[$locationsFieldsMapping['address_alias']] : null,
403
+						"address_1"     => $rows[$locationsFieldsMapping['address_1']],
404
+						"address_2"     => isset($locationsFieldsMapping['address_2']) ? $rows[$locationsFieldsMapping['address_2']] : null,
405
+						"address_city"     => isset($locationsFieldsMapping['address_city']) ? $rows[$locationsFieldsMapping['address_city']] : null,
406
+						"address_state_id"     => isset($locationsFieldsMapping['address_state_id']) ? $rows[$locationsFieldsMapping['address_state_id']] : null,
407
+						"address_zip"     => isset($locationsFieldsMapping['address_zip']) ? $rows[$locationsFieldsMapping['address_zip']] : null,
408
+						"address_phone_number"  => isset($locationsFieldsMapping['address_phone_number']) ? $rows[$locationsFieldsMapping['address_phone_number']] : null,
409
+						"schedule" => isset($oSchedule) ? $oSchedule : null,
410
+						"address_group"  => isset($locationsFieldsMapping['address_group']) ? $rows[$locationsFieldsMapping['address_group']] : null,
411
+						"first_name"  => isset($locationsFieldsMapping['first_name']) ? $rows[$locationsFieldsMapping['first_name']] : null,
412
+						"last_name"  => isset($locationsFieldsMapping['last_name']) ? $rows[$locationsFieldsMapping['last_name']] : null,
413
+						"local_time_window_start"  => isset($locationsFieldsMapping['local_time_window_start']) ? $rows[$locationsFieldsMapping['local_time_window_start']] : null,
414
+						"local_time_window_end"  => isset($locationsFieldsMapping['local_time_window_end']) ? $rows[$locationsFieldsMapping['local_time_window_end']] : null,
415
+						"local_time_window_start_2"  => isset($locationsFieldsMapping['local_time_window_start_2']) ? $rows[$locationsFieldsMapping['local_time_window_start_2']] : null,
416
+						"local_time_window_end_2"  => isset($locationsFieldsMapping['local_time_window_end_2']) ? $rows[$locationsFieldsMapping['local_time_window_end_2']] : null,
417
+						"address_email"  => isset($locationsFieldsMapping['address_email']) ? $rows[$locationsFieldsMapping['address_email']] : null,
418
+						"address_country_id"  => isset($locationsFieldsMapping['address_country_id']) ? $rows[$locationsFieldsMapping['address_country_id']] : null,
419
+						"address_custom_data"  => isset($locationsFieldsMapping['address_custom_data']) ? $rows[$locationsFieldsMapping['address_custom_data']] : null,
420
+						"schedule_blacklist"  => isset($locationsFieldsMapping['schedule_blacklist']) ? $rows[$locationsFieldsMapping['schedule_blacklist']] : null,
421
+						"service_time"  => isset($locationsFieldsMapping['service_time']) ? $rows[$locationsFieldsMapping['service_time']] : null,
422
+						"local_timezone_string"  => isset($locationsFieldsMapping['local_timezone_string']) ? $rows[$locationsFieldsMapping['local_timezone_string']] : null,
423
+						"color"  => isset($locationsFieldsMapping['color']) ? $rows[$locationsFieldsMapping['color']] : null,
424
+						"address_icon"  => isset($locationsFieldsMapping['address_icon']) ? $rows[$locationsFieldsMapping['address_icon']] : null,
425
+						"address_stop_type"  => isset($locationsFieldsMapping['address_stop_type']) ? $rows[$locationsFieldsMapping['address_stop_type']] : null,
426
+						"address_cube"  => isset($locationsFieldsMapping['address_cube']) ? $rows[$locationsFieldsMapping['address_cube']] : null,
427
+						"address_pieces"  => isset($locationsFieldsMapping['address_pieces']) ? $rows[$locationsFieldsMapping['address_pieces']] : null,
428
+						"address_reference_no"  => isset($locationsFieldsMapping['address_reference_no']) ? $rows[$locationsFieldsMapping['address_reference_no']] : null,
429
+						"address_revenue"  => isset($locationsFieldsMapping['address_revenue']) ? $rows[$locationsFieldsMapping['address_revenue']] : null,
430
+						"address_weight"  => isset($locationsFieldsMapping['address_weight']) ? $rows[$locationsFieldsMapping['address_weight']] : null,
431
+						"address_priority"  => isset($locationsFieldsMapping['address_priority']) ? $rows[$locationsFieldsMapping['address_priority']] : null,
432
+						"address_customer_po"  => isset($locationsFieldsMapping['address_customer_po']) ? $rows[$locationsFieldsMapping['address_customer_po']] : null,
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
                 
443
-            }
443
+			}
444 444
 
445
-            return $results;
446
-        }
445
+			return $results;
446
+		}
447 447
 	
448 448
 	   
449 449
 	}
Please login to merge, or discard this patch.
examples/Optimizations/hybridOptimization.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -43,21 +43,21 @@  discard block
 block discarded – undo
43 43
 $locationsFieldsMapping['monthly_nth_wwhat']=17;
44 44
 
45 45
 if (($handle = fopen("$source_file", "r")) !== FALSE) {
46
-        $oAbook = new AddressBookLocation();
46
+		$oAbook = new AddressBookLocation();
47 47
 
48
-        $results=$oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping); //Temporarry
48
+		$results=$oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping); //Temporarry
49 49
         
50
-        echo "Errors: <br><br>";
51
-        foreach ($results['fail'] as $evalue) {
52
-            echo $evalue."<br>";
53
-        }
50
+		echo "Errors: <br><br>";
51
+		foreach ($results['fail'] as $evalue) {
52
+			echo $evalue."<br>";
53
+		}
54 54
         
55
-        echo "Successes: <br><br>";
56
-        foreach ($results['success'] as $svalue) {
57
-            echo $svalue."<br>";
58
-        }
55
+		echo "Successes: <br><br>";
56
+		foreach ($results['success'] as $svalue) {
57
+			echo $svalue."<br>";
58
+		}
59 59
 
60
-    }
60
+	}
61 61
 
62 62
 /* Add orders with schedules from a CSV file  */
63 63
 
@@ -76,91 +76,91 @@  discard block
 block discarded – undo
76 76
 $ordersFieldsMapping['day_scheduled_for_YYMMDD']=8;
77 77
 
78 78
 if (($handle = fopen("$orders_file", "r")) !== FALSE) {
79
-        $order = new Order();
80
-        $results=$order->addOrdersFromCsvFile($handle, $ordersFieldsMapping);
79
+		$order = new Order();
80
+		$results=$order->addOrdersFromCsvFile($handle, $ordersFieldsMapping);
81 81
         
82
-        echo "Errors: <br><br>";
83
-        foreach ($results['fail'] as $evalue) {
84
-            echo $evalue."<br>";
85
-        }
82
+		echo "Errors: <br><br>";
83
+		foreach ($results['fail'] as $evalue) {
84
+			echo $evalue."<br>";
85
+		}
86 86
         
87
-        echo "Successes: <br><br>";
88
-        foreach ($results['success'] as $svalue) {
89
-            echo $svalue."<br>";
90
-        }
87
+		echo "Successes: <br><br>";
88
+		foreach ($results['success'] as $svalue) {
89
+			echo $svalue."<br>";
90
+		}
91 91
   
92
-    }
92
+	}
93 93
 
94 94
 /* Get Hybrid Optimization */
95 95
 
96
-    $ep = time()+604800;
97
-    $sched_date = date("Y-m-d", $ep);
96
+	$ep = time()+604800;
97
+	$sched_date = date("Y-m-d", $ep);
98 98
 
99
-    $hybridParams = array(
100
-        "target_date_string" => $sched_date,
101
-        "timezone_offset_minutes" => 480
102
-    );
99
+	$hybridParams = array(
100
+		"target_date_string" => $sched_date,
101
+		"timezone_offset_minutes" => 480
102
+	);
103 103
     
104
-    $optimization = new OptimizationProblem(); 
105
-    $hybridOptimization = $optimization->getHybridOptimization($hybridParams);
104
+	$optimization = new OptimizationProblem(); 
105
+	$hybridOptimization = $optimization->getHybridOptimization($hybridParams);
106 106
     
107
-    if ($hybridOptimization!=null) {
107
+	if ($hybridOptimization!=null) {
108 108
         
109
-        if (isset($hybridOptimization['optimization_problem_id'])) {
110
-            $optid = $hybridOptimization['optimization_problem_id'];
109
+		if (isset($hybridOptimization['optimization_problem_id'])) {
110
+			$optid = $hybridOptimization['optimization_problem_id'];
111 111
             
112
-            echo "Hibrid optimization with optimization_problem_id=$optid <br><br>";
112
+			echo "Hibrid optimization with optimization_problem_id=$optid <br><br>";
113 113
             
114
-            /* Add depots to the Hybrid Optimization */
115
-            $depotfile = "depots.csv";
114
+			/* Add depots to the Hybrid Optimization */
115
+			$depotfile = "depots.csv";
116 116
             
117
-            if (($handle = fopen("$depotfile", "r")) !== FALSE) {
117
+			if (($handle = fopen("$depotfile", "r")) !== FALSE) {
118 118
                 
119
-                $columns = fgetcsv($handle, $max_line_length, $delemietr);
119
+				$columns = fgetcsv($handle, $max_line_length, $delemietr);
120 120
                 
121
-                if (!$columns) {
122
-                    $error['message'] = 'Empty';
123
-                     return ($error);
124
-                }
121
+				if (!$columns) {
122
+					$error['message'] = 'Empty';
123
+					 return ($error);
124
+				}
125 125
                 
126
-                $depotsParams = array(
127
-                    'optimization_problem_id' => $optid,
128
-                    'delete_old_depots'  => true,
129
-                );
126
+				$depotsParams = array(
127
+					'optimization_problem_id' => $optid,
128
+					'delete_old_depots'  => true,
129
+				);
130 130
                 
131
-                $iRow=1;
132
-                $depotAddresses = array();
131
+				$iRow=1;
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);
140
-                    }
141
-                }
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
+					}
141
+				}
142 142
                 
143
-                $depotsParams['new_depots'] = $depotAddresses;
143
+				$depotsParams['new_depots'] = $depotAddresses;
144 144
                 
145
-                $optProblem = new OptimizationProblem();
145
+				$optProblem = new OptimizationProblem();
146 146
                 
147
-                $resultDepots = $optProblem->addDepotsToHybrid($depotsParams);
147
+				$resultDepots = $optProblem->addDepotsToHybrid($depotsParams);
148 148
                 
149
-                var_dump($resultDepots);
149
+				var_dump($resultDepots);
150 150
                 
151
-                /* Reoptimize hybrid optimization */
151
+				/* Reoptimize hybrid optimization */
152 152
                 
153
-                if ($resultDepots!=null) {
154
-                    $problemParams = array(
155
-                        'optimization_problem_id'  =>  $optid
156
-                    );
157
-                    $problem = OptimizationProblem::reoptimize($problemParams);
153
+				if ($resultDepots!=null) {
154
+					$problemParams = array(
155
+						'optimization_problem_id'  =>  $optid
156
+					);
157
+					$problem = OptimizationProblem::reoptimize($problemParams);
158 158
                     
159
-                    Route4Me::simplePrint($problem);
160
-                }
161
-            }
159
+					Route4Me::simplePrint($problem);
160
+				}
161
+			}
162 162
                 
163
-        }
163
+		}
164 164
 
165
-    }
165
+	}
166 166
 ?>
167 167
\ No newline at end of file
Please login to merge, or discard this patch.