noalyss Version-9
Public Member Functions
Template_Card_Category Class Reference

Manage the template of card category. More...

+ Inheritance diagram for Template_Card_Category:
+ Collaboration diagram for Template_Card_Category:

Public Member Functions

 __construct (Fiche_def_ref_SQL $p_table)
 
 add_mandatory_attr ()
 When adding a template of category of card, the minimum is the name and the quickcode, which must be added into attr_min. More...
 
 check ()
 Check before inserting or updating, return TRUE if ok otherwise FALSE. More...
 
 delete ()
 delete a datarow , the id must be have set before More...
 
 input ()
 display into a dialog box the datarow in order to be appended or modified. More...
 
- Public Member Functions inherited from Manage_Table_SQL
 __construct (Data_SQL $p_table)
 
 add_json_param ($p_attribute, $p_value)
 Add json parameter to the current one. More...
 
 ajax_delete ()
 Delete a record and return an XML answer for ajax. More...
 
 ajax_input ($p_status="OK")
 send an xml with input of the object, create an xml answer. More...
 
 ajax_save ()
 Save the record from Request into the DB and returns an XML to update the Html Element. More...
 
 can_append_row ()
 return false if the append of the row is forbidden More...
 
 can_delete_row ()
 return false if the delete of the row is forbidden More...
 
 can_update_row ()
 return false if the update of the row is forbidden More...
 
 check ()
 
 count_error ()
 returns the nb of errors found More...
 
 create_js_script ()
 we must create first the javascript if we want to update, insert or delete rows. More...
 
 delete ()
 delete a datarow , the id must be have set before More...
 
 display_error ()
 Display a list of the error collected. More...
 
 display_icon_custom ($p_row)
 usually contain a link and calls another page, it must be overriden More...
 
 display_icon_del ($p_row)
 
 display_icon_mod ($p_row)
 
 display_row ($p_row)
 display a data row in the table, with the order defined in a_order and depending of the visibility of the column, all the rows contains the attribute ctl_pk_id , to retrieve in javascript , ie with the function afterSaveFct (see managetable.js) More...
 
 display_row_custom ($p_key, $p_value, $p_id=0)
 When displaying a row, if a column has the type "custom" , we can call this function to display properly the value including the tag "<td>". More...
 
 display_table ($p_order="", $p_array=NULL)
 display the data of the table More...
 
 display_table_header ()
 display the column header excepted the not visible one and in the order defined with $this->a_order More...
 
 execute_query ($p_order="", $p_array=NULL)
 execute the query (Data_SQL.seek), called by display_table More...
 
 from_request ()
 get the data from http request strip the not update or not visible data to their initial value. More...
 
 get_button_add_top ()
 
 get_col_option ($p_key)
 add extra to column, normally class , javascript or style More...
 
 get_col_sort ()
 When adding an element , it is column we checked to insert before,. More...
 
 get_col_type ($p_key)
 return the type of a column More...
 
 get_current_pos ($p_key)
 get the position of a column More...
 
 get_current_row ()
 Return the current row printed in display_row. More...
 
 get_dialog_box ()
 
 get_dialogbox_style ()
 return the db_style More...
 
 get_error ($p_col)
 retrieve the error message More...
 
 get_header_option ($p_key)
 add extra to column Header, normally class , javascript or style More...
 
 get_icon_del ()
 
 get_icon_mod ()
 
 get_js_variable ()
 Get the object name. More...
 
 get_json ()
 
 get_object_name ()
 
 get_order ()
 
 get_property_updatable ($p_key)
 return True if the column is updatable otherwise false More...
 
 get_property_visible ($p_key)
 return True if the column is visible otherwise false More...
 
 get_search_table ()
 Get if we can search in the table. More...
 
 get_sort_column ()
 return the column to sort More...
 
 get_table ()
 
 getCssClass ()
 
 getTitle ()
 
 input ()
 display into a dialog box the datarow in order to be appended or modified. More...
 
 input_custom ($p_key, $p_value)
 this function let you create your own input , for example for a ITEXT , a IRADIO , ... it must be override , there is not default More...
 
 insert ()
 insert a new value More...
 
 move ($p_key, $p_idx)
 if we change a column order , the order of the other columns is impacted. More...
 
 param_set ($p_json)
 Set the parameter of the object (gDossier, ac, plugin_code...) @detail By default , only gDossier will be set . More...
 
 save ()
 save the Data_SQL Object The noalyss_SQL is not empty More...
 
 send_header ()
 send the XML headers for the ajax call More...
 
 set_append_row ($p_value)
 Enable or disable the appending of rows. More...
 
 set_button_add_top ($button_add_top)
 
 set_callback ($p_file)
 set the callback function that is passed to javascript More...
 
 set_col_label ($p_key, $p_display)
 set the name to display for a column More...
 
 set_col_option ($p_key, $p_value)
 add extra to column, normally class or style More...
 
 set_col_sort ($p_num)
 When adding an element ,we place it thanks the DOM Attribute sort_value set it to -1 if you want one to append. More...
 
 set_col_tips ($p_key, $p_comment)
 Set the info for a column, use Icon_Action::infobulle the message are in message_javascript.php. More...
 
 set_col_type ($p_key, $p_value, $p_array=NULL)
 set the type of a column , it will change in the input db box , the select must supply an array of possible values [val=> , label=>] with the variable $this->key_name->a_value More...
 
 set_current_row ($current_row)
 set the current row printed in display_row More...
 
 set_delete_row ($p_value)
 Enable or disable the deletion of rows. More...
 
 set_dialog_box ($dialog_box)
 
 set_dialogbox_style ($db_style)
 Dialog box style , by default {position: "fixed", top: '15', width: "auto", "margin-left": "20%"}. More...
 
 set_error ($p_col, $p_message)
 set the error message for a wrong input More...
 
 set_header_option ($p_key, $p_value)
 add extra to column Header, normally class or style More...
 
 set_icon_del ($pString)
 Set the icon to delete at the right or left of the row. More...
 
 set_icon_mod ($pString)
 Set the icon to modify at the right ,the first col or left of the row, if the mod if custom , you have to override the function display_icon_custom. More...
 
 set_json ($p_json)
 Set the parameter of the object (gDossier, ac, plugin_code...) @detail By default , only gDossier will be set . More...
 
 set_object_name ($p_object_name)
 Set the object_name. More...
 
 set_order ($p_order)
 
 set_pk ($p_id)
 set the id value of a data row and load from the db More...
 
 set_property_updatable ($p_key, $p_value)
 set a column of the data row updatable or not More...
 
 set_property_visible ($p_key, $p_value)
 set a column of the data row visible or not More...
 
 set_search_table ($search_table)
 Set the table searchable or not. More...
 
 set_sort_column ($p_col)
 set the column to sort by default More...
 
 set_table (Data_SQL $p_noalyss_sql)
 
 set_update_row ($p_value)
 Enable or disable the updating of rows. More...
 
 set_value ($p_key, $p_value)
 
 setCssClass ($p_class)
 
 setTitle ($p_title)
 Set the title of the diabox , default is Donnée. More...
 
 show_error ($p_col)
 
 update ()
 

