<?php

/**
 *
 * Api to load results of the current member bets after archive date
 * USE ONLY ON MOBILE
 * 
 * @author flabadens
 * @version 1.0
 * @param sessid int session id
 * 
 */
if ($versionmobile){
    include_once("../config.php3");
    $RACINE_DIR="../";
    $CORE = "CORE/";
}
else {
    include_once("config.php3");
    $RACINE_DIR="";
}
include_once($RACINE_DIR.$MOBILE_DIR."configMobile.php3");
include_once($RACINE_DIR.$BIB_DIR_FROM_RACINE."bib_db.php3");
include_once($RACINE_DIR.$BIB_DIR_FROM_RACINE."bib_generic.php3");
include_once($RACINE_DIR.$BIB_DIR_FROM_RACINE."bib_check_members.php3");
include_once($RACINE_DIR.$BIB_DIR_FROM_RACINE."LOC_bib_check_members_vip.php3");
include_once($RACINE_DIR.$BIB_DIR_FROM_RACINE."bib_exploitation.php3");
include_once("MyBets.functions.php");

// get session infos
$sess = open_page($sessid);

if ($sess->memberid == -1){

    if (!$versionmobile){
        $sess->redirect($REGISTRATION_PAGE, "");
    }
    else {
        echo "ErrorSESSID";
        exit();
    }
}

$member = getmember($sess->memberid);
$player = getplayer($sess->memberid);



$current_european_date = date("Y-m-d H:i:s", my_local_time());

$nbMatchsToShow = "";
if ($nbMatchsToShow == "")
{
        # on va prendre tous les paris du concours en cours
        # pour cela on récupère la date des oldScores. On ne prendra que les paris après cette date
        $DATE_ARCHIVAGE = getExploitationFile("date_archivage.php3");

        # il faut compter le nb de paris de la personne
        $squery = "SELECT COUNT(*) AS total FROM Paris WHERE PlayerId='".$player['Id']."' AND Date > '".$DATE_ARCHIVAGE."' AND Result!=''";
        $rows = main_db_query($squery);
        $row = db_fetch_assoc($rows);

        $nbMatchsToShow = $row['total'];
}

if (!isset($nbMatchsToShow) || empty( $nbMatchsToShow ) )
        $nbMatchsToShow = 15;

$results = loadResultsByContainer($containerId, $current_european_date, $nbMatchsToShow, $player[Id]);

include $RACINE_DIR . $VIEW . 'MyBetsResults.view.php';

?>
