function get_row($p_start, $p_end, $p_type_date) { $Res = $this->db->exec_sql("select fo_id ,\n fo_fr_id,\n fo_pos,\n fo_label,\n fo_formula,\n fr_label from form\n inner join formdef on fr_id=fo_fr_id\n where fr_id =" . $this->id . "order by fo_pos"); $Max = Database::num_row($Res); if ($Max == 0) { $this->row = 0; return null; } $col = array(); for ($i = 0; $i < $Max; $i++) { $l_line = Database::fetch_array($Res, $i); $col[] = Impress::parse_formula($this->db, $l_line['fo_label'], $l_line['fo_formula'], $p_start, $p_end, true, $p_type_date); } //for ($i $this->row = $col; return $col; }
function compute_formula($p_handle) { while (!feof($p_handle)) { $buffer = trim(fgets($p_handle)); // $a=(Impress::check_formula($buffer) == true)?"$buffer ok<br>":'<font color="red">'.'Pas ok '.$buffer."</font><br>"; // echo $a; // blank line are skipped if (strlen(trim($buffer)) == 0) { continue; } // skip comment if (strpos($buffer, '#') === true) { continue; } // buffer contains a formula A$=.... // We need to eval it $a = Impress::parse_formula($this->db, "{$buffer}", $buffer, $this->from, $this->to, false); $b = str_replace("\$", "\$this->", $a); if (eval("{$b};") === false) { echo_debug(__FILE__, __LINE__, "Code failed with {$b}"); } } // end read form line per line }
/** *@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; }