noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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.
 
 display_row ($p_row)
 Display a row.
 
 input ()
 display into a dialog box the datarow in order to be appended or modified.
 
 input_custom ($p_key, $p_value)
 if pcm_val already used then it cannot be modified
 
- 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.
 
 delete ()
 delete a datarow , the id must be have set before
 
 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_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 ()
 
 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 ()
 

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

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 37 of file acc_plan_mtable.class.php.

38 {
39 $this->table = $p_table;
40 parent::__construct($p_table);
41 //--------------------------------------------------------------
42 //Set the table header
43 //--------------------------------------------------------------
44 $this->set_col_label("pcm_val", _("Poste Comptable"));
45 $this->set_col_label("pcm_type", _("Type"));
46 $this->set_col_label("pcm_lib", _("Libellé"));
47 $this->set_col_label("parent_accounting", _("Dépend"));
48 $this->set_col_label("fiche_qcode", _("Fiche"));
49 $this->set_col_label("pcm_direct_use", _("Utilisation directe"));
50 //--------------------------------------------------------------
51 $this->set_property_visible("id", FALSE);
52 $this->set_property_updatable("fiche_qcode", FALSE);
53 $this->set_col_type("pcm_type", "select", [
54 ["label"=>_("Actif"),"value"=>"ACT"],
55 ["label"=>_("Actif inversé"),"value"=>"ACTINV"],
56 ["label"=>_("Passif"),"value"=>"PAS"],
57 ["label"=>_("Passif Inversé"),"value"=>"PASINV"],
58 ["label"=>_("Charge"),"value"=>"CHA"],
59 ["label"=>_("Charge inversé"),"value"=>"CHAINV"],
60 ["label"=>_("Produit"),"value"=>"PRO"],
61 ["label"=>_("Produit inversé"),"value"=>"PROINV"],
62 ["label"=>_("Contexte"),"value"=>"CON"]
63 ]);
64 $this->set_col_type("pcm_direct_use", "select",
65 array(["label" => _("Oui"), "value" => "Y"], ["label" => "Non", "value" => "N"]));
66 $this->set_col_type("pcm_val", "custom");
67 $this->a_order = ["pcm_val", "pcm_lib", "parent_accounting", "pcm_direct_use", "pcm_type", "fiche_qcode"];
68 $this->set_icon_mod("first");
69 $this->set_dialogbox_style(["width"=>"auto"]);
70 }
_("actif, passif,charge,...")
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 ,...
set_property_updatable($p_key, $p_value)
set a column of the data row updatable or not
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_dialogbox_style($db_style)
Dialog box style , by default {position: "fixed", top: '15', width: "auto", "margin-left": "20%"}...
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
$all table

References _, Manage_Table_SQL\set_col_label(), Manage_Table_SQL\set_col_type(), Manage_Table_SQL\set_dialogbox_style(), Manage_Table_SQL\set_icon_mod(), Manage_Table_SQL\set_property_updatable(), Manage_Table_SQL\set_property_visible(), and table.

+ Here is the call graph for this function:

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 163 of file acc_plan_mtable.class.php.

164 {
166 $count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = $1 and id <> $2",
167 array($this->table->pcm_val,$this->table->id));
168 if ($count > 0 ) {
169 $this->set_error("pcm_val", _("Poste comptable est unique"));
170 }
171 if ( trim($this->table->pcm_val) == "") {
172 $this->set_error("pcm_val", _("Poste comptable ne peut être vide"));
173 }
174 // Check size
175 if ( noalyss_strlentrim($this->table->pcm_val) > 40) {
176 $this->set_error("pcm_val", _("Poste comptable trop long"));
177 }
178 if ( trim($this->table->parent_accounting) == "") {
179 $this->set_error("parent_accounting", _("Poste comptable dépendant ne peut pas être vide"));
180 }
181 /**
182 * Check that the parent accounting does exist
183 */
184 $exist_parent=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = $1 ",
185 array($this->table->parent_accounting));
186 if ($exist_parent == 0) {
187 $this->set_error("parent_accounting", _("Compte parent n'existe pas"));
188 }
189 /**
190 * check that accounting is not already used
191 */
192 $old_accounting = $cn->get_value("select pcm_val from tmp_pcmn where id = $1",
193 array($this->table->id));
194 // it is not a new accounting and is different
195 if ($old_accounting != "" && $old_accounting != $this->table->pcm_val) {
196 // count it is used
197 if ($cn->get_value("select count(*) from jrnx where j_poste=$1",
198 [$old_accounting]) > 0) {
199 $this->set_error("pcm_val", _("Poste utilisé"));
200 }
201 }
202 if (count($this->aerror) > 0) return false;
203 return true;
204 }
noalyss_strlentrim($p_string)
static connect()
set_error($p_col, $p_message)
set the error message for a wrong input
$count

