}
        }
    }
    $r .= td(HtmlInput::hidden('jrid[' . $i . ']', $row['jr_id']) . $iradio->input(), ' style="text-align:center" ');
    if ($i % 2 == 0) {
        echo tr($r, ' class="odd" ');
    } else {
        echo tr($r, ' class="even" ');
    }
}
echo '</table>';
$bk_card = new Fiche($cn);
$bk_card->id = $Ledger->get_bank();
$filter_year = "  j_tech_per in (select p_id from parm_periode where  p_exercice='" . $g_user->get_exercice() . "')";
/*  get saldo for not reconcilied operations  */
$saldo_not_reconcilied = $bk_card->get_solde_detail($filter_year . " and j_grpt in (select jr_grpt_id from jrn where trim(jr_pj_number) ='' or jr_pj_number is null)");
/*  get saldo for reconcilied operation  */
$saldo_reconcilied = $bk_card->get_solde_detail($filter_year . " and j_grpt in (select jr_grpt_id from jrn where trim(jr_pj_number) != '' and jr_pj_number is not null)");
/* solde compte */
$saldo = $bk_card->get_solde_detail($filter_year);
echo '<table>';
echo '<tr>';
echo td("Solde compte  ");
echo td(nbm(bcsub($saldo['debit'], $saldo['credit'])), ' style="text-align:right"');
echo '</tr>';
echo '<tr>';
echo td("Solde non rapproché ");
echo td(nbm(bcsub($saldo_not_reconcilied['debit'], $saldo_not_reconcilied['credit'])), ' style="text-align:right"');
echo '</tr>';
echo '<tr>';
echo td("Solde  rapproché ");
Beispiel #2
0
 }
 echo '<h2>' . $cn->get_value("select fd_label from fiche_def where fd_id=\$1", array($afiche[$e]['fd_id'])) . '</h2>';
 $id = "table_" . $afiche[$e]['fd_id'] . "_id";
 echo _('Filtre rapide:') . HtmlInput::filter_table($id, '0,1,2', '1');
 echo '<table class="sortable" id="' . $id . '" class="result" >';
 echo tr(th('Quick Code') . th('Libellé') . '<th>Poste' . HtmlInput::infobulle(27) . '</th>' . th('Débit', 'style="text-align:right"') . th('Crédit', 'style="text-align:right"') . th('Solde', 'style="text-align:right"') . th('D/C', 'style="text-align:right"'));
 $idx = 0;
 $sum_deb = 0;
 $sum_cred = 0;
 $sum_solde = 0;
 bcscale(4);
 for ($i = 0; $i < Database::num_row($ret); $i++) {
     $filter = " (j_date >= to_date('" . $_REQUEST['start'] . "','DD.MM.YYYY') " . " and  j_date <= to_date('" . $_REQUEST['end'] . "','DD.MM.YYYY')) ";
     $aCard = Database::fetch_array($ret, $i);
     $oCard = new Fiche($cn, $aCard['f_id']);
     $solde = $oCard->get_solde_detail($filter);
     if ($solde['debit'] == 0 && $solde['credit'] == 0) {
         continue;
     }
     /* only not purged card */
     if ($_GET['histo'] == 5 && $solde['debit'] == $solde['credit']) {
         continue;
     }
     $class = $idx % 2 == 0 ? 'class="odd"' : 'class="even"';
     $idx++;
     $sum_cred = bcadd($sum_cred, $solde['credit']);
     $sum_deb = bcadd($sum_deb, $solde['debit']);
     $sum_solde = bcsub($sum_deb, $sum_cred);
     echo tr(td(HtmlInput::history_card($oCard->id, $oCard->strAttribut(ATTR_DEF_QUICKCODE))) . td($oCard->strAttribut(ATTR_DEF_NAME)) . td(HtmlInput::history_account($oCard->strAttribut(ATTR_DEF_ACCOUNT), $oCard->strAttribut(ATTR_DEF_ACCOUNT))) . td(nbm($solde['debit']), 'class="sorttable_numeric" sorttable_customkey="' . $solde['debit'] . '" style="text-align:right"') . td(nbm($solde['credit']), 'class="sorttable_numeric" sorttable_customkey="' . $solde['debit'] . '" style="text-align:right"') . td(nbm(abs($solde['solde'])), 'class="sorttable_numeric" sorttable_customkey="' . $solde['solde'] . '" style="text-align:right"') . td($solde['debit'] < $solde['credit'] ? 'C' : 'D', 'style="text-align:right"'), $class);
 }
 echo '<tfoot>';
 /**
  *@brief Display the result of the forecast
  *@param $p_periode
  *@return HTML String with the code
  */
 public function display()
 {
     bcscale(4);
     $forecast = new Forecast($this->cn, $this->f_id);
     $forecast->load();
     $str_name = h($forecast->get_parameter('name'));
     $start = $forecast->get_parameter('start_date');
     $end = $forecast->get_parameter('end_date');
     if ($start == '') {
         throw new Exception(_('Période de début non valable'));
     }
     if ($end == '') {
         throw new Exception(_('Période de fin non valable'));
     }
     $per = new Periode($this->cn, $start);
     $str_start = format_date($per->first_day());
     $per = new Periode($this->cn, $end);
     $str_end = format_date($per->last_day());
     $r = "";
     $aCat = $this->cn->get_array('select fc_id,fc_desc from forecast_cat where f_id=$1 order by fc_order', array($this->f_id));
     $aItem = array();
     $aReal = array();
     $poste = new Acc_Account_Ledger($this->cn, 0);
     $fiche = new Fiche($this->cn);
     $aPeriode = $this->cn->get_array("select p_id,to_char(p_start,'MM.YYYY') as myear from parm_periode\n\t                                 where p_start >= (select p_start from parm_periode where p_id={$start})\n                                         and p_end <= (select p_end from parm_periode where p_id={$end})\n\t\t\t\t\t order by p_start;");
     $error = array();
     for ($j = 0; $j < count($aCat); $j++) {
         $aItem[$j] = $this->cn->get_array('select fi_card,fi_account,fi_text,fi_amount,fi_debit from forecast_item where fc_id=$1  and fi_pid=0 order by fi_order ', array($aCat[$j]['fc_id']));
         $aPerMonth[$j] = $this->cn->get_array('select fi_pid,fi_card,fi_account,fi_text,fi_amount,fi_debit from forecast_item where fc_id=$1 and fi_pid !=0 order by fi_order ', array($aCat[$j]['fc_id']));
         /* compute the real amount for periode */
         for ($k = 0; $k < count($aItem[$j]); $k++) {
             /* for each periode */
             for ($l = 0; $l < count($aPeriode); $l++) {
                 if ($aItem[$j][$k]['fi_account'] == '') {
                     $fiche->id = $aItem[$j][$k]['fi_card'];
                     $amount = $fiche->get_solde_detail("j_tech_per = " . $aPeriode[$l]['p_id']);
                     if ($aItem[$j][$k]['fi_debit'] == 'C' && $amount['debit'] > $amount['credit']) {
                         $amount['solde'] = $amount["solde"] * -1;
                     }
                     if ($aItem[$j][$k]['fi_debit'] == 'D' && $amount['debit'] < $amount['credit']) {
                         $amount['solde'] = $amount["solde"] * -1;
                     }
                 } else {
                     $poste->id = $aItem[$j][$k]['fi_account'];
                     $aresult = Impress::parse_formula($this->cn, "OK", $poste->id, $aPeriode[$l]['p_id'], $aPeriode[$l]['p_id']);
                     $tmp_label = $aresult['desc'];
                     $amount['solde'] = $aresult['montant'];
                     if ($tmp_label != 'OK') {
                         $error[] = "<li> " . $aItem[$j][$k]['fi_text'] . $poste->id . '</li>';
                     }
                 }
                 $aReal[$j][$k][$l] = $amount['solde'];
             }
         }
     }
     ob_start();
     require_once NOALYSS_INCLUDE . '/template/forecast_result.php';
     $r .= ob_get_contents();
     ob_end_clean();
     return $r;
 }