function search_by_jid($p_jid) { $res = $this->db->exec_sql("select qs_id from quant_sold where j_id=" . $p_jid); if (Database::num_row($res) == 1) { $this->qs_id = Database::fetch_result($res, 0, 0); } else { $this->qs_id = 0; } }
public function insert() { if ($this->verify() != 0) { return; } $sql = "insert into forecast_cat (fc_desc,fc_order,f_id) " . " values (\$1,\$2,\$3) returning fc_id"; $res = $this->cn->exec_sql($sql, array($this->fc_desc, $this->fc_order, $this->f_id)); $this->fc_id = Database::fetch_result($res, 0, 0); }
function load() { $sql = $this->db->exec_sql("select fr_label from formdef where fr_id=\$1", array($this->id)); if (Database::num_row($sql) == 0) { return; } $this->name = Database::fetch_result($sql, 0, 0); $sql = $this->db->exec_sql("select fo_id,fo_pos,fo_label,fo_formula " . " from form " . " where fo_fr_id=\$1 order by fo_pos", array($this->id)); $f = Database::fetch_all($sql); $array = array(); if (!empty($f)) { foreach ($f as $r) { $obj = new Acc_Report_Row(); $obj->set_parameter("name", $r['fo_label']); $obj->set_parameter("id", $r['fo_id']); $obj->set_parameter("position", $r['fo_pos']); $obj->set_parameter("formula", $r['fo_formula']); $obj->set_parameter('database', $this->db); $obj->set_parameter('form_id', $this->id); $array[] = clone $obj; } } $this->aAcc_Report_row = $array; }
public function insert() { if ($this->verify() != 0) { return; } if (trim($this->tl_title) == '') { $this->tl_title = mb_substr(trim($this->tl_desc), 0, 30); } if (trim($this->tl_title) == '') { alert('La note est vide'); return; } /* limit the title to 35 char */ $this->tl_title = mb_substr(trim($this->tl_title), 0, 30); $sql = "insert into todo_list (tl_date,tl_title,tl_desc,use_login,is_public) " . " values (to_date(\$1,'DD.MM.YYYY'),\$2,\$3,\$4,\$5) returning tl_id"; $res = $this->cn->exec_sql($sql, array($this->tl_date, $this->tl_title, $this->tl_desc, $this->use_login, $this->is_public)); $this->tl_id = Database::fetch_result($res, 0, 0); }
echo "<ul>"; $sql_get = $cn->prepare('get_name', "select ad_value from fiche_detail where f_id = \$1 and ad_id=\$2"); for ($i = 0; $i < 12 && $i < count($sql); $i++) { $name = ''; $quick_code = ''; $desc = ''; $sql_name = $cn->execute('get_name', array($sql[$i]['f_id'], 1)); if (Database::num_row($sql_name) == 1) { $name = Database::fetch_result($sql_name, 0, 0); } $sql_name = $cn->execute('get_name', array($sql[$i]['f_id'], 9)); if (Database::num_row($sql_name) == 1) { $desc = Database::fetch_result($sql_name, 0, 0); } $sql_name = $cn->execute('get_name', array($sql[$i]['f_id'], 23)); if (Database::num_row($sql_name) == 1) { $quick_code = Database::fetch_result($sql_name, 0, 0); } /* Highlight the found pattern with bold format */ $name = str_ireplace($_REQUEST['FID'], '<em>' . $_REQUEST['FID'] . '</em>', h($name)); $qcode = str_ireplace($_REQUEST['FID'], '<em>' . $_REQUEST['FID'] . '</em>', h($quick_code)); $desc = str_ireplace($_REQUEST['FID'], '<em>' . $_REQUEST['FID'] . '</em>', h($desc)); printf('<li id="%s">%s <span class="informal"> %s %s</span></li>', $quick_code, $quick_code, $name, $desc); } echo '</ul>'; if (count($sql) > 12) { printf('<i>...' . _('Résultat limité à 12') . ' ...</i>'); } } else { echo "<ul><li>" . _("Non trouvé") . "</li></ul>"; }
public function insert() { if ($this->verify() != 0) { return; } $sql = "select tva_insert(\$1,\$2,\$3,\$4,\$5)"; $res = $this->cn->exec_sql($sql, array($this->tva_label, $this->tva_rate, $this->tva_comment, $this->tva_poste, $this->tva_both_side)); $this->tva_id = $this->cn->get_current_seq('s_tva'); $err = Database::fetch_result($res); }
function seek_internal($p_internal) { $res = $this->db->exec_sql('select jr_id from jrn where jr_internal=$1', array($p_internal)); if (Database::num_row($Res) == 0) { return -1; } $this->jr_id = Database::fetch_result($Res, 0, 0); return 0; }
private function set_default_periode() { /* get the first periode */ $sql = 'select min(p_id) as pid from parm_periode where p_closed = false and p_start = (select min(p_start) from parm_periode)'; $Res = $this->db->exec_sql($sql); $pid = Database::fetch_result($Res, 0, 0); /* if all the periode are closed, then we use the last closed period */ if ($pid == null) { $sql = 'select min(p_id) as pid from parm_periode where p_start = (select max(p_start) from parm_periode)'; $Res2 = $this->db->exec_sql($sql); $pid = Database::fetch_result($Res2, 0, 0); if ($pid == null) { throw new Exception(_("Aucune période trouvéee !!!")); } $pid = Database::fetch_result($Res2, 0, 0); } $sql = sprintf("insert into user_local_pref (user_id,parameter_value,parameter_type)\n values ('%s','%d','PERIODE')", $this->id, $pid); $Res = $this->db->exec_sql($sql); }
public function insert() { if ($this->verify() != 0) { return; } $sql = "INSERT INTO forecast_item(\n fi_text, fi_account, fi_card, fi_order, fc_id, fi_amount,\n fi_debit,fi_pid)\n VALUES (\$1, \$2, \$3, \$4, \$5, \$6, \$7,\$8) returning fi_id;"; $res = $this->cn->exec_sql($sql, array($this->fi_text, $this->fi_account, $this->fi_card, $this->fi_order, $this->fc_id, $this->fi_amount, $this->fi_debit, $this->fi_pid)); $this->fi_id = Database::fetch_result($res, 0, 0); }
// remove space $tva_poste = str_replace(" ", "", $tva_poste); $err = 0; // Error code if (isNumber($tva_rate) == 0) { $err = 2; } if ($err == 0) { if (isset($_POST['confirm_add'])) { $sql = "select tva_insert(\$1,\$2,\$3,\$4,\$5)"; $res = $cn->exec_sql($sql, array($tva_label, $tva_rate, $tva_comment, $tva_poste, $both_side)); $err = Database::fetch_result($res); } if (isset($_POST['confirm_mod'])) { $Res = $cn->exec_sql("select tva_modify(\$1,\$2,\$3,\$4,\$5,\$6)", array($tva_id, $tva_label, $tva_rate, $tva_comment, $tva_poste, $both_side)); $err = Database::fetch_result($Res); } } if ($err != 0) { $err_code = array(1 => "Tva id n\\'est pas un nombre", 2 => "Taux tva invalide", 3 => "Label ne peut être vide", 4 => "Poste invalide", 5 => "Tva id doit être unique"); $str_err = $err_code[$err]; echo "<script>alert ('{$str_err}'); </script>"; } } // If company not use VAT $own = new Own($cn); if ($own->MY_TVA_USE == 'N') { echo '<h2 class="error">' . _("Vous n'êtes pas assujetti à la TVA") . '</h2>'; return; } //-----------------------------------------------------
function find_periode($p_date) { $sql = "select p_id from parm_periode where p_start <= to_date(\$1,'DD.MM.YYYY') and p_end >= to_date(\$1,'DD.MM.YYYY') "; $ret = $this->cn->exec_sql($sql, array($p_date)); $nb_periode = Database::num_row($ret); if ($nb_periode == 0) { throw new Exception('Aucune période trouvée', 101); } if ($nb_periode > 1) { throw new Exception("Trop de périodes trouvées {$nb_periode} pour {$p_date}", 100); } $per = Database::fetch_result($ret, 0); $this->p_id = $per; return $per; }
function empty_attribute($p_attr) { $sql = "select ad_value\n from fiche_detail\n natural join fiche\n left join attr_def using (ad_id) where f_id=" . $this->id . " and ad_id = " . $p_attr . " order by ad_id"; $res = $this->cn->exec_sql($sql); if (Database::num_row($res) == 0) { return true; } $text = Database::fetch_result($res, 0, 0); return strlen(trim($text)) > 0 ? false : true; }
public function insert() { if ($this->verify() != 0) { return; } $sql = "insert into forecast (f_name,f_start_date,f_end_date) " . " values (\$1,\$2,\$3) returning f_id"; $res = $this->cn->exec_sql($sql, array($this->f_name, $this->f_start_date, $this->f_end_date)); $this->f_id = Database::fetch_result($res, 0, 0); }
function search_id_internal($p_internal) { $sql = "select jr_id from jrn where jr_internal='{$p_internal}'"; $r = $this->cn->exec_sql($sql); if (Database::num_row($r) > 0) { $this->jr_id = Database::fetch_result($r, 0, 0); return $this->jr_id; } else { $this->jr_id = -1; return $this->jr_id; } }