$p_post = null;
        if (isset($_REQUEST['pre_def']) && $_REQUEST['pre_def'] != '') {
            $op->set_od_id($_REQUEST['pre_def']);
            $p_post = $op->compute_array();
        }
    }
}
$p_msg = isset($p_msg) ? $p_msg : "";
print '<p class="notice">' . $p_msg . '</p>';
echo '<form method="post"  class="print">';
echo dossier::hidden();
echo HtmlInput::request_to_hidden(array('ac'));
echo $ledger->input($p_post);
echo '<div style="position:absolute;width:40%;right:20px">';
echo '<table class="info_op">' . '<tr>' . td(_('Débit')) . '<td id="totalDeb"></td>' . td(_('Crédit')) . ' <td id="totalCred"></td>' . td(_('Difference')) . ' <td id="totalDiff"></td>';
echo '</table>';
echo '</div>';
$iconcerned = new IConcerned('jrn_concerned');
$iconcerned->amount_id = "totalDeb";
echo "Opération rapprochée : " . $iconcerned->input();
echo '<p>';
echo HtmlInput::button('add', _('Ajout d\'une ligne'), 'onClick="quick_writing_add_row()"');
echo HtmlInput::submit('summary', _('Sauvez'));
echo '</p>';
echo '</form>';
echo "<script>checkTotalDirect();</script>";
echo create_script(" update_name()");
if ($g_parameter->MY_DATE_SUGGEST == 'Y') {
    echo create_script(" get_last_date()");
}
echo '</div>';
        $rmReconciliation->javascript = "return confirm_box(null,'" . _("vous confirmez?") . "',";
        $rmReconciliation->javascript .= sprintf('function () { dropLink(\'%s\',\'%s\',\'%s\',\'%s\');deleteRowRec(\'%s\',$(\'row%d\'));})', $gDossier, $div, $jr_id, $aRap[$e], $tableid, $e);
        if ($access == 'W') {
            $remove = $rmReconciliation->input();
        } else {
            $remove = '';
        }
        $comment = strip_tags($array_jr[0]['jr_comment']);
        echo tr(td(format_date($array_jr[0]['jr_date'])) . td('<a class="line" href="javascript:void(0)" onclick="' . $str . '" >' . $internal . '</A>') . td($comment) . td(nbm($amount)) . td($remove), ' id = "row' . $e . '"');
    }
    echo '</table>';
}
if ($access == 'W') {
    $wConcerned = new IConcerned("rapt" . $div);
    $wConcerned->amount_id = $obj->det->jr_montant;
    echo $wConcerned->input();
}
?>
</div>
<div id="linked_action_div<?php 
echo $div;
?>
" style="display:<?php 
echo $a_tab['linked_action_div']['display'];
?>
" class="myfieldset">
         <?php 
