Пример #1
0
 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;
 }