noalyss Version-9
Public Member Functions | Private Attributes
Action_Document_Type_MTable Class Reference

display , modify and add document_type for follow up More...

+ Inheritance diagram for Action_Document_Type_MTable:
+ Collaboration diagram for Action_Document_Type_MTable:

Public Member Functions

 __construct (Document_type_SQL $doc_type)
 
 check ()
 
 delete ()
 
 from_request ()
 
 input ()
 display the box for adding, the name for p_id , are in the form More...
 
 save ()
 save 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 ()
 

Private Attributes

 $other
 Other value. More...
 

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

display , modify and add document_type for follow up

See also
include/ajax/ajax_cfgaction.php
include/cfg_action.inc.php

Definition at line 34 of file action_document_type_mtable.class.php.

Constructor & Destructor Documentation

◆ __construct()

Action_Document_Type_MTable::__construct ( Document_type_SQL  $doc_type)

Definition at line 39 of file action_document_type_mtable.class.php.

40 {
41 parent::__construct($doc_type);
42 $this->set_order(["dt_id", "dt_prefix", "dt_value",]);
43 $this->set_property_updatable("dt_id", false);
44 $this->set_property_visible("dt_id", false);
45 $this->set_property_updatable("dt_value", true);
46 $this->set_property_updatable("dt_prefix", true);
47 $this->set_col_label("dt_value", _("Nom"));
48 $this->set_col_label("dt_prefix", _("Préfixe document"));
49 $this->other=array();
50 }
catch(Exception $ex) $doc_type
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_col_label($p_key, $p_display)
set the name to display for a column

References $doc_type, Manage_Table_SQL\set_col_label(), 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()

Action_Document_Type_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

Reimplemented from Manage_Table_SQL.

Definition at line 102 of file action_document_type_mtable.class.php.

103 {
104 $table=$this->get_table();
105 $error=0;
106 if (empty(trim($table->dt_value)))
107 {
108 $this->set_error("dt_value", _("Nom ne peut être vide"));
109 $error++;
110 }
111 if (empty(trim($table->dt_prefix)))
112 {
113 $this->set_error("dt_prefix", _("Préfixe ne peut être vide"));
114 $error++;
115 }
116 // Check doublon
117 if ($table->cn->get_value('select count(*) from document_type where upper(dt_value)=upper($1) and dt_id <> $2',
118 [$table->dt_value, $table->dt_id])>0)
119 {
120 $this->set_error("dt_value", _("Doublon, ce nom existe déjà "));
121 $error++;
122 }
123 // Check doublon
124 if ($table->cn->get_value('select count(*) from document_type where upper(dt_prefix)=upper($1) and dt_id <> $2',
125 [$table->dt_prefix, $table->dt_id])>0)
126 {
127 $this->set_error("dt_value", _("Doublon, ce préfixe existe déjà "));
128 $error++;
129 }
130 if ($error>0)
131 {
132 return false;
133 }
134 return true;
135 }

References $error, Manage_Table_SQL\$table, Manage_Table_SQL\get_table(), and Manage_Table_SQL\set_error().

+ Here is the call graph for this function:

◆ delete()

Action_Document_Type_MTable::delete ( )
Exceptions
Exception

Reimplemented from Manage_Table_SQL.

Definition at line 141 of file action_document_type_mtable.class.php.

142 {
143 $table=$this->get_table();
144 try
145 {
146 // remove the cat if no action
147 $count_md=$table->cn->get_value('select count(*) from document_modele where md_type=$1',
148 array($table->dt_id));
149 $count_a=$table->cn->get_value('select count(*) from action_gestion where ag_type=$1', array($table->dt_id));
150
151 if ($count_md!=0||$count_a!=0)
152 {
153 throw new Exception(_('Des actions dépendent de cette catégorie'), 1300);
154 }
155 $table->delete();
156 }
157 catch (Exception $exc)
158 {
159 if ($exc->getCode()!=1300)
160 {
161 record_log("ADTM01".$exc->getTrace());
162 }
163 throw new Exception($exc->getMessage());
164 }
165 }
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342

References Manage_Table_SQL\$table, Manage_Table_SQL\get_table(), and record_log().

+ Here is the call graph for this function:

◆ from_request()

