function display_form_plan($p_array, $p_null, $p_mode, $p_seq, $p_amount, $p_id = '', $p_add_button = true) { if ($p_array != null) { extract($p_array); } $result = ""; $plan = new Anc_Plan($this->db); $a_plan = $plan->get_list(" order by pa_id "); if (empty($a_plan)) { return ""; } $table_id = "t" . $p_seq; $hidden = new IHidden(); $readonly = $p_mode == 1 ? false : true; $result .= $hidden->input('amount_' . $table_id, $p_amount); if ($p_mode == 1) { $result .= '<table id="' . $p_id . $table_id . '">'; } else { $result .= '<table>'; } $result .= "<tr>" . $plan->header() . "<th>montant</th></tr>"; /* compute the number of rows */ $nb_row = isset($val[$p_seq]) ? count($val[$p_seq]) : 1; $count = 0; $remain = abs($p_amount); $ctrl_remain = "remain" . $this->in_div . $table_id; for ($i = 0; $i < $nb_row; $i++) { $result .= '<tr>'; foreach ($a_plan as $r_plan) { $array = $this->db->make_array("select po_id as value," . " html_quote(po_name) as label from poste_analytique " . " where pa_id = " . $r_plan['id'] . " order by po_name", $p_null); $select = new ISelect("hplan[" . $p_seq . "][]", $array); $select->table = 0; // view only or editables if ($p_mode == 1) { // editable $select->readonly = false; if (isset($hplan) && isset($hplan[$p_seq][$count])) { $select->selected = $hplan[$p_seq][$count]; } } else { if (isset($hplan) && isset($hplan[$p_seq][$count])) { $select->selected = $hplan[$p_seq][$count]; } // view only $select->readOnly = true; } if ($p_mode == 1) { $result .= '<td>' . $select->input() . '</td>'; } else { $result .= '<td>' . $select->display() . '</td>'; } $count++; } $value = new INum(); $value->javascript = 'onchange="format_number(this);anc_refresh_remain(\'' . $this->in_div . $table_id . '\',\'' . $p_seq . '\')"'; $value->name = "val[" . $p_seq . "][]"; $value->size = 6; $value->value = isset($val[$p_seq][$i]) ? $val[$p_seq][$i] : abs($p_amount); $value->readOnly = $p_mode == 1 ? false : true; $remain = bcsub($remain, $value->value); $result .= '<td>' . $value->input() . '</td>'; $result .= "</tr>"; } $result .= "</table>"; if ($p_add_button && $p_mode == 1) { $style_remain = $remain == 0 ? 'style="color:green"' : ' style="color:red"'; $result .= " Reste à imputer = " . '<span class="remain" ' . $style_remain . ' id="' . $ctrl_remain . '">' . $remain . '</span>'; // add a button to add a row $button = new IButton(); $button->javascript = "add_row('" . $p_id . "{$table_id}',{$p_seq});"; $button->name = "js" . $p_id . $p_seq; $button->label = _("Nouvelle ligne"); $result .= "<br>" . $button->input(); /** * Add a button for distribution key * */ $ledger = HtmlInput::default_value_post("p_jrn", 0); if ($ledger == 0) { $ledger = $this->db->get_value('select j_jrn_def from jrnx where j_id=$1', array($this->j_id)); } $gDossier = Dossier::id(); $button_key = new IButton(); $button_key->javascript = "anc_key_choice(" . $gDossier . ",'" . $p_id . "{$table_id}',{$p_amount},'" . $ledger . "');"; $button_key->name = "js" . $p_id . $p_seq; $button_key->label = _("Clef"); $result .= $button_key->input(); } return $result; }
function Display($p_readonly) { $this->GetAttribut(); $attr = $this->attribut; /* show card type here */ $type_card = $this->cn->get_value('select fd_label ' . ' from fiche_def join fiche using (fd_id) where f_id=$1', array($this->id)); $ret = ""; $ret .= h2(_("Catégorie") . " " . $type_card, 'style="display:inline"'); $ret .= '<span style="font-weight:bolder;margin-right:5px;float:right">' . _('id fiche') . ':' . $this->id . "</span>"; $ret .= "<table style=\"width:98%;margin:1%\">"; if (empty($attr)) { return 'FNT'; } /* for each attribute */ foreach ($attr as $r) { $msg = ""; $bulle = ""; if ($p_readonly) { $w = new IText(); $w->table = 1; $w->readOnly = true; $w->css_size = "100%"; } if ($p_readonly == false) { if ($r->ad_id == ATTR_DEF_ACCOUNT) { $w = new IPoste("av_text" . $r->ad_id); $w->set_attribute('ipopup', 'ipop_account'); $w->set_attribute('account', "av_text" . $r->ad_id); $w->dbl_click_history(); // account created automatically $w->table = 0; $w->value = $r->av_text; // account created automatically $sql = "select account_auto({$this->fiche_def})"; $ret_sql = $this->cn->exec_sql($sql); $a = Database::fetch_array($ret_sql, 0); $bulle = HtmlInput::infobulle(10); if ($a['account_auto'] == 't') { $bulle .= HtmlInput::warnbulle(11); } } elseif ($r->ad_id == ATTR_DEF_TVA) { $w = new ITva_Popup('popup_tva'); $w->table = 1; $w->value = $r->av_text; } else { switch ($r->ad_type) { case 'text': $w = new IText('av_text' . $r->ad_id); $w->css_size = "100%"; $w->value = $r->av_text; break; case 'numeric': $w = new INum('av_text' . $r->ad_id); $w->size = $r->ad_size; $w->prec = $r->ad_extra == "" ? 2 : $r->ad_extra; $w->value = $r->av_text; break; case 'date': $w = new IDate('av_text' . $r->ad_id); $w->value = $r->av_text; break; case 'zone': $w = new ITextArea('av_text' . $r->ad_id); $w->style = ' class="itextarea" style="margin:0px;width:100%"'; $w->value = $r->av_text; break; case 'poste': $w = new IPoste("av_text" . $r->ad_id); $w->set_attribute('ipopup', 'ipop_account'); $w->set_attribute('account', "av_text" . $r->ad_id); $w->dbl_click_history(); $w->width = $r->ad_size; $w->table = 0; $bulle = HtmlInput::infobulle(14); $w->value = $r->av_text; break; case 'card': $uniq = rand(0, 1000); $w = new ICard("av_text" . $r->ad_id); $w->id = "card_" . $this->id . $uniq; // filter on ad_extra $filter = $r->ad_extra; $w->width = $r->ad_size; $w->extra = $filter; $w->extra2 = 0; $label = new ISpan(); $label->name = "av_text" . $uniq . $r->ad_id . "_label"; $fiche = new Fiche($this->cn); $fiche->get_by_qcode($r->av_text); if ($fiche->id == 0) { $label->value = trim($r->av_text) == '' ? "" : " " . _("Fiche non trouvée") . " "; $r->av_text = ""; } else { $label->value = $fiche->strAttribut(ATTR_DEF_NAME) . " " . $fiche->strAttribut(ATTR_DEF_FIRST_NAME, 0); } $w->set_attribute('ipopup', 'ipopcard'); $w->set_attribute('typecard', $filter); $w->set_attribute('inp', "av_text" . $r->ad_id); $w->set_attribute('label', $label->name); $w->autocomplete = 0; $w->dblclick = "fill_ipopcard(this);"; $msg = $w->search(); $msg .= $label->input(); $w->value = $r->av_text; break; case 'select': $w = new ISelect(); $w->value = $this->cn->make_array($r->ad_extra); $w->selected = $r->av_text; $w->style = ' style="width:100%" '; break; default: var_dump($r); throw new Exception("Type invalide"); } $w->table = 0; } } else { switch ($r->ad_type) { case 'select': $x = new ISelect(); $x->value = $this->cn->make_array($r->ad_extra); $x->selected = $r->av_text; $value = $x->display(); $w->value = $value; break; default: $w->value = $r->av_text; } } $w->name = "av_text" . $r->ad_id; $w->readOnly = $p_readonly; if ($r->ad_id == 21 || $r->ad_id == 22 || $r->ad_id == 20 || $r->ad_id == 31) { $bulle = HtmlInput::infobulle(21); } $ret .= "<TR>" . td(_($r->ad_text) . $bulle) . td($w->input() . " " . $msg) . " </TR>"; } $ret .= "</table>"; return $ret; }