noalyss  Version-9
Public Member Functions
Acc_Plan_MTable Class Reference

this instance extends Manage_Table_SQL and aims to manage the Table tmp_pcmn thanks a web interface (add , delete, display...) More...

+ Inheritance diagram for Acc_Plan_MTable:
+ Collaboration diagram for Acc_Plan_MTable:

Public Member Functions

 __construct (Acc_Plan_SQL $p_table)
 
 check ()
 Check that the entered data are valid before recording them into tmp_pcmn, the errors are stored into this->a_error and if someting wrong is found it returns false, if the data can be saved it returns true. More...
 
 display_row ($p_row)
 Display a row. More...
 
 input ()
 display into a dialog box the datarow in order to be appended or modified. More...
 
 input_custom ($p_key, $p_value)
 if pcm_val already used then it cannot be 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...
 
 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_del ($p_row)
 
 display_icon_mod ($p_row)
 
 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 ()
 
 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. 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_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...
 
 $col_sort
 when inserting, it is the column to sort,-1 to disable it and append only More...
 
 $dialog_box
 ID of the dialog box which display the result of the ajax calls. 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

this instance extends Manage_Table_SQL and aims to manage the Table tmp_pcmn thanks a web interface (add , delete, display...)

See also
Acc_Plan_SQL

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

Constructor & Destructor Documentation

◆ __construct()

Acc_Plan_MTable::__construct ( Acc_Plan_SQL  $p_table)

Definition at line 42 of file acc_plan_mtable.class.php.