Action_Document_Type_MTable::from_request ( )
table "public.document_type"
ctl_id "dtr"
gDossier "74"
op "cfgaction"
p_id "28"
action "save"
ctl "tbl5f785d403b123"
dt_prefix "ABO.HEB"
dt_value "Abonnements+PhpCompta"
seq "0"
det_op "1"
det_contact_mul "1"
update "OK"
$profile p_id
$all table

Reimplemented from Manage_Table_SQL.

Definition at line 73 of file action_document_type_mtable.class.php.

74 {
75 $http=new HttpInput();
76 $this->table->dt_value=$http->request('dt_value');
77 $this->table->dt_prefix=$http->request('dt_prefix');
78 $this->other['detail_operation']=$http->request("detail_operation", "string", 0);
79 $this->other['contact_multiple']=$http->request("det_contact_mul", "string", 0);
80 $this->other['make_invoice']=$http->request("make_invoice", "string", 0);
81 $this->other['make_feenote']=$http->request("make_feenote", "string", 0);
82 $this->other['followup_comment']=$http->request("followup_comment", "string", 0);
83 $this->other['editable_description']=$http->request("editable_description", "string", 0);
84 $this->other['enable_followup']=$http->request("enable_followup", "string", 0);
85 $this->other['seq']=$http->request("seq", "string", 0);
86 $this->other['select_option_operation']=$http->request("select_option_operation", "string", null);
87 $this->other['select_comment']=$http->request("select_comment", "string", null);
88 $this->other['videoconf_server']=$http->request('videoconf_server',"string",0);
89 $this->other['videoconf_server_url']=$http->request('videoconf_server_url',"string",DEFAULT_SERVER_VIDEO_CONF);
90 $this->other["cor_id"]=$http->request("cor_id","array",[]);
91 $nb_corid=count($this->other["cor_id"]);
92 $http->set_empty(0);
93 for ($i=0;$i<$nb_corid;$i++) {
94 $this->other["contact_option$i"]=$http->request("contact_option".$i,"number",0);
95 }
96
97 }
manage the http input (get , post, request) and extract from an array

References $http, $i, and table.

◆ input()

Action_Document_Type_MTable::input ( )

display the box for adding, the name for p_id , are in the form

Reimplemented from Manage_Table_SQL.

Definition at line 170 of file action_document_type_mtable.class.php.

