noalyss Version-9
Public Member Functions | Data Fields
Fiche_Def Class Reference

define Class fiche and fiche def, those class are using class attribut More...

+ Collaboration diagram for Fiche_Def:

Public Member Functions

 __construct ($p_cn, $p_id=0)
 
 __toString ()
 
 Add ($array)
 Add a fiche category thanks the element from the array you cannot add twice the same cat. name table : insert into fiche_def insert into attr_def. More...
 
 count_category ($p_frd_id)
 count the number of fiche_def (category) which has the frd_id (type of category) More...
 
 display ()
 Display all card categories into a table. More...
 
 DisplayAttribut ($str="")
 Display all the attribut of the fiche_def. More...
 
 get ()
 Get attribut of the fiche_def. More...
 
 get_all ()
 Get all the fiche_def. More...
 
 get_attr_min ($p_fiche_def_ref)
 retrieve the mandatory field of the card model More...
 
 get_by_category ($p_cat)
 Get all the card where the fiche_def.frd_id is given in parameter. More...
 
 get_by_type ($step=0)
 Get all the card where the fiche_def.fd_id is given in parameter. More...
 
 getAttribut ()
 Get attribut of a fiche_def. More...
 
 HasAttribute ($p_attr)
 Check in vw_fiche_def if a fiche has a attribut X. More...
 
 input ()
 show the content of the form to create a new Fiche_Def_Ref More...
 
 input_base ()
 show input for the basic attribute : label, class_base, create_account use only when we want to update More...
 
 input_detail ()
 
 input_new ()
 
 insertAttribut ($p_ad_id, $p_order=-1)
 insert a new attribut for this fiche_def More...
 
 load ()
 alias for Fiche_Def->get(), More...
 
 myList ()
 list the card of a fd_id More...
 
 remove ()
 remove all the card from a categorie after having verify that the card is not used and then remove also the category More...
 
 removeAttribut ($array)
 remove an attribut for this fiche_def More...
 
 save_class_base ($p_label)
 Save the class base. More...
 
 save_description ($p_description)
 
 save_order ($p_array)
 save the order of a card, update the column jnt_fic_attr.jnt_order More...
 
 SaveLabel ($p_label)
 Save the label of the fiche_def. More...
 
 set_autocreate ($p_label)
 set the auto create accounting item for each card and save it into the database More...
 
 to_array ()
 make an array of attributes of the category of card (FICHE_DEF.FD_ID) The array can be used with the function insert, it will return a struct like this : in the first key (av_textX), X is the ATTR_DEF::AD_ID More...
 

