20require_once NOALYSS_INCLUDE.
'/lib/user_common.php';
52 return "fiche_def".print_r($this,
true);
70 $sql=
"select * from jnt_fic_attr ".
71 " natural join attr_def where fd_id= $1".
72 " order by jnt_order";
74 $Ret=$this->
cn->exec_sql(
$sql,[$this->
id]);
83 $t->ad_text=
$row[
'ad_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;
108 if ( $this->
id == 0 )
113 $sql=
"select * from fiche_def ".
115 $Ret=$this->
cn->exec_sql(
$sql,[$this->
id]);
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'];
132 $sql=
"select * from fiche_def ";
134 $Ret=$this->
cn->exec_sql(
$sql);
145 $all[
$i]->create_account=
$row[
'fd_create_account'];
160 return ($this->
cn->count_sql(
"select * from vw_fiche_def where ad_id=$p_attr and fd_id=".$this->id)>0)?
true:
false;
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");
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)
187 require_once NOALYSS_TEMPLATE.
'/fiche_def-display.php';
209 $p_nom_mod =
$http->extract(
'nom_mod',
"string",
"");
210 $p_fd_description =
$http->extract(
'fd_description',
"string",
"");
212 $p_fiche_def=
$http->extract(
'FICHE_REF',
"string",
"");
213 $p_create=
$http->extract(
'create',
"string",
"off");
216 if ( ! isset ($p_fd_description)) {
217 $p_fd_description=
"";
226 alert (
_(
'Le nom de la catégorie ne peut pas être vide'));
232 alert (
_(
'Un modéle de catégorie est obligatoire'));
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)));
241 alert (
_(
'Catégorie existante'));
244 $default_acc=$this->
cn->get_value(
"select frd_class_base from fiche_def_ref where frd_id=$1",[$p_fiche_def]);
247 $p_class_base=
$http->extract(
'class_base',
"string",
"");
248 $p_class_base=(
noalyss_trim($p_class_base)==
'')?$default_acc:$p_class_base;
256 $add_accounting=
false;
258 if (
sql_string($p_class_base) !=
null || ( $p_class_base !=
'' && strpos(
',',$p_class_base) != 0 ))
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";
264 $this->
id=$this->
cn->get_value(
$sql,array($p_nom_mod,$p_class_base,$p_fiche_def,$p_create,$p_fd_description));
267 if ( strpos(
',',$p_class_base) ==0)
269 $sql=
"select account_add($1,$2)";
270 $Res=$this->
cn->exec_sql(
$sql,array($p_class_base,$p_nom_mod));
273 $fd_id=$this->
cn->get_current_seq(
's_fdef');
279 $add_accounting=
true;
284 $sql=
"insert into fiche_def(fd_label,frd_id,fd_create_account,fd_description) values ($1,$2,$3,$4) returning fd_id";
287 $this->
id=$this->
cn->get_value(
$sql,array($p_nom_mod,$p_fiche_def,$p_create,$p_fd_description));
290 $fd_id=$this->
cn->get_current_seq(
's_fdef');
300 if (
sizeof($def_attr) != 0 )
303 foreach ( $def_attr as
$row)
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']));
309 $sql=sprintf(
"insert into jnt_fic_Attr(fd_id,ad_id,jnt_order)
312 $this->
cn->exec_sql(
$sql);
321 if ( $add_accounting) {
322 $sql=sprintf(
"insert into jnt_fic_attr(fd_id,ad_id,jnt_order)
328 $sql=sprintf(
"insert into jnt_fic_attr(fd_id,ad_id,jnt_order)
346 $sql=
"select f_id,ad_value
348 fiche join fiche_detail using(f_id)
349 where ad_id=1 and fd_id=$1 order by 2";
352 if (
$step == 1 && $_SESSION[SESSION_KEY.
'g_pagesize'] != -1 )
355 $step=$_SESSION[SESSION_KEY.
'g_pagesize'];
356 $sql.=
" offset $offset limit $step";
359 $Ret=$this->
cn->get_array(
$sql,array($this->
id));
369 $sql=
"select f_id,ad_value
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 ";
375 $Ret=$this->
cn->exec_sql(
$sql,array($p_cat));
396 echo
'<H2 class="info">'.$this->id.
" ".$this->
label.
'</H2>';
398 $step=$_SESSION[SESSION_KEY.
'g_pagesize'];
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;
417 $Res=$this->
cn->exec_sql(
"select f_id,vw_name,quick_code from ".
419 " where fd_id='".$this->
id.
420 "' order by f_id $sql_offset $sql_limit ");
426 if ( $_SESSION[SESSION_KEY.
'g_pagesize'] != -1)
428 $str=sprintf(
"&offset=%s&step=%s&page=%s&size=%s",
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');
448 echo
'<TR class="odd">';
450 echo
'<TR class="even">';
452 $span_mod=
'<TD><A href="?p_action=fiche&'.$str_dossier.
453 '&action=detail&fiche_id='.$l_line[
'f_id'].$str.
'&fiche='.
457 echo $span_mod.
'<TD>'.
h($l_line[
'vw_name']).
"</TD>";
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');
476 if ( $this->
id == 0 )
478 $this->
cn->exec_sql(
'select fiche_attribut_synchro($1)',array($this->
id));
482 $r.=
"<tr>".th(
'Nom attribut').th(
'').th(
'Ordre',
'style="text-align:right"').
'</tr>';
485 for (
$i=0;
$i<$MaxLine;
$i++)
491 $r.=
'<TR class="'.$class.
'"><td>';
499 if (
$str ==
"remove" )
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
508 $add_action=sprintf(
'</TD><TD> Supprimer <input type="checkbox" name="chk_remove[]" value="%d">',
509 $this->attribut[
$i]->ad_id);
512 $add_action=
"</td><td>";
515 $a=sprintf(
'%s ', $this->attribut[
$i]->ad_text);
521 $order->name=
'jnt_order'.$this->attribut[
$i]->ad_id;
523 $order->value=$this->attribut[
$i]->jnt_order;
524 $r.=
'</td><td> '.$order->input();
531 $Res=$this->
cn->exec_sql(
"select ad_id,ad_text from attr_def
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) );
539 $r.=
'<SELECT NAME="ad_id">';
543 $a=sprintf(
'<OPTION VALUE="%s"> %s',
544 $l[
'ad_id'],
$l[
'ad_text']);
557 if ( $this->
id == 0 )
return;
559 if (strlen(trim ($p_label)) == 0 )
563 $sql=sprintf(
"update fiche_def set fd_label='%s' ".
575 if ( $this->
id == 0 )
return;
581 $sql=
"update fiche_def set fd_create_account=$1 ".
593 if ( $this->
id == 0 )
return;
596 $sql=
"update fiche_def set fd_class_base=$1 ".
599 $Res=$this->
cn->exec_sql(
$sql,array($p_label,$this->
id));
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));
614 if ( $this->
id == 0 )
return;
616 $this->GetAttribut();
619 $order = $this->
cn->get_value(
"select ad_default_order from attr_def where ad_id=$1",[$p_ad_id]);
621 $max=$this->
cn->get_value(
"select count(*) from jnt_fic_attr where fd_id=$1",[$this->
id]);
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);
640 $sql=
"delete from jnt_fic_attr where fd_id=$1 ".
642 $this->
cn->exec_sql(
$sql,array($this->
id,$ch));
644 $sql=
"delete from fiche_detail where jft_id in ( select ".
645 " jft_id from fiche_Detail ".
646 " join fiche using(f_id) ".
650 $this->
cn->exec_sql(
$sql,array($this->
id,$ch));
662 $this->GetAttribut();
663 foreach ($this->attribut as
$row)
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},
674 $this->
cn->exec_sql(
'select attribute_correct_order()');
685 if ( $this->
id >= 500000 ) {
686 throw new Exception(
_(
'Catégorie verrouillée '));
690 $aFiche=fiche::get_fiche_def($this->
cn,$this->
id);
691 if ( $aFiche !=
null )
694 foreach ($aFiche as $dfiche)
699 if (
$fiche->is_used() ==
false )
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));
729 $Sql=
"select ad_id,ad_text ,attr_min.ad_default_order
731 join attr_def using(ad_id)
732 join fiche_def_ref using(frd_id)
734 frd_id= $1 order by ad_default_order";
735 $Res=$this->
cn->exec_sql($Sql,array($p_fiche_def_ref));
739 if ($Num == 0 )
return null;
747 $array[
$i][
'ad_default_order']=
$f[
'ad_default_order'];
759 $ret=$this->
cn->count_sql(
"select fd_id from fiche_def where frd_id=$1",array($p_frd_id));
773 $this->GetAttribut();
774 $r.=
'<H2 class="info">' . $this->
id .
" " .
h($this->
label) .
'</H2>';
775 $r.=
'<fieldset><legend>'._(
'Données générales').
'</legend>';
780 $class_base->set_attribute(
'ipopup',
'ipop_account');
781 $class_base->set_attribute(
'account',
'class_base');
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);
793 require_once NOALYSS_TEMPLATE.
'/fiche_def_input.php';
794 $r.=ob_get_contents();
796 $r.=HtmlInput::submit(
'change_name',
_(
'Sauver'));
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'));
804 require NOALYSS_TEMPLATE.
'/fiche_def-input_detail.php';
809 $r.=
'<fieldset><legend>'._(
'Détails').
'</legend>';
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",
"");
817 require NOALYSS_TEMPLATE.
"/fiche_def-input_detail-2.php";
818 $r.=ob_get_contents();
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");
844 $class_base->set_attribute(
'ipopup',
'ipop_account');
845 $class_base->set_attribute(
'account',
'class_base');
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';
855 echo HtmlInput::submit(
"add_modele" ,
_(
"Sauve"));
887 $sql=
"select 'av_text'||to_char(ad_id,'9999') as key,".
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);
912 include NOALYSS_TEMPLATE.
'/fiche_def-print_existing_attribut.php';
923 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,...")
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
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()
Get attribut of a fiche_def.
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 ...
get_by_type($step=0)
Get all the card where the fiche_def.fd_id is given in parameter.
myList()
list the card of a fd_id
__construct($p_cn, $p_id=0)
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_by_category($p_cat)
Get all the card where the fiche_def.frd_id is given in parameter.
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.
$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.
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)