noalyss Version-10
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 ($cn, $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 ($template_category, $inactive=1)
 Get all the card where the fiche_def.frd_id is given in parameter, it is the template for category.
 
 get_by_type ($step=0, $inactive=1)
 Get all the card where the fiche_def.fd_id is given in parameter.
 
 getAttribut ()
 replace by load_attribute
 
 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(),
 
 load_attribute ()
 Get attribute of a fiche_def.
 
 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 ( $cn,
$id = 0 )

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

43 {
44 $this->cn=$cn;
45 $this->id=$id;
46
47
48 }
$input_from cn
$id
id (fiche_def.fd_id
$cn
database connection

References $cn, $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 209 of file fiche_def.class.php.

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

773 {
774 $ret=$this->cn->count_sql("select fd_id from fiche_def where frd_id=$1",array($p_frd_id));
775 return $ret;
776 }

References $ret, and cn.

◆ display()

Fiche_Def::display ( )

Display all card categories into a table.

Returns
HTML row

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

177 {
178 $tab = new Sort_Table();
179
180 $url = HtmlInput::get_to_string(array('ac', 'gDossier'));
181 $tab->add(_("Nom de fiche"), $url, "order by fd_label asc", "order by fd_label desc", "na", "nd");
182 $tab->add(_("Basé sur le poste comptable"), $url, "order by fd_class_base asc", "order by fd_class_base desc", "pa", "pd");
183 $tab->add(_("Calcul automatique du poste comptable"), $url, "order by fd_create_account asc", "order by fd_create_account desc", "ca", "cd");
184 $tab->add(_("Basé sur le modèle"), $url, "order by frd_text asc", "order by frd_text desc", "ma", "md");
185
186 $order = (isset($_GET['ord'])) ? $tab->get_sql_order($_GET["ord"]) : $tab->get_sql_order("na");
187
188
189 $res = $this->cn->exec_sql("SELECT fd_id, fd_class_base, fd_label, fd_create_account, fiche_def_ref.frd_id,
190frd_text , fd_description FROM fiche_def join fiche_def_ref on (fiche_def.frd_id=fiche_def_ref.frd_id)
191$order
192");
193
194 require_once NOALYSS_TEMPLATE.'/fiche_def-display.php';
195 }
$_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 489 of file fiche_def.class.php.

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

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

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

138 {
139 $sql="select * from fiche_def ";
140
141 $Ret=$this->cn->exec_sql($sql);
142 if ( ($Max=Database::num_row($Ret)) == 0 )
143 return array();
144 $all=array();
145 for ( $i = 0; $i < $Max;$i++)
146 {
148 $all[$i]=new Fiche_Def($this->cn,$row['fd_id']);
149 $all[$i]->label=$row['fd_label'];
150 $all[$i]->class_base=$row['fd_class_base'];
151 $all[$i]->fiche_def=$row['frd_id'];
152 $all[$i]->create_account=$row['fd_create_account'];
153 }
154 return $all;
155 }

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

741 {
742
743 // find the min attr for the fiche_def_ref
744 $Sql="select ad_id,ad_text ,attr_min.ad_default_order
745 from attr_min
746 join attr_def using(ad_id)
747 join fiche_def_ref using(frd_id)
748 where
749 frd_id= $1 order by ad_default_order";
750 $Res=$this->cn->exec_sql($Sql,array($p_fiche_def_ref));
752
753 // test the number of returned rows
754 if ($Num == 0 ) return null;
755
756 // Get Results & Store them in a array
757 for ($i=0;$i<$Num;$i++)
758 {
760 $array[$i]['ad_id']=$f['ad_id'];
761 $array[$i]['ad_text']=$f['ad_text'];
762 $array[$i]['ad_default_order']=$f['ad_default_order'];
763 }
764 return $array;
765 }

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 ( $template_category,
$inactive = 1 )

Get all the card where the fiche_def.frd_id is given in parameter, it is the template for category.

Parameters
$inactiveint possible values : 1 = inactive included, 0 = only active ones (default 1)
$template_categoryint FICHE_DEF_REF.FRD_ID
Returns
array of Fiche or null is nothing is found

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

380 {
381 // var $cond_active string SQL cond for filtering active or not
382 $cond_active=($inactive == 1)?"":" and f_enable='1' ";
383 $sql="select f_id,ad_value
384 from
385 fiche join fiche_def using(fd_id)
386 join fiche_detail using(f_id)
387 where ad_id=1 and frd_id=$1 $cond_active
388 order by 2 ";
389
390 $Ret=$this->cn->exec_sql($sql,array($template_category));
391 if ( ($Max=Database::num_row($Ret)) == 0 )
392 return null;
393 $all[0]=new Fiche($this->cn);
394
395 for ($i=0;$i<$Max;$i++)
396 {
398 $t=new Fiche($this->cn,$row['f_id']);
399 $t->load_attribute();
400 $all[$i]=$t;
401
402 }
403 return $all;
404 }
$t
Definition compute.php:46

References $all, $i, $inactive, $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,
$inactive = 1 )

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
$inactiveint possible values : 1 = inactive included, 0 = only active ones (default 1)
Returns
array ('f_id'=>..,'ad_value'=>..)
See also
fiche

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

352 {
353 // var $cond_active string SQL cond for filtering active or not
354 $cond_active=($inactive == 1)?"":" and f_enable='1' ";
355 $sql="select f_id,ad_value
356 from
357 fiche join fiche_detail using(f_id)
358 where ad_id=1 and fd_id=$1 $cond_active order by 2";
359
360 // we use navigation_bar
361 if ($step == 1 && $_SESSION[SESSION_KEY.'g_pagesize'] != -1 )
362 {
363 $offset=(isset($_GET['offset']))?$_GET['offset']:0;
364 $step=$_SESSION[SESSION_KEY.'g_pagesize'];
365 $sql.=" offset $offset limit $step";
366 }
367
368 $Ret=$this->cn->get_array($sql,array($this->id));
369
370 return $Ret;
371 }

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

◆ getAttribut()

Fiche_Def::getAttribut ( )

replace by load_attribute

Deprecated
since version 9.3.12
Returns
type

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

67 {
68 return $this->load_attribute();
69 }
load_attribute()
Get attribute of a fiche_def.

References load_attribute().

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

166 {
167 return ($this->cn->count_sql("select * from vw_fiche_def where ad_id=$p_attr and fd_id=".$this->id)>0)?true:false;
168
169 }

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

783 {
784 $r = "";
785 // Save the label
786
787 $this->get();
788 $this->load_attribute();
789 $r.= '<H2 class="info">' . $this->id . " " . h($this->label) . '</H2>';
790 $r.='<fieldset><legend>'._('Données générales').'</legend>';
791
792 $nom_mod=$this->label;
793 /* the accounting item */
794 $class_base=new IPoste('class_base');
795 $class_base->set_attribute('ipopup','ipop_account');
796 $class_base->set_attribute('account','class_base');
797 $class_base->set_attribute('label','acc_label');
799 $f_class_base=$class_base->input();
800 $fd_description=new ITextarea('fd_description');
801 $fd_description->width=80;
802 $fd_description->heigh=4;
803 $fd_description->style='class="itextarea form-control input_text" style="margin-left:0px;vertical-align:text-top"';
805 $r.='<form method="post" style="display:inline">';
806 $r.=\HtmlInput::hidden('fd_id',$this->id);
807 ob_start();
808 require_once NOALYSS_TEMPLATE.'/fiche_def_input.php';
809 $r.=ob_get_contents();
810 ob_clean();
811 $r.=HtmlInput::submit('change_name', _('Sauver'));
812 $r.='</form>';
813 $r.='<form method="post" style="display:inline" id="catcard_remove" onsubmit="return confirm_box(this,\'Effacer?\')">';
814 $r.=HtmlInput::hidden("action", "remove_cat");
815 $r.=HtmlInput::hidden('fd_id',$this->id);
816 $r.=HtmlInput::submit('remove_cat', _('Effacer'));
817 $r.='</form>';
818
819
820
821 $r.='</fieldset>';
822 $r.='<hr>';
823 /* attributes */
824 $r.='<fieldset><legend>'._('Détails').'</legend>';
825
826 $r.= '<FORM id="input_detail_frm" method="POST">';
827 $r.=dossier::hidden();
828 $r.=HtmlInput::hidden("fd_id", $this->id);
829 $r.=HtmlInput::hidden("action", "");
830 // $r.= $this->DisplayAttribut("remove");
831 ob_start();
832 require NOALYSS_TEMPLATE."/fiche_def-input_detail-2.php";
833 $r.=ob_get_contents();
834 ob_clean();
835
836 $r.= "</form>";
837
838 $r.='</fieldset>';
839 return $r;
840 }
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, label, and load_attribute().

+ Here is the call graph for this function:

◆ input_new()

Fiche_Def::input_new ( )

input for creating a new category

Returns
void

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

848 {
849 $single=new Single_Record("dup");
850 echo '<form method="post" style="display:inline" onsubmit="return check_new_category()">';
851 echo $single->hidden();
852 echo HtmlInput::hidden("p_action","fiche");
853 echo dossier::hidden();
854 $ref=$this->cn->get_array("select * from fiche_def_ref order by frd_text");
855 $iradio=new IRadio();
856 $nom_mod="";
857 /* the accounting item */
858 $class_base=new IPoste('class_base');
859 $class_base->set_attribute('ipopup','ipop_account');
860 $class_base->set_attribute('account','class_base');
861 $class_base->set_attribute('label','acc_label');
862 $f_class_base=$class_base->input();
863 $fd_description=new ITextarea('fd_description');
864 $fd_description->width=80;
865 $fd_description->heigh=4;
866 $fd_description->style='class="itextarea form-control input_text" style="margin-left:0px;vertical-align:text-top"';
867 require_once NOALYSS_TEMPLATE.'/fiche_def_input.php';
868 require_once NOALYSS_TEMPLATE.'/fiche_def-input_new.php';
869
870 echo HtmlInput::submit("add_modele" ,_("Sauve"));
871 echo '</FORM>';
872 }

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

628 {
629 if ( $this->id == 0 ) return;
630 /* ORDER */
631 $this->load_attribute();
633 if ( $p_order == -1 ) {
634 $order = $this->cn->get_value("select ad_default_order from attr_def where ad_id=$1",[$p_ad_id]);
635 if ( $order == 0 || empty($order)) {
636 $max=$this->cn->get_value("select count(*) from jnt_fic_attr where fd_id=$1",[$this->id]);
637 $order=$max*15;
638 }
639 }
640 // Insert a new attribute for the model
641 // it means insert a row in jnt_fic_attr
642 $sql=sprintf("insert into jnt_fic_attr (fd_id,ad_id,jnt_order) values (%d,%d,%d)",
643 $this->id,$p_ad_id,$order);
644 $Res=$this->cn->exec_sql($sql);
645 }

References $max, $order, $p_order, $Res, $sql, cn, and load_attribute().

+ Here is the call graph for this function:

◆ load()

Fiche_Def::load ( )

alias for Fiche_Def->get(),

Returns
void

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

105 :void
106 {
107 $this->get();
108 }

◆ load_attribute()

Fiche_Def::load_attribute ( )

Get attribute of a fiche_def.

Returns
array of Card_Property

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

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

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

Referenced by getAttribut(), input_detail(), insertAttribut(), and save_order().

+ Here is the call graph for this function:

◆ myList()

Fiche_Def::myList ( )

list the card of a fd_id

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

409 {
410 $this->get();
411 echo '<H2 class="info">'.$this->id." ".$this->label.'</H2>';
412
413 $step=$_SESSION[SESSION_KEY.'g_pagesize'];
414 $sql_limit="";
415 $sql_offset="";
416 $bar="";
417 if ( $step != -1 )
418 {
419
420 $page=(isset($_GET['page']))?$_GET['page']:1;
421 $offset=(isset($_GET['offset']))?$_GET['offset']:0;
422 $max_line=$this->cn->count_sql("select f_id,ad_value from
423 fiche join fiche_detail using (f_id)
424 where fd_id='".$this->id."' and ad_id=".ATTR_DEF_NAME." order by f_id");
425 $sql_limit=" limit ".$step;
426 $sql_offset=" offset ".$offset;
428 }
429
430 // Get all name the cards of the select category
431 // 1 for attr_def.ad_id is always the name
432 $Res=$this->cn->exec_sql("select f_id,vw_name,quick_code from ".
433 " vw_fiche_attr ".
434 " where fd_id='".$this->id.
435 "' order by f_id $sql_offset $sql_limit ");
437 echo $bar;
438 $str="";
439 // save the url
440 // with offet &offset=15&step=15&page=2&size=15
441 if ( $_SESSION[SESSION_KEY.'g_pagesize'] != -1)
442 {
443 $str=sprintf("&offset=%s&step=%s&page=%s&size=%s",
444 $offset,
445 $step,
446 $page,
447 $max_line);
448 }
449
450
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 $str_dossier=dossier::get();
458 echo '<table>';
459 for ( $i = 0; $i < $Max; $i++)
460 {
462 if ( $i%2 == 0)
463 echo '<TR class="odd">';
464 else
465 echo '<TR class="even">';
466
467 $span_mod='<TD><A href="?p_action=fiche&'.$str_dossier.
468 '&action=detail&fiche_id='.$l_line['f_id'].$str.'&fiche='.
469 $_REQUEST['fiche'].'&ac='.$_REQUEST['ac'].'">'.$l_line['quick_code']
470 .'</A></TD>';
471
472 echo $span_mod.'<TD>'.h($l_line['vw_name'])."</TD>";
473 echo '</tr>';
474 }
475 echo '</table>';
476 echo '<FORM METHOD="POST" action="?p_action=fiche&action=vue'.$str.'">';
477 echo HtmlInput::hidden('ac',$_REQUEST['ac']);
478 echo dossier::hidden();
479 echo HtmlInput::hidden("fiche",$this->id);
480 echo HtmlInput::submit('add','Ajout fiche');
481 echo '</FORM>';
482 echo $bar;
483
484 }
$_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 936 of file fiche_def.class.php.

937 {
938 include NOALYSS_TEMPLATE.'/fiche_def-print_available_attribut.php';
939 }

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

926 {
927 include NOALYSS_TEMPLATE.'/fiche_def-print_existing_attribut.php';
928 }

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

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

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

651 {
652 foreach ($array as $ch)
653 {
654 $this->cn->start();
655 $sql="delete from jnt_fic_attr where fd_id=$1 ".
656 " and ad_id=$2";
657 $this->cn->exec_sql($sql,array($this->id,$ch));
658
659 $sql="delete from fiche_detail where jft_id in ( select ".
660 " jft_id from fiche_Detail ".
661 " join fiche using(f_id) ".
662 " where ".
663 "fd_id = $1 and ".
664 "ad_id=$2)";
665 $this->cn->exec_sql($sql,array($this->id,$ch));
666
667 $this->cn->commit();
668 }
669 }

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

607 {
608 if ( $this->id == 0 ) return;
609 $p_label=sql_string($p_label);
610
611 $sql="update fiche_def set fd_class_base=$1 ".
612 "where fd_id=$2";
613
614 $Res=$this->cn->exec_sql($sql,array($p_label,$this->id));
615 }

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

617 {
618 if ( $this->id == 0) return;
619 $this->cn->exec_sql("update fiche_def set fd_description=$1 where fd_id=$2",array($p_description,$this->id));
620 }

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

675 {
676 extract($p_array, EXTR_SKIP);
677 $this->load_attribute();
678 foreach ($this->attribut as $row)
679 {
680 if ( $row->ad_id == 1 ) continue;
681 if ( ${'jnt_order'.$row->ad_id} <= 0 ) continue;
682 $sql='update jnt_fic_attr set jnt_order=$1 where fd_id=$2 and ad_id=$3';
683 $this->cn->exec_sql($sql,array(${'jnt_order'.$row->ad_id},
684 $this->id,
685 $row->ad_id));
686
687 }
688 /* correct the order */
689 $this->cn->exec_sql('select attribute_correct_order()');
690 }

References $id, $p_array, $row, $sql, cn, and load_attribute().

+ Here is the call graph for this function:

◆ SaveLabel()

Fiche_Def::SaveLabel ( $p_label)

Save the label of the fiche_def.

Parameters
$p_labellabel

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

571 {
572 if ( $this->id == 0 ) return;
573 $p_label=sql_string($p_label);
574 if (strlen(trim ($p_label)) == 0 )
575 {
576 return;
577 }
578 $sql=sprintf("update fiche_def set fd_label='%s' ".
579 "where fd_id=%d",
580 $p_label,$this->id);
581 $Res=$this->cn->exec_sql($sql);
582
583 }

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

589 {
590 if ( $this->id == 0 ) return;
591 if ($p_label==true)
592 $t='t';
593 if ($p_label==false)
594 $t='f';
595
596 $sql="update fiche_def set fd_create_account=$1 ".
597 "where fd_id=$2";
598
599 $Res=$this->cn->exec_sql($sql,array($t,$this->id));
600
601
602 }

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

901 {
902 $sql="select 'av_text'||to_char(ad_id,'9999') as key,".
903 " ad_text ".
904 " from fiche_def join jnt_fic_attr using (fd_id)".
905 " join attr_def using (ad_id) ".
906 " where fd_id=$1 order by jnt_order";
907 $ret=$this->cn->get_array($sql,array($this->id));
908 if ( empty($ret)) throw new Exception(_('Cette categorie de card n\'existe pas').' '.$this->id,1);
909 $array=array();
910 foreach($ret as $idx=>$val)
911 {
912 $a=noalyss_str_replace(' ','',$val['key']);
913 $array[$a]=$val['ad_text'];
914 }
915 return $array;
916
917 }
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 load_attribute().

◆ $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.

Referenced by __construct().

◆ $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 __construct(), and 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: