@@ -7,16 +7,16 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Track extends Common |
| 9 | 9 | { |
| 10 | - public static function set(TrackSetParams $params) |
|
| 11 | - { |
|
| 12 | - $allQueryFields = Route4Me::getObjectProperties(new TrackSetParams(), array('tx_id')); |
|
| 10 | + public static function set(TrackSetParams $params) |
|
| 11 | + { |
|
| 12 | + $allQueryFields = Route4Me::getObjectProperties(new TrackSetParams(), array('tx_id')); |
|
| 13 | 13 | |
| 14 | - $json = Route4Me::makeRequst(array( |
|
| 15 | - 'url' => Endpoint::TRACK_SET, |
|
| 16 | - 'method' => 'GET', |
|
| 17 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 18 | - )); |
|
| 14 | + $json = Route4Me::makeRequst(array( |
|
| 15 | + 'url' => Endpoint::TRACK_SET, |
|
| 16 | + 'method' => 'GET', |
|
| 17 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 18 | + )); |
|
| 19 | 19 | |
| 20 | - return $json; |
|
| 21 | - } |
|
| 20 | + return $json; |
|
| 21 | + } |
|
| 22 | 22 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | public static function searchOrder($params) |
| 217 | 217 | { |
| 218 | - $allQueryFields = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
| 218 | + $allQueryFields = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit'); |
|
| 219 | 219 | |
| 220 | 220 | $response = Route4Me::makeRequst(array( |
| 221 | 221 | 'url' => Endpoint::ORDER_V4, |
@@ -269,11 +269,11 @@ discard block |
||
| 269 | 269 | $allOrderFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
| 270 | 270 | |
| 271 | 271 | if (!empty($columns)) { |
| 272 | - array_push($results['fail'],'Empty CSV table'); |
|
| 272 | + array_push($results['fail'], 'Empty CSV table'); |
|
| 273 | 273 | return ($results); |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - $iRow=1; |
|
| 276 | + $iRow = 1; |
|
| 277 | 277 | |
| 278 | 278 | while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
| 279 | 279 | if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
@@ -6,324 +6,324 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Order extends Common |
| 8 | 8 | { |
| 9 | - public $address_1; |
|
| 10 | - public $address_2; |
|
| 11 | - public $cached_lat; |
|
| 12 | - public $cached_lng; |
|
| 13 | - public $curbside_lat; |
|
| 14 | - public $curbside_lng; |
|
| 15 | - public $address_alias; |
|
| 16 | - public $address_city; |
|
| 17 | - public $EXT_FIELD_first_name; |
|
| 18 | - public $EXT_FIELD_last_name; |
|
| 19 | - public $EXT_FIELD_email; |
|
| 20 | - public $EXT_FIELD_phone; |
|
| 21 | - public $EXT_FIELD_custom_data; |
|
| 9 | + public $address_1; |
|
| 10 | + public $address_2; |
|
| 11 | + public $cached_lat; |
|
| 12 | + public $cached_lng; |
|
| 13 | + public $curbside_lat; |
|
| 14 | + public $curbside_lng; |
|
| 15 | + public $address_alias; |
|
| 16 | + public $address_city; |
|
| 17 | + public $EXT_FIELD_first_name; |
|
| 18 | + public $EXT_FIELD_last_name; |
|
| 19 | + public $EXT_FIELD_email; |
|
| 20 | + public $EXT_FIELD_phone; |
|
| 21 | + public $EXT_FIELD_custom_data; |
|
| 22 | 22 | |
| 23 | - public $color; |
|
| 24 | - public $order_icon; |
|
| 25 | - public $local_time_window_start; |
|
| 26 | - public $local_time_window_end; |
|
| 27 | - public $local_time_window_start_2; |
|
| 28 | - public $local_time_window_end_2; |
|
| 29 | - public $service_time; |
|
| 23 | + public $color; |
|
| 24 | + public $order_icon; |
|
| 25 | + public $local_time_window_start; |
|
| 26 | + public $local_time_window_end; |
|
| 27 | + public $local_time_window_start_2; |
|
| 28 | + public $local_time_window_end_2; |
|
| 29 | + public $service_time; |
|
| 30 | 30 | |
| 31 | - public $day_scheduled_for_YYMMDD; |
|
| 31 | + public $day_scheduled_for_YYMMDD; |
|
| 32 | 32 | |
| 33 | - public $route_id; |
|
| 34 | - public $redirect; |
|
| 35 | - public $optimization_problem_id; |
|
| 36 | - public $order_id; |
|
| 37 | - public $order_ids; |
|
| 33 | + public $route_id; |
|
| 34 | + public $redirect; |
|
| 35 | + public $optimization_problem_id; |
|
| 36 | + public $order_id; |
|
| 37 | + public $order_ids; |
|
| 38 | 38 | |
| 39 | - public $day_added_YYMMDD; |
|
| 40 | - public $scheduled_for_YYMMDD; |
|
| 41 | - public $fields; |
|
| 42 | - public $offset; |
|
| 43 | - public $limit; |
|
| 44 | - public $query; |
|
| 39 | + public $day_added_YYMMDD; |
|
| 40 | + public $scheduled_for_YYMMDD; |
|
| 41 | + public $fields; |
|
| 42 | + public $offset; |
|
| 43 | + public $limit; |
|
| 44 | + public $query; |
|
| 45 | 45 | |
| 46 | - public $created_timestamp; |
|
| 47 | - public $order_status_id; |
|
| 48 | - public $member_id; |
|
| 49 | - public $address_state_id; |
|
| 50 | - public $address_country_id; |
|
| 51 | - public $address_zip; |
|
| 52 | - public $in_route_count; |
|
| 53 | - public $last_visited_timestamp; |
|
| 54 | - public $last_routed_timestamp; |
|
| 55 | - public $local_timezone_string; |
|
| 56 | - public $is_validated; |
|
| 57 | - public $is_pending; |
|
| 58 | - public $is_accepted; |
|
| 59 | - public $is_started; |
|
| 60 | - public $is_completed; |
|
| 61 | - public $custom_user_fields; |
|
| 46 | + public $created_timestamp; |
|
| 47 | + public $order_status_id; |
|
| 48 | + public $member_id; |
|
| 49 | + public $address_state_id; |
|
| 50 | + public $address_country_id; |
|
| 51 | + public $address_zip; |
|
| 52 | + public $in_route_count; |
|
| 53 | + public $last_visited_timestamp; |
|
| 54 | + public $last_routed_timestamp; |
|
| 55 | + public $local_timezone_string; |
|
| 56 | + public $is_validated; |
|
| 57 | + public $is_pending; |
|
| 58 | + public $is_accepted; |
|
| 59 | + public $is_started; |
|
| 60 | + public $is_completed; |
|
| 61 | + public $custom_user_fields; |
|
| 62 | 62 | |
| 63 | - public $addresses = array(); |
|
| 63 | + public $addresses = array(); |
|
| 64 | 64 | |
| 65 | - public static function fromArray(array $params) { |
|
| 66 | - $order = new Order(); |
|
| 67 | - foreach ($params as $key => $value) { |
|
| 68 | - if (property_exists($order, $key)) { |
|
| 69 | - $order->{$key} = $value; |
|
| 70 | - } |
|
| 71 | - } |
|
| 65 | + public static function fromArray(array $params) { |
|
| 66 | + $order = new Order(); |
|
| 67 | + foreach ($params as $key => $value) { |
|
| 68 | + if (property_exists($order, $key)) { |
|
| 69 | + $order->{$key} = $value; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - return $order; |
|
| 74 | - } |
|
| 73 | + return $order; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * @param Order $params |
|
| 78 | - */ |
|
| 79 | - public static function addOrder($params) |
|
| 80 | - { |
|
| 81 | - $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', 'order_id', |
|
| 82 | - 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
| 76 | + /** |
|
| 77 | + * @param Order $params |
|
| 78 | + */ |
|
| 79 | + public static function addOrder($params) |
|
| 80 | + { |
|
| 81 | + $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', 'order_id', |
|
| 82 | + 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
| 83 | 83 | |
| 84 | - $allBodyFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
| 84 | + $allBodyFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
| 85 | 85 | |
| 86 | - $response = Route4Me::makeRequst(array( |
|
| 87 | - 'url' => Endpoint::ORDER_V4, |
|
| 88 | - 'method' => 'POST', |
|
| 89 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 90 | - )); |
|
| 86 | + $response = Route4Me::makeRequst(array( |
|
| 87 | + 'url' => Endpoint::ORDER_V4, |
|
| 88 | + 'method' => 'POST', |
|
| 89 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 90 | + )); |
|
| 91 | 91 | |
| 92 | - return $response; |
|
| 93 | - } |
|
| 92 | + return $response; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - public static function addOrder2Route($params) |
|
| 96 | - { |
|
| 97 | - $allQueryFields = array('route_id', 'redirect'); |
|
| 98 | - $allBodyFields = array('addresses'); |
|
| 95 | + public static function addOrder2Route($params) |
|
| 96 | + { |
|
| 97 | + $allQueryFields = array('route_id', 'redirect'); |
|
| 98 | + $allBodyFields = array('addresses'); |
|
| 99 | 99 | |
| 100 | - $response = Route4Me::makeRequst(array( |
|
| 101 | - 'url' => Endpoint::ROUTE_V4, |
|
| 102 | - 'method' => 'PUT', |
|
| 103 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 104 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 105 | - )); |
|
| 100 | + $response = Route4Me::makeRequst(array( |
|
| 101 | + 'url' => Endpoint::ROUTE_V4, |
|
| 102 | + 'method' => 'PUT', |
|
| 103 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 104 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 105 | + )); |
|
| 106 | 106 | |
| 107 | - return $response; |
|
| 108 | - } |
|
| 107 | + return $response; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - public static function addOrder2Optimization($params) |
|
| 111 | - { |
|
| 112 | - $allQueryFields = array('optimization_problem_id', 'redirect', 'device_type'); |
|
| 113 | - $allBodyFields = array('addresses'); |
|
| 110 | + public static function addOrder2Optimization($params) |
|
| 111 | + { |
|
| 112 | + $allQueryFields = array('optimization_problem_id', 'redirect', 'device_type'); |
|
| 113 | + $allBodyFields = array('addresses'); |
|
| 114 | 114 | |
| 115 | - $response = Route4Me::makeRequst(array( |
|
| 116 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
| 117 | - 'method' => 'PUT', |
|
| 118 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 119 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 120 | - )); |
|
| 115 | + $response = Route4Me::makeRequst(array( |
|
| 116 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
| 117 | + 'method' => 'PUT', |
|
| 118 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 119 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 120 | + )); |
|
| 121 | 121 | |
| 122 | - return $response; |
|
| 123 | - } |
|
| 122 | + return $response; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - public static function getOrder($params) |
|
| 126 | - { |
|
| 127 | - $allQueryFields = array('order_id', 'fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit'); |
|
| 125 | + public static function getOrder($params) |
|
| 126 | + { |
|
| 127 | + $allQueryFields = array('order_id', 'fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit'); |
|
| 128 | 128 | |
| 129 | - $response = Route4Me::makeRequst(array( |
|
| 130 | - 'url' => Endpoint::ORDER_V4, |
|
| 131 | - 'method' => 'GET', |
|
| 132 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 133 | - )); |
|
| 129 | + $response = Route4Me::makeRequst(array( |
|
| 130 | + 'url' => Endpoint::ORDER_V4, |
|
| 131 | + 'method' => 'GET', |
|
| 132 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 133 | + )); |
|
| 134 | 134 | |
| 135 | - return $response; |
|
| 136 | - } |
|
| 135 | + return $response; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - public static function getOrders($params) |
|
| 139 | - { |
|
| 140 | - $allQueryFields = array('offset', 'limit'); |
|
| 138 | + public static function getOrders($params) |
|
| 139 | + { |
|
| 140 | + $allQueryFields = array('offset', 'limit'); |
|
| 141 | 141 | |
| 142 | - $response = Route4Me::makeRequst(array( |
|
| 143 | - 'url' => Endpoint::ORDER_V4, |
|
| 144 | - 'method' => 'GET', |
|
| 145 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 146 | - )); |
|
| 142 | + $response = Route4Me::makeRequst(array( |
|
| 143 | + 'url' => Endpoint::ORDER_V4, |
|
| 144 | + 'method' => 'GET', |
|
| 145 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 146 | + )); |
|
| 147 | 147 | |
| 148 | - return $response; |
|
| 149 | - } |
|
| 148 | + return $response; |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - public function getRandomOrderId($offset, $limit) |
|
| 152 | - { |
|
| 153 | - $randomOrder = $this->getRandomOrder($offset, $limit); |
|
| 151 | + public function getRandomOrderId($offset, $limit) |
|
| 152 | + { |
|
| 153 | + $randomOrder = $this->getRandomOrder($offset, $limit); |
|
| 154 | 154 | |
| 155 | - if (is_null($randomOrder) || !isset($randomOrder)) { |
|
| 156 | - return null; |
|
| 157 | - } |
|
| 155 | + if (is_null($randomOrder) || !isset($randomOrder)) { |
|
| 156 | + return null; |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - return $randomOrder['order_id']; |
|
| 160 | - } |
|
| 159 | + return $randomOrder['order_id']; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - public function getRandomOrder($offset, $limit) |
|
| 163 | - { |
|
| 164 | - $params = array('offset' => $offset, 'limit' => $limit); |
|
| 162 | + public function getRandomOrder($offset, $limit) |
|
| 163 | + { |
|
| 164 | + $params = array('offset' => $offset, 'limit' => $limit); |
|
| 165 | 165 | |
| 166 | - $orders = self::getOrders($params); |
|
| 166 | + $orders = self::getOrders($params); |
|
| 167 | 167 | |
| 168 | - if (is_null($orders) || !isset($orders['results'])) { |
|
| 169 | - return null; |
|
| 170 | - } |
|
| 168 | + if (is_null($orders) || !isset($orders['results'])) { |
|
| 169 | + return null; |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - $randomIndex = rand(0, sizeof($orders['results']) - 1); |
|
| 172 | + $randomIndex = rand(0, sizeof($orders['results']) - 1); |
|
| 173 | 173 | |
| 174 | - $order = $orders['results'][$randomIndex]; |
|
| 174 | + $order = $orders['results'][$randomIndex]; |
|
| 175 | 175 | |
| 176 | - return $order; |
|
| 177 | - } |
|
| 176 | + return $order; |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - public static function removeOrder($params) |
|
| 180 | - { |
|
| 181 | - $allBodyFields = array('order_ids'); |
|
| 179 | + public static function removeOrder($params) |
|
| 180 | + { |
|
| 181 | + $allBodyFields = array('order_ids'); |
|
| 182 | 182 | |
| 183 | - $response = Route4Me::makeRequst(array( |
|
| 184 | - 'url' => Endpoint::ORDER_V4, |
|
| 185 | - 'method' => 'DELETE', |
|
| 186 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 187 | - )); |
|
| 183 | + $response = Route4Me::makeRequst(array( |
|
| 184 | + 'url' => Endpoint::ORDER_V4, |
|
| 185 | + 'method' => 'DELETE', |
|
| 186 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 187 | + )); |
|
| 188 | 188 | |
| 189 | - return $response; |
|
| 190 | - } |
|
| 189 | + return $response; |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | - public static function updateOrder($params) |
|
| 193 | - { |
|
| 194 | - $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', |
|
| 195 | - 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
| 192 | + public static function updateOrder($params) |
|
| 193 | + { |
|
| 194 | + $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', |
|
| 195 | + 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
| 196 | 196 | |
| 197 | - $allBodyFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
| 197 | + $allBodyFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
| 198 | 198 | |
| 199 | - $response = Route4Me::makeRequst(array( |
|
| 200 | - 'url' => Endpoint::ORDER_V4, |
|
| 201 | - 'method' => 'PUT', |
|
| 202 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 203 | - )); |
|
| 199 | + $response = Route4Me::makeRequst(array( |
|
| 200 | + 'url' => Endpoint::ORDER_V4, |
|
| 201 | + 'method' => 'PUT', |
|
| 202 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 203 | + )); |
|
| 204 | 204 | |
| 205 | - return $response; |
|
| 206 | - } |
|
| 205 | + return $response; |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - public static function searchOrder($params) |
|
| 209 | - { |
|
| 210 | - $allQueryFields = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
| 208 | + public static function searchOrder($params) |
|
| 209 | + { |
|
| 210 | + $allQueryFields = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
| 211 | 211 | |
| 212 | - $response = Route4Me::makeRequst(array( |
|
| 213 | - 'url' => Endpoint::ORDER_V4, |
|
| 214 | - 'method' => 'GET', |
|
| 215 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 216 | - )); |
|
| 212 | + $response = Route4Me::makeRequst(array( |
|
| 213 | + 'url' => Endpoint::ORDER_V4, |
|
| 214 | + 'method' => 'GET', |
|
| 215 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 216 | + )); |
|
| 217 | 217 | |
| 218 | - return $response; |
|
| 219 | - } |
|
| 218 | + return $response; |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - public static function validateCoordinate($coord) |
|
| 222 | - { |
|
| 223 | - $key = key($coord); |
|
| 221 | + public static function validateCoordinate($coord) |
|
| 222 | + { |
|
| 223 | + $key = key($coord); |
|
| 224 | 224 | |
| 225 | - if (!is_numeric($coord[$key])) { |
|
| 226 | - return false; |
|
| 227 | - } |
|
| 225 | + if (!is_numeric($coord[$key])) { |
|
| 226 | + return false; |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - switch ($key) { |
|
| 230 | - case 'cached_lat': |
|
| 231 | - case 'curbside_lat': |
|
| 232 | - if ($coord[$key]>90 || $coord[$key]<-90) { |
|
| 233 | - return false; |
|
| 234 | - } |
|
| 235 | - break; |
|
| 236 | - case 'cached_lng': |
|
| 237 | - case 'curbside_lng': |
|
| 238 | - if ($coord[$key]>180 || $coord[$key]<-180) { |
|
| 239 | - return false; |
|
| 240 | - } |
|
| 241 | - break; |
|
| 242 | - } |
|
| 229 | + switch ($key) { |
|
| 230 | + case 'cached_lat': |
|
| 231 | + case 'curbside_lat': |
|
| 232 | + if ($coord[$key]>90 || $coord[$key]<-90) { |
|
| 233 | + return false; |
|
| 234 | + } |
|
| 235 | + break; |
|
| 236 | + case 'cached_lng': |
|
| 237 | + case 'curbside_lng': |
|
| 238 | + if ($coord[$key]>180 || $coord[$key]<-180) { |
|
| 239 | + return false; |
|
| 240 | + } |
|
| 241 | + break; |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - return true; |
|
| 245 | - } |
|
| 244 | + return true; |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
| 248 | - { |
|
| 249 | - $max_line_length = 512; |
|
| 250 | - $delemietr = ','; |
|
| 247 | + public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
| 248 | + { |
|
| 249 | + $max_line_length = 512; |
|
| 250 | + $delemietr = ','; |
|
| 251 | 251 | |
| 252 | - $results = array(); |
|
| 253 | - $results['fail'] = array(); |
|
| 254 | - $results['success'] = array(); |
|
| 252 | + $results = array(); |
|
| 253 | + $results['fail'] = array(); |
|
| 254 | + $results['success'] = array(); |
|
| 255 | 255 | |
| 256 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
| 256 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
| 257 | 257 | |
| 258 | - $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', 'order_id', |
|
| 259 | - 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
| 258 | + $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', 'order_id', |
|
| 259 | + 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
| 260 | 260 | |
| 261 | - $allOrderFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
| 261 | + $allOrderFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
| 262 | 262 | |
| 263 | - if (!empty($columns)) { |
|
| 264 | - array_push($results['fail'],'Empty CSV table'); |
|
| 265 | - return ($results); |
|
| 266 | - } |
|
| 263 | + if (!empty($columns)) { |
|
| 264 | + array_push($results['fail'],'Empty CSV table'); |
|
| 265 | + return ($results); |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - $iRow=1; |
|
| 268 | + $iRow=1; |
|
| 269 | 269 | |
| 270 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
| 271 | - if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
|
| 270 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
| 271 | + if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
|
| 272 | 272 | |
| 273 | - $cached_lat = 0.000; |
|
| 274 | - $cached_lng = 0.000; |
|
| 273 | + $cached_lat = 0.000; |
|
| 274 | + $cached_lng = 0.000; |
|
| 275 | 275 | |
| 276 | - foreach (array('cached_lat', 'cached_lng', 'curbside_lat', 'curbside_lng') as $coord) { |
|
| 277 | - if (!$this->validateCoordinate(array($coord => $rows[$ordersFieldsMapping[$coord]]))) { |
|
| 278 | - array_push($results['fail'], "$iRow --> Wrong "+$coord); |
|
| 279 | - $iRow++; |
|
| 280 | - continue; |
|
| 281 | - } else { |
|
| 282 | - switch ($coord) { |
|
| 283 | - case 'cached_lat': |
|
| 284 | - $cached_lat = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
| 285 | - break; |
|
| 286 | - case 'cached_lng': |
|
| 287 | - $cached_lng = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
| 288 | - break; |
|
| 289 | - } |
|
| 290 | - } |
|
| 291 | - } |
|
| 276 | + foreach (array('cached_lat', 'cached_lng', 'curbside_lat', 'curbside_lng') as $coord) { |
|
| 277 | + if (!$this->validateCoordinate(array($coord => $rows[$ordersFieldsMapping[$coord]]))) { |
|
| 278 | + array_push($results['fail'], "$iRow --> Wrong "+$coord); |
|
| 279 | + $iRow++; |
|
| 280 | + continue; |
|
| 281 | + } else { |
|
| 282 | + switch ($coord) { |
|
| 283 | + case 'cached_lat': |
|
| 284 | + $cached_lat = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
| 285 | + break; |
|
| 286 | + case 'cached_lng': |
|
| 287 | + $cached_lng = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
| 288 | + break; |
|
| 289 | + } |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - $address = $rows[$ordersFieldsMapping['address_1']]; |
|
| 293 | + $address = $rows[$ordersFieldsMapping['address_1']]; |
|
| 294 | 294 | |
| 295 | - foreach (array('order_city', 'order_state_id', 'order_zip_code', 'order_country_id') as $addressPart) { |
|
| 296 | - if (isset($ordersFieldsMapping[$addressPart])) { |
|
| 297 | - $address .= ', '.$rows[$ordersFieldsMapping[$addressPart]]; |
|
| 298 | - } |
|
| 299 | - } |
|
| 295 | + foreach (array('order_city', 'order_state_id', 'order_zip_code', 'order_country_id') as $addressPart) { |
|
| 296 | + if (isset($ordersFieldsMapping[$addressPart])) { |
|
| 297 | + $address .= ', '.$rows[$ordersFieldsMapping[$addressPart]]; |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
| 301 | + echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
| 302 | 302 | |
| 303 | - $parametersArray = array(); |
|
| 303 | + $parametersArray = array(); |
|
| 304 | 304 | |
| 305 | - $parametersArray["cached_lat"] = $cached_lat; |
|
| 306 | - $parametersArray["cached_lng"] = $cached_lng; |
|
| 305 | + $parametersArray["cached_lat"] = $cached_lat; |
|
| 306 | + $parametersArray["cached_lng"] = $cached_lng; |
|
| 307 | 307 | |
| 308 | 308 | |
| 309 | - foreach ($allOrderFields as $orderField) { |
|
| 310 | - if (isset($ordersFieldsMapping[$orderField])) { |
|
| 311 | - $parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]]; |
|
| 312 | - } |
|
| 313 | - } |
|
| 309 | + foreach ($allOrderFields as $orderField) { |
|
| 310 | + if (isset($ordersFieldsMapping[$orderField])) { |
|
| 311 | + $parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]]; |
|
| 312 | + } |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - $orderParameters = Order::fromArray($parametersArray); |
|
| 315 | + $orderParameters = Order::fromArray($parametersArray); |
|
| 316 | 316 | |
| 317 | - $order = new Order(); |
|
| 317 | + $order = new Order(); |
|
| 318 | 318 | |
| 319 | - $orderResults = $order->addOrder($orderParameters); |
|
| 319 | + $orderResults = $order->addOrder($orderParameters); |
|
| 320 | 320 | |
| 321 | - array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
| 322 | - } else { |
|
| 323 | - array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
| 324 | - } |
|
| 321 | + array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
| 322 | + } else { |
|
| 323 | + array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | - $iRow++; |
|
| 327 | - } |
|
| 328 | - } |
|
| 326 | + $iRow++; |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | 329 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | public static function getTerritory($params) |
| 42 | 42 | { |
| 43 | - $allQueryFields = array('territory_id', 'addresses'); |
|
| 43 | + $allQueryFields = array('territory_id', 'addresses'); |
|
| 44 | 44 | |
| 45 | 45 | $territory = Route4Me::makeRequst(array( |
| 46 | 46 | 'url' => Endpoint::TERRITORY_V4, |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | public static function getTerritories($params) |
| 55 | 55 | { |
| 56 | - $allQueryFields = array('offset', 'limit', 'addresses'); |
|
| 56 | + $allQueryFields = array('offset', 'limit', 'addresses'); |
|
| 57 | 57 | |
| 58 | 58 | $response = Route4Me::makeRequst(array( |
| 59 | 59 | 'url' => Endpoint::TERRITORY_V4, |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | public static function addTerritory($params) |
| 68 | 68 | { |
| 69 | - $allBodyFields = array('territory_name', 'member_id', 'territory_color', 'territory'); |
|
| 69 | + $allBodyFields = array('territory_name', 'member_id', 'territory_color', 'territory'); |
|
| 70 | 70 | |
| 71 | 71 | $response = Route4Me::makeRequst(array( |
| 72 | 72 | 'url' => Endpoint::TERRITORY_V4, |
@@ -92,14 +92,14 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | public function updateTerritory($params) |
| 94 | 94 | { |
| 95 | - $allQueryFields = array('territory_id'); |
|
| 96 | - $allBodyFields = array('territory_name', 'member_id', 'territory_color', 'territory'); |
|
| 95 | + $allQueryFields = array('territory_id'); |
|
| 96 | + $allBodyFields = array('territory_name', 'member_id', 'territory_color', 'territory'); |
|
| 97 | 97 | |
| 98 | 98 | $response = Route4Me::makeRequst(array( |
| 99 | 99 | 'url' => Endpoint::TERRITORY_V4, |
| 100 | 100 | 'method' => 'PUT', |
| 101 | 101 | 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
| 102 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 102 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 103 | 103 | )); |
| 104 | 104 | |
| 105 | 105 | return $response; |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | { |
| 20 | 20 | $geocoding = new Geocoding(); |
| 21 | 21 | |
| 22 | - foreach($params as $key => $value) { |
|
| 22 | + foreach ($params as $key => $value) { |
|
| 23 | 23 | if (property_exists($geocoding, $key)) { |
| 24 | 24 | $geocoding->{$key} = $value; |
| 25 | 25 | } |
@@ -6,109 +6,109 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Geocoding extends Common |
| 8 | 8 | { |
| 9 | - public $strExportFormat; |
|
| 10 | - public $format; |
|
| 11 | - public $addresses; |
|
| 12 | - public $pk; |
|
| 13 | - public $offset; |
|
| 14 | - public $limit; |
|
| 15 | - public $housenumber; |
|
| 16 | - public $zipcode; |
|
| 9 | + public $strExportFormat; |
|
| 10 | + public $format; |
|
| 11 | + public $addresses; |
|
| 12 | + public $pk; |
|
| 13 | + public $offset; |
|
| 14 | + public $limit; |
|
| 15 | + public $housenumber; |
|
| 16 | + public $zipcode; |
|
| 17 | 17 | |
| 18 | - public static function fromArray(array $params) |
|
| 19 | - { |
|
| 20 | - $geocoding = new Geocoding(); |
|
| 18 | + public static function fromArray(array $params) |
|
| 19 | + { |
|
| 20 | + $geocoding = new Geocoding(); |
|
| 21 | 21 | |
| 22 | - foreach($params as $key => $value) { |
|
| 23 | - if (property_exists($geocoding, $key)) { |
|
| 24 | - $geocoding->{$key} = $value; |
|
| 25 | - } |
|
| 26 | - } |
|
| 22 | + foreach($params as $key => $value) { |
|
| 23 | + if (property_exists($geocoding, $key)) { |
|
| 24 | + $geocoding->{$key} = $value; |
|
| 25 | + } |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - return $geocoding; |
|
| 29 | - } |
|
| 28 | + return $geocoding; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - public static function forwardGeocoding($params) |
|
| 32 | - { |
|
| 33 | - $allBodyFields = array('strExportFormat', 'addresses'); |
|
| 31 | + public static function forwardGeocoding($params) |
|
| 32 | + { |
|
| 33 | + $allBodyFields = array('strExportFormat', 'addresses'); |
|
| 34 | 34 | |
| 35 | - $fgCoding = Route4Me::makeRequst(array( |
|
| 36 | - 'url' => Endpoint::GEOCODER, |
|
| 37 | - 'method' => 'POST', |
|
| 38 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 39 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 40 | - )); |
|
| 35 | + $fgCoding = Route4Me::makeRequst(array( |
|
| 36 | + 'url' => Endpoint::GEOCODER, |
|
| 37 | + 'method' => 'POST', |
|
| 38 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 39 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 40 | + )); |
|
| 41 | 41 | |
| 42 | - return $fgCoding; |
|
| 43 | - } |
|
| 42 | + return $fgCoding; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public static function reverseGeocoding($params) |
|
| 46 | - { |
|
| 47 | - $allQueryFields = array('format', 'addresses', 'detailed'); |
|
| 45 | + public static function reverseGeocoding($params) |
|
| 46 | + { |
|
| 47 | + $allQueryFields = array('format', 'addresses', 'detailed'); |
|
| 48 | 48 | |
| 49 | - $fgcoding = Route4Me::makeRequst(array( |
|
| 50 | - 'url' => Endpoint::GEOCODER, |
|
| 51 | - 'method' => 'POST', |
|
| 52 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 53 | - )); |
|
| 49 | + $fgcoding = Route4Me::makeRequst(array( |
|
| 50 | + 'url' => Endpoint::GEOCODER, |
|
| 51 | + 'method' => 'POST', |
|
| 52 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 53 | + )); |
|
| 54 | 54 | |
| 55 | - return $fgcoding; |
|
| 56 | - } |
|
| 55 | + return $fgcoding; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public static function getStreetData($params) |
|
| 59 | - { |
|
| 60 | - Route4Me::setBaseUrl(Endpoint::STREET_DATA); |
|
| 58 | + public static function getStreetData($params) |
|
| 59 | + { |
|
| 60 | + Route4Me::setBaseUrl(Endpoint::STREET_DATA); |
|
| 61 | 61 | |
| 62 | - $allPathFields = array('pk', 'offset', 'limit'); |
|
| 62 | + $allPathFields = array('pk', 'offset', 'limit'); |
|
| 63 | 63 | |
| 64 | - $url_query = Route4Me::generateUrlPath($allPathFields, $params); |
|
| 64 | + $url_query = Route4Me::generateUrlPath($allPathFields, $params); |
|
| 65 | 65 | |
| 66 | - $query = array(); |
|
| 66 | + $query = array(); |
|
| 67 | 67 | |
| 68 | - $response = Route4Me::makeRequst(array( |
|
| 69 | - 'url' => $url_query, |
|
| 70 | - 'method' => 'GET', |
|
| 71 | - 'query' => $query |
|
| 72 | - )); |
|
| 68 | + $response = Route4Me::makeRequst(array( |
|
| 69 | + 'url' => $url_query, |
|
| 70 | + 'method' => 'GET', |
|
| 71 | + 'query' => $query |
|
| 72 | + )); |
|
| 73 | 73 | |
| 74 | - return $response; |
|
| 75 | - } |
|
| 74 | + return $response; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - public static function getZipCode($params) |
|
| 78 | - { |
|
| 79 | - Route4Me::setBaseUrl(Endpoint::STREET_DATA_ZIPCODE); |
|
| 77 | + public static function getZipCode($params) |
|
| 78 | + { |
|
| 79 | + Route4Me::setBaseUrl(Endpoint::STREET_DATA_ZIPCODE); |
|
| 80 | 80 | |
| 81 | - $allPathFields = array('zipcode', 'offset', 'limit'); |
|
| 81 | + $allPathFields = array('zipcode', 'offset', 'limit'); |
|
| 82 | 82 | |
| 83 | - $url_query = Route4Me::generateUrlPath($allPathFields, $params); |
|
| 83 | + $url_query = Route4Me::generateUrlPath($allPathFields, $params); |
|
| 84 | 84 | |
| 85 | - $query = array(); |
|
| 85 | + $query = array(); |
|
| 86 | 86 | |
| 87 | - $response = Route4Me::makeRequst(array( |
|
| 88 | - 'url' => $url_query, |
|
| 89 | - 'method' => 'GET', |
|
| 90 | - 'query' => $query |
|
| 91 | - )); |
|
| 87 | + $response = Route4Me::makeRequst(array( |
|
| 88 | + 'url' => $url_query, |
|
| 89 | + 'method' => 'GET', |
|
| 90 | + 'query' => $query |
|
| 91 | + )); |
|
| 92 | 92 | |
| 93 | - return $response; |
|
| 94 | - } |
|
| 93 | + return $response; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - public static function getService($params) |
|
| 97 | - { |
|
| 98 | - Route4Me::setBaseUrl(Endpoint::STREET_DATA_SERVICE); |
|
| 96 | + public static function getService($params) |
|
| 97 | + { |
|
| 98 | + Route4Me::setBaseUrl(Endpoint::STREET_DATA_SERVICE); |
|
| 99 | 99 | |
| 100 | - $allPathFields = array('zipcode', 'housenumber', 'offset', 'limit'); |
|
| 100 | + $allPathFields = array('zipcode', 'housenumber', 'offset', 'limit'); |
|
| 101 | 101 | |
| 102 | - $url_query = Route4Me::generateUrlPath($allPathFields, $params); |
|
| 102 | + $url_query = Route4Me::generateUrlPath($allPathFields, $params); |
|
| 103 | 103 | |
| 104 | - $query = array(); |
|
| 104 | + $query = array(); |
|
| 105 | 105 | |
| 106 | - $response = Route4Me::makeRequst(array( |
|
| 107 | - 'url' => $url_query, |
|
| 108 | - 'method' => 'GET', |
|
| 109 | - 'query' => $query |
|
| 110 | - )); |
|
| 106 | + $response = Route4Me::makeRequst(array( |
|
| 107 | + 'url' => $url_query, |
|
| 108 | + 'method' => 'GET', |
|
| 109 | + 'query' => $query |
|
| 110 | + )); |
|
| 111 | 111 | |
| 112 | - return $response; |
|
| 113 | - } |
|
| 112 | + return $response; |
|
| 113 | + } |
|
| 114 | 114 | } |
@@ -171,7 +171,7 @@ |
||
| 171 | 171 | |
| 172 | 172 | public function mergeRoutes($params) |
| 173 | 173 | { |
| 174 | - $allBodyFields = array('route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng'); |
|
| 174 | + $allBodyFields = array('route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng'); |
|
| 175 | 175 | |
| 176 | 176 | $result = Route4Me::makeRequst(array( |
| 177 | 177 | 'url' => Endpoint::ROUTES_MERGE, |
@@ -9,410 +9,410 @@ |
||
| 9 | 9 | |
| 10 | 10 | class Route extends Common |
| 11 | 11 | { |
| 12 | - public $route_id; |
|
| 13 | - public $member_id; |
|
| 14 | - public $route_destination_id; |
|
| 15 | - public $optimization_problem_id; |
|
| 16 | - public $vehicle_alias; |
|
| 17 | - public $driver_alias; |
|
| 18 | - public $trip_distance; |
|
| 19 | - public $mpg; |
|
| 20 | - public $gas_price; |
|
| 21 | - public $route_duration_sec; |
|
| 22 | - public $destination_count; |
|
| 23 | - public $parameters; |
|
| 24 | - public $addresses = array(); |
|
| 25 | - public $links = array(); |
|
| 26 | - public $directions = array(); |
|
| 27 | - public $path = array(); |
|
| 28 | - public $tracking_history = array(); |
|
| 29 | - public $recipient_email; |
|
| 30 | - public $httpheaders; |
|
| 31 | - public $is_unrouted; |
|
| 32 | - public $time; |
|
| 12 | + public $route_id; |
|
| 13 | + public $member_id; |
|
| 14 | + public $route_destination_id; |
|
| 15 | + public $optimization_problem_id; |
|
| 16 | + public $vehicle_alias; |
|
| 17 | + public $driver_alias; |
|
| 18 | + public $trip_distance; |
|
| 19 | + public $mpg; |
|
| 20 | + public $gas_price; |
|
| 21 | + public $route_duration_sec; |
|
| 22 | + public $destination_count; |
|
| 23 | + public $parameters; |
|
| 24 | + public $addresses = array(); |
|
| 25 | + public $links = array(); |
|
| 26 | + public $directions = array(); |
|
| 27 | + public $path = array(); |
|
| 28 | + public $tracking_history = array(); |
|
| 29 | + public $recipient_email; |
|
| 30 | + public $httpheaders; |
|
| 31 | + public $is_unrouted; |
|
| 32 | + public $time; |
|
| 33 | 33 | |
| 34 | - public $dev_lat; |
|
| 35 | - public $dev_lng; |
|
| 34 | + public $dev_lat; |
|
| 35 | + public $dev_lng; |
|
| 36 | 36 | |
| 37 | - public $user_route_rating; |
|
| 38 | - public $member_email; |
|
| 39 | - public $member_first_name; |
|
| 40 | - public $member_last_name; |
|
| 41 | - public $channel_name; |
|
| 42 | - public $route_cost; |
|
| 43 | - public $route_revenue; |
|
| 44 | - public $net_revenue_per_distance_unit; |
|
| 45 | - public $created_timestamp; |
|
| 46 | - public $planned_total_route_duration; |
|
| 47 | - public $actual_travel_distance; |
|
| 48 | - public $actual_travel_time; |
|
| 49 | - public $actual_footsteps; |
|
| 50 | - public $working_time; |
|
| 51 | - public $driving_time; |
|
| 52 | - public $idling_time; |
|
| 53 | - public $paying_miles; |
|
| 54 | - public $geofence_polygon_type; |
|
| 55 | - public $geofence_polygon_size; |
|
| 56 | - public $notes; |
|
| 57 | - public $member_config_storage; |
|
| 37 | + public $user_route_rating; |
|
| 38 | + public $member_email; |
|
| 39 | + public $member_first_name; |
|
| 40 | + public $member_last_name; |
|
| 41 | + public $channel_name; |
|
| 42 | + public $route_cost; |
|
| 43 | + public $route_revenue; |
|
| 44 | + public $net_revenue_per_distance_unit; |
|
| 45 | + public $created_timestamp; |
|
| 46 | + public $planned_total_route_duration; |
|
| 47 | + public $actual_travel_distance; |
|
| 48 | + public $actual_travel_time; |
|
| 49 | + public $actual_footsteps; |
|
| 50 | + public $working_time; |
|
| 51 | + public $driving_time; |
|
| 52 | + public $idling_time; |
|
| 53 | + public $paying_miles; |
|
| 54 | + public $geofence_polygon_type; |
|
| 55 | + public $geofence_polygon_size; |
|
| 56 | + public $notes; |
|
| 57 | + public $member_config_storage; |
|
| 58 | 58 | |
| 59 | - public static function fromArray(array $params) |
|
| 60 | - { |
|
| 61 | - $route = new Route(); |
|
| 62 | - $route->route_id = Common::getValue($params, 'route_id'); |
|
| 63 | - $route->member_id = Common::getValue($params, 'member_id'); |
|
| 64 | - $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
| 65 | - $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); |
|
| 66 | - $route->driver_alias = Common::getValue($params, 'driver_alias'); |
|
| 67 | - $route->trip_distance = Common::getValue($params, 'trip_distance'); |
|
| 68 | - $route->mpg = Common::getValue($params, 'mpg'); |
|
| 69 | - $route->gas_price = Common::getValue($params, 'gas_price'); |
|
| 70 | - $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec'); |
|
| 71 | - $route->destination_count = Common::getvalue($params, 'destination_count'); |
|
| 72 | - $route->is_unrouted = Common::getvalue($params, 'is_unrouted'); |
|
| 59 | + public static function fromArray(array $params) |
|
| 60 | + { |
|
| 61 | + $route = new Route(); |
|
| 62 | + $route->route_id = Common::getValue($params, 'route_id'); |
|
| 63 | + $route->member_id = Common::getValue($params, 'member_id'); |
|
| 64 | + $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
| 65 | + $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); |
|
| 66 | + $route->driver_alias = Common::getValue($params, 'driver_alias'); |
|
| 67 | + $route->trip_distance = Common::getValue($params, 'trip_distance'); |
|
| 68 | + $route->mpg = Common::getValue($params, 'mpg'); |
|
| 69 | + $route->gas_price = Common::getValue($params, 'gas_price'); |
|
| 70 | + $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec'); |
|
| 71 | + $route->destination_count = Common::getvalue($params, 'destination_count'); |
|
| 72 | + $route->is_unrouted = Common::getvalue($params, 'is_unrouted'); |
|
| 73 | 73 | |
| 74 | - // Make RouteParameters |
|
| 75 | - if (isset($params['parameters'])) { |
|
| 76 | - $route->parameters = RouteParameters::fromArray($params['parameters']); |
|
| 77 | - } |
|
| 74 | + // Make RouteParameters |
|
| 75 | + if (isset($params['parameters'])) { |
|
| 76 | + $route->parameters = RouteParameters::fromArray($params['parameters']); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - if (isset($params['addresses'])) { |
|
| 80 | - $addresses = array(); |
|
| 79 | + if (isset($params['addresses'])) { |
|
| 80 | + $addresses = array(); |
|
| 81 | 81 | |
| 82 | - foreach ($params['addresses'] as $address) { |
|
| 83 | - $addresses[] = Address::fromArray($address); |
|
| 84 | - } |
|
| 82 | + foreach ($params['addresses'] as $address) { |
|
| 83 | + $addresses[] = Address::fromArray($address); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - $route->addresses = $addresses; |
|
| 87 | - } |
|
| 86 | + $route->addresses = $addresses; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - $route->links = Common::getValue($params, 'links', array()); |
|
| 90 | - $route->directions = Common::getValue($params, 'directions', array()); |
|
| 91 | - $route->path = Common::getValue($params, 'path', array()); |
|
| 92 | - $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
| 89 | + $route->links = Common::getValue($params, 'links', array()); |
|
| 90 | + $route->directions = Common::getValue($params, 'directions', array()); |
|
| 91 | + $route->path = Common::getValue($params, 'path', array()); |
|
| 92 | + $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
| 93 | 93 | |
| 94 | - return $route; |
|
| 95 | - } |
|
| 94 | + return $route; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - public static function getRoutes($params = null) |
|
| 98 | - { |
|
| 99 | - $allQueryFields = array('route_id', 'route_path_output', 'query', 'directions', 'device_tracking_history', 'limit', 'offset'); |
|
| 97 | + public static function getRoutes($params = null) |
|
| 98 | + { |
|
| 99 | + $allQueryFields = array('route_id', 'route_path_output', 'query', 'directions', 'device_tracking_history', 'limit', 'offset'); |
|
| 100 | 100 | |
| 101 | - $result = Route4Me::makeRequst(array( |
|
| 102 | - 'url' => Endpoint::ROUTE_V4, |
|
| 103 | - 'method' => 'GET', |
|
| 104 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 105 | - )); |
|
| 101 | + $result = Route4Me::makeRequst(array( |
|
| 102 | + 'url' => Endpoint::ROUTE_V4, |
|
| 103 | + 'method' => 'GET', |
|
| 104 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 105 | + )); |
|
| 106 | 106 | |
| 107 | - if (isset($params['route_id'])) { |
|
| 108 | - return Route::fromArray($result); |
|
| 109 | - } else { |
|
| 110 | - $routes = array(); |
|
| 111 | - foreach ($result as $route) { |
|
| 112 | - $routes[] = Route::fromArray($route); |
|
| 113 | - } |
|
| 114 | - return $routes; |
|
| 115 | - } |
|
| 116 | - } |
|
| 107 | + if (isset($params['route_id'])) { |
|
| 108 | + return Route::fromArray($result); |
|
| 109 | + } else { |
|
| 110 | + $routes = array(); |
|
| 111 | + foreach ($result as $route) { |
|
| 112 | + $routes[] = Route::fromArray($route); |
|
| 113 | + } |
|
| 114 | + return $routes; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - public function getRoutePoints($params) |
|
| 119 | - { |
|
| 120 | - $allQueryFields = array('route_id', 'route_path_output', 'compress_path_points', 'directions'); |
|
| 118 | + public function getRoutePoints($params) |
|
| 119 | + { |
|
| 120 | + $allQueryFields = array('route_id', 'route_path_output', 'compress_path_points', 'directions'); |
|
| 121 | 121 | |
| 122 | - $result = Route4Me::makeRequst(array( |
|
| 123 | - 'url' => Endpoint::ROUTE_V4, |
|
| 124 | - 'method' => 'GET', |
|
| 125 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 126 | - )); |
|
| 122 | + $result = Route4Me::makeRequst(array( |
|
| 123 | + 'url' => Endpoint::ROUTE_V4, |
|
| 124 | + 'method' => 'GET', |
|
| 125 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 126 | + )); |
|
| 127 | 127 | |
| 128 | - return $result; |
|
| 129 | - } |
|
| 128 | + return $result; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - public function duplicateRoute($route_id) |
|
| 132 | - { |
|
| 133 | - $result = Route4Me::makeRequst(array( |
|
| 134 | - 'url' => Endpoint::ROUTE_DUPLICATE, |
|
| 135 | - 'method' => 'GET', |
|
| 136 | - 'query' => array( |
|
| 137 | - 'route_id' => $route_id, |
|
| 138 | - 'to' => 'none', |
|
| 139 | - ) |
|
| 140 | - )); |
|
| 131 | + public function duplicateRoute($route_id) |
|
| 132 | + { |
|
| 133 | + $result = Route4Me::makeRequst(array( |
|
| 134 | + 'url' => Endpoint::ROUTE_DUPLICATE, |
|
| 135 | + 'method' => 'GET', |
|
| 136 | + 'query' => array( |
|
| 137 | + 'route_id' => $route_id, |
|
| 138 | + 'to' => 'none', |
|
| 139 | + ) |
|
| 140 | + )); |
|
| 141 | 141 | |
| 142 | - return $result; |
|
| 143 | - } |
|
| 142 | + return $result; |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - public function resequenceRoute($params) |
|
| 146 | - { |
|
| 147 | - $allQueryFields = array('route_id', 'route_destination_id'); |
|
| 148 | - $allBodyFields = array('addresses'); |
|
| 145 | + public function resequenceRoute($params) |
|
| 146 | + { |
|
| 147 | + $allQueryFields = array('route_id', 'route_destination_id'); |
|
| 148 | + $allBodyFields = array('addresses'); |
|
| 149 | 149 | |
| 150 | - $result = Route4Me::makeRequst(array( |
|
| 151 | - 'url' => Endpoint::ROUTE_V4, |
|
| 152 | - 'method' => 'PUT', |
|
| 153 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 154 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 155 | - )); |
|
| 150 | + $result = Route4Me::makeRequst(array( |
|
| 151 | + 'url' => Endpoint::ROUTE_V4, |
|
| 152 | + 'method' => 'PUT', |
|
| 153 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 154 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 155 | + )); |
|
| 156 | 156 | |
| 157 | - return $result; |
|
| 158 | - } |
|
| 157 | + return $result; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - public function resequenceAllAddresses($params) |
|
| 161 | - { |
|
| 162 | - $allQueryFields = array('route_id', 'disable_optimization', 'optimize'); |
|
| 160 | + public function resequenceAllAddresses($params) |
|
| 161 | + { |
|
| 162 | + $allQueryFields = array('route_id', 'disable_optimization', 'optimize'); |
|
| 163 | 163 | |
| 164 | - $result = Route4Me::makeRequst(array( |
|
| 165 | - 'url' => Endpoint::REOPTIMIZE_V3_2, |
|
| 166 | - 'method' => 'GET', |
|
| 167 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 168 | - )); |
|
| 164 | + $result = Route4Me::makeRequst(array( |
|
| 165 | + 'url' => Endpoint::REOPTIMIZE_V3_2, |
|
| 166 | + 'method' => 'GET', |
|
| 167 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 168 | + )); |
|
| 169 | 169 | |
| 170 | - return $result; |
|
| 171 | - } |
|
| 170 | + return $result; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - public function mergeRoutes($params) |
|
| 174 | - { |
|
| 175 | - $allBodyFields = array('route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng'); |
|
| 173 | + public function mergeRoutes($params) |
|
| 174 | + { |
|
| 175 | + $allBodyFields = array('route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng'); |
|
| 176 | 176 | |
| 177 | - $result = Route4Me::makeRequst(array( |
|
| 178 | - 'url' => Endpoint::ROUTES_MERGE, |
|
| 179 | - 'method' => 'POST', |
|
| 180 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 181 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 182 | - )); |
|
| 177 | + $result = Route4Me::makeRequst(array( |
|
| 178 | + 'url' => Endpoint::ROUTES_MERGE, |
|
| 179 | + 'method' => 'POST', |
|
| 180 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 181 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 182 | + )); |
|
| 183 | 183 | |
| 184 | - return $result; |
|
| 185 | - } |
|
| 184 | + return $result; |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - public function shareRoute($params) |
|
| 188 | - { |
|
| 189 | - $allQueryFields = array('route_id', 'response_format'); |
|
| 190 | - $allBodyFields = array('recipient_email'); |
|
| 187 | + public function shareRoute($params) |
|
| 188 | + { |
|
| 189 | + $allQueryFields = array('route_id', 'response_format'); |
|
| 190 | + $allBodyFields = array('recipient_email'); |
|
| 191 | 191 | |
| 192 | - $result = Route4Me::makeRequst(array( |
|
| 193 | - 'url' => Endpoint::ROUTE_SHARE, |
|
| 194 | - 'method' => 'POST', |
|
| 195 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 196 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 197 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 198 | - )); |
|
| 192 | + $result = Route4Me::makeRequst(array( |
|
| 193 | + 'url' => Endpoint::ROUTE_SHARE, |
|
| 194 | + 'method' => 'POST', |
|
| 195 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 196 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 197 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 198 | + )); |
|
| 199 | 199 | |
| 200 | - return $result; |
|
| 201 | - } |
|
| 200 | + return $result; |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - // Returns random route_id from existing routes between $offset and $offset+$limit |
|
| 204 | - public function getRandomRouteId($offset, $limit) |
|
| 205 | - { |
|
| 206 | - $params = array( |
|
| 207 | - 'offset' => !is_null($offset) ? $offset : 0, |
|
| 208 | - 'limit' => !is_null($limit) ? $limit : 30 |
|
| 209 | - ); |
|
| 203 | + // Returns random route_id from existing routes between $offset and $offset+$limit |
|
| 204 | + public function getRandomRouteId($offset, $limit) |
|
| 205 | + { |
|
| 206 | + $params = array( |
|
| 207 | + 'offset' => !is_null($offset) ? $offset : 0, |
|
| 208 | + 'limit' => !is_null($limit) ? $limit : 30 |
|
| 209 | + ); |
|
| 210 | 210 | |
| 211 | - $routes = $this->getRoutes($params); |
|
| 211 | + $routes = $this->getRoutes($params); |
|
| 212 | 212 | |
| 213 | - if (is_null($routes) || sizeof($routes)<1) { |
|
| 214 | - echo "<br> There are no routes in the account. Please, create the routes first. <br>"; |
|
| 215 | - return null; |
|
| 216 | - } |
|
| 213 | + if (is_null($routes) || sizeof($routes)<1) { |
|
| 214 | + echo "<br> There are no routes in the account. Please, create the routes first. <br>"; |
|
| 215 | + return null; |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - $randomIndex = rand(0, sizeof($routes) - 1); |
|
| 218 | + $randomIndex = rand(0, sizeof($routes) - 1); |
|
| 219 | 219 | |
| 220 | - return $routes[$randomIndex]->route_id; |
|
| 221 | - } |
|
| 220 | + return $routes[$randomIndex]->route_id; |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - public function update() |
|
| 224 | - { |
|
| 225 | - $route = Route4Me::makeRequst(array( |
|
| 226 | - 'url' => Endpoint::ROUTE_V4, |
|
| 227 | - 'method' => 'PUT', |
|
| 228 | - 'query' => array( |
|
| 229 | - 'route_id' => isset($this->route_id) ? $this->route_id : null |
|
| 230 | - ), |
|
| 231 | - 'body' => array( |
|
| 232 | - 'parameters' => $this->parameters, |
|
| 233 | - ), |
|
| 234 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 235 | - )); |
|
| 223 | + public function update() |
|
| 224 | + { |
|
| 225 | + $route = Route4Me::makeRequst(array( |
|
| 226 | + 'url' => Endpoint::ROUTE_V4, |
|
| 227 | + 'method' => 'PUT', |
|
| 228 | + 'query' => array( |
|
| 229 | + 'route_id' => isset($this->route_id) ? $this->route_id : null |
|
| 230 | + ), |
|
| 231 | + 'body' => array( |
|
| 232 | + 'parameters' => $this->parameters, |
|
| 233 | + ), |
|
| 234 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 235 | + )); |
|
| 236 | 236 | |
| 237 | - return Route::fromArray($route); |
|
| 238 | - } |
|
| 237 | + return Route::fromArray($route); |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - public function updateAddress($address = null) |
|
| 241 | - { |
|
| 242 | - $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) |
|
| 243 | - : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); |
|
| 240 | + public function updateAddress($address = null) |
|
| 241 | + { |
|
| 242 | + $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) |
|
| 243 | + : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); |
|
| 244 | 244 | |
| 245 | - $result = Route4Me::makeRequst(array( |
|
| 246 | - 'url' => Endpoint::ADDRESS_V4, |
|
| 247 | - 'method' => 'PUT', |
|
| 248 | - 'query' => array( |
|
| 249 | - 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
| 250 | - 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
| 251 | - ), |
|
| 252 | - 'body' => $body, |
|
| 253 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 254 | - )); |
|
| 245 | + $result = Route4Me::makeRequst(array( |
|
| 246 | + 'url' => Endpoint::ADDRESS_V4, |
|
| 247 | + 'method' => 'PUT', |
|
| 248 | + 'query' => array( |
|
| 249 | + 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
| 250 | + 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
| 251 | + ), |
|
| 252 | + 'body' => $body, |
|
| 253 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 254 | + )); |
|
| 255 | 255 | |
| 256 | - return $result; |
|
| 257 | - } |
|
| 256 | + return $result; |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - public function updateRouteAddress() |
|
| 260 | - { |
|
| 261 | - $result = Route4Me::makeRequst(array( |
|
| 262 | - 'url' => Endpoint::ADDRESS_V4, |
|
| 263 | - 'method' => 'PUT', |
|
| 264 | - 'query' => array( |
|
| 265 | - 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
| 266 | - 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
| 267 | - ), |
|
| 268 | - 'body' => array( |
|
| 269 | - "parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null, |
|
| 270 | - "addresses" => isset($this->addresses) ? $this->addresses : null |
|
| 271 | - ), |
|
| 272 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 273 | - )); |
|
| 259 | + public function updateRouteAddress() |
|
| 260 | + { |
|
| 261 | + $result = Route4Me::makeRequst(array( |
|
| 262 | + 'url' => Endpoint::ADDRESS_V4, |
|
| 263 | + 'method' => 'PUT', |
|
| 264 | + 'query' => array( |
|
| 265 | + 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
| 266 | + 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
| 267 | + ), |
|
| 268 | + 'body' => array( |
|
| 269 | + "parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null, |
|
| 270 | + "addresses" => isset($this->addresses) ? $this->addresses : null |
|
| 271 | + ), |
|
| 272 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 273 | + )); |
|
| 274 | 274 | |
| 275 | - return $result; |
|
| 276 | - } |
|
| 275 | + return $result; |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - public function addAddresses($params) |
|
| 279 | - { |
|
| 280 | - $allQueryFields = array('route_id'); |
|
| 281 | - $allBodyFields = array('addresses'); |
|
| 278 | + public function addAddresses($params) |
|
| 279 | + { |
|
| 280 | + $allQueryFields = array('route_id'); |
|
| 281 | + $allBodyFields = array('addresses'); |
|
| 282 | 282 | |
| 283 | - $route = Route4Me::makeRequst(array( |
|
| 284 | - 'url' => Endpoint::ROUTE_V4, |
|
| 285 | - 'method' => 'PUT', |
|
| 286 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 287 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 288 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 289 | - )); |
|
| 283 | + $route = Route4Me::makeRequst(array( |
|
| 284 | + 'url' => Endpoint::ROUTE_V4, |
|
| 285 | + 'method' => 'PUT', |
|
| 286 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 287 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 288 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 289 | + )); |
|
| 290 | 290 | |
| 291 | - return Route::fromArray($route); |
|
| 292 | - } |
|
| 291 | + return Route::fromArray($route); |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - public function insertAddressOptimalPosition(array $params) |
|
| 295 | - { |
|
| 296 | - $allQueryFields = array('route_id'); |
|
| 297 | - $allBodyFields = array('addresses', 'optimal_position'); |
|
| 294 | + public function insertAddressOptimalPosition(array $params) |
|
| 295 | + { |
|
| 296 | + $allQueryFields = array('route_id'); |
|
| 297 | + $allBodyFields = array('addresses', 'optimal_position'); |
|
| 298 | 298 | |
| 299 | - $route = Route4Me::makeRequst(array( |
|
| 300 | - 'url' => Endpoint::ROUTE_V4, |
|
| 301 | - 'method' => 'PUT', |
|
| 302 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 303 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 304 | - )); |
|
| 299 | + $route = Route4Me::makeRequst(array( |
|
| 300 | + 'url' => Endpoint::ROUTE_V4, |
|
| 301 | + 'method' => 'PUT', |
|
| 302 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 303 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 304 | + )); |
|
| 305 | 305 | |
| 306 | - return Route::fromArray($route); |
|
| 307 | - } |
|
| 306 | + return Route::fromArray($route); |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - public function addNoteFile($params) |
|
| 310 | - { |
|
| 311 | - $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
| 312 | - $rpath = realpath($fname); |
|
| 309 | + public function addNoteFile($params) |
|
| 310 | + { |
|
| 311 | + $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
| 312 | + $rpath = realpath($fname); |
|
| 313 | 313 | |
| 314 | - $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type'); |
|
| 315 | - $allBodyFields = array('strUpdateType', 'strFilename', 'strNoteContents'); |
|
| 314 | + $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type'); |
|
| 315 | + $allBodyFields = array('strUpdateType', 'strFilename', 'strNoteContents'); |
|
| 316 | 316 | |
| 317 | - $result = Route4Me::makeRequst(array( |
|
| 318 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
| 319 | - 'method' => 'POST', |
|
| 320 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 321 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 322 | - 'FILE' => $rpath, |
|
| 323 | - 'HTTPHEADER' => array( |
|
| 324 | - 'Content-Type: application/x-www-form-urlencoded' |
|
| 325 | - ) |
|
| 326 | - )); |
|
| 317 | + $result = Route4Me::makeRequst(array( |
|
| 318 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
| 319 | + 'method' => 'POST', |
|
| 320 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 321 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 322 | + 'FILE' => $rpath, |
|
| 323 | + 'HTTPHEADER' => array( |
|
| 324 | + 'Content-Type: application/x-www-form-urlencoded' |
|
| 325 | + ) |
|
| 326 | + )); |
|
| 327 | 327 | |
| 328 | - return $result; |
|
| 329 | - } |
|
| 328 | + return $result; |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - public function deleteRoutes($route_id) |
|
| 332 | - { |
|
| 333 | - $result = Route4Me::makeRequst(array( |
|
| 334 | - 'url' => Endpoint::ROUTES_DELETE, |
|
| 335 | - 'method' => 'DELETE', |
|
| 336 | - 'query' => array( |
|
| 337 | - 'route_id' => $route_id, |
|
| 338 | - ) |
|
| 339 | - )); |
|
| 331 | + public function deleteRoutes($route_id) |
|
| 332 | + { |
|
| 333 | + $result = Route4Me::makeRequst(array( |
|
| 334 | + 'url' => Endpoint::ROUTES_DELETE, |
|
| 335 | + 'method' => 'DELETE', |
|
| 336 | + 'query' => array( |
|
| 337 | + 'route_id' => $route_id, |
|
| 338 | + ) |
|
| 339 | + )); |
|
| 340 | 340 | |
| 341 | - return $result; |
|
| 342 | - } |
|
| 341 | + return $result; |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - public function GetAddressesFromRoute($route_id) |
|
| 345 | - { |
|
| 346 | - $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
| 344 | + public function GetAddressesFromRoute($route_id) |
|
| 345 | + { |
|
| 346 | + $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
| 347 | 347 | |
| 348 | - if (isset($route1)) { |
|
| 349 | - return $route1->addresses; |
|
| 350 | - } else { |
|
| 351 | - return null; |
|
| 352 | - } |
|
| 353 | - } |
|
| 348 | + if (isset($route1)) { |
|
| 349 | + return $route1->addresses; |
|
| 350 | + } else { |
|
| 351 | + return null; |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | 354 | |
| 355 | - public function GetRandomAddressFromRoute($route_id) |
|
| 356 | - { |
|
| 357 | - $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
| 355 | + public function GetRandomAddressFromRoute($route_id) |
|
| 356 | + { |
|
| 357 | + $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
| 358 | 358 | |
| 359 | - if (isset($route1)) { |
|
| 360 | - $addresses = $route1->addresses; |
|
| 359 | + if (isset($route1)) { |
|
| 360 | + $addresses = $route1->addresses; |
|
| 361 | 361 | |
| 362 | - $rnd = rand(0, sizeof($addresses) - 1); |
|
| 362 | + $rnd = rand(0, sizeof($addresses) - 1); |
|
| 363 | 363 | |
| 364 | - return $addresses[$rnd]; |
|
| 365 | - } else { |
|
| 366 | - return null; |
|
| 367 | - } |
|
| 368 | - } |
|
| 364 | + return $addresses[$rnd]; |
|
| 365 | + } else { |
|
| 366 | + return null; |
|
| 367 | + } |
|
| 368 | + } |
|
| 369 | 369 | |
| 370 | - public function getRouteId() |
|
| 371 | - { |
|
| 372 | - return $this->route_id; |
|
| 373 | - } |
|
| 370 | + public function getRouteId() |
|
| 371 | + { |
|
| 372 | + return $this->route_id; |
|
| 373 | + } |
|
| 374 | 374 | |
| 375 | - public function getOptimizationId() |
|
| 376 | - { |
|
| 377 | - return $this->optimization_problem_id; |
|
| 378 | - } |
|
| 375 | + public function getOptimizationId() |
|
| 376 | + { |
|
| 377 | + return $this->optimization_problem_id; |
|
| 378 | + } |
|
| 379 | 379 | |
| 380 | - public function GetLastLocation(array $params) |
|
| 381 | - { |
|
| 382 | - $allQueryFields = array('route_id', 'device_tracking_history'); |
|
| 380 | + public function GetLastLocation(array $params) |
|
| 381 | + { |
|
| 382 | + $allQueryFields = array('route_id', 'device_tracking_history'); |
|
| 383 | 383 | |
| 384 | - $route = Route4Me::makeRequst(array( |
|
| 385 | - 'url' => Endpoint::ROUTE_V4, |
|
| 386 | - 'method' => 'GET', |
|
| 387 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 388 | - )); |
|
| 384 | + $route = Route4Me::makeRequst(array( |
|
| 385 | + 'url' => Endpoint::ROUTE_V4, |
|
| 386 | + 'method' => 'GET', |
|
| 387 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 388 | + )); |
|
| 389 | 389 | |
| 390 | - return Route::fromArray($route); |
|
| 391 | - } |
|
| 390 | + return Route::fromArray($route); |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | - public function GetTrackingHistoryFromTimeRange(array $params) |
|
| 394 | - { |
|
| 395 | - $allQueryFields = array('route_id', 'format', 'time_period', 'start_date', 'end_date'); |
|
| 393 | + public function GetTrackingHistoryFromTimeRange(array $params) |
|
| 394 | + { |
|
| 395 | + $allQueryFields = array('route_id', 'format', 'time_period', 'start_date', 'end_date'); |
|
| 396 | 396 | |
| 397 | - $route = Route4Me::makeRequst(array( |
|
| 398 | - 'url' => Endpoint::GET_DEVICE_LOCATION, |
|
| 399 | - 'method' => 'GET', |
|
| 400 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 401 | - )); |
|
| 397 | + $route = Route4Me::makeRequst(array( |
|
| 398 | + 'url' => Endpoint::GET_DEVICE_LOCATION, |
|
| 399 | + 'method' => 'GET', |
|
| 400 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 401 | + )); |
|
| 402 | 402 | |
| 403 | - return $route; |
|
| 404 | - } |
|
| 403 | + return $route; |
|
| 404 | + } |
|
| 405 | 405 | |
| 406 | - public function GetAssetTracking(array $params) |
|
| 407 | - { |
|
| 408 | - $allQueryFields = array('tracking'); |
|
| 406 | + public function GetAssetTracking(array $params) |
|
| 407 | + { |
|
| 408 | + $allQueryFields = array('tracking'); |
|
| 409 | 409 | |
| 410 | - $route = Route4Me::makeRequst(array( |
|
| 411 | - 'url' => Endpoint::STATUS_V4, |
|
| 412 | - 'method' => 'GET', |
|
| 413 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 414 | - )); |
|
| 410 | + $route = Route4Me::makeRequst(array( |
|
| 411 | + 'url' => Endpoint::STATUS_V4, |
|
| 412 | + 'method' => 'GET', |
|
| 413 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 414 | + )); |
|
| 415 | 415 | |
| 416 | - return $route; |
|
| 417 | - } |
|
| 416 | + return $route; |
|
| 417 | + } |
|
| 418 | 418 | } |
@@ -351,70 +351,70 @@ |
||
| 351 | 351 | |
| 352 | 352 | if ($mode!='daily') { |
| 353 | 353 | switch ($mode) { |
| 354 | - case 'weekly': |
|
| 355 | - if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
| 356 | - if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
| 357 | - $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
| 358 | - } else { |
|
| 359 | - array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
| 360 | - } |
|
| 354 | + case 'weekly': |
|
| 355 | + if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
| 356 | + if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
| 357 | + $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
| 361 | 358 | } else { |
| 362 | - array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
| 359 | + array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
| 363 | 360 | } |
| 364 | - break; |
|
| 365 | - case 'monthly': |
|
| 366 | - $monthlyMode = ""; |
|
| 367 | - if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
| 368 | - if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
| 369 | - $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
| 370 | - $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
| 371 | - } else { |
|
| 372 | - array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
| 373 | - } |
|
| 361 | + } else { |
|
| 362 | + array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
| 363 | + } |
|
| 364 | + break; |
|
| 365 | + case 'monthly': |
|
| 366 | + $monthlyMode = ""; |
|
| 367 | + if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
| 368 | + if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
| 369 | + $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
| 370 | + $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
| 374 | 371 | } else { |
| 375 | - array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
| 372 | + array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
| 376 | 373 | } |
| 374 | + } else { |
|
| 375 | + array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - if ($monthlyMode!="") { |
|
| 379 | - switch ($monthlyMode) { |
|
| 380 | - case 'dates': |
|
| 381 | - if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
| 382 | - if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
| 383 | - $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
| 384 | - } else { |
|
| 385 | - array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
| 386 | - } |
|
| 387 | - } |
|
| 388 | - break; |
|
| 389 | - case 'nth': |
|
| 390 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
| 391 | - if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
| 392 | - $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
| 393 | - } else { |
|
| 394 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
| 395 | - } |
|
| 396 | - } else { |
|
| 397 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
| 398 | - } |
|
| 378 | + if ($monthlyMode!="") { |
|
| 379 | + switch ($monthlyMode) { |
|
| 380 | + case 'dates': |
|
| 381 | + if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
| 382 | + if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
| 383 | + $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
| 384 | + } else { |
|
| 385 | + array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
| 386 | + } |
|
| 387 | + } |
|
| 388 | + break; |
|
| 389 | + case 'nth': |
|
| 390 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
| 391 | + if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
| 392 | + $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
| 393 | + } else { |
|
| 394 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
| 395 | + } |
|
| 396 | + } else { |
|
| 397 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
| 398 | + } |
|
| 399 | 399 | |
| 400 | - if ($curSchedule!="") { |
|
| 401 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
| 402 | - if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
| 403 | - $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
| 404 | - } else { |
|
| 405 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
| 406 | - } |
|
| 407 | - } else { |
|
| 408 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
| 409 | - } |
|
| 410 | - } |
|
| 411 | - break; |
|
| 400 | + if ($curSchedule!="") { |
|
| 401 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
| 402 | + if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
| 403 | + $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
| 404 | + } else { |
|
| 405 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
| 412 | 406 | } |
| 407 | + } else { |
|
| 408 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
| 409 | + } |
|
| 413 | 410 | } |
| 414 | 411 | break; |
| 415 | - default: |
|
| 416 | - $curSchedule = ""; |
|
| 412 | + } |
|
| 413 | + } |
|
| 417 | 414 | break; |
| 415 | + default: |
|
| 416 | + $curSchedule = ""; |
|
| 417 | + break; |
|
| 418 | 418 | } |
| 419 | 419 | } |
| 420 | 420 | |
@@ -6,449 +6,449 @@ |
||
| 6 | 6 | |
| 7 | 7 | class AddressBookLocation extends Common |
| 8 | 8 | { |
| 9 | - public $address_id; |
|
| 10 | - public $address_group; |
|
| 11 | - public $address_alias; |
|
| 12 | - public $address_1; |
|
| 13 | - public $address_2; |
|
| 14 | - public $first_name; |
|
| 15 | - public $last_name; |
|
| 16 | - public $address_email; |
|
| 17 | - public $address_phone_number; |
|
| 18 | - public $address_city; |
|
| 19 | - public $address_state_id; |
|
| 20 | - public $address_country_id; |
|
| 21 | - public $address_zip; |
|
| 22 | - public $cached_lat; |
|
| 23 | - public $cached_lng; |
|
| 24 | - public $curbside_lat; |
|
| 25 | - public $curbside_lng; |
|
| 26 | - public $color; |
|
| 27 | - public $address_custom_data; |
|
| 28 | - public $schedule; |
|
| 9 | + public $address_id; |
|
| 10 | + public $address_group; |
|
| 11 | + public $address_alias; |
|
| 12 | + public $address_1; |
|
| 13 | + public $address_2; |
|
| 14 | + public $first_name; |
|
| 15 | + public $last_name; |
|
| 16 | + public $address_email; |
|
| 17 | + public $address_phone_number; |
|
| 18 | + public $address_city; |
|
| 19 | + public $address_state_id; |
|
| 20 | + public $address_country_id; |
|
| 21 | + public $address_zip; |
|
| 22 | + public $cached_lat; |
|
| 23 | + public $cached_lng; |
|
| 24 | + public $curbside_lat; |
|
| 25 | + public $curbside_lng; |
|
| 26 | + public $color; |
|
| 27 | + public $address_custom_data; |
|
| 28 | + public $schedule; |
|
| 29 | 29 | |
| 30 | - public $created_timestamp; |
|
| 31 | - public $member_id; |
|
| 32 | - public $schedule_blacklist; |
|
| 33 | - public $in_route_count; |
|
| 34 | - public $last_visited_timestamp; |
|
| 35 | - public $last_routed_timestamp; |
|
| 36 | - public $local_time_window_start; |
|
| 37 | - public $local_time_window_end; |
|
| 38 | - public $local_time_window_start_2; |
|
| 39 | - public $local_time_window_end_2; |
|
| 40 | - public $service_time; |
|
| 41 | - public $local_timezone_string; |
|
| 42 | - public $address_icon; |
|
| 43 | - public $address_stop_type; |
|
| 44 | - public $address_cube; |
|
| 45 | - public $address_pieces; |
|
| 46 | - public $address_reference_no; |
|
| 47 | - public $address_revenue; |
|
| 48 | - public $address_weight; |
|
| 49 | - public $address_priority; |
|
| 50 | - public $address_customer_po; |
|
| 30 | + public $created_timestamp; |
|
| 31 | + public $member_id; |
|
| 32 | + public $schedule_blacklist; |
|
| 33 | + public $in_route_count; |
|
| 34 | + public $last_visited_timestamp; |
|
| 35 | + public $last_routed_timestamp; |
|
| 36 | + public $local_time_window_start; |
|
| 37 | + public $local_time_window_end; |
|
| 38 | + public $local_time_window_start_2; |
|
| 39 | + public $local_time_window_end_2; |
|
| 40 | + public $service_time; |
|
| 41 | + public $local_timezone_string; |
|
| 42 | + public $address_icon; |
|
| 43 | + public $address_stop_type; |
|
| 44 | + public $address_cube; |
|
| 45 | + public $address_pieces; |
|
| 46 | + public $address_reference_no; |
|
| 47 | + public $address_revenue; |
|
| 48 | + public $address_weight; |
|
| 49 | + public $address_priority; |
|
| 50 | + public $address_customer_po; |
|
| 51 | 51 | |
| 52 | - public static function fromArray(array $params) |
|
| 53 | - { |
|
| 54 | - $addressbooklocation = new AddressBookLocation(); |
|
| 52 | + public static function fromArray(array $params) |
|
| 53 | + { |
|
| 54 | + $addressbooklocation = new AddressBookLocation(); |
|
| 55 | 55 | |
| 56 | - foreach ($params as $key => $value) { |
|
| 57 | - if (property_exists($addressbooklocation, $key)) { |
|
| 58 | - $addressbooklocation->{$key} = $value; |
|
| 59 | - } |
|
| 60 | - } |
|
| 56 | + foreach ($params as $key => $value) { |
|
| 57 | + if (property_exists($addressbooklocation, $key)) { |
|
| 58 | + $addressbooklocation->{$key} = $value; |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return $addressbooklocation; |
|
| 63 | - } |
|
| 62 | + return $addressbooklocation; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | |
| 66 | - public static function getAddressBookLocation($addressId) |
|
| 67 | - { |
|
| 68 | - $ablocations = Route4Me::makeRequst(array( |
|
| 69 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 70 | - 'method' => 'GET', |
|
| 71 | - 'query' => array( |
|
| 72 | - 'query' => $addressId, |
|
| 73 | - 'limit' => 30 |
|
| 74 | - ) |
|
| 75 | - )); |
|
| 66 | + public static function getAddressBookLocation($addressId) |
|
| 67 | + { |
|
| 68 | + $ablocations = Route4Me::makeRequst(array( |
|
| 69 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 70 | + 'method' => 'GET', |
|
| 71 | + 'query' => array( |
|
| 72 | + 'query' => $addressId, |
|
| 73 | + 'limit' => 30 |
|
| 74 | + ) |
|
| 75 | + )); |
|
| 76 | 76 | |
| 77 | - return $ablocations; |
|
| 78 | - } |
|
| 77 | + return $ablocations; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - public static function searchAddressBookLocations($params) |
|
| 81 | - { |
|
| 82 | - $allQueryFields = array('display', 'query', 'fields', 'limit', 'offset'); |
|
| 80 | + public static function searchAddressBookLocations($params) |
|
| 81 | + { |
|
| 82 | + $allQueryFields = array('display', 'query', 'fields', 'limit', 'offset'); |
|
| 83 | 83 | |
| 84 | - $result = Route4Me::makeRequst(array( |
|
| 85 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 86 | - 'method' => 'GET', |
|
| 87 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 88 | - )); |
|
| 84 | + $result = Route4Me::makeRequst(array( |
|
| 85 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 86 | + 'method' => 'GET', |
|
| 87 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 88 | + )); |
|
| 89 | 89 | |
| 90 | - return $result; |
|
| 91 | - } |
|
| 90 | + return $result; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - public static function getAddressBookLocations($params) |
|
| 94 | - { |
|
| 95 | - $allQueryFields = array('limit', 'offset', 'address_id'); |
|
| 93 | + public static function getAddressBookLocations($params) |
|
| 94 | + { |
|
| 95 | + $allQueryFields = array('limit', 'offset', 'address_id'); |
|
| 96 | 96 | |
| 97 | - $ablocations = Route4Me::makeRequst(array( |
|
| 98 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 99 | - 'method' => 'GET', |
|
| 100 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 101 | - )); |
|
| 97 | + $ablocations = Route4Me::makeRequst(array( |
|
| 98 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 99 | + 'method' => 'GET', |
|
| 100 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 101 | + )); |
|
| 102 | 102 | |
| 103 | - return $ablocations; |
|
| 104 | - } |
|
| 103 | + return $ablocations; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - public static function getRandomAddressBookLocation($params) |
|
| 107 | - { |
|
| 108 | - $ablocations = self::getAddressBookLocations($params); |
|
| 106 | + public static function getRandomAddressBookLocation($params) |
|
| 107 | + { |
|
| 108 | + $ablocations = self::getAddressBookLocations($params); |
|
| 109 | 109 | |
| 110 | - if (isset($ablocations["results"])) { |
|
| 111 | - $locationsSize = sizeof($ablocations["results"]); |
|
| 110 | + if (isset($ablocations["results"])) { |
|
| 111 | + $locationsSize = sizeof($ablocations["results"]); |
|
| 112 | 112 | |
| 113 | - if ($locationsSize>0) { |
|
| 114 | - $randomLocationIndex = rand(0, $locationsSize - 1); |
|
| 115 | - return $ablocations["results"][$randomLocationIndex]; |
|
| 116 | - } |
|
| 117 | - } |
|
| 113 | + if ($locationsSize>0) { |
|
| 114 | + $randomLocationIndex = rand(0, $locationsSize - 1); |
|
| 115 | + return $ablocations["results"][$randomLocationIndex]; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - return null; |
|
| 120 | - } |
|
| 119 | + return null; |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * @param AddressBookLocation $params |
|
| 124 | - */ |
|
| 125 | - public static function addAdressBookLocation($params) |
|
| 126 | - { |
|
| 127 | - $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
| 122 | + /** |
|
| 123 | + * @param AddressBookLocation $params |
|
| 124 | + */ |
|
| 125 | + public static function addAdressBookLocation($params) |
|
| 126 | + { |
|
| 127 | + $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
| 128 | 128 | |
| 129 | - $response = Route4Me::makeRequst(array( |
|
| 130 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 131 | - 'method' => 'POST', |
|
| 132 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 133 | - )); |
|
| 129 | + $response = Route4Me::makeRequst(array( |
|
| 130 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 131 | + 'method' => 'POST', |
|
| 132 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 133 | + )); |
|
| 134 | 134 | |
| 135 | - return $response; |
|
| 136 | - } |
|
| 135 | + return $response; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - public function deleteAdressBookLocation($address_ids) |
|
| 139 | - { |
|
| 140 | - $result = Route4Me::makeRequst(array( |
|
| 141 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 142 | - 'method' => 'DELETEARRAY', |
|
| 143 | - 'query' => array( |
|
| 144 | - 'address_ids' => $address_ids |
|
| 145 | - ) |
|
| 146 | - )); |
|
| 138 | + public function deleteAdressBookLocation($address_ids) |
|
| 139 | + { |
|
| 140 | + $result = Route4Me::makeRequst(array( |
|
| 141 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 142 | + 'method' => 'DELETEARRAY', |
|
| 143 | + 'query' => array( |
|
| 144 | + 'address_ids' => $address_ids |
|
| 145 | + ) |
|
| 146 | + )); |
|
| 147 | 147 | |
| 148 | - return $result; |
|
| 149 | - } |
|
| 148 | + return $result; |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - public function updateAdressBookLocation($params) |
|
| 152 | - { |
|
| 153 | - $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('in_route_count')); |
|
| 151 | + public function updateAdressBookLocation($params) |
|
| 152 | + { |
|
| 153 | + $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('in_route_count')); |
|
| 154 | 154 | |
| 155 | - $response = Route4Me::makeRequst(array( |
|
| 156 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 157 | - 'method' => 'PUT', |
|
| 158 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 159 | - )); |
|
| 155 | + $response = Route4Me::makeRequst(array( |
|
| 156 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 157 | + 'method' => 'PUT', |
|
| 158 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 159 | + )); |
|
| 160 | 160 | |
| 161 | - return $response; |
|
| 162 | - } |
|
| 161 | + return $response; |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - public static function validateScheduleMode($scheduleMode) |
|
| 165 | - { |
|
| 166 | - $schedMmodes = array("daily", "weekly", "monthly", "annually"); |
|
| 164 | + public static function validateScheduleMode($scheduleMode) |
|
| 165 | + { |
|
| 166 | + $schedMmodes = array("daily", "weekly", "monthly", "annually"); |
|
| 167 | 167 | |
| 168 | - if (in_array($scheduleMode, $schedMmodes)) { |
|
| 169 | - return TRUE; |
|
| 170 | - } else { |
|
| 171 | - return FALSE; |
|
| 172 | - } |
|
| 173 | - } |
|
| 168 | + if (in_array($scheduleMode, $schedMmodes)) { |
|
| 169 | + return TRUE; |
|
| 170 | + } else { |
|
| 171 | + return FALSE; |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - public static function validateScheduleEnable($scheduleEnabled) |
|
| 176 | - { |
|
| 177 | - $schedEnables = array(TRUE, FALSE); |
|
| 175 | + public static function validateScheduleEnable($scheduleEnabled) |
|
| 176 | + { |
|
| 177 | + $schedEnables = array(TRUE, FALSE); |
|
| 178 | 178 | |
| 179 | - if (in_array($scheduleEnabled, $schedEnables)) { |
|
| 180 | - return TRUE; |
|
| 181 | - } else { |
|
| 182 | - return FALSE; |
|
| 183 | - } |
|
| 184 | - } |
|
| 179 | + if (in_array($scheduleEnabled, $schedEnables)) { |
|
| 180 | + return TRUE; |
|
| 181 | + } else { |
|
| 182 | + return FALSE; |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - public static function validateScheduleEvery($scheduleEvery) |
|
| 187 | - { |
|
| 188 | - if (is_numeric($scheduleEvery)) { |
|
| 189 | - return TRUE; |
|
| 190 | - } else { |
|
| 191 | - return FALSE; |
|
| 192 | - } |
|
| 193 | - } |
|
| 186 | + public static function validateScheduleEvery($scheduleEvery) |
|
| 187 | + { |
|
| 188 | + if (is_numeric($scheduleEvery)) { |
|
| 189 | + return TRUE; |
|
| 190 | + } else { |
|
| 191 | + return FALSE; |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - public static function validateScheduleWeekDays($scheduleWeekDays) |
|
| 196 | - { |
|
| 197 | - $weekdays = explode(',', $scheduleWeekDays); |
|
| 198 | - $weekdaysSize = sizeof($weekdays); |
|
| 195 | + public static function validateScheduleWeekDays($scheduleWeekDays) |
|
| 196 | + { |
|
| 197 | + $weekdays = explode(',', $scheduleWeekDays); |
|
| 198 | + $weekdaysSize = sizeof($weekdays); |
|
| 199 | 199 | |
| 200 | - if ($weekdaysSize<1) { |
|
| 201 | - return FALSE; |
|
| 202 | - } |
|
| 200 | + if ($weekdaysSize<1) { |
|
| 201 | + return FALSE; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - $isValid = TRUE; |
|
| 204 | + $isValid = TRUE; |
|
| 205 | 205 | |
| 206 | - for ($i = 0; $i<$weekdaysSize; $i++) { |
|
| 207 | - if (is_numeric($weekdays[$i])) { |
|
| 208 | - $wday = intval($weekdays[$i]); |
|
| 209 | - if ($wday<1 || $wday>7) { |
|
| 210 | - $isValid = FALSE; |
|
| 211 | - } |
|
| 212 | - } else { |
|
| 213 | - $isValid = FALSE; |
|
| 214 | - } |
|
| 215 | - } |
|
| 206 | + for ($i = 0; $i<$weekdaysSize; $i++) { |
|
| 207 | + if (is_numeric($weekdays[$i])) { |
|
| 208 | + $wday = intval($weekdays[$i]); |
|
| 209 | + if ($wday<1 || $wday>7) { |
|
| 210 | + $isValid = FALSE; |
|
| 211 | + } |
|
| 212 | + } else { |
|
| 213 | + $isValid = FALSE; |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - return $isValid; |
|
| 218 | - } |
|
| 217 | + return $isValid; |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
|
| 221 | - { |
|
| 222 | - $schedMonthlyMmodes = array("dates", "nth"); |
|
| 220 | + public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
|
| 221 | + { |
|
| 222 | + $schedMonthlyMmodes = array("dates", "nth"); |
|
| 223 | 223 | |
| 224 | - if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) { |
|
| 225 | - return TRUE; |
|
| 226 | - } else { |
|
| 227 | - return FALSE; |
|
| 228 | - } |
|
| 229 | - } |
|
| 224 | + if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) { |
|
| 225 | + return TRUE; |
|
| 226 | + } else { |
|
| 227 | + return FALSE; |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
|
| 232 | - { |
|
| 233 | - $monthlyDates = explode(',', $scheduleMonthlyDates); |
|
| 234 | - $monthlyDatesSize = sizeof($monthlyDates); |
|
| 231 | + public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
|
| 232 | + { |
|
| 233 | + $monthlyDates = explode(',', $scheduleMonthlyDates); |
|
| 234 | + $monthlyDatesSize = sizeof($monthlyDates); |
|
| 235 | 235 | |
| 236 | - if ($monthlyDatesSize<1) { |
|
| 237 | - return FALSE; |
|
| 238 | - } |
|
| 236 | + if ($monthlyDatesSize<1) { |
|
| 237 | + return FALSE; |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - $isValid = TRUE; |
|
| 240 | + $isValid = TRUE; |
|
| 241 | 241 | |
| 242 | - for ($i = 0; $i<$monthlyDatesSize; $i++) { |
|
| 243 | - if (is_numeric($monthlyDates[$i])) { |
|
| 244 | - $mday = intval($monthlyDates[$i]); |
|
| 245 | - if ($mday<1 || $mday>31) { |
|
| 246 | - $isValid = FALSE; |
|
| 247 | - } |
|
| 248 | - } else { |
|
| 249 | - $isValid = FALSE; |
|
| 250 | - } |
|
| 251 | - } |
|
| 242 | + for ($i = 0; $i<$monthlyDatesSize; $i++) { |
|
| 243 | + if (is_numeric($monthlyDates[$i])) { |
|
| 244 | + $mday = intval($monthlyDates[$i]); |
|
| 245 | + if ($mday<1 || $mday>31) { |
|
| 246 | + $isValid = FALSE; |
|
| 247 | + } |
|
| 248 | + } else { |
|
| 249 | + $isValid = FALSE; |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - return $isValid; |
|
| 254 | - } |
|
| 253 | + return $isValid; |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - public static function validateScheduleNthN($scheduleNthN) |
|
| 257 | - { |
|
| 258 | - if (!is_numeric($scheduleNthN)) { |
|
| 259 | - return FALSE; |
|
| 260 | - } |
|
| 256 | + public static function validateScheduleNthN($scheduleNthN) |
|
| 257 | + { |
|
| 258 | + if (!is_numeric($scheduleNthN)) { |
|
| 259 | + return FALSE; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - $schedNthNs = array(1, 2, 3, 4, 5, -1); |
|
| 262 | + $schedNthNs = array(1, 2, 3, 4, 5, -1); |
|
| 263 | 263 | |
| 264 | - if (in_array($scheduleNthN, $schedNthNs)) { |
|
| 265 | - return TRUE; |
|
| 266 | - } else { |
|
| 267 | - return FALSE; |
|
| 268 | - } |
|
| 269 | - } |
|
| 264 | + if (in_array($scheduleNthN, $schedNthNs)) { |
|
| 265 | + return TRUE; |
|
| 266 | + } else { |
|
| 267 | + return FALSE; |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - public static function validateScheduleNthWhat($scheduleNthWhat) |
|
| 272 | - { |
|
| 273 | - if (!is_numeric($scheduleNthWhat)) { |
|
| 274 | - return FALSE; |
|
| 275 | - } |
|
| 271 | + public static function validateScheduleNthWhat($scheduleNthWhat) |
|
| 272 | + { |
|
| 273 | + if (!is_numeric($scheduleNthWhat)) { |
|
| 274 | + return FALSE; |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | - $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
| 277 | + $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
| 278 | 278 | |
| 279 | - if (in_array($scheduleNthWhat, $schedNthWhats)) { |
|
| 280 | - return TRUE; |
|
| 281 | - } else { |
|
| 282 | - return FALSE; |
|
| 283 | - } |
|
| 284 | - } |
|
| 279 | + if (in_array($scheduleNthWhat, $schedNthWhats)) { |
|
| 280 | + return TRUE; |
|
| 281 | + } else { |
|
| 282 | + return FALSE; |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | 285 | |
| 286 | - /** Function adds the locations (with/without schedule) from the CSV file. |
|
| 287 | - * $csvFileHandle - a file handler. |
|
| 288 | - * Returns array $results which contains two arrays: fail and succes. |
|
| 289 | - */ |
|
| 290 | - public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping) |
|
| 291 | - { |
|
| 292 | - $max_line_length = 512; |
|
| 293 | - $delemietr = ','; |
|
| 286 | + /** Function adds the locations (with/without schedule) from the CSV file. |
|
| 287 | + * $csvFileHandle - a file handler. |
|
| 288 | + * Returns array $results which contains two arrays: fail and succes. |
|
| 289 | + */ |
|
| 290 | + public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping) |
|
| 291 | + { |
|
| 292 | + $max_line_length = 512; |
|
| 293 | + $delemietr = ','; |
|
| 294 | 294 | |
| 295 | - $results = array(); |
|
| 296 | - $results['fail'] = array(); |
|
| 297 | - $results['success'] = array(); |
|
| 295 | + $results = array(); |
|
| 296 | + $results['fail'] = array(); |
|
| 297 | + $results['success'] = array(); |
|
| 298 | 298 | |
| 299 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
| 299 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
| 300 | 300 | |
| 301 | - $addressBookFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
| 301 | + $addressBookFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
| 302 | 302 | |
| 303 | - if (empty($columns)) { |
|
| 304 | - array_push($results['fail'], 'Empty CSV table'); |
|
| 305 | - return ($results); |
|
| 306 | - } |
|
| 303 | + if (empty($columns)) { |
|
| 304 | + array_push($results['fail'], 'Empty CSV table'); |
|
| 305 | + return ($results); |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - $iRow = 1; |
|
| 308 | + $iRow = 1; |
|
| 309 | 309 | |
| 310 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
| 311 | - if (!isset($rows[$locationsFieldsMapping['cached_lat']]) || !isset($rows[$locationsFieldsMapping['cached_lng']]) |
|
| 312 | - || !isset($rows[$locationsFieldsMapping['address_1']]) || array(null)==$rows) { |
|
| 313 | - continue; |
|
| 314 | - } |
|
| 310 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
| 311 | + if (!isset($rows[$locationsFieldsMapping['cached_lat']]) || !isset($rows[$locationsFieldsMapping['cached_lng']]) |
|
| 312 | + || !isset($rows[$locationsFieldsMapping['address_1']]) || array(null)==$rows) { |
|
| 313 | + continue; |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | - $curSchedule = ""; |
|
| 317 | - $mode = ""; |
|
| 316 | + $curSchedule = ""; |
|
| 317 | + $mode = ""; |
|
| 318 | 318 | |
| 319 | - $failCount = sizeof($results['fail']); |
|
| 319 | + $failCount = sizeof($results['fail']); |
|
| 320 | 320 | |
| 321 | - if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
| 322 | - if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
| 323 | - $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
| 324 | - $mode = $rows[$locationsFieldsMapping['schedule_mode']]; |
|
| 325 | - } else { |
|
| 326 | - array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); |
|
| 327 | - } |
|
| 328 | - } else { |
|
| 329 | - array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); |
|
| 330 | - } |
|
| 321 | + if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
| 322 | + if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
| 323 | + $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
| 324 | + $mode = $rows[$locationsFieldsMapping['schedule_mode']]; |
|
| 325 | + } else { |
|
| 326 | + array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); |
|
| 327 | + } |
|
| 328 | + } else { |
|
| 329 | + array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | - if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
| 333 | - if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
| 334 | - $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
| 335 | - } else { |
|
| 336 | - array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set "); |
|
| 337 | - } |
|
| 338 | - } |
|
| 332 | + if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
| 333 | + if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
| 334 | + $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
| 335 | + } else { |
|
| 336 | + array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set "); |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
| 341 | - if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
| 342 | - $curSchedule .= '"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
| 343 | - if ($mode=='daily') { |
|
| 344 | - $curSchedule = trim($curSchedule, ','); |
|
| 345 | - $curSchedule .= '}'; |
|
| 346 | - } |
|
| 347 | - } else { |
|
| 348 | - array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); |
|
| 349 | - } |
|
| 350 | - } |
|
| 340 | + if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
| 341 | + if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
| 342 | + $curSchedule .= '"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
| 343 | + if ($mode=='daily') { |
|
| 344 | + $curSchedule = trim($curSchedule, ','); |
|
| 345 | + $curSchedule .= '}'; |
|
| 346 | + } |
|
| 347 | + } else { |
|
| 348 | + array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | - if ($mode!='daily') { |
|
| 353 | - switch ($mode) { |
|
| 354 | - case 'weekly': |
|
| 355 | - if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
| 356 | - if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
| 357 | - $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
| 358 | - } else { |
|
| 359 | - array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
| 360 | - } |
|
| 361 | - } else { |
|
| 362 | - array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
| 363 | - } |
|
| 364 | - break; |
|
| 365 | - case 'monthly': |
|
| 366 | - $monthlyMode = ""; |
|
| 367 | - if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
| 368 | - if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
| 369 | - $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
| 370 | - $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
| 371 | - } else { |
|
| 372 | - array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
| 373 | - } |
|
| 374 | - } else { |
|
| 375 | - array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
| 376 | - } |
|
| 352 | + if ($mode!='daily') { |
|
| 353 | + switch ($mode) { |
|
| 354 | + case 'weekly': |
|
| 355 | + if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
| 356 | + if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
| 357 | + $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
| 358 | + } else { |
|
| 359 | + array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
| 360 | + } |
|
| 361 | + } else { |
|
| 362 | + array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
| 363 | + } |
|
| 364 | + break; |
|
| 365 | + case 'monthly': |
|
| 366 | + $monthlyMode = ""; |
|
| 367 | + if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
| 368 | + if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
| 369 | + $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
| 370 | + $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
| 371 | + } else { |
|
| 372 | + array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
| 373 | + } |
|
| 374 | + } else { |
|
| 375 | + array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - if ($monthlyMode!="") { |
|
| 379 | - switch ($monthlyMode) { |
|
| 380 | - case 'dates': |
|
| 381 | - if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
| 382 | - if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
| 383 | - $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
| 384 | - } else { |
|
| 385 | - array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
| 386 | - } |
|
| 387 | - } |
|
| 388 | - break; |
|
| 389 | - case 'nth': |
|
| 390 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
| 391 | - if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
| 392 | - $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
| 393 | - } else { |
|
| 394 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
| 395 | - } |
|
| 396 | - } else { |
|
| 397 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
| 398 | - } |
|
| 378 | + if ($monthlyMode!="") { |
|
| 379 | + switch ($monthlyMode) { |
|
| 380 | + case 'dates': |
|
| 381 | + if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
| 382 | + if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
| 383 | + $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
| 384 | + } else { |
|
| 385 | + array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
| 386 | + } |
|
| 387 | + } |
|
| 388 | + break; |
|
| 389 | + case 'nth': |
|
| 390 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
| 391 | + if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
| 392 | + $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
| 393 | + } else { |
|
| 394 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
| 395 | + } |
|
| 396 | + } else { |
|
| 397 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
| 398 | + } |
|
| 399 | 399 | |
| 400 | - if ($curSchedule!="") { |
|
| 401 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
| 402 | - if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
| 403 | - $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
| 404 | - } else { |
|
| 405 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
| 406 | - } |
|
| 407 | - } else { |
|
| 408 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
| 409 | - } |
|
| 410 | - } |
|
| 411 | - break; |
|
| 412 | - } |
|
| 413 | - } |
|
| 414 | - break; |
|
| 415 | - default: |
|
| 416 | - $curSchedule = ""; |
|
| 417 | - break; |
|
| 418 | - } |
|
| 419 | - } |
|
| 400 | + if ($curSchedule!="") { |
|
| 401 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
| 402 | + if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
| 403 | + $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
| 404 | + } else { |
|
| 405 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
| 406 | + } |
|
| 407 | + } else { |
|
| 408 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
| 409 | + } |
|
| 410 | + } |
|
| 411 | + break; |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | + break; |
|
| 415 | + default: |
|
| 416 | + $curSchedule = ""; |
|
| 417 | + break; |
|
| 418 | + } |
|
| 419 | + } |
|
| 420 | 420 | |
| 421 | - if (sizeof($results['fail'])>$failCount) { |
|
| 422 | - $curSchedule = ""; |
|
| 423 | - } |
|
| 421 | + if (sizeof($results['fail'])>$failCount) { |
|
| 422 | + $curSchedule = ""; |
|
| 423 | + } |
|
| 424 | 424 | |
| 425 | - if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") { |
|
| 426 | - $iRow++; |
|
| 427 | - continue; |
|
| 428 | - } |
|
| 425 | + if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") { |
|
| 426 | + $iRow++; |
|
| 427 | + continue; |
|
| 428 | + } |
|
| 429 | 429 | |
| 430 | - $curSchedule = strtolower($curSchedule); |
|
| 430 | + $curSchedule = strtolower($curSchedule); |
|
| 431 | 431 | |
| 432 | - $curSchedule = '[{'.$curSchedule.'}]'; |
|
| 432 | + $curSchedule = '[{'.$curSchedule.'}]'; |
|
| 433 | 433 | |
| 434 | - $parametersArray = array(); |
|
| 434 | + $parametersArray = array(); |
|
| 435 | 435 | |
| 436 | - foreach ($addressBookFields as $addressBookField) { |
|
| 437 | - if (isset($locationsFieldsMapping[$addressBookField])) { |
|
| 438 | - $parametersArray[$addressBookField] = $rows[$locationsFieldsMapping[$addressBookField]]; |
|
| 439 | - } |
|
| 440 | - } |
|
| 436 | + foreach ($addressBookFields as $addressBookField) { |
|
| 437 | + if (isset($locationsFieldsMapping[$addressBookField])) { |
|
| 438 | + $parametersArray[$addressBookField] = $rows[$locationsFieldsMapping[$addressBookField]]; |
|
| 439 | + } |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | - $AdressBookLocationParameters = AddressBookLocation::fromArray($parametersArray); |
|
| 442 | + $AdressBookLocationParameters = AddressBookLocation::fromArray($parametersArray); |
|
| 443 | 443 | |
| 444 | - $abContacts = new AddressBookLocation(); |
|
| 444 | + $abContacts = new AddressBookLocation(); |
|
| 445 | 445 | |
| 446 | - $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
| 446 | + $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
| 447 | 447 | |
| 448 | - array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
| 449 | - } |
|
| 448 | + array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
| 449 | + } |
|
| 450 | 450 | |
| 451 | - return $results; |
|
| 452 | - } |
|
| 451 | + return $results; |
|
| 452 | + } |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | \ No newline at end of file |
@@ -13,13 +13,13 @@ |
||
| 13 | 13 | Route4Me::setApiKey('11111111111111111111111111111111'); |
| 14 | 14 | |
| 15 | 15 | $recordParameters = Member::fromArray(array( |
| 16 | - 'email_address' => '[email protected]', |
|
| 17 | - 'first_name' => 'Mmmmm', |
|
| 18 | - 'last_name' => 'Ccccc', |
|
| 19 | - 'phone_number' => '454-454544', |
|
| 20 | - 'company_name' => 'c_name', |
|
| 21 | - 'member_id' => '123456', |
|
| 22 | - 'webinar_date' => '2016-06-05 10:00:00' |
|
| 16 | + 'email_address' => '[email protected]', |
|
| 17 | + 'first_name' => 'Mmmmm', |
|
| 18 | + 'last_name' => 'Ccccc', |
|
| 19 | + 'phone_number' => '454-454544', |
|
| 20 | + 'company_name' => 'c_name', |
|
| 21 | + 'member_id' => '123456', |
|
| 22 | + 'webinar_date' => '2016-06-05 10:00:00' |
|
| 23 | 23 | )); |
| 24 | 24 | |
| 25 | 25 | $member = new Member(); |
@@ -17,10 +17,10 @@ |
||
| 17 | 17 | // Example refers to the process of searching for text and specifing returned fields. |
| 18 | 18 | |
| 19 | 19 | $params = array( |
| 20 | - 'query' => 'David', |
|
| 21 | - 'fields' => 'first_name,address_email', |
|
| 22 | - 'offset' => 0, |
|
| 23 | - 'limit' => 5 |
|
| 20 | + 'query' => 'David', |
|
| 21 | + 'fields' => 'first_name,address_email', |
|
| 22 | + 'offset' => 0, |
|
| 23 | + 'limit' => 5 |
|
| 24 | 24 | ); |
| 25 | 25 | |
| 26 | 26 | $abcResult = $ablocation->searchAddressBookLocations($params); |
@@ -13,8 +13,8 @@ discard block |
||
| 13 | 13 | // Get two random locations IDs |
| 14 | 14 | |
| 15 | 15 | $adressBookLocationParameters = array( |
| 16 | - "limit" => 30, |
|
| 17 | - "offset" => 0 |
|
| 16 | + "limit" => 30, |
|
| 17 | + "offset" => 0 |
|
| 18 | 18 | ); |
| 19 | 19 | |
| 20 | 20 | $abContacts = new AddressBookLocation(); |
@@ -38,6 +38,6 @@ discard block |
||
| 38 | 38 | $results = $ablocation->getValue($abcResult, "results"); |
| 39 | 39 | |
| 40 | 40 | foreach ($results as $result) { |
| 41 | - Route4Me::simplePrint($result); |
|
| 42 | - echo "<br>"; |
|
| 41 | + Route4Me::simplePrint($result); |
|
| 42 | + echo "<br>"; |
|
| 43 | 43 | } |