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

Configure the tva : code , rate, label ... When using Manage_Table_SQL. More...

+ Inheritance diagram for Tva_Rate_MTable:
+ Collaboration diagram for Tva_Rate_MTable:

Public Member Functions

 __construct (V_Tva_rate_SQL $p_table)
 
 check ()
 Check data are valid. More...
 
 delete ()
 delete if not used anywhere More...
 
 getPreviousId ()
 
 input ()
 display into a dialog box the datarow in order to be appended or modified. More...
 
 save ()
 save the data in TVA_RATE if tva_both_side is 1 and tva_purchase or tva_sale is empty then it is equal to the other value More...
 
 setPreviousId ($previous_id)
 
- 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

 $previous_id
 < previous tva_id, used to know if we update or insert, 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

Configure the tva : code , rate, label ... When using Manage_Table_SQL.

Examples
tva_parameter.php.

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

Constructor & Destructor Documentation

◆ __construct()

Tva_Rate_MTable::__construct ( V_Tva_rate_SQL  $p_table)

Definition at line 46 of file tva_rate_mtable.class.php.

47 {
48 parent::__construct($p_table);
49 $this->set_col_label("tva_id", _("id"));
50 $this->set_col_label("tva_label", _("label"));
51 $this->set_col_label("tva_rate", _("taux"));
52 $this->set_col_label("tva_comment", _("Description"));
53 $this->set_col_label("tva_both_side", _("Autoliquidation"));
54 $this->set_col_label("tva_sale", _("TVA Vente (C)"));
55 $this->set_col_label("tva_purchase", _("TVA Achat (D)"));
56 $this->set_col_type("tva_both_side", "select",
57 array(
58 ["value"=>0, "label"=>_("Non")],
59 ["value"=>1, "label"=>_("Oui")]
60 ));
61 $this->set_property_updatable("tva_id", true);
62 $this->set_col_label("tva_payment_purchase",_("Exigible achat"));
63 $this->set_col_type("tva_payment_purchase","select",
64 array(
65 array("value"=>'O',"label"=>"Opération"),
66 array("value"=>'P',"label"=>"Paiement")
67 )
68 );
69 $this->set_col_label("tva_payment_sale",_("Exigible vente"));
70 $this->set_col_type("tva_payment_sale","select",
71 array(
72 array("value"=>'O',"label"=>"Opération"),
73 array("value"=>'P',"label"=>"Paiement")
74 )
75 );
76 $this->a_info=["tva_purchase"=>44,"tva_both_side"=>43,"tva_sale"=>45
77 ,"tva_payment_sale"=>74,"tva_payment_purchase"=>74];
78 $this->previous_id=null;
79 }
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_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_type(), and Manage_Table_SQL\set_property_updatable().

+ Here is the call graph for this function:

Member Function Documentation

◆ check()

Tva_Rate_MTable::check ( )

Check data are valid.

  1. tva_rate between 0 & 1
  2. label is uniq
  3. accounting must exist
    Returns
    boolean

Reimplemented from Manage_Table_SQL.

Definition at line 254 of file tva_rate_mtable.class.php.

255 {
257 if ( $this->previous_id == null ) {
258 throw new \Exception ("TVA184: no previous TVA id");
259 }
260 // both accounting can not be empty
261 if (trim($this->table->tva_purchase)==""&&trim($this->table->tva_sale)=="")
262 {
263 $this->set_error("tva_purchase",
264 _("Les 2 postes comptables ne peuvent être nuls"));
265 $this->set_error("tva_sale",
266 _("Les 2 postes comptables ne peuvent être nuls"));
267 }
268
269 // Check the tva rate
270 if (trim($this->table->tva_rate)==""||isNumber($this->table->tva_rate)==0||$this->table->tva_rate>1)
271 {
272 $this->set_error("tva_rate", _("Taux de TVA invalide"));
273 }
274
275 //Check the label must be unique
276 $count=$cn->get_value("select count(*) from tva_rate where tva_id<>$1 and lower(tva_label)=lower($2)",
277 [$this->getPreviousId(), $this->table->tva_label]);
278 if ($count>0)
279 {
280 $this->set_error("tva_label", _("Ce nom est déjà utilisé"));
281 }
282
283 // Check accounting exists for purchase
284 if (trim($this->table->tva_purchase)!=""&&$this->table->tva_purchase!="#")
285 {
286 $count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = $1",
287 [$this->table->tva_purchase]);
288 if ($count==0)
289 {
290 $this->set_error("tva_purchase", _("Poste comptable inexistant"));
291 }
292 }
293 // Check accounting exists for sale
294 if (trim($this->table->tva_sale)!=""&&$this->table->tva_sale!="#")
295 {
296 $count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = $1",
297 [$this->table->tva_sale]);
298 if ($count==0)
299 {
300 $this->set_error("tva_sale", _("Poste comptable inexistant"));
301 }
302 }
303
304 // check if tva_both_side is valid
305 if ($this->table->tva_both_side!=0&&$this->table->tva_both_side!=1)
306 {
307 $this->set_error("tva_both_side", _("Choix incorrect"));
308 }
309 $flag = true;
310 if ( isNumber($this->table->tva_id) == 0 || $this->table->tva_id != round($this->table->tva_id) )
311 {
312 $this->set_error("tva_id",_("Valeur invalide"));
313 $flag=false;
314 }
315 // Check if old tva_id was not overwritting something
316 if ( $flag && $this->previous_id != $this->table->tva_id && $cn->get_value("select count(*) from tva_rate where tva_id=$1",[$this->table->tva_id]) > 0)
317 {
318 $this->set_error("tva_id",_("Code TVA déjà utilisé"));
319 }
320 // Check that tva_id is a integer not a float
321
322 if ($this->count_error()!=0)
323 return false;
324 return true;
325 }
isNumber($p_int)
Definition: ac_common.php:215
static connect()
count_error()
returns the nb of errors found
set_error($p_col, $p_message)
set the error message for a wrong input
$all table
$count
$flag
Definition: install.php:531

