22require_once NOALYSS_INCLUDE.
'/database/fiche_def_ref_sql.class.php';
38 $this->
table=$p_table;
39 parent::__construct($p_table);
42 $this->
set_col_label(
"frd_class_base",
_(
"Poste comptable de base"));
46 $this->a_order=[
"frd_id",
"frd_text",
"frd_class_base"];
51 $cn=Dossier::connect();
53 if (
$cn->get_value(
"select count(*) from fiche_def where frd_id=$1",
54 [$this->table->frd_id])>0)
56 throw new Exception(
_(
"Effacement impossible : catégorie utilisée"));
58 $cn->exec_sql(
"delete from attr_min where frd_id=$1",[$this->
table->frd_id]);
59 $this->
table->delete();
68 $cn=Dossier::connect();
70 if (trim($this->
table->frd_text)==
"")
72 $this->
set_error(
"frd_text",
_(
"Le nom ne peut pas être vide"));
75 if (trim($this->
table->frd_class_base)!=
"")
77 $cnt=
$cn->get_value(
"select count(*) from tmp_pcmn where pcm_val=$1"
78 , [$this->
table->frd_class_base]);
82 _(
"Poste comptable n'existe pas"));
101 echo
"<br><font color=\"red\"> ";
102 echo
_(
"Attention, ne pas changer la signification de ce poste.");
103 echo
hi(
_(
"par exemple ne pas changer Client par fournisseur")).
"<br>";
104 echo
_(
"sinon le programme fonctionnera mal, ".
105 "utiliser uniquement des chiffres pour la classe de base ou rien").
"</font>";
106 $error_name=$this->
get_error(
"frd_text");
107 $error_account=$this->
get_error(
"frd_class_base");
108 $error_name=($error_name==
"")?
"":HtmlInput::errorbulle($error_name);
109 $error_account=($error_account==
"")?
"":HtmlInput::errorbulle($error_account);
114 $account->set_attribute(
'gDossier',Dossier::id());
116 $account->set_attribute(
'account',
'frd_class_base');
117 $name_label=
_(
"Nom");
118 $account_label=
_(
"Poste comptable de base");
127 <
td> {$name_label} {$error_name}</
td>
133 <
td> {$account_label} {$error_account}</
td>
141 echo HtmlInput::get_to_hidden([
"gDossier",
"op",
"p_id"]);
145 if ($this->
table->frd_id!=-1)
147 echo
h2(
_(
"Attribut minimum pour les catégories de fiches"));
148 $cn=Dossier::connect();
151 $a_attribut=
$cn->get_array(
"select ad_id,ad_text,ad_type,a1.ad_default_order from attr_min a1 join attr_def using (ad_id) where frd_id=$1 order by a1.ad_default_order",
152 [$this->
table->frd_id]);
153 $nb_attribut=count($a_attribut);
154 printf(
'<ul class="list-unstyled" style="width: 60%%;margin-left: 21%%" id="%s_list"> ',
$objname);
155 $used=
$cn->get_value(
"select count(*) from jnt_fic_attr join fiche_def using (fd_id) where frd_id=$1",
156 [$this->
table->frd_id]);
159 echo_warning(
_(
"Catégorie utilisée, les attributs de base ne peuvent pas être modifiés"));
161 echo
_(
"Vous pouvez modifier l'ordre des attributs avec la souris");
162 for (
$i=0;
$i<$nb_attribut;
$i++)
164 printf(
'<li id="%s_elt%d" style="cursor:move;border:1px solid navy;padding : 0.5rem 0.2rem 0.5rem 0.2rem;margin-top:2px">',
$objname
165 , $a_attribut[
$i][
'ad_id']);
166 echo $a_attribut[
$i][
'ad_text'];
171 $js=sprintf(
"category_card.remove_attribut('%s','%s','%s',%d)",
172 Dossier::id(), $this->
table->frd_id,
$objname, $a_attribut[
$i][
'ad_id']);
182 $sel_attribut->value=
$cn->make_array(
"select ad_id,ad_text
189 frd_id=$1 and ad_id=attr_def.ad_id)", NULL,
190 [$this->
table->frd_id]);
191 echo
_(
"Attribut à ajouter");
192 echo $sel_attribut->input();
193 $js_script=sprintf(
"category_card.add_attribut('%s','%s','%s')",
197 echo \HtmlInput::hidden(
"attribut_order",
"");
199 onUpdate:function(){document.getElementById('attribut_order').value=Sortable.serialize('{$objname}_list')}})");
210 $cn=Dossier::connect();
212 $cn->exec_sql(
"insert into attr_min (frd_id,ad_id,ad_default_order) values ($1,$2,$3)",
214 $cn->exec_sql(
"insert into attr_min (frd_id,ad_id,ad_default_order) values ($1,$2,$3)",
229 $attribut_order=
$http->post(
'attribut_order',
'string',
'');
230 if ($attribut_order==
'')
return;
231 parse_str($attribut_order,$aOrder);
232 if ( isset($aOrder[
$ctl])) {
234 foreach( $aOrder[
$ctl] as $item) {
235 $ad_id = str_replace(
'elt',
'',$item);
236 $cn->exec_sql(
"update attr_min set ad_default_order = $1 where ad_id=$2 and frd_id=$3",
h2($p_string, $p_class="", $raw="")
echo_warning($p_string)
warns
tr($p_string, $p_extra='')
td($p_string='', $p_extra='')
surround the string with td
_("actif, passif,charge,...")
ORM Manage the table public.fiche_def_ref , which concerns the template of category of card.
show a button, for selecting a account and a input text for manually inserting an account the differe...
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
static icon_add($id, $p_javascript, $p_style="")
static trash($p_id, $p_javascript)
Display the icon of a trashbin.
Purpose is to propose a librairy to display a table content and allow to update and delete row ,...
set_property_updatable($p_key, $p_value)
set a column of the data row updatable or not
get_error($p_col)
retrieve the error message
set_error($p_col, $p_message)
set the error message for a wrong input
set_col_label($p_key, $p_display)
set the name to display for a column
Manage the template of card category.
save()
save also the order
input()
display into a dialog box the datarow in order to be appended or modified.
__construct(Fiche_def_ref_SQL $p_table)
check()
Check before inserting or updating, return TRUE if ok otherwise FALSE.
add_mandatory_attr()
When adding a template of category of card, the minimum is the name and the quickcode,...
create_script($p_string)
create the HTML for adding the script tags around of the script