noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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
 
 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
 
 print ()
 Compute a HTML string in a TR element with information of this card property.
 
 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
 
static get_attribute (\Database $conx, $card_id, $property_id)
 returns the property value of a card without creating a card
 
static load (Fiche $fiche)
 Load all the attribute of a card , it modifies the parameter $fiche.
 
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.
 

Data Fields

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

Protected Attributes

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

Private Member Functions

 add_link ($p_ad_id, $p_text)
 add a link
 

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
$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 701 of file card_property.class.php.

701 {
702 if ( $this->display_mode=="large" && $p_ad_id == ATTR_DEF_WEBSITE) {
703 $url=linkTo($p_text);
704 }elseif ( $this->display_mode=="large" && $p_ad_id == ATTR_DEF_EMAIL) {
705 $url=mailTo($p_text);
706 }elseif ( $this->display_mode=="large" && $p_ad_id == ATTR_DEF_FAX) {
707 $url=faxTo($p_text);
708 }else {
709 return "";
710 }
711 return $url;
712 }
mailTo($p_email)
compose a HTML string with email
linkTo($p_url)
const ATTR_DEF_EMAIL
Definition constant.php:235
const ATTR_DEF_WEBSITE
Definition constant.php:246
const ATTR_DEF_FAX
Definition constant.php:238
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

Propose a button to check VAT

Propose a button to check VAT

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;font-size:80%;display:block\">" .
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;font-size:80%;display:block\">" . _("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
198 }
199 if($this->ad_id == ATTR_DEF_BQ_NO)
200 {
201 $result['input']=new IBan_Number("av_text{$this->ad_id}",$this->av_text);
202 $result['label']=$this->ad_text;
203 return $result;
204 }
205 if ($this->ad_id == ATTR_DEF_NUMTVA) {
206 /// Propose a button to check VAT
207 $result['input']=new IVATNumber( "av_text" . $this->ad_id,$this->av_text);
208 $result['label']=$this->ad_text;
209 return $result;
210 }
211 if ( $this->ad_id == ATTR_DEF_QUANTITY_TYPE){
212 $result['input']=new IText( "av_text" . $this->ad_id,$this->av_text);
213 $array=$this->cn->get_array("select qc_code,format('%s %s',qc_code,qc_label) label from quantity_code_ref order by qc_label",p_mode: PGSQL_NUM);
214 $result['input']->set_datalist($array);
215 $result['label']=$this->ad_text;
216 return $result;
217 }
218 if ( $this->ad_id == ATTR_DEF_PEPPOLID)
219 {
220 /// Propose a button to check VAT
221 $result['input']=new IPEPPOL_ID( "av_text" . $this->ad_id,$this->av_text);
222 $result['label']=$this->ad_text;
223 return $result;
224 }
225
226 if ($this->ad_id == ATTR_DEF_TVA) {
227 $result['input'] = new ITva_Popup( "av_text" . $this->ad_id);
228 $result['input']->table = 0;
229 $result['input']->value = $this->av_text;
230 $result['label']=$this->ad_text;
231 return $result;
232 }
233 // Warning length quickcode
234 if ($this->ad_id == ATTR_DEF_QUICKCODE) {
235 $result['input'] = new IText();
236 $result['input']->css_size = "100%";
237 $result['input']->label = $this->ad_text;
238 $result['input']->name = "av_text" . $this->ad_id;
239 $result['input']->value = $this->av_text;
240 $result['input']->placeholder= "999NOM";
241 $result['bulle'] = Icon_Action::warnbulle(76);
242 $result['label']=$this->ad_text;
243 return $result;
244 }
245
246 switch ($this->ad_type) {
247 case 'text':
248 $result['input'] = new IText();
249 $result['input']->css_size = "100%";
250 $result['input']->value = $this->av_text;
251 break;
252 case 'numeric':
253 $result['input'] = new INum();
254 $result['input']->prec = ($this->ad_extra == "") ? 2 : $this->ad_extra;
255 $result['input']->size = $this->ad_size;
256 $result['input']->value = $this->av_text;
257 break;
258 case 'date':
259 $result['input'] = new IDate();
260 $result['input']->value = $this->av_text;
261 break;
262 case 'zone':
263 $result['input'] = new ITextArea();
264 $result['input']->style = ' class="itextarea" style="margin:0px;width:100%"';
265 $result['input']->value = $this->av_text;
266 break;
267 case 'poste':
268 $result['input'] = new IPoste("av_text" . $this->ad_id);
269 $result['input']->set_attribute('ipopup', 'ipop_account');
270 $result['input']->set_attribute('account', "av_text" . $this->ad_id);
271 $result['input']->table = 1;
272 $bulle = Icon_Action::infobulle(14);
273 $result['input']->value = $this->av_text;
274 break;
275 case 'check':
276 $result['input'] = new InputSwitch("av_text" . $this->ad_id);
277 $result['input']->value = (empty($this->av_text) ) ? 0 : 1;
278 break;
279 case 'select':
280 $result['input'] = new ISelect("av_text" . $this->ad_id);
281 $result['input']->value = $this->cn->make_array($this->ad_extra);
282 $result['input']->style = 'style="width:100%"';
283 $result['input']->selected = $this->av_text;
284 break;
285 case 'card':
286 $result['input'] = new ICard("av_text" . $this->ad_id);
287 // filter on frd_id
288 $result['input']->extra = $this->ad_extra;
289 $result['input']->extra2 = 0;
290 $result['input']->id = uniqid();
291 $result['label'] = new ISpan();
293 $result['input']->width = $this->ad_size;
294 $result['input']->extra = $filter;
295 $result['input']->extra2 = 0;
296 $result['input']->limit = 6;
297 $result['label']->name = "av_text" . $this->ad_id . $result['input']->id . "_label";
298 $result['input']->set_attribute('ipopup', 'ipopcard');
299 $result['input']->set_attribute('typecard', $this->ad_extra);
300 $result['input']->set_attribute('inp', $result['input']->id);
301 $result['input']->set_attribute('label', "av_text" . $this->ad_id . $result['input']->id . "_label");
302 $result['input']->autocomplete = 1;
303 $result['input']->dblclick = "fill_ipopcard(this);";
304 $result['msg'] = $result['input']->search();
305 $result['msg'] .= $result['label']->input();
306 $result['input']->value = $this->av_text;
307 break;
308 }
309 $result['input']->table = 0;
310 $result['label']=$this->ad_text;
311
312
313 $result['input']->label = $this->ad_text;
314 $result['input']->name = "av_text" . $this->ad_id;
315 if ($this->ad_id == 21 || $this->ad_id == 22 || $this->ad_id == 20 || $this->ad_id == 31) {
316 $result['bulle'] = Icon_Action::infobulle(21);
317 }
318
319
320
321 return $result;
322 }
noalyss_strlentrim($p_string)
_("actif, passif,charge,...")
$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
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.
const ATTR_DEF_NUMTVA
Definition constant.php:229
const ATTR_DEF_NAME
Definition constant.php:223
const ATTR_DEF_TVA
Definition constant.php:228
const ATTR_DEF_BQ_NO
Definition constant.php:224
const ATTR_DEF_PEPPOLID
Definition constant.php:256
const ATTR_DEF_QUANTITY_TYPE
Definition constant.php:257
const ATTR_DEF_QUICKCODE
Definition constant.php:244
const ATTR_DEF_ACCOUNT
Definition constant.php:222