References $cn, $count, $flag, Dossier\connect(), Manage_Table_SQL\count_error(), getPreviousId(), isNumber(), Manage_Table_SQL\set_error(), and table.

+ Here is the call graph for this function:

◆ delete()

Tva_Rate_MTable::delete ( )

delete if not used anywhere

Reimplemented from Manage_Table_SQL.

Definition at line 329 of file tva_rate_mtable.class.php.

330 {
332 $count_purchase=$cn->get_value("select count(*) from quant_purchase where qp_vat_code = $1",[$this->table->tva_id]);
333 $count_sale=$cn->get_value("select count(*) from quant_sold where qs_vat_code = $1",[$this->table->tva_id]);
334 if ( $count_purchase > 0 || $count_sale > 0) {
335 throw new Exception(_("Effacement interdit : TVA utilisée"));
336 }
337
338 // Forbid to remove all tva
339 $count=$cn->get_value("select count(*) from tva_rate");
340 if ( $count < 2) {
341 throw new Exception(_("Vous ne pouvez pas effacer tous les taux. Si votre société n'utilise pas la TVA, changer dans le menu société"));
342 }
343 $cn->exec_sql("delete from tva_rate where tva_id=$1", [$this->table->tva_id]);
344 }

References $cn, $count, Dossier\connect(), and table.

+ Here is the call graph for this function:

◆ getPreviousId()

Tva_Rate_MTable::getPreviousId ( )
Returns
int or null

Definition at line 84 of file tva_rate_mtable.class.php.

85 {
86 return $this->previous_id;
87 }
$previous_id
< previous tva_id, used to know if we update or insert,

References $previous_id.

Referenced by check().

◆ input()

Tva_Rate_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 104 of file tva_rate_mtable.class.php.

105 {
106 $nb_order=count($this->a_order);
107 echo "<table>";
108 for ($i=0; $i<$nb_order; $i++)
109 {
110 echo "<tr>";
111 $key=$this->a_order[$i];
112 $label=$this->a_label_displaid[$key];
113 $value=$this->table->get($key);
114 $error=$this->get_error($key);
116
117 if ($this->get_property_visible($key)===TRUE)
118 {
119 $info="";
120 if ( isset($this->a_info[$key])) {
121 $info=Icon_Action::infobulle($this->a_info[$key]);
122 }
123 // Label
124 echo "<td> {$label} {$info} {$error}</td>";
125
126 if ($this->get_property_updatable($key)==TRUE)
127 {
128 echo "<td>";
129 if ($this->a_type[$key]=="select")
130 {
131 $select=new ISelect($key);
132 $select->value=$this->a_select[$key];
133 $select->selected=$value;
134 echo $select->input();
135 }
136 elseif ($key=="tva_rate")
137 {
138 $text=new INum($key);
139 $text->value=$value;
140 $text->prec=4;
141 $min_size=(strlen($value??"")<10)?10:strlen($value)+1;
142 $text->size=$min_size;
143 echo $text->input();
144 }
145 elseif ($key=='tva_purchase')
146 {
147 $text=new IPoste("tva_purchase");
148 $text->value=$value;
149 $min_size=10;
150 $text->size=$min_size;
151 $text->set_attribute('gDossier', Dossier::id());
152 $text->set_attribute('jrn', 0);
153 $text->set_attribute('account', 'tva_purchase');
154 echo $text->input();
155 $url="do.php?".http_build_query(array("gDossier"=>Dossier::id(),"ac"=>'CFGPCMN','p_start'=>4));
156 echo HtmlInput::anchor(_("Configuration poste comptable"),$url,"",'target="_blank"');
157 }
158 elseif ($key=='tva_sale')
159 {
160 $text=new IPoste("tva_sale");
161 $text->value=$value;
162 $min_size=10;
163 $text->set_attribute('gDossier', Dossier::id());
164 $text->set_attribute('jrn', 0);
165 $text->set_attribute('account', 'tva_sale');
166 $text->size=$min_size;
167 echo $text->input();
168 }
169 elseif ($this->a_type[$key]=="text")
170 {
171 $text=new IText($key);
172 $text->value=$value;
173 $min_size=(strlen($value??"")<30)?30:strlen($value)+5;
174 $text->size=$min_size;
175 echo $text->input();
176 } elseif ($key == "tva_id") {
177 $inum=new INum($key,$value);
178 echo $inum->input();
179 echo \HtmlInput::hidden("old_tva_id",$value);
180
181 }
182 echo "</td>";
183 }
184 else
185 {
186 printf('<td>%s %s</td>', h($value),
188 );
189 }
190 }
191 echo "</tr>";
192 }
193 echo "</table>";
194 }
h( $row[ 'oa_description'])
$url
static id()
return the 'gDossier' value after a check
static anchor($p_text, $p_url="", $p_js="", $p_style=' class="line" ', $p_title="click", array $p_attribute=[])
Return a simple anchor with a url or a javascript if $p_js is not null then p_url will be javascript:...
static hidden($p_name, $p_value, $p_id="")
static errorbulle($p_comment)
This class handles only the numeric input, the input will call a javascript to change comma to period...
Definition: inum.class.php:42
show a button, for selecting a account and a input text for manually inserting an account the differe...
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Html Input.
Definition: itext.class.php:30
static infobulle($p_comment)
Display a info in a bubble, text is in message_javascript.
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_error($p_col)
retrieve the error message
if( $delta< 0) elseif( $delta==0)