Data Fields

 $all
 
 $attribut
 get from attr_xxx tables More...
 
 $class_base
 fiche_def.fd_class_base More...
 
 $cn
 database connection More...
 
 $create_account
 fd_create_account: flag More...
 
 $fd_description
 Description of the Card Category. More...
 
 $fiche_def
 fiche_def.frd_id = fiche_def_ref.frd_id More...
 
 $id
 id (fiche_def.fd_id More...
 
 $label
 fiche_def.fd_label More...
 

Detailed Description

define Class fiche and fiche def, those class are using class attribut

Definition at line 30 of file fiche_def.class.php.

Constructor & Destructor Documentation

◆ __construct()

Fiche_Def::__construct (   $p_cn,
  $p_id = 0 
)

Definition at line 42 of file fiche_def.class.php.

43 {
44 $this->cn=$p_cn;
45 $this->id=$p_id;
46
47
48 }
$input_from cn
Definition: balance.inc.php:66

References $p_id, and cn.

Member Function Documentation

◆ __toString()

Fiche_Def::__toString ( )

Definition at line 50 of file fiche_def.class.php.

50 : string
51 {
52 return "fiche_def".print_r($this,true);
53 }

◆ Add()

Fiche_Def::Add (   $array)

Add a fiche category thanks the element from the array you cannot add twice the same cat. name table : insert into fiche_def insert into attr_def.

Parameters
$arrayarray index FICHE_REF nom_mod class_base fd_description create

Check needed info

Definition at line 214 of file fiche_def.class.php.

215 {
216 /**
217 * Check needed info
218 */
219 $http=new HttpInput();
220 $http->set_array($array);
221 $p_nom_mod = $http->extract('nom_mod',"string","");
222 $p_fd_description = $http->extract('fd_description',"string", "");
223 $p_class_base=$http->extract('class_base',"string", "");
224 $p_fiche_def= $http->extract('FICHE_REF',"string", "");
225 $p_create= $http->extract('create',"string", "off");
226
227 // If there is no description then add a empty one
228 if ( ! isset ($p_fd_description)) {
229 $p_fd_description="";
230 }
231 // Format correctly the name of the cat. of card
232 $p_nom_mod=sql_string($p_nom_mod);
233
234
235 // Name can't be empty
236 if ( noalyss_strlentrim($p_nom_mod) == 0 )
237 {
238 alert (_('Le nom de la catégorie ne peut pas être vide'));
239 return 1;
240 }
241 // $p_fiche_def can't be empty
242 if ( noalyss_strlentrim($p_fiche_def) == 0 )
243 {
244 alert (_('Un modéle de catégorie est obligatoire'));
245 return 1;
246 }
247
248 /* check if the cat. name already exists */
249 $sql="select count(*) from fiche_Def where upper(fd_label)=upper($1)";
250 $count=$this->cn->get_value($sql,array(trim($p_nom_mod)));
251
252 if ($count != 0 ) {
253 alert (_('Catégorie existante'));
254 return 1;
255 }
256 // Set the value of fiche_def.fd_create_account
257 // automatic creation for 'poste comptable'
258 if ( $p_create == "on" && noalyss_strlentrim($p_class_base) != 0)
259 $p_create='true';
260 else
261 $p_create='false';
262
263 // Class is valid ?
264 if ( sql_string($p_class_base) != null || ( $p_class_base !='' && strpos(',',$p_class_base) != 0 ))
265 {
266 // p_class is a valid number
267 $sql="insert into fiche_def(fd_label,fd_class_base,frd_id,fd_create_account,fd_description)
268 values ($1,$2,$3,$4,$5) returning fd_id";
269
270 $this->id=$this->cn->get_value($sql,array($p_nom_mod,$p_class_base,$p_fiche_def,$p_create,$p_fd_description));
271
272 // p_class must be added to tmp_pcmn if it is a single accounting
273 if ( strpos(',',$p_class_base) ==0)
274 {
275 $sql="select account_add($1,$2)";
276 $Res=$this->cn->exec_sql($sql,array($p_class_base,$p_nom_mod));
277 }
278 // Get the fd_id
279 $fd_id=$this->cn->get_current_seq('s_fdef');
280
281 // update jnt_fic_attr
282 $sql=sprintf("insert into jnt_fic_attr(fd_id,ad_id,jnt_order)
283 values (%d,%d,10)",$fd_id,ATTR_DEF_ACCOUNT);
284 $Res=$this->cn->exec_sql($sql);
285 }
286 else
287 {
288 //There is no class base not even as default
289 $sql="insert into fiche_def(fd_label,frd_id,fd_create_account,fd_description) values ($1,$2,$3,$4) returning fd_id";
290
291
292 $this->id=$this->cn->get_value($sql,array($p_nom_mod,$p_fiche_def,$p_create,$p_fd_description));
293
294 // Get the fd_id
295 $fd_id=$this->cn->get_current_seq('s_fdef');
296
297 }
298
299 // Get the default attr_def from attr_min
300 $def_attr=$this->get_attr_min($p_fiche_def);
301
302 //if defaut attr not null
303 // build the sql insert for the table attr_def
304 if (sizeof($def_attr) != 0 )
305 {
306 // insert all the mandatory fields into jnt_fiche_attr
307 foreach ( $def_attr as $row)
308 {
309 $order=$row['ad_default_order'];
310 if ( $row['ad_id'] == ATTR_DEF_NAME )
311 $order=0;
312 $count=$this->cn->get_value("select count(*) from jnt_fic_attr where fd_id=$1 and ad_id=$2",array($fd_id,$row['ad_id']));
313 if ($count == 0)
314 {
315 $sql=sprintf("insert into jnt_fic_Attr(fd_id,ad_id,jnt_order)
316 values (%d,%s,%d)",
317 $fd_id,$row['ad_id'],$order);
318 $this->cn->exec_sql($sql);
319 }
320 }
321 }
322 $this->id=$fd_id;
323 return 0;
324
325 }//--------------end function Add ----------------------------
noalyss_strlentrim($p_string)
Definition: ac_common.php:1549
sql_string($p_string)
Fix the problem with the quote char for the database.
Definition: ac_common.php:511
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738
get_attr_min($p_fiche_def_ref)
retrieve the mandatory field of the card model
manage the http input (get , post, request) and extract from an array
const ATTR_DEF_NAME
Definition: constant.php:216
const ATTR_DEF_ACCOUNT
Definition: constant.php:215
$Res
$count
$fd_id
Definition: fiche.inc.php:104

References $array, $count, $fd_id, $http, $order, $Res, $row, $sql, alert(), ATTR_DEF_ACCOUNT, ATTR_DEF_NAME, cn, get_attr_min(), noalyss_strlentrim(), and sql_string().

+ Here is the call graph for this function:

◆ count_category()

Fiche_Def::count_category (   $p_frd_id)

count the number of fiche_def (category) which has the frd_id (type of category)

Parameters
$p_frd_idis the frd_id in constant.php the FICHE_TYPE_
Returns
the number of cat. of card of the given type
See also
constant.php

Definition at line 778 of file fiche_def.class.php.

779 {
780 $ret=$this->cn->count_sql("select fd_id from fiche_def where frd_id=$1",array($p_frd_id));
781 return $ret;
782 }

References $ret, and cn.

◆ display()

Fiche_Def::display ( )

Display all card categories into a table.

Returns
HTML row

Definition at line 181 of file fiche_def.class.php.

182 {
183 $tab = new Sort_Table();
184
185 $url = HtmlInput::get_to_string(array('ac', 'gDossier'));
186 $tab->add(_("Nom de fiche"), $url, "order by fd_label asc", "order by fd_label desc", "na", "nd");
187 $tab->add(_("Basé sur le poste comptable"), $url, "order by fd_class_base asc", "order by fd_class_base desc", "pa", "pd");
188 $tab->add(_("Calcul automatique du poste comptable"), $url, "order by fd_create_account asc", "order by fd_create_account desc", "ca", "cd");
189 $tab->add(_("Basé sur le modèle"), $url, "order by frd_text asc", "order by frd_text desc", "ma", "md");
190
191 $order = (isset($_GET['ord'])) ? $tab->get_sql_order($_GET["ord"]) : $tab->get_sql_order("na");
192
193
194 $res = $this->cn->exec_sql("SELECT fd_id, fd_class_base, fd_label, fd_create_account, fiche_def_ref.frd_id,
195frd_text , fd_description FROM fiche_def join fiche_def_ref on (fiche_def.frd_id=fiche_def_ref.frd_id)
196$order
197");
198
199 require_once NOALYSS_TEMPLATE.'/fiche_def_list.php';
200 }
$url
$_GET['qcode']
static get_to_string($array, $start="?")
transform $_GET data to string
Description of class_syn_sort_table.

References $_GET, $order, $res, $tab, $url, cn, and HtmlInput\get_to_string().

+ Here is the call graph for this function:

◆ DisplayAttribut()

Fiche_Def::DisplayAttribut (   $str = "")

Display all the attribut of the fiche_def.

Parameters
$strgive the action possible values are remove, empty

Definition at line 498 of file fiche_def.class.php.

499 {
500 if ( $this->id == 0 )
501 return ;
502 $this->cn->exec_sql('select fiche_attribut_synchro($1)',array($this->id));
503
504 $MaxLine=sizeof($this->attribut);
505 $r="<TABLE>";
506 $r.="<tr>".th('Nom attribut').th('').th('Ordre','style="text-align:right"').'</tr>';
507 // Display each attribute
508 $add_action="";
509 for ($i=0;$i<$MaxLine;$i++)
510 {
511 $class="even";
512 if ( $i % 2 == 0 )
513 $class="odd";
514
515 $r.='<TR class="'.$class.'"><td>';
516 // Can change the name
517 if ( $this->attribut[$i]->ad_id == ATTR_DEF_NAME )
518 {
519 continue;
520 }
521 else
522 {
523 if ( $str == "remove" )
524 {
525 //Only for the not mandatory attribute (not defined in attr_min)
526 if ( $this->cn->count_sql("select * from attr_min where frd_id=".
527 $this->fiche_def." and ad_id = ".$this->attribut[$i]->ad_id) == 0
528 && $this->attribut[$i]->ad_id != ATTR_DEF_QUICKCODE
529 && $this->attribut[$i]->ad_id != ATTR_DEF_ACCOUNT
530 )
531 {
532 $add_action=sprintf( '</TD><TD> Supprimer <input type="checkbox" name="chk_remove[]" value="%d">',
533 $this->attribut[$i]->ad_id);
534 }
535 else
536 $add_action="</td><td>";
537 }
538 // The attribut.
539 $a=sprintf('%s ', $this->attribut[$i]->ad_text);
540 $r.=$a.$add_action;
541 /*---------------------------------------- */
542 /* ORDER OF THE CARD */
543 /*---------------------------------------- */
544 $order=new IText();
545 $order->name='jnt_order'.$this->attribut[$i]->ad_id;
546 $order->size=3;
547 $order->value=$this->attribut[$i]->jnt_order;
548 $r.='</td><td> '.$order->input();
549 }
550 $r.= '</td></tr>';
551 }
552
553 // Show the possible attribute which are not already attribute of the model
554 // of card
555 $Res=$this->cn->exec_sql("select ad_id,ad_text from attr_def
556 where
557 ad_id not in (select ad_id from fiche_def natural join jnt_fic_attr
558 where fd_id=$1) order by ad_text",array($this->id) );
560
561 // Show the unused attribute
562 $r.='<TR> <TD>';
563 $r.= '<SELECT NAME="ad_id">';
564 for ($i=0;$i<$M;$i++)
565 {
567 $a=sprintf('<OPTION VALUE="%s"> %s',
568 $l['ad_id'],$l['ad_text']);
569 $r.=$a;
570 }
571 $r.='</SELECT>';
572
573 $r.="</TABLE>";
574 return $r;
575 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$class
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
$attribut
get from attr_xxx tables
Html Input.
Definition: itext.class.php:30
const ATTR_DEF_QUICKCODE
Definition: constant.php:237
$str
Definition: fiche.inc.php:91

References $a, $attribut, $class, $i, $l, $order, $r, $Res, $str, ATTR_DEF_ACCOUNT, ATTR_DEF_NAME, ATTR_DEF_QUICKCODE, cn, DatabaseCore\fetch_array(), DatabaseCore\num_row(), and return.

Referenced by input_detail().

+ Here is the call graph for this function:

◆ get()

Fiche_Def::get ( )

Get attribut of the fiche_def.

Definition at line 118 of file fiche_def.class.php.

119 {
120 if ( $this->id == 0 )
121 return 0;
122 /* $this->cn->exec_sql('select fiche_attribut_synchro($1)',
123 array($this->id));
124 */
125 $sql="select * from fiche_def ".
126 " where fd_id= $1";
127 $Ret=$this->cn->exec_sql($sql,[$this->id]);
128 if ( ($Max=Database::num_row($Ret)) == 0 )
129 return ;
131 $this->label=$row['fd_label'];
132 $this->class_base=$row['fd_class_base'];
133 $this->fiche_def=$row['frd_id'];
134 $this->create_account=$row['fd_create_account'];
135 $this->fd_description=$row['fd_description'];
136 }
$ret label

References $Max, $row, $sql, cn, DatabaseCore\fetch_array(), label, DatabaseCore\num_row(), and return.

+ Here is the call graph for this function:

◆ get_all()

Fiche_Def::get_all ( )

Get all the fiche_def.

Returns
an array of fiche_def object

Definition at line 142 of file fiche_def.class.php.

143 {
144 $sql="select * from fiche_def ";
145
146 $Ret=$this->cn->exec_sql($sql);
147 if ( ($Max=Database::num_row($Ret)) == 0 )
148 return array();
149 $all=array();
150 for ( $i = 0; $i < $Max;$i++)
151 {
153 $all[$i]=new Fiche_Def($this->cn,$row['fd_id']);
154 $all[$i]->label=$row['fd_label'];
155 $all[$i]->class_base=$row['fd_class_base'];
156 $all[$i]->fiche_def=$row['frd_id'];
157 $all[$i]->create_account=$row['fd_create_account'];
158 }
159 return $all;
160 }
define Class fiche and fiche def, those class are using class attribut

References $all, $i, $Max, $row, $sql, cn, DatabaseCore\fetch_array(), and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ get_attr_min()

Fiche_Def::get_attr_min (   $p_fiche_def_ref)

retrieve the mandatory field of the card model

Parameters
$p_fiche_def_ref
Returns
array of ad_id (attr_min.ad_id) and labels (attr_def.ad_text)

Definition at line 748 of file fiche_def.class.php.

749 {
750
751 // find the min attr for the fiche_def_ref
752 $Sql="select ad_id,ad_text ,ad_default_order
753 from attr_min natural join attr_def
754 natural join fiche_def_ref
755 where
756 frd_id= $1 order by ad_default_order";
757 $Res=$this->cn->exec_sql($Sql,array($p_fiche_def_ref));
759
760 // test the number of returned rows
761 if ($Num == 0 ) return null;
762
763 // Get Results & Store them in a array
764 for ($i=0;$i<$Num;$i++)
765 {
767 $array[$i]['ad_id']=$f['ad_id'];
768 $array[$i]['ad_text']=$f['ad_text'];
769 $array[$i]['ad_default_order']=$f['ad_default_order'];
770 }
771 return $array;
772 }

References $array, $f, $i, $Res, cn, DatabaseCore\fetch_array(), and DatabaseCore\num_row().

Referenced by Add().

+ Here is the call graph for this function:

◆ get_by_category()

Fiche_Def::get_by_category (   $p_cat)

Get all the card where the fiche_def.frd_id is given in parameter.

Returns
array of fiche or null is nothing is found

Definition at line 357 of file fiche_def.class.php.

358 {
359 $sql="select f_id,ad_value
360 from
361 fiche join fiche_def using(fd_id)
362 join fiche_detail using(f_id)
363 where ad_id=1 and frd_id=$1 order by 2 ";
364
365 $Ret=$this->cn->exec_sql($sql,array($p_cat));
366 if ( ($Max=Database::num_row($Ret)) == 0 )
367 return null;
368 $all[0]=new Fiche($this->cn);
369
370 for ($i=0;$i<$Max;$i++)
371 {
373 $t=new Fiche($this->cn,$row['f_id']);
374 $t->getAttribut();
375 $all[$i]=$t;
376
377 }
378 return $all;
379 }
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Definition: fiche.class.php:38

References $all, $i, $Max, $row, $sql, cn, DatabaseCore\fetch_array(), and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ get_by_type()

Fiche_Def::get_by_type (   $step = 0)

Get all the card where the fiche_def.fd_id is given in parameter.

Parameters
$step= 0 we don't use the offset, page_size,... $step = 1 we use the jnr_bar_nav
Returns
array ('f_id'=>..,'ad_value'=>..)
See also
fiche

Definition at line 334 of file fiche_def.class.php.

335 {
336 $sql="select f_id,ad_value
337 from
338 fiche join fiche_detail using(f_id)
339 where ad_id=1 and fd_id=$1 order by 2";
340
341 // we use navigation_bar
342 if ($step == 1 && $_SESSION[SESSION_KEY.'g_pagesize'] != -1 )
343 {
344 $offset=(isset($_GET['offset']))?$_GET['offset']:0;
345 $step=$_SESSION[SESSION_KEY.'g_pagesize'];
346 $sql.=" offset $offset limit $step";
347 }
348
349 $Ret=$this->cn->get_array($sql,array($this->id));
350
351 return $Ret;
352 }

References $_GET, $offset, $sql, $step, and cn.

◆ getAttribut()

Fiche_Def::getAttribut ( )

Get attribut of a fiche_def.

Returns
array of Card_Property

Definition at line 80 of file fiche_def.class.php.

81 {
82 $sql="select * from jnt_fic_attr ".
83 " natural join attr_def where fd_id= $1".
84 " order by jnt_order";
85
86 $Ret=$this->cn->exec_sql($sql,[$this->id]);
87
88 if ( ($Max=Database::num_row($Ret)) == 0 )
89 return ;
90 for ($i=0;$i < $Max;$i++)
91 {
93 $t = new Card_Property($this->cn);
94 $t->ad_id=$row['ad_id'];
95 $t->ad_text=$row['ad_text'];
96 $t->av_text="";
97 $t->jnt_order=$row['jnt_order'];
98 $t->ad_size=$row['ad_size'];
99 $t->ad_type=$row['ad_type'];
100 $t->ad_extra=$row['ad_extra'];
101 $this->attribut[$i]=clone $t;
102 }
103 return $this->attribut;
104 }
contains the attributes of a card , manage them, save them , ...

References $attribut, $i, $Max, $row, $sql, cn, DatabaseCore\fetch_array(), DatabaseCore\num_row(), and return.

+ Here is the call graph for this function:

◆ HasAttribute()

Fiche_Def::HasAttribute (   $p_attr)

Check in vw_fiche_def if a fiche has a attribut X.

Parameters
$p_attrattribut to check
Returns
true or false

Definition at line 170 of file fiche_def.class.php.

171 {
172 return ($this->cn->count_sql("select * from vw_fiche_def where ad_id=$p_attr and fd_id=".$this->id)>0)?true:false;
173
174 }

References cn.

◆ input()

Fiche_Def::input ( )

show the content of the form to create a new Fiche_Def_Ref

Definition at line 57 of file fiche_def.class.php.

58 {
59 $ref=$this->cn->get_array("select * from fiche_def_ref order by frd_text");
60 $iradio=new IRadio();
61 /* the accounting item */
62 $class_base=new IPoste('class_base');
63 $class_base->set_attribute('ipopup','ipop_account');
64 $class_base->set_attribute('account','class_base');
65 $class_base->set_attribute('label','acc_label');
66 $f_class_base=$class_base->input();
67 $fd_description=new ITextarea('fd_description');
68 $fd_description->width=80;
69 $fd_description->heigh=4;
70 $fd_description->style='class="itextarea" style="margin-left:0px;vertical-align:text-top"';
71 require_once NOALYSS_TEMPLATE.'/fiche_def_input.php';
72 return;
73 }
$fd_description
Description of the Card Category.
$class_base
fiche_def.fd_class_base
show a button, for selecting a account and a input text for manually inserting an account the differe...
Html Input.
Manage the TEXTAREA html element.

References $class_base, $fd_description, and cn.

Referenced by input_new().

◆ input_base()

Fiche_Def::input_base ( )

show input for the basic attribute : label, class_base, create_account use only when we want to update

Returns
HTML string with the form

Definition at line 465 of file fiche_def.class.php.

466 {
467 $r="";
468 $r.=_('Label');
469 $label=new IText('label',$this->label);
470 $r.=$label->input();
471 $r.='<br>';
472 /* the accounting item */
473 $class_base=new IPoste('class_base',$this->class_base);
474 $class_base->set_attribute('ipopup','ipop_account');
475 $class_base->set_attribute('account','class_base');
476 $class_base->set_attribute('label','acc_label');
477 $fd_description=new ITextarea('fd_description',$this->fd_description);
478 $fd_description->width=80;
479 $fd_description->heigh=4;
480 $fd_description->style='class="itextarea" style="margin-left:0px;vertical-align:text-top"';
481
482 $r.=_('Poste Comptable de base').' : ';
483 $r.=$class_base->input();
484 $r.='<span id="acc_label"></span><br>';
485 $r.='<br/>';
486 $r.=" Description ".$fd_description->input();
487 /* auto Create */
488 $r.='<br/>';
489 $ck=new ICheckBox('create');
490 $ck->selected=($this->create_account=='f')?false:true;
491 $r.=_('Chaque fiche aura automatiquement son propre poste comptable : ');
492 $r.=$ck->input();
493 return $r;
494 }
$label
fiche_def.fd_label
Html Input.

References $ck, $class_base, $fd_description, $label, $r, and label.

Referenced by input_detail().

◆ input_detail()

Fiche_Def::input_detail ( )

Definition at line 783 of file fiche_def.class.php.

784 {
785 $r = "";
786 // Save the label
787
788 $this->get();
789 $this->GetAttribut();
790 $r.= '<H2 class="info">' . $this->id . " " . h($this->label) . '</H2>';
791 $r.='<fieldset><legend>'._('Données générales').'</legend>';
792
793 /* show the values label class_base and create account */
794 $r.='<form method="post">';
795 $r.=dossier::hidden();
796 $r.=HtmlInput::hidden("fd_id", $this->id);
797 $r.=HtmlInput::hidden("p_action", "fiche");
798 $r.= $this->input_base();
799 $r.='<hr>';
800 $r.=HtmlInput::submit('change_name', _('Sauver'));
801 $r.='</form>';
802 $r.='</fieldset>';
803 /* attributes */
804 $r.='<fieldset><legend>'._('Détails').'</legend>';
805
806 $r.= '<FORM id="input_detail_frm" method="POST">';
807 $r.=dossier::hidden();
808 $r.=HtmlInput::hidden("fd_id", $this->id);
809 $r.=HtmlInput::hidden("action", "");
810 $r.= $this->DisplayAttribut("remove");
811 $r.= HtmlInput::submit('add_line_bt', _('Ajoutez cet élément'),
812 'onclick="$(\'action\').value=\'add_line\'"');
813 $r.= HtmlInput::submit("save_line_bt", _("Sauvez"),
814 'onclick="$(\'action\').value=\'save_line\'"');
815
816 $r.=HtmlInput::submit('remove_cat_bt', _('Effacer cette catégorie'), 'onclick="$(\'action\').value=\'remove_cat\';return confirm_box(\'input_detail_frm\',\'' . _('Vous confirmez ?') . '\')"');
817 // if there is nothing to remove then hide the button
818 if (strpos($r, "chk_remove") != 0)
819 {
820 $r.=HtmlInput::submit('remove_line_bt', _("Enleve les éléments cochés"),
821 'onclick="$(\'action\').value=\'remove_line\';return confirm_box(\'input_detail_frm\',\'' . _('Vous confirmez ?') . '\')"');
822 }
823 $r.= "</form>";
824 $r.=" <p class=\"notice\"> " . _("Attention : il n'y aura pas de demande de confirmation pour enlever les
825 attributs sélectionnés. Il ne sera pas possible de revenir en arrière") . "</p>";
826 $r.='</fieldset>';
827 return $r;
828 }
p($p_string)
Definition: ac_common.php:39
h( $row[ 'oa_description'])
DisplayAttribut($str="")
Display all the attribut of the fiche_def.
input_base()
show input for the basic attribute : label, class_base, create_account use only when we want to updat...
static hidden($p_name, $p_value, $p_id="")
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")

References $r, DisplayAttribut(), h, HtmlInput\hidden(), input_base(), label, p(), and HtmlInput\submit().

+ Here is the call graph for this function:

◆ input_new()

Fiche_Def::input_new ( )

Definition at line 829 of file fiche_def.class.php.

830 {
831 $single=new Single_Record("dup");
832 echo '<form method="post" style="display:inline">';
833 echo $single->hidden();
834 echo HtmlInput::hidden("p_action","fiche");
835 echo dossier::hidden();
836 echo $this->input(); // CreateCategory($cn,$search);
837 echo HtmlInput::submit("add_modele" ,_("Sauve"));
838 echo '</FORM>';
839 }
input()
show the content of the form to create a new Fiche_Def_Ref
Objec to check a double insert into the database, this duplicate occurs after a refresh of the web pa...

References HtmlInput\hidden(), input(), and HtmlInput\submit().

+ Here is the call graph for this function:

◆ insertAttribut()

Fiche_Def::insertAttribut (   $p_ad_id,
  $p_order = -1 
)

insert a new attribut for this fiche_def

Parameters
$p_ad_idid of the attribut
int$p_orderorder of the attribut if -1 then computed

Definition at line 635 of file fiche_def.class.php.

636 {
637 if ( $this->id == 0 ) return;
638 /* ORDER */
639 $this->GetAttribut();
641 if ( $p_order == -1 ) {
642 $order = $this->cn->get_value("select ad_default_order from attr_def where ad_id=$1",[$p_ad_id]);
643 if ( $order == 0 || empty($order)) {
644 $max=$this->cn->get_value("select count(*) from jnt_fic_attr where fd_id=$1",[$this->id]);
645 $order=$max*15;
646 }
647 }
648 // Insert a new attribute for the model
649 // it means insert a row in jnt_fic_attr
650 $sql=sprintf("insert into jnt_fic_attr (fd_id,ad_id,jnt_order) values (%d,%d,%d)",
651 $this->id,$p_ad_id,$order);
652 $Res=$this->cn->exec_sql($sql);
653 }

References $max, $order, $p_order, $Res, $sql, and cn.

◆ load()

Fiche_Def::load ( )

alias for Fiche_Def->get(),

Returns
void

Definition at line 110 of file fiche_def.class.php.

110 :void
111 {
112 $this->get();
113 }

◆ myList()

Fiche_Def::myList ( )

list the card of a fd_id

Definition at line 383 of file fiche_def.class.php.

384 {
385 $this->get();
386 echo '<H2 class="info">'.$this->id." ".$this->label.'</H2>';
387
388 $step=$_SESSION[SESSION_KEY.'g_pagesize'];
389 $sql_limit="";
390 $sql_offset="";
391 $bar="";
392 if ( $step != -1 )
393 {
394
395 $page=(isset($_GET['page']))?$_GET['page']:1;
396 $offset=(isset($_GET['offset']))?$_GET['offset']:0;
397 $max_line=$this->cn->count_sql("select f_id,ad_value from
398 fiche join fiche_detail using (f_id)
399 where fd_id='".$this->id."' and ad_id=".ATTR_DEF_NAME." order by f_id");
400 $sql_limit=" limit ".$step;
401 $sql_offset=" offset ".$offset;
403 }
404
405 // Get all name the cards of the select category
406 // 1 for attr_def.ad_id is always the name
407 $Res=$this->cn->exec_sql("select f_id,vw_name,quick_code from ".
408 " vw_fiche_attr ".
409 " where fd_id='".$this->id.
410 "' order by f_id $sql_offset $sql_limit ");
412 echo $bar;
413 $str="";
414 // save the url
415 // with offet &offset=15&step=15&page=2&size=15
416 if ( $_SESSION[SESSION_KEY.'g_pagesize'] != -1)
417 {
418 $str=sprintf("&offset=%s&step=%s&page=%s&size=%s",
419 $offset,
420 $step,
421 $page,
422 $max_line);
423 }
424
425
426 echo '<FORM METHOD="POST" action="?p_action=fiche&action=vue'.$str.'">';
427 echo HtmlInput::hidden('ac',$_REQUEST['ac']);
428 echo dossier::hidden();
429 echo HtmlInput::hidden("fiche",$this->id);
430 echo HtmlInput::submit('add','Ajout fiche');
431 echo '</FORM>';
432 $str_dossier=dossier::get();
433 echo '<table>';
434 for ( $i = 0; $i < $Max; $i++)
435 {
437 if ( $i%2 == 0)
438 echo '<TR class="odd">';
439 else
440 echo '<TR class="even">';
441
442 $span_mod='<TD><A href="?p_action=fiche&'.$str_dossier.
443 '&action=detail&fiche_id='.$l_line['f_id'].$str.'&fiche='.
444 $_REQUEST['fiche'].'&ac='.$_REQUEST['ac'].'">'.$l_line['quick_code']
445 .'</A></TD>';
446
447 echo $span_mod.'<TD>'.h($l_line['vw_name'])."</TD>";
448 echo '</tr>';
449 }
450 echo '</table>';
451 echo '<FORM METHOD="POST" action="?p_action=fiche&action=vue'.$str.'">';
452 echo HtmlInput::hidden('ac',$_REQUEST['ac']);
453 echo dossier::hidden();
454 echo HtmlInput::hidden("fiche",$this->id);
455 echo HtmlInput::submit('add','Ajout fiche');
456 echo '</FORM>';
457 echo $bar;
458
459 }
$_REQUEST['ac']
$str_dossier
Definition: anc_od.inc.php:33
navigation_bar($p_offset, $p_line, $p_size=0, $p_page=1, $p_javascript="")
Create a navigation_bar (pagesize)
Definition: user_common.php:76

References $_GET, $_REQUEST, $bar, $i, $Max, $max_line, $offset, $page, $Res, $step, $str, $str_dossier, ATTR_DEF_NAME, cn, DatabaseCore\fetch_array(), h, HtmlInput\hidden(), label, navigation_bar(), DatabaseCore\num_row(), and HtmlInput\submit().

+ Here is the call graph for this function:

◆ remove()

Fiche_Def::remove ( )

remove all the card from a categorie after having verify that the card is not used and then remove also the category

Returns
the remains items, not equal to 0 if a card remains and then the category is not removed

Definition at line 706 of file fiche_def.class.php.

707 {
708 if ( $this->id >= 500000 ) {
709 throw new Exception(_('Catégorie verrouillée '));
710 }
711 $remain=0;
712 /* get all the card */
713 $aFiche=fiche::get_fiche_def($this->cn,$this->id);
714 if ( $aFiche != null )
715 {
716 /* check if the card is used */
717 foreach ($aFiche as $dfiche)
718 {
719 $fiche=new Fiche($this->cn,$dfiche['f_id']);
720
721 /* if the card is not used then remove it otherwise increment remains */
722 if ( $fiche->is_used() == false )
723 {
724 $fiche->delete();
725 }
726 else
727 $remain++;
728 }
729 }
730 /* if remains == 0 then remove cat */
731 if ( $remain == 0 )
732 {
733 $sql='delete from jnt_fic_attr where fd_id=$1';
734 $this->cn->exec_sql($sql,array($this->id));
735 $sql='delete from fiche_def where fd_id=$1';
736 $this->cn->exec_sql($sql,array($this->id));
737 }
738
739 return $remain;
740
741 }

References $fiche, $sql, and cn.

◆ removeAttribut()

Fiche_Def::removeAttribut (   $array)

remove an attribut for this fiche_def

Parameters
arrayof ad_id to remove
Remarks
you can't remove the attribut defined in attr_min

Definition at line 658 of file fiche_def.class.php.

659 {
660 foreach ($array as $ch)
661 {
662 $this->cn->start();
663 $sql="delete from jnt_fic_attr where fd_id=$1 ".
664 " and ad_id=$2";
665 $this->cn->exec_sql($sql,array($this->id,$ch));
666
667 $sql="delete from fiche_detail where jft_id in ( select ".
668 " jft_id from fiche_Detail ".
669 " join fiche using(f_id) ".
670 " where ".
671 "fd_id = $1 and ".
672 "ad_id=$2)";
673 $this->cn->exec_sql($sql,array($this->id,$ch));
674
675 $this->cn->commit();
676 }
677 }

References $array, $sql, and cn.

◆ save_class_base()

Fiche_Def::save_class_base (   $p_label)

Save the class base.

Parameters
$p_labellabel

Definition at line 614 of file fiche_def.class.php.

615 {
616 if ( $this->id == 0 ) return;
617 $p_label=sql_string($p_label);
618
619 $sql="update fiche_def set fd_class_base=$1 ".
620 "where fd_id=$2";
621
622 $Res=$this->cn->exec_sql($sql,array($p_label,$this->id));
623 }

References $Res, $sql, cn, and sql_string().

+ Here is the call graph for this function:

◆ save_description()

Fiche_Def::save_description (   $p_description)

Definition at line 624 of file fiche_def.class.php.

625 {
626 if ( $this->id == 0) return;
627 $this->cn->exec_sql("update fiche_def set fd_description=$1 where fd_id=$2",array($p_description,$this->id));
628 }

References cn.

◆ save_order()

Fiche_Def::save_order (   $p_array)

save the order of a card, update the column jnt_fic_attr.jnt_order

Parameters
$p_arraycontaining the order

Definition at line 682 of file fiche_def.class.php.

683 {
684 extract($p_array, EXTR_SKIP);
685 $this->GetAttribut();
686 foreach ($this->attribut as $row)
687 {
688 if ( $row->ad_id == 1 ) continue;
689 if ( ${'jnt_order'.$row->ad_id} <= 0 ) continue;
690 $sql='update jnt_fic_attr set jnt_order=$1 where fd_id=$2 and ad_id=$3';
691 $this->cn->exec_sql($sql,array(${'jnt_order'.$row->ad_id},
692 $this->id,
693 $row->ad_id));
694
695 }
696 /* correct the order */
697 $this->cn->exec_sql('select attribute_correct_order()');
698 }
$id
id (fiche_def.fd_id

References $id, $p_array, $row, $sql, and cn.

◆ SaveLabel()

Fiche_Def::SaveLabel (   $p_label)

Save the label of the fiche_def.

Parameters
$p_labellabel

Definition at line 579 of file fiche_def.class.php.

580 {
581 if ( $this->id == 0 ) return;
582 $p_label=sql_string($p_label);
583 if (strlen(trim ($p_label)) == 0 )
584 {
585 return;
586 }
587 $sql=sprintf("update fiche_def set fd_label='%s' ".
588 "where fd_id=%d",
589 $p_label,$this->id);
590 $Res=$this->cn->exec_sql($sql);
591
592 }

References $Res, $sql, cn, and sql_string().

+ Here is the call graph for this function:

◆ set_autocreate()

Fiche_Def::set_autocreate (   $p_label)

set the auto create accounting item for each card and save it into the database

Parameters
$p_labeltrue or false

Definition at line 597 of file fiche_def.class.php.

598 {
599 if ( $this->id == 0 ) return;
600 if ($p_label==true)
601 $t='t';
602 if ($p_label==false)
603 $t='f';
604
605 $sql="update fiche_def set fd_create_account=$1 ".
606 "where fd_id=$2";
607
608 $Res=$this->cn->exec_sql($sql,array($t,$this->id));
609
610 }

References $Res, $sql, and cn.

◆ to_array()

Fiche_Def::to_array ( )

make an array of attributes of the category of card (FICHE_DEF.FD_ID) The array can be used with the function insert, it will return a struct like this : in the first key (av_textX), X is the ATTR_DEF::AD_ID

Example
Array
(
  [av_text1] => Nom
  [av_text12] => Personne de contact
  [av_text5] => Poste Comptable
  [av_text13] => numéro de tva
  [av_text14] => Adresse
  [av_text15] => code postal
  [av_text24] => Ville
  [av_text16] => pays
  [av_text17] => téléphone
  [av_text18] => email
  [av_text23] => Quick Code
)
Parameters
$pfd_idFICHE_DEF::FD_ID
Returns
an array of attribute
Exceptions
Exceptionif the cat of card doesn't exist, Exception.getCode()=1
See also
fiche::insert()

Definition at line 867 of file fiche_def.class.php.

868 {
869 $sql="select 'av_text'||to_char(ad_id,'9999') as key,".
870 " ad_text ".
871 " from fiche_def join jnt_fic_attr using (fd_id)".
872 " join attr_def using (ad_id) ".
873 " where fd_id=$1 order by jnt_order";
874 $ret=$this->cn->get_array($sql,array($this->id));
875 if ( empty($ret)) throw new Exception(_('Cette categorie de card n\'existe pas').' '.$this->id,1);
876 $array=array();
877 foreach($ret as $idx=>$val)
878 {
879 $a=noalyss_str_replace(' ','',$val['key']);
880 $array[$a]=$val['ad_text'];
881 }
882 return $array;
883
884 }
noalyss_str_replace($search, $replace, $string)
Definition: ac_common.php:1553
$idx

References $a, $array, $idx, $ret, $sql, $val, cn, and noalyss_str_replace().

+ Here is the call graph for this function:

Field Documentation

◆ $all

Fiche_Def::$all

Definition at line 38 of file fiche_def.class.php.

Referenced by get_all(), and get_by_category().

◆ $attribut

Fiche_Def::$attribut

get from attr_xxx tables

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

Referenced by DisplayAttribut(), and getAttribut().

◆ $class_base

Fiche_Def::$class_base

fiche_def.fd_class_base

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

Referenced by input(), and input_base().

◆ $cn

Fiche_Def::$cn

database connection

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

◆ $create_account

Fiche_Def::$create_account

fd_create_account: flag

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

◆ $fd_description

Fiche_Def::$fd_description

Description of the Card Category.

Definition at line 40 of file fiche_def.class.php.

Referenced by input(), and input_base().

◆ $fiche_def

Fiche_Def::$fiche_def

fiche_def.frd_id = fiche_def_ref.frd_id

Definition at line 36 of file fiche_def.class.php.

◆ $id

Fiche_Def::$id

id (fiche_def.fd_id

Definition at line 33 of file fiche_def.class.php.

Referenced by save_order().

◆ $label

Fiche_Def::$label

fiche_def.fd_label

Definition at line 34 of file fiche_def.class.php.

Referenced by input_base().


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