global $mycur;
    return $amount / $mycur;
}
$billing_table = new Table('cc_billing_customer', 'id,date');
$clause_last_billing = "id_card = " . $_SESSION["card_id"];
$result = $billing_table->Get_list($DBHandle, $clause_last_billing, "date", "desc");
$call_table = new Table('cc_call', 'COALESCE(SUM(sessionbill),0)');
$clause_call_billing = "card_id = " . $_SESSION["card_id"] . " AND ";
$clause_charge = "id_cc_card = " . $_SESSION["card_id"] . " AND ";
$start_date = $result[0][1];
$nbitems = nbDetailledItems($start_date);
$nb_by_page = 100;
$nb_page = ceil($nbitems / $nb_by_page);
$items = loadDetailledItems($start_date, ($page - 1) * $nb_by_page, $nb_by_page);
if ($nb_page > 1) {
    $totalprice = SumDetailledItems($start_date);
}
//load customer
$DBHandle = DbConnect();
$smarty->display('main.tpl');
//Currencies check
$curr = $_SESSION['currency'];
$currencies_list = get_currencies();
if (!isset($currencies_list[strtoupper($curr)][2]) || !is_numeric($currencies_list[strtoupper($curr)][2])) {
    $mycur = 1;
    $display_curr = strtoupper(BASE_CURRENCY);
} else {
    $mycur = $currencies_list[strtoupper($curr)][2];
    $display_curr = strtoupper($curr);
}
?>
}

$billing_table = new Table('cc_billing_customer','id,date');
$clause_last_billing = "id_card = ".$_SESSION["card_id"];
$result = $billing_table -> Get_list($DBHandle, $clause_last_billing,"date","desc");
$call_table = new Table('cc_call','COALESCE(SUM(sessionbill),0)' );
$clause_call_billing ="card_id = ".$_SESSION["card_id"]." AND ";
$clause_charge = "id_cc_card = ".$_SESSION["card_id"]." AND ";
$start_date =$result[0][1];


$nbitems = nbDetailledItems($start_date);
$nb_by_page =100;
$nb_page = ceil($nbitems/$nb_by_page);
$items = loadDetailledItems($start_date,(($page-1)*$nb_by_page),$nb_by_page);
if ($nb_page>1) $totalprice = SumDetailledItems($start_date);

//load customer
$DBHandle  = DbConnect();

$smarty->display('main.tpl');

//Currencies check
$curr = $_SESSION['currency'];
$currencies_list = get_currencies();

if (!isset($currencies_list[strtoupper($curr)][2]) || !is_numeric($currencies_list[strtoupper($curr)][2])) {
	$mycur = 1;
	$display_curr=strtoupper(BASE_CURRENCY);
} else {
	$mycur = $currencies_list[strtoupper($curr)][2];