noalyss Version-9
acc_other_tax_mtable.class.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * PhpCompta is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * PhpCompta is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with PhpCompta; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Copyright (2002-2022) Author Dany De Bontridder <danydb@noalyss.eu>
19 */
21{
22 /**
23 * @brief Build and returns an object
24 * @param int $p_id
25 */
26 static public function build($p_id=-1)
27 {
29 $object_sql=new Acc_Other_Tax_SQL($cn,$p_id);
30
31 $object=new Acc_Other_Tax_MTable($object_sql);
32 $object->set_object_name("other_tax_ctl");
33 $object->set_callback("ajax_misc.php");
34 $object->add_json_param("op","other_tax");
35 $object->set_order(["ac_label","ac_rate","ac_accounting","ajrn_def_id"]);
36
37 $object->set_col_label("ac_label",_("Nom"));
38 $object->set_col_label("ajrn_def_id",_("Journaux"));
39 $object->set_col_label("ac_rate",_("Taux"));
40 $object->set_col_tips("ac_rate",82);
41 $object->set_col_label("ac_accounting",_("Poste comptable"));
42 $object->set_col_tips("ac_accounting",81);
43 $object->set_col_type("ac_accounting","custom");
44 $object->set_col_type("ajrn_def_id","custom");
45 $object->set_property_visible("ajrn_def_id",false);
46 return $object;
47 }
48 function input_custom($p_key,$p_value) {
49 switch ($p_key) {
50 case "ac_accounting":
51 $accounting=new IPoste("ac_accounting",$p_value);
52 $accounting->set_attribute('gDossier',Dossier::id());
53 $accounting->set_attribute('jrn',0);
54 $accounting->set_attribute('account','ac_accounting');
55 echo $accounting->input();
56 break;
57 case "ajrn_def_id":
59 $a_ledger=$cn->get_array("select
60 jrn_def_id,jrn_def_name ,
61 coalesce ( (select array_position(ajrn_def_id,jrn_def_id) from acc_other_tax
62 where ac_id=$1
63 ),0) as in_array
64 from jrn_def
65 where
66 jrn_enable=1
67 and jrn_def_type in ('ACH','VEN')
68 order by jrn_def_name",[$this->get_table()->get("ac_id")]);
69 if (empty($a_ledger) ) {
70 echo _("Aucun journal disponible");
71 return;
72 }
73 $nb_ledger=count($a_ledger);
74 echo '<ul class="tab_row">';
75 for ($i=0;$i<$nb_ledger;$i++) {
76 $icheckbox=new ICheckBox("check[]",$a_ledger[$i]['jrn_def_id']);
77 if ( $a_ledger[$i]['in_array']!=0) {
78 $icheckbox->set_check($a_ledger[$i]['jrn_def_id']);
79 }
80 echo '<li>',
81 $icheckbox->input(),
82 h($a_ledger[$i]['jrn_def_name']),
83 '</li>';
84
85 }
86 echo '</ul>';
87 break;
88 }
89 }
90 function display_row_custom($p_key, $p_value, $p_id = 0)
91 {
93 switch ($p_key)
94 {
95 case 'ac_accounting':
96 $label=$cn->get_value("select pcm_lib from tmp_pcmn where pcm_val=$1",
97 [$p_value]);
98 echo '<td>',
99 h($p_value),
100 " ",
101 h($label),
102 '</td>';
103 break;
104 }
105
106 }
107
108 function check()
109 {
110 $row=$this->get_table();
111 $cn=$row->get_cn();
112
113 if ( trim($row->getp("ac_rate")) == "") {
114 $row->setp("ac_rate",0);
115 }
116
117 if ( $row->getp("ac_rate")>100 || $row->getp("ac_rate")< 0 ) {
118 $this->set_error("ac_rate",_("Valeur invalide"));
119 }
120
121 $accounting=$row->getp("ac_accounting");
122 $nb_accounting=$cn->get_value("select count(*) from tmp_pcmn where pcm_val =format_account($1)",
123 [$accounting]);
124 if (empty($accounting)||$nb_accounting == 0) {
125 $this->set_error("ac_accounting",_("Poste comptable inexistant"));
126 }
127
128 $ledger=$row->get("ajrn_def_id");
129 if ( $ledger != "{}" && ! empty ($ledger))
130 {
131 $ledger=trim($ledger,'{');
132 $ledger=trim($ledger,'}');
133 $a_ledger=explode(",",$ledger);
134
135 $nb_ledger=count($a_ledger);
136 $pk=$row->get("ac_id");
137 for ($i=0;$i<$nb_ledger;$i++) {
138 if ($cn->get_value("select count(*) from acc_other_tax
139 where
140 array_position(ajrn_def_id,$1) is not null
141 and ac_id != $2
142 ",[$a_ledger[$i],$pk]) > 0)
143 {
144 $this->set_error("ajrn_def_id",_("Journal déjà utilisé dans autre taxe"));
145 }
146 }
147 }
148
149
150 if ($this->count_error()>0) {
151 return false;
152 }
153 return true;
154 }
155 function input()
156 {
157 $this->set_property_visible("ajrn_def_id",true);
158 return parent::input();
159 }
160
161 function from_request()
162 {
163 parent::from_request(); // TODO: Change the autogenerated stub
164 $http=new HttpInput();
165 $this->table->set("ajrn_def_id","{".join(",",$http->post("check","array",array()))."}");
166 }
167}
h( $row[ 'oa_description'])
catch(Exception $e) $object
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 prope...
from_request()
get the data from http request strip the not update or not visible data to their initial value.
input_custom($p_key, $p_value)
this function let you create your own input , for example for a ITEXT , a IRADIO ,...
static build($p_id=-1)
Build and returns an object.
input()
display into a dialog box the datarow in order to be appended or modified.
ORM public.acc_other_tax.
static id()
return the 'gDossier' value after a check
static connect()
manage the http input (get , post, request) and extract from an array
Html Input.
show a button, for selecting a account and a input text for manually inserting an account the differe...
Purpose is to propose a librairy to display a table content and allow to update and delete row ,...
count_error()
returns the nb of errors found
set_property_visible($p_key, $p_value)
set a column of the data row visible or not
set_error($p_col, $p_message)
set the error message for a wrong input
$all table
$icheckbox
Definition: tag_detail.php:19