noalyss Version-9
Public Member Functions | Static Public Member Functions | Data Fields | Protected Attributes | Private Member Functions
Card_Property Class Reference

contains the attributes of a card , manage them, save them , ... More...

+ Collaboration diagram for Card_Property:

Public Member Functions

 __construct ($cn, $ad_id=0)
 
 __toString ()
 
 build_input ($p_fiche_def=null)
 build the needed elements to display More...
 
 get_ad_extra ()
 
 get_ad_id ()
 
 get_ad_size ()
 
 get_ad_text ()
 
 get_ad_type ()
 
 get_av_text ()
 
 get_jnt_order ()
 
 getDisplayMode ()
 
 input ($p_fiche_def=null)
 input a property of a card More...
 
 print ()
 Compute a HTML string in a TR element with information of this card property. More...
 
 set_ad_extra ($ad_extra)
 
 set_ad_id ($ad_id)
 
 set_ad_size ($ad_size)
 
 set_ad_text ($ad_text)
 
 set_ad_type ($ad_type)
 
 set_av_text ($av_text)
 
 set_jnt_order ($jnt_order)
 
 setDisplayMode ($p_mode)
 

Static Public Member Functions

static findProperty ($attr_def_id, $a_property)
 return the Property of an array of property with the right ad_id More...
 
static load (Fiche $fiche)
 Load all the attribute of a card , it modifies the parameter $fiche. More...
 
static update (Fiche $p_fiche)
 update all the data of the card , including f_enable. if we are in a transaction we don't commit here , else if not then a transaction is started and committed . The member attributes $p_fiche->attribut will be saved into fiche_detail after transforming if needed. If a transaction is started if there is none, so updating a card is always in a transaction. More...
 

Data Fields

 $ad_extra
 ad_extra extra info for a attribute More...
 
 $ad_id
 ad_id int id of the attribute attr_def.ad_id More...
 
 $ad_size
 ad_size int size of the attribute More...
 
 $ad_text
 ad_text string label of the attribute attr_def.ad_def More...
 
 $ad_type
 ad_type string : type of this attribute (select, text ,...) More...
 
 $av_text
 av_text string value of this attribute More...
 
 $cn
 cn database connexion More...
 
 $jnt_order
 jnt_order order to display More...
 

Protected Attributes

 $display_mode
 display mode values are large , window , display Property depending of this mode. More...
 

Private Member Functions

 add_link ($p_ad_id, $p_text)
 add a link More...
 

Detailed Description

contains the attributes of a card , manage them, save them , ...

Definition at line 32 of file card_property.class.php.

Constructor & Destructor Documentation

◆ __construct()

Card_Property::__construct (   $cn,
  $ad_id = 0 
)

Definition at line 53 of file card_property.class.php.

54 {
55 $this->cn=$cn;
56 $this->ad_id=$ad_id;
57 $this->display_mode='window';
58 }
$input_from cn
Definition: balance.inc.php:66
$ad_id
ad_id int id of the attribute attr_def.ad_id
$cn
cn database connexion

References $ad_id, $cn, and cn.

Member Function Documentation

◆ __toString()

Card_Property::__toString ( )

Definition at line 59 of file card_property.class.php.

59 : string
60 {
61 return "card_property".var_export($this,true);
62 }

◆ add_link()

Card_Property::add_link (   $p_ad_id,
  $p_text 
)
private

add a link

Parameters
$p_ad_id
$p_text
Returns
false|mixed|string

Definition at line 660 of file card_property.class.php.

660 {
661 if ( $this->display_mode=="large" && $p_ad_id == ATTR_DEF_WEBSITE) {
662 $url=linkTo($p_text);
663 }elseif ( $this->display_mode=="large" && $p_ad_id == ATTR_DEF_EMAIL) {
664 $url=mailTo($p_text);
665 }elseif ( $this->display_mode=="large" && $p_ad_id == ATTR_DEF_FAX) {
666 $url=faxTo($p_text);
667 }else {
668 return "";
669 }
670 return $url;
671 }
mailTo($p_email)
compose a HTML string with email
Definition: ac_common.php:1615
linkTo($p_url)
Definition: ac_common.php:1649
$url
const ATTR_DEF_EMAIL
Definition: constant.php:228
const ATTR_DEF_WEBSITE
Definition: constant.php:239
const ATTR_DEF_FAX
Definition: constant.php:231
if( $delta< 0) elseif( $delta==0)

