Пример #1
0
 /**
  * @brief show the result of the array to confirm
  * before inserting
  * @param$p_array array from the form
  * \return string
  */
 function confirm($p_array, $p_readonly = false)
 {
     global $g_parameter;
     $msg = array();
     if (!$p_readonly) {
         $msg = $this->verify($p_array);
     }
     $this->id = $p_array['p_jrn'];
     if (empty($p_array)) {
         return 'Aucun résultat';
     }
     $anc = null;
     extract($p_array);
     $lPeriode = new Periode($this->db);
     if ($this->check_periode() == true) {
         $lPeriode->p_id = $period;
     } else {
         $lPeriode->find_periode($e_date);
     }
     $total_deb = 0;
     $total_cred = 0;
     bcscale(2);
     $ret = "";
     if (!empty($msg)) {
         $ret .= $this->display_warning($msg, _("Attention : il vaut mieux utiliser les fiches que les postes comptables"));
     }
     $ret .= "<table >";
     $ret .= "<tr><td>" . _('Date') . " : </td><td>{$e_date}</td></tr>";
     /* display periode */
     $date_limit = $lPeriode->get_date_limit();
     $ret .= '<tr> ' . td(_('Période Comptable')) . td($date_limit['p_start'] . '-' . $date_limit['p_end']) . '</tr>';
     $ret .= "<tr><td>" . _('Libellé') . " </td><td>" . h($desc) . "</td></tr>";
     $ret .= "<tr><td>" . _('PJ Num') . " </td><td>" . h($e_pj) . "</td></tr>";
     $ret .= '</table>';
     $ret .= "<table class=\"result\">";
     $ret .= "<tr>";
     $ret .= "<th>" . _('Quick Code ou ');
     $ret .= _("Poste") . " </th>";
     $ret .= "<th style=\"text-align:left\"> " . _("Libellé") . " </th>";
     $ret .= "<th style=\"text-align:right\">" . _("Débit") . "</th>";
     $ret .= "<th style=\"text-align:right\">" . _("Crédit") . "</th>";
     /* if we use the AC */
     if ($g_parameter->MY_ANALYTIC != 'nu') {
         $anc = new Anc_Plan($this->db);
         $a_anc = $anc->get_list();
         $x = count($a_anc);
         /* set the width of the col */
         $ret .= '<th colspan="' . $x . '" style="width:auto;text-align:center" >' . _('Compt. Analytique') . '</th>';
         /* add hidden variables pa[] to hold the value of pa_id */
         $ret .= Anc_Plan::hidden($a_anc);
     }
     $ret .= "</tr>";
     $ret .= HtmlInput::hidden('e_date', $e_date);
     $ret .= HtmlInput::hidden('desc', $desc);
     $ret .= HtmlInput::hidden('period', $lPeriode->p_id);
     $ret .= HtmlInput::hidden('e_pj', $e_pj);
     $ret .= HtmlInput::hidden('e_pj_suggest', $e_pj_suggest);
     $mt = microtime(true);
     $ret .= HtmlInput::hidden('mt', $mt);
     // For predefined operation
     $ret .= HtmlInput::hidden('e_comm', $desc);
     $ret .= HtmlInput::hidden('jrn_type', $this->get_type());
     $ret .= HtmlInput::hidden('p_jrn', $this->id);
     $ret .= HtmlInput::hidden('nb_item', $nb_item);
     if ($this->with_concerned == true) {
         $ret .= HtmlInput::hidden('jrn_concerned', $jrn_concerned);
     }
     $ret .= dossier::hidden();
     $count = 0;
     for ($i = 0; $i < $nb_item; $i++) {
         if ($p_readonly == true) {
             if (!isset(${'qc_' . $i})) {
                 ${'qc_' . $i} = '';
             }
             if (!isset(${'poste' . $i})) {
                 ${'poste' . $i} = '';
             }
             if (!isset(${'amount' . $i})) {
                 ${'amount' . $i} = '';
             }
         }
         $class = $i % 2 == 0 ? ' class="even" ' : ' class="odd" ';
         $ret .= "<tr {$class}> ";
         if (trim(${'qc_' . $i}) != "") {
             $oqc = new Fiche($this->db);
             $oqc->get_by_qcode(${'qc_' . $i}, false);
             $strPoste = $oqc->strAttribut(ATTR_DEF_ACCOUNT);
             $ret .= "<td>" . ${'qc_' . $i} . ' - ' . $oqc->strAttribut(ATTR_DEF_NAME) . HtmlInput::hidden('qc_' . $i, ${'qc_' . $i}) . '</td>';
         }
         if (trim(${'qc_' . $i}) == "" && trim(${'poste' . $i}) != "") {
             $oposte = new Acc_Account_Ledger($this->db, ${'poste' . $i});
             $strPoste = $oposte->id;
             $ret .= "<td>" . h(${"poste" . $i} . " - " . $oposte->get_name()) . HtmlInput::hidden('poste' . $i, ${'poste' . $i}) . '</td>';
         }
         if (trim(${'qc_' . $i}) == "" && trim(${'poste' . $i}) == "") {
             continue;
         }
         $ret .= "<td>" . h(${"ld" . $i}) . HtmlInput::hidden('ld' . $i, ${'ld' . $i});
         $ret .= isset(${"ck{$i}"}) ? HtmlInput::hidden('ck' . $i, ${'ck' . $i}) : "";
         $ret .= "</td>";
         if (isset(${"ck{$i}"})) {
             $ret .= "<td class=\"num\">" . nbm(${"amount" . $i}) . HtmlInput::hidden('amount' . $i, ${'amount' . $i}) . "</td>" . td("");
             $total_deb = bcadd($total_deb, ${'amount' . $i});
         } else {
             $ret .= td("") . "<td class=\"num\">" . nbm(${"amount" . $i}) . HtmlInput::hidden('amount' . $i, ${'amount' . $i}) . "</td>";
             $total_cred = bcadd($total_cred, ${"amount" . $i});
         }
         /*$ret.="<td>";
         		$ret.=(isset(${"ck$i"})) ? HtmlInput::hidden('ck' . $i, ${'ck' . $i}) : "";
         		$ret.="</td>";*/
         // CA
         if ($g_parameter->MY_ANALYTIC != 'nu') {
             if (preg_match("/^[6,7]+/", $strPoste) == 1) {
                 // show form
                 $op = new Anc_Operation($this->db);
                 $null = $g_parameter->MY_ANALYTIC == 'op' ? 1 : 0;
                 $p_array['pa_id'] = $a_anc;
                 /* op is the operation it contains either a sequence or a jrnx.j_id */
                 $ret .= HtmlInput::hidden('op[]=', $i);
                 $ret .= '<td style="text-align:center">';
                 $read = $p_readonly == true ? 0 : 1;
                 $ret .= $op->display_form_plan($p_array, $null, $read, $count, round(${'amount' . $i}, 2));
                 $ret .= '</td>';
                 $count++;
             }
         }
         $ret .= "</tr>";
     }
     $ret .= tr(td('') . td(_('Totaux')) . td($total_deb, 'class="num"') . td($total_cred, 'class="num"'), 'class="highlight"');
     $ret .= "</table>";
     if ($g_parameter->MY_ANALYTIC != 'nu' && $p_readonly == false) {
         $ret .= '<input type="button" class="button" value="' . _('verifie Imputation Analytique') . '" onClick="verify_ca(\'\');">';
     }
     return $ret;
 }
