noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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.
 
 check ()
 Check before inserting or updating, return TRUE if ok otherwise FALSE.
 
 delete ()
 delete a datarow , the id must be have set before
 
 input ()
 display into a dialog box the datarow in order to be appended or modified.
 
 save ()
 save also the order
 
- 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.
 
 ajax_delete ()
 Delete a record and return an XML answer for ajax.
 
 ajax_input ($p_status="OK")
 send an xml with input of the object, create an xml answer.
 
 ajax_save ()
 Save the record from Request into the DB and returns an XML to update the Html Element.
 
 can_append_row ()
 return false if the append of the row is forbidden
 
 can_delete_row ()
 return false if the delete of the row is forbidden
 
 can_update_row ()
 return false if the update of the row is forbidden
 
 count_error ()
 returns the nb of errors found
 
 create_js_script ()
 we must create first the javascript if we want to update, insert or delete rows.
 
 display_error ()
 Display a list of the error collected.
 
 display_icon_custom ($p_row)
 usually contain a link and calls another page, it must be overriden
 
 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)
 
 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>".
 
 display_table ($p_order="", $p_array=NULL)
 display the data of the table
 
 display_table_header ()
 display the column header excepted the not visible one and in the order defined with $this->a_order
 
 execute_query ($p_order="", $p_array=NULL)
 execute the query (Data_SQL.seek), called by display_table
 
 from_request ()
 get the data from http request strip the not update or not visible data to their initial value.
 
 get_button_add_top ()
 
 get_col_option ($p_key)
 add extra to column, normally class , javascript or style
 
 get_col_sort ()
 When adding an element , it is column we checked to insert before,.
 
 get_col_type ($p_key)
 return the type of a column
 
 get_current_pos ($p_key)
 get the position of a column
 
 get_current_row ()
 Return the current row printed in display_row.
 
 get_dialog_box ()
 
 get_dialogbox_style ()
 return the db_style
 
 get_error ($p_col)
 retrieve the error message
 
 get_header_option ($p_key)
 add extra to column Header, normally class , javascript or style
 
 get_icon_del ()
 
 get_icon_mod ()
 
 get_js_variable ()
 Get the object name.
 
 get_json ()
 
 get_object_name ()
 
 get_order ()
 
 get_property_updatable ($p_key)
 return True if the column is updatable otherwise false
 
 get_property_visible ($p_key)
 return True if the column is visible otherwise false
 
 get_search_table ()
 Get if we can search in the table.
 
 get_sort_column ()
 return the column to sort
 
 get_table ()
 
 getCssClass ()
 
 getTitle ()
 
 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
 
 insert ()
 insert a new value
 
 move ($p_key, $p_idx)
 if we change a column order , the order of the other columns is impacted.
 
 param_set ($p_json)
 Set the parameter of the object (gDossier, ac, plugin_code...) @detail By default , only gDossier will be set .
 
 send_header ()
 send the XML headers for the ajax call
 
 set_append_row ($p_value)
 Enable or disable the appending of rows.
 
 set_button_add_top ($button_add_top)
 
 set_callback ($p_file)
 set the callback function that is passed to javascript
 
 set_col_label ($p_key, $p_display)
 set the name to display for a column
 
 set_col_option ($p_key, $p_value)
 add extra to column, normally class or style
 
 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.
 
 set_col_tips ($p_key, $p_comment)
 Set the info for a column, use Icon_Action\infobulle the message are in message_javascript.php.
 
 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
 
 set_current_row ($current_row)
 set the current row printed in display_row
 
 set_delete_row ($p_value)
 Enable or disable the deletion of rows.
 
 set_dialog_box ($dialog_box)
 
 set_dialogbox_style ($db_style)
 Dialog box style , by default {position: "fixed", top: '15', width: "auto", "margin-left": "20%"}.
 
 set_error ($p_col, $p_message)
 set the error message for a wrong input
 
 set_header_option ($p_key, $p_value)
 add extra to column Header, normally class or style
 
 set_icon_del ($pString)
 Set the icon to delete at the right or left of the row.
 
 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.
 
 set_json ($p_json)
 Set the parameter of the object (gDossier, ac, plugin_code...) @detail By default , only gDossier will be set .
 
 set_object_name ($p_object_name)
 Set the object_name.
 
 set_order ($p_order)
 
 set_pk ($p_id)
 set the id value of a data row and load from the db
 
 set_property_updatable ($p_key, $p_value)
 set a column of the data row updatable or not
 
 set_property_visible ($p_key, $p_value)
 set a column of the data row visible or not
 
 set_search_table ($search_table)
 Set the table searchable or not.
 
 set_sort_column ($p_col)
 set the column to sort by default
 
 set_table (Data_SQL $p_noalyss_sql)
 
 set_update_row ($p_value)
 Enable or disable the updating of rows.
 
 set_value ($p_key, $p_value)
 
 setCssClass ($p_class)
 
 setTitle ($p_title)
 Set the title of the diabox , default is Donnée.
 
 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
 
 $a_header_option
 Extra to add to the column Header : CSS Style , CSS class, javascript ,...
 
 $a_info
 Array with the infotip.
 
 $a_label_displaid
 Label of the col. of the datarow.
 
 $a_order
 order of the col
 
 $a_prop
 property for each col.
 
 $a_select
 Possible value if a_type is a SELECT.
 
 $a_type
 Type of the column : date , select ... Only in input.
 
 $aerror
 Array containing the error of the input data.
 
 $button_add_top
 place of the button add on the top, by default true
 
 $callback
 Callback function.
 
 $col_sort
 when inserting, it is the column to sort,-1 to disable it and append only
 
 $cssclass
 < give the title of the diabox , default is Data
 
 $current_row
 CSS class for the dialog box.
 
 $dialog_box
 ID of the dialog box which display the result of the ajax calls.
 
 $dialogbox_style
 style of the dialog box
 
 $icon_del
 place of right or left the icon update or mod, default right, accepted value=left,right
 
 $icon_mod
 place of right or left the icon update or mod, default right, accepted value=left,right,first,custom column for mod
 
 $json_parameter
 Default parameter to add (gDossier...), sent to the ajax callback.
 
 $object_name
 Object_name is used for the javascript , it is the row id to update or delete.
 
 $row_append
 Flag to indicate if rows can be added.
 
 $row_delete
 Flag to indicate if rows can be deleted.
 
 $row_update
 Flag to indicate if rows can be updated.
 
 $search_table
 boolean , by default true ,it is possible to search in the table,
 
 $sort_column
 javascript sort on this column , if empty there is no js sort
 
 $table
 Object Data_SQL.
 
 $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 }
