Conditions | 3 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
8 | public function augmentSQL(SQLQuery &$query) |
||
9 | { |
||
10 | $address = Controller::curr()->getRequest()->getVar('Address'); |
||
11 | if ($this->owner->hasMethod('updateAddressValue')) { |
||
12 | $address = $this->owner->updateAddressValue($address); |
||
13 | } |
||
14 | if ($address) { // on frontend |
||
15 | $coords = GoogleGeocoding::address_to_point($address); |
||
16 | |||
17 | $Lat = $coords['lat']; |
||
18 | $Lng = $coords['lng']; |
||
19 | |||
20 | $query |
||
21 | ->addSelect(array( |
||
22 | '( 3959 * acos( cos( radians(' . $Lat . ') ) * cos( radians( `Lat` ) ) * cos( radians( `Lng` ) - radians(' . $Lng . ') ) + sin( radians(' . $Lat . ') ) * sin( radians( `Lat` ) ) ) ) AS distance', |
||
23 | )); |
||
24 | } |
||
25 | } |
||
26 | } |
||
27 |