77  {

Member Function Documentation

◆ check()

Acc_Plan_MTable::check ( )

Check that the entered data are valid before recording them into tmp_pcmn, the errors are stored into this->a_error and if someting wrong is found it returns false, if the data can be saved it returns true.

Returns
return false if an error is found,

Check that the parent accounting does exist

check that accounting is not already used

Reimplemented from Manage_Table_SQL.

Definition at line 166 of file acc_plan_mtable.class.php.

166  {
167  $this->set_error("pcm_val", _("Poste comptable est unique"));
168  }
169  if ( trim($this->table->pcm_val) == "") {
170  $this->set_error("pcm_val", _("Poste comptable ne peut être vide"));
171  }
172  // Check size
173  if ( strlen(trim($this->table->pcm_val)) > 40) {
174  $this->set_error("pcm_val", _("Poste comptable trop long"));
175  }
176  if ( trim($this->table->parent_accounting) == "") {
177  $this->set_error("parent_accounting", _("Poste comptable dépendant ne peut pas être vide"));
178  }
179  /**
180  * Check that the parent accounting does exist
181  */
182  $exist_parent=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = $1 ",
183  array($this->table->parent_accounting));
184  if ($exist_parent == 0) {
185  $this->set_error("parent_accounting", _("Compte parent n'existe pas"));
186  }
187  /**
188  * check that accounting is not already used
189  */
190  $old_accounting = $cn->get_value("select pcm_val from tmp_pcmn where id = $1",
191  array($this->table->id));
192  // it is not a new accounting and is different
193  if ($old_accounting != "" && $old_accounting != $this->table->pcm_val) {
194  // count it is used
195  if ($cn->get_value("select count(*) from jrnx where j_poste=$1",
196  [$old_accounting]) > 0) {
197  $this->set_error("pcm_val", _("Poste utilisé"));
198  }
199  }
200  if (count($this->aerror) > 0) return false;
201  return true;
202  }
203 
204  /**
205  * @brief display into a dialog box the datarow in order
206  * to be appended or modified. Can be override if you need
207  * a more complex form

References Manage_Table_SQL\set_error().

+ Here is the call graph for this function:

◆ display_row()

Acc_Plan_MTable::display_row (   $p_row)

Display a row.

Parameters
type$p_rowarray of value key column=>value

Reimplemented from Manage_Table_SQL.

Definition at line 81 of file acc_plan_mtable.class.php.

86  {
87  $v=$this->a_order[$i];
88  $nb=0;
90  $nb_used=$cn->get_value("select count(*) from jrnx where j_poste=$1",[$p_row['pcm_val']]);
91  $nb_plan=$cn->get_value("select count(*) from tmp_pcmn where pcm_val_parent=$1",[$p_row['pcm_val']]);
92  $nb=$nb_used+$nb_plan;
93  if ($v=="pcm_val")
94  {
95  $js=sprintf("onclick=\"%s.input('%s','%s');\"", $this->object_name,
96  $p_row[$this->table->primary_key], $this->object_name);
97  echo sprintf('<td sort_type="text" sort_value="X%s">%s',
98  htmlspecialchars($p_row[$v]),
99  HtmlInput::anchor($p_row[$v], "", $js)).
100  '</td>';
101  }
102  elseif ($v == "fiche_qcode") {
103  $count=$this->table->cn->get_value("select count(*) from fiche_detail where ad_id=5 and ad_value=$1",array($p_row['pcm_val']));
104  if ($count == 0) echo td("");
105  elseif ($count == 1 ) {
106  echo '<td>';
107  echo HtmlInput::card_detail($p_row[$v]) ;
108  echo '</td>';
109 
110  }
111  elseif ($count > 1) {
112  echo '<td>';
113  $a_code=explode(",",$p_row[$v]);
114  $nb_code=count($a_code);
115  for ($xx = 0;$xx < $nb_code;$xx++)
116  {
117  echo HtmlInput::card_detail($a_code[$xx])."," ;
118  }
119  echo " ($count) ";
120  echo Icon_Action::more(uniqid(), sprintf("display_all_card('%s','%s')",$dossier_id,$p_row["pcm_val"]));
121  echo '</td>';
122 
123  }
124  }
125  elseif ($v=="pcm_lib")
126  {
127 
128  if ( $nb >0){
129  echo "<td>";
130  if ($nb_used > 0) {
131  $used=sprintf (' (%s)',$nb_used);
132  echo HtmlInput::history_account($p_row['pcm_val'],h($p_row["pcm_lib"].$used));
133  } else {
134  echo h($p_row["pcm_lib"]);
135  }
136  echo "</td>";
137  } else {
138  echo td($p_row[$v]);
139  }
140 
141  }
142  else
143  {
144  if ( ! $this->get_property_visible($v)) continue;
145  echo td($p_row[$v]);
146  }
147  }
148  if ( $nb == 0 ) $this->display_icon_del($p_row);
149  else echo td("&nbsp;");
150 
151 
152  echo '</tr>';
153  }
154 
155  /**
156  * Check that the entered data are valid before recording them into
157  * tmp_pcmn, the errors are stored into this->a_error and if someting wrong
158  * is found it returns false, if the data can be saved it returns true

◆ input()

Acc_Plan_MTable::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

Reimplemented from Manage_Table_SQL.

Definition at line 214 of file acc_plan_mtable.class.php.

224  {

◆ input_custom()

Acc_Plan_MTable::input_custom (   $p_key,
  $p_value 
)

if pcm_val already used then it cannot be modified

Parameters
$p_keyalways pcm_val
$p_valuecurrent value of pcm_val
Returns
nothing|void

Reimplemented from Manage_Table_SQL.

Definition at line 228 of file acc_plan_mtable.class.php.

231  {
232  $readonly=false;
233  }
234  $text=new IText($p_key);
235  $text->setReadOnly($readonly);
236  $text->value=$p_value;
237  $min_size=(strlen($p_value)<30)?30:strlen($p_value)+5;
238  $text->size=$min_size;
239  echo $text->input();
240  }
241 
242 }

References $readonly.


The documentation for this class was generated from the following file:
h
h( $row[ 'oa_description'])
Definition: ajax_anc_detail_operation.php:46
IText
Html Input.
Definition: itext.class.php:29
Icon_Action\more
static more($p_id, $p_javascript)
Definition: icon_action.class.php:309
HtmlInput\anchor
static anchor($p_text, $p_url="", $p_js="", $p_style=' class="line" ', $p_title="click")
Return a simple anchor with a url or a javascript if $p_js is not null then p_url will be javascript:...
Definition: html_input.class.php:915
Manage_Table_SQL\get_property_visible
get_property_visible($p_key)
return True if the column is visible otherwise false
Definition: manage_table_sql.class.php:682
$text
$text
Definition: follow_up_detail_display.php:31
Dossier\connect
static connect()
Definition: dossier.class.php:282
$readonly
$readonly
Definition: follow_up_detail_display.php:34
$nb_plan
$nb_plan
Definition: ajax_anc_detail_operation.php:51
Manage_Table_SQL\set_error
set_error($p_col, $p_message)
set the error message for a wrong input
Definition: manage_table_sql.class.php:289
$i
$i
Definition: action_document_type_mtable_input.php:83
$cn
$cn
Definition: ajax_anc_accounting.php:30
$count
$count
Definition: modele.inc.php:251
table
$all table
Definition: company.inc.php:138
$dossier_id
$dossier_id
Definition: ajax_poste.php:43
$nb
$nb
Definition: ajax_auto_anc_card.php:32
td
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
HtmlInput\history_account
static history_account($p_account, $p_mesg, $p_style="", $p_exercice="")
display a div with the history of the account
Definition: html_input.class.php:349
HtmlInput\card_detail
static card_detail($p_qcode, $pname='', $p_style="", $p_nohistory=false)
show the detail of a card
Definition: html_input.class.php:565
Manage_Table_SQL\display_icon_del
display_icon_del($p_row)
Definition: manage_table_sql.class.php:956
$js
$js
Definition: ajax_tag_list.php:32