<?php
/* **
 * @application PhpMyShopping
 * @part        Boutique
 * @file        saisie_adresse.php
 * @path        ./
 * @author      Stephane DINE <stephane@phpmyshopping.org>
 * @site        http://www.phpmyshopping.org
 * @license     http://www.php.net/license/3_0.txt  PHP License 3.0
 *
 * PHP version 5
 *
 * Affichage du formulaire pour l'adresse de livraison/facturation ainsi que le formulaire d'identification
 */

session_start();

/**
 * Client inexistant sur la boutique, meme en temporaire -> redirection vers index.php
 */
if ((!isset($_SESSION['IDC'])) or (!$_SESSION['IDC']) or ($_SESSION['IDC'] == 0)) {
	header('Location: ./index.php');
}

/**
 * Pas de panier de cree -> redirection vers index.php
 */
if ((!isset($_SESSION['IDB'])) or (!$_SESSION['IDB']) or ($_SESSION['IDB'] == 0)) {
	header('Location: ./index.php');
}

require_once './admin/include/class.shop.php';
$shop = new Shop();
$shop->log(__FILE__, array('action' => 'Ouverture fichier'));

include('./header.php');

/**
 * Variable pour le menu
 */
$smarty->assign('MENU_TOP', $shop->menuTop());
$smarty->assign('CATEGORY_LIST', $shop->listCategory());
$GenderList = $shop->liste_select('ID_Gender', array('ID_Gender', 'GenderName'), 'Gender', 'ID_Gender', 0, false, '', '', false);
$smarty->assign('ID_GENDER', $GenderList);

/**
 * Pays
 */
$sqlCountry  = 'SELECT ID_Country, CountryName FROM Country WHERE Status = "A" ORDER BY CountryName ASC';
$CountryList = $shop->liste_select('ID_Country', array('ID_Country', 'CountryName'), '', '', 75, false, '', $sqlCountry, false);
$smarty->assign('ID_COUNTRY', $CountryList);

/**
 * Etats / Departements
 */
$sqlState  = 'SELECT ID_State, StateName FROM State WHERE ID_Country = 75 ORDER BY StateName ASC';
$StateList = $shop->liste_select('ID_State', array('ID_State', 'StateName'), '', '', 0, true, array('--[ Choisissez votre &eacute;tat ou d&eacute;partement ]--' => 'X'), $sqlState, false);
$smarty->assign('ID_STATE', $StateList);


// /**
 // * Villes
 // */
// $D_sqlCity  = 'SELECT ID_City, CityName FROM City WHERE ID_State = '.$D_ID_State;
// $D_CityList = $shop->liste_select('ID_City', array('ID_City', 'CityName', 'PostCode'), '', '', $D_ID_City, false, '', $D_sqlCity, false);
// $tpln->Parse('D_ID_CITY', $D_CityList);


$companyInfo = $shop->getCompanyName();
$smarty->assign('COMPANY_NAME', $companyInfo['CompanyName']);
$smarty->assign('SIREN_CODE', $companyInfo['SirenCode']);


/**
 * Generation de la page
 */
$smarty->clear_all_cache();
$smarty->display('saisie_adresse.tpl');
?>
