noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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.
 
 count_category ($p_frd_id)
 count the number of fiche_def (category) which has the frd_id (type of category)
 
 display ()
 Display all card categories into a table.
 
 DisplayAttribut ($str="")
 Display all the attribut of the fiche_def.
 
 get ()
 Get attribut of the fiche_def.
 
 get_all ()
 Get all the fiche_def.
 
 get_attr_min ($p_fiche_def_ref)
 retrieve the mandatory field of the card model
 
 get_by_category ($p_cat)
 Get all the card where the fiche_def.frd_id is given in parameter.
 
 get_by_type ($step=0)
 Get all the card where the fiche_def.fd_id is given in parameter.
 
 getAttribut ()
 Get attribut of a fiche_def.
 
 HasAttribute ($p_attr)
 Check in vw_fiche_def if a fiche has a attribut X.
 
 input ()
 show the content of the form to create a new Fiche_Def_Ref
 
 input_detail ()
 ask for detail
 
 input_new ()
 input for creating a new category
 
 insertAttribut ($p_ad_id, $p_order=-1)
 insert a new attribut for this fiche_def
 
 load ()
 alias for Fiche_Def->get(),
 
 myList ()
 list the card of a fd_id
 
 remove ()
 remove all the card from a categorie after having verify that the card is not used and then remove also the category
 
 removeAttribut ($array)
 remove an attribut for this fiche_def
 
 save_class_base ($p_label)
 Save the class base.
 
 save_description ($p_description)
 
 save_order ($p_array)
 save the order of a card, update the column jnt_fic_attr.jnt_order
 
 SaveLabel ($p_label)
 Save the label of the fiche_def.
 
 set_autocreate ($p_label)
 set the auto create accounting item for each card and save it into the database
 
 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
 

Static Public Member Functions

static print_available_attribut ($attribut_id, $attribut_text, $class)
 display available attribut
 
static print_existing_attribut ($attribut_id, $attribut_text)
 display existing attribut
 

Data Fields

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

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

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 202 of file fiche_def.class.php.

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

References $array, $count, $fd_id, $http, $Res, $row, $sql, _, alert(), ATTR_DEF_ACCOUNT, ATTR_DEF_QUICKCODE, cn, get_attr_min(), noalyss_strlentrim(), noalyss_trim(), 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 757 of file fiche_def.class.php.

758 {
759 $ret=$this->cn->count_sql("select fd_id from fiche_def where frd_id=$1",array($p_frd_id));
760 return $ret;
761 }

References $ret, and cn.

◆ display()

Fiche_Def::display ( )

Display all card categories into a table.

Returns
HTML row

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