Additional Inherited Members

- Data Fields inherited from Manage_Table_SQL
const UPDATABLE =1
 
const VISIBLE =2
 
- Protected Attributes inherited from Manage_Table_SQL
 $a_col_option
 in display_row and display_custom_row, it is the current row which is used More...
 
 $a_header_option
 Extra to add to the column Header : CSS Style , CSS class, javascript ,... More...
 
 $a_info
 Array with the infotip. More...
 
 $a_label_displaid
 Label of the col. of the datarow. More...
 
 $a_order
 order of the col More...
 
 $a_prop
 property for each col. More...
 
 $a_select
 Possible value if a_type is a SELECT. More...
 
 $a_type
 Type of the column : date , select ... Only in input. More...
 
 $aerror
 Array containing the error of the input data. More...
 
 $button_add_top
 place of the button add on the top, by default true More...
 
 $callback
 Callback function. More...
 
 $col_sort
 when inserting, it is the column to sort,-1 to disable it and append only More...
 
 $cssclass
 < give the title of the diabox , default is Data More...
 
 $current_row
 CSS class for the dialog box. More...
 
 $dialog_box
 ID of the dialog box which display the result of the ajax calls. More...
 
 $dialogbox_style
 style of the dialog box More...
 
 $icon_del
 place of right or left the icon update or mod, default right, accepted value=left,right More...
 
 $icon_mod
 place of right or left the icon update or mod, default right, accepted value=left,right,first,custom column for mod More...
 
 $json_parameter
 Default parameter to add (gDossier...), sent to the ajax callback. More...
 
 $object_name
 Object_name is used for the javascript , it is the row id to update or delete. More...
 
 $row_append
 Flag to indicate if rows can be added. More...
 
 $row_delete
 Flag to indicate if rows can be deleted. More...
 
 $row_update
 Flag to indicate if rows can be updated. More...
 
 $search_table
 boolean , by default true ,it is possible to search in the table, More...
 
 $sort_column
 javascript sort on this column , if empty there is no js sort More...
 
 $table
 Object Data_SQL. More...
 
 $title
 

