63 $this->attribut=array();
69 $this->display_mode=
"window";
79 if ( ! in_array($p_mode,array(
"window",
"large"))) {
80 throw new Exception(
"FIC70 invalide display mode");
82 $this->display_mode=$p_mode;
95 $this->fiche_def=$p_fiche_def;
147 $sql_ledger=
$g_user->get_ledger_sql(
'FIN',3);
148 $avail=$this->
cn->get_array(
"select jrn_def_id,jrn_def_name,"
149 .
"jrn_def_bank,jrn_def_description,currency_id from jrn_def where jrn_def_type='FIN' and $sql_ledger
150 order by jrn_def_name");
158 $t->ledger_name=
$avail[
$i][
'jrn_def_name'];
159 $t->ledger_description=
$avail[
$i][
'jrn_def_description'];
179 if ( $p_qcode ==
null )
181 $p_qcode=trim($p_qcode);
182 $sql=
"select f_id from fiche_detail
183 where ad_id=23 and ad_value=upper($1)";
184 $this->
id=$this->
cn->get_value(
$sql,array($p_qcode));
185 if ( $this->
cn->count()==0)
205 if ( $this->fiche_def == 0)
throw new Exception (
"FICHE.179 Invalid category",
EXC_INVALID);
206 if (
sizeof($this->attribut)==0 ) $this->
getAttribut();
210 if ( $this->attribut[
$e]->ad_id == $p_ad_id )
212 $this->attribut[
$e]->av_text=$p_value;
231 function seek($p_attribut,$p_value)
233 $sql=
"select jft_id,f_id,fd_id,ad_id,ad_value from fiche join fiche_detail using (f_id)
234 where ad_id=$1 and upper(ad_value)=upper($2)";
235 $res=$this->
cn->get_array(
$sql,array($p_attribut,$p_value));
252 $this->
cn->search_sql_inject($p_sql);
254 if ( $p_search !=
"" )
256 $result = $this->
cn->get_value(
"select count(*) from
260 and vw_name ilike '%'||$2||'%'",
261 [$p_frd_id,$p_search]);
264 $result = $this->
cn->get_value(
"select count(*)
266 fiche join fiche_Def using (fd_id)
267 where frd_id=$1 ".$p_sql
295 $this->attribut_value.
"</TD>".
297 $this->attribut_def.
"</TD></TR>";
311 if ( empty ($this->attribut) )
317 foreach ($this->attribut as
$e)
319 if (
$e->ad_id == $p_ad_id )
332 if ( empty ($this->attribut)) {
335 foreach ($this->attribut as
$attr)
337 $a_return[
'av_text'.$attr->ad_id]=
$attr->av_text;
357 $r.=
'<table style="width:98%;margin:1%">';
371 return print_r($this,
true);
380 $type_card=$this->
cn->get_value(
'select fd_label '
381 .
' from fiche_def join fiche using (fd_id) where f_id=$1',
397 $this->GetAttribut();
400 $ret.=
'<span style="margin-right:5px;float:right;font-size:80%">'.
401 _(
'id').
':'.$this->
id.
"</span>";
402 $ret.=
"<table style=\"width:98%;margin:1%\">";
414 $r->setDisplayMode($this->display_mode);
431 td(_(
"Actif"),
'class="input_text"').
td($enable_is->input(),
'class="input_text"')
449 if ( $this->
id == 0 )
450 $this->
insert($p_fiche_def);
475 $this->fiche_def=$p_fiche_def;
484 $Ret=$this->
cn->exec_sql(
"insert into fiche(f_id,f_enable,fd_id) values ($1,$2,$3)",
489 $p_array[
'av_text'.ATTR_DEF_NAME]=_(
"Nom vide");
492 $this->
cn->exec_sql(
"insert into fiche_detail (f_id,ad_id,ad_value) values ($1,$2,$3)",
498 $p_array[
"av_text".ATTR_DEF_QUICKCODE]=
"";
502 $this->
cn->exec_sql(
$sql);
508 if (empty($this->attribut))
510 throw new Exception(
"FICHE.UPDATE02"._(
"Aucun attribut ").
"($p_fiche_def)",
EXC_INVALID);
513 foreach ($this->attribut as $property)
515 $key=
'av_text'.$property->ad_id;
530 $this->
cn->rollback();
555 $this->fiche_def = $this->
cn->get_value(
"select fd_id from fiche where f_id=$1",[$this->
id]);
557 if ( empty($this->fiche_def)) {
558 throw new Exception(
'FICHE.UPDATE524 category not found',
EXC_INVALID);
560 if ( $this->
cn->size()==0) {
561 throw new Exception(
"FICHE.UPDATE01"._(
"Fiche n'existe pas"),
EXC_INVALID);
568 if ( empty ($this->attribut) ) {
569 throw new Exception(
"FICHE.UPDATE02"._(
"Aucun attribut ").
"($this->fiche_def)",
EXC_INVALID);
572 foreach($this->attribut as $property) {
573 $key=
'av_text'.$property->ad_id;
590 function remove($silent=
false)
592 if ( $this->
id==0 )
return;
596 if ( $this->
is_used() == FALSE) {
602 alert(_(
'Impossible cette fiche est utilisée dans un journal'));
613 $sql=
"select ad_value from fiche_detail
614 where ad_id=1 and f_id=$1";
615 $Res=$this->
cn->exec_sql(
$sql,array($this->
id));
618 throw new Exception (_(
"Fiche n'existe pas"), 1000);
619 return $r[0][
'ad_value'];
627 $sql=
"select ad_value from fiche_detail where ad_id=23 and f_id=$1";
628 $Res=$this->
cn->exec_sql(
$sql,array($this->
id));
630 if (
$r == FALSE ||
sizeof(
$r) == 0 )
632 return $r[0][
'ad_value'];
666 if ( $p_offset == -1 )
670 fiche join fiche_Def using (fd_id) join vw_fiche_name using(f_id)
671 where frd_id=".$this->fiche_def_ref.
" $p_search ".
$order;
675 $limit=($_SESSION[SESSION_KEY.
'g_pagesize']!=-1)?
"limit ".$_SESSION[SESSION_KEY.
'g_pagesize']:
"";
678 fiche join fiche_Def using (fd_id) join vw_fiche_name using(f_id)
679 where frd_id=".$this->fiche_def_ref.
" $p_search $order "
680 .$limit.
" offset ".$p_offset;
684 $Ret=$this->
cn->exec_sql(
$sql);
692 $t=
new Fiche($this->
cn,$row[
'f_id']);
705 $result=$this->
cn->get_array(
"select frd_id from fiche join fiche_Def using (fd_id) where f_id=$1",[$this->
id]);
722 if (
$Max == 0 )
return null;
754 if ( $this->
id == 0 )
759 $filter_sql=
$g_user->get_ledger_sql(
'ALL',3);
766 $sql_let=
' and j_id in (select j_id from letter_cred union select j_id from letter_deb)';
769 $sql_let=
' and j_id not in (select j_id from letter_cred union select j_id from letter_deb) ';
774 $this->row=$this->
cn->get_array(
"
776 (select j_id,jl_id from letter_cred union all select j_id , jl_id from letter_deb )
777 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,".
778 "case when j_debit='t' then j_montant else 0 end as deb_montant,".
779 "case when j_debit='f' then j_montant else 0 end as cred_montant,".
780 " jr_comment as description,jrn_def_name as jrn_name,j_poste,".
782 "j_debit, jr_internal,jr_id,(select distinct jl_id from sqlletter where sqlletter.j_id=j1.j_id ) as letter , ".
784 " jr_tech_per,p_exercice,jrn_def_name,
785 (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 ),
786 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 )
787 select amount_deb-amount_cred
790 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,
793 jrn.currency_rate_ref,
795 (select cr_code_iso from currency where id=jrn.currency_id) as cr_code_iso,
797 sum_oc_amount as oc_amount,
798 sum_oc_vat_amount as oc_vat_amount ,
799 case when exists(select 1 from operation_analytique oa where j1.j_id=oa.j_id) then 1 else 0 end as op_analytic
800 from jrnx as j1 left join jrn_def on jrn_def_id=j_jrn_def
801 left join (select j_id,
802 coalesce(oc_amount,0) as sum_oc_amount ,
803 coalesce(oc_vat_amount,0) as sum_oc_vat_amount
804 from jrnx left join operation_currency using (j_id)
805 ) as v1 on (v1.j_id=j1.j_id )
806 left join jrn on jr_grpt_id=j_grpt".
807 " left join parm_periode on (p_id=jr_tech_per) ".
808 " where j_qcode=$1 and ".
809 " ( to_date($2,'DD.MM.YYYY') <= j_date and ".
810 " to_date($3,'DD.MM.YYYY') >= j_date )".
811 " and $filter_sql $sql_let ".
812 " order by j_date,substring(jr_pj_number,'[0-9]+$')",array(
$qcode,$p_from,$p_to));
814 $res_saldo = $this->
cn->exec_sql(
"select sum(deb_montant),sum(cred_montant) from
815 (select case when j_debit='t' then j_montant else 0 end as deb_montant,
816 case when j_debit='f' then j_montant else 0 end as cred_montant
818 join jrn_def on (jrn_def_id=j_jrn_def )
819 join jrn on (jr_grpt_id=j_grpt)
820 join tmp_pcmn on (j_poste=pcm_val)
821 join parm_periode on (p_id=jr_tech_per)
823 ( to_date($2,'DD.MM.YYYY') <= j_date and
824 to_date($3,'DD.MM.YYYY') >= j_date )
825 and $filter_sql $sql_let ) as m",array($this->
id,$p_from,$p_to));
826 $this->tot_deb=$this->tot_cred=0;
847 if ( $this->
id == 0 )
855 $this->row=$this->
cn->get_array(
"select j_date,
856 to_char(j_date,'DD.MM.YYYY') as j_date_fmt,
858 case when j_debit='t' then j_montant else 0 end as deb_montant,
859 case when j_debit='f' then j_montant else 0 end as cred_montant,
860 jr_comment as description,
861 jrn_def_name as jrn_name,
866 left join jrn_def on jrn_def_id=j_jrn_def
867 left join jrn on jr_grpt_id=j_grpt
869 j_qcode=$1 and {$periode}
870 order by j_date::date",array(
873 $res_saldo = $this->
cn->exec_sql(
"select sum(deb_montant),sum(cred_montant) from
874 (select case when j_debit='t' then j_montant else 0 end as deb_montant,
875 case when j_debit='f' then j_montant else 0 end as cred_montant
877 left join jrn_def on jrn_def_id=j_jrn_def
878 left join jrn on jr_grpt_id=j_grpt
880 j_qcode=$1 and {$periode} ) as m",
882 $this->tot_deb=$this->tot_cred=0;
888 return array($this->row,$this->tot_deb,$this->tot_cred);
908 if ( count($this->row ) == 0 )
913 $already_seen=array();
914 echo
'<h2 class="info">'.$this->id.
" ".
$name.
'</h2>';
915 echo
"<TABLE class=\"result\" style=\"width:100%;border-collapse:separate;border-spacing:5px\">";
917 "<TH>"._(
"n° de pièce / Code interne").
" </TH>".
918 "<TH>"._(
"Date").
"</TH>".
919 "<TH>"._(
"Description").
" </TH>".
920 "<TH>"._(
'Montant').
" </TH>".
921 "<TH> "._(
'Débit/Crédit').
" </TH>".
924 foreach ( $this->row as
$op )
926 if ( in_array(
$op[
'jr_internal'],$already_seen) )
929 $already_seen[]=
$op[
'jr_internal'];
930 echo
"<TR style=\"text-align:center;background-color:lightgrey\">".
931 "<td>".$op[
'jr_pj_number'].
" / ".
$op[
'jr_internal'].
"</td>".
932 "<td>".$op[
'j_date'].
"</td>".
933 "<td>".h(
$op[
'description']).
"</td>".
938 $ac->jr_id=$op[
'jr_id'];
940 echo
$ac->display_jrnx_detail(1);
950 "<TD>$tot_cred</TD>".
980 if ( count($this->row ) == 0 )
986 echo
"<TABLE id=\"tbpopup\" class=\"resultfooter\" style=\"margin:1%;width:98%;;border-collapse:collapse;border-spacing:0px 5px\">";
990 echo
"<TABLE id=\"tb" .
$from_div .
"\"class=\"result\" style=\"margin:1%;width:98%;border-collapse:collapse;border-spacing:0px 2px\">";
994 "<TH style=\"text-align:left\">"._(
'Date').
"</TH>".
995 "<TH style=\"text-align:left\">"._(
'Pièce').
" </TH>".
996 "<TH style=\"text-align:left\">"._(
'Poste').
" </TH>".
997 "<TH style=\"text-align:left\">"._(
'Interne').
" </TH>".
998 "<TH style=\"text-align:left\">"._(
'Tiers').
" </TH>".
999 "<TH style=\"text-align:left\">"._(
'Description').
" </TH>".
1000 "<TH style=\"text-align:left\">"._(
'Type').
"</TH>".
1001 "<TH style=\"text-align:left\">"._(
'ISO').
"</TH>".
1002 "<TH style=\"text-align:right\">"._(
'Dev.').
"</TH>".
1003 "<TH style=\"text-align:right\">"._(
'Débit').
" </TH>".
1004 "<TH style=\"text-align:right\">"._(
'Crédit').
" </TH>".
1005 th(
'Prog.',
'style="text-align:right"').
1006 th(
'Let.',
'style="text-align:right"');
1009 $old_exercice=
"";$sum_deb=0;$sum_cred=0;
1013 foreach ( $this->row as
$op )
1015 $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']);
1018 if (
$op[
'letter'] !=
"")
1020 $let = strtoupper(base_convert(
$op[
'letter'], 10, 36));
1022 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;
1024 $tmp_diff=bcsub($op['deb_montant'],$op['cred_montant']);
1027 * reset prog. balance to zero if we change of exercice
1029 if ( $old_exercice != $op['p_exercice'])
1031 if ($old_exercice != '' )
1033 $progress=bcsub($sum_deb,$sum_cred);
1034 $side="
".$this->get_amount_side($progress);
1035 echo "<TR
class=\
"highlight\">".
1036 "<TD>$old_exercice</TD>".
1044 "<TD style=\"text-align:right\">".nbm($sum_deb).
"</TD>".
1045 "<TD style=\"text-align:right\">".nbm($sum_cred).
"</TD>".
1056 $sum_cred=bcadd($sum_cred,
$op[
'cred_montant']);
1057 $sum_deb=bcadd($sum_deb,
$op[
'deb_montant']);
1062 $op_analytic=(
$op[
'op_analytic']==1)?
'<span style="float:right;background:black;color:white;">∋</span>':
'';
1063 echo
"<TR $class name=\"tr_" .
$let .
"_" .
$from_div .
"\">" .
1065 td(
h(
$op[
'jr_pj_number'])).
1067 "<TD>".$vw_operation.
"</TD>".
1069 "<TD>".h(
$op[
'description']).$op_analytic.
"</TD>".
1070 td(
$op[
'jr_optype']);
1073 if (
$op[
'currency_id'] > 0 &&
$op[
'oc_amount'] != 0)
1075 echo
td(
$op[
'cr_code_iso']).
1076 td(
nbm(
$op[
'oc_amount'],4),
'style="text-align:right;padding-left:10px;"');
1081 echo
"<TD style=\"text-align:right\">".nbm(
$op[
'deb_montant']).
"</TD>".
1082 "<TD style=\"text-align:right\">".nbm(
$op[
'cred_montant']).
"</TD>".
1084 td($html_let,
' style="text-align:right"') .
1086 $old_exercice=
$op[
'p_exercice'];
1089 $solde_type=_(
"Année ").($sum_deb>$sum_cred)?_(
"solde débiteur"):_(
"solde créditeur");
1090 $solde_side=($sum_deb>$sum_cred)?
"D":
"C";
1091 $diff=abs(bcsub($sum_deb,$sum_cred));
1093 echo
"<TR class=\"highlight\">".
1094 td(
$op[
'p_exercice']).
1103 "<TD style=\"text-align:right\">".nbm($sum_deb).
"</TD>".
1104 "<TD style=\"text-align:right\">".nbm($sum_cred).
"</TD>".
1105 "<TD style=\"text-align:right\">".nbm(
$diff).
"</TD>".
1108 echo
"<TR style=\"font-weight:bold\">".
1109 "<TD>$solde_type</TD>".
1110 "<TD style=\"text-align:right\">".nbm(
$diff).
"</TD>".
1115 $solde_until_now=$this->
get_solde_detail(
" j_date <= to_date('{$p_array['to_periode']}','DD.MM.YYYY') ");
1116 echo
'<tr style="font-weight:bold;color:orangered">';
1117 echo
td(_(
"Solde global"));
1118 echo
td(
"D : ".
nbm($solde_until_now[
'debit']),
'class="num"');
1119 echo
td(
"C : ".
nbm($solde_until_now[
'credit']),
'class="num"');
1120 echo
td(
"Delta : ".
nbm($solde_until_now[
'solde']).
" ".$this->
get_amount_side($solde_until_now[
'debit']-$solde_until_now[
'credit']),
'class="num"');
1142 echo
'<div class="noprint">';
1146 echo
'<TD><form method="GET" ACTION="">'.
1150 $hid->input(
"type",
"poste").$hid->input(
'p_action',
'impress').
"</form></TD>";
1153 echo
'<TD><form method="GET" ACTION="export.php" ';
1154 $id=uniqid(
"export_");
1155 printf(
'id="%s" onsubmit="download_document_form(\'%s\')">',
$id,
$id);
1158 dossier::hidden().$str_ople.
1160 $hid->input(
"type",
"poste").
1161 $hid->input(
'p_action',
'impress').
1162 $hid->input(
"f_id",$this->
id).
1166 if (isset(
$p_array[
'oper_detail']))
1167 echo
$hid->input(
'oper_detail',
'on');
1169 echo
"</form></TD>";
1171 echo
'<TD><form method="GET" ACTION="export.php" ';
1172 $id=uniqid(
"export_");
1173 printf(
'id="%s" onsubmit="download_document_form(\'%s\')">',
$id,
$id);
1177 dossier::hidden().$str_ople.
1178 $hid->input(
"type",
"poste").
1179 $hid->input(
'p_action',
'impress').
1180 $hid->input(
"f_id",$this->
id).
1183 if (isset(
$p_array[
'oper_detail']))
1184 echo
$hid->input(
'oper_detail',
'on');
1186 echo
"</form></TD>";
1187 echo
"</form></TD>";
1188 echo
'<td style="vertical-align:top">';
1203 if ( $this->
id == 0 )
return array(
'credit'=>0,
'debit'=>0,
'solde'=>0);
1206 if ( $p_cond !=
"") $p_cond=
" and ".$p_cond;
1207 $Res=$this->
cn->exec_sql(
"select coalesce(sum(deb),0) as sum_deb,
1208 coalesce(sum(cred),0) as sum_cred from
1210 case when j_debit='t' then j_montant else 0 end as deb,
1211 case when j_debit='f' then j_montant else 0 end as cred
1214 j_qcode = ('$qcode'::text)
1218 if (
$Max==0)
return 0;
1221 return array(
'debit'=>
$r[
'sum_deb'],
1222 'credit'=>
$r[
'sum_cred'],
1223 'solde'=>abs(
$r[
'sum_deb']-
$r[
'sum_cred']));
1233 if ( $this->
id == 0 )
throw new Exception(
'fiche->id est nul');
1235 if ( $p_cond !=
"") $p_cond=
" and ".$p_cond;
1238 select sum(sum_oc_amount)
1255 if ( $this->
id == 0 )
throw new Exception(
'fiche->id est nul');
1258 if ( $p_cond !=
"") $p_cond=
" and ".$p_cond;
1259 $sql=
"select sum(deb) as sum_deb, sum(cred) as sum_cred from
1261 case when j_debit='t' then j_montant else 0 end as deb,
1262 case when j_debit='f' then j_montant else 0 end as cred
1264 join jrn on (jr_grpt_id=j_grpt)
1266 j_qcode = ('$qcode'::text)
1272 if (
$Max==0)
return 0;
1275 return array(
'debit'=>
$r[
'sum_deb'],
1276 'credit'=>
$r[
'sum_cred'],
1277 'solde'=>abs(
$r[
'sum_deb']-
$r[
'sum_cred']));
1286 $sql=
"select ad_value
1289 left join attr_def using (ad_id) where f_id=$1 ".
1292 $res=$this->
cn->exec_sql(
$sql,[$this->
id,$p_attr]);
1326 $filter_year=
" j_tech_per in (select p_id from parm_periode ".
1327 "where p_exercice='".$g_user->get_exercice().
"')";
1329 if ( $p_amount) $filter_amount=
' and f_id in (select f_id from jrnx where '.$filter_year.
')';
1331 $all_tiers=$this->count_by_modele($this->fiche_def_ref,
"",$p_sql.$filter_amount);
1347 $search.=
" and f_id in
1348 (select distinct f_id from fiche_detail
1350 ad_id in (1,32,30,23,18,13) and ad_value ilike '%$p_search%')";
1353 $step_tiers=$this->get_by_category(
$offset,$search.$filter_amount,
'name');
1355 if ( $all_tiers == 0 || empty($step_tiers ) ) {
return ""; }
1359 $r.=
'<table id="tiers_tb" class="sortable" style="">
1361 <TH>'._(
'Quick Code').Icon_Action::infobulle(17).
'</TH>'.
1362 '<th>'._(
'Poste comptable').
'</th>'.
1363 '<th class="sorttable_sorted">'._(
'Nom').
'</span>'.
'</th>
1364 <th>'._(
'Adresse').
'</th>
1365 <th>'._(
'site web').
'</th>
1366 <th style="text-align:right">'._(
'Total débit').
'</th>
1367 <th style="text-align:right">'._(
'Total crédit').
'</th>
1368 <th style="text-align:right">'._(
'Solde').
'</th>';
1370 if (
sizeof ($step_tiers ) == 0 )
1375 foreach ($step_tiers as
$tiers )
1387 if ( $p_amount &&
$amount[
'debit']==0 &&
$amount[
'credit'] == 0 &&
$amount[
'solde'] == 0 )
continue;
1390 $odd = (
$i % 2 == 0 ) ?
' odd ':
' even ';
1396 (!empty ($bank->value) && strpos(
$accounting,$bank->p_value)===0 )
1397 || (!empty ($cash->value) && strpos(
$accounting,$cash->p_value)===0 )
1398 || ( !empty ($cc->value) && strpos(
$accounting,$cc->p_value)===0)
1406 $odd=
' class="'.$odd.
'"';
1410 $e=sprintf(
'<A HREF="%s" title="Détail" class="line"> ',
1414 $r.=
"<TD sorttable_customkey=\"text{$accounting}\"> $e".$accounting.
"</TD>";
1424 $r.=
'<TD sorttable_customkey="'.$amount[
'debit'].
'" align="right"> '.$str_deb.
'</TD>';
1425 $r.=
'<TD sorttable_customkey="'.$amount[
'credit'].
'" align="right"> '.$str_cred.
'</TD>';
1437 $r.=
'<TD class="'.$red.
'" sorttable_customkey="'.
$amount[
'solde'].
'" align="right"> '.$str_solde.
"$side </TD>";
1447 $r.=
'<tr class="highlight">';
1448 $r.=
td(
"").td(
"").td(
"").td(
"").td(
"Totaux").td(
nbm(
$deb),
'class="num"').td(
nbm(
$cred),
'class="num"').td(
" $side ".
nbm(
$solde),
'class="num"');
1461 if ( $this->
id == 0 )
throw new Exception(
'class_fiche : f_id = 0 ');
1462 $sql=
'select fd_id from fiche where f_id=$1';
1463 $R=$this->
cn->get_value(
$sql, array($this->
id));
1488 if (($this->quick_code==
null || $this->quick_code ==
"" )
1491 throw new Exception(
'erreur ni quick_code ni f_id ne sont donnes');
1495 if ( $this->quick_code==
"")
1496 $this->quick_code=$this->get_quick_code();
1499 if ( $this->quick_code==
null)
1502 if ( $this->
id == 0 )
1503 if ( $this->get_by_qcode(
null,
false) == 1)
1509 $get=
'jrn_def_fiche_deb';
1512 $get=
'jrn_def_fiche_cred';
1516 $Res=$this->
cn->exec_sql(
"select $get as fiche from jrn_def where jrn_def_id=$p_jrn");
1521 $Res=$this->
cn->exec_sql(
" select jrn_def_fiche_cred as fiche
1522 from jrn_def where jrn_def_id=$p_jrn
1524 select jrn_def_fiche_deb
1525 from jrn_def where jrn_def_id=$p_jrn"
1539 if (
$row[
'fiche'] !=
'' )
1541 $str_list.=$comma.$row[
'fiche'];
1555 fd_id in (".$str_list.
") and f_id= ".
$this->id;
1575 $sql=
'select f_id,ad_value from fiche join fiche_detail using (f_id) where ad_id=1 and fd_id=$1 order by 2 asc';
1578 $sql=
'select f_id,ad_value from fiche join fiche_detail using (f_id) where ad_id=1 and fd_id=$1 order by 2 desc';
1581 $sql=
'select f_id from fiche where fd_id=$1 ';
1583 $array=$p_cn->get_array(
$sql,array($pFd_id));
1594 $sql=
'select count(*) as c from jrnx where j_qcode=$1';
1596 if (
$count > 0 )
return TRUE;
1597 $count=$this->
cn->get_value(
"select count(*) from action_gestion where f_id_dest=$1 or ag_contact=$1 ",
1599 if (
$count > 0 )
return TRUE;
1600 $count=$this->
cn->get_value(
"select count(*) from action_person where f_id=$1 ",
1602 if (
$count > 0 )
return TRUE;
1607 join fiche_detail using (ad_id)
1608 where ad_type='card'
1612 if (
$count > 0 )
return TRUE;
1623 $Res=$this->
cn->exec_sql(
"delete from fiche_detail
1625 f_id= $1",[ $this->
id] );
1628 $Res=$this->
cn->exec_sql(
"delete from fiche where f_id=$1",[$this->
id]);
1630 $this->
cn->commit();
1649 extract(
$array, EXTR_SKIP);
1651 $filter_fd_id=
'true';
1661 throw Exception(
'Erreur pas de valeur pour jrn');
1662 $filter_jrn=$this->
cn->make_list(
"select jrn_def_fiche_cred from jrn_Def where jrn_def_id=$1",
1664 $filter_fd_id=(empty($filter_jrn))?
" fd_id in (-1) ":
" fd_id in (".$filter_jrn.
")";
1669 throw Exception(
'Erreur pas de valeur pour jrn');
1670 $filter_jrn=$this->
cn->make_list(
"select jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
1672 $filter_fd_id=(empty($filter_jrn))?
"fd_id in (-1) ":
" fd_id in (".$filter_jrn.
")";
1677 throw Exception(
'Erreur pas de valeur pour jrn');
1678 $filter_jrn=$this->
cn->make_list(
"select jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
1682 $fp1=
" fd_id in (".$filter_jrn.
")";
1686 $filter_jrn=$this->cn->make_list(
"select jrn_def_fiche_cred from jrn_Def where jrn_def_id=$1",
1690 $fp2=
" fd_id in (".$filter_jrn.
")";
1694 $filter_fd_id=
'('.$fp1.
' or '.$fp2.
')';
1699 $filter_fd_id=
' true';
1703 $filter_fd_id=
' fd_id in ('.
$typecard.
')';
1705 $filter_fd_id=
' fd_id < 0';
1722 $filter_query=$and.
"(vw_name ilike '%$query%' or quick_code ilike ('%$query%') "
1723 .
" or vw_description ilike '%$query%' or tva_num ilike '%$query%' or accounting like upper('$query%'))";
1730 $sql=
"select * from vw_fiche_attr where ".$filter_fd_id.$filter_query;
1742 $this->
cn->exec_sql(
'update fiche set fd_id=$1 where f_id=$2',array($p_fdid,$this->
id));
1744 $this->
cn->exec_sql(
'select fiche_attribut_synchro($1)',array($p_fdid));
1746 $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));
1747 $this->
cn->commit();
1767 echo
h1(
'Test select category');
1770 $select_cat->value=
$cn->make_array(
'select fd_id,fd_label from fiche_def where frd_id='.
1772 echo
'<FORM METHOD="GET"> ';
1773 echo dossier::hidden();
1775 echo
'Choix de la catégorie';
1779 if ( isset (
$_GET[
'go_card']))
1781 $empty=
$a->to_array(
$_GET[
'fd_id']);
1785 echo
h1(
"Insert new card");
1786 $name=
"test ".microtime();
1796 echo
p(print_r(
$fiche->to_array(),
false));
1804 echo
p(
"accounting id",$acc_accounting->get_parameter(
"id"));
1805 assert($acc_accounting->get_lib(
"pcm_lib") ==
$name,
"Cannot create a new accouting with
1811 $r =
"<h2 id=\"gestion_title\">" .
h($this->getName()) .
" " .
h($this->strAttribut(
ATTR_DEF_FIRST_NAME,0)) .
'[' . $this->get_quick_code() .
']</h2>';
1826 $href=
"export.php?".http_build_query(
1832 "from_periode"=>$p_from,
1833 "to_periode"=>$p_to,
1834 "act"=>
"CSV:fichedetail"
1837 return '<a class="smallbutton" style="display:inline-block" href="'.$href.
'">'._(
"Export CSV").
'</a>';
1848 $href=
"export.php?".http_build_query(
1854 "from_periode"=>$p_from,
1855 "to_periode"=>$p_to,
1856 "act"=>
"PDF:fichedetail"
1859 return '<a class="smallbutton" style="display:inline-block" href="'.$href.
'">'._(
"Export PDF").
'</a>';
1869 return _(
'Cherche').
' '.
HtmlInput::filter_table($p_table_id,
'0,1,2,3,4,5,6,7,8,9,10', 1);
1877 $id=$this->
cn->get_value(
"select jrn_def_id from jrn_def where jrn_def_bank = $1 ",[$this->
id]);
1878 if ($id ==
"") {
return NULL;}
1883 catch (Exception
$e) {
1897 $this->getAttribut();
1898 foreach($this->attribut as
$attr) {
1901 if (
$attr->ad_type!=
'select')
1904 if (
$attr->ad_type==
"date") {
1906 $sort=
'sorttable_customkey="'.format_date(
$attr->av_text,
"DD.MM.YYYY",
"YYYYMMDD").
'"';
1909 $sort=
'sorttable_customkey="TEXT'.$attr->av_text.
'"';
1911 echo
td(
$attr->av_text,
'style="padding: 0 10 1 10;white-space:nowrap;" '.$sort);
1914 $value=$this->
cn->make_array($attr->ad_extra);
1922 echo
td($row_content,
'style="padding: 0 10 1 10;white-space:nowrap;"');
1936 $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)
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.
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(!headers_sent())
– pour utiliser unoconv démarrer un server libreoffice commande libreoffice –headless –accept="socket...
catch(Exception $e) $exercice
if(isset( $_REQUEST[ 'show'])) if(isset($_REQUEST['del'])) $ac
if(! isset($_GET['submit_query'])) $p_action
if($action=='add_line') if( $action=='remove_line') if($action=='remove_cat') if(isset($_POST['change_name'])) if($action=='save_line') if(isset($_POST['add_modele'])) $fiche_def
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_all($ret)
wrapper for the function pg_fetch_all
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 num_row($ret)
wrapper for the function pg_num_rows
static id()
return the 'gDossier' value after a check
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)
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
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
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
belong_ledger($p_jrn, $p_type="")
Check if a fiche is used by a jrn return 1 if the fiche is in the range otherwise 0,...
get_row($p_from, $p_to)
Get data for poste.
__construct($p_cn, $p_id=0)
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 from_qcode($p_qcode)
create a card from a qcode and returns a card
button_csv($p_from, $p_to)
Return a string with the HTML code to display a button to export the history in CSV.
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::getAttribut.
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)
set an attribute by a value, if the attribut array is empty a call to getAttribut is performed
static get_fiche_def($p_cn, $pFd_id, $p_order='')
get all the card from a categorie
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()
get all the attribute of a card, add missing ones and sort the array ($this->attribut) by ad_id
load()
Synonum of fiche::getAttribut.
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
set_fiche_def($p_fiche_def)
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...
For the periode tables parm_periode and jrn_periode.
const NOTFOUND(!defined("SYSINFO_DISPLAY"))
const ATTR_DEF_FIRST_NAME
foreach( $Fiche->row as $op) $solde_type
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