// display title only in popup
if ($div == 'popup') {
    ?>
 
 function input($p_array = null, $notused = 0)
 {
     global $g_parameter, $g_user;
     if ($p_array != null) {
         extract($p_array);
     }
     $pview_only = false;
     $min_article = $this->get_min_row();
     $f_add_button = new IButton('add_card');
     $f_add_button->label = _('Créer une nouvelle fiche');
     $f_add_button->set_attribute('ipopup', 'ipop_newcard');
     $f_add_button->set_attribute('jrn', $this->id);
     $f_add_button->javascript = " this.jrn=\$('p_jrn').value;select_card_type(this);";
     $str_add_button = $g_user->check_action(FICADD) == 1 ? $f_add_button->input() : "";
     // The first day of the periode
     $pPeriode = new Periode($this->db);
     list($l_date_start, $l_date_end) = $pPeriode->get_date_limit($g_user->get_periode());
     if ($g_parameter->MY_DATE_SUGGEST == 'Y') {
         $op_date = !isset($e_date) ? $l_date_start : $e_date;
     } else {
         $op_date = !isset($e_date) ? '' : $e_date;
     }
     $r = "";
     $r .= dossier::hidden();
     $f_legend = 'Banque, caisse';
     //  Date
     //--
     $Date = new IDate("e_date", $op_date);
     $Date->setReadOnly($pview_only);
     $f_date = $Date->input();
     $f_period = '';
     if ($this->check_periode() == true) {
         // Periode
         //--
         $l_user_per = isset($periode) ? $periode : $g_user->get_periode();
         $period = new IPeriod();
         $period->cn = $this->db;
         $period->type = OPEN;
         $period->value = $l_user_per;
         $period->user = $g_user;
         $period->name = 'periode';
         try {
             $l_form_per = $period->input();
         } catch (Exception $e) {
             if ($e->getCode() == 1) {
                 throw new Exception(_("Aucune période ouverte"));
             }
         }
         $label = HtmlInput::infobulle(3);
         $f_period = "Période comptable {$label}" . $l_form_per;
     }
     // Ledger (p_jrn)
     //--
     $onchange = "update_bank();ajax_saldo('first_sold');update_name();update_row('fin_item');";
     if ($g_parameter->MY_DATE_SUGGEST == 'Y') {
         $onchange .= 'get_last_date();';
     }
     if ($g_parameter->MY_PJ_SUGGEST == 'Y') {
         $onchange .= 'update_pj();';
     }
     $add_js = 'onchange="' . $onchange . '"';
     $wLedger = $this->select_ledger('FIN', 2);
     if ($wLedger == null) {
         throw new Exception(_('Pas de journal disponible'));
     }
     $wLedger->javascript = $add_js;
     $label = " Journal " . HtmlInput::infobulle(2);
     $f_jrn = $label . $wLedger->input();
     // retrieve bank name, code and account from the jrn_def.jrn_def_bank
     $f_bank = '<span id="bkname">' . $this->get_bank_name() . '</span>';
     if ($this->bank_id == "") {
         echo h2("Journal de banque non configuré " . $this->get_name(), ' class="error"');
         echo '<span class="error"> vous devez donner à ce journal un compte en banque (fiche), modifiez dans CFGLED</span>';
         alert("Journal de banque non configuré " . $this->get_name());
     }
     $f_legend_detail = 'Opérations financières';
     //--------------------------------------------------
     // Saldo begin end
     //-------------------------------------------------
     // Extrait
     $default_pj = '';
     if ($g_parameter->MY_PJ_SUGGEST == 'Y') {
         $default_pj = $this->guess_pj();
     }
     $wPJ = new IText('e_pj');
     $wPJ->readonly = false;
     $wPJ->size = 10;
     $wPJ->value = isset($e_pj) ? $e_pj : $default_pj;
     $f_extrait = $wPJ->input() . HtmlInput::hidden('e_pj_suggest', $default_pj);
     $label = HtmlInput::infobulle(7);
     $first_sold = isset($first_sold) ? $first_sold : "";
     $wFirst = new INum('first_sold', $first_sold);
     $last_sold = isset($last_sold) ? $last_sold : "";
     $wLast = new INum('last_sold', $last_sold);
     $max = isset($nb_item) ? $nb_item : $min_article;
     $r .= HtmlInput::hidden('nb_item', $max);
     //--------------------------------------------------
     // financial operation
     //-------------------------------------------------
     $array = array();
     // Parse each " tiers"
     for ($i = 0; $i < $max; $i++) {
         $tiers = isset(${"e_other" . $i}) ? ${"e_other" . $i} : "";
         $tiers_amount = isset(${"e_other{$i}" . "_amount"}) ? round(${"e_other{$i}" . "_amount"}, 2) : 0;
         $tiers_comment = isset(${"e_other{$i}" . "_comment"}) ? ${"e_other{$i}" . "_comment"} : "";
         $operation_date = new IDate("dateop" . $i);
         $operation_date->value = isset(${'dateop' . $i}) ? ${'dateop' . $i} : "";
         $array[$i]['dateop'] = $operation_date->input();
         ${"e_other{$i}" . "_amount"} = isset(${"e_other{$i}" . "_amount"}) ? ${"e_other{$i}" . "_amount"} : 0;
         $W1 = new ICard();
         $W1->label = "";
         $W1->name = "e_other" . $i;
         $W1->id = "e_other" . $i;
         $W1->value = $tiers;
         $W1->extra = 'deb';
         // credits
         $W1->typecard = 'deb';
         $W1->style = ' style = "vertical-align:65%"';
         $W1->set_dblclick("fill_ipopcard(this);");
         $W1->set_attribute('ipopup', 'ipopcard');
         // name of the field to update with the name of the card
         $W1->set_attribute('label', 'e_other_name' . $i);
         // name of the field to update with the name of the card
         $W1->set_attribute('typecard', 'filter');
         // Add the callback function to filter the card on the jrn
         $W1->set_callback('filter_card');
         $W1->set_function('fill_data');
         $W1->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $W1->name);
         $W1->readonly = $pview_only;
         $array[$i]['qcode'] = $W1->input();
         $array[$i]['search'] = $W1->search();
         // Card name
         //
         $card_name = "";
         if ($tiers != "") {
             $fiche = new Fiche($this->db);
             $fiche->get_by_qcode($tiers);
             $card_name = $this->db->get_value("Select ad_value from fiche_detail where ad_id=\$1 and f_id=\$2", array(ATTR_DEF_NAME, $fiche->id));
         }
         $wcard_name = new IText("e_other_name" . $i, $card_name);
         $wcard_name->id = $wcard_name->name;
         $wcard_name->readOnly = true;
         $array[$i]['cname'] = $wcard_name->input();
         // Comment
         $wComment = new IText("e_other{$i}" . "_comment", $tiers_comment);
         $wComment->size = 35;
         $wComment->setReadOnly($pview_only);
         $array[$i]['comment'] = $wComment->input();
         // amount
         $wAmount = new INum("e_other{$i}" . "_amount", $tiers_amount);
         $wAmount->size = 7;
         $wAmount->setReadOnly($pview_only);
         $array[$i]['amount'] = $wAmount->input();
         // concerned
         ${"e_concerned" . $i} = isset(${"e_concerned" . $i}) ? ${"e_concerned" . $i} : "";
         $wConcerned = new IConcerned("e_concerned" . $i, ${"e_concerned" . $i});
         $wConcerned->tiers = "e_other" . $i;
         $wConcerned->setReadOnly($pview_only);
         $wConcerned->amount_id = "e_other" . $i . "_amount";
         $wConcerned->paid = 'paid';
         $array[$i]['concerned'] = $wConcerned->input();
     }
     ob_start();
     require_once NOALYSS_INCLUDE . '/template/form_ledger_fin.php';
     $r .= ob_get_contents();
     ob_end_clean();
     $r .= create_script("\$('" . $Date->id . "').focus()");
     return $r;
 }