References $a, $ad_extra, $ad_id, $ad_size, $ad_text, $array, $av_text, $filter, $result, $sql, _, ATTR_DEF_ACCOUNT, ATTR_DEF_BQ_NO, ATTR_DEF_NAME, ATTR_DEF_NUMTVA, ATTR_DEF_PEPPOLID, ATTR_DEF_QUANTITY_TYPE, ATTR_DEF_QUICKCODE, ATTR_DEF_TVA, cn, 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 720 of file card_property.class.php.

721 {
722 $nb = count($a_property);
723 for ($i = 0; $i < $nb; $i++) {
724 if ($a_property[$i]->get_ad_id() == $attr_def_id) return $a_property[$i];
725 }
726 return null;
727 }

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_attribute()

static Card_Property::get_attribute ( \Database $conx,
$card_id,
$property_id )
static

returns the property value of a card without creating a card

Parameters
\Database$conx
$card_id(int) FICHE.F_ID
$property_id(int) ad_value
Returns
string or false if nothing was found

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

736 {
737 $r=$conx->get_value("select ad_value from fiche_detail where
738 ad_id = $1 and f_id=$2",[$property_id,$card_id]);
739 if ( $conx->count() == 0) { return false;}
740 return $r;
741 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r

References $card_id, $r, DatabaseCore\count(), and DatabaseCore\get_value().

+ Here is the call graph for this function:

◆ 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 413 of file card_property.class.php.

414 {
415
416 $result=$this->build_input($p_fiche_def);
417
418
419 $url='<td>'.$this->add_link($this->ad_id,$this->av_text).'</td>';
420 $r="<TR>".
421 td(_($result["label"]). $result['bulle'],
422 ' class="'.$result['class'].'" ').
423 td($result["input"]->input().$result["msg"]).
424 $url.
425 " </TR>";
426 return $r;
427 }
td($p_string='', $p_extra='')
surround the string with td
Definition ac_common.php:83
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 333 of file card_property.class.php.

334 {
335 // if card is not yet saved then we don't load it from database but all the properties are set to empty
336 if ($fiche->id==0 && $fiche->fiche_def !=0 )
337 {
338 $fiche_def=new Fiche_Def($fiche->cn,$fiche->fiche_def);
339 $aProperty=$fiche_def->load_attribute();
340 $fiche->attribut=$aProperty;
341 return;
342 } elseif ($fiche->id==0 && $fiche->fiche_def ==0 )
343 {
344 return;
345// throw new Exception("CP147. Card category cannot be empty (fiche->set_fiche_def)",EXC_PARAM_VALUE);
346 }
347 $sql="select *
348 from
349 fiche
350 natural join fiche_detail
351 join jnt_fic_attr on (jnt_fic_attr.fd_id=fiche.fd_id and fiche_detail.ad_id=jnt_fic_attr.ad_id)
352 join attr_def on (attr_def.ad_id=fiche_detail.ad_id) where f_id= $1".
353 " order by jnt_order";
354
355 $Ret=$fiche->cn->exec_sql($sql, [$fiche->id]);
356 if (($Max=Database::num_row($Ret))==0)
357 return;
358 for ($i=0; $i<$Max; $i++)
359 {
361 $fiche->fiche_def=$row['fd_id'];
362 $fiche->set_f_enable($row['f_enable']);
363 $t=new Card_Property($fiche->cn);
364 $t->ad_id=$row['ad_id'];
365 $t->ad_text=$row['ad_text'];
366 $t->av_text=$row['ad_value'];
367 $t->ad_type=$row['ad_type'];
368 $t->ad_size=$row['ad_size'];
369 $t->ad_extra=$row['ad_extra'];
370 $t->jnt_order=$row['jnt_order'];
371 $fiche->attribut[$i]=$t;
372 }
373 $e=new Fiche_Def($fiche->cn, $fiche->fiche_def);
374 $e->load_attribute();
375
376 if (sizeof($fiche->attribut)!=sizeof($e->attribut))
377 {
378
379 /*
380 * !! Missing attribute
381 */
382 foreach ($e->attribut as $f)
383 {
384 $flag=0;
385 foreach ($fiche->attribut as $g)
386 {
387 if ($g->ad_id==$f->ad_id)
388 $flag=1;
389 }
390 if ($flag==0)
391 {
392 // there's a missing one, we insert it
393 $t=new Card_Property($fiche->cn, $f->ad_id);
394 $t->av_text="";
395 $t->ad_text=$f->ad_text;
396 $t->jnt_order=$f->jnt_order;
397 $t->ad_type=$f->ad_type;
398 $t->ad_size=$f->ad_size;
399 $t->ad_id=$f->ad_id;
400 $t->ad_extra=$f->ad_extra;
401 $fiche->attribut[$Max]=$t;
402 $Max++;
403 } // if flag == 0
404 }// foreach
405 }//missing attribut
406 }
$fiche_def
static num_row($ret)
wrapper for the function pg_num_rows
$t
Definition compute.php:46
$flag
Definition install.php:535

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

Referenced by Fiche\getAttribut(), and Fiche\load_attribute().

+ 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 434 of file card_property.class.php.

435 {
436 $w=new IText();
437 $w->table=1;
438 $w->readOnly=true;
439 $w->css_size="100%";
440 $msg="";
441 $bulle="";
442 $ret="";
444 if ($this->ad_id==21||$this->ad_id==22||$this->ad_id==20||$this->ad_id==31)
445 {
446 $bulle=Icon_Action::infobulle(21);
447 }
448
449 // Warning length quickcode
450 if ($this->ad_id==ATTR_DEF_QUICKCODE)
451 {
452 $bulle=Icon_Action::warnbulle(76);
453 }
454 if ($this->ad_id==ATTR_DEF_NAME||$this->ad_id==ATTR_DEF_QUICKCODE)
455 {
456 $class=" input_text highlight info";
457 }
458 else
459 {
460 $class="input_text";
461 }
462 switch ($this->ad_type)
463 {
464 case 'select':
465 $x=new ISelect();
466 $x->value=$this->cn->make_array($this->ad_extra);
467 $x->selected=$this->av_text;
468 $value=$x->display();
469 $w->value=$value;
470 break;
471 case 'check':
472 $w=new InputSwitch("av_text".$this->ad_id);
473 $w->value=$this->av_text;
474 $w->value=(trim($w->value)=="")?1:$w->value;
475 break;
476 default:
477 $w->value=$this->av_text;
478 }
479 $url="<td>".$this->add_link($this->ad_id,$this->av_text).'</td>';
480 $ret.="<TR>".td(_($this->ad_text)." $bulle", ' class="'.$class.'" ').td($value." $msg",
481 'style="border:1px solid blue"').'<td>'.$url.'</td>'." </TR>";
482 return $ret;
483 }
foreach($array as $idx=> $m) $w
$class
Display the Plugin and for each profile were it is installed or not.

References $av_text, $class, $msg, $ret, $url, $value, $w, $x, _, 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 494 of file card_property.class.php.

495 {
496 //transaction in the function or from the caller
497 $commit=false;
498 try
499 {
500 // are we inside a transaction (between BEGIN - COMMIT )
501 if ($p_fiche->cn->status()==PGSQL_TRANSACTION_IDLE)
502 {
503 $p_fiche->cn->start();
504 $commit=true;
505 }
506
507 $p_fiche->cn->exec_sql("update fiche set f_enable=$1 where f_id=$2",
508 array($p_fiche->get_f_enable(), $p_fiche->id));
509
510 $name = $p_fiche->get_attribute(ATTR_DEF_NAME);
511
512 // parse the attribute
513 foreach ($p_fiche->attribut as $value)
514 {
515 // retrieve jft_id to update table attr_value
516 $sql=" select jft_id from fiche_detail where ad_id=$1 and f_id=$2";
517 $Ret=$p_fiche->cn->exec_sql($sql, [$value->ad_id, $p_fiche->id]);
518
519 // if attribute doesn't exist, then we insert one,
520 if (Database::num_row($Ret)==0)
521 {
522 // we need to insert this new attribut , $jft_id contains the PK of fiche_detail
523 $jft_id=$p_fiche->cn->get_next_seq('s_jnt_fic_att_value');
524
525 $sql2="insert into fiche_detail(jft_id,ad_id,f_id,ad_value) values ($1,$2,$3,NULL)";
526
527 $ret2=$p_fiche->cn->exec_sql($sql2, array($jft_id, $value->ad_id, $p_fiche->id));
528 }
529 else
530 {
532 // $jft_id contains the PK of fiche_detail
533 $jft_id=$tmp['jft_id'];
534 }
535
536 // Special traitement
537 // quickcode , if already used in ledger , it cannot be changed
538 if ($value->ad_id==ATTR_DEF_QUICKCODE)
539 {
540 $used = $p_fiche->cn->get_value("select count(*) from jrnx where j_qcode= $1",[$value->av_text]);
541 if ($used == 0) {
542 $sql=sprintf("select update_quick_code(%d,'%s')", $jft_id, sql_string($value->av_text));
543 $p_fiche->cn->exec_sql($sql);
544 }
545 continue;
546 }
547 // name
548 if ($value->ad_id==ATTR_DEF_NAME && noalyss_strlentrim($value->av_text)==0 )
549 {
550 continue;
551 }
552 // account
553 if ($value->ad_id==ATTR_DEF_ACCOUNT)
554 {
555 $v=mb_strtoupper($value->av_text??"");
556 // 2 accounts given
557 if (trim($v)!='')
558 {
559 if (strpos($v, ',')!=0)
560 {
561 $ac_array=explode(",", $v);
562 if (count($ac_array)<>2)
563 throw new Exception('Désolé, il y a trop de virgule dans le poste comptable '.h($v));
564 $part1=$ac_array[0];
565 $part2=$ac_array[1];
566 $part1=$p_fiche->cn->get_value('select format_account($1)', array($part1));
567 $part2=$p_fiche->cn->get_value('select format_account($1)', array($part2));
568
569 if (mb_strlen($part1)>40)
570 throw new Exception("CP475."._("Poste comptable trop long"), 1);
571 if (mb_strlen($part2)>40)
572 throw new Exception("CP476."._("Poste comptable trop long"), 1);
573
574 $acc_account1=new Acc_Account($p_fiche->cn, $part1);
575
576 if ($acc_account1->get_parameter("id")==-1)
577 {
578 $account_name=$name;
579 $acc_account1->set_parameter("pcm_lib", $account_name);
580 $acc_account1->set_parameter('pcm_direct_use', "Y");
581 $parent=$acc_account1->find_parent();
582 $acc_account1->set_parameter("pcm_val_parent", $parent);
583 $acc_account1->save();
584 }
585 // Check that the accounting can be used directly
586 if ($acc_account1->get_parameter('pcm_direct_use')=='N')
587 {
588 throw new Exception("CP493."._("Utilisation directe interdite du poste comptable $part1"));
589 }
590 // Part 2
591 $acc_account2=new Acc_Account($p_fiche->cn, $part2);
592
593 if ($acc_account2->get_parameter("id")==-1)
594 {
595 $account_name=$name;
596 $acc_account2->set_parameter("pcm_lib", $account_name);
597 $acc_account2->set_parameter('pcm_direct_use', "Y");
598 $parent=$acc_account2->find_parent();
599 $acc_account2->set_parameter("pcm_val_parent", $parent);
600 $acc_account2->save();
601 }
602
603 // Check that the accounting can be used directly
604 if ($acc_account2->get_parameter('pcm_direct_use')=='N')
605 {
606 throw new Exception("CP511."._("Utilisation directe interdite du poste comptable $part2"));
607 }
608 $v=$part1.','.$part2;
609 }
610 else
611 {
612 if (mb_strlen($v)>40)
613 throw new Exception("CP520."._("Poste comptable trop long"), 1);
614 $acc_account=new Acc_Account($p_fiche->cn, $v);
615 // Set default for new accounting
616 if ($acc_account->get_parameter("id")==-1)
617 {
618 $account_name=$name;
619 $acc_account->set_parameter("pcm_lib", $account_name);
620 // By Default can be used directly
621 $acc_account->set_parameter('pcm_direct_use', "Y");
622 $parent=$acc_account->find_parent();
623 $acc_account->set_parameter("pcm_val_parent", $parent);
624 $acc_account->save();
625 }
626
627 $acc_account=new Acc_Account($p_fiche->cn, $v);
628 if ($acc_account->get_parameter('pcm_direct_use')=='N')
629 {
630 throw new Exception("CP537."._("Utilisation directe interdite du poste comptable $v"));
631 }
632 }
633 $sql=sprintf("select account_insert(%d,'%s')", $p_fiche->id, $v);
634 try
635 {
636 $p_fiche->cn->exec_sql($sql);
637 }
638 catch (Exception $e)
639 {
640 throw new Exception("CP546."._("opération annulée")." ".$e->getMessage());
641 }
642 continue;
643 }
644 if (noalyss_strlentrim($v)==0)
645 {
646
647 $sql=sprintf("select account_insert(%d,null)", $p_fiche->id);
648 try
649 {
650 $Ret=$p_fiche->cn->exec_sql($sql);
651 }
652 catch (Exception $e)
653 {
654 throw new Exception("CP560."._("Erreur : Aucun compte parent ")."[$v]");
655 }
656
657 continue;
658 }
659 }
660 // TVA
661 if ($value->ad_id==ATTR_DEF_TVA)
662 {
663 // Verify if the rate exists, if not then do not update
664 if (noalyss_strlentrim($value->av_text)!=0)
665 {
666 $acc_tva=Acc_Tva::build($p_fiche->cn,$value->av_text );
667 if ($acc_tva->tva_id==-1)
668 {
669 continue;
670 }
671 }
672 }
673 // Normal traitement
674 $sql="update fiche_detail set ad_value=$1 where jft_id=$2";
675 $p_fiche->cn->exec_sql($sql, array(noalyss_strip_tags($value->av_text), $jft_id));
676 }
677 if ($commit)
678 {
679 $p_fiche->cn->commit();
680 }
681 }
682 catch (Exception $e)
683 {
684 echo '<span class="error">'.
685 $e->getMessage().
686 '</span>';
687 record_log("CP597.".$e->getMessage().$e->getTraceAsString());
688 if ($commit) { $p_fiche->cn->rollback(); }
689 return;
690 }
691
692 return;
693 }
noalyss_strip_tags($p_string)
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...
sql_string($p_string)
Fix the problem with the quote char for the database.
h( $row[ 'oa_description'])
static build($db, $p_code)
retrieve TVA rate thanks the code that could be the tva_id or tva_code.
get_attribute($p_ad_id, $p_return=1)
return the string of the given attribute (attr_def.ad_id)
get_f_enable()

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

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: