20require_once NOALYSS_INCLUDE.
'/lib/user_common.php';
52 return "fiche_def".print_r($this,
true);
77 $sql=
"select * from jnt_fic_attr ".
78 " natural join attr_def where fd_id= $1".
79 " order by jnt_order";
81 $Ret=$this->
cn->exec_sql(
$sql,[$this->
id]);
90 $t->ad_text=
$row[
'ad_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;
115 if ( $this->
id == 0 )
120 $sql=
"select * from fiche_def ".
122 $Ret=$this->
cn->exec_sql(
$sql,[$this->
id]);
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'];
139 $sql=
"select * from fiche_def ";
141 $Ret=$this->
cn->exec_sql(
$sql);
152 $all[
$i]->create_account=
$row[
'fd_create_account'];
167 return ($this->
cn->count_sql(
"select * from vw_fiche_def where ad_id=$p_attr and fd_id=".$this->id)>0)?
true:
false;
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");
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)
194 require_once NOALYSS_TEMPLATE.
'/fiche_def-display.php';
216 $p_nom_mod =
$http->extract(
'nom_mod',
"string",
"");
217 $p_fd_description =
$http->extract(
'fd_description',
"string",
"");
219 $p_fiche_def=
$http->extract(
'FICHE_REF',
"string",
"");
220 $p_create=
$http->extract(
'create',
"string",
"off");
223 if ( ! isset ($p_fd_description)) {
224 $p_fd_description=
"";
233 alert (
_(
'Le nom de la catégorie ne peut pas être vide'));
239 alert (
_(
'Un modéle de catégorie est obligatoire'));
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)));
248 alert (
_(
'Catégorie existante'));
251 $default_acc=$this->
cn->get_value(
"select frd_class_base from fiche_def_ref where frd_id=$1",[$p_fiche_def]);
254 $p_class_base=
$http->extract(
'class_base',
"string",
"");
255 $p_class_base=(
noalyss_trim($p_class_base)==
'')?$default_acc:$p_class_base;
263 $add_accounting=
false;
265 if (
sql_string($p_class_base) !=
null || ( $p_class_base !=
'' && strpos(
',',$p_class_base) != 0 ))
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";
271 $this->
id=$this->
cn->get_value(
$sql,array($p_nom_mod,$p_class_base,$p_fiche_def,$p_create,$p_fd_description));
274 if ( strpos(
',',$p_class_base) ==0)
276 $sql=
"select account_add($1,$2)";
277 $Res=$this->
cn->exec_sql(
$sql,array($p_class_base,$p_nom_mod));
280 $fd_id=$this->
cn->get_current_seq(
's_fdef');
286 $add_accounting=
true;
291 $sql=
"insert into fiche_def(fd_label,frd_id,fd_create_account,fd_description) values ($1,$2,$3,$4) returning fd_id";
294 $this->
id=$this->
cn->get_value(
$sql,array($p_nom_mod,$p_fiche_def,$p_create,$p_fd_description));
297 $fd_id=$this->
cn->get_current_seq(
's_fdef');
307 if (
sizeof($def_attr) != 0 )
310 foreach ( $def_attr as
$row)
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']));
316 $sql=sprintf(
"insert into jnt_fic_Attr(fd_id,ad_id,jnt_order)
319 $this->
cn->exec_sql(
$sql);
328 if ( $add_accounting) {
329 $sql=sprintf(
"insert into jnt_fic_attr(fd_id,ad_id,jnt_order)
335 $sql=sprintf(
"insert into jnt_fic_attr(fd_id,ad_id,jnt_order)
354 $cond_active=(
$inactive == 1)?
"":
" and f_enable='1' ";
355 $sql=
"select f_id,ad_value
357 fiche join fiche_detail using(f_id)
358 where ad_id=1 and fd_id=$1 $cond_active order by 2";
361 if (
$step == 1 && $_SESSION[SESSION_KEY.
'g_pagesize'] != -1 )
364 $step=$_SESSION[SESSION_KEY.
'g_pagesize'];
365 $sql.=
" offset $offset limit $step";
368 $Ret=$this->
cn->get_array(
$sql,array($this->
id));
382 $cond_active=(
$inactive == 1)?
"":
" and f_enable='1' ";
383 $sql=
"select f_id,ad_value
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
390 $Ret=$this->
cn->exec_sql(
$sql,array($template_category));
399 $t->load_attribute();
411 echo
'<H2 class="info">'.$this->id.
" ".$this->
label.
'</H2>';
413 $step=$_SESSION[SESSION_KEY.
'g_pagesize'];
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;
432 $Res=$this->
cn->exec_sql(
"select f_id,vw_name,quick_code from ".
434 " where fd_id='".$this->
id.
435 "' order by f_id $sql_offset $sql_limit ");
441 if ( $_SESSION[SESSION_KEY.
'g_pagesize'] != -1)
443 $str=sprintf(
"&offset=%s&step=%s&page=%s&size=%s",
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');
463 echo
'<TR class="odd">';
465 echo
'<TR class="even">';
467 $span_mod=
'<TD><A href="?p_action=fiche&'.$str_dossier.
468 '&action=detail&fiche_id='.$l_line[
'f_id'].$str.
'&fiche='.
472 echo $span_mod.
'<TD>'.
h($l_line[
'vw_name']).
"</TD>";
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');
491 if ( $this->
id == 0 )
493 $this->
cn->exec_sql(
'select fiche_attribut_synchro($1)',array($this->
id));
497 $r.=
"<tr>".th(
'Nom attribut').th(
'').th(
'Ordre',
'style="text-align:right"').
'</tr>';
500 for (
$i=0;
$i<$MaxLine;
$i++)
506 $r.=
'<TR class="'.$class.
'"><td>';
514 if (
$str ==
"remove" )
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
523 $add_action=sprintf(
'</TD><TD> Supprimer <input type="checkbox" name="chk_remove[]" value="%d">',
524 $this->attribut[
$i]->ad_id);
527 $add_action=
"</td><td>";
530 $a=sprintf(
'%s ', $this->attribut[
$i]->ad_text);
536 $order->name=
'jnt_order'.$this->attribut[
$i]->ad_id;
538 $order->value=$this->attribut[
$i]->jnt_order;
539 $r.=
'</td><td> '.$order->input();
546 $Res=$this->
cn->exec_sql(
"select ad_id,ad_text from attr_def
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) );
554 $r.=
'<SELECT NAME="ad_id">';
558 $a=sprintf(
'<OPTION VALUE="%s"> %s',
559 $l[
'ad_id'],
$l[
'ad_text']);
572 if ( $this->
id == 0 )
return;
574 if (strlen(trim ($p_label)) == 0 )
578 $sql=sprintf(
"update fiche_def set fd_label='%s' ".
590 if ( $this->
id == 0 )
return;
596 $sql=
"update fiche_def set fd_create_account=$1 ".
608 if ( $this->
id == 0 )
return;
611 $sql=
"update fiche_def set fd_class_base=$1 ".
614 $Res=$this->
cn->exec_sql(
$sql,array($p_label,$this->
id));
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));
629 if ( $this->
id == 0 )
return;
634 $order = $this->
cn->get_value(
"select ad_default_order from attr_def where ad_id=$1",[$p_ad_id]);
636 $max=$this->
cn->get_value(
"select count(*) from jnt_fic_attr where fd_id=$1",[$this->
id]);
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);
655 $sql=
"delete from jnt_fic_attr where fd_id=$1 ".
657 $this->
cn->exec_sql(
$sql,array($this->
id,$ch));
659 $sql=
"delete from fiche_detail where jft_id in ( select ".
660 " jft_id from fiche_Detail ".
661 " join fiche using(f_id) ".
665 $this->
cn->exec_sql(
$sql,array($this->
id,$ch));
678 foreach ($this->attribut as
$row)
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},
689 $this->
cn->exec_sql(
'select attribute_correct_order()');
700 if ( $this->
id >= 500000 ) {
701 throw new Exception(
_(
'Catégorie verrouillée '));
705 $aFiche=fiche::get_fiche_def($this->
cn,$this->
id);
706 if ( $aFiche !=
null )
709 foreach ($aFiche as $dfiche)
714 if (
$fiche->is_used() ==
false )
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));
744 $Sql=
"select ad_id,ad_text ,attr_min.ad_default_order
746 join attr_def using(ad_id)
747 join fiche_def_ref using(frd_id)
749 frd_id= $1 order by ad_default_order";
750 $Res=$this->
cn->exec_sql($Sql,array($p_fiche_def_ref));
754 if ($Num == 0 )
return null;
762 $array[
$i][
'ad_default_order']=
$f[
'ad_default_order'];
774 $ret=$this->
cn->count_sql(
"select fd_id from fiche_def where frd_id=$1",array($p_frd_id));
789 $r.=
'<H2 class="info">' . $this->
id .
" " .
h($this->
label) .
'</H2>';
790 $r.=
'<fieldset><legend>'._(
'Données générales').
'</legend>';
795 $class_base->set_attribute(
'ipopup',
'ipop_account');
796 $class_base->set_attribute(
'account',
'class_base');
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);
808 require_once NOALYSS_TEMPLATE.
'/fiche_def_input.php';
809 $r.=ob_get_contents();
811 $r.=HtmlInput::submit(
'change_name',
_(
'Sauver'));
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'));
824 $r.=
'<fieldset><legend>'._(
'Détails').
'</legend>';
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",
"");
832 require NOALYSS_TEMPLATE.
"/fiche_def-input_detail-2.php";
833 $r.=ob_get_contents();
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");
859 $class_base->set_attribute(
'ipopup',
'ipop_account');
860 $class_base->set_attribute(
'account',
'class_base');
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';
870 echo HtmlInput::submit(
"add_modele" ,
_(
"Sauve"));
902 $sql=
"select 'av_text'||to_char(ad_id,'9999') as key,".
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);
927 include NOALYSS_TEMPLATE.
'/fiche_def-print_existing_attribut.php';
938 include NOALYSS_TEMPLATE.
'/fiche_def-print_available_attribut.php';
noalyss_strlentrim($p_string)
noalyss_str_replace($search, $replace, $string)
sql_string($p_string)
Fix the problem with the quote char for the database.
alert($p_msg, $buffer=false)
alert in javascript
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
h( $row[ 'oa_description'])
_("actif, passif,charge,...")
$class
Display the Plugin and for each profile were it is installed or not.
contains the attributes of a card , manage them, save them , ...
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
define Class fiche and fiche def, those class are using class attribut
static print_existing_attribut($attribut_id, $attribut_text)
display existing attribut
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.
save_description($p_description)
input()
show the content of the form to create a new Fiche_Def_Ref
load()
alias for Fiche_Def->get(),
getAttribut()
replace by load_attribute
save_class_base($p_label)
Save the class base.
Add($array)
Add a fiche category thanks the element from the array you cannot add twice the same cat....
DisplayAttribut($str="")
Display all the attribut of the 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 ...
myList()
list the card of a fd_id
display()
Display all card categories into a table.
count_category($p_frd_id)
count the number of fiche_def (category) which has the frd_id (type of category)
get_attr_min($p_fiche_def_ref)
retrieve the mandatory field of the card model
$attribut
get from attr_xxx tables
$fiche_def
fiche_def.frd_id = fiche_def_ref.frd_id
removeAttribut($array)
remove an attribut for this fiche_def
insertAttribut($p_ad_id, $p_order=-1)
insert a new attribut for this fiche_def
$fd_description
Description of the Card Category.
get_by_type($step=0, $inactive=1)
Get all the card where the fiche_def.fd_id is given in parameter.
$create_account
fd_create_account: flag
$class_base
fiche_def.fd_class_base
HasAttribute($p_attr)
Check in vw_fiche_def if a fiche has a attribut X.
load_attribute()
Get attribute of a fiche_def.
input_new()
input for creating a new category
set_autocreate($p_label)
set the auto create accounting item for each card and save it into the database
input_detail()
ask for detail
save_order($p_array)
save the order of a card, update the column jnt_fic_attr.jnt_order
static print_available_attribut($attribut_id, $attribut_text, $class)
display available attribut
get_all()
Get all the fiche_def.
SaveLabel($p_label)
Save the label of the fiche_def.
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
show a button, for selecting a account and a input text for manually inserting an account the differe...
Manage the TEXTAREA html element.
Objec to check a double insert into the database, this duplicate occurs after a refresh of the web pa...
Description of class_syn_sort_table.
catch(\Exception $e) $bar
navigation_bar($p_offset, $p_line, $p_size=0, $p_page=1, $p_javascript="")
Create a navigation_bar (pagesize)