Пример #2
0
 /**
  * @brief Call the Anc_Operation::display_form_plan with the right amounts.
  * This function compute the array and amount to pass to the Anc_Operation::display_form_plan
  * and replace the current table of activity with the value computed from the key.
  * 
  * @global $cn database connection
  * @param $p_target Table to be replaced
  * @param $p_amount amount to distribute among activities
  */
 function fill_table($p_target, $p_amount)
 {
     global $cn;
     /* number is the index of the plan, he's computed from p_target */
     $number = preg_replace('/det[0-9]/', '', $p_target);
     $number = str_replace('t', '', $number);
     $number = str_replace('popup', '', $number);
     $op[$number] = $p_amount;
     $array['op'] = $op;
     $a_plan = $cn->get_array('select pa_id from plan_analytique order by pa_id');
     for ($i = 0; $i < count($a_plan); $i++) {
         $array['pa_id'][$i] = $a_plan[$i]['pa_id'];
     }
     $a_poste = $cn->get_array('select po_id,ke_percent,pa_id,ke_row
              from key_distribution_activity 
              join key_distribution_detail using (ke_id)  
              where
              kd_id=$1
              order by ke_row,pa_id', array($this->key->getp('id')));
     for ($i = 0; $i < count($a_poste); $i++) {
         $hplan[$number][$i] = $a_poste[$i]['po_id'] == null ? -1 : $a_poste[$i]['po_id'];
     }
     $array['hplan'] = $hplan;
     $a_amount = $cn->get_array("select distinct ke_row,ke_percent \n                 from key_distribution_activity \n                 join key_distribution_detail using (ke_id) \n                 where\n                    kd_id=\$1\n                    and pa_id=\$2\n                 order by ke_row", array($this->key->getp('id'), $a_plan[0]['pa_id']));
     bcscale(2);
     for ($i = 0; $i < count($a_amount); $i++) {
         $val[$number][$i] = bcmul($p_amount, $a_amount[$i]['ke_percent']) / 100;
     }
     $array['val'] = $val;
     $anc_operation = new Anc_Operation($cn);
     echo $anc_operation->display_form_plan($array, 1, 1, $number, $p_amount, '', false);
 }
Пример #3
0
    function confirm($p_array, $p_summary = false)
    {
        global $g_parameter;
        extract($p_array);
        // don't need to verify for a summary
        if (!$p_summary) {
            $this->verify($p_array);
        }
        $anc = null;
        // to show a select list for the analytic & VAT USE
        // if analytic is op (optionnel) there is a blank line
        bcscale(4);
        $client = new Fiche($this->db);
        $client->get_by_qcode($e_client, true);
        $client_name = $client->getName() . ' ' . $client->strAttribut(ATTR_DEF_ADRESS) . ' ' . $client->strAttribut(ATTR_DEF_CP) . ' ' . $client->strAttribut(ATTR_DEF_CITY);
        $lPeriode = new Periode($this->db);
        if ($this->check_periode() == true) {
            $lPeriode->p_id = $period;
        } else {
            $lPeriode->find_periode($e_date);
        }
        $date_limit = $lPeriode->get_date_limit();
        $r = "";
        $r .= '<TABLE>';
        if ($p_summary) {
            $jr_id = $this->db->get_value('select jr_id from jrn where jr_internal=$1', array($this->internal));
            $r .= "<tr>";
            $r .= '<td>';
            $r .= _('Détail opération ');
            $r .= '</td>';
            $r .= '<td>';
            $r .= sprintf('<a class="line" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a>', $jr_id, dossier::id(), $this->internal);
            $r .= '</td>';
            $r .= "</tr>";
        }
        $r .= '<tr>';
        if (!$p_summary) {
            $r .= '<td>' . _('Numéro Pièce') . '</td><td>' . hb($e_pj) . '</td>';
        } else {
            if (strcmp($this->pj, $e_pj) != 0) {
                $r .= '<td>' . _('Numéro Pièce') . '</td><td>' . hb($this->pj) . '<span class="notice"> ' . _('Attention numéro pièce existante, elle a du être adaptée') . '</span></td>';
            } else {
                $r .= '<td>' . _('Numéro Pièce') . '</td><td>' . hb($this->pj) . '</td>';
            }
        }
        $r .= '</tr>';
        $r .= '<tr>';
        $r .= '<td> ' . _('Date') . '</td><td> ' . hb($e_date) . '</td>';
        $r .= '</tr>';
        $r .= '<tr>';
        $r .= '<td>' . _('Echeance') . '</td><td> ' . hb($e_ech) . '</td>';
        $r .= '</tr>';
        $r .= '<tr>';
        $r .= '<td> ' . _('Période Comptable') . '</td><td> ' . hb($date_limit['p_start'] . '-' . $date_limit['p_end']) . '</td>';
        $r .= '</tr>';
        $r .= '<tr>';
        $r .= '<td> ' . _('Journal') . '</td><td> ' . hb($this->get_name()) . '</td>';
        $r .= '</tr>';
        $r .= '<tr>';
        $r .= '<td> ' . _('Libellé') . '</td><td> ' . hb($e_comm) . '</td>';
        $r .= '</tr>';
        $r .= '<tr>';
        $r .= '<td> ' . _('Client') . '</td><td> ' . hb($e_client . ':' . $client_name) . '</td>';
        $r .= '</tr>';
        $r .= '</table>';
        $r .= '<h2>' . _('Détail articles vendus') . '</h2>';
        $r .= '<p class="decale">';
        $r .= '<table class="result" >';
        $r .= '<TR>';
        $r .= "<th>" . _('Code') . "</th>";
        $r .= "<th>" . _('Dénomination') . "</th>";
        $r .= "<th style=\"text-align:right\">" . _('prix') . "</th>";
        $r .= "<th style=\"text-align:right\">" . _('quantité') . "</th>";
        if ($g_parameter->MY_TVA_USE == 'Y') {
            $r .= "<th style=\"text-align:right\">" . _('tva') . "</th>";
            $r .= '<th style="text-align:right"> ' . _('Montant TVA') . '</th>';
            $r .= '<th style="text-align:right">' . _('Montant HTVA') . '</th>';
            $r .= '<th style="text-align:right">' . _('Montant TVAC') . '</th>';
        } else {
            $r .= '<th style="text-align:right">' . _('Montant') . '</th>';
        }
        /* if we use the AC */
        if ($g_parameter->MY_ANALYTIC != 'nu') {
            $anc = new Anc_Plan($this->db);
            $a_anc = $anc->get_list();
            $x = count($a_anc);
            /* set the width of the col */
            $r .= '<th colspan="' . $x . '">' . _('Compt. Analytique') . '</th>';
            /* add hidden variables pa[] to hold the value of pa_id */
            $r .= Anc_Plan::hidden($a_anc);
        }
        $r .= '</tr>';
        $tot_amount = 0.0;
        $tot_tva = 0.0;
        for ($i = 0; $i < $nb_item; $i++) {
            if (strlen(trim(${"e_march" . $i})) == 0) {
                continue;
            }
            /* retrieve information for card */
            $fiche = new Fiche($this->db);
            $fiche->get_by_qcode(${"e_march" . $i});
            if ($g_parameter->MY_UPDLAB == 'Y') {
                $fiche_name = h(${"e_march" . $i . "_label"});
            } else {
                $fiche_name = $fiche->strAttribut(ATTR_DEF_NAME);
            }
            if ($g_parameter->MY_TVA_USE == 'Y') {
                $oTva = new Acc_Tva($this->db);
                $idx_tva = ${"e_march" . $i . "_tva_id"};
                $oTva->set_parameter('id', $idx_tva);
                $oTva->load();
            }
            $op = new Acc_Compute();
            $amount = bcmul(${"e_march" . $i . "_price"}, ${'e_quant' . $i});
            $op->set_parameter("amount", $amount);
            if ($g_parameter->MY_TVA_USE == 'Y') {
                $op->set_parameter('amount_vat_rate', $oTva->get_parameter('rate'));
                $op->compute_vat();
                $tva_computed = $op->get_parameter('amount_vat');
                $tva_item = ${"e_march" . $i . "_tva_amount"};
                if (isset($tva[$idx_tva])) {
                    $tva[$idx_tva] += $tva_item;
                } else {
                    $tva[$idx_tva] = $tva_item;
                }
                $tot_tva = round(bcadd($tva_item, $tot_tva), 2);
            }
            $tot_amount = round(bcadd($tot_amount, $amount), 2);
            $r .= '<tr>';
            $r .= '<td>';
            $r .= ${"e_march" . $i};
            $r .= '</td>';
            $r .= '<TD style="border-bottom:1px dotted grey;">';
            $r .= $fiche_name;
            $r .= '</td>';
            $r .= '<td class="num">';
            $r .= nbm(${"e_march" . $i . "_price"});
            $r .= '</td>';
            $r .= '<td class="num">';
            $r .= nbm(${"e_quant" . $i});
            $r .= '</td>';
            $both_side = 0;
            if ($g_parameter->MY_TVA_USE == 'Y') {
                $r .= '<td class="num">';
                $r .= $oTva->get_parameter('label');
                $r .= '</td>';
                $both_side = $oTva->get_parameter("both_side");
                /* warning if tva_computed and given are not the
                   same */
                if (bcsub($tva_item, $tva_computed) != 0 && !($tva_item == 0 && $both_side == 1)) {
                    $r .= '<td style="background-color:red" class="num">';
                    $r .= HtmlInput::infobulle(28);
                    $r .= '<a href="#" class="error" style="display:inline" title="' . _("Attention Différence entre TVA calculée et donnée") . '">' . nbm($tva_item) . '<a>';
                } else {
                    $r .= '<td  class="num">';
                    $r .= nbm($tva_item);
                }
                $r .= '</td>';
                $r .= '<td class="num">';
                $r .= nbm($amount);
                $r .= '</td>';
                $tot_row = bcadd($tva_item, $amount);
                $r .= td(nbm($tot_row), 'class="num"');
            } else {
                $r .= '<td class="num">';
                $r .= nbm($amount);
                $r .= '</td>';
            }
            // encode the pa
            if ($g_parameter->MY_ANALYTIC != 'nu') {
                // use of AA
                // show form
                $anc_op = new Anc_Operation($this->db);
                $null = $g_parameter->MY_ANALYTIC == 'op' ? 1 : 0;
                $r .= '<td>';
                $p_mode = $p_summary == false ? 1 : 0;
                $p_array['pa_id'] = $a_anc;
                /* op is the operation it contains either a sequence or a jrnx.j_id */
                $r .= HtmlInput::hidden('op[]=', $i);
                $r .= $anc_op->display_form_plan($p_array, $null, $p_mode, $i, $amount);
                $r .= '</td>';
            }
            $r .= '</tr>';
        }
        // end loop item
        //
        // Add the sum
        $decalage = $g_parameter->MY_TVA_USE == 'Y' ? '<td></td><td></td><td></td><td></td>' : '<td></td>';
        $tot = round(bcadd($tot_amount, $tot_tva), 2);
        $tot_tva = nbm($tot_tva);
        $tot = nbm($tot);
        $str_tot = _('Totaux');
        $tot_amount = nbm($tot_amount);
        $r .= <<<EOF
<tr class="highlight">
    {$decalage}            
     <td>
                {$str_tot}
     </td>
    <td class="num">
        {$tot_tva}
    </td>
    <td class="num">
        {$tot_amount}
    </td>
    <td class="num">
        {$tot}
    </td>
EOF;
        $r .= '</table>';
        $r .= '</p>';
        if ($g_parameter->MY_ANALYTIC != 'nu' && !$p_summary) {
            // use of AA
            $r .= '<input type="button" class="button" value="' . _('Vérifiez Imputation Analytique') . '" onClick="verify_ca(\'\');">';
        }
        $r .= !$p_summary ? '<div id="total_div_id" >' : '<div>';
        $r .= '<h2>Totaux</h2>';
        /* use VAT */
        if ($g_parameter->MY_TVA_USE == 'Y') {
            $r .= '<table>';
            $r .= '<tr><td>Total HTVA</td>';
            $r .= td(hb($tot_amount), 'class="num"');
            foreach ($tva as $i => $value) {
                $oTva->set_parameter('id', $i);
                $oTva->load();
                $r .= '<tr><td>  TVA ' . $oTva->get_parameter('label') . '</td>';
                $r .= td(hb(nbm($tva[$i])), 'class="num"');
            }
            $r .= '<tr>' . td(_('Total TVA')) . td(hb($tot_tva), 'class="num"');
            $r .= '<tr>' . td(_('Total TVAC')) . td(hb($tot), 'class="num"');
            $r .= '</table>';
        } else {
            $r .= '<br>Total ' . hb($tot);
        }
        $r .= '</div>';
        /*  Add hidden */
        $r .= HtmlInput::hidden('e_client', $e_client);
        $r .= HtmlInput::hidden('nb_item', $nb_item);
        $r .= HtmlInput::hidden('p_jrn', $p_jrn);
        $mt = microtime(true);
        $r .= HtmlInput::hidden('mt', $mt);
        if (isset($period)) {
            $r .= HtmlInput::hidden('period', $period);
        }
        /* \todo comment les types hidden gérent ils des contenus avec des quotes, double quote ou < > ??? */
        $r .= HtmlInput::hidden('e_comm', $e_comm);
        $r .= HtmlInput::hidden('e_date', $e_date);
        $r .= HtmlInput::hidden('e_ech', $e_ech);
        $r .= HtmlInput::hidden('e_pj', $e_pj);
        $r .= HtmlInput::hidden('e_pj_suggest', $e_pj_suggest);
        $e_mp = isset($e_mp) ? $e_mp : 0;
        $r .= HtmlInput::hidden('e_mp', $e_mp);
        if (isset($repo)) {
            // Show the available repository
            $r .= $this->select_depot($p_summary, $repo);
        }
        /* if the paymethod is not 0 and if a quick code is given */
        if ($e_mp != 0 && strlen(trim(${'e_mp_qcode_' . $e_mp})) != 0) {
            $r .= HtmlInput::hidden('e_mp_qcode_' . $e_mp, ${'e_mp_qcode_' . $e_mp});
            $r .= HtmlInput::hidden('acompte', $acompte);
            $r .= HtmlInput::hidden('e_comm_paiement', $e_comm_paiement);
            /* needed for generating a invoice */
            $r .= HtmlInput::hidden('qcode_benef', ${'e_mp_qcode_' . $e_mp});
            $fname = new Fiche($this->db);
            $fname->get_by_qcode(${'e_mp_qcode_' . $e_mp});
            $r .= '<h2>' . "Payé par " . ${'e_mp_qcode_' . $e_mp} . " " . $fname->getName() . '</h2> ' . '<p class="decale">' . _('Déduction acompte ') . h($acompte) . '</p>' . _('Libellé :') . h($e_comm_paiement);
            $r .= '<br>';
        }
        $r .= HtmlInput::hidden('jrn_type', $jrn_type);
        for ($i = 0; $i < $nb_item; $i++) {
            $r .= HtmlInput::hidden("e_march" . $i, ${"e_march" . $i});
            if (isset(${"e_march" . $i . "_label"})) {
                $r .= HtmlInput::hidden("e_march" . $i . "_label", ${"e_march" . $i . "_label"});
            }
            $r .= HtmlInput::hidden("e_march" . $i . "_price", ${"e_march" . $i . "_price"});
            if ($g_parameter->MY_TVA_USE == 'Y') {
                $r .= HtmlInput::hidden("e_march" . $i . "_tva_id", ${"e_march" . $i . "_tva_id"});
                $r .= HtmlInput::hidden("e_march" . $i . "_tva_amount", ${"e_march" . $i . "_tva_amount"});
            }
            $r .= HtmlInput::hidden("e_quant" . $i, ${"e_quant" . $i});
        }
        return $r;
    }
Пример #4
0
 public function confirm($p_array, $p_nothing = 0)
 {
     global $g_parameter, $g_user;
     $r = "";
     bcscale(2);
     extract($p_array);
     $pPeriode = new Periode($this->db);
     if ($this->check_periode() == true) {
         $pPeriode->p_id = $periode;
     } else {
         if (isDate($e_date) != null) {
             $pPeriode->find_periode($e_date);
         } else {
             $pPeriode->p_id = $g_user->get_periode();
         }
     }
     list($l_date_start, $l_date_end) = $pPeriode->get_date_limit();
     $exercice = $pPeriode->get_exercice();
     $r .= '';
     $r .= '<fieldset><legend>Banque, caisse </legend>';
     $r .= '<div id="jrn_name_div">';
     $r .= '<h2 id="jrn_name" style="display:inline">' . $this->get_name() . '</h2>';
     $r .= '</div>';
     $r .= '<TABLE  width="100%">';
     //  Date
     //--
     $r .= "<tr>";
     if ($chdate == 1) {
         $r .= '<td> Date : </td><td>' . $e_date;
     }
     // Periode
     //--
     $r .= "<td>";
     $r .= "Période comptable </td><td>";
     $r .= $l_date_start . ' - ' . $l_date_end;
     $r .= "</td>";
     $r .= "</tr>";
     // Ledger (p_jrn)
     //--
     $r .= '<tr>';
     $r .= '<td> Journal </td>';
     $this->id = $p_jrn;
     $r .= '<td>';
     $r .= h($this->get_name());
     $r .= '</td>';
     $r .= '</tr>';
     //retrieve bank name
     $bk_id = $this->get_bank();
     $fBank = new Fiche($this->db, $bk_id);
     $e_bank_account_label = $this->get_bank_name();
     $filter_year = "  j_tech_per in (select p_id from parm_periode where  p_exercice='" . $exercice . "')";
     $acc_account = new Acc_Account_Ledger($this->db, $fBank->strAttribut(ATTR_DEF_ACCOUNT));
     $asolde = $acc_account->get_solde_detail($filter_year);
     $deb = $asolde['debit'];
     $cred = $asolde['credit'];
     $solde = bcsub($deb, $cred);
     $new_solde = $solde;
     $r .= "<TR><td colspan=\"4\"> Banque ";
     $r .= $e_bank_account_label;
     $r .= "</TABLE>";
     $r .= '</fieldset>';
     $r .= '<div class="myfieldset"><h1 class="legend">Extrait de compte</h1>';
     //--------------------------------------------------
     // Saldo begin end
     //-------------------------------------------------
     $r .= '<table>';
     $r .= '<tr>';
     // Extrait
     //--
     $r .= tr('<td> Numéro d\'extrait</td>' . td(h($e_pj)));
     $r .= '<tr><td >Solde début extrait </td>';
     $r .= '<td style="num">' . nbm($first_sold) . '</td></tr>';
     $r .= '<tr><td>Solde fin extrait </td>';
     $r .= '<td style="num">' . nbm($last_sold) . '</td></tr>';
     $r .= '</table>';
     $r .= '<h1 class="legend">Opérations financières</h1>';
     //--------------------------------------------------
     // financial operation
     //-------------------------------------------------
     $r .= '<TABLE style="width:100%" id="fin_item">';
     $r .= "<TR>";
     if ($chdate == 2) {
         $r .= '<th>Date</th>';
     }
     $r .= "<th style=\"width:auto;text-align:left\" colspan=\"2\">Nom</TH>";
     $r .= "<th style=\"text-align:left\" >Commentaire</TH>";
     $r .= "<th style=\"text-align:right\">Montant</TH>";
     $r .= '<th colspan="2"> Op. Concern&eacute;e(s)</th>';
     /* if we use the AC */
     if ($g_parameter->MY_ANALYTIC != 'nu') {
         $anc = new Anc_Plan($this->db);
         $a_anc = $anc->get_list();
         $x = count($a_anc);
         /* set the width of the col */
         $r .= '<th colspan="' . $x . '">' . _('Compt. Analytique') . '</th>';
         /* add hidden variables pa[] to hold the value of pa_id */
         $r .= Anc_Plan::hidden($a_anc);
     }
     $r .= "</TR>";
     // Parse each " tiers"
     $tot_amount = 0;
     //--------------------------------------------------
     // For each items
     //--------------------------------------------------
     for ($i = 0; $i < $nb_item; $i++) {
         $tiers = isset(${"e_other" . $i}) ? ${"e_other" . $i} : "";
         if (strlen(trim($tiers)) == 0) {
             continue;
         }
         $tiers_label = "";
         $tiers_amount = round(${"e_other{$i}" . "_amount"}, 2);
         $tot_amount = bcadd($tot_amount, $tiers_amount);
         $tiers_comment = h(${"e_other{$i}" . "_comment"});
         // If $tiers has a value
         $fTiers = new Fiche($this->db);
         $fTiers->get_by_qcode($tiers);
         $tiers_label = $fTiers->strAttribut(ATTR_DEF_NAME);
         $r .= "<TR>";
         if ($chdate == 2) {
             $r .= td(${"dateop" . $i});
         }
         $r .= "<td>" . ${'e_other' . $i} . "</TD>";
         // label
         $r .= '<TD style="width:25%;border-bottom:1px dotted grey;">';
         $r .= $fTiers->strAttribut(ATTR_DEF_NAME);
         $r .= '</td>';
         // Comment
         $r .= '<td style="width:40%">' . $tiers_comment . '</td>';
         // amount
         $r .= '<td class="num">' . nbm($tiers_amount) . '</td>';
         // concerned
         $r .= '<td style="text-align:center">';
         if (${"e_concerned" . $i} != '') {
             $jr_internal = $this->db->get_array("select jr_internal from jrn where jr_id in (" . ${"e_concerned" . $i} . ")");
             $comma = "";
             for ($x = 0; $x < count($jr_internal); $x++) {
                 $r .= $comma . HtmlInput::detail_op(${"e_concerned" . $i}, $jr_internal[$x]['jr_internal']);
                 $comma = " , ";
             }
         }
         $r .= '</td>';
         // encode the pa
         if ($g_parameter->MY_ANALYTIC != 'nu' && preg_match("/^[6,7]/", $fTiers->strAttribut(ATTR_DEF_ACCOUNT)) == 1) {
             // show form
             $anc_op = new Anc_Operation($this->db);
             $null = $g_parameter->MY_ANALYTIC == 'op' ? 1 : 0;
             $r .= '<td>';
             $p_mode = 1;
             $p_array['pa_id'] = $a_anc;
             /* op is the operation it contains either a sequence or a jrnx.j_id */
             $r .= HtmlInput::hidden('op[]=', $i);
             $r .= $anc_op->display_form_plan($p_array, $null, $p_mode, $i, $tiers_amount);
             $r .= '</td>';
         }
         $r .= '</TR>';
     }
     $r .= "</TABLE>";
     // saldo
     $r .= '<br>Ancien solde = ' . $solde;
     $new_solde += $tot_amount;
     $r .= '<br>Nouveau solde = ' . $new_solde;
     $r .= '<br>Difference =' . $tot_amount;
     // check for upload piece
     $file = new IFile();
     $r .= "<br>Ajoutez une pi&egrave;ce justificative ";
     $r .= $file->input("pj", "");
     $r .= '</div>';
     //--------------------------------------------------
     // Hidden variables
     //--------------------------------------------------
     $r .= dossier::hidden();
     $r .= HtmlInput::hidden('p_jrn', $this->id);
     $r .= HtmlInput::hidden('nb_item', $nb_item);
     $r .= HtmlInput::hidden('last_sold', $last_sold);
     $r .= HtmlInput::hidden('first_sold', $first_sold);
     $r .= HtmlInput::hidden('e_pj', $e_pj);
     $r .= HtmlInput::hidden('e_pj_suggest', $e_pj_suggest);
     $r .= HtmlInput::hidden('e_date', $e_date);
     $mt = microtime(true);
     $r .= HtmlInput::hidden('mt', $mt);
     if (isset($periode)) {
         $r .= HtmlInput::hidden('periode', $periode);
     }
     $r .= dossier::hidden();
     $r .= HtmlInput::hidden('sa', 'n', 'chdate');
     for ($i = 0; $i < $nb_item; $i++) {
         $tiers = isset(${"e_other" . $i}) ? ${"e_other" . $i} : "";
         $r .= HtmlInput::hidden('e_other' . $i, $tiers);
         $r .= HtmlInput::hidden('e_other' . $i, $tiers);
         $r .= HtmlInput::hidden('e_other' . $i . '_comment', ${'e_other' . $i . '_comment'});
         $r .= HtmlInput::hidden('e_other' . $i . '_amount', ${'e_other' . $i . '_amount'});
         $r .= HtmlInput::hidden('e_concerned' . $i, ${'e_concerned' . $i});
         $r .= HtmlInput::hidden('dateop' . $i, ${'dateop' . $i});
         $r .= HtmlInput::hidden('chdate', $chdate);
     }
     return $r;
 }