//already includes config.php
//###############################procedures#####################################
if (!empty($_SESSION['client'])) {
    $arCompte = getCompteDisplay();
    $arCompte = preg_split("/,/", $arCompte);
}
//###############################variables######################################
$legend = 'Création d'une facture d'amarrage';
$deliblink = '46-2011';
$deliblink2 = '83-2010';
$fact = buildArray();
//details de la facture
$jsarType = buildJSArray($fact, 'Type');
$jsarMontantFCP = buildJSArray($fact, 'MontantFCP');
$jsarMontantEURO = buildJSArray($fact, 'MontantEURO');
$jsarUnite = buildJSArray($fact, 'Unite');
//#################################building forms################################
$InValidationList = buildFacturesEnAttente($arCompte[1]);
//$PeriodeList = buildOptionsPeriod(0);
//#################################functions#####################################
function buildJSArray($f, $col)
{
    $i = 0;
    $jsar = '';
    while ($i < count($f)) {
        $jsar .= '"' . $f[$i][$col] . '",';
        $i++;
    }
    $jsar = substr($jsar, 0, strlen($jsar) - 1);
    return $jsar;
}
$fact = buildArray("tarifs_cantines");
//details de la facture
$jsarType = buildJSArray($fact, 'status');
$jsarMontantFCP = buildJSArray($fact, 'MontantFCP');
$jsarMontantEURO = buildJSArray($fact, 'MontantEURO');
$jsarUnite = buildJSArray($fact, 'Unite');
$enf = buildArray("enfants", $arCompte[1]);
//details des enfants
//echo(print_r($enf));
$jsarID_Enfant = buildJSArray($enf, 'enfantid');
$jsarNom_Enfant = buildJSArray($enf, 'nom');
$jsarPrenom_Enfant = buildJSArray($enf, 'prenom');
$jsarEcoleID_Enfant = buildJSArray($enf, 'ecole');
$jsarEcole_Enfant = buildJSArray($enf, 'nomecole');
$jsarClasse_Enfant = buildJSArray($enf, 'classe');
$jsarStatus_Enfant = buildJSArray($enf, 'status');
//#################################building forms################################
$InValidationList = buildFacturesEnAttente($arCompte[1]);
$KidsList = buildOptionsKids($enf);
//#################################functions#####################################
function buildJSArray($f, $col)
{
    $i = 0;
    $jsar = '';
    while ($i < count($f)) {
        $jsar .= '"' . $f[$i][$col] . '",';
        $i++;
    }
    $jsar = substr($jsar, 0, strlen($jsar) - 1);
    return $jsar;
}