25require_once NOALYSS_INCLUDE.
'/lib/user_common.php';
104 $this->oa_jrnx_id_source=
null;
105 $this->oa_positive=
'Y';
109 $this->currency_rate=1;
119 if ( $this->oa_group == 0)
121 $this->oa_group=$this->
db->get_next_seq(
's_oa_group');
124 if ( $this->j_id == 0 )
129 if ( $this->oa_jrnx_id_source ==
null)
131 $side=$this->
db->get_value(
'select j_debit from jrnx where j_id=$1',
135 $side=$this->
db->get_value(
'select j_debit from jrnx where j_id=$1',
136 array($this->oa_jrnx_id_source));
138 $this->oa_debit=
$side;
143 if ( $this->oa_amount == 0 || $this->po_id==-1)
146 if ( $this->oa_amount< 0)
149 $this->oa_positive=
'N';
150 $this->oa_debit=($this->oa_debit==
't')?
'f':
't';
155 if ( $this->card !=
"") {
157 $fiche->get_by_qcode($this->card);
160 $n_fid=($n_fid!=0)?$n_fid:NULL;
161 $oa_row=(isset($this->oa_row))?$this->oa_row:
null;
162 $sql=
"insert into operation_analytique (
174 ) values ($1,$2,$3,$4,$5,$6,to_date($7,'DD.MM.YYYY'),$8,$9,$10,$11)";
176 $this->
db->exec_sql(
$sql,array(
178 abs($this->oa_amount),
179 $this->oa_description,
185 $this->oa_jrnx_id_source,
196 $sql=
"delete from operation_analytique where oa_id=$1";
198 $this->
db->exec_sql(
$sql,array($this->oa_id));
207 $cond=
"$where (oa_date >= to_date('$p_from','DD.MM.YYYY') or oa_date >= to_date('$p_from','DD.MM.YYYY') )";
211 $cond.=
"$where (oa_date <=to_date('$p_to','DD.MM.YYYY') or oa_date <=to_date('$p_to','DD.MM.YYYY')) ";
215 $cond .= $where.
" j_id is null ";
218 select distinct oa_group,
219 to_char(oa_date,'DD.MM.YYYY') as str_date ,
223 operation_analytique as oa
226 return $this->
db->get_array(
$sql);
232 function get_list($p_from,$p_to,$p_from_poste=
"",$p_to_poste=
"")
238 $cond=
"and (jr_date >= to_date('$p_from','DD.MM.YYYY') or oa_date >= to_date('$p_from','DD.MM.YYYY') )";
240 $cond.=
"and (jr_date <=to_date('$p_to','DD.MM.YYYY') or oa_date <=to_date('$p_to','DD.MM.YYYY')) ";
242 if ($p_from_poste !=
"" )
243 $cond_poste=
" and upper(po_name) >= upper('".$p_from_poste.
"')";
244 if ($p_to_poste !=
"" )
245 $cond_poste.=
" and upper(po_name) <= upper('".$p_to_poste.
"')";
247 if ( isset ( $this->
pa_id) && $this->
pa_id !=
'')
248 $pa_id_cond=
"pa_id=".$this->pa_id.
" and";
251 select B.po_id as po_id,
257 (case when jr_date is not null then to_char(jr_date,'DD.MM.YYYY') else to_char(oa_date,'DD.MM.YYYY') end ) as oa_date,
258 (case when jr_date is not null then to_char(jr_date,'YYYYMMDD') else to_char(oa_date,'YYYYMMDD') end ) as str_order_date,
265 coalesce(jr_comment,b.oa_description) as jr_comment,
266 case when j_poste is null and b.f_id is not null then
267 (select ad_value from fiche_detail where fiche_detail.f_id=b.f_id and ad_id=".ATTR_DEF_ACCOUNT.
")
268 when j_poste is not null then
272 coalesce(jrnx.f_id,b.f_id) as f_id,
273 case when jrnx.f_id is not null then
274 (select ad_value from fiche_Detail where f_id=jrnx.f_id and ad_id=23)
275 when b.f_id is not null then
276 (select ad_value from fiche_Detail where f_id=b.f_id and ad_id=23)
280 from operation_analytique as B join poste_analytique using(po_id)
281 left join jrnx using (j_id)
282 left join jrn on (j_grpt=jr_grpt_id)
283 where $pa_id_cond oa_amount <> 0.0 $cond $cond_poste
284 order by jr_date,oa_group,oa_debit desc,oa_id";
286 $RetSql=$this->
db->exec_sql(
$sql);
309 return _(
"Pas d'enregistrement trouvé");
312 $step=$_SESSION[SESSION_KEY.
'g_pagesize'];
331 $ret.=
"<table id=\"anc_operation_list_tb\"class=\"result\">";
337 foreach ($view as
$row)
339 $class=(
$i%2 == 0)?
'class="even"':
' class="odd"';
342 if ( $oldgroup <>
$row[
'oa_group']) {
343 $oldgroup=
$row[
'oa_group'];
345 $row_id=sprintf(
'id="tr%s"',$oldgroup);
347 $ret.=
"<tr $row_id $class>";
350 $js=
"anc_remove_operation(".$gDossier.
",".$oldgroup.
")";
352 $ret.=
"<td>".Icon_Action::trash(uniqid(),
$js) .
"</td>";
353 $js=
"anc_detail_op({$row['oa_group']},{$gDossier})";
369 $a_plan=$this->
db->get_array(
'select pa_id from plan_analytique order by pa_id');
374 $a_rowcount=$this->
db->get_array(
"select distinct oa_row "
375 .
" from operation_analytique where j_id=$1 order by oa_row", array($p_jid));
377 for (
$i=0;
$i<count($a_rowcount);
$i++)
382 $a_existing=$this->
db->get_array(
'
383 select distinct oa_id,
394 from operation_analytique join poste_analytique using (po_id)
396 j_id=$1 and oa_row = $2
397 order by j_id,oa_row',
398 array($p_jid, $a_rowcount[
$i][
'oa_row']));
405 for ($j=0; $j<count(
$a_plan); $j++)
410 $a_fetch=$this->
db->get_array(
'
411 select distinct oa_id,
422 from operation_analytique join poste_analytique using (po_id)
424 j_id=$1 and oa_row = $2 and pa_id=$3', array($p_jid,
425 $a_rowcount[
$i][
'oa_row'],
429 if (count($a_fetch)==0)
432 $a_fetch[
'pa_id']=
$a_plan[$j][
'pa_id'];
433 $a_fetch[
'po_id']=-1;
434 $a_fetch[
'oa_id']=
'';
438 if (count($a_fetch)==1)
468 $sql=
"select jr_date,j_montant,j_debit from jrnx ".
469 " join jrn on (jr_grpt_id = j_grpt) ".
470 "where j_id=".$this->j_id;
474 $this->oa_amount=
$row[
'j_amount'];
475 $this->oa_date=
$row[
'jr_date'];
476 $this->oa_debit=
$row[
'j_debit'];
477 $this->oa_description=
$row[
'jr_comment'];
484 if (
$row->pa_id == $this->pa_id )
486 $row->po_id=$p_po_id;
495 $sql=
"select distinct jr_id from jrn join jrnx on (j_grpt=jr_grpt_id) join operation_analytique using (j_id) where j_id is not null and oa_group=".$this->oa_group;
499 return $ret[0][
'jr_id'];
510 $sql=
"select oa_id, po_id, oa_amount, oa_debit, j_date from jrnx join operation_analytique using (j_id)
511 join poste_analytique using (po_id)
513 $cond and j_id is not null and pa_id=$p_plan_id";
517 $sql=
"union select oa_id, po_id, oa_amount, oa_debit,oa_date from
519 join poste_analytique using (po_id)
520 where j_id is null and
521 $cond and pa_id=$p_plan_id ";
577 $a_plan=$plan->get_list(
" order by pa_id ");
578 if ( empty (
$a_plan) )
return "";
586 $result .= sprintf(
'<input type="HIDDEN" id="amount_%s" class="%s%s-amount" name="amount_%s" value="%s">',
594 $result.=
'<table id="'.$p_id.$table_id.
'">';
600 $result.=
"<tr>".$plan->header().
"<th>"._(
"montant").
"</th></tr>";
606 $remain=abs($p_amount);
607 $ctrl_remain=
"remain".$this->in_div.$table_id;
615 $existing=(isset($hplan[$p_seq][
$count]))?$hplan[$p_seq][
$count]:-1;
617 "select po_id as value,".
618 " html_quote(po_name) as label from poste_analytique ".
619 " where pa_id = $1 ".
620 " and ( po_state = 1 or po_id = $2) ".
621 " order by po_name",$p_null,[$r_plan[
'id'],$existing]);
629 if ( isset($hplan) && isset($hplan[$p_seq][
$count]) ){
636 if ( isset($hplan) && isset($hplan[$p_seq][
$count]) ){
644 $result.=
'<td>'.$select->input().
'</td>';
648 $result.=
'<td>'.$select->display().
'</td>';
655 $value->javascript=
'onchange="format_number(this);anc_refresh_remain(\''.$this->in_div.$table_id.
'\',\
''.$p_seq.
'\')
"';
656 $value->name=($readonly)?"ro
"."val[
".$p_seq."][]
":"val[
".$p_seq."][]
";
658 $value->value=(isset($val[$p_seq][$i]))?$val[$p_seq][$i]:abs($p_amount);
659 $value->value=round($value->value,2);
660 $value->style='class="inum
'.$this->in_div.$table_id.'-
value-
'.$p_seq.'"';
661 $value->readOnly=($p_mode==1)?false:true;
662 $remain=bcsub($remain,$value->value);
663 $result.='<td>'.$value->input().'</td>';
670 if ($p_add_button && $p_mode == 1)
672 $style_remain=($remain==0)?'style="color:green
"':' style="color:red
"';
673 $result.=" "._("Reste
")." =
".
674 '<span class="remain
" '.$style_remain.' id="'.$ctrl_remain.'">'.
676 // add a button to add a row
677 $button=new IButton();
678 $button->javascript="add_row(
'".$p_id."$table_id',$p_seq);
";
679 $button->name="js".$p_id.$p_seq;
680 $button->label=_("Nouvelle ligne
");
682 $result.="<
br>
".$button->input();
687 $http=new HttpInput();
688 $ledger=$http->post("p_jrn
", "string",0);
690 $ledger=$this->db->get_value('select j_jrn_def from jrnx where j_id=$1',array($this->j_id));
692 $gDossier=Dossier::id();
693 $button_key=new IButton();
694 $button_key->javascript="anc_key_choice(
".$gDossier.",
'".$p_id."$table_id',$p_amount,
'".$ledger."');
";
695 $button_key->name="js".$p_id.$p_seq;
696 $button_key->label=_("Clef
");
697 $result .= $button_key->input();
701 $button_clean=new IButton();
702 $button_clean->javascript=sprintf("anc_key_clean(
'%s',
'%s',
'%s',
'%s',
'%s',
'%s');
",
710 $button_clean->name=uniqid();
711 $button_clean->label=_("Efface détail
");
712 $result.=$button_clean->input();
729 function save_form_plan_vat_nd($p_array,$p_item,$p_j_id,$p_nd)
732 extract($p_array, EXTR_SKIP);
733 if (! isset ($hplan) ) return;
735 if ( ! isset(${'amount_t'.$p_item}) )
736 throw new Exception ('amount not set');
739 /* variable for in array
740 pa_id array of existing pa_id
741 hplan double array with the pa_id (column)
742 val double array by row with amount
744 p_item is used to identify what op is concerned
746 /* echo "j_id =
$j_id p_item = $p_item hplan=
".var_export($hplan[$p_item],true)." val =
".var_export($val[$p_item],true).'<br>'; */
748 // for ($i=0;$i<count($val[$p_item]);$i++) {
751 $a_Anc_Operation=array();
753 for ($e=0;$e<count($hplan[$p_item]);$e++)
755 if ( $idx_pa_id == count($pa_id))
760 if ($hplan[$p_item][$e] != -1 && $val[$p_item][$row] != '')
762 $op=new Anc_Operation($this->db);
763 $op->po_id=$hplan[$p_item][$e];
764 $op->oa_group=$this->oa_group;
767 if (${"amount_t
".$p_item} != 0 ) {
768 $ratio=bcdiv($val[$p_item][$row],${"amount_t
".$p_item});
770 $amount= bcmul($p_nd, $ratio);
772 $amount=bcmul($amount,$this->currency_rate);
773 $op->oa_amount=round($amount,2);
774 $op->oa_debit=$this->oa_debit;
775 $op->oa_date=$this->oa_date;
777 $op->oa_description=$this->oa_description;
779 $op->oa_jrnx_id_source=$this->oa_jrnx_id_source;
780 $a_Anc_Operation[]=clone $op;
784 $nb_op=count($a_Anc_Operation);
786 for ($i=0;$i<$nb_op;$i++)
788 $tot=bcadd($tot,$a_Anc_Operation[$i]->oa_amount);
791// if ( $tot != $p_nd && count($a_Anc_Operation) > 0 )
793// $diff= bcsub($tot, $p_nd);
794// $a_Anc_Operation[0]->oa_amount=bcsub($a_Anc_Operation[0]->oa_amount,$diff);
796 for ($i=0;$i<$nb_op;$i++)
798 $a_Anc_Operation[$i]->add();
889 function save_form_plan($p_array,$p_item,$p_j_id)
891 extract($p_array, EXTR_SKIP);
892 if (! isset ($hplan) ) return;
893 /* variable for in array
894 pa_id array of existing pa_id
895 hplan double array with the pa_id (column)
896 val double array by row with amount
898 p_item is used to identify what op is concerned
904 if ( ! isset ($hplan[$p_item])) return;
906 for ($e=0;$e<count($hplan[$p_item]);$e++)
908 if ( $idx_pa_id == count($pa_id))
913 if ($hplan[$p_item][$e] != -1 && $val[$p_item][$row] != '')
915 $op=new Anc_Operation($this->db);
916 $op->po_id=$hplan[$p_item][$e];
917 $op->oa_group=$this->oa_group;
919 // convert oa_amount to EUR
920 $op->oa_amount=bcdiv($val[$p_item][$row],$this->currency_rate,2);
921 $op->oa_debit=$this->oa_debit;
922 $op->oa_date=$this->oa_date;
924 $op->oa_description=$this->oa_description;
943 function save_update_form($p_array)
945 extract($p_array, EXTR_SKIP);
946 if ( ! isset($opanc)) return;
947 for ($i = 0; $i < count($opanc); $i++)
949 /* clean operation_analytique */
950 $this->db->exec_sql('delete from operation_analytique where j_id=$1', array($opanc[$i]));
952 /* get missing data for adding */
953 $a_missing = $this->db->get_array("select to_char(jr_date,
'DD.MM.YYYY')
954 as mdate,j_montant,j_debit,jr_comment ,j_poste
955 from jrnx join
jrn on (j_grpt=jr_grpt_id) where j_id=$1", array($opanc[
$i]));
956 $missing = $a_missing[0];
958 $this->oa_description = $missing['jr_comment'];
959 $this->j_id = $opanc[
$i];
960 $group = $this->
db->get_next_seq("s_oa_group");
961 $this->oa_group = $group;
962 $this->oa_date = $missing['mdate'];
966 $a_nd = $this->
db->get_array('select j_id
from operation_analytique
967 where oa_jrnx_id_source=$1', array($opanc[
$i]));
968 if (count($a_nd) > 0)
971 for (
$e=0;
$e<count($a_nd);
$e++)
973 $this->
db->exec_sql(
'delete from operation_analytique where j_id=$1', array($a_nd[
$e][
'j_id']));
975 $a_missing_vat = $this->
db->get_array(
"select to_char(jr_date,'DD.MM.YYYY') as mdate,j_montant,j_debit,jr_comment from jrnx join jrn on (j_grpt=jr_grpt_id) where j_id=$1", array($a_nd[
$e][
'j_id']));
976 $missing_vat = $a_missing_vat[0];
977 $this->oa_debit =
't';
978 $this->oa_description = $missing_vat[
'jr_comment'];
979 $this->j_id = $opanc[
$i];
980 $group = $this->
db->get_next_seq(
"s_oa_group");
981 $this->oa_group = $group;
982 $this->oa_date = $missing_vat[
'mdate'];
983 $this->oa_jrnx_id_source=$opanc[
$i];
984 $p_array[
'amount_t'.$i]=$missing[
'j_montant'];
1000 $result[]=array(
'op'=>$this->j_id);
1020 $jrn_def=$this->
db->get_value(
'select jrn_def_type from jrnx join jrn_def on (j_jrn_def=jrn_def_id) where j_id=$1',array($this->j_id));
1027 if ( $jrn_def !=
'FIN')
1047 $sql=
"delete from operation_analytique where j_id=$1";
1048 $this->
db->exec_sql(
$sql,array($p_jid));
1069 return "<td>".$this->display_form_plan($request,1,$p_mode,
$seq,$p_amount,
$p_id).
"</td>";
1073 return '<td>'.$this->display_form_plan(
null,1,$p_mode,
$seq,$p_amount,
$p_id).
"</TD>";
1095 echo dossier::hidden();
1098 echo $anco->display_table(1,15002,0);
1099 echo
'<input type="submit" name="save">';
th($p_string, $p_extra='', $raw='')
sql_filter_per($p_cn, $p_from, $p_to, $p_form='p_id', $p_field='jr_tech_per')
Create the condition to filter on the j_tech_per thanks a from and to date.
tr($p_string, $p_extra='')
record_log($p_message)
Record an error message into the log file of the server.
td($p_string='', $p_extra='')
surround the string with td
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
h( $row[ 'oa_description'])
if(!headers_sent())
– pour utiliser unoconv démarrer un server libreoffice commande libreoffice –headless –accept="socket...
this class is used to show the form for entering an operation only FOR analytic operation to save it,...
save_form_plan($p_array, $p_item, $p_j_id)
it called for each item, the data are taken from $p_array data and set before in this....
get_jrid()
retrieve the jr_id thanks the oa_group
get_balance($p_from, $p_to, $p_plan_id)
set_currency_rate($currency_rate)
update_from_jrnx($p_po_id)
modify an op from modify_op.php
$oa_positive
signed of the amount
get_by_jid($p_jid)
retrieve an operation thanks a jrnx.j_id
get_list($p_from, $p_to, $p_from_poste="", $p_to_poste="")
get a list of row from a certain periode
save_form_plan_vat_nd($p_array, $p_item, $p_j_id, $p_nd)
Save the ND VAT with prorata.
get_list_simple($p_from, $p_to)
to_request($p_array, $p_line)
add($p_seq=0)
add a row to the table operation_analytique
display_table($p_mode, $p_amount, $p_id)
Display a table with analytic accounting in detail of operation.
delete_by_jid($p_jid)
delete from operation_analytique
display_form_plan($p_array, $p_null, $p_mode, $p_seq, $p_amount, $p_id='', $p_add_button=true)
display the form for PA
__construct($p_cn, $p_id=0)
constructor
$oa_jrnx_id_source
In the case, the amount comes from a ND VAT, the variable contents the jrnx.j_id of the source which ...
Concerns the Analytic plan (table plan_analytique)
static fetch_all($ret)
wrapper for the function pg_fetch_all
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
This class handles only the numeric input, the input will call a javascript to change comma to period...
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
static modify($p_id, $p_javascript)
Display the icon to modify a idem.
For the periode tables parm_periode and jrn_periode.
for($i=0;$i< $count;$i++) $template
navigation_bar($p_offset, $p_line, $p_size=0, $p_page=1, $p_javascript="")
Create a navigation_bar (pagesize)