<?php

/**
 *
 *  View relative to MyBetsList.core
 *  Display bets 
 *
 * @author flabadens
 * @version 1.0
 * @see MyBetsResults.core.php
 * @see for colors go to configMobile.php3
 * @todo display iphone like maybe
 * 
 *
 */
?>

<?php

if ( $nbResults == 0){
    echo "Aucun pronostics dans cette rubrique";
    exit();
}

$width = 320;
$height = 197;

?>

<table width=<?php echo $width; ?> height=<?php echo $height; ?> border=0 bordercolor=#FFFFFF cellspacing=0 cellpadding=0 >
    
<?php

echo "<tr >\n";
    echo "<td width=\"1\"><img src=\"".$IMAGES_DIR."Tree/spacer.gif\"></td>\n";
    echo "<td height=7 colspan=5><img src=\"".$IMAGES_DIR."Tree/spacer.gif\"></td>\n";
    echo "<td width=\"1\" ><img src=\"".$IMAGES_DIR."Tree/spacer.gif\"></td>\n";
echo "</tr>\n";


// run all matchs
for($rPatch = 0; $rPatch < $nbResults; $rPatch++){

    $bgColor = ($bgColor == '#eaeaea')?'':'#eaeaea';


    // init variables
    $myMatch = $matchs[$rPatch];
    $matchTitle = formatString($myMatch[Team1])." - ".formatString($myMatch[Team2]);

    $matchTime = time_diff($date, $myMatch[Date]);
    
    $matchPronos= "";

    // if match already bet, get back the prono
    if ($tabAllBets[$myMatch[MatchId]] != "")
    {
        $matchPronos = "(".$tabAllBets[$myMatch[MatchId]].")";
    }

    // waiting results
    if ($matchTime < -7200)
    {
        $couleurmatch = $WAITING_RESULTS;
        $messageDate = 'r&eacute;sultat en attente';
    }
    // during the match (2h), display live
    elseif ($matchTime < 0){
        $couleurmatch = $LIVE_MATCH;
        $messageDate = 'Live';
    }
    else {
        // day of the match
        if ($current_european_date==date_mysql($myMatch[Date])) {
            $couleurmatch = $TODAY_MATCH;
            $messageDate = date("d/m", strtotime($myMatch[Date])).' &agrave; '.time_mysql($myMatch[Date]);
        }
        else {
            // waiting pronos
            if( $matchPronos != "" )
                $couleurmatch = $ALREADY_BET;
            else
                $couleurmatch = $NOT_ALREADY_BET;

            $messageDate = date("d/m", strtotime($myMatch[Date])).' &agrave; '.time_mysql($myMatch[Date]);
            
        }
    }

    $matchDate = '<font color='.$couleurmatch.'>'.$messageDate.'</font>';
    $matchTitle = '<font color='.$couleurmatch.'>'.$matchTitle.'</font>';
    $mise = ($tabAllAmounts[$myMatch[MatchId]] > 0)?'<font color='.$couleurmatch.'>Points misés: '.$tabAllAmounts[$myMatch[MatchId]].'</font>':'';
    $pronos = ( $matchPronos )? '<font color='.$couleurmatch.'>Score : '.$matchPronos.'</font>': '';

    ?>
    <tr>
        <!--a style="font-size: 12px" href="#" onclick="currentPronoDisplay(<?php echo $myMatch[MatchId] ?>);">-->
        <td width="1" bgcolor="<?php echo $bgColor;?>" >
            <img src="<?php echo $IMAGES_DIR; ?>Tree/spacer.gif">
        </td>
        <td width=20 class=smallDark bgcolor="<?php echo $bgColor;?>">
            &nbsp;<img src="<?php echo $IMAGES_DIR.$myMatch['Image']; ?>" onMouseover="showtip(this,event,'<?php echo addslashes($myMatch['Name']); ?>')" onMouseout="hidetip()">
        </td>

        <?php $link_tooltip = "onMouseover=\"showtip(this,event,'".addslashes($myMatch['Name'])."')\" onMouseout=\"hidetip()\""; ?>
        <td class=smallDark bgcolor="<?php echo $bgColor;?>">
            <?php
                echo "<a class=smallDarkLink ".$link_tooltip." href=\"".$sess->link3($DISPLAY_GRID_OF_BETS,"sessid=".$sess->sessid."&containerId=".getContainerByCategoryId($myMatch['Category'])."&categoryId=".$myMatch['Category'])."\" target=_top>";
                echo $matchTitle."</a>\n";
            ?>
        </td>
        <td class=smallDark bgcolor="<?php echo $bgColor;?>"><?php echo $matchDate; ?></td>
        <td width="1" bgcolor="<?php echo $bgColor;?>"><img src="<?php echo $IMAGES_DIR; ?>Tree/spacer.gif"></td>

        <!--</a>-->
    </tr>
    <?php
    echo "<tr>\n";
    echo "<td width=\"1\"><img src=\"".$IMAGES_DIR."Tree/spacer.gif\"></td>\n";
    echo "<td colspan=5 class=smallDark height=1><img src=\"".$IMAGES_DIR."spacer.gif\" ></td>\n";
    echo "<td width=\"1\"><img src=\"".$IMAGES_DIR."Tree/spacer.gif\"></td>\n";
    echo "</tr>\n";
}



if ($nbResults==0)
{
    echo "<tr>\n";
        echo "<td width=\"1\" ><img src=\"".$IMAGES_DIR."Tree/spacer.gif\"></td>\n";
        echo "<td class=smallDark align=center colspan=5>".C_AUCUNPARIS."<br></td>\n";
        echo "<td width=\"1\" ><img src=\"".$IMAGES_DIR."Tree/spacer.gif\"></td>\n";
    echo "</tr>\n";
}

echo "<tr >\n";
    echo "<td width=\"1\"><img src=\"".$IMAGES_DIR."Tree/spacer.gif\"></td>\n";
    echo "<td height=7 colspan=5><img src=\"".$IMAGES_DIR."Tree/spacer.gif\"></td>\n";
    echo "<td width=\"1\" ><img src=\"".$IMAGES_DIR."Tree/spacer.gif\"></td>\n";
echo "</tr>\n";

echo "<tr >\n";
    echo "<td width=\"1\" ><img src=\"".$IMAGES_DIR."Tree/spacer.gif\"></td>\n";
    echo "<td valign=bottom colspan=10 align=right class=smallDark>";

    echo "<img align=\"absmiddle\" border=0 src=\"".$IMAGES_DIR."triangleorange.gif\">&nbsp;";
    echo "<a class=smallDarkLink href=\"".$sess->link3($CHOOSE_BET_PAGE,"")."\" target=_top>";
    echo "Tous les pronostics";

    echo "</td >";

echo "</tr>\n";

?>
</table>