Digital Pour test


[insert_php] $string =
$string =
file_get_contents(“https://server.digitalpour.com/DashboardServer/api/v3/MenuItems/5492437db3b6f60840e939ba/1/Tap?apiKey=55afd9f85e002c032cc708dd”);

$json_taps = json_decode($string, true);

$t=1;
echo ‘

‘;

foreach ($json_taps as $beverage) {

$item_name = $beverage[‘MenuItemDisplayDetail’][‘DisplayName’];
$producer_name = $beverage[‘MenuItemProductDetail’][‘FullProducerList’];
$beverage_name = $beverage[‘MenuItemProductDetail’][‘BeverageNameWithVintage’];
$beverage_style = $beverage[‘MenuItemProductDetail’][‘FulStyleName’];
$beverage_color = $beverage[‘MenuItemProductDetail’][‘Beverage’][‘StyleColor’];
$year = $beverage[‘MenuItemProductDetail’][‘Year’];
$beverage_abv = $beverage[‘MenuItemProductDetail’][‘Beverage’][‘Abv’];
$beverage_type = $beverage[‘MenuItemProductDetail’][‘BeverageType’];
$producer_location = “”;
$producer_url = “”;
switch($beverage_type) {
case “Beer”:
$producer_location = $beverage[‘MenuItemProductDetail’][‘Beverage’][‘Brewery’][‘Location’];
$producer_url = $beverage[‘MenuItemProductDetail’][‘Beverage’][‘Brewery’][‘BreweryUrl’];
break;
case “Cider”:
$producer_location = $beverage[‘MenuItemProductDetail’][‘Beverage’][‘Cidery’][‘Location’];
$producer_url = $beverage[‘MenuItemProductDetail’][‘Beverage’][‘Cidery’][‘CideryUrl’];
break;
case “Mead”:
$producer_location = $beverage[‘MenuItemProductDetail’][‘Beverage’][‘Meadery’][‘Location’];
$producer_url = $beverage[‘MenuItemProductDetail’][‘Beverage’][‘Meadery’][‘MeaderyUrl’];
break;
case “Wine”:
$producer_location = $beverage[‘MenuItemProductDetail’][‘Beverage’][‘Winery’][‘Location’];
$producer_url = $beverage[‘MenuItemProductDetail’][‘Beverage’][‘Winery’][‘WineryUrl’];
break;
case “Kombucha”:
$producer_location = $beverage[‘MenuItemProductDetail’][‘Beverage’][‘KombuchaMaker’][‘Location’];
$producer_url = $beverage[‘MenuItemProductDetail’][‘Beverage’][‘KombuchaMaker’][‘Url’];
break;
case “Soft Drink”:
$producer_location = $beverage[‘MenuItemProductDetail’][‘Beverage’][‘SoftDrinkMaker’][‘Location’];
$producer_url = $beverage[‘MenuItemProductDetail’][‘Beverage’][‘SoftDrinkMaker’][‘Url’];
break;
}
$date_put_on = $beverage[‘DatePutOn’];
$bottle_size = $beverage[‘MenuItemProductDetail’][‘Prices’][0][‘Size’];
$bottle_price = $beverage[‘MenuItemProductDetail’][‘Prices’][0][‘Price’];
$beverage_ps = $beverage[‘MenuItemProductDetail’][‘Prices’][0][‘DisplayName’];
$in_bottles = $beverage[‘MenuItemProductDetail’][‘AvailableInBottles’];
$keg_size = $beverage[‘MenuItemProductDetail’][‘KegSize’];
$oz_remaining = $beverage[‘MenuItemProductDetail’][‘EstimatedOzLeft’];
$scale = 1.0; //

//calculating percentage of keg remaining
// Get Percentage out of 100
if ( !empty($keg_size) ) { $percent = $oz_remaining / $keg_size; }
else { $percent = 0; }

// Limit to 100 percent (if more than the max is allowed)
if ( $percent > 1 ) { $percent = 1; }
if ( $percent < 0 ) { $percent = .005; } $percent_remaining = number_format($percent*100, 0); if ( $percent_remaining < 1 ) {$percent_remaining = "< 1";} //determine percent Left color // |-----------Red ---------------------------| |-------Green--------------------| |Blue| $percent_left_color = (max(0,min(255,511 * (1-$percent))) * 65536) + (max(0,min(255,511 * $percent)) * 256) + 40; $html = '

‘.

‘.

‘.
$item_name.”: “.
(!empty($producer_url) ? ‘‘ : ‘‘).$producer_name.’‘.
‘. $beverage_name.’
‘.
RB|‘.
BA

‘.
$beverage_style.’ ‘.(!empty ($beverage_abv) ?
number_format($beverage_abv, 1, ‘.’, ”).’% ‘ : ”).
‘.$beverage_location.’ ‘.
‘.($beverage_ps == ’12oz’ ? $beverage_ps : ”).’‘.

‘. ‘‘.($in_bottles == TRUE
? ‘Available in bottles!‘ :
”).’
‘.
//PERCENTAGE AND COLOR

‘.

‘.

‘.

‘.

‘.

($t == $countnumrows ? ‘

‘ : ”);

echo $html;
$t++;
}
echo ‘

‘.