noalyss Version-9
Public Member Functions | Static Public Member Functions | Data Fields
Anc_Group_Operation Class Reference

group of object operations, used for misc operation More...

+ Collaboration diagram for Anc_Group_Operation:

Public Member Functions

 __construct ($p_cn, $p_id=0)
 constructor More...
 
 add ()
 add several rows More...
 
 form ($p_readonly=0)
 show a form for the operation (several rows) More...
 
 get_from_array ($p_array)
 fill row from $_POST data More...
 
 save ()
 save the group of operation but only if the amount is balanced
More...
 
 show ()
 show the form More...
 

Static Public Member Functions

static test_me ()
 

Data Fields

 $a_operation
 
 $date
 
 $db
 
 $id
 
 $pa_id
 

Detailed Description

group of object operations, used for misc operation

Definition at line 30 of file anc_group_operation.class.php.

Constructor & Destructor Documentation

◆ __construct()

Anc_Group_Operation::__construct (   $p_cn,
  $p_id = 0 
)

constructor

Definition at line 43 of file anc_group_operation.class.php.

44 {
45 $this->db=$p_cn;
46 $this->id=$p_id;
47 $this->date=date("d.m.Y");
48 $this->nMaxRow=10;
49 }
$SecUser db

References $p_id, and db.

Member Function Documentation

◆ add()

Anc_Group_Operation::add ( )

add several rows

Definition at line 51 of file anc_group_operation.class.php.

52 {
53
54 $amount=0;
55 try
56 {
57 $this->db->start();
58 foreach ($this->a_operation as $row)
59 {
60 $add=round($row->oa_amount,2);
61 $add=($row->oa_debit=='t')?$add:$add*(-1);
62 $amount+=round($add,2);
63 $row->add();
64 }
65 if ( $amount != 0 ) throw new Exception (_('Operation non equilibrée'));
66 }
67 catch (Exception $e)
68 {
70 echo $e->getTrace();
71 $this->db->rollback();
72 throw new Exception($e);
73 }
74 $this->db->commit();
75 }
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342

References $amount, $e, $row, db, and record_log().

+ Here is the call graph for this function:

◆ form()

Anc_Group_Operation::form (   $p_readonly = 0)

show a form for the operation (several rows)

Returns
the string containing the form but without the form tag

Definition at line 80 of file anc_group_operation.class.php.

