noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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 {
28 $cn=Dossier::connect();
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 $object->setCssClass("inner_box2");
47 return $object;
48 }
49 function input_custom($p_key,$p_value) {
50 switch ($p_key) {
51 case "ac_accounting":
52 $accounting=new IPoste("ac_accounting",$p_value);
53 $accounting->set_attribute('gDossier',Dossier::id());
54 $accounting->set_attribute('jrn',0);
55 $accounting->set_attribute('account','ac_accounting');
56 echo $accounting->input();
57 break;
58 case "ajrn_def_id":
59 $cn=Dossier::connect();
60 $a_ledger=$cn->get_array("select
61 jrn_def_id,jrn_def_name ,
62 coalesce ( (select array_position(ajrn_def_id,jrn_def_id) from acc_other_tax
63 where ac_id=$1
64 ),0) as in_array
65 from jrn_def
66 where
67 jrn_enable=1
68 and jrn_def_type in ('ACH','VEN')
69 order by jrn_def_name",[$this->get_table()->get("ac_id")]);
70 if (empty($a_ledger) ) {
71 echo _("Aucun journal disponible");
72 return;
73 }
74 $nb_ledger=count($a_ledger);
75 echo '<ul class="tab_row">';
76 for ($i=0;$i<$nb_ledger;$i++) {
77 $icheckbox=new ICheckBox("check[]",$a_ledger[$i]['jrn_def_id']);
78 if ( $a_ledger[$i]['in_array']!=0) {
79 $icheckbox->set_check($a_ledger[$i]['jrn_def_id']);
80 }
81 echo '<li>',
82 $icheckbox->input(),
83 h($a_ledger[$i]['jrn_def_name']),
84 '</li>';
85
86 }
87 echo '</ul>';
88 break;
89 }
90 }
91 function display_row_custom($p_key, $p_value, $p_id = 0)
92 {
93 $cn=Dossier::connect();
94 switch ($p_key)
95 {
96 case 'ac_accounting':
97 $label=$cn->get_value("select pcm_lib from tmp_pcmn where pcm_val=$1",
98 [$p_value]);
99 echo '<td>',
100 h($p_value),
101 " ",
102 h($label),
103 '</td>';
104 break;
105 }
106
107 }
108
109 function check()
110 {
111 $row=$this->get_table();
112 $cn=$row->get_cn();
113
114 if ( trim($row->getp("ac_rate")) == "") {
115 $row->setp("ac_rate",0);
116 }
117
118 if ( $row->getp("ac_rate")>100 || $row->getp("ac_rate")< 0 ) {
119 $this->set_error("ac_rate",_("Valeur invalide"));
120 }
121
122 $accounting=$row->getp("ac_accounting");
123 $nb_accounting=$cn->get_value("select count(*) from tmp_pcmn where pcm_val =format_account($1)",
124 [$accounting]);
125 if (empty($accounting)||$nb_accounting == 0) {
126 $this->set_error("ac_accounting",_("Poste comptable inexistant"));
127 }
128
129 $ledger=$row->get("ajrn_def_id");
130 if ( $ledger != "{}" && ! empty ($ledger))
131 {
132 $ledger=trim($ledger,'{');
133 $ledger=trim($ledger,'}');
134 $a_ledger=explode(",",$ledger);
135
136 $nb_ledger=count($a_ledger);
137 $pk=$row->get("ac_id");
138 for ($i=0;$i<$nb_ledger;$i++) {
139 if ($cn->get_value("select count(*) from acc_other_tax
140 where
141 array_position(ajrn_def_id,$1) is not null
142 and ac_id != $2
143 ",[$a_ledger[$i],$pk]) > 0)
144 {
145 $this->set_error("ajrn_def_id",_("Journal déjà utilisé dans autre taxe"));
146 }
147 }
148 }
149
150
151 if ($this->count_error()>0) {
152 return false;
153 }
154 return true;
155 }
156 function input()
157 {
158 $this->set_property_visible("ajrn_def_id",true);
159 return parent::input();
160 }
161
162 function from_request()
163 {
164 parent::from_request(); // TODO: Change the autogenerated stub
165 $http=new HttpInput();
166 $this->table->set("ajrn_def_id","{".join(",",$http->post("check","array",array()))."}");
167 }
168}
h( $row[ 'oa_description'])
catch(Exception $e) $object
_("actif, passif,charge,...")
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.
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