References $cn, $count, _, noalyss_strlentrim(), Manage_Table_SQL\set_error(), and table.

+ 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 76 of file acc_plan_mtable.class.php.

77 {
78 printf('<tr id="%s_%s">',
79 $this->object_name,
80 $p_row[$this->table->primary_key])
81 ;
82
84 $nb_order=count($this->a_order);
85 for ($i=0; $i<$nb_order; $i++)
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"
104 ,array($p_row['pcm_val']));
105 if ($count == 0) echo td("");
106 elseif ($count == 1 ) {
107 echo '<td>';
108 echo HtmlInput::card_detail($p_row[$v]) ;
109 echo '</td>';
110
111 }
112 elseif ($count > 1) {
113 echo '<td>';
114 $a_code=explode(",",$p_row[$v]);
115 $nb_code=count($a_code);
116 for ($xx = 0;$xx < $nb_code;$xx++)
117 {
118 echo HtmlInput::card_detail($a_code[$xx],'','style="display:inline"')."," ;
119 }
120 echo " ($count) ";
121 echo Icon_Action::more(uniqid(), sprintf("display_all_card('%s','%s')",
122 $dossier_id,$p_row["pcm_val"]));
123 echo '</td>';
124
125 }
126 }
127 elseif ($v=="pcm_lib")
128 {
129
130 if ( $nb >0){
131 echo "<td>";
132 if ($nb_used > 0) {
133 $used=sprintf (' (%s)',$nb_used);
134 echo HtmlInput::history_account($p_row['pcm_val'],h($p_row["pcm_lib"].$used));
135 } else {
136 echo h($p_row["pcm_lib"]);
137 }
138 echo "</td>";
139 } else {
140 echo td($p_row[$v]);
141 }
142
143 }
144 else
145 {
146 if ( ! $this->get_property_visible($v)) continue;
147 echo td($p_row[$v]);
148 }
149 }
150 if ( $nb == 0 ) $this->display_icon_del($p_row);
151 else echo td("&nbsp;");
152
153
154 echo '</tr>';
155 }
td($p_string='', $p_extra='')
surround the string with td
Definition ac_common.php:83
$dossier_id
h( $row[ 'oa_description'])
static id()
return the 'gDossier' value after a check
static history_account($p_account, $p_mesg, $p_style="", $p_exercice="")
display a div with the history of the account
static card_detail($p_qcode, $pname='', $p_style="", $p_nohistory=false, $nofollowup=false)
show the detail of a card
static more($p_id, $p_javascript)
get_property_visible($p_key)
return True if the column is visible otherwise false
if( $delta< 0) elseif( $delta==0)

References $cn, $count, $dossier_id, $i, $js, $nb, $nb_plan, Manage_Table_SQL\display_icon_del(), elseif, Manage_Table_SQL\get_property_visible(), h, Icon_Action\more(), table, and td().

+ Here is the call graph for this function:

◆ 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 211 of file acc_plan_mtable.class.php.

212 {
213 parent::input();
215 echo HtmlInput::button_action(_("Toutes les fiches") , sprintf("display_all_card('%s','%s')",$dossier_id,$this->table->pcm_val));
216 }
static button_action($action, $javascript, $id=NULL, $p_class="button", $p_symbole="")
button Html with javascript

References $dossier_id, _, and table.

◆ 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 225 of file acc_plan_mtable.class.php.

226 {
227 $readonly=true;
229 if (
230 $p_value == "" ||
231 ($p_value !="" && $cn->get_value("select count(*) from jrnx where j_poste=$1",[$p_value]) == 0 )
232 )
233 {
234 $readonly=false;
235 }
236 $text=new IText($p_key);
237 $text->setReadOnly($readonly);
238 $text->value=$p_value;
239 $min_size=(strlen($p_value??"")<30)?30:strlen($p_value)+5;
240 $text->size=$min_size;
241 echo $text->input();
242 }

References $cn, $readonly, and $text.


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