81 {
82 $wDate=new IDate("pdate",$this->date);
83 $wDate->table=1;
84 $wDate->size=10;
85 $wDate->readonly=$p_readonly;
86
87 $wDescription=new IText("pdesc");
88 $wDescription->table=0;
89 $wDescription->size=80;
90 $wDescription->readonly=$p_readonly;
91 // Show an existing operation
92 //
93 if ( isset ($this->a_operation[0]))
94 {
95 $wDate->value=$this->a_operation[0]->oa_date;
96 $wDescription->value=$this->a_operation[0]->oa_description;
97 }
98
99 $ret="";
100
101 $ret.='<table style="result" >';
102
103 $ret.="<TR>".td(_("Date")).td($wDate->input())."</tr>";
104 $ret.='<tr><td>Description</td>'.
105 '<td colspan="3">'.
106 $wDescription->input()."</td></tr>";
107 $Plan=new Anc_Plan($this->db);
108 $aPlan=$Plan->get_list();
109 $this->a_operation=(empty($this->a_operation))?[]:$this->a_operation;
110 $max=(count($this->a_operation)<$this->nMaxRow)?$this->nMaxRow:count($this->a_operation);
111 $ret.='</table><table id="ago" style="width: 100%;">';
112 /* show 10 rows */
113 $ret.="<tr>";
114 $ret.=th(_("Fiche"),'style="text-align:left"').th("");
115 foreach ($aPlan as $d)
116 {
117 $idx=$d['id'];
118 /* array of possible value for the select */
119 $aPoste[$idx]=$this->db->make_array("select 0 as value,'-' as label "
120 . " union select po_id as value,".
121 " po_name||':'||coalesce(po_description,'-') as label ".
122 " from poste_analytique ".
123 " where pa_id = ".$idx.
124 " order by 2 ");
125
126 $ret.="<th style=\"text-align:left\">".$d['name']."</th>";
127 }
128 $ret.="<th></th>".
129 "<th style=\"text-align:left\">"._('Montant') ."</th>".
130 "<th style=\"text-align:left\">"._("Débit")."</th>".
131 "</tr>";
132
133 for ($i = 0;$i < $max;$i++)
134 {
135 if ( $p_readonly == 1 && isset($this->a_operation[$i]) && $this->a_operation[$i]->po_id ==0 ) continue;
136 $ret.="<tr>";
137 $ret.="<td>";
138 $card=new ICard("qcode$i");
139 $card->set_attribute("typecard", sprintf("[sql] fd_id in (select fd_id from jnt_fic_attr where ad_id=%s)",ATTR_DEF_ACCOUNT));
140 $card->set_attribute('label', "qcode{$i}_label");
141 $card->setReadOnly($p_readonly);
142 $card->value=(isset($this->a_operation[$i]->card))?$this->a_operation[$i]->card:"";
143 $ret.=$card->input();
144 $ret.=$card->search();
145
146 $ret.='</td>';
147 $ret.='<td>';
148 $label=new ISpan("qcode{$i}_label");
149 $label->style="vertical-align:top";
150 $ret.=$label->input();
151 $ret.='</td>';
152 foreach ($aPlan as $d)
153 {
154 $idx=$d['id'];
155 // init variable
156 $wSelect=new ISelect("pop".$i."plan".$idx);
157 $wSelect->value=$aPoste[$idx];
158 $wSelect->size=12;
159
160 $wSelect->readOnly=$p_readonly;
161 if ( isset($this->a_operation[$i]))
162 {
163 $wSelect->selected=$this->a_operation[$i]->po_id;
164 }
165 $ret.=td($wSelect->input());
166 }
167 $wAmount=new INum("pamount$i",0.0);
168 $wAmount->size=12;
169 $wAmount->table=1;
170 $wAmount->javascript=" onChange=format_number(this);caod_checkTotal()";
171 $wAmount->readOnly=$p_readonly;
172
173 $wDebit=new ICheckBox("pdeb$i");
174 $wDebit->readOnly=$p_readonly;
175 $wDebit->javascript=" onChange=caod_checkTotal()";
176 if ( isset ($this->a_operation[$i]))
177 {
178 $wSelect->selected=$this->a_operation[$i]->po_id;
179 $wAmount->value=$this->a_operation[$i]->oa_amount;
180 $wDebit->value=$this->a_operation[$i]->oa_debit;
181 if ( $wDebit->value=='t')
182 {
183 $wDebit->selected=true;
184 }
185
186 }
187
188 // build the table
189
190 $ret.="<TD></TD>";
191 $ret.=$wAmount->input();
192 $ret.=td($wDebit->input());
193
194 $ret.="</tr>";
195 }
196 $ret.="</table>";
197 if ( $p_readonly==false)
198 {
199 $add_row=new IButton('Ajouter');
200 $add_row->label=_('Ajouter une ligne');
201 $add_row->javascript='anc_add_row(\'ago\');';
202 $ret.=HtmlInput::hidden('nbrow',$max);
203
204 $ret.=$add_row->input();
205 }
206 return $ret;
207 }
th($p_string, $p_extra='', $raw='')
Definition: ac_common.php:58
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
$idx
Concerns the Analytic plan (table plan_analytique)
static hidden($p_name, $p_value, $p_id="")
Html Input.
Input HTML for the card show buttons, in the file, you have to add card.js How to use :
Html Input.
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
Definition: idate.class.php:34
This class handles only the numeric input, the input will call a javascript to change comma to period...
Definition: inum.class.php:42
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Html Input.
Definition: ispan.class.php:32
Html Input.
Definition: itext.class.php:30
const ATTR_DEF_ACCOUNT
Definition: constant.php:215

References $card, $i, $idx, $label, $max, $p_readonly, $ret, $wDate, ATTR_DEF_ACCOUNT, db, HtmlInput\hidden(), td(), and th().

