noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
Card_Attribut_MTable Class Reference

manage the table attr_def More...

+ Inheritance diagram for Card_Attribut_MTable:
+ Collaboration diagram for Card_Attribut_MTable:

Public Member Functions

 __construct (\Data_SQL $p_table)
 
 check ()
 
 delete ()
 delete a datarow , the id must be have set before
 
 display_row ($row)
 Display row of table attr_def.
 
 display_row_custom ($p_key, $p_value, $p_id=0)
 For the type custom , we can call a function to display properly the value.
 
 input_custom ($p_key, $p_value)
 For the type custom , we can call a function to display properly the value.
 
- 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_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 ()
 display into a dialog box the datarow in order to be appended or modified.
 
 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 .
 
 save ()
 save the Data_SQL Object The noalyss_SQL is not empty
 
 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 ()
 

Data Fields

 $dossier_id
 
- Data Fields inherited from Manage_Table_SQL
const UPDATABLE =1
 
const VISIBLE =2
 

Additional Inherited Members

- 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 table attr_def

See also
card_attr.inc.php

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

Constructor & Destructor Documentation

◆ __construct()

Card_Attribut_MTable::__construct ( \Data_SQL $p_table)

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

37 {
38 parent::__construct($p_table);
39 $this->set_property_visible("ad_id", TRUE);
40 $this->set_property_updatable("ad_id", FALSE);
41 $this->set_col_label("ad_text", _("Nom"));
42 $this->set_col_label("ad_type", _("Type"));
43 $this->set_col_label("ad_size", _("Taille"));
44 $this->set_col_label('ad_default_order', _("Ordre"));
45 $this->set_col_label("ad_extra", _("Option sup."));
46 $this->set_col_label("ad_search_followup", _("Recherche suivi"));
47
48 $this->set_col_type("ad_search_followup", "custom");
49 $this->set_col_type("ad_text", "custom");
50 $this->set_col_type("ad_size", "numeric");
51 $this->set_col_type("ad_extra", "custom");
52 $this->set_col_type("ad_type", "select",
53 array(
54 ["value"=>"text", "label"=>_("Texte")],
55 ["value"=>"date", "label"=>_("Date")],
56 ["value"=>"numeric", "label"=>_("Nombre")],
57 ["value"=>"select", "label"=>_("Choix")],
58 ["value"=>"card", "label"=>_("Fiche")],
59 ["value"=>"zone", "label"=>_("Zone de texte")],
60 ["value"=>"check", "label"=>_("Coche")],
61 ["value"=>"poste", "label"=>_("Poste comptable")]
62 ));
63 $this->set_col_tips("ad_search_followup", 77);
64 // to prevent a call to this function for each row
65 $this->dossier_id=Dossier::id();
66 $this->set_order(['ad_id','ad_text',"ad_type","ad_default_order","ad_size","ad_extra","ad_search_followup"]);
67 $this->set_col_sort(1);
68 }
_("actif, passif,charge,...")
static id()
return the 'gDossier' value after a check
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 ...
set_property_updatable($p_key, $p_value)
set a column of the data row updatable or not
set_col_tips($p_key, $p_comment)
Set the info for a column, use Icon_Action\infobulle the message are in message_javascript....
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 po...
set_property_visible($p_key, $p_value)
set a column of the data row visible or not
set_col_label($p_key, $p_display)
set the name to display for a column

References _, Manage_Table_SQL\set_col_label(), Manage_Table_SQL\set_col_sort(), Manage_Table_SQL\set_col_tips(), Manage_Table_SQL\set_col_type(), Manage_Table_SQL\set_order(), Manage_Table_SQL\set_property_updatable(), and Manage_Table_SQL\set_property_visible().

+ Here is the call graph for this function:

Member Function Documentation

◆ check()