References $error, $i, $label, $select, $text, $url, $value, HtmlInput\anchor(), elseif, HtmlInput\errorbulle(), Manage_Table_SQL\get_error(), Manage_Table_SQL\get_property_updatable(), Manage_Table_SQL\get_property_visible(), h, HtmlInput\hidden(), Dossier\id(), Icon_Action\infobulle(), and table.

+ Here is the call graph for this function:

◆ save()

Tva_Rate_MTable::save ( )

save the data in TVA_RATE if tva_both_side is 1 and tva_purchase or tva_sale is empty then it is equal to the other value

Reimplemented from Manage_Table_SQL.

Definition at line 202 of file tva_rate_mtable.class.php.

203 {
204 if ( $this->previous_id == null ) {
205 throw new \Exception ("TVA184: no previous TVA id");
206 }
208 // if tva_both_side is 1 and tva_purchase or tva_sale is empty then
209 // it is equal to the other value
210 if ($this->table->tva_both_side==1)
211 {
212 if ($this->table->tva_purchase=="#"||trim($this->table->tva_purchase)
213 =="#")
214 {
215 $this->table->tva_purchase=$this->table->tva_sale;
216 }
217 if ($this->table->tva_sale=="#"||trim($this->table->tva_sale)=="#")
218 {
219 $this->table->tva_sale=$this->table->tva_purchase;
220 }
221 }
222 $new_tva_id=$this->table->tva_id;
224 $tva_rate->setp("tva_id",$new_tva_id);
225 $tva_rate->setp("tva_rate", $this->table->tva_rate);
226 $tva_rate->setp("tva_label", $this->table->tva_label);
227 $tva_rate->setp("tva_comment", $this->table->tva_comment);
228 $tva_rate->setp("tva_both_side", $this->table->tva_both_side);
229
230 // TVA accounting must be joined and separated with a comma
231 $tva_purchase=(trim($this->table->tva_purchase)=="")?"#":$this->table->tva_purchase;
232 $tva_sale=(trim($this->table->tva_sale)=="")?"#":$this->table->tva_sale;
233 $tva_rate->setp("tva_poste", $tva_purchase.",".$tva_sale);
234 $tva_rate->setp("tva_payment_sale", $this->table->tva_payment_sale);
235 $tva_rate->setp("tva_payment_purchase", $this->table->tva_payment_purchase);
236 if ( $this->previous_id == -1 ) {
237 $tva_rate->insert();
238 } else {
239 $tva_rate->update();
240 }
241 if ( $this->previous_id != - 1 && $this->previous_id != $new_tva_id) {
242 $cn->exec_sql("update tva_rate set tva_id = $1 where tva_id = $2",[$new_tva_id,$this->previous_id]);
243 $this->table->setp("tva_id",$new_tva_id);
244 }else $this->table->setp("tva_id",$tva_rate->getp("tva_id"));
245
246 }
catch(Exception $e) $tva_rate
abstract of the table public.tva_rate

References $cn, $tva_rate, Dossier\connect(), and table.

+ Here is the call graph for this function:

◆ setPreviousId()

Tva_Rate_MTable::setPreviousId (   $previous_id)
Parameters
int$previous_id

Definition at line 93 of file tva_rate_mtable.class.php.

94 {
95 $this->previous_id = $previous_id;
96 return $this;
97 }
Configure the tva : code , rate, label ... When using Manage_Table_SQL.

References $previous_id.

Field Documentation

◆ $previous_id

Tva_Rate_MTable::$previous_id
private

< previous tva_id, used to know if we update or insert,

Definition at line 38 of file tva_rate_mtable.class.php.

Referenced by getPreviousId(), and setPreviousId().


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