20require_once NOALYSS_INCLUDE.
'/lib/user_common.php';
52 return "fiche_def".print_r($this,
true);
59 $ref=$this->
cn->get_array(
"select * from fiche_def_ref order by frd_text");
63 $class_base->set_attribute(
'ipopup',
'ipop_account');
70 $fd_description->style=
'class="itextarea" style="margin-left:0px;vertical-align:text-top"';
71 require_once NOALYSS_TEMPLATE.
'/fiche_def_input.php';
82 $sql=
"select * from jnt_fic_attr ".
83 " natural join attr_def where fd_id= $1".
84 " order by jnt_order";
86 $Ret=$this->
cn->exec_sql(
$sql,[$this->
id]);
94 $t->ad_id=
$row[
'ad_id'];
95 $t->ad_text=
$row[
'ad_text'];
97 $t->jnt_order=
$row[
'jnt_order'];
98 $t->ad_size=
$row[
'ad_size'];
99 $t->ad_type=
$row[
'ad_type'];
100 $t->ad_extra=
$row[
'ad_extra'];
101 $this->attribut[
$i]=clone $t;
120 if ( $this->
id == 0 )
125 $sql=
"select * from fiche_def ".
127 $Ret=$this->
cn->exec_sql(
$sql,[$this->
id]);
132 $this->class_base=
$row[
'fd_class_base'];
133 $this->fiche_def=
$row[
'frd_id'];
134 $this->create_account=
$row[
'fd_create_account'];
135 $this->fd_description=
$row[
'fd_description'];
144 $sql=
"select * from fiche_def ";
146 $Ret=$this->
cn->exec_sql(
$sql);
154 $all[
$i]->label=
$row[
'fd_label'];
157 $all[
$i]->create_account=
$row[
'fd_create_account'];
172 return ($this->
cn->count_sql(
"select * from vw_fiche_def where ad_id=$p_attr and fd_id=".$this->id)>0)?
true:
false;
186 $tab->add(_(
"Nom de fiche"),
$url,
"order by fd_label asc",
"order by fd_label desc",
"na",
"nd");
187 $tab->add(_(
"Basé sur le poste comptable"),
$url,
"order by fd_class_base asc",
"order by fd_class_base desc",
"pa",
"pd");
188 $tab->add(_(
"Calcul automatique du poste comptable"),
$url,
"order by fd_create_account asc",
"order by fd_create_account desc",
"ca",
"cd");
189 $tab->add(_(
"Basé sur le modèle"),
$url,
"order by frd_text asc",
"order by frd_text desc",
"ma",
"md");
194 $res = $this->
cn->exec_sql(
"SELECT fd_id, fd_class_base, fd_label, fd_create_account, fiche_def_ref.frd_id,
195frd_text , fd_description FROM fiche_def join fiche_def_ref on (fiche_def.frd_id=fiche_def_ref.frd_id)
199 require_once NOALYSS_TEMPLATE.
'/fiche_def_list.php';
221 $p_nom_mod =
$http->extract(
'nom_mod',
"string",
"");
222 $p_fd_description =
$http->extract(
'fd_description',
"string",
"");
223 $p_class_base=
$http->extract(
'class_base',
"string",
"");
224 $p_fiche_def=
$http->extract(
'FICHE_REF',
"string",
"");
225 $p_create=
$http->extract(
'create',
"string",
"off");
228 if ( ! isset ($p_fd_description)) {
229 $p_fd_description=
"";
238 alert (_(
'Le nom de la catégorie ne peut pas être vide'));
244 alert (_(
'Un modéle de catégorie est obligatoire'));
249 $sql=
"select count(*) from fiche_Def where upper(fd_label)=upper($1)";
250 $count=$this->
cn->get_value(
$sql,array(trim($p_nom_mod)));
253 alert (_(
'Catégorie existante'));
264 if (
sql_string($p_class_base) !=
null || ( $p_class_base !=
'' && strpos(
',',$p_class_base) != 0 ))
267 $sql=
"insert into fiche_def(fd_label,fd_class_base,frd_id,fd_create_account,fd_description)
268 values ($1,$2,$3,$4,$5) returning fd_id";
270 $this->
id=$this->
cn->get_value(
$sql,array($p_nom_mod,$p_class_base,$p_fiche_def,$p_create,$p_fd_description));
273 if ( strpos(
',',$p_class_base) ==0)
275 $sql=
"select account_add($1,$2)";
276 $Res=$this->
cn->exec_sql(
$sql,array($p_class_base,$p_nom_mod));
279 $fd_id=$this->
cn->get_current_seq(
's_fdef');
282 $sql=sprintf(
"insert into jnt_fic_attr(fd_id,ad_id,jnt_order)
289 $sql=
"insert into fiche_def(fd_label,frd_id,fd_create_account,fd_description) values ($1,$2,$3,$4) returning fd_id";
292 $this->
id=$this->
cn->get_value(
$sql,array($p_nom_mod,$p_fiche_def,$p_create,$p_fd_description));
295 $fd_id=$this->
cn->get_current_seq(
's_fdef');
304 if (
sizeof($def_attr) != 0 )
307 foreach ( $def_attr as
$row)
312 $count=$this->
cn->get_value(
"select count(*) from jnt_fic_attr where fd_id=$1 and ad_id=$2",array(
$fd_id,
$row[
'ad_id']));
315 $sql=sprintf(
"insert into jnt_fic_Attr(fd_id,ad_id,jnt_order)
318 $this->
cn->exec_sql(
$sql);
336 $sql=
"select f_id,ad_value
338 fiche join fiche_detail using(f_id)
339 where ad_id=1 and fd_id=$1 order by 2";
342 if (
$step == 1 && $_SESSION[SESSION_KEY.
'g_pagesize'] != -1 )
345 $step=$_SESSION[SESSION_KEY.
'g_pagesize'];
346 $sql.=
" offset $offset limit $step";
349 $Ret=$this->
cn->get_array(
$sql,array($this->
id));
359 $sql=
"select f_id,ad_value
361 fiche join fiche_def using(fd_id)
362 join fiche_detail using(f_id)
363 where ad_id=1 and frd_id=$1 order by 2 ";
365 $Ret=$this->
cn->exec_sql(
$sql,array($p_cat));
386 echo
'<H2 class="info">'.$this->id.
" ".$this->
label.
'</H2>';
388 $step=$_SESSION[SESSION_KEY.
'g_pagesize'];
397 $max_line=$this->
cn->count_sql(
"select f_id,ad_value from
398 fiche join fiche_detail using (f_id)
399 where fd_id='".$this->
id.
"' and ad_id=".
ATTR_DEF_NAME.
" order by f_id");
400 $sql_limit=
" limit ".$step;
401 $sql_offset=
" offset ".$offset;
407 $Res=$this->
cn->exec_sql(
"select f_id,vw_name,quick_code from ".
409 " where fd_id='".$this->
id.
410 "' order by f_id $sql_offset $sql_limit ");
416 if ( $_SESSION[SESSION_KEY.
'g_pagesize'] != -1)
418 $str=sprintf(
"&offset=%s&step=%s&page=%s&size=%s",
426 echo
'<FORM METHOD="POST" action="?p_action=fiche&action=vue'.$str.
'">';
428 echo dossier::hidden();
438 echo
'<TR class="odd">';
440 echo
'<TR class="even">';
442 $span_mod=
'<TD><A href="?p_action=fiche&'.$str_dossier.
443 '&action=detail&fiche_id='.$l_line[
'f_id'].$str.
'&fiche='.
447 echo $span_mod.
'<TD>'.
h($l_line[
'vw_name']).
"</TD>";
451 echo
'<FORM METHOD="POST" action="?p_action=fiche&action=vue'.$str.
'">';
453 echo dossier::hidden();
474 $class_base->set_attribute(
'ipopup',
'ipop_account');
475 $class_base->set_attribute(
'account',
'class_base');
480 $fd_description->style=
'class="itextarea" style="margin-left:0px;vertical-align:text-top"';
482 $r.=_(
'Poste Comptable de base').
' : ';
484 $r.=
'<span id="acc_label"></span><br>';
486 $r.=
" Description ".$fd_description->input();
490 $ck->selected=($this->create_account==
'f')?
false:
true;
491 $r.=_(
'Chaque fiche aura automatiquement son propre poste comptable : ');
500 if ( $this->
id == 0 )
502 $this->
cn->exec_sql(
'select fiche_attribut_synchro($1)',array($this->
id));
506 $r.=
"<tr>".th(
'Nom attribut').th(
'').th(
'Ordre',
'style="text-align:right"').
'</tr>';
509 for (
$i=0;
$i<$MaxLine;
$i++)
515 $r.=
'<TR class="'.$class.
'"><td>';
523 if (
$str ==
"remove" )
526 if ( $this->
cn->count_sql(
"select * from attr_min where frd_id=".
527 $this->fiche_def.
" and ad_id = ".$this->attribut[
$i]->ad_id) == 0
532 $add_action=sprintf(
'</TD><TD> Supprimer <input type="checkbox" name="chk_remove[]" value="%d">',
533 $this->attribut[
$i]->ad_id);
536 $add_action=
"</td><td>";
539 $a=sprintf(
'%s ', $this->attribut[
$i]->ad_text);
545 $order->name=
'jnt_order'.$this->attribut[
$i]->ad_id;
547 $order->value=$this->attribut[
$i]->jnt_order;
548 $r.=
'</td><td> '.$order->input();
555 $Res=$this->
cn->exec_sql(
"select ad_id,ad_text from attr_def
557 ad_id not in (select ad_id from fiche_def natural join jnt_fic_attr
558 where fd_id=$1) order by ad_text",array($this->
id) );
563 $r.=
'<SELECT NAME="ad_id">';
567 $a=sprintf(
'<OPTION VALUE="%s"> %s',
568 $l[
'ad_id'],
$l[
'ad_text']);
581 if ( $this->
id == 0 )
return;
583 if (strlen(trim ($p_label)) == 0 )
587 $sql=sprintf(
"update fiche_def set fd_label='%s' ".
599 if ( $this->
id == 0 )
return;
605 $sql=
"update fiche_def set fd_create_account=$1 ".
608 $Res=$this->
cn->exec_sql(
$sql,array($t,$this->
id));
616 if ( $this->
id == 0 )
return;
619 $sql=
"update fiche_def set fd_class_base=$1 ".
622 $Res=$this->
cn->exec_sql(
$sql,array($p_label,$this->
id));
626 if ( $this->
id == 0)
return;
627 $this->
cn->exec_sql(
"update fiche_def set fd_description=$1 where fd_id=$2",array($p_description,$this->
id));
637 if ( $this->
id == 0 )
return;
639 $this->GetAttribut();
642 $order = $this->
cn->get_value(
"select ad_default_order from attr_def where ad_id=$1",[$p_ad_id]);
644 $max=$this->
cn->get_value(
"select count(*) from jnt_fic_attr where fd_id=$1",[$this->
id]);
650 $sql=sprintf(
"insert into jnt_fic_attr (fd_id,ad_id,jnt_order) values (%d,%d,%d)",
651 $this->
id,$p_ad_id,
$order);
663 $sql=
"delete from jnt_fic_attr where fd_id=$1 ".
665 $this->
cn->exec_sql(
$sql,array($this->
id,$ch));
667 $sql=
"delete from fiche_detail where jft_id in ( select ".
668 " jft_id from fiche_Detail ".
669 " join fiche using(f_id) ".
673 $this->
cn->exec_sql(
$sql,array($this->
id,$ch));
685 $this->GetAttribut();
686 foreach ($this->attribut as
$row)
688 if (
$row->ad_id == 1 )
continue;
689 if ( ${
'jnt_order'.$row->ad_id} <= 0 )
continue;
690 $sql=
'update jnt_fic_attr set jnt_order=$1 where fd_id=$2 and ad_id=$3';
691 $this->
cn->exec_sql(
$sql,array(${
'jnt_order'.$row->ad_id},
697 $this->
cn->exec_sql(
'select attribute_correct_order()');
708 if ( $this->
id >= 500000 ) {
709 throw new Exception(_(
'Catégorie verrouillée '));
713 $aFiche=fiche::get_fiche_def($this->
cn,$this->
id);
714 if ( $aFiche !=
null )
717 foreach ($aFiche as $dfiche)
722 if (
$fiche->is_used() ==
false )
733 $sql=
'delete from jnt_fic_attr where fd_id=$1';
734 $this->
cn->exec_sql(
$sql,array($this->
id));
735 $sql=
'delete from fiche_def where fd_id=$1';
736 $this->
cn->exec_sql(
$sql,array($this->
id));
752 $Sql=
"select ad_id,ad_text ,ad_default_order
753 from attr_min natural join attr_def
754 natural join fiche_def_ref
756 frd_id= $1 order by ad_default_order";
757 $Res=$this->
cn->exec_sql($Sql,array($p_fiche_def_ref));
761 if ($Num == 0 )
return null;
769 $array[
$i][
'ad_default_order']=
$f[
'ad_default_order'];
780 $ret=$this->
cn->count_sql(
"select fd_id from fiche_def where frd_id=$1",array($p_frd_id));
789 $this->GetAttribut();
790 $r.=
'<H2 class="info">' . $this->
id .
" " .
h($this->
label) .
'</H2>';
791 $r.=
'<fieldset><legend>'._(
'Données générales').
'</legend>';
794 $r.=
'<form method="post">';
795 $r.=dossier::hidden();
804 $r.=
'<fieldset><legend>'._(
'Détails').
'</legend>';
806 $r.=
'<FORM id="input_detail_frm" method="POST">';
807 $r.=dossier::hidden();
812 'onclick="$(\'action\').value=\'add_line\'"');
814 'onclick="$(\'action\').value=\'save_line\'"');
816 $r.=
HtmlInput::submit(
'remove_cat_bt', _(
'Effacer cette catégorie'),
'onclick="$(\'action\').value=\'remove_cat\';return confirm_box(\'input_detail_frm\',\'' . _(
'Vous confirmez ?') .
'\')
"');
817 // if there is nothing to remove then hide the button
818 if (strpos($r, "chk_remove
") != 0)
820 $r.=HtmlInput::submit('remove_line_bt', _("Enleve les éléments cochés
"),
821 'onclick="$(\
'action\').value=\'remove_line\';return confirm_box(\'input_detail_frm\',\'' . _(
'Vous confirmez ?') .
'\')
"');
824 $r.=" <
p class=\
"notice\"> " . _(
"Attention : il n'y aura pas de demande de confirmation pour enlever les
825 attributs sélectionnés. Il ne sera pas possible de revenir en arrière") .
"</p>";
832 echo
'<form method="post" style="display:inline">';
833 echo $single->hidden();
835 echo dossier::hidden();
869 $sql=
"select 'av_text'||to_char(ad_id,'9999') as key,".
871 " from fiche_def join jnt_fic_attr using (fd_id)".
872 " join attr_def using (ad_id) ".
873 " where fd_id=$1 order by jnt_order";
874 $ret=$this->
cn->get_array(
$sql,array($this->
id));
875 if ( empty(
$ret))
throw new Exception(_(
'Cette categorie de card n\'existe pas').
' '.$this->
id,1);
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'])
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
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.
set_autocreate($p_label)
set the auto create accounting item for each card and save it into the database
save_order($p_array)
save the order of a card, update the column jnt_fic_attr.jnt_order
get_all()
Get all the fiche_def.
input_base()
show input for the basic attribute : label, class_base, create_account use only when we want to updat...
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.
navigation_bar($p_offset, $p_line, $p_size=0, $p_page=1, $p_javascript="")
Create a navigation_bar (pagesize)