Card_Attribut_MTable::check ( )
   @brief This function can be overrided to check the data before 
   inserting , updating or removing, above an example of an overidden check.

   Usually , you get the row of the table (get_table) , you check the conditions
   if an condition is not met then you set the error with $this->set_error 

   if there are error (returns false otherwise true

   @see set_error get_error count_error
   @return boolean
function check()
{
global $cn;
$table=$this->get_table();
$is_error=0;
$insert=false;
// sect_codename must be unique
if ( $table->exist() > 0) {
$insert=1;
}
$count=$cn->get_value(" select count(*) from syndicat.treasurer where tr_login=$1 and sect_id=$2 and tr_id<>$3",
array(
$table->tr_login,
$table->section_full_name,
$table->tr_id
));
if ($count > 0 ) {
$this->set_error("section_full_name",_("Ce trésorier a déjà accès à cette section"));
$is_error++;
}
if ( $is_error > 0 ) return false;
return true;
}
set_error($p_col, $p_message)
set the error message for a wrong input
$count
$table
Definition menu.inc.php:104

Reimplemented from Manage_Table_SQL.

Definition at line 163 of file card_attribut_mtable.class.php.

164 {
165 $object_sql=$this->get_table();
166
167 if ($object_sql->get("ad_id")<9000&&$object_sql->get("ad_id")!=-1)
168 {
169 $this->set_error("ad_id", _("Bloqué"));
170 }
171
172 // Duplicate
173 $count="select count(*)
174 from attr_def as ad1
175 where
176 upper(trim(ad1.ad_text)) = upper(trim($1))
177 and ad1.ad_id != $2
178 ";
179 $count_duplicate=$object_sql->cn->get_value($count, [$object_sql->ad_text, $object_sql->ad_id]);
180 if ($count_duplicate>0)
181 {
182 $this->set_error("ad_text", _("Doublon"));
183 }
184 // type
185 if (in_array($object_sql->get("ad_type"),
186 array('date', 'text', 'numeric', 'zone', 'poste', 'card', 'select', 'check'))==false)
187 {
188 $this->set_error("ad_type", _("Type invalide"));
189 }
190
191 // Name empty
192 if (trim($object_sql->ad_text)=="")
193 {
194 $this->set_error("ad_text", _("Description ne peut pas être vide"));
195 }
196 // select protect
197 if ($object_sql->ad_size=="")
198 {
199 $object_sql->ad_size=22;
200 }
201 if ($object_sql->ad_type=='numeric')
202 {
203 $object_sql->ad_extra=(trim($object_sql->ad_extra)=='')?'2':$object_sql->ad_extra;
204 if (isNumber($object_sql->ad_extra)==0)
205 {
206 $this->set_error("ad_text", _("La précision doit être un chiffre"));
207 }
208 }
209
210 if ($object_sql->ad_type=='select')
211 {
212 if (trim($object_sql->ad_extra)=="")
213 {
214
215 $this->set_error("ad_extra", _("La requête SQL est vide "));
216 }
217 $cn= $this->get_table()->cn;
218 $cn->start();
219 try {
220 // remove SQL command like insert , delete , update, truncate , drop
221 $sql=$object_sql->ad_extra;
222 $sql=str_ireplace("delete", "del.ete", $sql);
223 $sql=str_ireplace("insert", "del.ete", $sql);
224 $sql=str_ireplace("update", "del.ete", $sql);
225 $sql=str_ireplace("truncate", "del.ete", $sql);
226 $sql=str_ireplace("drop", "del.ete", $sql);
227 $cn->exec_sql($sql);
228
229 } catch (\Exception $e) {
230 $this->set_error("ad_extra", _("ERREUR SQL : ")
231 .$object_sql->ad_extra);
232 } finally {
233 $cn->rollback();
234 }
235
236
237 if (preg_match('/^\h*select/i', $object_sql->ad_extra)==0)
238 {
239
240 }
241 }
242 if ( $object_sql->ad_default_order < 11 || $object_sql->ad_default_order > 9998) {
243 $this->set_error("ad_default_order",_("Valeur entre 11 et 9998"));
244 }
245 if ($this->count_error()>0)
246 {
247 return false;
248 }
249 return true;
250 }
isNumber($p_int)
count_error()
returns the nb of errors found

References $cn, $count, $e, $sql, _, Manage_Table_SQL\count_error(), Manage_Table_SQL\get_table(), isNumber(), and Manage_Table_SQL\set_error().

+ Here is the call graph for this function:

◆ delete()

Card_Attribut_MTable::delete ( )

delete a datarow , the id must be have set before

See also
from_request

Reimplemented from Manage_Table_SQL.

Definition at line 252 of file card_attribut_mtable.class.php.

253 {
254 $object_sql=$this->get_table();
255
256 if ($object_sql->getp("ad_id")<9000)
257 {
258 throw new Exception(_("Effacement bloqué"));
259 }
260
261 $db=$object_sql->cn;
262 try
263 {
264 $db->start();
265 $sql=$db->exec_sql("delete from fiche_detail where ad_id=$1 ", array($object_sql->ad_id));
266
267 $sql="delete from jnt_fic_attr where ad_id=$1";
268 $res=$db->exec_sql($sql, array($object_sql->ad_id));
269
270 $sql="delete from attr_def where ad_id=$1";
271 $res=$db->exec_sql($sql, array($object_sql->ad_id));
272
273 $object_sql=$this->get_table()->delete();
274 $db->commit();
275 }
276 catch (Exception $ex)
277 {
278 $db->rollback();
279 throw new Exception(_("Effacement bloqué : attribut utilisé"));
280 }
281 }
$ex

References $ex, $res, $sql, _, and Manage_Table_SQL\get_table().

+ Here is the call graph for this function:

◆ display_row()

Card_Attribut_MTable::display_row ( $row)

Display row of table attr_def.

Parameters
array$row

Reimplemented from Manage_Table_SQL.

Definition at line 74 of file card_attribut_mtable.class.php.

75 {
76 tracedebug("card_attribute.log", $row);
77 if ($row['ad_id']>=9000)
78 {
79 $this->set_delete_row(TRUE);
80 $this->set_update_row(TRUE);
81 }
82 else
83 {
84 $this->set_delete_row(FALSE);
85 $this->set_update_row(FALSE);
86 }
87
88 parent::display_row($row);
89 }
set_delete_row($p_value)
Enable or disable the deletion of rows.
set_update_row($p_value)
Enable or disable the updating of rows.

References $row, Manage_Table_SQL\set_delete_row(), and Manage_Table_SQL\set_update_row().

+ Here is the call graph for this function:

◆ display_row_custom()

Card_Attribut_MTable::display_row_custom ( $p_key,
$p_value,
$p_id = 0 )

For the type custom , we can call a function to display properly the value.

Parameters
$p_keystring key name
$p_valuestring value
See also
input_custom
set_type
Note
must return a string which will be in surrounded by td in the function display_row
Returns
string

Reimplemented from Manage_Table_SQL.

Definition at line 100 of file card_attribut_mtable.class.php.

101 {
102 if ($p_key=="ad_search_followup")
103 {
104 $ic=new Inplace_Switch(uniqid("search_follow_up"), $p_value);
105 $ic->set_callback("ajax_misc.php");
106 $ic->add_json_param("op", "card");
107 $ic->add_json_param("gDossier", $this->dossier_id);
108 $ic->add_json_param("op2", "attribute");
109 $ic->add_json_param("action", "enable_search");
110 $ic->add_json_param("ad_id", $p_id);
111 $ic->add_json_param("ctl", $p_id);
112 $ret=$ic->input();
113
114 return td($ret);
115 }
116 if ($p_key=="ad_text")
117 {
118 return td($p_value);
119 }
120 if ($p_key=="ad_extra")
121 {
122 return td($p_value);
123 }
124 return;
125 }
td($p_string='', $p_extra='')
surround the string with td
Definition ac_common.php:83

References $p_id, $ret, and td().

+ Here is the call graph for this function:

◆ input_custom()

Card_Attribut_MTable::input_custom ( $p_key,
$p_value )

For the type custom , we can call a function to display properly the value.

Parameters
$p_keystring key name
$p_valuestring value
See also
input_custom
set_type
Note
must return a string which will be in surrounded by td in the function display_row
Returns
string

Bug in firefox if id=ad_text , the widget is not displaid

Reimplemented from Manage_Table_SQL.

Definition at line 136 of file card_attribut_mtable.class.php.

137 {
138 if ($p_key=="ad_search_followup")
139 {
140 $p_id=$this->get_table()->get("ad_id");
141 $ic=new InputSwitch("ad_search_followup", $p_value);
142 echo $ic->input();
143 }
144 elseif ($p_key=="ad_text")
145 {
146 /**
147 * Bug in firefox if id=ad_text , the widget is not displaid
148 */
149 $text=new IText("ad_text", $p_value);
150 $text->id=uniqid();
151 echo $text->input();
152 }
153 elseif ($p_key=="ad_extra")
154 {
155 $text=new ITextarea("ad_extra", $p_value);
156 $text->id=uniqid();
157 echo $text->input();
158 }
159 echo "";
160 return;
161 }
if( $delta< 0) elseif( $delta==0)

References $p_id, $text, elseif, and Manage_Table_SQL\get_table().

+ Here is the call graph for this function:

Field Documentation

◆ $dossier_id

Card_Attribut_MTable::$dossier_id

Definition at line 35 of file card_attribut_mtable.class.php.


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