171 {
172 parent::input();
173
174
175
176 // Detail option contact
177 $table=$this->get_table();
178 $cn=$table->cn;
179 try
180 {
181 $cn->start();
182 if ( $table->dt_id == -1 ){
183 $aOption=$cn->get_array("select cor_id,cor_label,cor_type,-1 document_type_id,0 jdoc_enable
184 from
185 contact_option_ref cor
186 order by cor_label");
187
188 } else {
189 // insert new contact options
190 $cn->exec_sql("insert into jnt_document_option_contact (jdoc_enable,document_type_id,
191 contact_option_ref_id)
192 select 0 , $1, cor_id
193 from contact_option_ref
194 where
195 cor_id not in (select cor_id from
196 jnt_document_option_contact a
197 where a.document_type_id=$1)", [$table->dt_id]);
198
199 // Select all
200 $aOption=$cn->get_array("select cor_id,cor_label,cor_type,document_type_id ,coalesce(jdoc_enable,0) jdoc_enable
201 from
202 contact_option_ref cor
203 left join jnt_document_option_contact jdoc on (cor_id=contact_option_ref_id)
204 where
205 document_type_id is null
206 or document_type_id = $1
207 order by cor_label", [$this->table->dt_id]);
208
209 // delete unused option by the action_person_
210 $cn->exec_sql("delete from action_person_option where ap_id in (select apo.ap_id
211 from action_person a
212 left join action_person_option apo ON (a.ap_id=apo.action_person_id)
213 left join contact_option_ref cor on (apo.contact_option_ref_id=cor.cor_id)
214 join action_gestion ag on (a.ag_id=ag.ag_id)
215 where
216 cor.cor_id not in (select jdoc2.contact_option_ref_id
217 from jnt_document_option_contact jdoc2
218 where jdoc2.document_type_id =$1
219 and jdoc2.jdoc_enable =1));
220 ",[$table->dt_id]);
221 }
222
223 // Detail option
224 require NOALYSS_TEMPLATE."/action_document_type_mtable_input.php";
225 $cn->commit();
226 }
227 catch (Exception $exc)
228 {
229 $cn->rollback();
230
231 echo $exc->getMessage();
232 error_log($exc->getTraceAsString());
233 }
234
235 }
for($i=0;$i< $nb;$i++) $aOption

References $aOption, $cn, Manage_Table_SQL\$table, Manage_Table_SQL\get_table(), and table.

+ Here is the call graph for this function:

◆ save()

Action_Document_Type_MTable::save ( )

save

Reimplemented from Manage_Table_SQL.

Definition at line 240 of file action_document_type_mtable.class.php.

241 {
242 parent::save();
244 $object_sql=$this->get_table();
245 // restart sequence
246 if ($this->other['seq']!=0)
247 {
248 $doc_type=new Document_type($cn, $object_sql->dt_id);
249 $doc_type->set_number($this->other['seq']);
250 }
251 // Save detail operation
252 $cn->exec_sql("insert into document_option (do_code,document_type_id,do_enable,do_option) values ($1,$2,$3,$4)
253 on conflict on constraint document_option_un
254 do update set do_enable=$3,do_option=$4",
255 [ "detail_operation",
256 $object_sql->dt_id,
257 $this->other['detail_operation'],
258 $this->other['select_option_operation']
259 ]);
260
261 // Save contact_multiple
262 $cn->exec_sql("insert into document_option (do_code,document_type_id,do_enable) values ($1,$2,$3)
263 on conflict on constraint document_option_un
264 do update set do_enable=$3 ", ["contact_multiple", $object_sql->dt_id, $this->other['contact_multiple']]);
265
266 // Save editable description
267 $cn->exec_sql("insert into document_option (do_code,document_type_id,do_enable) values ($1,$2,$3)
268 on conflict on constraint document_option_un
269 do update set do_enable=$3 ", ["editable_description", $object_sql->dt_id
270 , $this->other['editable_description']]);
271
272 // Save make invoice
273 $cn->exec_sql("insert into document_option (do_code,document_type_id,do_enable) values ($1,$2,$3)
274 on conflict on constraint document_option_un
275 do update set do_enable=$3 ", ["make_invoice", $object_sql->dt_id, $this->other['make_invoice']]);
276
277 // Save make feenote
278 $cn->exec_sql("insert into document_option (do_code,document_type_id,do_enable) values ($1,$2,$3)
279 on conflict on constraint document_option_un
280 do update set do_enable=$3 ", ["make_feenote", $object_sql->dt_id, $this->other['make_feenote']]);
281
282 // Option for comments
283 $cn->exec_sql("insert into document_option (do_code,document_type_id,do_enable,do_option) values ($1,$2,$3,$4)
284 on conflict on constraint document_option_un
285 do update set do_enable=$3,do_option=$4 ",
286 [ "followup_comment",
287 $object_sql->dt_id,
288 $this->other['followup_comment'],
289 $this->other['select_comment']
290 ]);
291
292 // Save videoconf setting
293 if ( $this->other['videoconf_server'] == 1 && trim($this->other['videoconf_server_url'])=="") {
294 $this->other['videoconf_server_url']=DEFAULT_SERVER_VIDEO_CONF;
295 }
296 $cn->exec_sql("insert into document_option (do_code,document_type_id,do_enable,do_option) values ($1,$2,$3,$4)
297 on conflict on constraint document_option_un
298 do update set do_enable=$3,do_option=$4 ",
299 [ "videoconf_server",
300 $object_sql->dt_id,
301 $this->other['videoconf_server'],
302 $this->other['videoconf_server_url']
303 ]);
304
305 // Option contact to save
306 $cn->exec_sql("delete from jnt_document_option_contact where document_type_id=$1",[$object_sql->dt_id]);
307 $nb_contact_option=count($this->other["cor_id"]);
308 $aOption=$this->other["cor_id"];
309 for ( $e=0;$e<$nb_contact_option;$e++) {
310 $option_id=$aOption[$e];
311 if ( isset($this->other["contact_option".$e]) ) {
312 $cn->exec_sql("insert into jnt_document_option_contact
313 (jdoc_enable,document_type_id,contact_option_ref_id)
314 values ($1,$2,$3)",[$this->other["contact_option".$e],$object_sql->dt_id,$option_id]);
315 }
316 }
317
318
319 }
static connect()

References $aOption, $cn, $doc_type, $e, Dossier\connect(), and Manage_Table_SQL\get_table().

+ Here is the call graph for this function:

Field Documentation

◆ $other

Action_Document_Type_MTable::$other
private

Other value.

Definition at line 37 of file action_document_type_mtable.class.php.


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