170 {
171 $tab = new Sort_Table();
172
173 $url = HtmlInput::get_to_string(array('ac', 'gDossier'));
174 $tab->add(_("Nom de fiche"), $url, "order by fd_label asc", "order by fd_label desc", "na", "nd");
175 $tab->add(_("Basé sur le poste comptable"), $url, "order by fd_class_base asc", "order by fd_class_base desc", "pa", "pd");
176 $tab->add(_("Calcul automatique du poste comptable"), $url, "order by fd_create_account asc", "order by fd_create_account desc", "ca", "cd");
177 $tab->add(_("Basé sur le modèle"), $url, "order by frd_text asc", "order by frd_text desc", "ma", "md");
178
179 $order = (isset($_GET['ord'])) ? $tab->get_sql_order($_GET["ord"]) : $tab->get_sql_order("na");
180
181
182 $res = $this->cn->exec_sql("SELECT fd_id, fd_class_base, fd_label, fd_create_account, fiche_def_ref.frd_id,
183frd_text , fd_description FROM fiche_def join fiche_def_ref on (fiche_def.frd_id=fiche_def_ref.frd_id)
184$order
185");
186
187 require_once NOALYSS_TEMPLATE.'/fiche_def-display.php';
188 }
$_GET['qcode']
static get_to_string($array, $start="?")
transform $_GET data to string

References $_GET, $order, $res, $tab, $url, _, and cn.

◆ 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 474 of file fiche_def.class.php.

475 {
476 if ( $this->id == 0 )
477 return ;
478 $this->cn->exec_sql('select fiche_attribut_synchro($1)',array($this->id));
479
480 $MaxLine=sizeof($this->attribut);
481 $r="<TABLE>";
482 $r.="<tr>".th('Nom attribut').th('').th('Ordre','style="text-align:right"').'</tr>';
483 // Display each attribute
484 $add_action="";
485 for ($i=0;$i<$MaxLine;$i++)
486 {
487 $class="even";
488 if ( $i % 2 == 0 )
489 $class="odd";
490
491 $r.='<TR class="'.$class.'"><td>';
492 // Can change the name
493 if ( $this->attribut[$i]->ad_id == ATTR_DEF_NAME )
494 {
495 continue;
496 }
497 else
498 {
499 if ( $str == "remove" )
500 {
501 //Only for the not mandatory attribute (not defined in attr_min)
502 if ( $this->cn->count_sql("select * from attr_min where frd_id=".
503 $this->fiche_def." and ad_id = ".$this->attribut[$i]->ad_id) == 0
504 && $this->attribut[$i]->ad_id != ATTR_DEF_QUICKCODE
505 && $this->attribut[$i]->ad_id != ATTR_DEF_ACCOUNT
506 )
507 {
508 $add_action=sprintf( '</TD><TD> Supprimer <input type="checkbox" name="chk_remove[]" value="%d">',
509 $this->attribut[$i]->ad_id);
510 }
511 else
512 $add_action="</td><td>";
513 }
514 // The attribut.
515 $a=sprintf('%s ', $this->attribut[$i]->ad_text);
516 $r.=$a.$add_action;
517 /*---------------------------------------- */
518 /* ORDER OF THE CARD */
519 /*---------------------------------------- */
520 $order=new IText();
521 $order->name='jnt_order'.$this->attribut[$i]->ad_id;
522 $order->size=3;
523 $order->value=$this->attribut[$i]->jnt_order;
524 $r.='</td><td> '.$order->input();
525 }
526 $r.= '</td></tr>';
527 }
528
529 // Show the possible attribute which are not already attribute of the model
530 // of card
531 $Res=$this->cn->exec_sql("select ad_id,ad_text from attr_def
532 where
533 ad_id not in (select ad_id from fiche_def natural join jnt_fic_attr
534 where fd_id=$1) order by ad_text",array($this->id) );
536
537 // Show the unused attribute
538 $r.='<TR> <TD>';
539 $r.= '<SELECT NAME="ad_id">';
540 for ($i=0;$i<$M;$i++)
541 {
543 $a=sprintf('<OPTION VALUE="%s"> %s',
544 $l['ad_id'],$l['ad_text']);
545 $r.=$a;
546 }
547 $r.='</SELECT>';
548
549 $r.="</TABLE>";
550 return $r;
551 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
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
const ATTR_DEF_NAME
Definition constant.php:216
$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.

+ Here is the call graph for this function:

◆ get()

Fiche_Def::get ( )

Get attribut of the fiche_def.

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

107 {
108 if ( $this->id == 0 )
109 return 0;
110 /* $this->cn->exec_sql('select fiche_attribut_synchro($1)',
111 array($this->id));
112 */
113 $sql="select * from fiche_def ".
114 " where fd_id= $1";
115 $Ret=$this->cn->exec_sql($sql,[$this->id]);
116 if ( ($Max=Database::num_row($Ret)) == 0 )
117 return ;
119 $this->label=$row['fd_label'];
120 $this->class_base=$row['fd_class_base'];
121 $this->fiche_def=$row['frd_id'];
122 $this->create_account=($row['fd_create_account']=='f')?false:true;
123 $this->fd_description=$row['fd_description'];
124 }
$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 130 of file fiche_def.class.php.

131 {
132 $sql="select * from fiche_def ";
133
134 $Ret=$this->cn->exec_sql($sql);
135 if ( ($Max=Database::num_row($Ret)) == 0 )
136 return array();
137 $all=array();
138 for ( $i = 0; $i < $Max;$i++)
139 {
141 $all[$i]=new Fiche_Def($this->cn,$row['fd_id']);
142 $all[$i]->label=$row['fd_label'];
143 $all[$i]->class_base=$row['fd_class_base'];
144 $all[$i]->fiche_def=$row['frd_id'];
145 $all[$i]->create_account=$row['fd_create_account'];
146 }
147 return $all;
148 }

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 725 of file fiche_def.class.php.

726 {
727
728 // find the min attr for the fiche_def_ref
729 $Sql="select ad_id,ad_text ,attr_min.ad_default_order
730 from attr_min
731 join attr_def using(ad_id)
732 join fiche_def_ref using(frd_id)
733 where
734 frd_id= $1 order by ad_default_order";
735 $Res=$this->cn->exec_sql($Sql,array($p_fiche_def_ref));
737
738 // test the number of returned rows
739 if ($Num == 0 ) return null;
740
741 // Get Results & Store them in a array
742 for ($i=0;$i<$Num;$i++)
743 {
745 $array[$i]['ad_id']=$f['ad_id'];
746 $array[$i]['ad_text']=$f['ad_text'];
747 $array[$i]['ad_default_order']=$f['ad_default_order'];
748 }
749 return $array;
750 }

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 367 of file fiche_def.class.php.

368 {
369 $sql="select f_id,ad_value
370 from
371 fiche join fiche_def using(fd_id)
372 join fiche_detail using(f_id)
373 where ad_id=1 and frd_id=$1 order by 2 ";
374
375 $Ret=$this->cn->exec_sql($sql,array($p_cat));
376 if ( ($Max=Database::num_row($Ret)) == 0 )
377 return null;
378 $all[0]=new Fiche($this->cn);
379
380 for ($i=0;$i<$Max;$i++)
381 {
383 $t=new Fiche($this->cn,$row['f_id']);
384 $t->getAttribut();
385 $all[$i]=$t;
386
387 }
388 return $all;
389 }
$t
Definition compute.php:46

References $all, $i, $Max, $row, $sql, $t, 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 344 of file fiche_def.class.php.

345 {
346 $sql="select f_id,ad_value
347 from
348 fiche join fiche_detail using(f_id)
349 where ad_id=1 and fd_id=$1 order by 2";
350
351 // we use navigation_bar
352 if ($step == 1 && $_SESSION[SESSION_KEY.'g_pagesize'] != -1 )
353 {
354 $offset=(isset($_GET['offset']))?$_GET['offset']:0;
355 $step=$_SESSION[SESSION_KEY.'g_pagesize'];
356 $sql.=" offset $offset limit $step";
357 }
358
359 $Ret=$this->cn->get_array($sql,array($this->id));
360
361 return $Ret;
362 }

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 68 of file fiche_def.class.php.

69 {
70 $sql="select * from jnt_fic_attr ".
71 " natural join attr_def where fd_id= $1".
72 " order by jnt_order";
73
74 $Ret=$this->cn->exec_sql($sql,[$this->id]);
75
76 if ( ($Max=Database::num_row($Ret)) == 0 )
77 return ;
78 for ($i=0;$i < $Max;$i++)
79 {
81 $t = new Card_Property($this->cn);
82 $t->ad_id=$row['ad_id'];
83 $t->ad_text=$row['ad_text'];
84 $t->av_text="";
85 $t->jnt_order=$row['jnt_order'];
86 $t->ad_size=$row['ad_size'];
87 $t->ad_type=$row['ad_type'];
88 $t->ad_extra=$row['ad_extra'];
89 $this->attribut[$i]=clone $t;
90 }
91 return $this->attribut;
92 }

References $attribut, $i, $Max, $row, $sql, $t, 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 158 of file fiche_def.class.php.

159 {
160 return ($this->cn->count_sql("select * from vw_fiche_def where ad_id=$p_attr and fd_id=".$this->id)>0)?true:false;
161
162 }

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
60 return;
61 }

◆ input_detail()

Fiche_Def::input_detail ( )

ask for detail

Returns
string

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

768 {
769 $r = "";
770 // Save the label
771
772 $this->get();
773 $this->GetAttribut();
774 $r.= '<H2 class="info">' . $this->id . " " . h($this->label) . '</H2>';
775 $r.='<fieldset><legend>'._('Données générales').'</legend>';
776
777 $nom_mod=$this->label;
778 /* the accounting item */
779 $class_base=new IPoste('class_base');
780 $class_base->set_attribute('ipopup','ipop_account');
781 $class_base->set_attribute('account','class_base');
782 $class_base->set_attribute('label','acc_label');
784 $f_class_base=$class_base->input();
785 $fd_description=new ITextarea('fd_description');
786 $fd_description->width=80;
787 $fd_description->heigh=4;
788 $fd_description->style='class="itextarea form-control input_text" style="margin-left:0px;vertical-align:text-top"';
790 $r.='<form method="post" style="display:inline">';
791 $r.=\HtmlInput::hidden('fd_id',$this->id);
792 ob_start();
793 require_once NOALYSS_TEMPLATE.'/fiche_def_input.php';
794 $r.=ob_get_contents();
795 ob_clean();
796 $r.=HtmlInput::submit('change_name', _('Sauver'));
797 $r.='</form>';
798 $r.='<form method="post" style="display:inline" id="catcard_remove" onsubmit="return confirm_box(this,\'Effacer?\')">';
799 $r.=HtmlInput::hidden("action", "remove_cat");
800 $r.=HtmlInput::hidden('fd_id',$this->id);
801 $r.=HtmlInput::submit('remove_cat', _('Effacer'));
802 $r.='</form>';
803
804 require NOALYSS_TEMPLATE.'/fiche_def-input_detail.php';
805
806 $r.='</fieldset>';
807 $r.='<hr>';
808 /* attributes */
809 $r.='<fieldset><legend>'._('Détails').'</legend>';
810
811 $r.= '<FORM id="input_detail_frm" method="POST">';
812 $r.=dossier::hidden();
813 $r.=HtmlInput::hidden("fd_id", $this->id);
814 $r.=HtmlInput::hidden("action", "");
815 // $r.= $this->DisplayAttribut("remove");
816 ob_start();
817 require NOALYSS_TEMPLATE."/fiche_def-input_detail-2.php";
818 $r.=ob_get_contents();
819 ob_clean();
820
821 $r.= "</form>";
822
823 $r.='</fieldset>';
824 return $r;
825 }
h( $row[ 'oa_description'])
$fd_description
Description of the Card Category.
$class_base
fiche_def.fd_class_base
$label
fiche_def.fd_label
static hidden($p_name, $p_value, $p_id="")
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")

References $class_base, $fd_description, $label, $r, _, h, and label.

◆ input_new()

Fiche_Def::input_new ( )

input for creating a new category

Returns
void

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

833 {
834 $single=new Single_Record("dup");
835 echo '<form method="post" style="display:inline" onsubmit="return check_new_category()">';
836 echo $single->hidden();
837 echo HtmlInput::hidden("p_action","fiche");
838 echo dossier::hidden();
839 $ref=$this->cn->get_array("select * from fiche_def_ref order by frd_text");
840 $iradio=new IRadio();
841 $nom_mod="";
842 /* the accounting item */
843 $class_base=new IPoste('class_base');
844 $class_base->set_attribute('ipopup','ipop_account');
845 $class_base->set_attribute('account','class_base');
846 $class_base->set_attribute('label','acc_label');
847 $f_class_base=$class_base->input();
848 $fd_description=new ITextarea('fd_description');
849 $fd_description->width=80;
850 $fd_description->heigh=4;
851 $fd_description->style='class="itextarea form-control input_text" style="margin-left:0px;vertical-align:text-top"';
852 require_once NOALYSS_TEMPLATE.'/fiche_def_input.php';
853 require_once NOALYSS_TEMPLATE.'/fiche_def-input_new.php';
854
855 echo HtmlInput::submit("add_modele" ,_("Sauve"));
856 echo '</FORM>';
857 }

References $class_base, $fd_description, _, and cn.

◆ 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 612 of file fiche_def.class.php.

613 {
614 if ( $this->id == 0 ) return;
615 /* ORDER */
616 $this->GetAttribut();
618 if ( $p_order == -1 ) {
619 $order = $this->cn->get_value("select ad_default_order from attr_def where ad_id=$1",[$p_ad_id]);
620 if ( $order == 0 || empty($order)) {
621 $max=$this->cn->get_value("select count(*) from jnt_fic_attr where fd_id=$1",[$this->id]);
622 $order=$max*15;
623 }
624 }
625 // Insert a new attribute for the model
626 // it means insert a row in jnt_fic_attr
627 $sql=sprintf("insert into jnt_fic_attr (fd_id,ad_id,jnt_order) values (%d,%d,%d)",
628 $this->id,$p_ad_id,$order);
629 $Res=$this->cn->exec_sql($sql);
630 }

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

◆ load()

Fiche_Def::load ( )

alias for Fiche_Def->get(),

Returns
void

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

98 :void
99 {
100 $this->get();
101 }

◆ myList()

Fiche_Def::myList ( )

list the card of a fd_id

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

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

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

+ Here is the call graph for this function:

◆ print_available_attribut()

static Fiche_Def::print_available_attribut ( $attribut_id,
$attribut_text,
$class )
static

display available attribut

Parameters
$attribut_idint SQL attr_def.ad_id
$attribut_textSQL attr_def.ad_text
Returns
void

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

922 {
923 include NOALYSS_TEMPLATE.'/fiche_def-print_available_attribut.php';
924 }

References $class.

◆ print_existing_attribut()

static Fiche_Def::print_existing_attribut ( $attribut_id,
$attribut_text )
static

display existing attribut

Parameters
$attribut_idint SQL attr_def.ad_id
$attribut_textSQL attr_def.ad_text
Returns
void

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

911 {
912 include NOALYSS_TEMPLATE.'/fiche_def-print_existing_attribut.php';
913 }

◆ 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 683 of file fiche_def.class.php.

684 {
685 if ( $this->id >= 500000 ) {
686 throw new Exception(_('Catégorie verrouillée '));
687 }
688 $remain=0;
689 /* get all the card */
690 $aFiche=fiche::get_fiche_def($this->cn,$this->id);
691 if ( $aFiche != null )
692 {
693 /* check if the card is used */
694 foreach ($aFiche as $dfiche)
695 {
696 $fiche=new Fiche($this->cn,$dfiche['f_id']);
697
698 /* if the card is not used then remove it otherwise increment remains */
699 if ( $fiche->is_used() == false )
700 {
701 $fiche->delete();
702 }
703 else
704 $remain++;
705 }
706 }
707 /* if remains == 0 then remove cat */
708 if ( $remain == 0 )
709 {
710 $sql='delete from jnt_fic_attr where fd_id=$1';
711 $this->cn->exec_sql($sql,array($this->id));
712 $sql='delete from fiche_def where fd_id=$1';
713 $this->cn->exec_sql($sql,array($this->id));
714 }
715
716 return $remain;
717
718 }

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 635 of file fiche_def.class.php.

636 {
637 foreach ($array as $ch)
638 {
639 $this->cn->start();
640 $sql="delete from jnt_fic_attr where fd_id=$1 ".
641 " and ad_id=$2";
642 $this->cn->exec_sql($sql,array($this->id,$ch));
643
644 $sql="delete from fiche_detail where jft_id in ( select ".
645 " jft_id from fiche_Detail ".
646 " join fiche using(f_id) ".
647 " where ".
648 "fd_id = $1 and ".
649 "ad_id=$2)";
650 $this->cn->exec_sql($sql,array($this->id,$ch));
651
652 $this->cn->commit();
653 }
654 }

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 591 of file fiche_def.class.php.

592 {
593 if ( $this->id == 0 ) return;
594 $p_label=sql_string($p_label);
595
596 $sql="update fiche_def set fd_class_base=$1 ".
597 "where fd_id=$2";
598
599 $Res=$this->cn->exec_sql($sql,array($p_label,$this->id));
600 }

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 601 of file fiche_def.class.php.

602 {
603 if ( $this->id == 0) return;
604 $this->cn->exec_sql("update fiche_def set fd_description=$1 where fd_id=$2",array($p_description,$this->id));
605 }

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 659 of file fiche_def.class.php.

660 {
661 extract($p_array, EXTR_SKIP);
662 $this->GetAttribut();
663 foreach ($this->attribut as $row)
664 {
665 if ( $row->ad_id == 1 ) continue;
666 if ( ${'jnt_order'.$row->ad_id} <= 0 ) continue;
667 $sql='update jnt_fic_attr set jnt_order=$1 where fd_id=$2 and ad_id=$3';
668 $this->cn->exec_sql($sql,array(${'jnt_order'.$row->ad_id},
669 $this->id,
670 $row->ad_id));
671
672 }
673 /* correct the order */
674 $this->cn->exec_sql('select attribute_correct_order()');
675 }
$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 555 of file fiche_def.class.php.

556 {
557 if ( $this->id == 0 ) return;
558 $p_label=sql_string($p_label);
559 if (strlen(trim ($p_label)) == 0 )
560 {
561 return;
562 }
563 $sql=sprintf("update fiche_def set fd_label='%s' ".
564 "where fd_id=%d",
565 $p_label,$this->id);
566 $Res=$this->cn->exec_sql($sql);
567
568 }

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 573 of file fiche_def.class.php.

574 {
575 if ( $this->id == 0 ) return;
576 if ($p_label==true)
577 $t='t';
578 if ($p_label==false)
579 $t='f';
580
581 $sql="update fiche_def set fd_create_account=$1 ".
582 "where fd_id=$2";
583
584 $Res=$this->cn->exec_sql($sql,array($t,$this->id));
585
586
587 }

References $Res, $sql, $t, 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 885 of file fiche_def.class.php.

886 {
887 $sql="select 'av_text'||to_char(ad_id,'9999') as key,".
888 " ad_text ".
889 " from fiche_def join jnt_fic_attr using (fd_id)".
890 " join attr_def using (ad_id) ".
891 " where fd_id=$1 order by jnt_order";
892 $ret=$this->cn->get_array($sql,array($this->id));
893 if ( empty($ret)) throw new Exception(_('Cette categorie de card n\'existe pas').' '.$this->id,1);
894 $array=array();
895 foreach($ret as $idx=>$val)
896 {
897 $a=noalyss_str_replace(' ','',$val['key']);
898 $array[$a]=$val['ad_text'];
899 }
900 return $array;
901
902 }
noalyss_str_replace($search, $replace, $string)

References $a, $array, $idx, $ret, $sql, _, 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_detail(), and input_new().

◆ $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_detail(), and input_new().

◆ $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_detail().


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