28 require_once(
'class_amortissement_histo_sql.php');
48 $sel_ledger=
$ledger->select_ledger(
'ODS', 2);
49 $sel_ledger->selected=(isset($p_array[
'p_jrn']))?$p_array[
'p_jrn']:
'';
54 $p_date->value=(isset($p_array[
'p_date']))?$p_array[
'p_date']:date(
'd.m.Y');
59 $year=
new INum(
'p_year');
61 $year->value=(isset($p_array[
'p_year']))?$p_array[
'p_year']:date(
'Y');
66 $pj=
new IText(
'p_pj');
71 if (
$ledger->check_periode()==
true)
73 $l_user_per=$g_user->get_periode();
75 $period=
new IPeriod(
"period");
76 $period->user=$g_user;
82 $l_form_per=$period->input();
88 echo _(
"Aucune période ouverte");
92 $label=HtmlInput::infobulle(3);
93 $f_periode=_(
"Période comptable").
" $label ";
98 require_once(
'template/util_generate.php');
123 if (isNumber($p_array[
'p_year'])==0||$p_array[
'p_year']<1900||$p_array[
'p_year']>2100)
124 $msg=
"Année invalide\n";
125 if (isDate($p_array[
'p_date'])==null)
126 $msg.=
"Date invalide ";
134 'p_jrn'=>$p_array[
'p_jrn'],
135 'e_date'=>$p_array[
'p_date'],
137 'desc'=>
'Amortissement '.$p_array[
'p_year'],
138 'e_pj'=>$p_array[
'p_pj'],
139 'e_pj_suggest'=>$p_array[
'p_pj'],
141 if (isset($p_array[
'period']))
143 $array[
'period']=$p_array[
'period'];
147 for ($i=0; $i<count($p_array[
'a_id']); $i++)
149 if (isset($p_array[
'p_ck'.$i]))
156 $fiche=
new Fiche($cn, $n->f_id);
157 $val=$cn->get_value(
"select ad_amount from amortissement.amortissement_detail ".
158 " where a_id = $1 and ad_year=$2", array($n->a_id, $p_array[
'p_year']));
159 $val=($val==
'')?0:$val;
162 if ($n->card_deb!=
"")
164 $fiche_card_deb=
new Fiche($cn, $n->card_deb);
165 $card_deb=$fiche_card_deb->get_quick_code();
169 if ($n->card_cred!=
"")
172 $fiche_card_cred=
new Fiche($cn, $n->card_cred);
173 $card_cred=$fiche_card_cred->get_quick_code();
175 $mat=array(
'poste'.$idx=>$n->account_deb,
177 'ld'.$idx=>
'Dotation à '.$fiche->strAttribut(ATTR_DEF_QUICKCODE),
179 'qc_'.$idx=>$card_deb);
180 $a_material+=array(
'request_a'.$i=>$idx);
183 $mat=array(
'poste'.$idx=>$n->account_cred,
185 'ld'.$idx=>
'Amortissement '.$fiche->strAttribut(ATTR_DEF_QUICKCODE),
186 'qc_'.$idx=>$card_cred);
191 $array+=array(
'nb_item'=>$idx);
192 $ledger=
new Acc_Ledger($cn, $p_array[
'p_jrn']);
194 $list=
new ISelect(
'grouped');
196 array(
'label'=>_(
'En une opération'),
'value'=>1),
197 array(
'label'=>_(
'En plusieurs opérations'),
'value'=>0),
198 array(
'label'=>_(
'-- choix --'),
'value'=>-1)
201 echo
'<div style="width:80%;margin-left:10%">';
202 echo
'<form method="POST" style="display:inline">';
206 foreach ($a_material as
$key=> $value)
207 echo HtmlInput::hidden(
$key, $value);
211 echo alert($e->getMessage());
215 echo HtmlInput::submit(
'save',_(
'Sauver'));
216 echo HtmlInput::hidden(
'sa', $p_array[
'sa']);
217 echo HtmlInput::hidden(
'sb', $p_array[
'sb']);
218 echo HtmlInput::hidden(
'p_year', $p_array[
'p_year']);
219 echo HtmlInput::hidden(
'p_date', $p_array[
'p_date']);
220 echo HtmlInput::hidden(
'p_jrn', $p_array[
'p_jrn']);
221 echo HtmlInput::hidden(
'plugin_code', $p_array[
'plugin_code']);
222 for ($i=0; $i<count($p_array[
'a_id']); $i++)
224 echo HtmlInput::hidden(
'a_id[]', $p_array[
'a_id'][$i]);
225 if (isset($p_array[
'p_ck'.$i]))
226 echo HtmlInput::hidden(
'p_ck'.$i,
'1');
234 echo
'<form method="POST" style="display:inline">';
235 echo dossier::hidden();
236 echo HtmlInput::hidden(
'sa', $p_array[
'sa']);
237 echo HtmlInput::hidden(
'sb', $p_array[
'sb']);
238 echo HtmlInput::hidden(
'p_year', $p_array[
'p_year']);
239 echo HtmlInput::hidden(
'p_date', $p_array[
'p_date']);
240 echo HtmlInput::hidden(
'p_jrn', $p_array[
'p_jrn']);
241 echo HtmlInput::hidden(
'plugin_code', $p_array[
'plugin_code']);
242 for ($i=0; $i<count($p_array[
'a_id']); $i++)
244 echo HtmlInput::hidden(
'a_id[]', $p_array[
'a_id'][$i]);
245 if (isset($p_array[
'p_ck'.$i]))
246 echo HtmlInput::hidden(
'p_ck'.$i,
'1');
248 echo HtmlInput::submit(
'correct',
'Corriger');
275 function save($p_array, $p_group)
277 if ($p_group ==
true)
281 else if ($p_group ==
false)
296 $ledger=
new Acc_Ledger($cn, $p_array[
'p_jrn']);
297 $this->saved_operation=array();
300 $period=
$oPeriode->find_periode($p_array[
'e_date']);
301 for ($i=0; $i<count($p_array[
'a_id']); $i++)
303 if (isset($p_array[
'p_ck'.$i]))
311 $idx=$p_array[
'request_a'.$i];
318 $p_post[
'p_jrn']=$p_array[
'p_jrn'];
319 $p_post[
'jrn_type']=$p_array[
'jrn_type'];
320 $p_post[
'e_date']=$p_array[
'e_date'];
321 $p_post[
'e_pj']=$p_array[
'e_pj'];
322 $p_post[
'e_pj_suggest']=$p_array[
'e_pj_suggest'];
323 $msg_operation=$cn->get_value(
'select vw_name from vw_fiche_attr join amortissement.amortissement using (f_id) where a_id=$1', array($p_array[
'a_id'][$i]));
324 $p_post[
'desc']=$p_array[
'e_comm'].
"-".$msg_operation;
325 $p_post[
'period']=$period;
326 $this->saved_operation[
'desc'][]=$p_post[
'desc'];
327 $p_post[
'mt']=microtime(
false);
328 $p_post[
'nb_item']=$cred*2;
331 if (isset($p_array[
'ck'.$idx]))
332 $p_post[
'ck'.$idx]=1;
333 if (isset($p_array[
'poste'.$idx]))
334 $p_post[
'poste'.$idx]=$p_array[
'poste'.$idx];
335 if (isset($p_array[
'qc_'.$idx]))
336 $p_post[
'qc_'.$idx]=$p_array[
'qc_'.$idx];
337 if (isset($p_array[
'ld'.$idx]))
338 $p_post[
'ld'.$idx]=$p_array[
'ld'.$idx];
339 $p_post[
'amount'.$idx]=$p_array[
'amount'.$idx];
341 if (isset($p_array[
'poste'.$cred]))
342 $p_post[
'poste'.$cred]=$p_array[
'poste'.$cred];
343 if (isset($p_array[
'qc_'.$cred]))
344 $p_post[
'qc_'.$cred]=$p_array[
'qc_'.$cred];
345 if (isset($p_array[
'ld'.$cred]))
346 $p_post[
'ld'.$cred]=$p_array[
'ld'.$cred];
347 $p_post[
'amount'.$cred]=$p_array[
'amount'.$cred];
349 $this->saved_operation[
"internal"][]=
$ledger->internal;
350 $this->saved_operation[
"jr_id"][]=
$ledger->jr_id;
355 $val=$cn->get_value(
"select ad_amount from amortissement.amortissement_detail ".
356 " where a_id = $1 and ad_year=$2", array($p_array[
'a_id'][$i], $p_array[
'p_year']));
357 $val=($val==
'')?0:$val;
358 $h=$cn->get_value(
'select ha_id from amortissement.amortissement_histo where a_id=$1 and h_year=$2', array($p_array[
'a_id'][$i], $p_array[
'p_year']));
364 $n->h_year=$p_array[
'p_year'];
365 $n->jr_internal=
$ledger->internal;
380 $ledger=
new Acc_Ledger($cn, $p_array[
'p_jrn']);
381 $this->saved_operation=array();
386 $p_post[
'p_jrn']=$p_array[
'p_jrn'];
387 $p_post[
'jrn_type']=$p_array[
'jrn_type'];
388 $p_post[
'e_date']=$p_array[
'e_date'];
389 $p_post[
'e_pj']=$p_array[
'e_pj'];
390 $p_post[
'e_pj_suggest']=$p_array[
'e_pj_suggest'];
391 $p_post[
'desc']=
'Amortissement ';
392 $this->saved_operation[
'desc'][0]=$p_post[
'desc'];
393 $p_post[
'mt']=microtime(
false);
395 $p_post[
'period']=
$oPeriode->find_periode($p_array[
'e_date']);
397 for ($i=0; $i<count($p_array[
'a_id']); $i++)
399 if (isset($p_array[
'p_ck'.$i]))
407 $idx=$p_array[
'request_a'.$i];
411 $p_post[
'nb_item']=$cred*2;
414 if (isset($p_array[
'ck'.$idx]))
415 $p_post[
'ck'.$idx]=1;
416 if (isset($p_array[
'poste'.$idx]))
417 $p_post[
'poste'.$idx]=$p_array[
'poste'.$idx];
418 if (isset($p_array[
'qc_'.$idx]))
419 $p_post[
'qc_'.$idx]=$p_array[
'qc_'.$idx];
420 if (isset($p_array[
'ld'.$idx]))
421 $p_post[
'ld'.$idx]=$p_array[
'ld'.$idx];
422 $p_post[
'amount'.$idx]=$p_array[
'amount'.$idx];
424 if (isset($p_array[
'poste'.$cred]))
425 $p_post[
'poste'.$cred]=$p_array[
'poste'.$cred];
426 if (isset($p_array[
'qc_'.$cred]))
427 $p_post[
'qc_'.$cred]=$p_array[
'qc_'.$cred];
428 if (isset($p_array[
'ld'.$cred]))
429 $p_post[
'ld'.$cred]=$p_array[
'ld'.$cred];
430 $p_post[
'amount'.$cred]=$p_array[
'amount'.$cred];
434 $this->saved_operation[
"internal"][0]=
$ledger->internal;
435 $this->saved_operation[
"jr_id"][0]=
$ledger->jr_id;
436 for ($i=0; $i<count($p_array[
'a_id']); $i++)
438 if (isset($p_array[
'p_ck'.$i]))
444 $val=$cn->get_value(
"select ad_amount from amortissement.amortissement_detail ".
445 " where a_id = $1 and ad_year=$2", array($p_array[
'a_id'][$i], $p_array[
'p_year']));
446 $val=($val==
'')?0:$val;
447 $h=$cn->get_value(
'select ha_id from amortissement.amortissement_histo where a_id=$1 and h_year=$2', array($p_array[
'a_id'][$i], $p_array[
'p_year']));
453 $n->h_year=$p_array[
'p_year'];
454 $n->jr_internal=
$ledger->internal;
if($cn->count()==0) $oPeriode
propose_writing($p_array)
Propose to save the writing in the selected ledger.
save($p_array, $p_group)
save into amortissement_histo
save_grouped($p_array)
save the amortized material into several writings
input($p_array)
Show the form to generate the writing select ledger year date of operation list of material...
if(isset($_POST['remove'])) $array
Manage the table amortissement.amortissement_histo.
save_separated($p_array)
save the amortized material into only one writing
Manage the table amortissement.amortissement.