_("actif, passif,charge,...")
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 208 of file template_card_category.class.php.

209 {
211 $frd_id=$this->get_table()->getp("frd_id");
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)",
215 [$frd_id, ATTR_DEF_QUICKCODE,10000]);
216 }
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, 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, _, 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, _, and table.

◆ 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,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]);
157 if ($used!=0)
158 {
159 echo_warning( _("Catégorie utilisée, les attributs de base ne peuvent pas être modifiés"));
160 }
161 echo _("Vous pouvez modifier l'ordre des attributs avec la souris");
162 for ($i=0; $i<$nb_attribut; $i++)
163 {
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'];
167 // cannot delete NAME and QUICKCODE + attribute used in a
168 if (!in_array($a_attribut[$i]['ad_id'], [ATTR_DEF_NAME, ATTR_DEF_QUICKCODE])&&$used==0)
169 {
170 // allow to remove attribute
171 $js=sprintf("category_card.remove_attribut('%s','%s','%s',%d)",
172 Dossier::id(), $this->table->frd_id, $objname, $a_attribut[$i]['ad_id']);
173 echo Icon_Action::trash(uniqid(), $js);
174 }
175 echo '</li>';
176 }
177 echo '</ul>';
178 // Add some attribute if not used
179 if ($used==0)
180 {
181 $sel_attribut=new ISelect("sel".$this->get_object_name());
182 $sel_attribut->value=$cn->make_array("select ad_id,ad_text
183 from attr_def
184 where
185 not exists (select 1
186 from
187 attr_min
188 where
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')",
194 $dossier_id, $this->table->frd_id, $objname);
195 echo Icon_Action::icon_add(uniqid(), $js_script);
196 }
197 echo \HtmlInput::hidden("attribut_order", "");
198 echo create_script("Sortable.create('{$objname}_list',{
199 onUpdate:function(){document.getElementById('attribut_order').value=Sortable.serialize('{$objname}_list')}})");
200 }
201
202 }
h2($p_string, $p_class="", $raw="")
Definition ac_common.php:68
hi($p_string)
Definition ac_common.php:48
echo_warning($p_string)
warns
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
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
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
create_script($p_string)
create the HTML for adding the script tags around of the script

References $account, $cn, $dossier_id, $frd_id, $i, $js, $name, $objname, _, ATTR_DEF_NAME, ATTR_DEF_QUICKCODE, create_script(), echo_warning(), Manage_Table_SQL\get_error(), Manage_Table_SQL\get_object_name(), Manage_Table_SQL\get_table(), h2(), hi(), Icon_Action\icon_add(), table, td(), tr(), and Icon_Action\trash().

+ Here is the call graph for this function:

◆ save()

Template_Card_Category::save ( )

save also the order

Returns
void

Reimplemented from Manage_Table_SQL.

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

223 {
224 parent::save();
225 $cn=$this->get_table()->get_cn();
226 $table_sql=$this->get_table();
227 $http=new HttpInput();
228 $ctl=$http->request("ctl")."_list";
229 $attribut_order=$http->post('attribut_order','string','');
230 if ($attribut_order=='') return;
231 parse_str($attribut_order,$aOrder);
232 if ( isset($aOrder[$ctl])) {
233 $order = 10;
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",
237 [$order,$ad_id,$table_sql->get('frd_id')]);
238 $order+=10;
239 }
240 }
241
242 }

References $ad_id, $cn, $ctl, $http, $order, and Manage_Table_SQL\get_table().

+ Here is the call graph for this function:

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