<?php
//define this module's name and path
$mn = basename(__FILE__ , ".php");
include("modules/modules.php");

/*
Available variables:
All system classes
All request variables
$p (the template path)
$mp (the module path)
$sufixID (id sufix for this module's divs)
*/


$marginTop = ($moduleParameters['marginTop'] == "__EMPTY__" || empty($moduleParameters['marginTop'])) ? 0 : $moduleParameters['marginTop'];
$marginRight = ($moduleParameters['marginRight'] == "__EMPTY__" || empty($moduleParameters['marginRight'])) ? 0 : $moduleParameters['marginRight'];
$marginBottom = ($moduleParameters['marginBottom'] == "__EMPTY__" || empty($moduleParameters['marginBottom'])) ? 0 : $moduleParameters['marginBottom'];
$marginLeft = ($moduleParameters['marginLeft'] == "__EMPTY__" || empty($moduleParameters['marginLeft'])) ? 0 : $moduleParameters['marginLeft'];
$paddingTop = ($moduleParameters['paddingTop'] == "__EMPTY__" || empty($moduleParameters['paddingTop'])) ? 0 : $moduleParameters['paddingTop'];
$paddingRight = ($moduleParameters['paddingRight'] == "__EMPTY__" || empty($moduleParameters['paddingRight'])) ? 0 : $moduleParameters['paddingRight'];
$paddingBottom = ($moduleParameters['paddingBottom'] == "__EMPTY__" || empty($moduleParameters['paddingBottom'])) ? 0 : $moduleParameters['paddingBottom'];
$paddingLeft = ($moduleParameters['paddingLeft'] == "__EMPTY__" || empty($moduleParameters['paddingLeft'])) ? 0 : $moduleParameters['paddingLeft'];
$useModuleContainer = ($moduleParameters['useModuleContainer'] == "__EMPTY__" || empty($moduleParameters['useModuleContainer'])) ? 0 : (int)$moduleParameters['useModuleContainer'];
$widthInPixels = ($moduleParameters['widthInPixels'] == "__EMPTY__" || empty($moduleParameters['widthInPixels'])) ? null : (int)$moduleParameters['widthInPixels'];

if(empty($marginTop) && empty($marginRight) && empty($marginBottom) && empty($marginLeft)){
	$Mmargin = "0";
}else{
	$Mmargin = $marginTop." ".$marginRight." ".$marginBottom." ".$marginLeft." ";
}
if(empty($paddingTop) && empty($paddingRight) && empty($paddingBottom) && empty($paddingLeft)){
	$Mpadding = "0";
}else{
	$Mpadding = $paddingTop." ".$paddingRight." ".$paddingBottom." ".$paddingLeft." ";
}

$MenuTheme = $moduleParameters["MenuTheme"];

$auth = new authentication(false);
$login = $auth->getLoginStatus() != 2;
$userID = ($login) ? $_SESSION['userID'] : NULL;


if($useModuleContainer ){
?>
<div id="<?php echo $mn.$sufixID;?>" data-editable="editable" class="responsive_float">
<?php
}
?>

<style  type="text/css">
<?php
if($useModuleContainer ){
	?>
#<?php echo $mn.$sufixID;?>{
	<?php 
	$alignRule = ($moduleParameters['moduleAlign'] == "center") ? "text-align" : "float";
	echo $alignRule.": ".$moduleParameters['moduleAlign'].";".PHP_EOL;
	?>
	margin : <?php echo $Mmargin;?>;
	padding : <?php echo $Mpadding;?>;
<?php
if($widthInPixels){
	?>
	width: <?php echo $widthInPixels;?>px;
	<?php 
}	

if($moduleParameters['moduleAlign'] && $moduleParameters['moduleHR']){ // there are system parameters...

if($moduleParameters['moduleHR'] == "top" || $moduleParameters['moduleHR'] == "bottom"){
?>
	border-<?php echo $moduleParameters['moduleHR'];?> : 1px solid black;
<?php 
}
}
?>
}
<?php
}
if($MenuTheme == "light"){
?>
.open_account{
	background-position: left bottom; 
	color: #e9e9e9;
}
.open_account:hover{
	color: #e9e9e9; /* overidde general link behavior*/
}
.open_account_down_arrow{
	color: #e9e9e9;
}
<?php	
}
?>
#accountMenu<?php echo $sufixID;?>{
	display: none;
	position: absolute;
	top: 25px;
	right:0;
	border: 1px solid black;
	background-color: white;
	z-index: 9999;
	padding: 10px 0;
	min-width: 200px;
	box-shadow: 2px 2px 16px 0px rgba(0, 0, 0, 0.52) !important;
}
</style>

<div class="dropDownMenuContainer">
    <a href="javascript:void(0)" onclick="dropDownMenu($(this).attr('id'), 'accountMenu<?php echo $sufixID;?>')" id="accountMenuButton<?php echo $sufixID;?>" class="open_account">
    <?php echo t("Ο λογαριασμός μου");?><span class="open_account_down_arrow menu_content">▼</span>
    </a>
    <div id="accountMenu<?php echo $sufixID;?>" data-menu="dropdown" class="accountMenu">
    <?php
	if($userID){ // registered client
		$user_name = $content->getValue("users", $userID, "title");
		?>
        <div class="account_menu_user menu_content"><?php echo $user_name;?></div>
        <ul class="dropDownMenuOptions">
        	<li><a href="<?php $sef->url("index.php?section=users&view=profile");?>"><?php echo t("Profile"); ?></a></li>
            <?php
			if($parameters->getParameter("basket_enabled")){
			?>
            <li><a href="<?php $sef->url("index.php?section=users&view=orders");?>"><?php echo t("Παραγγελίες"); ?></a></li>
            <?php
			}
			?>
            <li><a href="<?php $sef->url("index.php?section=users&view=wishlist");?>"><?php echo t("Λίστα Αγαπημένων"); ?></a></li>
        </ul>
		<?php
        if($parameters->getParameter("basket_enabled")){
        ?>        
        <a class="dd_button rainbow menu_content" href="index.php?section=users&view=basket&langID=<?php echo $langID;?>"><?php echo t("Δείτε το καλάθι σας");?></a>
        <?php
		}
		?>
        <a class="dd_button rainbow menu_content" href="<?php echo "index.php?logout=1&langID=".$langID;?>"><?php echo t("Αποσύνδεση", $langID, "account_menu");?></a>
        <?php
	}else{ // visitor
		?>
        <div class="account_menu_user menu_content"><?php echo t("Επισκέπτης", $langID, "account_menu");?></div>
        <a class="dd_button rainbow menu_content" href="<?php $sef->url("index.php?section=users&view=login");?>"><?php echo t("Σύνδεση", $langID, "account_menu");?></a>
		<a class="dd_button rainbow menu_content" href="<?php $sef->url("index.php?section=users&view=register");?>"><?php echo t("Εγγραφή", $langID, "account_menu");?></a>
        <?php
	}
	?>
    </div>
</div>


<?php
if($useModuleContainer ){
?>
</div>
<?php 
}
?>