References $url, ATTR_DEF_EMAIL, ATTR_DEF_FAX, ATTR_DEF_WEBSITE, elseif, linkTo(), and mailTo().

+ Here is the call graph for this function:

◆ build_input()

Card_Property::build_input (   $p_fiche_def = null)

build the needed elements to display

Parameters
ObjectFiche_Def $p_fiche_def
Returns
array
  • $result['msg'] message to display,
  • $result['label'] label of the CardProperty (ad_text),
  • $result['input' is the HtmlInput object
  • $result['class'] is the CSS class to use
  • $result['bulle'] is the infobulle

Definition at line 156 of file card_property.class.php.

157 {
158 $result = ['msg' => '', 'input' => null, 'label' => '', 'class' => 'input_text','bulle'=>''];
159 if ($this->ad_id == ATTR_DEF_NAME || $this->ad_id == ATTR_DEF_QUICKCODE) {
160 $result['class'] = " input_text highlight info";
161 }
162 if ($this->ad_id == ATTR_DEF_ACCOUNT) {
163 if ( $p_fiche_def == null ) {
164 throw new \Exception ("CP162.p_fiche_def is null");
165 }
166 $result['input'] = new IPoste("av_text" . $this->ad_id);
167 $result['input']->id = uniqid('accounting');
168 $result['input']->set_attribute('ipopup', 'ipop_account');
169 $result['input']->set_attribute('jrn', '0');
170 $result['input']->set_attribute('account', $result['input']->id);
171 $result['input']->dbl_click_history();
172 $result['input']->value = $this->av_text;
173 // account created automatically
174 $sql = "select account_auto($p_fiche_def->id)";
175 $ret_sql = $this->cn->exec_sql($sql);
176 $a = Database::fetch_array($ret_sql, 0);
177 $result['label'] = new ISpan();
178 $result['label']->name = "av_text" . $this->ad_id . "_label";
179 $p_fiche_def->load();
180 if ($a['account_auto'] == 't') {
181 $result['msg'] .= $result['label']->input() . " <span style=\"color:red\">" .
182 _("Rappel: Poste créé automatiquement à partir de ")
183 . $p_fiche_def->class_base . " </span> ";
184 } else {
185 // if there is a class base in fiche_def_ref, this account will be the
186 // the default one
187 if (noalyss_strlentrim($p_fiche_def->class_base) != 0) {
188 $result['msg'] .= " <span style=\"color:red\">" . _("Rappel: Poste par défaut sera ") .
189 $p_fiche_def->class_base .
190 " !</span> ";
191 $result['input']->value = (empty ($result['input']->value)) ?$p_fiche_def->class_base:$result['input']->value;
192 }
193 }
194 $result['label']=_("Poste comptable");
195 $result['class']=" highlight input_text";
196 return $result;
197 } elseif ($this->ad_id == ATTR_DEF_TVA) {
198 $result['input'] = new ITva_Popup('popup_tva');
199 $result['input']->table = 0;
200 $result['input']->value = $this->av_text;
201 $result['label']=$this->ad_text;
202 } else {
203 switch ($this->ad_type) {
204 case 'text':
205 $result['input'] = new IText();
206 $result['input']->css_size = "100%";
207 $result['input']->value = $this->av_text;
208 break;
209 case 'numeric':
210 $result['input'] = new INum();
211 $result['input']->prec = ($this->ad_extra == "") ? 2 : $this->ad_extra;
212 $result['input']->size = $this->ad_size;
213 $result['input']->value = $this->av_text;
214 break;
215 case 'date':
216 $result['input'] = new IDate();
217 $result['input']->value = $this->av_text;
218 break;
219 case 'zone':
220 $result['input'] = new ITextArea();
221 $result['input']->style = ' class="itextarea" style="margin:0px;width:100%"';
222 $result['input']->value = $this->av_text;
223 break;
224 case 'poste':
225 $result['input'] = new IPoste("av_text" . $this->ad_id);
226 $result['input']->set_attribute('ipopup', 'ipop_account');
227 $result['input']->set_attribute('account', "av_text" . $this->ad_id);
228 $result['input']->table = 1;
229 $bulle = Icon_Action::infobulle(14);
230 $result['input']->value = $this->av_text;
231 break;
232 case 'check':
233 $result['input'] = new InputSwitch("av_text" . $this->ad_id);
234 $result['input']->value = (empty($this->av_text) ) ? 0 : 1;
235 break;
236 case 'select':
237 $result['input'] = new ISelect("av_text" . $this->ad_id);
238 $result['input']->value = $this->cn->make_array($this->ad_extra);
239 $result['input']->style = 'style="width:100%"';
240 $result['input']->selected = $this->av_text;
241 break;
242 case 'card':
243 $result['input'] = new ICard("av_text" . $this->ad_id);
244 // filter on frd_id
245 $result['input']->extra = $this->ad_extra;
246 $result['input']->extra2 = 0;
247 $result['input']->id = uniqid();
248 $result['label'] = new ISpan();
250 $result['input']->width = $this->ad_size;
251 $result['input']->extra = $filter;
252 $result['input']->extra2 = 0;
253 $result['input']->limit = 6;
254 $result['label']->name = "av_text" . $this->ad_id . $result['input']->id . "_label";
255 $result['input']->set_attribute('ipopup', 'ipopcard');
256 $result['input']->set_attribute('typecard', $this->ad_extra);
257 $result['input']->set_attribute('inp', $result['input']->id);
258 $result['input']->set_attribute('label', "av_text" . $this->ad_id . $result['input']->id . "_label");
259 $result['input']->autocomplete = 1;
260 $result['input']->dblclick = "fill_ipopcard(this);";
261 $result['msg'] = $result['input']->search();
262 $result['msg'] .= $result['label']->input();
263 $result['input']->value = $this->av_text;
264 break;
265 }
266 $result['input']->table = 0;
267 $result['label']=$this->ad_text;
268 }
269
270 $result['input']->label = $this->ad_text;
271 $result['input']->name = "av_text" . $this->ad_id;
272 if ($this->ad_id == 21 || $this->ad_id == 22 || $this->ad_id == 20 || $this->ad_id == 31) {
273 $result['bulle'] = Icon_Action::infobulle(21);
274 }
275
276 // Warning length quickcode
277 if ($this->ad_id == ATTR_DEF_QUICKCODE) {
278 $result['bulle'] = Icon_Action::warnbulle(76);
279 }
280
281 return $result;
282 }
noalyss_strlentrim($p_string)
Definition: ac_common.php:1549
$filter
$ad_extra
ad_extra extra info for a attribute
$ad_text
ad_text string label of the attribute attr_def.ad_def
$ad_size
ad_size int size of the attribute
$av_text
av_text string value of this attribute
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
Input HTML for the card show buttons, in the file, you have to add card.js How to use :
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
Definition: idate.class.php:34
This class handles only the numeric input, the input will call a javascript to change comma to period...
Definition: inum.class.php:42
show a button, for selecting a account and a input text for manually inserting an account the differe...
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Html Input.
Definition: ispan.class.php:32
Html Input.
Definition: itext.class.php:30
let you choose a TVA in a popup
static warnbulle($p_comment)
Display a warning in a bubble, text is in message_javascript.
static infobulle($p_comment)
Display a info in a bubble, text is in message_javascript.
show a switch, when you click on it an hidden field is changed, the value is 1 or 0
const ATTR_DEF_NAME
Definition: constant.php:216
const ATTR_DEF_TVA
Definition: constant.php:221
const ATTR_DEF_QUICKCODE
Definition: constant.php:237
const ATTR_DEF_ACCOUNT
Definition: constant.php:215

References $a, $ad_extra, $ad_id, $ad_size, $ad_text, $av_text, $filter, $result, $sql, ATTR_DEF_ACCOUNT, ATTR_DEF_NAME, ATTR_DEF_QUICKCODE, ATTR_DEF_TVA, cn, elseif, DatabaseCore\fetch_array(), Icon_Action\infobulle(), noalyss_strlentrim(), value, and Icon_Action\warnbulle().

Referenced by input().

+ Here is the call graph for this function:

◆ findProperty()

static Card_Property::findProperty (   $attr_def_id,
  $a_property 
)
static

return the Property of an array of property with the right ad_id

Parameters
int$attr_def_idthe search attr_def_id
array$a_propertyarray of Card_Property
Returns
mixed|null

Definition at line 679 of file card_property.class.php.

680 {
681 $nb = count($a_property);
682 for ($i = 0; $i < $nb; $i++) {
683 if ($a_property[$i]->get_ad_id() == $attr_def_id) return $a_property[$i];
684 }
685 return null;
686 }

References $i, $nb, and get_ad_id().

+ Here is the call graph for this function:

◆ get_ad_extra()

Card_Property::get_ad_extra ( )

Definition at line 101 of file card_property.class.php.

102 {
103 return $this->ad_extra;
104 }

References $ad_extra.

◆ get_ad_id()

Card_Property::get_ad_id ( )

Definition at line 76 of file card_property.class.php.

77 {
78 return $this->ad_id;
79 }

References $ad_id.

Referenced by findProperty().

◆ get_ad_size()

Card_Property::get_ad_size ( )

Definition at line 96 of file card_property.class.php.

97 {
98 return $this->ad_size;
99 }

References $ad_size.

◆ get_ad_text()

Card_Property::get_ad_text ( )

Definition at line 81 of file card_property.class.php.

82 {
83 return $this->ad_text;
84 }

References $ad_text.

◆ get_ad_type()

Card_Property::get_ad_type ( )

Definition at line 91 of file card_property.class.php.

92 {
93 return $this->ad_type;
94 }
$ad_type
ad_type string : type of this attribute (select, text ,...)

References $ad_type.

◆ get_av_text()

Card_Property::get_av_text ( )

Definition at line 86 of file card_property.class.php.

87 {
88 return $this->av_text;
89 }

References $av_text.

◆ get_jnt_order()

Card_Property::get_jnt_order ( )

Definition at line 106 of file card_property.class.php.

107 {
108 return $this->jnt_order;
109 }
$jnt_order
jnt_order order to display

References $jnt_order.

◆ getDisplayMode()

Card_Property::getDisplayMode ( )

Definition at line 71 of file card_property.class.php.

72 {
74 }
$display_mode
display mode values are large , window , display Property depending of this mode.

References $display_mode.

◆ input()

Card_Property::input (   $p_fiche_def = null)

input a property of a card

Parameters
Fiche_Def$p_fiche_def
Returns
string HTML string with the right input type

Definition at line 373 of file card_property.class.php.

374 {
375
376 $result=$this->build_input($p_fiche_def);
377
378
379 $url='<td>'.$this->add_link($this->ad_id,$this->av_text).'</td>';
380 $r="<TR>".
381 td(_($result["label"]). $result['bulle'],
382 ' class="'.$result['class'].'" ').
383 td($result["input"]->input().$result["msg"]).
384 $url.
385 " </TR>";
386 return $r;
387 }
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
build_input($p_fiche_def=null)
build the needed elements to display
input($p_fiche_def=null)
input a property of a card

References $r, $result, $url, build_input(), input(), and td().

Referenced by input().

+ Here is the call graph for this function:

◆ load()

static Card_Property::load ( Fiche  $fiche)
static

Load all the attribute of a card , it modifies the parameter $fiche.

Usually called from fiche::insert and fiche::update . In the same time, it will synchronize the attributes which the database. The attributes (public.fiche_detail) will be ordered in the member attribute $fiche->attribut

Parameters
$ficheFiche Full fill this card with all the attributes
See also
Fiche::update Fiche::insert
Note
it is not possible to compute the default attributes for a new card without the card category, so it returns nothing

Definition at line 293 of file card_property.class.php.

294 {
295 // if card is not yet saved then we don't load it from database but all the properties are set to empty
296 if ($fiche->id==0 && $fiche->fiche_def !=0 )
297 {
298 $fiche_def=new Fiche_Def($fiche->cn,$fiche->fiche_def);
299 $aProperty=$fiche_def->getAttribut();
300 $fiche->attribut=$aProperty;
301 return;
302 } elseif ($fiche->id==0 && $fiche->fiche_def ==0 )
303 {
304 return;
305// throw new Exception("CP147. Card category cannot be empty (fiche->set_fiche_def)",EXC_PARAM_VALUE);
306 }
307 $sql="select *
308 from
309 fiche
310 natural join fiche_detail
311 join jnt_fic_attr on (jnt_fic_attr.fd_id=fiche.fd_id and fiche_detail.ad_id=jnt_fic_attr.ad_id)
312 join attr_def on (attr_def.ad_id=fiche_detail.ad_id) where f_id= $1".
313 " order by jnt_order";
314
315 $Ret=$fiche->cn->exec_sql($sql, [$fiche->id]);
316 if (($Max=Database::num_row($Ret))==0)
317 return;
318 for ($i=0; $i<$Max; $i++)
319 {
321 $fiche->fiche_def=$row['fd_id'];
322 $fiche->set_f_enable($row['f_enable']);
323 $t=new Card_Property($fiche->cn);
324 $t->ad_id=$row['ad_id'];
325 $t->ad_text=$row['ad_text'];
326 $t->av_text=$row['ad_value'];
327 $t->ad_type=$row['ad_type'];
328 $t->ad_size=$row['ad_size'];
329 $t->ad_extra=$row['ad_extra'];
330 $t->jnt_order=$row['jnt_order'];
331 $fiche->attribut[$i]=$t;
332 }
333 $e=new Fiche_Def($fiche->cn, $fiche->fiche_def);
334 $e->GetAttribut();
335
336 if (sizeof($fiche->attribut)!=sizeof($e->attribut))
337 {
338
339 /*
340 * !! Missing attribute
341 */
342 foreach ($e->attribut as $f)
343 {
344 $flag=0;
345 foreach ($fiche->attribut as $g)
346 {
347 if ($g->ad_id==$f->ad_id)
348 $flag=1;
349 }
350 if ($flag==0)
351 {
352 // there's a missing one, we insert it
353 $t=new Card_Property($fiche->cn, $f->ad_id);
354 $t->av_text="";
355 $t->ad_text=$f->ad_text;
356 $t->jnt_order=$f->jnt_order;
357 $t->ad_type=$f->ad_type;
358 $t->ad_size=$f->ad_size;
359 $t->ad_id=$f->ad_id;
360 $t->ad_extra=$f->ad_extra;
361 $fiche->attribut[$Max]=$t;
362 $Max++;
363 } // if flag == 0
364 }// foreach
365 }//missing attribut
366 }
if($action=='add_line') if( $action=='remove_line') if($action=='remove_cat') if(isset($_POST['change_name'])) if($action=='save_line') if(isset($_POST['add_modele'])) $fiche_def
contains the attributes of a card , manage them, save them , ...
static num_row($ret)
wrapper for the function pg_num_rows
define Class fiche and fiche def, those class are using class attribut
$flag
Definition: install.php:531

References $e, $f, $fiche, $fiche_def, $flag, $i, $Max, $row, $sql, elseif, DatabaseCore\fetch_array(), and DatabaseCore\num_row().

Referenced by Fiche\getAttribut().

+ Here is the call graph for this function:

◆ print()

Card_Property::print ( )

Compute a HTML string in a TR element with information of this card property.

Returns
string HTML into tr

Definition at line 394 of file card_property.class.php.

395 {
396 $w=new IText();
397 $w->table=1;
398 $w->readOnly=true;
399 $w->css_size="100%";
400 $msg="";
401 $bulle="";
402 $ret="";
404 if ($this->ad_id==21||$this->ad_id==22||$this->ad_id==20||$this->ad_id==31)
405 {
406 $bulle=Icon_Action::infobulle(21);
407 }
408
409 // Warning length quickcode
410 if ($this->ad_id==ATTR_DEF_QUICKCODE)
411 {
412 $bulle=Icon_Action::warnbulle(76);
413 }
414 if ($this->ad_id==ATTR_DEF_NAME||$this->ad_id==ATTR_DEF_QUICKCODE)
415 {
416 $class=" input_text highlight info";
417 }
418 else
419 {
420 $class="input_text";
421 }
422 switch ($this->ad_type)
423 {
424 case 'select':
425 $x=new ISelect();
426 $x->value=$this->cn->make_array($this->ad_extra);
427 $x->selected=$this->av_text;
428 $value=$x->display();
429 $w->value=$value;
430 break;
431 case 'check':
432 $w=new InputSwitch("av_text".$this->ad_id);
433 $w->value=$this->av_text;
434 $w->value=(trim($w->value)=="")?1:$w->value;
435 break;
436 default:
437 $w->value=$this->av_text;
438 }
439 $url="<td>".$this->add_link($this->ad_id,$this->av_text).'</td>';
440 $ret.="<TR>".td(_($this->ad_text)." $bulle", ' class="'.$class.'" ').td($value." $msg",
441 'style="border:1px solid blue"').'<td>'.$url.'</td>'." </TR>";
442 return $ret;
443 }
foreach($array as $idx=> $m) $w
$class

References $av_text, $class, $msg, $ret, $url, $value, $w, ATTR_DEF_NAME, ATTR_DEF_QUICKCODE, cn, Icon_Action\infobulle(), and Icon_Action\warnbulle().

+ Here is the call graph for this function:

◆ set_ad_extra()

Card_Property::set_ad_extra (   $ad_extra)

Definition at line 136 of file card_property.class.php.

136 : void
137 {
138 $this->ad_extra=$ad_extra;
139 }

References $ad_extra.

◆ set_ad_id()

Card_Property::set_ad_id (   $ad_id)

Definition at line 111 of file card_property.class.php.

111 : void
112 {
113 $this->ad_id=$ad_id;
114 }

References $ad_id.

◆ set_ad_size()

Card_Property::set_ad_size (   $ad_size)

Definition at line 131 of file card_property.class.php.

131 : void
132 {
133 $this->ad_size=$ad_size;
134 }

References $ad_size.

◆ set_ad_text()

Card_Property::set_ad_text (   $ad_text)

Definition at line 116 of file card_property.class.php.

116 : void
117 {
118 $this->ad_text=$ad_text;
119 }

References $ad_text.

◆ set_ad_type()

Card_Property::set_ad_type (   $ad_type)

Definition at line 126 of file card_property.class.php.

126 : void
127 {
128 $this->ad_type=$ad_type;
129 }

References $ad_type.

◆ set_av_text()

Card_Property::set_av_text (   $av_text)

Definition at line 121 of file card_property.class.php.

121 : void
122 {
123 $this->av_text=$av_text;
124 }

References $av_text.

◆ set_jnt_order()

Card_Property::set_jnt_order (   $jnt_order)

Definition at line 141 of file card_property.class.php.

141 : void
142 {
143 $this->jnt_order=$jnt_order;
144 }

References $jnt_order.

◆ setDisplayMode()

Card_Property::setDisplayMode (   $p_mode)

Definition at line 63 of file card_property.class.php.

64 {
65 if ( ! in_array($p_mode,array("window","large"))) {
66 throw new Exception("FIC70 invalide display mode");
67 }
68 $this->display_mode=$p_mode;
69 return $this;
70 }

◆ update()

static Card_Property::update ( Fiche  $p_fiche)
static

update all the data of the card , including f_enable. if we are in a transaction we don't commit here , else if not then a transaction is started and committed . The member attributes $p_fiche->attribut will be saved into fiche_detail after transforming if needed. If a transaction is started if there is none, so updating a card is always in a transaction.

Definition at line 454 of file card_property.class.php.

455 {
456 //transaction in the function or from the caller
457 $commit=false;
458 try
459 {
460 // are we inside a transaction (between BEGIN - COMMIT )
461 if ($p_fiche->cn->status()==PGSQL_TRANSACTION_IDLE)
462 {
463 $p_fiche->cn->start();
464 $commit=true;
465 }
466
467 $p_fiche->cn->exec_sql("update fiche set f_enable=$1 where f_id=$2",
468 array($p_fiche->get_f_enable(), $p_fiche->id));
469
470 $name = $p_fiche->strAttribut(ATTR_DEF_NAME);
471
472 // parse the attribute
473 foreach ($p_fiche->attribut as $value)
474 {
475 // retrieve jft_id to update table attr_value
476 $sql=" select jft_id from fiche_detail where ad_id=$1 and f_id=$2";
477 $Ret=$p_fiche->cn->exec_sql($sql, [$value->ad_id, $p_fiche->id]);
478
479 // if attribute doesn't exist, then we insert one,
480 if (Database::num_row($Ret)==0)
481 {
482 // we need to insert this new attribut , $jft_id contains the PK of fiche_detail
483 $jft_id=$p_fiche->cn->get_next_seq('s_jnt_fic_att_value');
484
485 $sql2="insert into fiche_detail(jft_id,ad_id,f_id,ad_value) values ($1,$2,$3,NULL)";
486
487 $ret2=$p_fiche->cn->exec_sql($sql2, array($jft_id, $value->ad_id, $p_fiche->id));
488 }
489 else
490 {
492 // $jft_id contains the PK of fiche_detail
493 $jft_id=$tmp['jft_id'];
494 }
495
496 // Special traitement
497 // quickcode , if already used in ledger , it cannot be changed
498 if ($value->ad_id==ATTR_DEF_QUICKCODE)
499 {
500 $used = $p_fiche->cn->get_value("select count(*) from jrnx where j_qcode= $1",[$value->av_text]);
501 if ($used == 0) {
502 $sql=sprintf("select update_quick_code(%d,'%s')", $jft_id, sql_string($value->av_text));
503 $p_fiche->cn->exec_sql($sql);
504 }
505 continue;
506 }
507 // name
508 if ($value->ad_id==ATTR_DEF_NAME && noalyss_strlentrim($value->av_text)==0 )
509 {
510 continue;
511 }
512 // account
513 if ($value->ad_id==ATTR_DEF_ACCOUNT)
514 {
515 $v=mb_strtoupper($value->av_text??"");
516 // 2 accounts given
517 if (trim($v)!='')
518 {
519 if (strpos($v, ',')!=0)
520 {
521 $ac_array=explode(",", $v);
522 if (count($ac_array)<>2)
523 throw new Exception('Désolé, il y a trop de virgule dans le poste comptable '.h($v));
524 $part1=$ac_array[0];
525 $part2=$ac_array[1];
526 $part1=$p_fiche->cn->get_value('select format_account($1)', array($part1));
527 $part2=$p_fiche->cn->get_value('select format_account($1)', array($part2));
528
529 if (mb_strlen($part1)>40)
530 throw new Exception("CP475."._("Poste comptable trop long"), 1);
531 if (mb_strlen($part2)>40)
532 throw new Exception("CP476."._("Poste comptable trop long"), 1);
533
534 $acc_account1=new Acc_Account($p_fiche->cn, $part1);
535
536 if ($acc_account1->get_parameter("id")==-1)
537 {
538 $account_name=$name;
539 $acc_account1->set_parameter("pcm_lib", $account_name);
540 $acc_account1->set_parameter('pcm_direct_use', "Y");
541 $parent=$acc_account1->find_parent();
542 $acc_account1->set_parameter("pcm_val_parent", $parent);
543 $acc_account1->save();
544 }
545 // Check that the accounting can be used directly
546 if ($acc_account1->get_parameter('pcm_direct_use')=='N')
547 {
548 throw new Exception("CP493."._("Utilisation directe interdite du poste comptable $part1"));
549 }
550 // Part 2
551 $acc_account2=new Acc_Account($p_fiche->cn, $part2);
552
553 if ($acc_account2->get_parameter("id")==-1)
554 {
555 $account_name=$name;
556 $acc_account2->set_parameter("pcm_lib", $account_name);
557 $acc_account2->set_parameter('pcm_direct_use', "Y");
558 $parent=$acc_account2->find_parent();
559 $acc_account2->set_parameter("pcm_val_parent", $parent);
560 $acc_account2->save();
561 }
562
563 // Check that the accounting can be used directly
564 if ($acc_account2->get_parameter('pcm_direct_use')=='N')
565 {
566 throw new Exception("CP511."._("Utilisation directe interdite du poste comptable $part2"));
567 }
568 $v=$part1.','.$part2;
569 }
570 else
571 {
572 if (mb_strlen($v)>40)
573 throw new Exception("CP520."._("Poste comptable trop long"), 1);
574 $acc_account=new Acc_Account($p_fiche->cn, $v);
575 // Set default for new accounting
576 if ($acc_account->get_parameter("id")==-1)
577 {
578 $account_name=$name;
579 $acc_account->set_parameter("pcm_lib", $account_name);
580 // By Default can be used directly
581 $acc_account->set_parameter('pcm_direct_use', "Y");
582 $parent=$acc_account->find_parent();
583 $acc_account->set_parameter("pcm_val_parent", $parent);
584 $acc_account->save();
585 }
586
587 $acc_account=new Acc_Account($p_fiche->cn, $v);
588 if ($acc_account->get_parameter('pcm_direct_use')=='N')
589 {
590 throw new Exception("CP537."._("Utilisation directe interdite du poste comptable $v"));
591 }
592 }
593 $sql=sprintf("select account_insert(%d,'%s')", $p_fiche->id, $v);
594 try
595 {
596 $p_fiche->cn->exec_sql($sql);
597 }
598 catch (Exception $e)
599 {
600 throw new Exception("CP546."._("opération annulée")." ".$e->getMessage());
601 }
602 continue;
603 }
604 if (noalyss_strlentrim($v)==0)
605 {
606
607 $sql=sprintf("select account_insert(%d,null)", $p_fiche->id);
608 try
609 {
610 $Ret=$p_fiche->cn->exec_sql($sql);
611 }
612 catch (Exception $e)
613 {
614 throw new Exception("CP560."._("Erreur : Aucun compte parent ")."[$v]");
615 }
616
617 continue;
618 }
619 }
620 // TVA
621 if ($value->ad_id==ATTR_DEF_TVA)
622 {
623 // Verify if the rate exists, if not then do not update
624 if (noalyss_strlentrim($value->av_text)!=0)
625 {
626 if ($p_fiche->cn->get_value("select count(*) from tva_rate where tva_id=$1",[$value->av_text])==0)
627 {
628 continue;
629 }
630 }
631 }
632 // Normal traitement
633 $sql="update fiche_detail set ad_value=$1 where jft_id=$2";
634 $p_fiche->cn->exec_sql($sql, array(noalyss_strip_tags($value->av_text), $jft_id));
635 }
636 if ($commit)
637 {
638 $p_fiche->cn->commit();
639 }
640 }
641 catch (Exception $e)
642 {
643 echo '<span class="error">'.
644 $e->getMessage().
645 '</span>';
646 record_log("CP597.".$e->getMessage().$e->getTraceAsString());
647 if ($commit) { $p_fiche->cn->rollback(); }
648 return;
649 }
650
651 return;
652 }
noalyss_strip_tags($p_string)
Definition: ac_common.php:1569
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
sql_string($p_string)
Fix the problem with the quote char for the database.
Definition: ac_common.php:511
h( $row[ 'oa_description'])
Manage the account from the table tmp_pcmn.
strAttribut($p_ad_id, $p_return=1)
get_f_enable()

References $e, $name, $sql, $tmp, $value, ATTR_DEF_ACCOUNT, ATTR_DEF_NAME, ATTR_DEF_QUICKCODE, ATTR_DEF_TVA, DatabaseCore\fetch_array(), Fiche\get_f_enable(), h, noalyss_strip_tags(), noalyss_strlentrim(), DatabaseCore\num_row(), record_log(), sql_string(), and Fiche\strAttribut().

Referenced by Fiche\insert(), and Fiche\update().

+ Here is the call graph for this function:

Field Documentation

◆ $ad_extra

Card_Property::$ad_extra

ad_extra extra info for a attribute

Definition at line 45 of file card_property.class.php.

Referenced by build_input(), get_ad_extra(), and set_ad_extra().

◆ $ad_id

Card_Property::$ad_id

ad_id int id of the attribute attr_def.ad_id

Definition at line 35 of file card_property.class.php.

Referenced by __construct(), build_input(), get_ad_id(), and set_ad_id().

◆ $ad_size

Card_Property::$ad_size

ad_size int size of the attribute

Definition at line 43 of file card_property.class.php.

Referenced by build_input(), get_ad_size(), and set_ad_size().

◆ $ad_text

Card_Property::$ad_text

ad_text string label of the attribute attr_def.ad_def

Definition at line 37 of file card_property.class.php.

Referenced by build_input(), get_ad_text(), and set_ad_text().

◆ $ad_type

Card_Property::$ad_type

ad_type string : type of this attribute (select, text ,...)

Definition at line 41 of file card_property.class.php.

Referenced by get_ad_type(), and set_ad_type().

◆ $av_text

Card_Property::$av_text

av_text string value of this attribute

Definition at line 39 of file card_property.class.php.

Referenced by build_input(), get_av_text(), print(), and set_av_text().

◆ $cn

Card_Property::$cn

cn database connexion

Definition at line 49 of file card_property.class.php.

Referenced by __construct().

◆ $display_mode

Card_Property::$display_mode
protected

display mode values are large , window , display Property depending of this mode.

Definition at line 51 of file card_property.class.php.

Referenced by getDisplayMode().

◆ $jnt_order

Card_Property::$jnt_order

jnt_order order to display

Definition at line 47 of file card_property.class.php.

Referenced by get_jnt_order(), and set_jnt_order().


The documentation for this class was generated from the following file: