@@ -1,42 +1,42 @@ |
||
1 | 1 | <?php |
2 | - namespace Route4Me; |
|
3 | - |
|
4 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
5 | - |
|
6 | - require $vdir.'/../vendor/autoload.php'; |
|
7 | - |
|
8 | - use Route4Me\Route4Me; |
|
9 | - use Route4Me\Order; |
|
10 | - |
|
11 | - // Set the api key in the Route4me class |
|
12 | - Route4Me::setApiKey('11111111111111111111111111111111'); |
|
13 | - |
|
14 | - $orderParameters=Order::fromArray(array( |
|
15 | - "address_1" => "318 S 39th St, Louisville, KY 40212, USA", |
|
16 | - "cached_lat" => 38.259326, |
|
17 | - "cached_lng" => -85.814979, |
|
18 | - "curbside_lat" => 38.259326, |
|
19 | - "curbside_lng" => -85.814979, |
|
20 | - "address_alias" => "318 S 39th St 40212", |
|
21 | - "address_city" => "Louisville", |
|
22 | - "EXT_FIELD_first_name" => "Lui", |
|
23 | - "EXT_FIELD_last_name" => "Carol", |
|
24 | - "EXT_FIELD_email" => "[email protected]", |
|
25 | - "EXT_FIELD_phone" => "897946541", |
|
26 | - "EXT_FIELD_custom_data" => array("order_type" => "scheduled order"), |
|
27 | - "day_scheduled_for_YYMMDD" => "2017-12-20", |
|
28 | - "local_time_window_end" => 39000, |
|
29 | - "local_time_window_end_2" => 46200, |
|
30 | - "local_time_window_start" => 37800, |
|
31 | - "local_time_window_start_2" => 45000, |
|
32 | - "local_timezone_string" => "America/New_York", |
|
33 | - "order_icon" => "emoji/emoji-bank" |
|
34 | - )); |
|
35 | - |
|
36 | - $order = new Order(); |
|
37 | - |
|
38 | - $response = $order->addOrder($orderParameters); |
|
39 | - |
|
40 | - Route4Me::simplePrint($response); |
|
2 | + namespace Route4Me; |
|
3 | + |
|
4 | + $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
5 | + |
|
6 | + require $vdir.'/../vendor/autoload.php'; |
|
7 | + |
|
8 | + use Route4Me\Route4Me; |
|
9 | + use Route4Me\Order; |
|
10 | + |
|
11 | + // Set the api key in the Route4me class |
|
12 | + Route4Me::setApiKey('11111111111111111111111111111111'); |
|
13 | + |
|
14 | + $orderParameters=Order::fromArray(array( |
|
15 | + "address_1" => "318 S 39th St, Louisville, KY 40212, USA", |
|
16 | + "cached_lat" => 38.259326, |
|
17 | + "cached_lng" => -85.814979, |
|
18 | + "curbside_lat" => 38.259326, |
|
19 | + "curbside_lng" => -85.814979, |
|
20 | + "address_alias" => "318 S 39th St 40212", |
|
21 | + "address_city" => "Louisville", |
|
22 | + "EXT_FIELD_first_name" => "Lui", |
|
23 | + "EXT_FIELD_last_name" => "Carol", |
|
24 | + "EXT_FIELD_email" => "[email protected]", |
|
25 | + "EXT_FIELD_phone" => "897946541", |
|
26 | + "EXT_FIELD_custom_data" => array("order_type" => "scheduled order"), |
|
27 | + "day_scheduled_for_YYMMDD" => "2017-12-20", |
|
28 | + "local_time_window_end" => 39000, |
|
29 | + "local_time_window_end_2" => 46200, |
|
30 | + "local_time_window_start" => 37800, |
|
31 | + "local_time_window_start_2" => 45000, |
|
32 | + "local_timezone_string" => "America/New_York", |
|
33 | + "order_icon" => "emoji/emoji-bank" |
|
34 | + )); |
|
35 | + |
|
36 | + $order = new Order(); |
|
37 | + |
|
38 | + $response = $order->addOrder($orderParameters); |
|
39 | + |
|
40 | + Route4Me::simplePrint($response); |
|
41 | 41 | |
42 | 42 |
@@ -1,198 +1,198 @@ |
||
1 | 1 | <?php |
2 | - namespace Route4Me; |
|
2 | + namespace Route4Me; |
|
3 | 3 | |
4 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
4 | + $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
5 | 5 | |
6 | - require $vdir.'/../vendor/autoload.php'; |
|
6 | + require $vdir.'/../vendor/autoload.php'; |
|
7 | 7 | |
8 | - use Route4Me\Route4Me; |
|
9 | - use Route4Me\Route; |
|
8 | + use Route4Me\Route4Me; |
|
9 | + use Route4Me\Route; |
|
10 | 10 | |
11 | - // Set the api key in the Route4me class |
|
12 | - Route4Me::setApiKey('11111111111111111111111111111111'); |
|
11 | + // Set the api key in the Route4me class |
|
12 | + Route4Me::setApiKey('11111111111111111111111111111111'); |
|
13 | 13 | |
14 | - #region // Add a location, scheduled daily with custom data. |
|
15 | - $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
16 | - "address_1" => "1604 PARKRIDGE PKWY, Louisville, KY, 40214", |
|
17 | - "address_alias" => "1604 PARKRIDGE PKWY 40214", |
|
18 | - "address_group" => "Scheduled daily", |
|
19 | - "first_name" => "Peter", |
|
20 | - "last_name" => "Newman", |
|
21 | - "address_email" => "[email protected]", |
|
22 | - "address_phone_number" => "65432178", |
|
23 | - "cached_lat" => 38.141598, |
|
24 | - "cached_lng" => -85.793846, |
|
25 | - "address_city" => "Louisville", |
|
26 | - "address_custom_data" => array("scheduled" => "yes", "serice type" => "publishing"), |
|
27 | - "schedule" => array(array( |
|
28 | - "enabled" => true, |
|
29 | - "mode" => "daily", |
|
30 | - "daily" => array("every" => 1) |
|
31 | - )), |
|
32 | - "service_time" => 900 |
|
33 | - )); |
|
14 | + #region // Add a location, scheduled daily with custom data. |
|
15 | + $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
16 | + "address_1" => "1604 PARKRIDGE PKWY, Louisville, KY, 40214", |
|
17 | + "address_alias" => "1604 PARKRIDGE PKWY 40214", |
|
18 | + "address_group" => "Scheduled daily", |
|
19 | + "first_name" => "Peter", |
|
20 | + "last_name" => "Newman", |
|
21 | + "address_email" => "[email protected]", |
|
22 | + "address_phone_number" => "65432178", |
|
23 | + "cached_lat" => 38.141598, |
|
24 | + "cached_lng" => -85.793846, |
|
25 | + "address_city" => "Louisville", |
|
26 | + "address_custom_data" => array("scheduled" => "yes", "serice type" => "publishing"), |
|
27 | + "schedule" => array(array( |
|
28 | + "enabled" => true, |
|
29 | + "mode" => "daily", |
|
30 | + "daily" => array("every" => 1) |
|
31 | + )), |
|
32 | + "service_time" => 900 |
|
33 | + )); |
|
34 | 34 | |
35 | - $abContacts1=new AddressBookLocation(); |
|
35 | + $abContacts1=new AddressBookLocation(); |
|
36 | 36 | |
37 | - $abcResults1=$abContacts1->addAdressBookLocation($AdressBookLocationParameters); |
|
37 | + $abcResults1=$abContacts1->addAdressBookLocation($AdressBookLocationParameters); |
|
38 | 38 | |
39 | - echo "address_id = ".strval($abcResults1["address_id"])."<br>"; |
|
39 | + echo "address_id = ".strval($abcResults1["address_id"])."<br>"; |
|
40 | 40 | |
41 | - Route4Me::simplePrint($abcResults1); |
|
42 | - #endregion |
|
43 | - |
|
44 | - #region // Add a location, scheduled weekly. |
|
45 | - $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
46 | - "address_1" => "1407 MCCOY, Louisville, KY, 40215", |
|
47 | - "address_alias" => "1407 MCCOY 40215", |
|
48 | - "address_group" => "Scheduled weekly", |
|
49 | - "first_name" => "Bart", |
|
50 | - "last_name" => "Douglas", |
|
51 | - "address_email" => "[email protected]", |
|
52 | - "address_phone_number" => "95487454", |
|
53 | - "cached_lat" => 38.202496, |
|
54 | - "cached_lng" => -85.786514, |
|
55 | - "curbside_lat" => 38.202496, |
|
56 | - "curbside_lng" => -85.786514, |
|
57 | - "address_city" => "Louisville", |
|
58 | - "schedule" => array(array( |
|
59 | - "enabled" => true, |
|
60 | - "mode" => "weekly", |
|
61 | - "weekly" => array( |
|
62 | - "every" => 1, |
|
63 | - "weekdays" => array(1,2,3,4,5) |
|
64 | - ) |
|
65 | - )), |
|
66 | - "service_time" => 600 |
|
67 | - )); |
|
68 | - |
|
69 | - $abContacts2=new AddressBookLocation(); |
|
70 | - |
|
71 | - $abcResults2=$abContacts2->addAdressBookLocation($AdressBookLocationParameters); |
|
72 | - |
|
73 | - echo "address_id = ".strval($abcResults2["address_id"])."<br>"; |
|
74 | - |
|
75 | - Route4Me::simplePrint($abcResults2); |
|
76 | - #endregion |
|
77 | - |
|
78 | - #region // Add a location, scheduled monthly (dates mode). |
|
79 | - $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
80 | - "address_1" => "4805 BELLEVUE AVE, Louisville, KY, 40215", |
|
81 | - "address_2" => "4806 BELLEVUE AVE, Louisville, KY, 40215", |
|
82 | - "address_alias" => "4805 BELLEVUE AVE 40215", |
|
83 | - "address_group" => "Scheduled monthly", |
|
84 | - "first_name" => "Bart", |
|
85 | - "last_name" => "Douglas", |
|
86 | - "address_email" => "[email protected]", |
|
87 | - "address_phone_number" => "95487454", |
|
88 | - "cached_lat" => 38.178844, |
|
89 | - "cached_lng" => -85.774864, |
|
90 | - "curbside_lat" => 38.178844, |
|
91 | - "curbside_lng" => -85.774864, |
|
92 | - "address_city" => "Louisville", |
|
93 | - "address_country_id" => "US", |
|
94 | - "address_state_id" => "KY", |
|
95 | - "address_zip" => "40215", |
|
96 | - "schedule" => array(array( |
|
97 | - "enabled" => true, |
|
98 | - "mode" => "monthly", |
|
99 | - "monthly" => array( |
|
100 | - "every" => 1, |
|
101 | - "mode" => "dates", |
|
102 | - "dates" => array(20,22,23,24,25) |
|
103 | - ) |
|
104 | - )), |
|
105 | - "service_time" => 750, |
|
106 | - "color" => "red" |
|
107 | - )); |
|
108 | - |
|
109 | - $abContacts3=new AddressBookLocation(); |
|
110 | - |
|
111 | - $abcResults3=$abContacts3->addAdressBookLocation($AdressBookLocationParameters); |
|
112 | - |
|
113 | - echo "address_id = ".strval($abcResults3["address_id"])."<br>"; |
|
114 | - |
|
115 | - Route4Me::simplePrint($abcResults3); |
|
116 | - |
|
117 | - #endregion |
|
118 | - |
|
119 | - #region // AAdd a location, scheduled monthly (nth mode). |
|
120 | - $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
121 | - "address_1" => "730 CECIL AVENUE, Louisville, KY, 40211", |
|
122 | - "address_alias" => "730 CECIL AVENUE 40211", |
|
123 | - "address_group" => "Scheduled monthly", |
|
124 | - "first_name" => "David", |
|
125 | - "last_name" => "Silvester", |
|
126 | - "address_email" => "[email protected]", |
|
127 | - "address_phone_number" => "36985214", |
|
128 | - "cached_lat" => 38.248684, |
|
129 | - "cached_lng" => -85.821121, |
|
130 | - "curbside_lat" => 38.248684, |
|
131 | - "curbside_lng" => -85.821121, |
|
132 | - "address_city" => "Louisville", |
|
133 | - "address_custom_data" => array( |
|
134 | - "scheduled" => "yes", |
|
135 | - "service type" => "library" |
|
136 | - ), |
|
137 | - "schedule" => array(array( |
|
138 | - "enabled" => true, |
|
139 | - "mode" => "monthly", |
|
140 | - "monthly" => array( |
|
141 | - "every" => 1, |
|
142 | - "mode" => "nth", |
|
143 | - "nth" => array( |
|
144 | - "n" => 1, |
|
145 | - "what" => 4 |
|
146 | - ) |
|
147 | - ) |
|
148 | - )), |
|
149 | - "service_time" => 450, |
|
150 | - "address_icon" => "emoji/emoji-bus" |
|
151 | - )); |
|
152 | - |
|
153 | - $abContacts4=new AddressBookLocation(); |
|
154 | - |
|
155 | - $abcResults4=$abContacts4->addAdressBookLocation($AdressBookLocationParameters); |
|
156 | - |
|
157 | - echo "address_id = ".strval($abcResults4["address_id"])."<br>"; |
|
158 | - |
|
159 | - Route4Me::simplePrint($abcResults4); |
|
160 | - #endregion |
|
161 | - |
|
162 | - #region // Add a location with the daily scheduling and blacklist. |
|
163 | - $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
164 | - |
|
165 | - "address_1" => "4629 HILLSIDE DRIVE, Louisville, KY, 40216", |
|
166 | - "address_alias" => "4629 HILLSIDE DRIVE 40216", |
|
167 | - "address_group" => "Scheduled daily", |
|
168 | - "first_name" => "Kim", |
|
169 | - "last_name" => "Shandor", |
|
170 | - "address_email" => "[email protected]", |
|
171 | - "address_phone_number" => "9874152", |
|
172 | - "cached_lat" => 38.176067, |
|
173 | - "cached_lng" => -85.824638, |
|
174 | - "curbside_lat" => 38.176067, |
|
175 | - "curbside_lng" => -85.824638, |
|
176 | - "address_city" => "Louisville", |
|
177 | - "address_custom_data" => array( |
|
178 | - "scheduled" => "yes", |
|
179 | - "serice type" => "appliance" |
|
180 | - ), |
|
181 | - "schedule" => array( |
|
182 | - "enabled" => true, |
|
183 | - "mode" => "daily", |
|
184 | - "daily" => array("every" => 1) |
|
185 | - ), |
|
186 | - "schedule_blacklist" => array("2017-02-24","2017-02-25"), |
|
187 | - "service_time" => 300 |
|
188 | - )); |
|
189 | - |
|
190 | - $abContacts5=new AddressBookLocation(); |
|
191 | - |
|
192 | - $abcResults5=$abContacts5->addAdressBookLocation($AdressBookLocationParameters); |
|
193 | - |
|
194 | - echo "address_id = ".strval($abcResults5["address_id"])."<br>"; |
|
195 | - |
|
196 | - Route4Me::simplePrint($abcResults5); |
|
197 | - #endregion |
|
41 | + Route4Me::simplePrint($abcResults1); |
|
42 | + #endregion |
|
43 | + |
|
44 | + #region // Add a location, scheduled weekly. |
|
45 | + $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
46 | + "address_1" => "1407 MCCOY, Louisville, KY, 40215", |
|
47 | + "address_alias" => "1407 MCCOY 40215", |
|
48 | + "address_group" => "Scheduled weekly", |
|
49 | + "first_name" => "Bart", |
|
50 | + "last_name" => "Douglas", |
|
51 | + "address_email" => "[email protected]", |
|
52 | + "address_phone_number" => "95487454", |
|
53 | + "cached_lat" => 38.202496, |
|
54 | + "cached_lng" => -85.786514, |
|
55 | + "curbside_lat" => 38.202496, |
|
56 | + "curbside_lng" => -85.786514, |
|
57 | + "address_city" => "Louisville", |
|
58 | + "schedule" => array(array( |
|
59 | + "enabled" => true, |
|
60 | + "mode" => "weekly", |
|
61 | + "weekly" => array( |
|
62 | + "every" => 1, |
|
63 | + "weekdays" => array(1,2,3,4,5) |
|
64 | + ) |
|
65 | + )), |
|
66 | + "service_time" => 600 |
|
67 | + )); |
|
68 | + |
|
69 | + $abContacts2=new AddressBookLocation(); |
|
70 | + |
|
71 | + $abcResults2=$abContacts2->addAdressBookLocation($AdressBookLocationParameters); |
|
72 | + |
|
73 | + echo "address_id = ".strval($abcResults2["address_id"])."<br>"; |
|
74 | + |
|
75 | + Route4Me::simplePrint($abcResults2); |
|
76 | + #endregion |
|
77 | + |
|
78 | + #region // Add a location, scheduled monthly (dates mode). |
|
79 | + $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
80 | + "address_1" => "4805 BELLEVUE AVE, Louisville, KY, 40215", |
|
81 | + "address_2" => "4806 BELLEVUE AVE, Louisville, KY, 40215", |
|
82 | + "address_alias" => "4805 BELLEVUE AVE 40215", |
|
83 | + "address_group" => "Scheduled monthly", |
|
84 | + "first_name" => "Bart", |
|
85 | + "last_name" => "Douglas", |
|
86 | + "address_email" => "[email protected]", |
|
87 | + "address_phone_number" => "95487454", |
|
88 | + "cached_lat" => 38.178844, |
|
89 | + "cached_lng" => -85.774864, |
|
90 | + "curbside_lat" => 38.178844, |
|
91 | + "curbside_lng" => -85.774864, |
|
92 | + "address_city" => "Louisville", |
|
93 | + "address_country_id" => "US", |
|
94 | + "address_state_id" => "KY", |
|
95 | + "address_zip" => "40215", |
|
96 | + "schedule" => array(array( |
|
97 | + "enabled" => true, |
|
98 | + "mode" => "monthly", |
|
99 | + "monthly" => array( |
|
100 | + "every" => 1, |
|
101 | + "mode" => "dates", |
|
102 | + "dates" => array(20,22,23,24,25) |
|
103 | + ) |
|
104 | + )), |
|
105 | + "service_time" => 750, |
|
106 | + "color" => "red" |
|
107 | + )); |
|
108 | + |
|
109 | + $abContacts3=new AddressBookLocation(); |
|
110 | + |
|
111 | + $abcResults3=$abContacts3->addAdressBookLocation($AdressBookLocationParameters); |
|
112 | + |
|
113 | + echo "address_id = ".strval($abcResults3["address_id"])."<br>"; |
|
114 | + |
|
115 | + Route4Me::simplePrint($abcResults3); |
|
116 | + |
|
117 | + #endregion |
|
118 | + |
|
119 | + #region // AAdd a location, scheduled monthly (nth mode). |
|
120 | + $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
121 | + "address_1" => "730 CECIL AVENUE, Louisville, KY, 40211", |
|
122 | + "address_alias" => "730 CECIL AVENUE 40211", |
|
123 | + "address_group" => "Scheduled monthly", |
|
124 | + "first_name" => "David", |
|
125 | + "last_name" => "Silvester", |
|
126 | + "address_email" => "[email protected]", |
|
127 | + "address_phone_number" => "36985214", |
|
128 | + "cached_lat" => 38.248684, |
|
129 | + "cached_lng" => -85.821121, |
|
130 | + "curbside_lat" => 38.248684, |
|
131 | + "curbside_lng" => -85.821121, |
|
132 | + "address_city" => "Louisville", |
|
133 | + "address_custom_data" => array( |
|
134 | + "scheduled" => "yes", |
|
135 | + "service type" => "library" |
|
136 | + ), |
|
137 | + "schedule" => array(array( |
|
138 | + "enabled" => true, |
|
139 | + "mode" => "monthly", |
|
140 | + "monthly" => array( |
|
141 | + "every" => 1, |
|
142 | + "mode" => "nth", |
|
143 | + "nth" => array( |
|
144 | + "n" => 1, |
|
145 | + "what" => 4 |
|
146 | + ) |
|
147 | + ) |
|
148 | + )), |
|
149 | + "service_time" => 450, |
|
150 | + "address_icon" => "emoji/emoji-bus" |
|
151 | + )); |
|
152 | + |
|
153 | + $abContacts4=new AddressBookLocation(); |
|
154 | + |
|
155 | + $abcResults4=$abContacts4->addAdressBookLocation($AdressBookLocationParameters); |
|
156 | + |
|
157 | + echo "address_id = ".strval($abcResults4["address_id"])."<br>"; |
|
158 | + |
|
159 | + Route4Me::simplePrint($abcResults4); |
|
160 | + #endregion |
|
161 | + |
|
162 | + #region // Add a location with the daily scheduling and blacklist. |
|
163 | + $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
164 | + |
|
165 | + "address_1" => "4629 HILLSIDE DRIVE, Louisville, KY, 40216", |
|
166 | + "address_alias" => "4629 HILLSIDE DRIVE 40216", |
|
167 | + "address_group" => "Scheduled daily", |
|
168 | + "first_name" => "Kim", |
|
169 | + "last_name" => "Shandor", |
|
170 | + "address_email" => "[email protected]", |
|
171 | + "address_phone_number" => "9874152", |
|
172 | + "cached_lat" => 38.176067, |
|
173 | + "cached_lng" => -85.824638, |
|
174 | + "curbside_lat" => 38.176067, |
|
175 | + "curbside_lng" => -85.824638, |
|
176 | + "address_city" => "Louisville", |
|
177 | + "address_custom_data" => array( |
|
178 | + "scheduled" => "yes", |
|
179 | + "serice type" => "appliance" |
|
180 | + ), |
|
181 | + "schedule" => array( |
|
182 | + "enabled" => true, |
|
183 | + "mode" => "daily", |
|
184 | + "daily" => array("every" => 1) |
|
185 | + ), |
|
186 | + "schedule_blacklist" => array("2017-02-24","2017-02-25"), |
|
187 | + "service_time" => 300 |
|
188 | + )); |
|
189 | + |
|
190 | + $abContacts5=new AddressBookLocation(); |
|
191 | + |
|
192 | + $abcResults5=$abContacts5->addAdressBookLocation($AdressBookLocationParameters); |
|
193 | + |
|
194 | + echo "address_id = ".strval($abcResults5["address_id"])."<br>"; |
|
195 | + |
|
196 | + Route4Me::simplePrint($abcResults5); |
|
197 | + #endregion |
|
198 | 198 |
@@ -23,11 +23,11 @@ discard block |
||
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,415 +36,415 @@ discard block |
||
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=array(); |
|
285 | - $results['fail']=array(); |
|
286 | - $results['success']=array(); |
|
284 | + $results=array(); |
|
285 | + $results['fail']=array(); |
|
286 | + $results['success']=array(); |
|
287 | 287 | |
288 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
289 | - if (!empty($columns)) { |
|
290 | - array_push($results['fail'],'Empty CSV table'); |
|
291 | - return ($results); |
|
292 | - } |
|
288 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
289 | + if (!empty($columns)) { |
|
290 | + array_push($results['fail'],'Empty CSV table'); |
|
291 | + return ($results); |
|
292 | + } |
|
293 | 293 | |
294 | - $iRow=1; |
|
294 | + $iRow=1; |
|
295 | 295 | |
296 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) { |
|
297 | - if ($rows[$locationsFieldsMapping['cached_lat']] && $rows[$locationsFieldsMapping['cached_lng']] && $rows[$locationsFieldsMapping['address_1']] && array(null) !== $rows) { |
|
298 | - $curSchedule=""; |
|
299 | - $mode=""; |
|
296 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) { |
|
297 | + if ($rows[$locationsFieldsMapping['cached_lat']] && $rows[$locationsFieldsMapping['cached_lng']] && $rows[$locationsFieldsMapping['address_1']] && array(null) !== $rows) { |
|
298 | + $curSchedule=""; |
|
299 | + $mode=""; |
|
300 | 300 | |
301 | - if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
302 | - if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
303 | - $curSchedule='"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
304 | - $mode=$rows[$locationsFieldsMapping['schedule_mode']]; |
|
305 | - } |
|
306 | - else {array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); $curSchedule="";} |
|
307 | - } |
|
308 | - else {array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); $curSchedule="";} |
|
301 | + if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
302 | + if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
303 | + $curSchedule='"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
304 | + $mode=$rows[$locationsFieldsMapping['schedule_mode']]; |
|
305 | + } |
|
306 | + else {array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); $curSchedule="";} |
|
307 | + } |
|
308 | + else {array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); $curSchedule="";} |
|
309 | 309 | |
310 | - if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
311 | - if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
312 | - $curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
313 | - } |
|
314 | - else {array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set "); $curSchedule="";} |
|
315 | - } |
|
310 | + if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
311 | + if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
312 | + $curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
313 | + } |
|
314 | + else {array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set "); $curSchedule="";} |
|
315 | + } |
|
316 | 316 | |
317 | - if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
318 | - if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
319 | - $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
320 | - if ($mode=='daily') { |
|
321 | - $curSchedule=trim($curSchedule,','); |
|
322 | - $curSchedule.='}'; |
|
323 | - } |
|
324 | - } |
|
325 | - else {array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); $curSchedule=""; } |
|
326 | - } |
|
317 | + if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
318 | + if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
319 | + $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
320 | + if ($mode=='daily') { |
|
321 | + $curSchedule=trim($curSchedule,','); |
|
322 | + $curSchedule.='}'; |
|
323 | + } |
|
324 | + } |
|
325 | + else {array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); $curSchedule=""; } |
|
326 | + } |
|
327 | 327 | |
328 | - if ($mode!='daily') { |
|
329 | - switch ($mode) { |
|
330 | - case 'weekly': |
|
331 | - if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
332 | - if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
333 | - $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
334 | - } |
|
335 | - else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $curSchedule="";} |
|
336 | - } |
|
337 | - else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $curSchedule="";} |
|
338 | - break; |
|
339 | - case 'monthly': |
|
340 | - $monthlyMode=""; |
|
341 | - if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
342 | - if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
343 | - $monthlyMode=$rows[$locationsFieldsMapping['monthly_mode']]; |
|
344 | - $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
345 | - } |
|
346 | - else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $curSchedule="";} |
|
347 | - } |
|
348 | - else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $curSchedule="";} |
|
328 | + if ($mode!='daily') { |
|
329 | + switch ($mode) { |
|
330 | + case 'weekly': |
|
331 | + if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
332 | + if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
333 | + $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
334 | + } |
|
335 | + else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $curSchedule="";} |
|
336 | + } |
|
337 | + else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $curSchedule="";} |
|
338 | + break; |
|
339 | + case 'monthly': |
|
340 | + $monthlyMode=""; |
|
341 | + if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
342 | + if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
343 | + $monthlyMode=$rows[$locationsFieldsMapping['monthly_mode']]; |
|
344 | + $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
345 | + } |
|
346 | + else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $curSchedule="";} |
|
347 | + } |
|
348 | + else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $curSchedule="";} |
|
349 | 349 | |
350 | - if ($monthlyMode!="") { |
|
351 | - switch ($monthlyMode) { |
|
352 | - case 'dates': |
|
353 | - if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
354 | - if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
355 | - $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
356 | - } |
|
357 | - else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $curSchedule="";} |
|
358 | - } |
|
359 | - break; |
|
360 | - case 'nth': |
|
361 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
362 | - if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
363 | - $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
364 | - } |
|
365 | - else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $curSchedule="";} |
|
366 | - } |
|
367 | - else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $curSchedule="";} |
|
350 | + if ($monthlyMode!="") { |
|
351 | + switch ($monthlyMode) { |
|
352 | + case 'dates': |
|
353 | + if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
354 | + if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
355 | + $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
356 | + } |
|
357 | + else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $curSchedule="";} |
|
358 | + } |
|
359 | + break; |
|
360 | + case 'nth': |
|
361 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
362 | + if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
363 | + $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
364 | + } |
|
365 | + else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $curSchedule="";} |
|
366 | + } |
|
367 | + else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $curSchedule="";} |
|
368 | 368 | |
369 | - if ($curSchedule!="") { |
|
370 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
371 | - if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
372 | - $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
373 | - } |
|
374 | - else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $curSchedule="";} |
|
375 | - } |
|
376 | - else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $curSchedule="";} |
|
377 | - } |
|
369 | + if ($curSchedule!="") { |
|
370 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
371 | + if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
372 | + $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
373 | + } |
|
374 | + else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $curSchedule="";} |
|
375 | + } |
|
376 | + else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $curSchedule="";} |
|
377 | + } |
|
378 | 378 | |
379 | - break; |
|
380 | - } |
|
381 | - } |
|
382 | - break; |
|
383 | - default: |
|
384 | - $curSchedule==""; |
|
385 | - break; |
|
386 | - } |
|
379 | + break; |
|
380 | + } |
|
381 | + } |
|
382 | + break; |
|
383 | + default: |
|
384 | + $curSchedule==""; |
|
385 | + break; |
|
386 | + } |
|
387 | 387 | |
388 | - } |
|
388 | + } |
|
389 | 389 | |
390 | - if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") {$iRow++; continue;} |
|
390 | + if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") {$iRow++; continue;} |
|
391 | 391 | |
392 | - $curSchedule=strtolower($curSchedule); |
|
392 | + $curSchedule=strtolower($curSchedule); |
|
393 | 393 | |
394 | - $curSchedule='[{'.$curSchedule.'}]'; |
|
394 | + $curSchedule='[{'.$curSchedule.'}]'; |
|
395 | 395 | |
396 | - $oSchedule= json_decode($curSchedule,TRUE); |
|
396 | + $oSchedule= json_decode($curSchedule,TRUE); |
|
397 | 397 | |
398 | - $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
399 | - "cached_lat" => $rows[$locationsFieldsMapping['cached_lat']], |
|
400 | - "cached_lng" => $rows[$locationsFieldsMapping['cached_lng']], |
|
401 | - "curbside_lat" => isset($locationsFieldsMapping['curbside_lat']) ? $rows[$locationsFieldsMapping['curbside_lat']] : null, |
|
402 | - "curbside_lng" => isset($locationsFieldsMapping['curbside_lng']) ? $rows[$locationsFieldsMapping['curbside_lng']] : null, |
|
403 | - "address_alias" => isset($locationsFieldsMapping['address_alias']) ? $rows[$locationsFieldsMapping['address_alias']] : null, |
|
404 | - "address_1" => $rows[$locationsFieldsMapping['address_1']], |
|
405 | - "address_2" => isset($locationsFieldsMapping['address_2']) ? $rows[$locationsFieldsMapping['address_2']] : null, |
|
406 | - "address_city" => isset($locationsFieldsMapping['address_city']) ? $rows[$locationsFieldsMapping['address_city']] : null, |
|
407 | - "address_state_id" => isset($locationsFieldsMapping['address_state_id']) ? $rows[$locationsFieldsMapping['address_state_id']] : null, |
|
408 | - "address_zip" => isset($locationsFieldsMapping['address_zip']) ? $rows[$locationsFieldsMapping['address_zip']] : null, |
|
409 | - "address_phone_number" => isset($locationsFieldsMapping['address_phone_number']) ? $rows[$locationsFieldsMapping['address_phone_number']] : null, |
|
410 | - "schedule" => isset($oSchedule) ? $oSchedule : null, |
|
411 | - "address_group" => isset($locationsFieldsMapping['address_group']) ? $rows[$locationsFieldsMapping['address_group']] : null, |
|
412 | - "first_name" => isset($locationsFieldsMapping['first_name']) ? $rows[$locationsFieldsMapping['first_name']] : null, |
|
413 | - "last_name" => isset($locationsFieldsMapping['last_name']) ? $rows[$locationsFieldsMapping['last_name']] : null, |
|
414 | - "local_time_window_start" => isset($locationsFieldsMapping['local_time_window_start']) ? $rows[$locationsFieldsMapping['local_time_window_start']] : null, |
|
415 | - "local_time_window_end" => isset($locationsFieldsMapping['local_time_window_end']) ? $rows[$locationsFieldsMapping['local_time_window_end']] : null, |
|
416 | - "local_time_window_start_2" => isset($locationsFieldsMapping['local_time_window_start_2']) ? $rows[$locationsFieldsMapping['local_time_window_start_2']] : null, |
|
417 | - "local_time_window_end_2" => isset($locationsFieldsMapping['local_time_window_end_2']) ? $rows[$locationsFieldsMapping['local_time_window_end_2']] : null, |
|
418 | - "address_email" => isset($locationsFieldsMapping['address_email']) ? $rows[$locationsFieldsMapping['address_email']] : null, |
|
419 | - "address_country_id" => isset($locationsFieldsMapping['address_country_id']) ? $rows[$locationsFieldsMapping['address_country_id']] : null, |
|
420 | - "address_custom_data" => isset($locationsFieldsMapping['address_custom_data']) ? $rows[$locationsFieldsMapping['address_custom_data']] : null, |
|
421 | - "schedule_blacklist" => isset($locationsFieldsMapping['schedule_blacklist']) ? $rows[$locationsFieldsMapping['schedule_blacklist']] : null, |
|
422 | - "service_time" => isset($locationsFieldsMapping['service_time']) ? $rows[$locationsFieldsMapping['service_time']] : null, |
|
423 | - "local_timezone_string" => isset($locationsFieldsMapping['local_timezone_string']) ? $rows[$locationsFieldsMapping['local_timezone_string']] : null, |
|
424 | - "color" => isset($locationsFieldsMapping['color']) ? $rows[$locationsFieldsMapping['color']] : null, |
|
425 | - "address_icon" => isset($locationsFieldsMapping['address_icon']) ? $rows[$locationsFieldsMapping['address_icon']] : null, |
|
426 | - "address_stop_type" => isset($locationsFieldsMapping['address_stop_type']) ? $rows[$locationsFieldsMapping['address_stop_type']] : null, |
|
427 | - "address_cube" => isset($locationsFieldsMapping['address_cube']) ? $rows[$locationsFieldsMapping['address_cube']] : null, |
|
428 | - "address_pieces" => isset($locationsFieldsMapping['address_pieces']) ? $rows[$locationsFieldsMapping['address_pieces']] : null, |
|
429 | - "address_reference_no" => isset($locationsFieldsMapping['address_reference_no']) ? $rows[$locationsFieldsMapping['address_reference_no']] : null, |
|
430 | - "address_revenue" => isset($locationsFieldsMapping['address_revenue']) ? $rows[$locationsFieldsMapping['address_revenue']] : null, |
|
431 | - "address_weight" => isset($locationsFieldsMapping['address_weight']) ? $rows[$locationsFieldsMapping['address_weight']] : null, |
|
432 | - "address_priority" => isset($locationsFieldsMapping['address_priority']) ? $rows[$locationsFieldsMapping['address_priority']] : null, |
|
433 | - "address_customer_po" => isset($locationsFieldsMapping['address_customer_po']) ? $rows[$locationsFieldsMapping['address_customer_po']] : null, |
|
434 | - )); |
|
398 | + $AdressBookLocationParameters=AddressBookLocation::fromArray(array( |
|
399 | + "cached_lat" => $rows[$locationsFieldsMapping['cached_lat']], |
|
400 | + "cached_lng" => $rows[$locationsFieldsMapping['cached_lng']], |
|
401 | + "curbside_lat" => isset($locationsFieldsMapping['curbside_lat']) ? $rows[$locationsFieldsMapping['curbside_lat']] : null, |
|
402 | + "curbside_lng" => isset($locationsFieldsMapping['curbside_lng']) ? $rows[$locationsFieldsMapping['curbside_lng']] : null, |
|
403 | + "address_alias" => isset($locationsFieldsMapping['address_alias']) ? $rows[$locationsFieldsMapping['address_alias']] : null, |
|
404 | + "address_1" => $rows[$locationsFieldsMapping['address_1']], |
|
405 | + "address_2" => isset($locationsFieldsMapping['address_2']) ? $rows[$locationsFieldsMapping['address_2']] : null, |
|
406 | + "address_city" => isset($locationsFieldsMapping['address_city']) ? $rows[$locationsFieldsMapping['address_city']] : null, |
|
407 | + "address_state_id" => isset($locationsFieldsMapping['address_state_id']) ? $rows[$locationsFieldsMapping['address_state_id']] : null, |
|
408 | + "address_zip" => isset($locationsFieldsMapping['address_zip']) ? $rows[$locationsFieldsMapping['address_zip']] : null, |
|
409 | + "address_phone_number" => isset($locationsFieldsMapping['address_phone_number']) ? $rows[$locationsFieldsMapping['address_phone_number']] : null, |
|
410 | + "schedule" => isset($oSchedule) ? $oSchedule : null, |
|
411 | + "address_group" => isset($locationsFieldsMapping['address_group']) ? $rows[$locationsFieldsMapping['address_group']] : null, |
|
412 | + "first_name" => isset($locationsFieldsMapping['first_name']) ? $rows[$locationsFieldsMapping['first_name']] : null, |
|
413 | + "last_name" => isset($locationsFieldsMapping['last_name']) ? $rows[$locationsFieldsMapping['last_name']] : null, |
|
414 | + "local_time_window_start" => isset($locationsFieldsMapping['local_time_window_start']) ? $rows[$locationsFieldsMapping['local_time_window_start']] : null, |
|
415 | + "local_time_window_end" => isset($locationsFieldsMapping['local_time_window_end']) ? $rows[$locationsFieldsMapping['local_time_window_end']] : null, |
|
416 | + "local_time_window_start_2" => isset($locationsFieldsMapping['local_time_window_start_2']) ? $rows[$locationsFieldsMapping['local_time_window_start_2']] : null, |
|
417 | + "local_time_window_end_2" => isset($locationsFieldsMapping['local_time_window_end_2']) ? $rows[$locationsFieldsMapping['local_time_window_end_2']] : null, |
|
418 | + "address_email" => isset($locationsFieldsMapping['address_email']) ? $rows[$locationsFieldsMapping['address_email']] : null, |
|
419 | + "address_country_id" => isset($locationsFieldsMapping['address_country_id']) ? $rows[$locationsFieldsMapping['address_country_id']] : null, |
|
420 | + "address_custom_data" => isset($locationsFieldsMapping['address_custom_data']) ? $rows[$locationsFieldsMapping['address_custom_data']] : null, |
|
421 | + "schedule_blacklist" => isset($locationsFieldsMapping['schedule_blacklist']) ? $rows[$locationsFieldsMapping['schedule_blacklist']] : null, |
|
422 | + "service_time" => isset($locationsFieldsMapping['service_time']) ? $rows[$locationsFieldsMapping['service_time']] : null, |
|
423 | + "local_timezone_string" => isset($locationsFieldsMapping['local_timezone_string']) ? $rows[$locationsFieldsMapping['local_timezone_string']] : null, |
|
424 | + "color" => isset($locationsFieldsMapping['color']) ? $rows[$locationsFieldsMapping['color']] : null, |
|
425 | + "address_icon" => isset($locationsFieldsMapping['address_icon']) ? $rows[$locationsFieldsMapping['address_icon']] : null, |
|
426 | + "address_stop_type" => isset($locationsFieldsMapping['address_stop_type']) ? $rows[$locationsFieldsMapping['address_stop_type']] : null, |
|
427 | + "address_cube" => isset($locationsFieldsMapping['address_cube']) ? $rows[$locationsFieldsMapping['address_cube']] : null, |
|
428 | + "address_pieces" => isset($locationsFieldsMapping['address_pieces']) ? $rows[$locationsFieldsMapping['address_pieces']] : null, |
|
429 | + "address_reference_no" => isset($locationsFieldsMapping['address_reference_no']) ? $rows[$locationsFieldsMapping['address_reference_no']] : null, |
|
430 | + "address_revenue" => isset($locationsFieldsMapping['address_revenue']) ? $rows[$locationsFieldsMapping['address_revenue']] : null, |
|
431 | + "address_weight" => isset($locationsFieldsMapping['address_weight']) ? $rows[$locationsFieldsMapping['address_weight']] : null, |
|
432 | + "address_priority" => isset($locationsFieldsMapping['address_priority']) ? $rows[$locationsFieldsMapping['address_priority']] : null, |
|
433 | + "address_customer_po" => isset($locationsFieldsMapping['address_customer_po']) ? $rows[$locationsFieldsMapping['address_customer_po']] : null, |
|
434 | + )); |
|
435 | 435 | |
436 | - $abContacts=new AddressBookLocation(); |
|
436 | + $abContacts=new AddressBookLocation(); |
|
437 | 437 | |
438 | - $abcResults=$abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
438 | + $abcResults=$abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
439 | 439 | |
440 | - array_push($results['success'],"The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
440 | + array_push($results['success'],"The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
441 | 441 | |
442 | - } |
|
442 | + } |
|
443 | 443 | |
444 | - } |
|
444 | + } |
|
445 | 445 | |
446 | - return $results; |
|
447 | - } |
|
446 | + return $results; |
|
447 | + } |
|
448 | 448 | |
449 | 449 | |
450 | 450 | } |
@@ -4,11 +4,11 @@ |
||
4 | 4 | |
5 | 5 | class myErrorHandler extends \Exception |
6 | 6 | { |
7 | - public function proc_error($errno, $errstr, $errfile, $errline) |
|
8 | - { |
|
9 | - echo "line: $errline --- ".$errstr."<br>"; |
|
7 | + public function proc_error($errno, $errstr, $errfile, $errline) |
|
8 | + { |
|
9 | + echo "line: $errline --- ".$errstr."<br>"; |
|
10 | 10 | |
11 | - } |
|
11 | + } |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | ?> |
15 | 15 | \ No newline at end of file |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | |
4 | 4 | $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
5 | 5 | |
6 | - require $vdir.'/../vendor/autoload.php'; |
|
6 | + require $vdir.'/../vendor/autoload.php'; |
|
7 | 7 | |
8 | 8 | use Route4Me\Route4Me; |
9 | 9 | use Route4Me\Route; |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | foreach ($notes['notes'] as $note) { |
49 | 49 | echo "========== Notes ==================<br>"; |
50 | 50 | echo "note_id --> ".$note['note_id']."<br>"; |
51 | - $content = isset($note['contents']) ? $note['contents'] : ""; |
|
52 | - if (strlen($content)>0) echo "contents --> $content"."<br>"; |
|
51 | + $content = isset($note['contents']) ? $note['contents'] : ""; |
|
52 | + if (strlen($content)>0) echo "contents --> $content"."<br>"; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | //var_dump($notes); |
@@ -9,55 +9,55 @@ discard block |
||
9 | 9 | |
10 | 10 | class Address extends Common |
11 | 11 | { |
12 | - static public $apiUrl = '/api.v4/address.php'; |
|
12 | + static public $apiUrl = '/api.v4/address.php'; |
|
13 | 13 | static public $apiUrlMove='/actions/route/move_route_destination.php'; |
14 | 14 | static public $apiUrDeparted='/api/route/mark_address_departed.php'; |
15 | 15 | static public $apiUrVisited='/actions/address/update_address_visited.php'; |
16 | 16 | |
17 | - public $route_destination_id; |
|
18 | - public $alias; |
|
19 | - public $member_id; |
|
20 | - public $address; |
|
21 | - public $is_depot = false; |
|
22 | - public $lat; |
|
23 | - public $lng; |
|
24 | - public $route_id; |
|
25 | - public $original_route_id; |
|
26 | - public $optimization_problem_id; |
|
27 | - public $sequence_no; |
|
28 | - public $geocoded; |
|
29 | - public $preferred_geocoding; |
|
30 | - public $failed_geocoding; |
|
31 | - public $geocodings = array(); |
|
32 | - public $contact_id; |
|
33 | - public $is_visited; |
|
34 | - public $customer_po; |
|
35 | - public $invoice_no; |
|
36 | - public $reference_no; |
|
37 | - public $order_no; |
|
38 | - public $weight; |
|
39 | - public $cost; |
|
40 | - public $revenue; |
|
41 | - public $cube; |
|
42 | - public $pieces; |
|
43 | - public $email; |
|
44 | - public $phone; |
|
45 | - public $destination_note_count; |
|
46 | - public $drive_time_to_next_destination; |
|
47 | - public $distance_to_next_destination; |
|
48 | - public $generated_time_window_start; |
|
49 | - public $generated_time_window_end; |
|
50 | - public $time_window_start; |
|
51 | - public $time_window_end; |
|
52 | - public $time; |
|
17 | + public $route_destination_id; |
|
18 | + public $alias; |
|
19 | + public $member_id; |
|
20 | + public $address; |
|
21 | + public $is_depot = false; |
|
22 | + public $lat; |
|
23 | + public $lng; |
|
24 | + public $route_id; |
|
25 | + public $original_route_id; |
|
26 | + public $optimization_problem_id; |
|
27 | + public $sequence_no; |
|
28 | + public $geocoded; |
|
29 | + public $preferred_geocoding; |
|
30 | + public $failed_geocoding; |
|
31 | + public $geocodings = array(); |
|
32 | + public $contact_id; |
|
33 | + public $is_visited; |
|
34 | + public $customer_po; |
|
35 | + public $invoice_no; |
|
36 | + public $reference_no; |
|
37 | + public $order_no; |
|
38 | + public $weight; |
|
39 | + public $cost; |
|
40 | + public $revenue; |
|
41 | + public $cube; |
|
42 | + public $pieces; |
|
43 | + public $email; |
|
44 | + public $phone; |
|
45 | + public $destination_note_count; |
|
46 | + public $drive_time_to_next_destination; |
|
47 | + public $distance_to_next_destination; |
|
48 | + public $generated_time_window_start; |
|
49 | + public $generated_time_window_end; |
|
50 | + public $time_window_start; |
|
51 | + public $time_window_end; |
|
52 | + public $time; |
|
53 | 53 | public $notes; |
54 | - public $timestamp_last_visited; |
|
55 | - public $custom_fields = array(); |
|
56 | - public $manifest = array(); |
|
54 | + public $timestamp_last_visited; |
|
55 | + public $custom_fields = array(); |
|
56 | + public $manifest = array(); |
|
57 | 57 | |
58 | - public static function fromArray(array $params) |
|
59 | - { |
|
60 | - /*if (!isset($params['address'])) { |
|
58 | + public static function fromArray(array $params) |
|
59 | + { |
|
60 | + /*if (!isset($params['address'])) { |
|
61 | 61 | throw new BadParam('address must be provided'); |
62 | 62 | } |
63 | 63 | |
@@ -69,142 +69,142 @@ discard block |
||
69 | 69 | throw new BadParam('lng must be provided'); |
70 | 70 | }*/ |
71 | 71 | |
72 | - $address = new Address(); |
|
73 | - foreach($params as $key => $value) { |
|
74 | - if (property_exists($address, $key)) { |
|
75 | - $address->{$key} = $value; |
|
76 | - } |
|
77 | - } |
|
72 | + $address = new Address(); |
|
73 | + foreach($params as $key => $value) { |
|
74 | + if (property_exists($address, $key)) { |
|
75 | + $address->{$key} = $value; |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + return $address; |
|
80 | + } |
|
78 | 81 | |
79 | - return $address; |
|
80 | - } |
|
81 | - |
|
82 | - public static function getAddress($routeId, $addressId) |
|
83 | - { |
|
84 | - $address = Route4Me::makeRequst(array( |
|
85 | - 'url' => self::$apiUrl, |
|
86 | - 'method' => 'GET', |
|
87 | - 'query' => array( |
|
88 | - 'route_id' => $routeId, |
|
89 | - 'route_destination_id' => $addressId, |
|
90 | - ) |
|
91 | - )); |
|
92 | - |
|
93 | - return Address::fromArray($address); |
|
94 | - } |
|
82 | + public static function getAddress($routeId, $addressId) |
|
83 | + { |
|
84 | + $address = Route4Me::makeRequst(array( |
|
85 | + 'url' => self::$apiUrl, |
|
86 | + 'method' => 'GET', |
|
87 | + 'query' => array( |
|
88 | + 'route_id' => $routeId, |
|
89 | + 'route_destination_id' => $addressId, |
|
90 | + ) |
|
91 | + )); |
|
92 | + |
|
93 | + return Address::fromArray($address); |
|
94 | + } |
|
95 | 95 | |
96 | 96 | /*Get notes from the specified route destination |
97 | 97 | * Returns an address object with notes, if an address exists, otherwise - return null. |
98 | 98 | */ |
99 | - public static function GetAddressesNotes($noteParams) |
|
100 | - { |
|
101 | - $address = Route4Me::makeRequst(array( |
|
102 | - 'url' => self::$apiUrl, |
|
103 | - 'method' => 'GET', |
|
104 | - 'query' => array( |
|
105 | - 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id']: null, |
|
106 | - 'route_destination_id' => isset($noteParams['route_destination_id']) ? $noteParams['route_destination_id'] : null, |
|
107 | - 'notes' => 1, |
|
108 | - ) |
|
109 | - )); |
|
110 | - |
|
111 | - return $address; |
|
112 | - } |
|
113 | - |
|
114 | - public function update() |
|
115 | - { |
|
116 | - $address = Route4Me::makeRequst(array( |
|
117 | - 'url' => self::$apiUrl, |
|
118 | - 'method' => 'PUT', |
|
119 | - 'body' => $this->toArray(), |
|
120 | - 'query' => array( |
|
121 | - 'route_id' => $this->route_id, |
|
122 | - 'route_destination_id' => $this->route_destination_id, |
|
123 | - ), |
|
124 | - )); |
|
125 | - |
|
126 | - return Address::fromArray($address); |
|
127 | - } |
|
99 | + public static function GetAddressesNotes($noteParams) |
|
100 | + { |
|
101 | + $address = Route4Me::makeRequst(array( |
|
102 | + 'url' => self::$apiUrl, |
|
103 | + 'method' => 'GET', |
|
104 | + 'query' => array( |
|
105 | + 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id']: null, |
|
106 | + 'route_destination_id' => isset($noteParams['route_destination_id']) ? $noteParams['route_destination_id'] : null, |
|
107 | + 'notes' => 1, |
|
108 | + ) |
|
109 | + )); |
|
110 | + |
|
111 | + return $address; |
|
112 | + } |
|
113 | + |
|
114 | + public function update() |
|
115 | + { |
|
116 | + $address = Route4Me::makeRequst(array( |
|
117 | + 'url' => self::$apiUrl, |
|
118 | + 'method' => 'PUT', |
|
119 | + 'body' => $this->toArray(), |
|
120 | + 'query' => array( |
|
121 | + 'route_id' => $this->route_id, |
|
122 | + 'route_destination_id' => $this->route_destination_id, |
|
123 | + ), |
|
124 | + )); |
|
125 | + |
|
126 | + return Address::fromArray($address); |
|
127 | + } |
|
128 | 128 | |
129 | 129 | public function markAddress($params, $body) |
130 | - { |
|
131 | - $result = Route4Me::makeRequst(array( |
|
132 | - 'url' => self::$apiUrl, |
|
133 | - 'method' => 'PUT', |
|
134 | - 'query' => array( |
|
135 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
136 | - 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
137 | - ), |
|
138 | - 'body' => $body |
|
139 | - )); |
|
140 | - |
|
141 | - return $result; |
|
142 | - } |
|
130 | + { |
|
131 | + $result = Route4Me::makeRequst(array( |
|
132 | + 'url' => self::$apiUrl, |
|
133 | + 'method' => 'PUT', |
|
134 | + 'query' => array( |
|
135 | + 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
136 | + 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
137 | + ), |
|
138 | + 'body' => $body |
|
139 | + )); |
|
140 | + |
|
141 | + return $result; |
|
142 | + } |
|
143 | 143 | |
144 | 144 | public function markAsDeparted($params) |
145 | 145 | { |
146 | 146 | $address = Route4Me::makeRequst(array( |
147 | - 'url' => self::$apiUrDeparted, |
|
148 | - 'method' => 'GET', |
|
149 | - 'query' => array( |
|
150 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
151 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
152 | - 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
153 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
154 | - ), |
|
155 | - )); |
|
156 | - |
|
157 | - return $address; |
|
147 | + 'url' => self::$apiUrDeparted, |
|
148 | + 'method' => 'GET', |
|
149 | + 'query' => array( |
|
150 | + 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
151 | + 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
152 | + 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
153 | + 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
154 | + ), |
|
155 | + )); |
|
156 | + |
|
157 | + return $address; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | public function markAsVisited($params) |
161 | 161 | { |
162 | 162 | $address = Route4Me::makeRequst(array( |
163 | - 'url' => self::$apiUrVisited, |
|
164 | - 'method' => 'GET', |
|
165 | - 'query' => array( |
|
166 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
167 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
168 | - 'is_visited' => isset($params['is_visited']) ? $params['is_visited']: null, |
|
169 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
170 | - ), |
|
171 | - )); |
|
172 | - |
|
173 | - return $address; |
|
163 | + 'url' => self::$apiUrVisited, |
|
164 | + 'method' => 'GET', |
|
165 | + 'query' => array( |
|
166 | + 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
167 | + 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
168 | + 'is_visited' => isset($params['is_visited']) ? $params['is_visited']: null, |
|
169 | + 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
170 | + ), |
|
171 | + )); |
|
172 | + |
|
173 | + return $address; |
|
174 | 174 | } |
175 | 175 | |
176 | - public function delete() |
|
177 | - { |
|
178 | - $address = Route4Me::makeRequst(array( |
|
179 | - 'url' => self::$apiUrl, |
|
180 | - 'method' => 'DELETE', |
|
181 | - 'query' => array( |
|
182 | - 'route_id' => $this->route_id, |
|
183 | - 'route_destination_id' => $this->route_destination_id, |
|
184 | - ) |
|
185 | - )); |
|
186 | - |
|
187 | - return (bool)$address['deleted']; |
|
188 | - } |
|
176 | + public function delete() |
|
177 | + { |
|
178 | + $address = Route4Me::makeRequst(array( |
|
179 | + 'url' => self::$apiUrl, |
|
180 | + 'method' => 'DELETE', |
|
181 | + 'query' => array( |
|
182 | + 'route_id' => $this->route_id, |
|
183 | + 'route_destination_id' => $this->route_destination_id, |
|
184 | + ) |
|
185 | + )); |
|
186 | + |
|
187 | + return (bool)$address['deleted']; |
|
188 | + } |
|
189 | 189 | |
190 | 190 | public function MoveDestinationToRoute($params) |
191 | 191 | { |
192 | 192 | $result = Route4Me::makeRequst(array( |
193 | - 'url' => self::$apiUrlMove, |
|
194 | - 'method' => 'POST', |
|
195 | - 'query' => array( |
|
196 | - 'to_route_id' => isset($params['to_route_id']) ? $params['to_route_id'] : null, |
|
197 | - 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
198 | - 'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null |
|
199 | - ) |
|
200 | - )); |
|
201 | - |
|
202 | - return $result; |
|
193 | + 'url' => self::$apiUrlMove, |
|
194 | + 'method' => 'POST', |
|
195 | + 'query' => array( |
|
196 | + 'to_route_id' => isset($params['to_route_id']) ? $params['to_route_id'] : null, |
|
197 | + 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
198 | + 'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null |
|
199 | + ) |
|
200 | + )); |
|
201 | + |
|
202 | + return $result; |
|
203 | 203 | |
204 | 204 | } |
205 | 205 | |
206 | - function getAddressId() |
|
207 | - { |
|
208 | - return $this->route_destination_id; |
|
209 | - } |
|
206 | + function getAddressId() |
|
207 | + { |
|
208 | + return $this->route_destination_id; |
|
209 | + } |
|
210 | 210 | } |