Detailed Description

Manage the template of card category.

Definition at line 33 of file template_card_category.class.php.

Constructor & Destructor Documentation

◆ __construct()

Template_Card_Category::__construct ( Fiche_def_ref_SQL  $p_table)

Definition at line 36 of file template_card_category.class.php.

37 {
38 $this->table=$p_table;
39 parent::__construct($p_table);
40 // Label of the columns
41 $this->set_col_label("frd_text", _("Nom"));
42 $this->set_col_label("frd_class_base", _("Poste comptable de base"));
43 $this->set_col_label("frd_id", _("ID"));
44 // Cannot update frd_id
45 $this->set_property_updatable("frd_id", FALSE);
46 $this->a_order=["frd_id", "frd_text", "frd_class_base"];
47 }
set_property_updatable($p_key, $p_value)
set a column of the data row updatable or not
set_col_label($p_key, $p_display)
set the name to display for a column
$all table

References Manage_Table_SQL\set_col_label(), Manage_Table_SQL\set_property_updatable(), and table.

+ Here is the call graph for this function:

Member Function Documentation

◆ add_mandatory_attr()

Template_Card_Category::add_mandatory_attr ( )

When adding a template of category of card, the minimum is the name and the quickcode, which must be added into attr_min.

Definition at line 204 of file template_card_category.class.php.

