*/
            $progress = 0;
            $current_exercice = $op['p_exercice'];
            $tot_deb = 0;
            $tot_cred = 0;
        }
        $diff = bcsub($op['deb_montant'], $op['cred_montant']);
        $progress = bcadd($progress, $diff);
        $tot_deb = bcadd($tot_deb, $op['deb_montant']);
        $tot_cred = bcadd($tot_cred, $op['cred_montant']);
        echo '"' . $op['j_qcode'] . '";' . '"' . $op['j_date_fmt'] . '"' . ";" . '"' . $op['jr_pj_number'] . '"' . ";" . '"' . $op['jr_internal'] . '"' . ";" . '"' . $op['jrn_def_code'] . '"' . ";" . '"' . $op['jrn_def_name'] . '"' . ";" . '"' . $op['description'] . '"' . ";" . nb($op['deb_montant']) . ";" . nb($op['cred_montant']) . ";" . nb(abs($progress)) . ';' . '"' . ($op['letter'] == -1 ? '' : strtoupper(base_convert($op['letter'], 10, 36))) . '"';
        printf("\n");
    }
} else {
    echo '"Poste";"Qcode";"date";"ref";"internal";';
    echo "\"Description\";" . "\"Montant\";" . "\"D/C\"";
    printf("\r\n");
    foreach ($Fiche->row as $op) {
        $acc = new Acc_Operation($cn);
        $acc->jr_id = $op['jr_id'];
        $result = $acc->get_jrnx_detail();
        foreach ($result as $r) {
            printf('"%s";"%s";"%s";"%s";"%s";%s;%s;"%s"', $r['j_poste'], $r['j_qcode'], $r['jr_date'], $op['jr_pj_number'], $r['jr_internal'], $r['description'], nb($r['j_montant']), $r['debit']);
            printf("\r\n");
        }
    }
}
$solde_type = $tot_deb > $tot_cred ? "solde débiteur" : "solde créditeur";
$diff = abs($tot_deb - $tot_cred);
printf('"' . "{$solde_type}" . '"' . ";" . nb($diff) . ";" . nb($tot_deb) . ";" . nb($tot_cred) . "\n");
exit;
        }
        $solde_type = $tot_deb > $tot_cred ? "solde débiteur" : "solde créditeur";
        $diff = abs($tot_deb - $tot_cred);
        printf(";;;" . '"' . _('total') . '";' . '"' . $current_exercice . '";' . '"' . "{$solde_type}" . '"' . ";" . nb($tot_deb) . ";" . nb($tot_cred) . ";" . nb($diff) . ";" . "\n");
    }
} else {
    /* detail of all operation */
    if (count($a_poste) == 0) {
        exit;
    }
    foreach ($a_poste as $pos) {
        $Poste = new Acc_Account_Ledger($cn, $pos['pcm_val']);
        $Poste->get_name();
        list($array, $tot_deb, $tot_cred) = $Poste->get_row_date($_REQUEST['from_periode'], $_REQUEST['to_periode'], $_GET['ople']);
        if (count($Poste->row) == 0) {
            continue;
        }
        echo '"Poste";' . '"Lib.";' . '"QuickCode";' . "\"Code interne\";" . "\"Date\";" . "\"Description\";" . "\"Montant\";" . "\"D/C\"";
        printf("\n");
        foreach ($Poste->row as $a) {
            $op = new Acc_Operation($cn);
            $op->jr_id = $a['jr_id'];
            $result = $op->get_jrnx_detail();
            foreach ($result as $r) {
                printf('"%s";"%s";"%s";"%s";"%s";"%s";"%s";%12.2f;"%s"', $r['j_poste'], $r['pcm_lib'], $r['j_qcode'], $r['jr_internal'], $r['jr_date'], $a['description'], $a['jr_pj_number'], nb($r['j_montant']), $r['debit']);
                printf("\r\n");
            }
        }
    }
    exit;
}
 $pdf->Cell($size[$l], 6, sprintf('% 12.2f', $row['deb_montant']), 0, 0, $align[$l]);
 $l++;
 $pdf->Cell($size[$l], 6, sprintf('% 12.2f', $row['cred_montant']), 0, 0, $align[$l]);
 $l++;
 $pdf->Cell($size[$l], 6, sprintf('% 12.2f', abs($prog)), 0, 0, $align[$l]);
 $l++;
 $pdf->ln();
 $tot_deb = bcadd($tot_deb, $row['deb_montant']);
 $tot_cred = bcadd($tot_deb, $row['cred_montant']);
 /* -------------------------------------- */
 /* if details are asked we show them here */
 /* -------------------------------------- */
 if (isset($_GET['oper_detail'])) {
     $detail = new Acc_Operation($cn);
     $detail->jr_id = $row['jr_id'];
     $a_detail = $detail->get_jrnx_detail();
     for ($f = 0; $f < count($a_detail); $f++) {
         $l = 0;
         $pdf->Cell($size[$l], 6, '', 0, 0, $align[$l]);
         $l++;
         $pdf->Cell($size[$l], 6, $a_detail[$f]['j_qcode'], 0, 0, $align[$l]);
         $l++;
         $pdf->Cell($size[$l], 6, $a_detail[$f]['j_poste'], 0, 0, $align[$l]);
         $l++;
         if ($a_detail[$f]['j_qcode'] == '') {
             $lib = $a_detail[$f]['pcm_lib'];
         } else {
             $f_id = $cn->get_value('select f_id from vw_poste_qcode where j_qcode=$1', array($a_detail[$f]['j_qcode']));
             $lib = $cn->get_value('select ad_value from fiche_detail where ad_id=$1 and f_id=$2', array(ATTR_DEF_NAME, $f_id));
         }
         $pdf->Cell($size[$l], 6, $lib, 0, 0, $align[$l]);