65 $this->attribut=array();
71 $this->display_mode=
"window";
81 if ( ! in_array($p_mode,array(
"window",
"large"))) {
82 throw new Exception(
"FIC70 invalide display mode");
84 $this->display_mode=$p_mode;
97 $this->fiche_def=$p_fiche_def;
149 $sql_ledger=
$g_user->get_ledger_sql(
'FIN',3);
150 $avail=$this->
cn->get_array(
"select jrn_def_id,jrn_def_name,"
151 .
"jrn_def_bank,jrn_def_description,currency_id from jrn_def where jrn_def_type='FIN' and $sql_ledger
152 order by jrn_def_name");
161 $t->ledger_description=
$avail[
$i][
'jrn_def_description'];
162 $t->load_attribute();
181 if ( $p_qcode ==
null )
183 $p_qcode=trim($p_qcode);
184 $sql=
"select f_id from fiche_detail
185 where ad_id=23 and ad_value=upper($1)";
186 $this->
id=$this->
cn->get_value(
$sql,array($p_qcode));
187 if ( $this->
cn->count()==0)
214 if ( $this->fiche_def == 0)
throw new Exception (
"FICHE.179 Invalid category",
EXC_INVALID);
219 if ( $this->attribut[
$e]->ad_id == $p_ad_id )
221 $this->attribut[
$e]->av_text=$p_value;
248 function seek($p_attribut,$p_value)
250 $sql=
"select jft_id,f_id,fd_id,ad_id,ad_value from fiche join fiche_detail using (f_id)
251 where ad_id=$1 and upper(ad_value)=upper($2)";
252 $res=$this->
cn->get_array(
$sql,array($p_attribut,$p_value));
269 $this->
cn->search_sql_inject($p_sql);
271 if ( $p_search !=
"" )
273 $result = $this->
cn->get_value(
"select count(*) from
277 and vw_name ilike '%'||$2||'%'",
278 [$p_frd_id,$p_search]);
281 $result = $this->
cn->get_value(
"select count(*)
283 fiche join fiche_Def using (fd_id)
284 where frd_id=$1 ".$p_sql
312 $this->attribut_value.
"</TD>".
314 $this->attribut_def.
"</TD></TR>";
338 if ( empty ($this->attribut) )
344 foreach ($this->attribut as
$e)
346 if (
$e->ad_id == $p_ad_id )
359 if ( empty ($this->attribut)) {
362 foreach ($this->attribut as
$attr)
364 $a_return[
'av_text'.$attr->ad_id]=
$attr->av_text;
384 $r.=
'<table style="width:98%;margin:1%">';
398 return print_r($this,
true);
407 $type_card=$this->
cn->get_value(
'select fd_label '
408 .
' from fiche_def join fiche using (fd_id) where f_id=$1',
427 $ret.=
'<span style="margin-right:5px;float:right;font-size:80%">'.
428 _(
'id').
':'.$this->
id.
"</span>";
429 $ret.=
"<table style=\"width:98%;margin:1%\">";
441 $r->setDisplayMode($this->display_mode);
458 td(
_(
"Actif"),
'class="input_text"').
td($enable_is->input(),
'class="input_text"')
476 if ( $this->
id == 0 )
477 $this->
insert($p_fiche_def);
502 $this->fiche_def=$p_fiche_def;
511 $Ret=$this->
cn->exec_sql(
"insert into fiche(f_id,f_enable,fd_id) values ($1,$2,$3)",
516 $p_array[
'av_text'.ATTR_DEF_NAME]=
_(
"Nom vide");
519 $this->
cn->exec_sql(
"insert into fiche_detail (f_id,ad_id,ad_value) values ($1,$2,$3)",
525 $p_array[
"av_text".ATTR_DEF_QUICKCODE]=
"";
533 $base_acc=$this->
cn->get_value(
"select substr(fd_class_base,1,2) from fiche_def where fd_id = $1",
536 $p_array[
"av_text".ATTR_DEF_QUICKCODE]=sprintf(
"%s%s"
543 $this->
cn->exec_sql(
$sql);
549 if (empty($this->attribut))
551 throw new Exception(
"FICHE.UPDATE02".
_(
"Aucun attribut ").
"($p_fiche_def)",
EXC_INVALID);
554 foreach ($this->attribut as $property)
556 $key=
'av_text'.$property->ad_id;
571 $this->
cn->rollback();
572 throw (
new \Exception (
"F561 ". __CLASS__.
".".__FUNCTION__,561,
$e));
596 $this->fiche_def = $this->
cn->get_value(
"select fd_id from fiche where f_id=$1",[$this->
id]);
598 if ( empty($this->fiche_def)) {
599 throw new Exception(
'FICHE.UPDATE524 category not found',
EXC_INVALID);
601 if ( $this->
cn->size()==0) {
602 throw new Exception(
"FICHE.UPDATE01".
_(
"Fiche n'existe pas"),
EXC_INVALID);
609 if ( empty ($this->attribut) ) {
610 throw new Exception(
"FICHE.UPDATE02".
_(
"Aucun attribut ").
"($this->fiche_def)",
EXC_INVALID);
613 foreach($this->attribut as $property) {
614 $key=
'av_text'.$property->ad_id;
631 function remove($silent=
false)
633 if ( $this->
id==0 )
return;
637 if ( $this->
is_used() == FALSE) {
643 alert(
_(
'Impossible cette fiche est utilisée dans un journal'));
654 $sql=
"select ad_value from fiche_detail
655 where ad_id=1 and f_id=$1";
656 $Res=$this->
cn->exec_sql(
$sql,array($this->
id));
659 throw new Exception (
_(
"Fiche n'existe pas"), 1000);
660 return $r[0][
'ad_value'];
668 $sql=
"select ad_value from fiche_detail where ad_id=23 and f_id=$1";
669 $Res=$this->
cn->exec_sql(
$sql,array($this->
id));
671 if (
$r == FALSE ||
sizeof(
$r) == 0 )
673 return $r[0][
'ad_value'];
707 if ( $p_offset == -1 )
711 fiche join fiche_Def using (fd_id) join vw_fiche_name using(f_id)
712 where frd_id=".$this->fiche_def_ref.
" $p_search ".
$order;
716 $limit=($_SESSION[SESSION_KEY.
'g_pagesize']!=-1)?
"limit ".$_SESSION[SESSION_KEY.
'g_pagesize']:
"";
719 fiche join fiche_Def using (fd_id) join vw_fiche_name using(f_id)
720 where frd_id=".$this->fiche_def_ref.
" $p_search $order "
721 .$limit.
" offset ".$p_offset;
725 $Ret=$this->
cn->exec_sql(
$sql);
734 $t->load_attribute();
746 $result=$this->
cn->get_array(
"select frd_id from fiche join fiche_Def using (fd_id) where f_id=$1",[$this->
id]);
763 if (
$Max == 0 )
return null;
795 if ( $this->
id == 0 )
800 $filter_sql=
$g_user->get_ledger_sql(
'ALL',3);
807 $sql_let=
' and j1.j_id in (select j_id from letter_cred union select j_id from letter_deb)';
810 $sql_let=
' and j1.j_id not in (select j_id from letter_cred union select j_id from letter_deb) ';
815 $this->row=$this->
cn->get_array(
"
817 (select j_id,jl_id from letter_cred union all select j_id , jl_id from letter_deb )
818 select distinct substring(jr_pj_number,'[0-9]+$'),j1.j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,j_qcode,".
819 "case when j_debit='t' then j_montant else 0 end as deb_montant,".
820 "case when j_debit='f' then j_montant else 0 end as cred_montant,".
821 " jr_comment as description,jrn_def_name as jrn_name,j_poste,".
823 "j_debit, jr_internal,jr_id,(select distinct jl_id from sqlletter where sqlletter.j_id=j1.j_id ) as letter , ".
825 " jr_tech_per,p_exercice,jrn_def_name,
826 (with cred as (select jl_id, sum(j_montant) as amount_cred from letter_cred lc1 left join jrnx as j3 on (j3.j_id=lc1.j_id) group by jl_id ),
827 deb as (select jl_id, sum(j_montant) as amount_deb from letter_deb ld1 left join jrnx as j2 on (j2.j_id = ld1.j_id) group by jl_id )
828 select amount_deb-amount_cred
831 full join deb using (jl_id) where jl_id=(select distinct jl_id from sqlletter where sqlletter.j_id=j1.j_id )) as delta_letter,
834 jrn.currency_rate_ref,
836 (select cr_code_iso from currency where id=jrn.currency_id) as cr_code_iso,
838 sum_oc_amount as oc_amount,
839 sum_oc_vat_amount as oc_vat_amount ,
840 case when exists(select 1 from operation_analytique oa where j1.j_id=oa.j_id) then 1 else 0 end as op_analytic
841 from jrnx as j1 left join jrn_def on jrn_def_id=j_jrn_def
842 left join (select j_id,
843 coalesce(oc_amount,0) as sum_oc_amount ,
844 coalesce(oc_vat_amount,0) as sum_oc_vat_amount
845 from jrnx left join operation_currency using (j_id)
846 ) as v1 on (v1.j_id=j1.j_id )
847 left join jrn on jr_grpt_id=j_grpt".
848 " left join parm_periode on (p_id=jr_tech_per) ".
849 " where j_qcode=$1 and ".
850 " ( to_date($2,'DD.MM.YYYY') <= j_date and ".
851 " to_date($3,'DD.MM.YYYY') >= j_date )".
852 " and $filter_sql $sql_let ".
853 " order by j_date,substring(jr_pj_number,'[0-9]+$')",array(
$qcode,$p_from,$p_to));
855 $res_saldo = $this->
cn->exec_sql(
"select sum(deb_montant),sum(cred_montant) from
856 (select case when j_debit='t' then j_montant else 0 end as deb_montant,
857 case when j_debit='f' then j_montant else 0 end as cred_montant
859 join jrn_def on (jrn_def_id=j_jrn_def )
860 join jrn on (jr_grpt_id=j_grpt)
861 join tmp_pcmn on (j_poste=pcm_val)
862 join parm_periode on (p_id=jr_tech_per)
864 ( to_date($2,'DD.MM.YYYY') <= j_date and
865 to_date($3,'DD.MM.YYYY') >= j_date )
866 and $filter_sql $sql_let ) as m",array($this->
id,$p_from,$p_to));
867 $this->tot_deb=$this->tot_cred=0;
888 if ( $this->
id == 0 )
896 $this->row=$this->
cn->get_array(
"select j_date,
897 to_char(j_date,'DD.MM.YYYY') as j_date_fmt,
899 case when j_debit='t' then j_montant else 0 end as deb_montant,
900 case when j_debit='f' then j_montant else 0 end as cred_montant,
901 jr_comment as description,
902 jrn_def_name as jrn_name,
907 left join jrn_def on jrn_def_id=j_jrn_def
908 left join jrn on jr_grpt_id=j_grpt
910 j_qcode=$1 and {$periode}
911 order by j_date::date",array(
914 $res_saldo = $this->
cn->exec_sql(
"select sum(deb_montant),sum(cred_montant) from
915 (select case when j_debit='t' then j_montant else 0 end as deb_montant,
916 case when j_debit='f' then j_montant else 0 end as cred_montant
918 left join jrn_def on jrn_def_id=j_jrn_def
919 left join jrn on jr_grpt_id=j_grpt
921 j_qcode=$1 and {$periode} ) as m",
923 $this->tot_deb=$this->tot_cred=0;
929 return array($this->row,$this->tot_deb,$this->tot_cred);
949 if ( count($this->row ) == 0 )
954 $already_seen=array();
955 echo
'<h2 class="info">'.$this->id.
" ".
$name.
'</h2>';
956 echo
"<TABLE class=\"result\" style=\"width:100%;border-collapse:separate;border-spacing:5px\">";
958 "<TH>"._(
"n° de pièce / Code interne").
" </TH>".
959 "<TH>"._(
"Date").
"</TH>".
960 "<TH>"._(
"Description").
" </TH>".
961 "<TH>"._(
'Montant').
" </TH>".
962 "<TH> "._(
'Débit/Crédit').
" </TH>".
965 foreach ( $this->row as
$op )
967 if ( in_array(
$op[
'jr_internal'],$already_seen) )
970 $already_seen[]=
$op[
'jr_internal'];
971 echo
"<TR style=\"text-align:center;background-color:lightgrey\">".
972 "<td>".$op[
'jr_pj_number'].
" / ".
$op[
'jr_internal'].
"</td>".
973 "<td>".$op[
'j_date'].
"</td>".
974 "<td>".h(
$op[
'description']).
"</td>".
981 echo
$ac->display_jrnx_detail(1);
991 "<TD>$tot_cred</TD>".
1021 if ( count($this->row ) == 0 )
1031 $label.=
_(
"Solde créditeur au lieu de débiteur").
'<span class="icon"></span>';
1036 $label.=
_(
"Solde débiteur au lieu de créditeur").
" ".
'<span class="icon"></span>';
1039 echo
'<span class="notice" >'.$label.
'</span>';
1043 echo
"<TABLE id=\"tbpopup\" class=\"resultfooter\" style=\"margin:1%;width:98%;;border-collapse:collapse;border-spacing:0px 5px\">";
1047 echo
"<TABLE id=\"tb" .
$from_div .
"\"class=\"result\" style=\"margin:1%;width:98%;border-collapse:collapse;border-spacing:0px 2px\">";
1051 "<TH style=\"text-align:left\">"._(
'Date').
"</TH>".
1052 "<TH style=\"text-align:left\">"._(
'Pièce').
" </TH>".
1053 "<TH style=\"text-align:left\">"._(
'Poste').
" </TH>".
1054 "<TH style=\"text-align:left\">"._(
'Interne').
" </TH>".
1055 "<TH style=\"text-align:left\">"._(
'Tiers').
" </TH>".
1056 "<TH class=\"visible_gt800\" style=\"text-align:left\">"._(
'Description').
" </TH>".
1057 "<TH class=\"visible_gt800\" style=\"text-align:left\">"._(
'Type').
"</TH>".
1058 "<TH class=\"visible_gt800\" style=\"text-align:left\">"._(
'ISO').
"</TH>".
1059 "<TH class=\"visible_gt800\" style=\"text-align:right\">"._(
'Dev.').
"</TH>".
1060 "<TH style=\"text-align:right\">"._(
'Débit').
" </TH>".
1061 "<TH style=\"text-align:right\">"._(
'Crédit').
" </TH>".
1062 th(
'Prog.',
'style="text-align:right"').
1063 th(
'Let.',
'class="visible_gt800" style="text-align:right"');
1066 $old_exercice=
"";$sum_deb=0;$sum_cred=0;
1070 foreach ( $this->row as
$op )
1072 $vw_operation = sprintf(
'<A class="detail" style="text-decoration:underline;color:red" HREF="javascript:modifyOperation(\'%s\',\'%s\')" >%s</A>',
$op[
'jr_id'], dossier::id(),
$op[
'jr_internal']);
1075 if (
$op[
'letter'] !=
"")
1077 $let = strtoupper(base_convert(
$op[
'letter'], 10, 36));
1079 if (
$op[
'delta_letter'] != 0) $html_let=
'<img src="image/warning.png" onmouseover="displayBulle(\'delta = '.$op[
'delta_letter'].
'\')
" onmouseleave="hideBulle()
" style="height:12px
"/>'.$html_let;
1081 $tmp_diff=bcsub($op['deb_montant'],$op['cred_montant']);
1084 * reset prog. balance to zero if we change of exercice
1086 if ( $old_exercice != $op['p_exercice'])
1088 if ($old_exercice != '' )
1090 $progress=bcsub($sum_deb,$sum_cred);
1091 $side="
".$this->get_amount_side($progress);
1092 echo "<TR
class=\
"highlight\">".
1093 td(
$op[
'p_exercice']).
1094 td(
"",
' class="visible_gt800" ').
1095 td(
"",
' class="visible_gt800" ').
1096 td(
"",
' class="visible_gt800" ').
1099 td(
"",
' class="visible_gt800" ').
1100 td(
"",
' class="" ').
1102 "<TD style=\"text-align:right\">".nbm($sum_deb).
"</TD>".
1103 "<TD style=\"text-align:right\">".nbm($sum_cred).
"</TD>".
1105 td(
"",
' class="visible_gt800" ').
1114 $sum_cred=bcadd($sum_cred,
$op[
'cred_montant']);
1115 $sum_deb=bcadd($sum_deb,
$op[
'deb_montant']);
1120 $op_analytic=(
$op[
'op_analytic']==1)?
'<span style="float:right;background:black;color:white;">∋</span>':
'';
1121 echo
"<TR $class name=\"tr_" .
$let .
"_" .
$from_div .
"\">" .
1123 td(
h(
$op[
'jr_pj_number'])).
1125 "<TD>".$vw_operation.
"</TD>".
1126 td(
$tiers,
' class="visible_gt800" ').
1127 "<TD class=\"visible_gt800\" >".h(
$op[
'description']).$op_analytic.
"</TD>".
1128 td(
$op[
'jr_optype']);
1131 if (
$op[
'currency_id'] > 0 &&
$op[
'oc_amount'] != 0)
1133 echo
td(
$op[
'cr_code_iso'],
' class="visible_gt800" ').
1134 td(
nbm(
$op[
'oc_amount'],4),
' class="visible_gt800" style="text-align:right;padding-left:10px;"');
1136 echo
td(
"",
' class="visible_gt800" ').td(
"",
' class="visible_gt800" ');
1139 echo
"<TD style=\"text-align:right\">".nbm(
$op[
'deb_montant']).
"</TD>".
1140 "<TD style=\"text-align:right\">".nbm(
$op[
'cred_montant']).
"</TD>".
1142 td($html_let,
' style="text-align:right" class="visible_gt800" ') .
1144 $old_exercice=
$op[
'p_exercice'];
1147 $solde_type=($sum_deb>$sum_cred)?
_(
"solde débiteur"):
_(
"solde créditeur");
1148 $solde_side=($sum_deb>$sum_cred)?
"D":
"C";
1149 $diff=abs(bcsub($sum_deb,$sum_cred));
1151 echo
"<TR class=\"highlight\">".
1152 td(
$op[
'p_exercice']).
1153 td(
"",
' class="visible_gt800" ').
1154 td(
"",
' class="visible_gt800" ').
1155 td(
"",
' class="visible_gt800" ').
1158 td(
"",
' class="visible_gt800" ').
1159 td(
"",
' class="" ').
1161 "<TD style=\"text-align:right\">".nbm($sum_deb).
"</TD>".
1162 "<TD style=\"text-align:right\">".nbm($sum_cred).
"</TD>".
1163 "<TD style=\"text-align:right\">".nbm(
$diff).$solde_side.
"</TD>".
1164 td(
"",
' class="visible_gt800" ').
1166 echo
"<TR style=\"font-weight:bold\">".
1167 "<TD>$solde_type</TD>".
1168 "<TD style=\"text-align:right\">".nbm(
$diff).
"</TD>".
1173 $solde_until_now=$this->
get_solde_detail(
" j_date <= to_date('{$p_array['to_periode']}','DD.MM.YYYY') ");
1174 echo
'<tr style="font-weight:bold;color:orangered">';
1175 echo
td(
_(
"Solde global"));
1176 echo
td(
"D : ".
nbm($solde_until_now[
'debit']),
'class="num"');
1177 echo
td(
"C : ".
nbm($solde_until_now[
'credit']),
'class="num"');
1178 echo
td(
"Delta : ".
nbm($solde_until_now[
'solde']).
" ".$this->
get_amount_side($solde_until_now[
'debit']-$solde_until_now[
'credit']),
'class="num"');
1200 echo
'<div class="noprint">';
1204 echo
'<TD><form method="GET" ACTION="">'.
1205 HtmlInput::submit(
'bt_other',
_(
"Autre poste")).
1206 HtmlInput::array_to_hidden(array(
'gDossier',
'ac'),
$_REQUEST).
1208 $hid->input(
"type",
"poste").$hid->input(
'p_action',
'impress').
"</form></TD>";
1211 echo
'<TD><form method="GET" ACTION="export.php" ';
1212 $id=uniqid(
"export_");
1213 printf(
'id="%s" onsubmit="download_document_form(\'%s\')">',
$id,
$id);
1215 HtmlInput::submit(
'bt_pdf',
_(
"Export PDF")).
1216 dossier::hidden().$str_ople.
1217 HtmlInput::hidden(
'act',
'PDF:fichedetail').
1218 $hid->input(
"type",
"poste").
1219 $hid->input(
'p_action',
'impress').
1220 $hid->input(
"f_id",$this->
id).
1224 if (isset(
$p_array[
'oper_detail']))
1225 echo
$hid->input(
'oper_detail',
'on');
1227 echo
"</form></TD>";
1229 echo
'<TD><form method="GET" ACTION="export.php" ';
1230 $id=uniqid(
"export_");
1231 printf(
'id="%s" onsubmit="download_document_form(\'%s\')">',
$id,
$id);
1233 echo HtmlInput::submit(
'bt_csv',
_(
"Export CSV")).
1234 HtmlInput::hidden(
'act',
'CSV:fichedetail').
1235 dossier::hidden().$str_ople.
1236 $hid->input(
"type",
"poste").
1237 $hid->input(
'p_action',
'impress').
1238 $hid->input(
"f_id",$this->
id).
1241 if (isset(
$p_array[
'oper_detail']))
1242 echo
$hid->input(
'oper_detail',
'on');
1244 echo
"</form></TD>";
1245 echo
"</form></TD>";
1246 echo
'<td style="vertical-align:top">';
1247 echo HtmlInput::print_window();
1261 if ( $this->
id == 0 )
return array(
'credit'=>0,
'debit'=>0,
'solde'=>0);
1264 if ( $p_cond !=
"") $p_cond=
" and ".$p_cond;
1265 $Res=$this->
cn->exec_sql(
"select coalesce(sum(deb),0) as sum_deb,
1266 coalesce(sum(cred),0) as sum_cred from
1268 case when j_debit='t' then j_montant else 0 end as deb,
1269 case when j_debit='f' then j_montant else 0 end as cred
1272 j_qcode = ('$qcode'::text)
1276 if (
$Max==0)
return 0;
1279 return array(
'debit'=>
$r[
'sum_deb'],
1280 'credit'=>
$r[
'sum_cred'],
1281 'solde'=>abs(
$r[
'sum_deb']-
$r[
'sum_cred']));
1291 if ( $this->
id == 0 )
throw new Exception(
'fiche->id est nul');
1293 if ( $p_cond !=
"") $p_cond=
" and ".$p_cond;
1296 select sum(sum_oc_amount)
1302 $val=$this->
cn->get_value(
$sql,[$this->
id]);
1313 if ( $this->
id == 0 )
throw new Exception(
'fiche->id est nul');
1316 if ( $p_cond !=
"") $p_cond=
" and ".$p_cond;
1317 $sql=
"select sum(deb) as sum_deb, sum(cred) as sum_cred from
1319 case when j_debit='t' then j_montant else 0 end as deb,
1320 case when j_debit='f' then j_montant else 0 end as cred
1322 join jrn on (jr_grpt_id=j_grpt)
1324 j_qcode = ('$qcode'::text)
1330 if (
$Max==0)
return 0;
1333 return array(
'debit'=>
$r[
'sum_deb'],
1334 'credit'=>
$r[
'sum_cred'],
1335 'solde'=>abs(
$r[
'sum_deb']-
$r[
'sum_cred']));
1344 $sql=
"select ad_value
1347 left join attr_def using (ad_id) where f_id=$1 ".
1350 $res=$this->
cn->exec_sql(
$sql,[$this->
id,$p_attr]);
1378 $script=$_SERVER[
'PHP_SELF']??
"";
1383 $filter_year=
" j_tech_per in (select p_id from parm_periode ".
1384 "where p_exercice='".$g_user->get_exercice().
"')";
1387 $filter_amount =
' and f_id in (select f_id from jrnx where ' .
$filter_year .
')';
1390 $all_tiers=$this->
count_by_modele($this->fiche_def_ref,
"",$p_sql.$filter_amount);
1393 $page=
$http->request(
"page",
"number",1);
1402 (select distinct f_id from fiche_detail
1404 ad_id in (1,32,30,23,18,13) and ad_value ilike '%$p_search%')";
1409 if ( $all_tiers == 0 || empty($step_tiers ) ) {
return ""; }
1413 $r.=
'<table id="tiers_tb" class="sortable" style="">
1415 <TH>'._(
'Quick Code').Icon_Action::infobulle(17).
'</TH>'.
1416 '<th>'._(
'Poste comptable').
'</th>'.
1417 '<th class="sorttable_sorted">'._(
'Nom').
'</span>'.
'</th>'.
1418 '<th>'._(
'Compte en banque').
'</th>'.
1419 '<th>'._(
'Adresse').
'</th>'.
1420 '<th>'._(
'site web').
'</th>'.
1421 '<th style="text-align:right">'._(
'Total débit').
'</th>
1422 <th style="text-align:right">'.
_(
'Total crédit').
'</th>
1423 <th style="text-align:right">'.
_(
'Solde').
'</th>';
1425 if (
sizeof ($step_tiers ) == 0 )
1430 foreach ($step_tiers as
$tiers )
1436 list($l_from,$l_to)=(
new Periode($this->
cn))->get_limit(
$g_user->get_exercice());
1437 $condition = sprintf (
" j_date <= to_date('%s','DD.MM.YYYY') ", $l_to->last_day());
1444 if ( $p_amount &&
$amount[
'debit']==0 &&
$amount[
'credit'] == 0 &&
$amount[
'solde'] == 0 )
continue;
1447 $odd = (
$i % 2 == 0 ) ?
' odd ':
' even ';
1453 (!empty ($bank->value) && strpos(
$accounting,$bank->p_value)===0 )
1454 || (!empty ($cash->value) && strpos(
$accounting,$cash->p_value)===0 )
1455 || ( !empty ($cc->value) && strpos(
$accounting,$cc->p_value)===0)
1463 $odd=
' class="'.$odd.
'"';
1467 $e=sprintf(
'<A HREF="%s" title="Détail" class="line"> ',
1471 $r.=
"<TD sorttable_customkey=\"text{$accounting}\"> $e".$accounting.
"</TD>";
1482 $r.=
'<TD sorttable_customkey="'.$amount[
'debit'].
'" align="right"> '.$str_deb.
'</TD>';
1483 $r.=
'<TD sorttable_customkey="'.$amount[
'credit'].
'" align="right"> '.$str_cred.
'</TD>';
1495 $r.=
'<TD class="'.$red.
'" sorttable_customkey="'.
$amount[
'solde'].
'" align="right"> '.$str_solde.
"$side </TD>";
1505 $r.=
'<tr class="highlight">';
1506 $r.=
td(
"").td(
"").td(
"").td(
"").td(
"Totaux").td(
nbm(
$deb),
'class="num"').td(
nbm(
$cred),
'class="num"').td(
" $side ".
nbm(
$solde),
'class="num"');
1519 if ( $this->
id == 0 )
throw new Exception(
'class_fiche : f_id = 0 ');
1520 $sql=
'select fd_id from fiche where f_id=$1';
1521 $R=$this->
cn->get_value(
$sql, array($this->
id));
1525 $this->fiche_def=$R;
1548 if (($this->quick_code==
null || $this->quick_code ==
"" )
1551 throw new Exception(
'erreur ni quick_code ni f_id ne sont donnes');
1555 if ($this->quick_code ==
"") {
1560 if ($this->quick_code ==
null) {
1564 if ($this->
id == 0 && $this->
get_by_qcode(
null,
false) == 1) {
1568 if (
$side ==
'deb' )
1570 $Res=$this->
cn->exec_sql(
"select jrn_def_fiche_deb as fiche from jrn_def where jrn_def_id=$1",[$jrn_def_id]);
1573 $Res=$this->
cn->exec_sql(
"select jrn_def_fiche_cred as fiche from jrn_def where jrn_def_id=$1",[$jrn_def_id]);
1578 $Res=$this->
cn->exec_sql(
" select jrn_def_fiche_cred as fiche
1579 from jrn_def where jrn_def_id=$1
1581 select jrn_def_fiche_deb
1582 from jrn_def where jrn_def_id=$1",
1596 if (
$row[
'fiche'] !=
'' )
1598 $str_list.=$comma.$row[
'fiche'];
1612 fd_id in (".$str_list.
") and f_id= ".
$this->id;
1632 $cond_active=(
$inactive == 1)?
"":
" and f_enable='1' ";
1637 $sql=
"select f_id,ad_value from fiche join fiche_detail using (f_id)
1645 $sql=
"select f_id,ad_value from fiche join fiche_detail using (f_id)
1652 $sql=
"select f_id from fiche where fd_id=$1 $cond_active ";
1654 $array=$p_cn->get_array(
$sql,array($card_category_id));
1665 $sql=
'select count(*) as c from jrnx where j_qcode=$1';
1667 if (
$count > 0 )
return TRUE;
1668 $count=$this->
cn->get_value(
"select count(*) from action_gestion where f_id_dest=$1 or ag_contact=$1 ",
1670 if (
$count > 0 )
return TRUE;
1671 $count=$this->
cn->get_value(
"select count(*) from action_person where f_id=$1 ",
1673 if (
$count > 0 )
return TRUE;
1678 join fiche_detail using (ad_id)
1679 where ad_type='card'
1683 if (
$count > 0 )
return TRUE;
1694 $Res=$this->
cn->exec_sql(
"delete from fiche_detail
1696 f_id= $1",[ $this->
id] );
1699 $Res=$this->
cn->exec_sql(
"delete from fiche where f_id=$1",[$this->
id]);
1701 $this->
cn->commit();
1720 extract(
$array, EXTR_SKIP);
1722 $filter_fd_id=
'true';
1732 throw Exception(
'Erreur pas de valeur pour jrn');
1733 $filter_jrn=$this->
cn->make_list(
"select jrn_def_fiche_cred from jrn_Def where jrn_def_id=$1",
1735 $filter_fd_id=(empty($filter_jrn))?
" fd_id in (-1) ":
" fd_id in (".$filter_jrn.
")";
1740 throw Exception(
'Erreur pas de valeur pour jrn');
1741 $filter_jrn=$this->
cn->make_list(
"select jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
1743 $filter_fd_id=(empty($filter_jrn))?
"fd_id in (-1) ":
" fd_id in (".$filter_jrn.
")";
1748 throw Exception(
'Erreur pas de valeur pour jrn');
1749 $filter_jrn=$this->
cn->make_list(
"select jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
1753 $fp1=
" fd_id in (".$filter_jrn.
")";
1757 $filter_jrn=$this->
cn->make_list(
"select jrn_def_fiche_cred from jrn_Def where jrn_def_id=$1",
1761 $fp2=
" fd_id in (".$filter_jrn.
")";
1765 $filter_fd_id=
'('.$fp1.
' or '.$fp2.
')';
1770 $filter_fd_id=
' true';
1774 $filter_fd_id=
' fd_id in ('.$typecard.
')';
1776 $filter_fd_id=
' fd_id < 0';
1793 $filter_query=$and.
"(vw_name ilike '%$query%' or quick_code ilike ('%$query%') "
1794 .
" or vw_description ilike '%$query%' or tva_num ilike '%$query%' or accounting like upper('$query%'))";
1801 $sql=
"select * from vw_fiche_attr where ".$filter_fd_id.$filter_query;
1813 $this->
cn->exec_sql(
'update fiche set fd_id=$1 where f_id=$2',array($p_fdid,$this->
id));
1815 $this->
cn->exec_sql(
'select fiche_attribut_synchro($1)',array($p_fdid));
1817 $this->
cn->exec_sql(
"insert into jnt_fic_attr (fd_id,ad_id,jnt_order) select $1,ad_id,100 from fiche_detail where f_id=$2 and ad_id not in (select ad_id from jnt_fic_attr where fd_id=$3)",array($p_fdid,$this->
id,$p_fdid));
1818 $this->
cn->commit();
1836 $cn=Dossier::connect();
1838 echo
h1(
'Test select category');
1841 $select_cat->value=
$cn->make_array(
'select fd_id,fd_label from fiche_def where frd_id='.
1843 echo
'<FORM METHOD="GET"> ';
1844 echo dossier::hidden();
1845 echo HtmlInput::hidden(
'test_select',
$http->get(
'test_select',
"string",1));
1846 echo
'Choix de la catégorie';
1848 echo HtmlInput::submit(
'go_card',
'Afficher');
1850 if ( isset (
$_GET[
'go_card']))
1852 $empty=
$a->to_array(
$_GET[
'fd_id']);
1856 echo
h1(
"Insert new card");
1857 $name=
"test ".microtime();
1867 echo
p(print_r(
$fiche->to_array(),
false));
1875 echo
p(
"accounting id",$acc_accounting->get_parameter(
"id"));
1876 assert($acc_accounting->get_lib(
"pcm_lib") ==
$name,
"Cannot create a new accouting with
1897 $href=
"export.php?".http_build_query(
1899 "gDossier"=>Dossier::id(),
1903 "from_periode"=>$p_from,
1904 "to_periode"=>$p_to,
1905 "act"=>
"CSV:fichedetail"
1908 return '<a class="smallbutton" style="display:inline-block" href="'.$href.
'">'.
_(
"Export CSV").
'</a>';
1919 $href=
"export.php?".http_build_query(
1921 "gDossier"=>Dossier::id(),
1925 "from_periode"=>$p_from,
1926 "to_periode"=>$p_to,
1927 "act"=>
"PDF:fichedetail"
1930 return '<a class="smallbutton" style="display:inline-block" href="'.$href.
'">'.
_(
"Export PDF").
'</a>';
1940 return _(
'Cherche').
' '.HtmlInput::filter_table($p_table_id,
'0,1,2,3,4,5,6,7,8,9,10', 1);
1948 $id=$this->
cn->get_value(
"select jrn_def_id from jrn_def where jrn_def_bank = $1 ",[$this->
id]);
1949 if ($id ==
"") {
return NULL;}
1954 catch (Exception
$e) {
1969 foreach($this->attribut as
$attr) {
1972 if (
$attr->ad_type!=
'select')
1975 if (
$attr->ad_type==
"date") {
1977 $sort=
'sorttable_customkey="'.format_date(
$attr->av_text,
"DD.MM.YYYY",
"YYYYMMDD").
'"';
1980 $sort=
'sorttable_customkey="TEXT'.$attr->av_text.
'"';
1982 echo
td(
$attr->av_text,
'style="padding: 0 10 1 10;white-space:nowrap;" '.$sort);
1993 echo
td($row_content,
'style="padding: 0 10 1 10;white-space:nowrap;"');
2007 $card->get_by_qcode($p_qcode);
format_date($p_date, $p_from_format='YYYY-MM-DD', $p_to_format='DD.MM.YYYY')
format the date, when taken from the database the format is MM-DD-YYYY
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.
noalyss_strlentrim($p_string)
p($p_string, $p_extra='')
h1($p_string, $p_class="")
noalyss_str_replace($search, $replace, $string)
echo_error($p_log, $p_line="", $p_message="")
log error into the /tmp/noalyss_error.log it doesn't work on windows
tr($p_string, $p_extra='')
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...
sql_string($p_string)
Fix the problem with the quote char for the database.
td($p_string='', $p_extra='')
surround the string with td
nbm($p_number, $p_dec=2)
format the number with a sep.
cmpDate($p_date, $p_date_oth)
Compare 2 dates.
alert($p_msg, $buffer=false)
alert in javascript
global $g_user
if no group available , then stop
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
h( $row[ 'oa_description'])
if(trim($query)==''|| $filter=='') $search
if(isset( $_REQUEST[ 'show'])) if(isset($_REQUEST['del'])) $ac
_("actif, passif,charge,...")
if(! isset($_GET['submit_query'])) $p_action
$class
Display the Plugin and for each profile were it is installed or not.
Manage the account from the table jrn, jrnx or tmp_pcmn.
Manage the account from the table tmp_pcmn.
the class Acc_Ledger_Fin inherits from Acc_Ledger, this object permit to manage the financial ledger
this file match the tables jrn & jrnx the purpose is to remove or save accountant writing to these ta...
Manage the table parm_code which contains the custom parameter for the module accountancy.
static update(Fiche $p_fiche)
update all the data of the card , including f_enable. if we are in a transaction we don't commit here...
static load(Fiche $fiche)
Load all the attribute of a card , it modifies the parameter $fiche.
static fetch_result($ret, $p_row=0, $p_col=0)
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 fetch_all($ret, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_all
static num_row($ret)
wrapper for the function pg_num_rows
contains the class for connecting to Noalyss
define Class fiche and fiche def, those class are using class attribut
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
button_pdf($p_from, $p_to)
Return a string with the HTML code to display a button to export the history in PDF.
strAttribut($p_ad_id, $p_return=1)
use get_attribute instead
empty_attribute($p_attr)
check if an attribute is empty
get_row_date($p_from, $p_to, $op_let=0)
Get data for poste.
is_used()
check if a card is used
HtmlTableDetail($p_array=null, $op_let=0)
HtmlTable, display a HTML of a card for the asked period.
display_row()
display card as a table row , the tag TR must be added
static from_qcode(Database $cn, string $p_qcode)
create a card from a qcode and returns a card
$ledger_description
!< this variable is a mistake, it shouldn't exist, need code rewrite
insert($p_fiche_def, $p_array=null, $transaction=true)
insert a new record thanks an array , either as parameter or $_POST
get_categorie()
get the fd_id of the card : fd_id, it set the attribute fd_id
belong_ledger($jrn_def_id, $side="")
Check if a card can be used and then belong tp a specific ledger, it the card.
filter_history($p_table_id)
Filter in javascript the table with the history.
HtmlTable($p_array=null, $op_let=0, $from_div=1)
HtmlTable, display a HTML of a card for the asked period.
static cmp_name(Fiche $o1, Fiche $o2)
used with a usort function, to sort an array of Fiche on the name
update($p_array=null)
update a card with an array
get_row($p_from, $p_to)
Get data for poste.
__construct($p_cn, $p_id=0)
!< this variable is a mistake, it shouldn't exist, need code rewrite
move_to($p_fdid)
move a card to another cat.
set_fiche_def_ref($fiche_def_ref)
seek($p_attribut, $p_value)
find the card with the p_attribut equal to p_value, it is not case sensitive
static get_fiche_def($p_cn, $card_category_id, $p_order='', $inactive=1)
get all the card from a categorie
button_csv($p_from, $p_to)
Return a string with the HTML code to display a button to export the history in CSV.
set_attribute($p_ad_id, $p_value)
set an attribute by a value, if the attribut array is empty a call to load_attribute is performed
get_bank_ledger()
Returns the Acc_Ledger_Fin ledger for which the card is the default bank account or null if no ledger...
HtmlTableHeader($p_array=null)
Display HTML Table Header (button)
Get()
Synonum of fiche::load_attribute.
Display($p_readonly, $p_in="")
Display object instance, getAttribute sort the attribute and add missing ones.
get_bk_account()
get the available bank_account filtered by the security
save($p_fiche_def=0)
Save a card, call insert or update.
get_row_result_deprecated($res)
fetch and return and array
get_amount_side($p_amount)
return the letter C if amount is > 0, D if < 0 or =
count_by_modele($p_frd_id, $p_search="", $p_sql="")
Count the nb of card with the reference card id frd_id.
get_by_category($p_offset=-1, $p_search="", $p_order='')
get all the card thanks the fiche_def_ref
build_sql($array)
create the sql statement for retrieving all the card
get_by_qcode($p_qcode=null, $p_all=true)
Retrieve a card thx his quick_code complete the object,, set the id member of the object or set it to...
Summary($p_search="", $p_action="", $p_sql="", $p_amount=false)
show the default screen
get_fiche_def_ref_id()
retrieve the frd_id of the fiche it is the type of the card (bank, purchase...) (fiche_def_ref primar...
get_quick_code()
return the quick_code of a card
setAttribut($p_ad_id, $p_value)
replace by set_attribute
get_bk_balance_currency($p_cond="")
Get the sum in Currency.
GetByDef($p_frd_id, $p_offset=-1, $p_search="", $p_order='')
Return array of card from the frd family deprecated , use insert get_by_category_id.
getAttribut()
replace by load_attribute
load()
Synonum of fiche::load_attribute.
setDisplayMode($p_mode)
how the card is display : either in a window or a greated container
blank($p_fiche_def)
insert a new record show a blank card to be filled
get_attribute($p_ad_id, $p_return=1)
return the string of the given attribute (attr_def.ad_id)
set_fiche_def($p_fiche_def)
load_attribute()
get all the attribute of a card, add missing ones and sort the array ($this->attribut) by ad_id
getName()
return the name of a card
get_solde_detail($p_cond="")
give the balance of an card
to_array()
turn a card into an array , then it can be saved thanks update or insert
get_bk_balance($p_cond="")
get the bank balance with receipt or not in Euro
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
const NOTFOUND(!defined("SYSINFO_DISPLAY"))
const ATTR_DEF_FIRST_NAME
foreach( $Fiche->row as $op) $solde_type
if(count($array)==0) $acc_account_ledger
catch(\Exception $e) $bar
if( $delta< 0) elseif( $delta==0)
for($i=0;$i< count($aHeading);$i++) $sort
navigation_bar($p_offset, $p_line, $p_size=0, $p_page=1, $p_javascript="")
Create a navigation_bar (pagesize)
for($i=0;$i< $nb_jrn;$i++) $deb