Referenced by show().

+ Here is the call graph for this function:

◆ get_from_array()

Anc_Group_Operation::get_from_array (   $p_array)

fill row from $_POST data

Definition at line 211 of file anc_group_operation.class.php.

212 {
213 $Plan=new Anc_Plan($this->db);
214 $aPlan=$Plan->get_list();
215
216
217 for ( $i = 0;$i <$p_array['nbrow'];$i++)
218 {
219 foreach ($aPlan as $d)
220 {
221 $idx=$d['id'];
222 $p=new Anc_Operation($this->db);
223 $p->oa_amount=$p_array["pamount$i"];
224
225 $p->oa_description=$p_array["pdesc"];
226 $p->oa_row=$i;
227 $p->oa_date=$p_array['pdate'];
228 $p->j_id=0;
229 $p->oa_debit=(isset ($p_array["pdeb$i"]))?'t':'f';
230 $p->oa_group=0;
231 $p->card=(isset($p_array["qcode".$i]))?$p_array["qcode".$i]:"";
232 $p->po_id=$p_array["pop$i"."plan".$idx];
233 $p->pa_id=$idx;
234 $this->a_operation[]=clone $p;
235 }
236 }
237 }
$p
Definition: array.php:34
this class is used to show the form for entering an operation only FOR analytic operation to save it,...

References $i, $idx, $p, $p_array, and db.

◆ save()

Anc_Group_Operation::save ( )

save the group of operation but only if the amount is balanced

Definition at line 240 of file anc_group_operation.class.php.

241 {
242 $this->db->start();
243 try
244 {
245 $oa_group=$this->db->get_next_seq('s_oa_group');
246 for ($i=0;$i<count($this->a_operation);$i++)
247 {
248 if ( $this->a_operation[$i]->po_id == 0 ) continue;
249 $this->a_operation[$i]->oa_group=$oa_group;
250 $this->a_operation[$i]->add();
251 }
252 }
253 catch (Exception $ex)
254 {
255 record_log($e);
256 echo '<span class="error">'.
257 'Erreur dans l\'enregistrement '.
258 __FILE__.':'.__LINE__.' '.
259 $ex->getMessage();
260 $p_cn->rollback();
261 throw new Exception("Erreur ".$ex->getMessage());
262
263 }
264 $this->db->commit();
265 }
$ex
Definition: balance.inc.php:45

References $e, $ex, $i, $oa_group, db, and record_log().

+ Here is the call graph for this function:

◆ show()

Anc_Group_Operation::show ( )

show the form

Definition at line 267 of file anc_group_operation.class.php.

268 {
269 return $this->form(1);
270 }
form($p_readonly=0)
show a form for the operation (several rows)

References form().

+ Here is the call graph for this function:

◆ test_me()

static Anc_Group_Operation::test_me ( )
static

Definition at line 271 of file anc_group_operation.class.php.

272 {
275
276 if ( isset($_POST['go']))
277 {
279 $b->get_from_array($_POST);
280 return;
281 }
282
284 echo '<form method="post">';
285 echo $a->form();
286 echo dossier::hidden();
287 echo '<input type="submit" name="go">';
288 echo '</form>';
289
290 }
$input_from id
Definition: balance.inc.php:63
$dossier
group of object operations, used for misc operation
static connect()
$_POST['ac']
Definition: do.php:310

References $_POST, $a, $b, $cn, $dossier, Dossier\connect(), and id.

+ Here is the call graph for this function:

Field Documentation

◆ $a_operation

Anc_Group_Operation::$a_operation

array of operations

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

◆ $date

Anc_Group_Operation::$date

date of the operations

Definition at line 39 of file anc_group_operation.class.php.

◆ $db

Anc_Group_Operation::$db

database connection

Definition at line 32 of file anc_group_operation.class.php.

◆ $id

Anc_Group_Operation::$id

oa_group, a group contains several rows of operation_analytique linked by the group id

Definition at line 33 of file anc_group_operation.class.php.

◆ $pa_id

Anc_Group_Operation::$pa_id

the concerned pa_id

Definition at line 40 of file anc_group_operation.class.php.


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