Service Dealer Locator

    $jsondata["results"][0]["geometry"]["location"]["lat"], 'lng' => $jsondata["results"][0]["geometry"]["location"]["lng"],); return $LatLng; } /* * Check if the json data from Google Geo is valid */ function check_status($jsondata) { if ($jsondata["status"] == "OK") return true; return false; } /* * Print an array */ function d($a) { echo "
    ";
        print_r($a);
        echo "
    "; } // Initialize URL Variables // Insert Smartsheet API Token here $accessToken = "u7p2ow8v3b313o0ymdnrr409z"; // Create Headers Array for Curl $headers = array("Authorization: Bearer " . $accessToken, "Content-Type: application/json"); $ch = curl_init(); // 2. set the options, including the url curl_setopt($ch, CURLOPT_URL, "https://api.smartsheet.com/1.1/sheet/2591890727036804/"); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // 3. execute and fetch the resulting HTML output curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $output = curl_exec($ch); if ($output === FALSE) { echo "cURL Error: " . curl_error($ch); } $info = curl_getinfo($ch); $smartsheetData = curl_exec($ch); $smartsheetData = str_replace('\\\'', "'", $smartsheetData); $PrepsheetsObj = json_decode($smartsheetData); $sheetsObj = json_decode($smartsheetData, true); //private column = 172530750252932 //dealer Name 659536756402052 //confirmed column id =6645559982352260 //location column = 3553863677568900 //startdate column = 5163136383772548 //go-no-go 7771459889194884 //enddate column =4099221444945796 //dealer URL 1379249325139844 $dealerURL = "#"; $rowCounter = "0"; $prevState = ""; // Reset previous state name to remove duplicate states from listing $locationarray = array(); //loop through the rows //BUG The non approved rows are getting counted here too so I subtract the number of unapproved. $rowCount = count($sheetsObj['rows']) - 4; $columnCount = 3; $columnCounter = 1; $itemsPerColumn = floor($rowCount / $columnCount); foreach ($sheetsObj['rows'] as $key => $value) { $publish = false; $private = false; $pastorpresent = "date-passed"; $rowCounter++; //loop through the cells and build the variables foreach ($value['cells'] as $key1 => $value1) { //URL if ($value1['columnId'] == 5377488470730628) { if (isset($value1['value'])) { $dealerURL = $value1['value']; } else { $dealerURL = "#"; } } //Dealer Name if ($value1['columnId'] == 310938889938820) { $dealerName = $value1['displayValue']; } //State Name if ($value1['columnId'] == 849893934819204) { $stateName = $value1['displayValue']; } //Dealer Manager if ($value1['columnId'] == 1436838796781444) { $dealerManager = $value1['displayValue']; } //Dealer Phone if ($value1['columnId'] == 7066338330994564) { $dealerPhone = $value1['displayValue']; } //Location if ($value1['columnId'] == 2562738703624068) { if (isset($value1['value'])) { $dealerLocation = $value1['value']; } } //Latitude if ($value1['columnId'] == 5075317120362372) { if (isset($value1['value'])) { $dealerLatitude = $value1['value']; } } //Longitude if ($value1['columnId'] == 2823517306677124) { if (isset($value1['value'])) { $dealerLongitude = $value1['value']; } } //Confirmed if ($value1['columnId'] == 3125688657045380) { if (isset($value1['value']) && $value1['value'] == true) { $publish = true; } } } if ($publish != false) { //Start building each dealer display $rowDisplay = '
    ' . $dealerName . '
    ' . $dealerManager . '
    ' . $dealerPhone . '
    '; $rowlocation = "" . $dealerLocation . ""; $dealerpopup = $dealerName . "
    " . $dealerLocation; if ($publish != false) { if (isset($dealerLatitude)) { $locationarray[] = array('lat' => $dealerLatitude, 'lng' => $dealerLongitude, 'data' => $dealerpopup); } else { $locationarray[] = array('address' => $dealerLocation, 'data' => $dealerpopup); } } echo "
  • "; if ($prevState != $stateName) { $prevState = $stateName; echo '' . $stateName . ''; } echo $rowDisplay; //Replace the first comma in an address with a
    $re = "/,/"; $str = $dealerLocation; $subst = "
    "; $result = preg_replace($re, $subst, $str, 1); echo '' . $result . $rowCounter . ''; //Make a new column if this row is exaclty divisible by itemsPerColumn if (($rowCounter % $itemsPerColumn) == 0 && $columnCounter < $columnCount) { $columnCounter++; echo '
    '; } else { echo "
"; } } }; ?>
VIA Dealer Service Portal
2014-vtrux-truck