20 require_once NOALYSS_INCLUDE.
'/class/class_fiche_attr.php';
21 require_once NOALYSS_INCLUDE.
'/lib/class_itext.php';
22 require_once NOALYSS_INCLUDE.
'/class/class_fiche_def_ref.php';
23 require_once NOALYSS_INCLUDE.
'/class/class_fiche.php';
24 require_once NOALYSS_INCLUDE.
'/lib/user_common.php';
25 require_once NOALYSS_INCLUDE.
'/lib/class_iradio.php';
54 $ref=$this->
cn->get_array(
"select * from fiche_def_ref order by frd_text");
58 $class_base->set_attribute(
'ipopup',
'ipop_account');
62 $fd_description=
new ITextarea(
'fd_description');
63 $fd_description->width=80;
64 $fd_description->heigh=4;
65 $fd_description->style=
'class="itextarea" style="margin-left:0px;vertical-align:text-top"';
66 require_once NOALYSS_TEMPLATE.
'/fiche_def_input.php';
77 $sql=
"select * from jnt_fic_attr ".
78 " natural join attr_def where fd_id=".$this->id.
79 " order by jnt_order";
85 for ($i=0;$i <
$Max;$i++)
89 $t->ad_id=
$row[
'ad_id'];
90 $t->ad_text=
$row[
'ad_text'];
91 $t->jnt_order=
$row[
'jnt_order'];
92 $t->ad_size=
$row[
'ad_size'];
93 $t->ad_type=
$row[
'ad_type'];
94 $t->ad_extra=
$row[
'ad_extra'];
95 $this->attribut[$i]=
clone $t;
106 if ( $this->
id == 0 )
111 $sql=
"select * from fiche_def ".
112 " where fd_id=".$this->id;
118 $this->class_base=
$row[
'fd_class_base'];
119 $this->fiche_def=
$row[
'frd_id'];
120 $this->create_account=
$row[
'fd_create_account'];
121 $this->fd_description=
$row[
'fd_description'];
131 $sql=
"select * from fiche_def ";
137 for ( $i = 0; $i <
$Max;$i++)
141 $this->all[$i]->label=
$row[
'fd_label'];
142 $this->all[$i]->class_base=
$row[
'fd_class_base'];
143 $this->all[$i]->fiche_def=
$row[
'frd_id'];
144 $this->all[$i]->create_account=
$row[
'fd_create_account'];
158 return ($this->
cn->count_sql(
"select * from vw_fiche_def where ad_id=$p_attr and fd_id=".$this->id)>0)?
true:
false;
172 $tab->add(_(
"Nom de fiche"),
$url,
"order by fd_label asc",
"order by fd_label desc",
"na",
"nd");
173 $tab->add(_(
"Basé sur le poste comptable"),
$url,
"order by fd_class_base asc",
"order by fd_class_base desc",
"pa",
"pd");
174 $tab->add(_(
"Calcul automatique du poste comptable"),
$url,
"order by fd_create_account asc",
"order by fd_create_account desc",
"ca",
"cd");
175 $tab->add(_(
"Basé sur le modèle"),
$url,
"order by frd_text asc",
"order by frd_text desc",
"ma",
"md");
180 $res = $this->
cn->exec_sql(
"SELECT fd_id, fd_class_base, fd_label, fd_create_account, fiche_def_ref.frd_id,
181 frd_text , fd_description FROM fiche_def join fiche_def_ref on (fiche_def.frd_id=fiche_def_ref.frd_id)
185 require_once NOALYSS_TEMPLATE.
'/fiche_def_list.php';
210 if ( ! isset ($p_fd_description)) {
211 $p_fd_description=
"";
218 if ( strlen(
trim($p_nom_mod)) == 0 )
220 alert (_(
'Le nom de la catégorie ne peut pas être vide'));
224 if ( strlen(
trim($p_fiche_def)) == 0 )
226 alert (_(
'Un modéle de catégorie est obligatoire'));
231 $sql=
"select count(*) from fiche_Def where upper(fd_label)=upper($1)";
235 echo
alert (_(
'Catégorie existante'));
240 if ( $p_create ==
"on" && strlen(
trim($p_class_base)) != 0)
246 if (
sql_string($p_class_base) != null || ( $p_class_base !=
'' && strpos(
',',$p_class_base) != 0 ))
249 $sql=
"insert into fiche_def(fd_label,fd_class_base,frd_id,fd_create_account,fd_description)
250 values ($1,$2,$3,$4,$5) returning fd_id";
252 $fd_id=$this->
cn->get_value(
$sql,array($p_nom_mod,$p_class_base,$p_fiche_def,$p_create,$p_fd_description));
255 if ( strpos(
',',$p_class_base) ==0)
257 $sql=
"select account_add($1,$2)";
258 $Res=$this->
cn->exec_sql(
$sql,array($p_class_base,$p_nom_mod));
261 $fd_id=$this->
cn->get_current_seq(
's_fdef');
264 $sql=sprintf(
"insert into jnt_fic_attr(fd_id,ad_id,jnt_order)
271 $sql=
"insert into fiche_def(fd_label,frd_id,fd_create_account,fd_description) values ($1,$2,$3,$4) returning fd_id";
274 $this->
id=$this->
cn->get_value(
$sql,array($p_nom_mod,$p_fiche_def,$p_create,$p_fd_description));
277 $fd_id=$this->
cn->get_current_seq(
's_fdef');
286 if (
sizeof($def_attr) != 0 )
290 foreach ( $def_attr as $i=>$v)
295 $count=$this->
cn->get_value(
"select count(*) from jnt_fic_attr where fd_id=$1 and ad_id=$2",array(
$fd_id,$v[
'ad_id']));
298 $sql=sprintf(
"insert into jnt_fic_Attr(fd_id,ad_id,jnt_order)
301 $this->
cn->exec_sql(
$sql);
320 $sql=
"select f_id,ad_value
322 fiche join fiche_detail using(f_id)
323 where ad_id=1 and fd_id=$1 order by 2";
326 if (
$step == 1 && $_SESSION[
'g_pagesize'] != -1 )
329 $step=$_SESSION[
'g_pagesize'];
330 $sql.=
" offset $offset limit $step";
333 $Ret=$this->
cn->get_array(
$sql,array($this->
id));
343 $sql=
"select f_id,ad_value
345 fiche join fiche_def using(fd_id)
346 join fiche_detail using(f_id)
347 where ad_id=1 and frd_id=$1 order by 2 ";
354 for ($i=0;$i<
$Max;$i++)
370 echo
'<H2 class="info">'.$this->id.
" ".$this->
label.
'</H2>';
372 $step=$_SESSION[
'g_pagesize'];
381 $max_line=$this->
cn->count_sql(
"select f_id,ad_value from
382 fiche join fiche_detail using (f_id)
383 where fd_id='".$this->
id.
"' and ad_id=".
ATTR_DEF_NAME.
" order by f_id");
384 $sql_limit=
" limit ".$step;
385 $sql_offset=
" offset ".$offset;
391 $Res=$this->
cn->exec_sql(
"select f_id,vw_name,quick_code from ".
393 " where fd_id='".$this->
id.
394 "' order by f_id $sql_offset $sql_limit ");
400 if ( $_SESSION[
'g_pagesize'] != -1)
402 $str=sprintf(
"&offset=%s&step=%s&page=%s&size=%s",
410 echo
'<FORM METHOD="POST" action="?p_action=fiche&action=vue'.$str.
'">';
412 echo dossier::hidden();
418 for ( $i = 0; $i <
$Max; $i++)
422 echo
'<TR class="odd">';
424 echo
'<TR class="even">';
426 $span_mod=
'<TD><A href="?p_action=fiche&'.$str_dossier.
427 '&action=detail&fiche_id='.$l_line[
'f_id'].$str.
'&fiche='.
431 echo $span_mod.
'<TD>'.
h($l_line[
'vw_name']).
"</TD>";
435 echo
'<FORM METHOD="POST" action="?p_action=fiche&action=vue'.$str.
'">';
437 echo dossier::hidden();
458 $class_base->set_attribute(
'ipopup',
'ipop_account');
459 $class_base->set_attribute(
'account',
'class_base');
461 $fd_description=
new ITextarea(
'fd_description',$this->fd_description);
462 $fd_description->width=80;
463 $fd_description->heigh=4;
464 $fd_description->style=
'class="itextarea" style="margin-left:0px;vertical-align:text-top"';
466 $r.=_(
'Poste Comptable de base').
' : ';
468 $r.=
'<span id="acc_label"></span><br>';
470 $r.=
" Description ".$fd_description->input();
474 $ck->selected=($this->create_account==
'f')?
false:
true;
475 $r.=_(
'Chaque fiche aura automatiquement son propre poste comptable : ');
484 if ( $this->
id == 0 )
486 $this->
cn->exec_sql(
'select fiche_attribut_synchro($1)',array($this->
id));
490 $r.=
"<tr>".th(
'Nom attribut').th(
'').th(
'Ordre',
'style="text-align:right"').
'</tr>';
493 for ($i=0;$i<$MaxLine;$i++)
499 $r.=
'<TR class="'.$class.
'"><td>';
507 if (
$str ==
"remove" )
510 if ( $this->
cn->count_sql(
"select * from attr_min where frd_id=".
511 $this->fiche_def.
" and ad_id = ".$this->attribut[$i]->ad_id) == 0
516 $add_action=sprintf(
'</TD><TD> Supprimer <input type="checkbox" name="chk_remove[]" value="%d">',
517 $this->attribut[$i]->ad_id);
520 $add_action=
"</td><td>";
523 $a=sprintf(
'%s ', $this->attribut[$i]->ad_text);
529 $order->name=
'jnt_order'.$this->attribut[$i]->ad_id;
531 $order->value=$this->attribut[$i]->jnt_order;
532 $r.=
'</td><td> '.$order->input();
539 $Res=$this->
cn->exec_sql(
"select ad_id,ad_text from attr_def
541 ad_id not in (select ad_id from fiche_def natural join jnt_fic_attr
542 where fd_id=$1) order by ad_text",array($this->
id) );
547 $r.=
'<SELECT NAME="ad_id">';
548 for ($i=0;$i<$M;$i++)
551 $a=sprintf(
'<OPTION VALUE="%s"> %s',
552 $l[
'ad_id'],
$l[
'ad_text']);
565 if ( $this->
id == 0 )
return;
567 if (strlen(
trim ($p_label)) == 0 )
571 $sql=sprintf(
"update fiche_def set fd_label='%s' ".
583 if ( $this->
id == 0 )
return;
589 $sql=
"update fiche_def set fd_create_account=$1 ".
592 $Res=$this->
cn->exec_sql(
$sql,array($t,$this->
id));
600 if ( $this->
id == 0 )
return;
603 $sql=
"update fiche_def set fd_class_base=$1 ".
606 $Res=$this->
cn->exec_sql(
$sql,array($p_label,$this->
id));
610 if ( $this->
id == 0)
return;
611 $this->
cn->exec_sql(
"update fiche_def set fd_description=$1 where fd_id=$2",array($p_description,$this->
id));
620 if ( $this->
id == 0 )
return;
622 $this->GetAttribut();
626 $sql=sprintf(
"insert into jnt_fic_attr (fd_id,ad_id,jnt_order) values (%d,%d,%d)",
627 $this->
id,$p_ad_id,
$max);
639 $sql=
"delete from jnt_fic_attr where fd_id=$1 ".
641 $this->
cn->exec_sql(
$sql,array($this->
id,$ch));
643 $sql=
"delete from fiche_detail where jft_id in ( select ".
644 " jft_id from fiche_Detail ".
645 " join fiche using(f_id) ".
649 $this->
cn->exec_sql(
$sql,array($this->
id,$ch));
661 $this->GetAttribut();
662 foreach ($this->attribut as
$row)
664 if ( $row->ad_id == 1 )
continue;
665 if ( ${
'jnt_order'.$row->ad_id} <= 0 )
continue;
666 $sql=
'update jnt_fic_attr set jnt_order=$1 where fd_id=$2 and ad_id=$3';
667 $this->
cn->exec_sql(
$sql,array(${
'jnt_order'.$row->ad_id},
673 $this->
cn->exec_sql(
'select attribute_correct_order()');
684 if ( $this->
id >= 500000 ) {
685 throw new Exception(_(
'Catégorie verrouillée '));
689 $aFiche=fiche::get_fiche_def($this->
cn,$this->
id);
690 if ( $aFiche != null )
693 foreach ($aFiche as $dfiche)
709 $sql=
'delete from jnt_fic_attr where fd_id=$1';
710 $this->
cn->exec_sql(
$sql,array($this->
id));
711 $sql=
'delete from fiche_def where fd_id=$1';
712 $this->
cn->exec_sql(
$sql,array($this->
id));
728 $Sql=
"select ad_id,ad_text from attr_min natural join attr_def
729 natural join fiche_def_ref
732 $Res=$this->
cn->exec_sql($Sql,array($p_fiche_def_ref));
736 if ($Num == 0 )
return null;
739 for ($i=0;$i<$Num;$i++)
743 $array[$i][
'ad_text']=
$f[
'ad_text'];
754 $ret=$this->
cn->count_sql(
"select fd_id from fiche_def where frd_id=$1",array($p_frd_id));
763 $this->GetAttribut();
764 $r.=
'<H2 class="info">' . $this->
id .
" " .
h($this->
label) .
'</H2>';
765 $r.=
'<fieldset><legend>'._(
'Données générales').
'</legend>';
768 $r.=
'<form method="post">';
769 $r.=dossier::hidden();
778 $r.=
'<fieldset><legend>'._(
'Détails').
'</legend>';
780 $r.=
'<FORM id="input_detail_frm" method="POST">';
781 $r.=dossier::hidden();
786 'onclick="$(\'action\').value=\'add_line\'"');
788 'onclick="$(\'action\').value=\'save_line\'"');
790 $r.=
HtmlInput::submit(
'remove_cat_bt', _(
'Effacer cette catégorie'),
'onclick="$(\'action\').value=\'remove_cat\';return confirm_box(\'input_detail_frm\',\'' . _(
'Vous confirmez ?') .
'\')
"');
791 // if there is nothing to remove then hide the button
792 if (strpos($r, "chk_remove
") != 0)
794 $r.=HtmlInput::submit('remove_line_bt', _("Enleve les éléments cochés
"),
795 'onclick="$(\
'action\').value=\'remove_line\';return confirm_box(\'input_detail_frm\',\'' . _(
'Vous confirmez ?') .
'\')
"');
798 $r.=" <p
class=\
"notice\"> " . _(
"Attention : il n'y aura pas de demande de confirmation pour enlever les
799 attributs sélectionnés. Il ne sera pas possible de revenir en arrière") .
"</p>";
806 echo
'<form method="post" style="display:inline">';
807 echo $single->hidden();
809 echo dossier::hidden();
alert($p_msg, $buffer=false)
alert in javascript
save_order($p_array)
save the order of a card, update the column jnt_fic_attr.jnt_order
__construct($p_cn, $p_id=0)
sql_string($p_string)
Fix the problem with the quote char for the database.
myList()
list the card of a fd_id
save_class_base($p_label)
Save the class base.
define Class fiche and fiche def, those class are using class attribut
static num_row($ret)
wrapper for the function pg_NumRows
input_base()
show input for the basic attribute : label, class_base, create_account use only when we want to updat...
Manage the table attr_def.
show a button, for selecting a account and a input text for manually inserting an account the differe...
set_autocreate($p_label)
set the auto create accounting item for each card and save it into the database
SaveLabel($p_label)
Save the label of the fiche_def.
input()
show the content of the form to create a new Fiche_Def_Ref
get_attr_min($p_fiche_def_ref)
retrieve the mandatory field of the card model
count_category($p_frd_id)
count the number of fiche_def (category) which has the frd_id (type of category)
save_description($p_description)
static fetch_array($ret, $p_indice=0)
wrapper for the function pg_fetch_array
navigation_bar($p_offset, $p_line, $p_size=0, $p_page=1, $p_javascript="")
Create a navigation_bar (pagesize)
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Display()
Display category into a table.
RemoveAttribut($array)
remove an attribut for this fiche_def
InsertAttribut($p_ad_id)
insert a new attribut for this fiche_def
function trim(s)
remove trailing and heading space
get_all()
Get all the fiche_def.
h($p_string)
to protect again bad characters which can lead to a cross scripting attack the string to be diplayed ...
Description of class_syn_sort_table.
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.
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.
Objec to check a double insert into the database, this duplicate occurs after a refresh of the web pa...
HasAttribute($p_attr)
Check in vw_fiche_def if a fiche has a attribut X.