205 {
207 $frd_id=$this->get_table()->getp("frd_id");
208 $cn->exec_sql("insert into attr_min (frd_id,ad_id) values ($1,$2)",
210 $cn->exec_sql("insert into attr_min (frd_id,ad_id) values ($1,$2)",
212 }
static connect()
const ATTR_DEF_NAME
Definition: constant.php:216
const ATTR_DEF_QUICKCODE
Definition: constant.php:237

References $cn, $frd_id, ATTR_DEF_NAME, ATTR_DEF_QUICKCODE, Dossier\connect(), and Manage_Table_SQL\get_table().

+ Here is the call graph for this function:

◆ check()

Template_Card_Category::check ( )

Check before inserting or updating, return TRUE if ok otherwise FALSE.

Returns
boolean

Reimplemented from Manage_Table_SQL.

Definition at line 66 of file template_card_category.class.php.

67 {
69 $error=0;
70 if (trim($this->table->frd_text)=="")
71 {
72 $this->set_error("frd_text", _("Le nom ne peut pas être vide"));
73 $error++;
74 }
75 if (trim($this->table->frd_class_base)!="")
76 {
77 $cnt=$cn->get_value("select count(*) from tmp_pcmn where pcm_val=$1"
78 , [$this->table->frd_class_base]);
79 if ($cnt==0)
80 {
81 $this->set_error("frd_class_base",
82 _("Poste comptable n'existe pas"));
83 $error++;
84 }
85 }
86
87 if ($error!=0)
88 {
89 return false;
90 }
91 return true;
92 }
set_error($p_col, $p_message)
set the error message for a wrong input

References $cn, $error, Dossier\connect(), Manage_Table_SQL\set_error(), and table.

+ Here is the call graph for this function:

◆ delete()

Template_Card_Category::delete ( )

delete a datarow , the id must be have set before

See also
from_request

Reimplemented from Manage_Table_SQL.

Definition at line 49 of file template_card_category.class.php.

50 {
52
53 if ($cn->get_value("select count(*) from fiche_def where frd_id=$1",
54 [$this->table->frd_id])>0)
55 {
56 throw new Exception(_("Effacement impossible : catégorie utilisée"));
57 }
58 $cn->exec_sql("delete from attr_min where frd_id=$1",[$this->table->frd_id]);
59 $this->table->delete();
60 }

References $cn, Dossier\connect(), and table.

+ Here is the call graph for this function:

◆ input()

Template_Card_Category::input ( )

display into a dialog box the datarow in order to be appended or modified.

Can be override if you need a more complex form

Add / Remove attribut Minimum

Reimplemented from Manage_Table_SQL.

Definition at line 99 of file template_card_category.class.php.

100 {
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);
110
111 $frd_id=HtmlInput::hidden("frd_id",$this->get_table()->getp("frd_id"));
112 $name=new IText("frd_text",$this->get_table()->getp("frd_text"));
113 $account=new IPoste("frd_class_base",$this->get_table()->getp("frd_class_base"));
114 $account->set_attribute('gDossier',Dossier::id());
115 $account->set_attribute('jrn',0);
116 $account->set_attribute('account','frd_class_base');
117 $name_label=_("Nom");
118 $account_label=_("Poste comptable de base");
119 echo <<<EOF
120 <table>
121 <tbody>
122 <tr>
123 <td> ID </td>
124 <td>{$frd_id}{$this->get_table()->getp("frd_id")}</td>
125 </tr>
126 <tr>
127 <td> {$name_label} {$error_name}</td>
128 <td>
129 {$name->input()}
130 </td>
131 </tr>
132 <tr>
133 <td> {$account_label} {$error_account}</td>
134 <td>
135 {$account->input()}
136 </td>
137 </tr>
138 </tbody>
139 </table>
140EOF;
141 echo HtmlInput::get_to_hidden(["gDossier","op","p_id"]);
142 /**
143 * Add / Remove attribut Minimum
144 */
145 if ($this->table->frd_id!=-1)
146 {
147 echo h2(_("Attribut minimum pour les catégories de fiches"));
150 $objname=$this->get_object_name();
151 $a_attribut=$cn->get_array("select ad_id,ad_text,ad_type from attr_min join attr_def using (ad_id) where frd_id=$1 order by 2",
152 [$this->table->frd_id]);
153 $nb_attribut=count($a_attribut);
154 printf('<ul 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]);
157 if ($used!=0)
158 {
159 echo _("Catégorie utilisée, les attributs ne peuvent pas être modifiés");
160 }
161 for ($i=0; $i<$nb_attribut; $i++)
162 {
163 printf('<li id="%s_elt%d">', $objname
164 , $a_attribut[$i]['ad_id']);
165 echo $a_attribut[$i]['ad_text'];
166 // cannot delete NAME and QUICKCODE + attribute used in a
167 if (!in_array($a_attribut[$i]['ad_id'], [ATTR_DEF_NAME, ATTR_DEF_QUICKCODE])&&$used==0)
168 {
169 // allow to remove attribute
170 $js=sprintf("category_card.remove_attribut('%s','%s','%s',%d)",
171 Dossier::id(), $this->table->frd_id, $objname, $a_attribut[$i]['ad_id']);
172 echo Icon_Action::trash(uniqid(), $js);
173 }
174 echo '</li>';
175 }
176 echo '</ul>';
177 // Add some attribute if not used
178 if ($used==0)
179 {
180 $sel_attribut=new ISelect("sel".$this->get_object_name());
181 $sel_attribut->value=$cn->make_array("select ad_id,ad_text
182 from attr_def
183 where
184 not exists (select 1
185 from
186 attr_min
187 where
188 frd_id=$1 and ad_id=attr_def.ad_id)", NULL,
189 [$this->table->frd_id]);
190 echo _("Attribut à ajouter");
191 echo $sel_attribut->input();
192 $js_script=sprintf("category_card.add_attribut('%s','%s','%s')",
193 $dossier_id, $this->table->frd_id, $objname);
194 echo Icon_Action::icon_add(uniqid(), $js_script);
195 }
196 }
197
198 }
h2($p_string, $p_class="", $raw="")
Definition: ac_common.php:68
hi($p_string)
Definition: ac_common.php:48
tr($p_string, $p_extra='')
Definition: ac_common.php:88
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
$dossier_id
Definition: ajax_poste.php:43
static id()
return the 'gDossier' value after a check
static hidden($p_name, $p_value, $p_id="")
static errorbulle($p_comment)
static get_to_hidden($array)
transform $_GET data to hidden
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...
Html Input.
Definition: itext.class.php:30
static icon_add($id, $p_javascript, $p_style="")
static trash($p_id, $p_javascript)
Display the icon of a trashbin.
get_error($p_col)
retrieve the error message

References $account, $cn, $dossier_id, $frd_id, $i, $js, $name, $objname, ATTR_DEF_NAME, ATTR_DEF_QUICKCODE, Dossier\connect(), HtmlInput\errorbulle(), Manage_Table_SQL\get_error(), Manage_Table_SQL\get_object_name(), Manage_Table_SQL\get_table(), HtmlInput\get_to_hidden(), h2(), hi(), HtmlInput\hidden(), Icon_Action\icon_add(), Dossier\id(), table, td(), tr(), and Icon_Action\trash().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: