<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  require_once "/home/jeftay6/vinsbalthazard.com/cmsAdmin/lib/viewer_functions.php";

  list($winesRecords, $winesMetaData) = getRecords(array(
    'tableName'   => 'wines',
    'where'       => whereRecordNumberInUrl(1),
  ));
  $winesRecord = @$winesRecords[0];
  
  list($winesRecords, $winesMetaData) = getRecords(array(
    'tableName'   => 'wines',
	'where'       => 'producer = "' . mysql_escape($winesRecord['producer']) . '"', 
  ));
  
  $page = 'vin'; 

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $winesRecord['page_title'] ?></title>
<meta name="Description" content="<?php echo $winesRecord['page_title'] ?>" />
<meta name="KeyWords" content="<?php echo $winesRecord['meta_keywords'] ?>" />
<link rel="shortcut icon" href="/images/balthazard.ico">
<link rel="stylesheet" href="/css/style.css" type="text/css" media="screen" />
<!--[if lte IE 6]>
<script src="/js/pngfix/supersleight-min.js" type="text/javascript" charset="utf-8"></script>
<![endif]-->
</head>

<body class="<?php echo $page ?>">
<div id="wrap">
	<?php include ($_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'); ?>  	
    <ul class="verticalwineinfo">
              <li class="container <?php if ($winesRecord['couleur'] == 'Blanc'): ?>white<?php endif; ?><?php if ($winesRecord['couleur'] == 'Rouge'): ?>red<?php endif; ?><?php if ($winesRecord['couleur'] == 'Rosee'): ?>rosee<?php endif; ?>">
              	<div class="winepic">
                	<?php foreach ($winesRecord['image'] as $upload): ?>
                    	<img src="<?php echo $upload['urlPath'] ?>" width="363" height="313" alt="<?php echo $winesRecord['title'] ?>" align="left" />
                        <?php break; ?> 
                    <?php endforeach ?>
                </div>
              	<ul class="infovin">
                	<li class="winename"><h1><a href="<?php echo $winesRecord['_link'] ?>"><?php echo $winesRecord['title'] ?></a></h1></li>
                    <li><strong><?php echo $winesRecord['producer'] ?>, <?php echo $winesRecord['region'] ?>, <?php echo $winesRecord['country'] ?></strong></li>
                    <li><strong>Appelation</strong> <?php echo $winesRecord['origin'] ?></li>
                    <li><strong>Encepagement:</strong> <?php echo $winesRecord['grape_variety'] ?></li>
                    <li><strong>Consomation:</strong> <?php echo $winesRecord['best_before'] ?></li>
                    <li><strong>Disponibilité:</strong> <?php echo $winesRecord['availability'] ?></li>
                    <li><strong>Format:</strong> <?php echo $winesRecord['format'] ?></li>
                    <li><strong>Fiche technique:</strong> <?php foreach ($winesRecord['technical_doc'] as $upload): ?><a href="<?php echo $upload['urlPath'] ?>">PDF</a><?php endforeach ?></li>
                    <?php if ($winesRecord['mentions'] != 0): ?> 
                    <li><strong>Mention(s):</strong> <?php echo $winesRecord['mentions'] ?></li>
                    <?php endif ?>
                    <li><a href="javascript:window.print()"><img src="/images/print-this-page.png" width="144" height="28" alt="Imprimer la page" /></a></li>                    
              	</ul>
                <ul class="saq">
                	<li>Prix: <?php echo $winesRecord['price'] ?></li>
                    <li><?php echo $winesRecord['year'] ?></li>
                    <?php if ($winesRecord['saq_code'] != 0): ?> 
                    <li><span>Code SAQ: <a href="<?php echo $winesRecord['saq_code_url'] ?>" target="_blank"><?php echo $winesRecord['saq_code'] ?></a></span></li>
                    <?php endif ?>
                </ul>                
              </li>     
    </ul>
    <?php if ($winesRecord['vintages'] != null): ?>
    <h2>Vieux Millésimes</h2>
    <ul id="millesime">
    	<?php foreach ($winesRecord['vintages'] as $upload): ?>
    	<li><a href="<?php echo $upload['urlPath'] ?>"><?php echo $upload['info1'] ?></a></li>
        <?php endforeach ?>  
    </ul>
    <?php endif ?>
    <?php if ($winesRecord['quotations_content'] != null): ?>
    <h2>Cotes et Citations</h2>
    <?php echo $winesRecord['quotations_content'] ?>
    <?php endif ?>
   	<h2>Vins <?php echo $winesRecord['producer'] ?></h2>
    <table width="100%" border="0">
      <tr>
        <th width="42">&nbsp;</th>
        <th width="197">Producteur</th>
        <th width="146">Vins</th>
        <th width="113">Region</th>
        <th width="133">Millesime</th>
        <th width="207">Appellation</th>
        <th>&nbsp;</th>
      </tr>
      <?php foreach ($winesRecords as $record): ?>
      <tr>      	
        <td class="<?php if ($record['couleur'] == 'Blanc'): ?>white<?php endif; ?><?php if ($record['couleur'] == 'Rouge'): ?>red<?php endif; ?><?php if ($record['couleur'] == 'Rosee'): ?>rosee<?php endif; ?>">&nbsp;</td>
        <td><?php echo $record['producer'] ?></td>
        <td><?php echo $record['title'] ?></td>
        <td><?php echo $record['country'] ?></td>
        <td><?php echo $record['year'] ?></td>
        <td><?php echo $record['origin'] ?></td>
        <td><a href="<?php echo $record['_link'] ?>"><img src="/images/more.png" width="110" height="28" alt="Voir vin"/></a></td>        
      </tr>
      <?php endforeach ?>
    </table>    
    <?php include ($_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'); ?>    
</div> <!-- wrap end -->
</body>
</html>